import{s as Ds,n as Ks,o as Ps}from"../chunks/scheduler.1f027d5a.js";import{S as Os,i as lt,e as M,s as a,c as y,h as st,a as p,d as t,b as n,f as Fs,g as o,j as J,k as $s,l as tt,m as e,n as c,t as T,o as i,p as j}from"../chunks/index.6117a65d.js";import{C as et}from"../chunks/CopyLLMTxtMenu.610b106b.js";import{D as at,C as U}from"../chunks/DocNotebookDropdown.4ae0d470.js";import{H as Ls,E as nt}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.bd18ae98.js";function Mt(js){let u,Ul,il,ul,w,wl,r,rl,m,ml,d,Us='<em>作者: <a href="https://huggingface.co/m-ric" rel="nofollow">Aymeric Roucher</a></em>',dl,h,us='<p>这个教程比较高级，建议你先看看另一个<a href="advanced_rag">更基础的教程</a>。</p>',hl,I,ws="<p>检索增强生成（RAG）是一种用大型语言模型（LLM）来回答问题的方法，但它会先从知识库中查找相关信息。这种方法比只用大型语言模型有很多好处，比如可以基于真实的事实来回答问题，减少虚构内容，还可以让模型获取特定领域的知识，并且可以精确控制模型从知识库中获取信息。</p>",Il,b,rs="不过，普通的RAG方法有两个主要问题：",bl,C,ms="<li>它只进行<strong>一次信息检索</strong>，如果检索的结果不好，那么回答也会差。</li> <li>它计算<strong>语义相似性时是以用户的提问为参照</strong>，这可能不太理想。比如，用户提出的问题通常是用疑问句，而包含答案的文档通常是陈述句，这样就会导致真正含有答案的文档和用户提问的相似性得分不高，可能会错过重要的信息。</li>",Cl,Z,ds="为了解决这些问题，我们可以创建<strong>一个带有检索功能的 RAG 智能体。</strong>",Zl,B,hs="这个智能体可以 ✅ 自己构建查询，并且 ✅ 在需要的时候重新检索信息。",Bl,G,Is="所以，我们得用点高级的 RAG 技术！",Gl,g,bs='<li>不直接使用用户的提问去搜索，而是智能体自行制定一个更接近目标文档的参考句子，就像 <a href="https://huggingface.co/papers/2212.10496" rel="nofollow">HyDE</a> 那样</li> <li>智能体能生成片段并在需要时重新检索，就像 <a href="https://docs.llamaindex.ai/en/stable/examples/evaluation/RetryQuery/" rel="nofollow">Self-Query</a> 那样</li>',gl,f,Cs="让我们开始做这个系统吧。🛠️",fl,N,Zs="运行下面的命令来安装所需的软件包：",Nl,V,Vl,W,Bs="我们首先加载一个知识库，以便在其上执行 RAG：这个数据集是许多 <code>huggingface</code> 软件包的文档页面的汇总，以 markdown 格式存储。",Wl,R,Rl,Q,Gs='现在我们通过处理数据集并将其存储到向量数据库中，为检索器准备知识库。我们使用 <a href="https://python.langchain.com/" rel="nofollow">LangChain</a>，因为它具有出色的向量数据库工具。对于嵌入模型，我们使用 <a href="https://huggingface.co/thenlper/gte-small" rel="nofollow">thenlper/gte-small</a>，因为它在我们的 <code>RAG_evaluation</code> 指南中表现良好。',Ql,E,El,v,gs=`Splitting documents...
`,vl,A,fs="现在数据库已经准备好了：让我们构建我们的智能体 RAG 系统吧！",Al,X,Ns="👉 我们只需要一个 <code>RetrieverTool</code>，我们的智能体可以利用它从知识库中检索信息。",Xl,k,kl,_,Vs="现在创建一个利用这个工具的智能体就简单了！",_l,q,Ws="智能体在初始化时需要以下参数：",ql,Y,Rs="<li><em><code>tools</code></em>：智能体能够调用的工具列表。</li> <li><em><code>llm_engine</code></em>：为智能体提供动力的LLM。</li>",Yl,H,Qs=`我们的 <code>llm_engine</code> 必须是一个可调用的对象，它接受一个 <a href="https://huggingface.co/docs/transformers/main/chat_templating" rel="nofollow">messages</a> 列表作为输入并返回文本。它还需要接受一个 <code>stop_sequences</code> 参数，该参数指示何时停止生成。为了方便起见，我们直接使用包中提供的 <code>HfModel</code> 类来获取一个调用我们的 <a href="https://huggingface.co/docs/api-inference/en/index" rel="nofollow">Inference API</a> 的 LLM 引擎。
我们使用 <a href="https://huggingface.co/CohereForAI/c4ai-command-r-plus" rel="nofollow">CohereForAI/c4ai-command-r-plus</a> 作为 llm 引擎，因为：`,Hl,S,Es="<li>它有一个长达 128k 的上下文，这对于处理长源文档很有帮助</li> <li>它在 HF 的 Inference API 上始终免费提供！</li>",Sl,x,xl,z,vs="既然我们已经将智能体初始化为 <code>ToolCallingAgent</code>，它就已经自动赋予了一个默认的系统提示，告诉 LLM 引擎要逐步处理并生成工具调用作为 JSON 块（你可以根据需要用你自己的提示模板替换这个）。",zl,F,As="然后，当它的 <code>.run()</code> 方法被启动时，智能体负责调用 LLM 引擎，解析工具调用的 JSON 块并执行这些工具调用，所有这些都在一个循环中进行，只有当提供最终答案时才会结束。",Fl,$,$l,L,Xs=`Final output:
There are multiple ways to push a model to the Hub. Here are a few examples using different libraries and functions:

