{"id":116827,"date":"2026-10-22T06:24:40","date_gmt":"2026-10-21T22:24:40","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/116827.html"},"modified":"2026-10-22T06:24:40","modified_gmt":"2026-10-21T22:24:40","slug":"rag%e8%af%84%e6%b5%8b-faithfulness%e8%af%84%e5%88%86","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/116827.html","title":{"rendered":"Rag\u8bc4\u6d4b-faithfulness\u8bc4\u5206"},"content":{"rendered":"<p>\u5f00\u59cb\u8fdb\u5165\u5230ragas\u7684\u6253\u5206\u73af\u8282\u4e86&#xff0c;\u9996\u5148\u8fdb\u884c\u4e2a\u4eba\u8ba4\u4e3a\u6700\u91cd\u8981\u7684faithfulness&#xff0c;\u4e5f\u5c31\u662f\u53ef\u4fe1\u5ea6\/\u5fe0\u8bda\u5ea6&#xff0c;\u53ef\u80fd\u5927\u5bb6\u66f4\u559c\u6b22\u53eb\u5b83\u5e7b\u89c9\u7387&#xff0c;\u56e0\u4e3a\u5b83\u8bc4\u5206\u7684\u6838\u5fc3\u6307\u6807\u662f\u68c0\u7d22\u6587\u6863\u548c\u56de\u7b54\u7b54\u6848\u7684\u76f8\u5173\u6027&#xff0c;\u6240\u4ee5\u7b54\u6848\u6709\u6ca1\u6709\u80e1\u7f16\u4e71\u9020\u4e3b\u8981\u770b\u8fd9\u4e2a\u6307\u6807\u3002\u4e0d\u8fc7\u5728\u6b63\u5f0f\u8dd1ragas\u6846\u67b6\u524d&#xff0c;\u9700\u8981\u5148\u5199\u4e2a\u9002\u914d\u5668&#xff0c;\u56e0\u4e3aragas\u6846\u67b6\u53ea\u8ba4Langchain\u5408\u540c&#xff0c;\u800c\u6211\u4eec\u5199\u7684\u662frequests\u8c03\u63a5\u53e3\u7684\u65b9\u5f0f&#xff0c;\u6240\u4ee5\u8fdb\u5165\u5230model.py\u6587\u4ef6&#xff0c;\u5f00\u59cb\u63a5\u7740\u4e0a\u6b21\u7684\u4ee3\u7801&#xff0c;\u7ee7\u7eed\u5199\u4e2aSystemChat\u7c7b&#xff1b;<\/p>\n<p>class SystemChat(BaseChatModel):<br \/>\n      &#064;property<br \/>\n      def _llm_type(self)-&gt;str:<br \/>\n           return &#034;System-chat&#034;<br \/>\n      def  _generate(self,message,stop&#061;None,run_manager&#061;None,**kwargs):<br \/>\n      prompt&#061;&#034;\\\\n&#034;.join(str(m.content) for m in messages)<br \/>\n      text&#061;ask_llm(prompt)<br \/>\n      return ChatResult(generations&#061;[ChatGeneration(message&#061;AIMessage(content&#061;text))])<\/p>\n<p>\u5199\u5b8c\u4e86\u9002\u914d\u5668&#xff0c;\u54b1\u4eec\u5c31\u53ef\u4ee5\u8fdb\u5165\u5230\u6253\u5206\u73af\u8282\u4e86&#xff0c;\u5148\u65b0\u5efa\u4e00\u4e2afaithfulness.py\u6587\u4ef6<\/p>\n<p>import json,os,sys<br \/>\nimport pandas as pd<br \/>\nfrom ragas import EvaluationDataset,evaluate,RunConfig<br \/>\nfrom ragas.metrics import Faithfulness<br \/>\nfrom ragas.llms import LangchainLLMWrapper<\/p>\n<p>#\u8def\u5f84\u951a\u5b9a&#xff0c;\u4e0d\u7ba1\u4ece\u54ea\u91cc\u8dd1&#xff0c;data\u90fd\u6307\u5411\u6240\u5728\u76ee\u5f55<br \/>\nBASE_DIR&#061;os.path.dirname(os.path.abspath(__file__)))<br \/>\nDATA_DIR&#061;os.path.join(BASE_DIR,&#034;data&#034;)<br \/>\nsys.path.insert(0,BASE_DIR)<br \/>\nfrom db import es<br \/>\nfrom models import SystemChat<br \/>\nMAX_CONTEXTS&#061;20#\u914d\u7f6e\u53c2\u6570&#xff0c;\u53d6\u95ee\u7b54\u63a5\u53e3\u5f15\u7528\u7684\u524d\u51e0\u4e2a\u5207\u7247&#xff0c;\u8fd9\u91cc\u53d6\u524d20\u4e2a<br \/>\nES_INDEX&#061;&#034;xxxx&#034;#es\u6570\u636e\u5e93\u5b9e\u9645\u4f7f\u7528\u7684\u7d22\u5f15<\/p>\n<p>\u4e0a\u9762\u628a\u57fa\u7840\u914d\u7f6e\u548c\u9700\u8981\u5f15\u7528\u7684\u5e93\u7ed9\u5199\u597d&#xff0c;\u63a5\u4e0b\u6765\u9700\u8981\u5148\u505a\u4e00\u4e2a\u5f88\u91cd\u8981\u7684\u4e8b&#xff0c;\u628a\u88ab\u6d4b\u7cfb\u7edf\u5f15\u7528\u7684\u6b63\u6587\u4eceES\u6362\u56de\u6765&#xff0c;\u5f53\u7136\u8fd9\u91cc\u8fd9\u6837\u5199\u662f\u57fa\u4e8e\u88ab\u6d4b\u7cfb\u7edf\u5728\u5f15\u7528\u6587\u6863\u65f6\u6ca1\u6709\u628a\u5f15\u7528\u6587\u7ae0\u6b63\u6587\u5e26\u51fa\u6765\u6216\u8005\u5e26\u7684\u662f\u4e2a\u6587\u6863\u58f3\u800c\u6b63\u6587\u4ee5\u9644\u4ef6\u5f62\u5f0f\u5b58\u5728\u68c0\u7d22\u6587\u6863\u4e2d\u7684\u60c5\u51b5&#xff0c;\u5982\u679c\u68c0\u7d22\u6587\u6863\u4e2d\u76f4\u63a5\u542b\u6709\u6b63\u6587\u5219\u66f4\u597d&#xff0c;\u4e0b\u9762\u9488\u5bf9\u7684\u662f\u68c0\u7d22\u65f6\u6ca1\u5e26\u7684\u60c5\u51b5&#xff1b;<\/p>\n<p>def fetch_contexts(df_res):<br \/>\n&#034;&#034;&#034;reference\u5982\u679c\u53ea\u6709nid\u7684\u60c5\u51b5\u4e0b&#034;&#034;&#034;<br \/>\n      all_nids&#061;sorted({ref[&#034;nid&#034;] for refs_str in df_res[&#034;references&#034;]<br \/>\n           for ref in json.loads(refs_str)})<br \/>\n      #\u4f7f\u7528nid\u6362\u56de\u6b63\u6587<br \/>\n      res&#061;es.search(<br \/>\n            index&#061;ES_INDEX#\u6307\u5b9a\u7d22\u5f15\u91cc\u67e5<br \/>\n            body&#061;{<br \/>\n                &#034;size&#034;:len(all_nids),<br \/>\n                &#034;query&#034;:{&#034;nested&#034;:{&#034;path&#034;:&#034;doc_contents&#034;,&#034;query&#034;:{&#034;terms&#034;:{&#034;doc_content.nid&#034;:all_nids}}}},<br \/>\n                &#034;_source&#034;:[&#034;doc_name&#034;,&#034;doc_contents.content&#034;],<br \/>\n              },<br \/>\n      )<br \/>\n      nid2content&#061;{}<br \/>\n      for hit in res[&#034;hits&#034;][&#034;hits&#034;] :#\u904d\u5386es\u8fd4\u56de\u7684\u6bcf\u4e00\u6761\u4e3b\u6587\u6863\u8bb0\u5f55<br \/>\n             for part in hit[&#034;_source&#034;].get(&#034;doc_contents&#034;,[])#\u904d\u5386\u8be5\u4e3b\u6587\u6863\u4e0b\u7684\u6240\u6709\u5207\u7247<br \/>\n                   if part.get(&#034;nid&#034;) in all_nids:#\u8fc7\u6ee4&#xff0c;\u5c06\u5207\u7247\u7684nid\u4f5c\u4e3akey&#xff0c;content\u4f5c\u4e3avalue&#xff0c;\u6e05\u7406\u6570\u636e\u7a7a\u683c\u5e76\u622a\u65ad\u957f\u5ea6<br \/>\n                         nid2content [part[&#034;nid&#034;]]&#061;str(part.get(&#034;content&#034;,&#034;&#034;)).strip()[:2000]<br \/>\n      return nid2content                    <\/p>\n<p>\u603b\u7ed3\u4e0a\u9762\u8fd9\u6bb5\u4ee3\u7801\u5c31\u662f&#034;\u6279\u91cf\u53d6\u4e66&#034;\u7684\u8fc7\u7a0b&#xff0c;\u628a\u6587\u6863\u7684\u6b63\u6587\u53d6\u51fa\u6765\u540e&#xff0c;\u5c31\u53ef\u4ee5\u628a\u9898\u76ee\u3001\u7b54\u6848\u3001\u68c0\u7d22\u6587\u6863\u6b63\u6587\u7b49\u6253\u5305\u597d\u8fdb\u5165\u5230faithfulness\u7684\u6253\u5206\u9636\u6bb5\u4e86;<\/p>\n<p>def judge_faithfulness<br \/>\n     samples&#061;[]  #\u6536\u96c6\u8bc4\u5206\u7684\u6750\u6599<br \/>\n     for i in range (len(df_res)):<br \/>\n        row&#061;df_res.iloc[i]    #\u53d6\u51fa\u7b54\u9898\u8bb0\u5f55(\u95ee\u9898\/\u7b54\u6848\/\u68c0\u7d22\u6587\u6863)<br \/>\n        ref_nids&#061;[]  #\u7cfb\u7edf\u7684\u5207\u7247\u6e05\u5355<br \/>\n        for ref in json.loads(row[&#034;references&#034;]):  #\u904d\u5386\u8fd9\u9053\u9898\u5f15\u7528\u7684\u6bcf\u4e2a\u5207\u7247<br \/>\n           n&#061;str(ref[&#034;nid&#034;])<br \/>\n           if n not in ref_nids:<br \/>\n                ref_nids.append(n)<br \/>\n         ref_nids&#061;ref.nids[:MAX_CONTEXTS] #\u53d6\u524d20\u4e2a\u5f15\u7528\u5207\u7247<br \/>\n         contexts&#061;[nid2content[n] for n in ref_nids  if n in nid2content[n]  #\u5207\u7247\u6709\u6b63\u6587\u7684\u76f4\u63a5\u88c5\u8ba2\u8d77\u6765<br \/>\n         samples.append({<br \/>\n               &#034;user_input&#034;:row[&#034;question&#034;],<br \/>\n               &#034;response&#034;:row[&#034;response&#034;],<br \/>\n               &#034;reference&#034;:row[&#034;answer&#034;],<br \/>\n               &#034;retrieved_contexts&#034;:contexts,<br \/>\n               })<br \/>\n      dataset&#061;EvaluationDataset.from_list(samples)#\u6750\u6599\u6253\u5305\u8d77\u6765\u6210ragas\u7684\u8bc4\u6d4b\u96c6<br \/>\n      print(f&#034;\u5df2\u52a0\u8f7d{len(dataset)}\u6761&#xff0c;\u5f00\u59cb\u6253\u5206\u2026&#034;)<br \/>\n      judge_llm&#061;LangchainLLMWrapper(ZhiwenChat()) #\u88c1\u5224\u6a21\u578b\u5c31\u7528\u51fa\u9898\u65f6\u7684\u6a21\u578b&#xff0c;\u5957langchain\u58f3\u7ed9ragas\u8bc6\u522b<br \/>\n      run_config&#061;RunConfig(timeout&#061;1200,max_retries&#061;0,max_workers&#061;2)#\u5355\u9898\u9650\u65f6\u6700\u591a20\u5206\u949f&#xff0c;\u8d85\u65f6\u4e0d\u91cd\u8bd5&#xff0c;\u540c\u65f6\u5f00\u4e24\u8def\u6253\u5206\u52a0\u5feb\u901f\u5ea6<br \/>\n      result&#061;evaluate (dataset&#061;dataset,metrics&#061;[Faithfulness()],llm&#061;judge_llm,run_config&#061;run_config)#\u5f00\u5224<br \/>\n      detail&#061;result.to_pandas() #\u603b\u5206\u62c6\u5206\u6210\u6bcf\u9898\u660e\u7ec6<br \/>\n      detail.to_csv(DATA_DIR&#043;&#034;\/eval_detail_faithfulness.csv&#034;,index&#061;False,encoding&#061;&#034;utf-8-sig&#034;)<br \/>\n      return result<\/p>\n<p>if __name__&#061;&#061;&#034;__main__&#034;:<br \/>\n    df_res&#061;pd.read_csv(DATA_DIR&#043;&#034;\/data_result_zhiwen.csv&#034;)<br \/>\n    nid2content&#061;fetch_contexts(df_res)<br \/>\n    judge_faithfulness(df_res,nid2content)<br \/>\n    df_detail&#061;pd.read_csv(DATA_DIR&#043;&#034;\/eval_detail_faithfulness.csv&#034;)<br \/>\n    n_nan&#061;df_detail[&#034;faithfulness&#034;].isna().sum()<br \/>\n    if n_nan:<br \/>\n       print (f&#034;\\\\n\u8d85\u65f6\u7f3a\u8003{n_nan}\u9898(NaN\u4e0d\u8ba1\u5206&#xff0c;\u62a5\u5206\u65f6\u6ce8\u660e\u6709\u6548\u9898\u6570&#034;)<\/p>\n<p>\u8fd9\u91cc\u7b97\u662f\u628a\u6574\u5957\u6253\u5206\u7684\u6d41\u7a0b\u7ed9\u5199\u5b8c\u4e86&#xff0c;\u4f46\u662f\u5b9e\u9645\u60c5\u51b5\u53ef\u80fd\u66f4\u590d\u6742&#xff0c;\u5f53\u7136\u53d6\u6b63\u6587\u7684\u60c5\u51b5\u4e5f\u53ef\u80fd\u66f4\u5bb9\u6613&#xff0c;\u4e00\u5207\u90fd\u6839\u636e\u770b\u5ba2\u4eec\u9879\u76ee\u5b9e\u9645\u60c5\u51b5\u6765\u5b9a\u593a\u4ee3\u7801\u8be5\u600e\u4e48\u5199&#xff0c;\u4e1a\u52a1\u573a\u666f\u8be5\u600e\u4e48\u5904\u7406&#xff0c;\u4e0b\u4e00\u7bc7\u5199\u56de\u7b54\u76f8\u5173\u6027\u8fd9\u4e2a\u6307\u6807\u7684\u5904\u7406\u65b9\u5f0f\u3002<br \/>\n\u54e6\u5bf9\u4e86ragas\u6846\u67b6\u7684\u8fd9\u4e9b\u6307\u6807\u603b\u5206\u5c31\u662f1\u5206&#xff0c;\u8981\u662f\u8fd9\u4e9b\u8bc4\u6d4b\u96c6\u603b\u5206\u6253\u51fa\u6765\u80fd\u67090.8\u5206\u4ee5\u4e0a&#xff0c;\u5c31\u662f\u4e0d\u9519\u7684\u5206\u6570\u4e86&#x1f604;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f00\u59cb\u8fdb\u5165\u5230ragas\u7684\u6253\u5206\u73af\u8282\u4e86&#xff0c;\u9996\u5148\u8fdb\u884c\u4e2a\u4eba\u8ba4\u4e3a\u6700\u91cd\u8981\u7684faithfulness&#xff0c;\u4e5f\u5c31\u662f\u53ef\u4fe1\u5ea6\/\u5fe0\u8bda\u5ea6&#xff0c;\u53ef\u80fd\u5927\u5bb6\u66f4\u559c\u6b22\u53eb\u5b83\u5e7b\u89c9\u7387&#xff0c;\u56e0\u4e3a\u5b83\u8bc4\u5206\u7684\u6838\u5fc3\u6307\u6807\u662f\u68c0\u7d22\u6587\u6863\u548c\u56de\u7b54\u7b54\u6848\u7684\u76f8\u5173\u6027&#xff0c;\u6240\u4ee5\u7b54\u6848\u6709\u6ca1\u6709\u80e1\u7f16\u4e71\u9020\u4e3b\u8981\u770b\u8fd9\u4e2a\u6307\u6807\u3002\u4e0d\u8fc7\u5728\u6b63\u5f0f\u8dd1ragas\u6846\u67b6\u524d&#xff0c;\u9700\u8981\u5148\u5199\u4e2a\u9002\u914d\u5668&#xff0c;\u56e0\u4e3aragas\u6846\u67b6\u53ea\u8ba4Langchain\u5408\u540c&#xff0c;\u800c\u6211\u4eec\u5199\u7684\u662frequests\u8c03\u63a5\u53e3\u7684\u65b9\u5f0f&amp;#xff0c<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81,50],"topic":[],"class_list":["post-116827","post","type-post","status-publish","format-standard","hentry","category-server","tag-python","tag-50"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Rag\u8bc4\u6d4b-faithfulness\u8bc4\u5206 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/116827.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Rag\u8bc4\u6d4b-faithfulness\u8bc4\u5206 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u5f00\u59cb\u8fdb\u5165\u5230ragas\u7684\u6253\u5206\u73af\u8282\u4e86&#xff0c;\u9996\u5148\u8fdb\u884c\u4e2a\u4eba\u8ba4\u4e3a\u6700\u91cd\u8981\u7684faithfulness&#xff0c;\u4e5f\u5c31\u662f\u53ef\u4fe1\u5ea6\/\u5fe0\u8bda\u5ea6&#xff0c;\u53ef\u80fd\u5927\u5bb6\u66f4\u559c\u6b22\u53eb\u5b83\u5e7b\u89c9\u7387&#xff0c;\u56e0\u4e3a\u5b83\u8bc4\u5206\u7684\u6838\u5fc3\u6307\u6807\u662f\u68c0\u7d22\u6587\u6863\u548c\u56de\u7b54\u7b54\u6848\u7684\u76f8\u5173\u6027&#xff0c;\u6240\u4ee5\u7b54\u6848\u6709\u6ca1\u6709\u80e1\u7f16\u4e71\u9020\u4e3b\u8981\u770b\u8fd9\u4e2a\u6307\u6807\u3002\u4e0d\u8fc7\u5728\u6b63\u5f0f\u8dd1ragas\u6846\u67b6\u524d&#xff0c;\u9700\u8981\u5148\u5199\u4e2a\u9002\u914d\u5668&#xff0c;\u56e0\u4e3aragas\u6846\u67b6\u53ea\u8ba4Langchain\u5408\u540c&#xff0c;\u800c\u6211\u4eec\u5199\u7684\u662frequests\u8c03\u63a5\u53e3\u7684\u65b9\u5f0f&amp;#xff0c\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/116827.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-21T22:24:40+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/116827.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/116827.html\",\"name\":\"Rag\u8bc4\u6d4b-faithfulness\u8bc4\u5206 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-21T22:24:40+00:00\",\"dateModified\":\"2026-10-21T22:24:40+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/116827.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/116827.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/116827.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Rag\u8bc4\u6d4b-faithfulness\u8bc4\u5206\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Rag\u8bc4\u6d4b-faithfulness\u8bc4\u5206 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/116827.html","og_locale":"zh_CN","og_type":"article","og_title":"Rag\u8bc4\u6d4b-faithfulness\u8bc4\u5206 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u5f00\u59cb\u8fdb\u5165\u5230ragas\u7684\u6253\u5206\u73af\u8282\u4e86&#xff0c;\u9996\u5148\u8fdb\u884c\u4e2a\u4eba\u8ba4\u4e3a\u6700\u91cd\u8981\u7684faithfulness&#xff0c;\u4e5f\u5c31\u662f\u53ef\u4fe1\u5ea6\/\u5fe0\u8bda\u5ea6&#xff0c;\u53ef\u80fd\u5927\u5bb6\u66f4\u559c\u6b22\u53eb\u5b83\u5e7b\u89c9\u7387&#xff0c;\u56e0\u4e3a\u5b83\u8bc4\u5206\u7684\u6838\u5fc3\u6307\u6807\u662f\u68c0\u7d22\u6587\u6863\u548c\u56de\u7b54\u7b54\u6848\u7684\u76f8\u5173\u6027&#xff0c;\u6240\u4ee5\u7b54\u6848\u6709\u6ca1\u6709\u80e1\u7f16\u4e71\u9020\u4e3b\u8981\u770b\u8fd9\u4e2a\u6307\u6807\u3002\u4e0d\u8fc7\u5728\u6b63\u5f0f\u8dd1ragas\u6846\u67b6\u524d&#xff0c;\u9700\u8981\u5148\u5199\u4e2a\u9002\u914d\u5668&#xff0c;\u56e0\u4e3aragas\u6846\u67b6\u53ea\u8ba4Langchain\u5408\u540c&#xff0c;\u800c\u6211\u4eec\u5199\u7684\u662frequests\u8c03\u63a5\u53e3\u7684\u65b9\u5f0f&amp;#xff0c","og_url":"https:\/\/www.wsisp.com\/helps\/116827.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-21T22:24:40+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/116827.html","url":"https:\/\/www.wsisp.com\/helps\/116827.html","name":"Rag\u8bc4\u6d4b-faithfulness\u8bc4\u5206 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-21T22:24:40+00:00","dateModified":"2026-10-21T22:24:40+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/116827.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/116827.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/116827.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Rag\u8bc4\u6d4b-faithfulness\u8bc4\u5206"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/116827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=116827"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/116827\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=116827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=116827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=116827"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=116827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}