Using the \`api\`:
python
api.upload_folder(
    repo_id=repo_id,
    folder_path=repo_local_path,
    path_in_repo='.',
)

print('Your model is pushed to the Hub. You can view your model here:', repo_url)


With Transformers:
python
from transformers import PushToHubCallback

# Initialize the callback with the output directory,
tokenizer, and your Hub username and model name
push_to_hub_callback = PushToHubCallback(
    output_dir='./your_model_save_path',
    tokenizer=tokenizer,
    hub_model_id='your-username/my-awesome-model'
)

# Assuming \`trainer\` is your Trainer object
trainer.add_callback(push_to_hub_callback)


Using \`timm\`:
python
from timm.models.hub import push_to_hf_hub

# Assuming \`model\` is your fine-tuned model
model_cfg = &#123;'labels': ['a', 'b', 'c', 'd']}
push_to_hf_hub(model, 'resnet18-random', model_config=model_cfg)


For computer vision models, you can also use \`push_to_hub\`:
python
processor.push_to_hub(hub_model_id)
trainer.push_to_hub(**kwargs)


You can also manually push a model with \`model.push_to_hub()\`:
python
model.push_to_hub()


Additionally, you can opt to push your model to the Hub at the end of training by specifying \`push_to_hub=True\` in the training configuration. Don't forget to have git-lfs installed and be logged into your Hugging Face account.
`,Ll,D,Dl,K,ks="智能体 RAG 和标准 RAG，哪个更好？我们用 LLM Judge 来比一比。",Kl,P,_s='我们会用一个非常强的模型 <a href="https://huggingface.co/meta-llama/Meta-Llama-3-70B-Instruct" rel="nofollow">meta-llama/Meta-Llama-3-70B-Instruct</a> 来做这个评估。',Pl,O,Ol,ll,qs="在运行测试之前，让我们让智能体输出更简洁一些。",ls,sl,ss,tl,ts,el,es,al,Ys='评估提示遵循了<a href="llm_judge">我们的 llm_judge cookbook</a> 中展示的一些最佳原则：它遵循一个小的整数李克特量表，有明确的评分标准和每个分数的描述。',as,nl,ns,Ml,Ms,pl,ps,Jl,Hs=`Average score for agentic RAG: 78.5%
`,Js,yl,Ss="<strong>让我们回顾一下：与标准的 RAG 相比，智能体设置提高了 8.5% 的得分！</strong>（从 70.0% 提高到 78.5%）",ys,ol,xs="这是一个巨大的改进，而且设置非常简单🚀",os,cl,zs="（作为基准，不使用知识库的 Llama-3-70B 得分为 36%）",cs,Tl,Ts,jl,is;return w=new at({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/cookbook/blob/main/notebooks/zh-CN/agent_rag.ipynb"}]}}),r=new et({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),m=new Ls({props:{title:"智能体 RAG：通过查询重构和自查询来增强你的 RAG ！🚀",local:"智能体-rag通过查询重构和自查询来增强你的-rag-",headingTag:"h1"}}),V=new U({props:{code:"IXBpcCUyMGluc3RhbGwlMjBwYW5kYXMlMjBsYW5nY2hhaW4lMjBsYW5nY2hhaW4tY29tbXVuaXR5JTIwc2VudGVuY2UtdHJhbnNmb3JtZXJzJTIwZmFpc3MtY3B1JTIwc21vbGFnZW50cw==",highlighted:"!pip install pandas langchain langchain-community sentence-transformers faiss-cpu smolagents",wrap:!1}}),R=new U({props:{code:"aW1wb3J0JTIwZGF0YXNldHMlMEElMEFrbm93bGVkZ2VfYmFzZSUyMCUzRCUyMGRhdGFzZXRzLmxvYWRfZGF0YXNldCglMjJtLXJpYyUyRmh1Z2dpbmdmYWNlX2RvYyUyMiUyQyUyMHNwbGl0JTNEJTIydHJhaW4lMjIp",highlighted:`<span class="hljs-keyword">import</span> datasets

knowledge_base = datasets.load_dataset(<span class="hljs-string">&quot;m-ric/huggingface_doc&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)`,wrap:!1}}),E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lMjAlMjAlMjAlMjAlMjAlMjBkb2NzX3Byb2Nlc3NlZC5hcHBlbmQobmV3X2RvYyklMEElMEFwcmludCglMEElMjAlMjAlMjAlMjAlMjJFbWJlZGRpbmclMjBkb2N1bWVudHMuLi4lMjBUaGlzJTIwc2hvdWxkJTIwdGFrZSUyMGElMjBmZXclMjBtaW51dGVzJTIwKDUlMjBtaW51dGVzJTIwb24lMjBNYWNCb29rJTIwd2l0aCUyME0xJTIwUHJvKSUyMiUwQSklMEFlbWJlZGRpbmdfbW9kZWwlMjAlM0QlMjBIdWdnaW5nRmFjZUVtYmVkZGluZ3MobW9kZWxfbmFtZSUzRCUyMnRoZW5scGVyJTJGZ3RlLXNtYWxsJTIyKSUwQXZlY3RvcmRiJTIwJTNEJTIwRkFJU1MuZnJvbV9kb2N1bWVudHMoJTBBJTIwJTIwJTIwJTIwZG9jdW1lbnRzJTNEZG9jc19wcm9jZXNzZWQlMkMlMEElMjAlMjAlMjAlMjBlbWJlZGRpbmclM0RlbWJlZGRpbmdfbW9kZWwlMkMlMEElMjAlMjAlMjAlMjBkaXN0YW5jZV9zdHJhdGVneSUzRERpc3RhbmNlU3RyYXRlZ3kuQ09TSU5FJTJDJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> langchain.docstore.document <span class="hljs-keyword">import</span> Document
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> langchain.text_splitter <span class="hljs-keyword">import</span> RecursiveCharacterTextSplitter
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> langchain.vectorstores <span class="hljs-keyword">import</span> FAISS
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> langchain_community.embeddings <span class="hljs-keyword">import</span> HuggingFaceEmbeddings
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> langchain_community.vectorstores.utils <span class="hljs-keyword">import</span> DistanceStrategy
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> tqdm <span class="hljs-keyword">import</span> tqdm

<span class="hljs-meta">&gt;&gt;&gt; </span>source_docs = [
<span class="hljs-meta">... </span>    Document(page_content=doc[<span class="hljs-string">&quot;text&quot;</span>], metadata={<span class="hljs-string">&quot;source&quot;</span>: doc[<span class="hljs-string">&quot;source&quot;</span>].split(<span class="hljs-string">&quot;/&quot;</span>)[<span class="hljs-number">1</span>]})
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> doc <span class="hljs-keyword">in</span> knowledge_base
<span class="hljs-meta">... </span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>text_splitter = RecursiveCharacterTextSplitter.from_huggingface_tokenizer(
<span class="hljs-meta">... </span>    AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;thenlper/gte-small&quot;</span>),
<span class="hljs-meta">... </span>    chunk_size=<span class="hljs-number">200</span>,
<span class="hljs-meta">... </span>    chunk_overlap=<span class="hljs-number">20</span>,
<span class="hljs-meta">... </span>    add_start_index=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    strip_whitespace=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    separators=[<span class="hljs-string">&quot;\\n\\n&quot;</span>, <span class="hljs-string">&quot;\\n&quot;</span>, <span class="hljs-string">&quot;.&quot;</span>, <span class="hljs-string">&quot; &quot;</span>, <span class="hljs-string">&quot;&quot;</span>],
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Split docs and keep only unique ones</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Splitting documents...&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>docs_processed = []
<span class="hljs-meta">&gt;&gt;&gt; </span>unique_texts = {}
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> doc <span class="hljs-keyword">in</span> tqdm(source_docs):
<span class="hljs-meta">... </span>    new_docs = text_splitter.split_documents([doc])
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> new_doc <span class="hljs-keyword">in</span> new_docs:
<span class="hljs-meta">... </span>        <span class="hljs-keyword">if</span> new_doc.page_content <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> unique_texts:
<span class="hljs-meta">... </span>            unique_texts[doc.page_content] = <span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>            docs_processed.append(new_doc)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;Embedding documents... This should take a few minutes (5 minutes on MacBook with M1 Pro)&quot;</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>embedding_model = HuggingFaceEmbeddings(model_name=<span class="hljs-string">&quot;thenlper/gte-small&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>vectordb = FAISS.from_documents(
<span class="hljs-meta">... </span>    documents=docs_processed,
<span class="hljs-meta">... </span>    embedding=embedding_model,
<span class="hljs-meta">... </span>    distance_strategy=DistanceStrategy.COSINE,
<span class="hljs-meta">... </span>)`,wrap:!1}}),k=new U({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBUb29sJTBBZnJvbSUyMGxhbmdjaGFpbl9jb3JlLnZlY3RvcnN0b3JlcyUyMGltcG9ydCUyMFZlY3RvclN0b3JlJTBBJTBBJTBBY2xhc3MlMjBSZXRyaWV2ZXJUb29sKFRvb2wpJTNBJTBBJTIwJTIwJTIwJTIwbmFtZSUyMCUzRCUyMCUyMnJldHJpZXZlciUyMiUwQSUyMCUyMCUyMCUyMGRlc2NyaXB0aW9uJTIwJTNEJTIwJTIyVXNpbmclMjBzZW1hbnRpYyUyMHNpbWlsYXJpdHklMkMlMjByZXRy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TIwaW4lMjBlbnVtZXJhdGUoZG9jcyklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAp",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> Tool
<span class="hljs-keyword">from</span> langchain_core.vectorstores <span class="hljs-keyword">import</span> VectorStore


<span class="hljs-keyword">class</span> <span class="hljs-title class_">RetrieverTool</span>(<span class="hljs-title class_ inherited__">Tool</span>):
    name = <span class="hljs-string">&quot;retriever&quot;</span>
    description = <span class="hljs-string">&quot;Using semantic similarity, retrieves some documents from the knowledge base that have the closest embeddings to the input query.&quot;</span>
    inputs = {
        <span class="hljs-string">&quot;query&quot;</span>: {
            <span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;text&quot;</span>,
            <span class="hljs-string">&quot;description&quot;</span>: <span class="hljs-string">&quot;The query to perform. This should be semantically close to your target documents. Use the affirmative form rather than a question.&quot;</span>,
        }
    }
    output_type = <span class="hljs-string">&quot;text&quot;</span>

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self, vectordb: VectorStore, **kwargs</span>):
        <span class="hljs-built_in">super</span>().__init__(**kwargs)
        self.vectordb = vectordb

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, query: <span class="hljs-built_in">str</span></span>) -&gt; <span class="hljs-built_in">str</span>:
        <span class="hljs-keyword">assert</span> <span class="hljs-built_in">isinstance</span>(query, <span class="hljs-built_in">str</span>), <span class="hljs-string">&quot;Your search query must be a string&quot;</span>

        docs = self.vectordb.similarity_search(
            query,
            k=<span class="hljs-number">7</span>,
        )

        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;\\nRetrieved documents:\\n&quot;</span> + <span class="hljs-string">&quot;&quot;</span>.join(
            [
                <span class="hljs-string">f&quot;===== Document <span class="hljs-subst">{<span class="hljs-built_in">str</span>(i)}</span> =====\\n&quot;</span> + doc.page_content
                <span class="hljs-keyword">for</span> i, doc <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(docs)
            ]
        )`,wrap:!1}}),x=new U({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBIZk1vZGVsJTJDJTIwVG9vbENhbGxpbmdBZ2VudCUwQSUwQW1vZGVsJTIwJTNEJTIwSGZNb2RlbCglMjJDb2hlcmVGb3JBSSUyRmM0YWktY29tbWFuZC1yLXBsdXMlMjIpJTBBJTBBcmV0cmlldmVyX3Rvb2wlMjAlM0QlMjBSZXRyaWV2ZXJUb29sKHZlY3RvcmRiKSUwQWFnZW50JTIwJTNEJTIwVG9vbENhbGxpbmdBZ2VudCglMEElMjAlMjAlMjAlMjB0b29scyUzRCU1QnJldHJpZXZlcl90b29sJTVEJTJDJTIwbW9kZWwlM0Rtb2RlbCUyQyUyMG1heF9pdGVyYXRpb25zJTNENCUyQyUyMHZlcmJvc2UlM0QyJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> HfModel, ToolCallingAgent

model = HfModel(<span class="hljs-string">&quot;CohereForAI/c4ai-command-r-plus&quot;</span>)

retriever_tool = RetrieverTool(vectordb)
agent = ToolCallingAgent(
    tools=[retriever_tool], model=model, max_iterations=<span class="hljs-number">4</span>, verbose=<span class="hljs-number">2</span>
)`,wrap:!1}}),$=new U({props:{code:"YWdlbnRfb3V0cHV0JTIwJTNEJTIwYWdlbnQucnVuKCUyMkhvdyUyMGNhbiUyMEklMjBwdXNoJTIwYSUyMG1vZGVsJTIwdG8lMjB0aGUlMjBIdWIlM0YlMjIpJTBBJTBBcHJpbnQoJTIyRmluYWwlMjBvdXRwdXQlM0ElMjIpJTBBcHJpbnQoYWdlbnRfb3V0cHV0KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>agent_output = agent.run(<span class="hljs-string">&quot;How can I push a model to the Hub?&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Final output:&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(agent_output)`,wrap:!1}}),D=new Ls({props:{title:"智能体RAG与标准RAG的比较",local:"智能体rag与标准rag的比较",headingTag:"h2"}}),O=new U({props:{code:"ZXZhbF9kYXRhc2V0JTIwJTNEJTIwZGF0YXNldHMubG9hZF9kYXRhc2V0KCUyMm0tcmljJTJGaHVnZ2luZ2ZhY2VfZG9jX3FhX2V2YWwlMjIlMkMlMjBzcGxpdCUzRCUyMnRyYWluJTIyKQ==",highlighted:'eval_dataset = datasets.load_dataset(<span class="hljs-string">&quot;m-ric/huggingface_doc_qa_eval&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)',wrap:!1}}),sl=new U({props:{code:"aW1wb3J0JTIwbG9nZ2luZyUwQSUwQWFnZW50LmxvZ2dlci5zZXRMZXZlbChsb2dnaW5nLldBUk5JTkcp",highlighted:`<span class="hljs-keyword">import</span> logging

agent.logger.setLevel(logging.WARNING)`,wrap:!1}}),tl=new U({props:{code:"b3V0cHV0c19hZ2VudGljX3JhZyUyMCUzRCUyMCU1QiU1RCUwQSUwQWZvciUyMGV4YW1wbGUlMjBpbiUyMHRxZG0oZXZhbF9kYXRhc2V0KSUzQSUwQSUyMCUyMCUyMCUyMHF1ZXN0aW9uJTIwJTNEJTIwZXhhbXBsZSU1QiUyMnF1ZXN0aW9uJTIyJTVEJTBBJTBBJTIwJTIwJTIwJTIwZW5oYW5jZWRfcXVlc3Rpb24lMjAlM0QlMjBmJTIyJTIyJTIyVXNpbmclMjB0aGUlMjBpbmZvcm1hdGlvbiUyMGNvbnRhaW5lZCUyMGluJTIweW91ciUyMGtub3dsZWRnZSUyMGJhc2UlMkMlMjB3aGljaCUyMHlvdSUyMGNhbiUyMGFjY2VzcyUyMHdpdGglMjB0aGUlMjAncmV0cmlldmVyJyUyMHR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uZXJhdGVkX2Fuc3dlciUyMiUzQSUyMGFuc3dlciUyQyUwQSUyMCUyMCUyMCUyMCU3RCUwQSUyMCUyMCUyMCUyMG91dHB1dHNfYWdlbnRpY19yYWcuYXBwZW5kKHJlc3VsdHNfYWdlbnRpYyk=",highlighted:`outputs_agentic_rag = []

<span class="hljs-keyword">for</span> example <span class="hljs-keyword">in</span> tqdm(eval_dataset):
    question = example[<span class="hljs-string">&quot;question&quot;</span>]

    enhanced_question = <span class="hljs-string">f&quot;&quot;&quot;Using the information contained in your knowledge base, which you can access with the &#x27;retriever&#x27; tool,
give a comprehensive answer to the question below.
Respond only to the question asked, response should be concise and relevant to the question.
If you cannot find information, do not give up and try calling your retriever again with different arguments!
Make sure to have covered the question completely by calling the retriever tool several times with semantically different queries.
Your queries should not be questions but affirmative form sentences: e.g. rather than &quot;How do I load a model from the Hub in bf16?&quot;, query should be &quot;load a model from the Hub bf16 weights&quot;.

Question:
<span class="hljs-subst">{question}</span>&quot;&quot;&quot;</span>
    answer = agent.run(enhanced_question)
    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;=======================================================&quot;</span>)
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Question: <span class="hljs-subst">{question}</span>&quot;</span>)
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Answer: <span class="hljs-subst">{answer}</span>&quot;</span>)
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&#x27;True answer: <span class="hljs-subst">{example[<span class="hljs-string">&quot;answer&quot;</span>]}</span>&#x27;</span>)

    results_agentic = {
        <span class="hljs-string">&quot;question&quot;</span>: question,
        <span class="hljs-string">&quot;true_answer&quot;</span>: example[<span class="hljs-string">&quot;answer&quot;</span>],
        <span class="hljs-string">&quot;source_doc&quot;</span>: example[<span class="hljs-string">&quot;source_doc&quot;</span>],
        <span class="hljs-string">&quot;generated_answer&quot;</span>: answer,
    }
    outputs_agentic_rag.append(results_agentic)`,wrap:!1}}),el=new U({props:{code:"Zn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b24lMjIlM0ElMjBxdWVzdGlvbiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnRydWVfYW5zd2VyJTIyJTNBJTIwZXhhbXBsZSU1QiUyMmFuc3dlciUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMnNvdXJjZV9kb2MlMjIlM0ElMjBleGFtcGxlJTVCJTIyc291cmNlX2RvYyUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmdlbmVyYXRlZF9hbnN3ZXIlMjIlM0ElMjBhbnN3ZXIlMkMlMEElMjAlMjAlMjAlMjAlN0QlMEElMjAlMjAlMjAlMjBvdXRwdXRzX3N0YW5kYXJkX3JhZy5hcHBlbmQocmVzdWx0c19hZ2VudGljKQ==",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient

reader_llm = InferenceClient(<span class="hljs-string">&quot;CohereForAI/c4ai-command-r-plus&quot;</span>)

outputs_standard_rag = []

<span class="hljs-keyword">for</span> example <span class="hljs-keyword">in</span> tqdm(eval_dataset):
    question = example[<span class="hljs-string">&quot;question&quot;</span>]
    context = retriever_tool(question)

    prompt = <span class="hljs-string">f&quot;&quot;&quot;Given the question and supporting documents below, give a comprehensive answer to the question.
Respond only to the question asked, response should be concise and relevant to the question.
Provide the number of the source document when relevant.
If you cannot find information, do not give up and try calling your retriever again with different arguments!

Question:
<span class="hljs-subst">{question}</span>

<span class="hljs-subst">{context}</span>
&quot;&quot;&quot;</span>
    messages = [{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: prompt}]
    answer = reader_llm.chat_completion(messages).choices[<span class="hljs-number">0</span>].message.content

    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;=======================================================&quot;</span>)
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Question: <span class="hljs-subst">{question}</span>&quot;</span>)
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Answer: <span class="hljs-subst">{answer}</span>&quot;</span>)
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&#x27;True answer: <span class="hljs-subst">{example[<span class="hljs-string">&quot;answer&quot;</span>]}</span>&#x27;</span>)

    results_agentic = {
        <span class="hljs-string">&quot;question&quot;</span>: question,
        <span class="hljs-string">&quot;true_answer&quot;</span>: example[<span class="hljs-string">&quot;answer&quot;</span>],
        <span class="hljs-string">&quot;source_doc&quot;</span>: example[<span class="hljs-string">&quot;source_doc&quot;</span>],
        <span class="hljs-string">&quot;generated_answer&quot;</span>: answer,
    }
    outputs_standard_rag.append(results_agentic)`,wrap:!1}}),nl=new U({props:{code:"RVZBTFVBVElPTl9QUk9NUFQlMjAlM0QlMjAlMjIlMjIlMjJZb3UlMjBhcmUlMjBhJTIwZmFpciUyMGV2YWx1YXRvciUyMGxhbmd1YWdlJTIwbW9kZWwuJTBBJTBBWW91JTIwd2lsbCUyMGJlJTIwZ2l2ZW4lMjBhbiUyMGluc3RydWN0aW9uJTJDJTIwYSUyMHJlc3BvbnNlJTIwdG8lMjBldmFsdWF0ZSUyQyUyMGElMjByZWZlcmVuY2UlMjBhbnN3ZXIlMjB0aGF0JTIwZ2V0cyUyMGElMjBzY29yZSUyMG9mJTIwMyUyQyUyMGFuZCUyMGElMjBzY29yZSUyMHJ1YnJpYyUyMHJlcHJlc2VudGluZyUyMGElMjBldmFsdWF0aW9uJTIwY3JpdGVyaWElMjBhcmUlMjBnaXZlbi4lMEExLiUyMFdyaXRlJTIwYSUyMGRldGFpbGVkJTIwZmVlZGJhY2slMjB0aGF0JTIwYXNzZXNzJTIwdGhlJTIwcXVhbGl0eSUyMG9mJTIwdGhlJTIwcmVzcG9uc2UlMjBzdHJpY3RseSUyMGJhc2VkJTIwb24lMjB0aGUlMjBnaXZlbiUyMHNjb3JlJTIwcnVicmljJTJDJTIwbm90JTIwZXZhbHVhdGluZyU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V2YWx1YXRlJTNBJTBBJTdCaW5zdHJ1Y3Rpb24lN0QlMEElMEFSZXNwb25zZSUyMHRvJTIwZXZhbHVhdGUlM0ElMEElN0JyZXNwb25zZSU3RCUwQSUwQVJlZmVyZW5jZSUyMEFuc3dlciUyMChTY29yZSUyMDMpJTNBJTBBJTdCcmVmZXJlbmNlX2Fuc3dlciU3RCUwQSUwQVNjb3JlJTIwUnVicmljcyUzQSUwQSU1QklzJTIwdGhlJTIwcmVzcG9uc2UlMjBjb21wbGV0ZSUyQyUyMGFjY3VyYXRlJTJDJTIwYW5kJTIwZmFjdHVhbCUyMGJhc2VkJTIwb24lMjB0aGUlMjByZWZlcmVuY2UlMjBhbnN3ZXIlM0YlNUQlMEFTY29yZSUyMDElM0ElMjBUaGUlMjByZXNwb25zZSUyMGlzJTIwY29tcGxldGVseSUyMGluY29tcGxldGUlMkMlMjBpbmFjY3VyYXRlJTJDJTIwYW5kJTJGb3IlMjBub3QlMjBmYWN0dWFsLiUwQVNjb3JlJTIwMiUzQSUyMFRoZSUyMHJlc3BvbnNlJTIwaXMlMjBzb21ld2hhdCUyMGNvbXBsZXRlJTJDJTIwYWNjdXJhdGUlMkMlMjBhbmQlMkZvciUyMGZhY3R1YWwuJTBBU2NvcmUlMjAzJTNBJTIwVGhlJTIwcmVzcG9uc2UlMjBpcyUyMGNvbXBsZXRlbHklMjBjb21wbGV0ZSUyQyUyMGFjY3VyYXRlJTJDJTIwYW5kJTJGb3IlMjBmYWN0dWFsLiUwQSUwQUZlZWRiYWNrJTNBJTIyJTIyJTIy",highlighted:`EVALUATION_PROMPT = <span class="hljs-string">&quot;&quot;&quot;You are a fair evaluator language model.

You will be given an instruction, a response to evaluate, a reference answer that gets a score of 3, and a score rubric representing a evaluation criteria are given.
1. Write a detailed feedback that assess the quality of the response strictly based on the given score rubric, not evaluating in general.
2. After writing a feedback, write a score that is an integer between 1 and 3. You should refer to the score rubric.
3. The output format should look as follows: \\&quot;Feedback: {{write a feedback for criteria}} [RESULT] {{an integer number between 1 and 3}}\\&quot;
4. Please do not generate any other opening, closing, and explanations. Be sure to include [RESULT] in your output.
5. Do not score conciseness: a correct answer that covers the question should receive max score, even if it contains additional useless information.

The instruction to evaluate:
{instruction}

Response to evaluate:
{response}

Reference Answer (Score 3):
{reference_answer}

Score Rubrics:
[Is the response complete, accurate, and factual based on the reference answer?]
Score 1: The response is completely incomplete, inaccurate, and/or not factual.
Score 2: The response is somewhat complete, accurate, and/or factual.
Score 3: The response is completely complete, accurate, and/or factual.

Feedback:&quot;&quot;&quot;</span>`,wrap:!1}}),Ml=new U({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQSUwQWV2YWx1YXRpb25fY2xpZW50JTIwJTNEJTIwSW5mZXJlbmNlQ2xpZW50KCUyMm1ldGEtbGxhbWElMkZNZXRhLUxsYW1hLTMtNzBCLUluc3RydWN0JTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient

evaluation_client = InferenceClient(<span class="hljs-string">&quot;meta-llama/Meta-Llama-3-70B-Instruct&quot;</span>)`,wrap:!1}}),pl=new U({props:{code:"aW1wb3J0JTIwcGFuZGFzJTIwYXMlMjBwZCUwQSUwQWZvciUyMHR5cGUlMkMlMjBvdXRwdXRzJTIwaW4lMjAlNUIlMEElMjAlMjAlMjAlMjAoJTIyYWdlbnRpYyUyMiUyQyUyMG91dHB1dHNfYWdlbnRpY19yYWcpJTJDJTBBJTIwJTIwJTIwJTIwKCUyMnN0YW5kYXJkJTIyJTJDJTIwb3V0cHV0c19zdGFuZGFyZF9yYWcpJTJDJTBBJTVEJTNBJTBBJTIwJTIwJTIwJTIwZm9yJTIwZXhwZXJpbWVudCUyMGluJTIwdHFkbShvdXRwdXRzKSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGV2YWxfcHJvbXB0JTIwJTNEJTIwRVZBTFV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RzJTVCJTIyZXZhbF9zY29yZV9MTE1fanVkZ2VfaW50JTIyJTVEJTIwJTNEJTIwKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJlc3VsdHMlNUIlMjJldmFsX3Njb3JlX0xMTV9qdWRnZSUyMiU1RC5maWxsbmEoMSkuYXBwbHkobGFtYmRhJTIweCUzQSUyMGludCh4KSklMEElMjAlMjAlMjAlMjApJTBBJTIwJTIwJTIwJTIwcmVzdWx0cyU1QiUyMmV2YWxfc2NvcmVfTExNX2p1ZGdlX2ludCUyMiU1RCUyMCUzRCUyMChyZXN1bHRzJTVCJTIyZXZhbF9zY29yZV9MTE1fanVkZ2VfaW50JTIyJTVEJTIwLSUyMDEpJTIwJTJGJTIwMiUwQSUwQSUyMCUyMCUyMCUyMHByaW50KCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGYlMjJBdmVyYWdlJTIwc2NvcmUlMjBmb3IlMjAlN0J0eXBlJTdEJTIwUkFHJTNBJTIwJTdCcmVzdWx0cyU1QidldmFsX3Njb3JlX0xMTV9qdWRnZV9pbnQnJTVELm1lYW4oKSoxMDAlM0EuMWYlN0QlMjUlMjIlMEElMjAlMjAlMjAlMjAp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> <span class="hljs-built_in">type</span>, outputs <span class="hljs-keyword">in</span> [
<span class="hljs-meta">... </span>    (<span class="hljs-string">&quot;agentic&quot;</span>, outputs_agentic_rag),
<span class="hljs-meta">... </span>    (<span class="hljs-string">&quot;standard&quot;</span>, outputs_standard_rag),
<span class="hljs-meta">... </span>]:
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> experiment <span class="hljs-keyword">in</span> tqdm(outputs):
<span class="hljs-meta">... </span>        eval_prompt = EVALUATION_PROMPT.<span class="hljs-built_in">format</span>(
<span class="hljs-meta">... </span>            instruction=experiment[<span class="hljs-string">&quot;question&quot;</span>],
<span class="hljs-meta">... </span>            response=experiment[<span class="hljs-string">&quot;generated_answer&quot;</span>],
<span class="hljs-meta">... </span>            reference_answer=experiment[<span class="hljs-string">&quot;true_answer&quot;</span>],
<span class="hljs-meta">... </span>        )
<span class="hljs-meta">... </span>        messages = [
<span class="hljs-meta">... </span>            {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a fair evaluator language model.&quot;</span>},
<span class="hljs-meta">... </span>            {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: eval_prompt},
<span class="hljs-meta">... </span>        ]

<span class="hljs-meta">... </span>        eval_result = evaluation_client.text_generation(
<span class="hljs-meta">... </span>            eval_prompt, max_new_tokens=<span class="hljs-number">1000</span>
<span class="hljs-meta">... </span>        )
<span class="hljs-meta">... </span>        <span class="hljs-keyword">try</span>:
<span class="hljs-meta">... </span>            feedback, score = [item.strip() <span class="hljs-keyword">for</span> item <span class="hljs-keyword">in</span> eval_result.split(<span class="hljs-string">&quot;[RESULT]&quot;</span>)]
<span class="hljs-meta">... </span>            experiment[<span class="hljs-string">&quot;eval_score_LLM_judge&quot;</span>] = score
<span class="hljs-meta">... </span>            experiment[<span class="hljs-string">&quot;eval_feedback_LLM_judge&quot;</span>] = feedback
<span class="hljs-meta">... </span>        <span class="hljs-keyword">except</span>:
<span class="hljs-meta">... </span>            <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Parsing failed - output was: <span class="hljs-subst">{eval_result}</span>&quot;</span>)

<span class="hljs-meta">... </span>    results = pd.DataFrame.from_dict(outputs)
<span class="hljs-meta">... </span>    results = results.loc[~results[<span class="hljs-string">&quot;generated_answer&quot;</span>].<span class="hljs-built_in">str</span>.contains(<span class="hljs-string">&quot;Error&quot;</span>)]
<span class="hljs-meta">... </span>    results[<span class="hljs-string">&quot;eval_score_LLM_judge_int&quot;</span>] = (
<span class="hljs-meta">... </span>        results[<span class="hljs-string">&quot;eval_score_LLM_judge&quot;</span>].fillna(<span class="hljs-number">1</span>).apply(<span class="hljs-keyword">lambda</span> x: <span class="hljs-built_in">int</span>(x))
<span class="hljs-meta">... </span>    )
<span class="hljs-meta">... </span>    results[<span class="hljs-string">&quot;eval_score_LLM_judge_int&quot;</span>] = (results[<span class="hljs-string">&quot;eval_score_LLM_judge_int&quot;</span>] - <span class="hljs-number">1</span>) / <span class="hljs-number">2</span>

<span class="hljs-meta">... </span>    <span class="hljs-built_in">print</span>(
<span class="hljs-meta">... </span>        <span class="hljs-string">f&quot;Average score for <span class="hljs-subst">{<span class="hljs-built_in">type</span>}</span> RAG: <span class="hljs-subst">{results[<span class="hljs-string">&#x27;eval_score_LLM_judge_int&#x27;</span>].mean()*<span class="hljs-number">100</span>:<span class="hljs-number">.1</span>f}</span>%&quot;</span>
<span class="hljs-meta">... </span>    )`,wrap:!1}}),Tl=new nt({props:{source:"https://github.com/huggingface/cookbook/blob/main/notebooks/zh-CN/agent_rag.md"}}),{c(){u=M("meta"),Ul=a(),il=M("p"),ul=a(),y(w.$$.fragment),wl=a(),y(r.$$.fragment),rl=a(),y(m.$$.fragment),ml=a(),d=M("p"),d.innerHTML=Us,dl=a(),h=M("blockquote"),h.innerHTML=us,hl=a(),I=M("blockquote"),I.innerHTML=ws,Il=a(),b=M("p"),b.textContent=rs,bl=a(),C=M("ul"),C.innerHTML=ms,Cl=a(),Z=M("p"),Z.innerHTML=ds,Zl=a(),B=M("p"),B.textContent=hs,Bl=a(),G=M("p"),G.textContent=Is,Gl=a(),g=M("ul"),g.innerHTML=bs,gl=a(),f=M("p"),f.textContent=Cs,fl=a(),N=M("p"),N.textContent=Zs,Nl=a(),y(V.$$.fragment),Vl=a(),W=M("p"),W.innerHTML=Bs,Wl=a(),y(R.$$.fragment),Rl=a(),Q=M("p"),Q.innerHTML=Gs,Ql=a(),y(E.$$.fragment),El=a(),v=M("pre"),v.textContent=gs,vl=a(),A=M("p"),A.textContent=fs,Al=a(),X=M("p"),X.innerHTML=Ns,Xl=a(),y(k.$$.fragment),kl=a(),_=M("p"),_.textContent=Vs,_l=a(),q=M("p"),q.textContent=Ws,ql=a(),Y=M("ul"),Y.innerHTML=Rs,Yl=a(),H=M("p"),H.innerHTML=Qs,Hl=a(),S=M("ul"),S.innerHTML=Es,Sl=a(),y(x.$$.fragment),xl=a(),z=M("p"),z.innerHTML=vs,zl=a(),F=M("p"),F.innerHTML=As,Fl=a(),y($.$$.fragment),$l=a(),L=M("pre"),L.textContent=Xs,Ll=a(),y(D.$$.fragment),Dl=a(),K=M("p"),K.textContent=ks,Kl=a(),P=M("p"),P.innerHTML=_s,Pl=a(),y(O.$$.fragment),Ol=a(),ll=M("p"),ll.textContent=qs,ls=a(),y(sl.$$.fragment),ss=a(),y(tl.$$.fragment),ts=a(),y(el.$$.fragment),es=a(),al=M("p"),al.innerHTML=Ys,as=a(),y(nl.$$.fragment),ns=a(),y(Ml.$$.fragment),Ms=a(),y(pl.$$.fragment),ps=a(),Jl=M("pre"),Jl.textContent=Hs,Js=a(),yl=M("p"),yl.innerHTML=Ss,ys=a(),ol=M("p"),ol.textContent=xs,os=a(),cl=M("p"),cl.textContent=zs,cs=a(),y(Tl.$$.fragment),Ts=a(),jl=M("p"),this.h()},l(l){const s=st("svelte-u9bgzb",document.head);u=p(s,"META",{name:!0,content:!0}),s.forEach(t),Ul=n(l),il=p(l,"P",{}),Fs(il).forEach(t),ul=n(l),o(w.$$.fragment,l),wl=n(l),o(r.$$.fragment,l),rl=n(l),o(m.$$.fragment,l),ml=n(l),d=p(l,"P",{"data-svelte-h":!0}),J(d)!=="svelte-1ouqjzx"&&(d.innerHTML=Us),dl=n(l),h=p(l,"BLOCKQUOTE",{"data-svelte-h":!0}),J(h)!=="svelte-1xmu9r8"&&(h.innerHTML=us),hl=n(l),I=p(l,"BLOCKQUOTE",{"data-svelte-h":!0}),J(I)!=="svelte-1y8hxsx"&&(I.innerHTML=ws),Il=n(l),b=p(l,"P",{"data-svelte-h":!0}),J(b)!=="svelte-1afhnhb"&&(b.textContent=rs),bl=n(l),C=p(l,"UL",{"data-svelte-h":!0}),J(C)!=="svelte-1i498ry"&&(C.innerHTML=ms),Cl=n(l),Z=p(l,"P",{"data-svelte-h":!0}),J(Z)!=="svelte-1sugc90"&&(Z.innerHTML=ds),Zl=n(l),B=p(l,"P",{"data-svelte-h":!0}),J(B)!=="svelte-1s3av12"&&(B.textContent=hs),Bl=n(l),G=p(l,"P",{"data-svelte-h":!0}),J(G)!=="svelte-hsbkwv"&&(G.textContent=Is),Gl=n(l),g=p(l,"UL",{"data-svelte-h":!0}),J(g)!=="svelte-d9fs7l"&&(g.innerHTML=bs),gl=n(l),f=p(l,"P",{"data-svelte-h":!0}),J(f)!=="svelte-1mltr0r"&&(f.textContent=Cs),fl=n(l),N=p(l,"P",{"data-svelte-h":!0}),J(N)!=="svelte-afhoxn"&&(N.textContent=Zs),Nl=n(l),o(V.$$.fragment,l),Vl=n(l),W=p(l,"P",{"data-svelte-h":!0}),J(W)!=="svelte-8zwf1q"&&(W.innerHTML=Bs),Wl=n(l),o(R.$$.fragment,l),Rl=n(l),Q=p(l,"P",{"data-svelte-h":!0}),J(Q)!=="svelte-4pfla7"&&(Q.innerHTML=Gs),Ql=n(l),o(E.$$.fragment,l),El=n(l),v=p(l,"PRE",{"data-svelte-h":!0}),J(v)!=="svelte-bkjqrc"&&(v.textContent=gs),vl=n(l),A=p(l,"P",{"data-svelte-h":!0}),J(A)!=="svelte-1cl11lp"&&(A.textContent=fs),Al=n(l),X=p(l,"P",{"data-svelte-h":!0}),J(X)!=="svelte-qho14t"&&(X.innerHTML=Ns),Xl=n(l),o(k.$$.fragment,l),kl=n(l),_=p(l,"P",{"data-svelte-h":!0}),J(_)!=="svelte-11vwtv8"&&(_.textContent=Vs),_l=n(l),q=p(l,"P",{"data-svelte-h":!0}),J(q)!=="svelte-t64l43"&&(q.textContent=Ws),ql=n(l),Y=p(l,"UL",{"data-svelte-h":!0}),J(Y)!=="svelte-1vtw5qe"&&(Y.innerHTML=Rs),Yl=n(l),H=p(l,"P",{"data-svelte-h":!0}),J(H)!=="svelte-37rnrr"&&(H.innerHTML=Qs),Hl=n(l),S=p(l,"UL",{"data-svelte-h":!0}),J(S)!=="svelte-168kz1b"&&(S.innerHTML=Es),Sl=n(l),o(x.$$.fragment,l),xl=n(l),z=p(l,"P",{"data-svelte-h":!0}),J(z)!=="svelte-1unxj4q"&&(z.innerHTML=vs),zl=n(l),F=p(l,"P",{"data-svelte-h":!0}),J(F)!=="svelte-1wjg1a8"&&(F.innerHTML=As),Fl=n(l),o($.$$.fragment,l),$l=n(l),L=p(l,"PRE",{"data-svelte-h":!0}),J(L)!=="svelte-aexpmm"&&(L.textContent=Xs),Ll=n(l),o(D.$$.fragment,l),Dl=n(l),K=p(l,"P",{"data-svelte-h":!0}),J(K)!=="svelte-no7fth"&&(K.textContent=ks),Kl=n(l),P=p(l,"P",{"data-svelte-h":!0}),J(P)!=="svelte-ihebqy"&&(P.innerHTML=_s),Pl=n(l),o(O.$$.fragment,l),Ol=n(l),ll=p(l,"P",{"data-svelte-h":!0}),J(ll)!=="svelte-vjko4c"&&(ll.textContent=qs),ls=n(l),o(sl.$$.fragment,l),ss=n(l),o(tl.$$.fragment,l),ts=n(l),o(el.$$.fragment,l),es=n(l),al=p(l,"P",{"data-svelte-h":!0}),J(al)!=="svelte-16k51po"&&(al.innerHTML=Ys),as=n(l),o(nl.$$.fragment,l),ns=n(l),o(Ml.$$.fragment,l),Ms=n(l),o(pl.$$.fragment,l),ps=n(l),Jl=p(l,"PRE",{"data-svelte-h":!0}),J(Jl)!=="svelte-mnmczc"&&(Jl.textContent=Hs),Js=n(l),yl=p(l,"P",{"data-svelte-h":!0}),J(yl)!=="svelte-1kcm2on"&&(yl.innerHTML=Ss),ys=n(l),ol=p(l,"P",{"data-svelte-h":!0}),J(ol)!=="svelte-9aqdr1"&&(ol.textContent=xs),os=n(l),cl=p(l,"P",{"data-svelte-h":!0}),J(cl)!=="svelte-1t0xi8t"&&(cl.textContent=zs),cs=n(l),o(Tl.$$.fragment,l),Ts=n(l),jl=p(l,"P",{}),Fs(jl).forEach(t),this.h()},h(){$s(u,"name","hf:doc:metadata"),$s(u,"content",pt)},m(l,s){tt(document.head,u),e(l,Ul,s),e(l,il,s),e(l,ul,s),c(w,l,s),e(l,wl,s),c(r,l,s),e(l,rl,s),c(m,l,s),e(l,ml,s),e(l,d,s),e(l,dl,s),e(l,h,s),e(l,hl,s),e(l,I,s),e(l,Il,s),e(l,b,s),e(l,bl,s),e(l,C,s),e(l,Cl,s),e(l,Z,s),e(l,Zl,s),e(l,B,s),e(l,Bl,s),e(l,G,s),e(l,Gl,s),e(l,g,s),e(l,gl,s),e(l,f,s),e(l,fl,s),e(l,N,s),e(l,Nl,s),c(V,l,s),e(l,Vl,s),e(l,W,s),e(l,Wl,s),c(R,l,s),e(l,Rl,s),e(l,Q,s),e(l,Ql,s),c(E,l,s),e(l,El,s),e(l,v,s),e(l,vl,s),e(l,A,s),e(l,Al,s),e(l,X,s),e(l,Xl,s),c(k,l,s),e(l,kl,s),e(l,_,s),e(l,_l,s),e(l,q,s),e(l,ql,s),e(l,Y,s),e(l,Yl,s),e(l,H,s),e(l,Hl,s),e(l,S,s),e(l,Sl,s),c(x,l,s),e(l,xl,s),e(l,z,s),e(l,zl,s),e(l,F,s),e(l,Fl,s),c($,l,s),e(l,$l,s),e(l,L,s),e(l,Ll,s),c(D,l,s),e(l,Dl,s),e(l,K,s),e(l,Kl,s),e(l,P,s),e(l,Pl,s),c(O,l,s),e(l,Ol,s),e(l,ll,s),e(l,ls,s),c(sl,l,s),e(l,ss,s),c(tl,l,s),e(l,ts,s),c(el,l,s),e(l,es,s),e(l,al,s),e(l,as,s),c(nl,l,s),e(l,ns,s),c(Ml,l,s),e(l,Ms,s),c(pl,l,s),e(l,ps,s),e(l,Jl,s),e(l,Js,s),e(l,yl,s),e(l,ys,s),e(l,ol,s),e(l,os,s),e(l,cl,s),e(l,cs,s),c(Tl,l,s),e(l,Ts,s),e(l,jl,s),is=!0},p:Ks,i(l){is||(T(w.$$.fragment,l),T(r.$$.fragment,l),T(m.$$.fragment,l),T(V.$$.fragment,l),T(R.$$.fragment,l),T(E.$$.fragment,l),T(k.$$.fragment,l),T(x.$$.fragment,l),T($.$$.fragment,l),T(D.$$.fragment,l),T(O.$$.fragment,l),T(sl.$$.fragment,l),T(tl.$$.fragment,l),T(el.$$.fragment,l),T(nl.$$.fragment,l),T(Ml.$$.fragment,l),T(pl.$$.fragment,l),T(Tl.$$.fragment,l),is=!0)},o(l){i(w.$$.fragment,l),i(r.$$.fragment,l),i(m.$$.fragment,l),i(V.$$.fragment,l),i(R.$$.fragment,l),i(E.$$.fragment,l),i(k.$$.fragment,l),i(x.$$.fragment,l),i($.$$.fragment,l),i(D.$$.fragment,l),i(O.$$.fragment,l),i(sl.$$.fragment,l),i(tl.$$.fragment,l),i(el.$$.fragment,l),i(nl.$$.fragment,l),i(Ml.$$.fragment,l),i(pl.$$.fragment,l),i(Tl.$$.fragment,l),is=!1},d(l){l&&(t(Ul),t(il),t(ul),t(wl),t(rl),t(ml),t(d),t(dl),t(h),t(hl),t(I),t(Il),t(b),t(bl),t(C),t(Cl),t(Z),t(Zl),t(B),t(Bl),t(G),t(Gl),t(g),t(gl),t(f),t(fl),t(N),t(Nl),t(Vl),t(W),t(Wl),t(Rl),t(Q),t(Ql),t(El),t(v),t(vl),t(A),t(Al),t(X),t(Xl),t(kl),t(_),t(_l),t(q),t(ql),t(Y),t(Yl),t(H),t(Hl),t(S),t(Sl),t(xl),t(z),t(zl),t(F),t(Fl),t($l),t(L),t(Ll),t(Dl),t(K),t(Kl),t(P),t(Pl),t(Ol),t(ll),t(ls),t(ss),t(ts),t(es),t(al),t(as),t(ns),t(Ms),t(ps),t(Jl),t(Js),t(yl),t(ys),t(ol),t(os),t(cl),t(cs),t(Ts),t(jl)),t(u),j(w,l),j(r,l),j(m,l),j(V,l),j(R,l),j(E,l),j(k,l),j(x,l),j($,l),j(D,l),j(O,l),j(sl,l),j(tl,l),j(el,l),j(nl,l),j(Ml,l),j(pl,l),j(Tl,l)}}}const pt='{"title":"智能体 RAG：通过查询重构和自查询来增强你的 RAG ！🚀","local":"智能体-rag通过查询重构和自查询来增强你的-rag-","sections":[{"title":"智能体RAG与标准RAG的比较","local":"智能体rag与标准rag的比较","sections":[],"depth":2}],"depth":1}';function Jt(js){return Ps(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class jt extends Os{constructor(u){super(),lt(this,u,Jt,Mt,Ds,{})}}export{jt as component};
