import{s as sn,n as an,o as pn}from"../chunks/scheduler.1f027d5a.js";import{S as rn,i as mn,e as i,s,c as m,h as hn,a as p,d as l,b as a,f as nn,g as h,j as r,k as Ml,l as Mn,m as n,n as M,t as c,o,p as y}from"../chunks/index.6117a65d.js";import{C as cn}from"../chunks/CopyLLMTxtMenu.610b106b.js";import{D as on,C as T}from"../chunks/DocNotebookDropdown.4ae0d470.js";import{H as J,E as yn}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.bd18ae98.js";function Tn(cl){let U,_e,Ve,He,j,Qe,d,Le,f,Ze,w,ol='<em>作者: <a href="https://github.com/dcarpintero" rel="nofollow">Diego Carpintero</a></em>',Fe,b,yl="知识图谱提供了一种以既能为人类又能为机器理解的格式建模和存储互联信息的方法。这些图谱由<em>节点</em>和<em>边</em>组成，分别表示实体及其关系。与传统数据库不同，图谱固有的表达能力允许更丰富的语义理解，同时提供了灵活性，可以在不受固定模式限制的情况下，适应新的实体类型和关系。",Xe,C,Tl="通过将知识图谱与嵌入（向量搜索）结合，我们可以利用<em>多跳连接性</em>和<em>信息的上下文理解</em>，来增强大语言模型（LLMs）的推理能力和可解释性。",Ye,$,Jl="本文档探讨了这一方法的实际应用，展示了如何：",Pe,E,Ul='<li>使用合成数据集在 <a href="https://neo4j.com/docs/" rel="nofollow">Neo4j</a> 中构建与研究出版物相关的知识图谱，</li> <li>使用<a href="https://python.langchain.com/v0.2/docs/integrations/text_embedding/" rel="nofollow">嵌入模型</a>将我们的部分数据字段投影到高维向量空间，</li> <li>在这些嵌入上构建向量索引以启用相似性搜索，</li> <li>使用自然语言从我们的图谱中提取洞见，通过 <a href="https://python.langchain.com/v0.2/docs/introduction/" rel="nofollow">LangChain</a> 轻松将用户查询转换为 <a href="https://neo4j.com/docs/cypher-manual/current/introduction/" rel="nofollow">Cypher</a> 语句：</li>',ze,u,ul='<img src="https://raw.githubusercontent.com/dcarpintero/generative-ai-101/main/static/knowledge-graphs.png"/>',De,g,Oe,I,qe,v,Ke,R,jl='我们将使用 <a href="https://neo4j.com/docs/" rel="nofollow">Neo4j</a> 来创建我们的知识图谱，它是一个开源的数据库管理系统，专门用于图数据库技术。',et,x,dl='为了快速且简便地设置，您可以在 <a href="https://neo4j.com/product/auradb/" rel="nofollow">Neo4j Aura</a>上 启动一个免费的实例。',tt,B,fl="接着，你可以使用 <code>.env</code> 文件将 <code>NEO4J_URI</code>、<code>NEO4J_USERNAME</code> 和 <code>NEO4J_PASSWORD</code> 设置为环境变量：",lt,N,nt,G,wl="LangChain 提供了 <code>Neo4jGraph</code> 类来与 Neo4j 进行交互：",st,A,at,k,it,S,bl='以下示例演示了如何与我们的 <code>Neo4j</code> 数据库建立连接，并使用<a href="https://github.com/dcarpintero/generative-ai-101/blob/main/dataset/synthetic_articles.csv" rel="nofollow">合成数据</a>填充它，这些数据包括研究文章及其作者。',pt,V,Cl="实体包括：",rt,W,$l="<li><em>研究人员</em>（Researcher）</li> <li><em>文章</em>（Article）</li> <li><em>主题</em>（Topic）</li>",mt,_,El="关系包括：",ht,H,gl="<li><em>研究人员</em> —[PUBLISHED]—&gt; <em>文章</em></li> <li><em>文章</em> —[IN_TOPIC]—&gt; <em>主题</em></li>",Mt,Q,ct,L,Il="让我们检查节点和关系是否已正确初始化：",ot,Z,yt,F,vl=`Node properties:
Article &#123;title: STRING, abstract: STRING, publication_date: DATE, embedding: LIST}
Researcher &#123;name: STRING}
Topic &#123;name: STRING}
Relationship properties:

The relationships:
(:Article)-[:IN_TOPIC]->(:Topic)
(:Researcher)-[:PUBLISHED]->(:Article)
`,Tt,X,Rl="我们可以在 Neo4j 工作区中检查我们的知识图谱：",Jt,Y,xl='<img src="https://raw.githubusercontent.com/dcarpintero/generative-ai-101/main/static/kg_sample_00.png"/>',Ut,P,ut,z,Bl="现在，我们构建一个向量索引，以便根据<em>主题、标题和摘要</em>高效地搜索相关的<em>文章</em>。这一过程包括使用这些字段计算每篇文章的嵌入。在查询时，系统通过使用相似性度量（例如余弦距离）来找到与用户输入最相似的文章。",jt,D,dt,O,Nl='<strong>注意：</strong> 要访问 OpenAI 嵌入模型，你需要创建一个 OpenAI 账户，获取 API 密钥，并将 <code>OPENAI_API_KEY</code> 设置为环境变量。你还可以尝试使用其他的<a href="https://python.langchain.com/v0.2/docs/integrations/text_embedding/" rel="nofollow">嵌入模型</a>集成，进行实验和对比。',ft,q,wt,K,Gl="<code>Langchain RetrievalQA</code> 创建了一个问答（QA）链，使用上述的向量索引作为检索器。",bt,ee,Ct,te,Al="我们来问一下：“<em>哪些文章讨论了人工智能如何影响我们的日常生活？</em>”",$t,le,Et,ne,kl=`The articles that discuss how AI might affect our daily life are:

1. **The Impact of AI on Employment: A Comprehensive Study**
   *Abstract:* This study analyzes the potential effects of AI on various job sectors and suggests policy recommendations to mitigate negative impacts.

2. **The Societal Implications of Advanced AI: A Multidisciplinary Analysis**
   *Abstract:* Our study brings together experts from various fields to analyze the potential long-term impacts of advanced AI on society, economy, and culture.

These two articles would provide insights into how AI could potentially impact our daily lives from different perspectives.
`,gt,se,It,ae,Sl="知识图谱非常适合于在实体之间建立连接，能够提取模式并发现新的洞察。",vt,ie,Vl="本节将演示如何实现这一过程，并通过自然语言查询将结果集成到大语言模型（LLM）管道中。",Rt,pe,xt,re,Wl="为了构建富有表现力且高效的查询，<code>Neo4j</code> 使用 <code>Cypher</code>，一种受 SQL 启发的声明式查询语言。<code>LangChain</code> 提供了封装器 <code>GraphCypherQAChain</code>，它是一个抽象层，允许通过自然语言查询图数据库，从而更容易将基于图的数据检索集成到大语言模型（LLM）管道中。",Bt,me,_l="在实际应用中，<code>GraphCypherQAChain</code>：",Nt,he,Hl="<li>从用户输入（自然语言）生成 Cypher 语句（图数据库的查询，如 Neo4j），并应用上下文学习（提示工程），</li> <li>将这些语句执行到图数据库中，</li> <li>将结果作为上下文提供，帮助 LLM 基于准确、最新的信息生成回答。</li>",Gt,Me,Ql="<strong>注意：</strong> 该实现涉及执行模型生成的图查询，这可能带来潜在风险，例如意外访问或修改数据库中的敏感数据。为减少这些风险，请确保数据库连接权限尽可能受限，以满足链/代理的特定需求。虽然这种方法能够降低风险，但并不能完全消除风险。",At,ce,kt,oe,St,ye,Ll="请注意，在以下示例中，Cypher 查询执行的结果是如何作为上下文提供给大语言模型（LLM）的：",Vt,Te,Wt,Je,Zl="在这个示例中，我们的问题“<em>Emily Chen 发布了多少篇文章？</em>”将被转换为以下 Cypher 查询：",_t,Ue,Ht,ue,Fl="该查询通过匹配名称为“Emily Chen”的 <code>Researcher</code> 节点，并遍历与之相关的 <code>PUBLISHED</code> 关系，连接到 <code>Article</code> 节点。然后，它计算与“Emily Chen”连接的 <code>Article</code> 节点的数量。",Qt,je,Xl="执行查询后，结果将作为上下文提供给 LLM，LLM 基于这个上下文来生成回答。",Lt,de,Yl='<img src="https://raw.githubusercontent.com/dcarpintero/generative-ai-101/main/static/kg_sample_01.png" width="40%"/>',Zt,fe,Ft,we,Pl=`\x1B[1m> Entering new GraphCypherQAChain chain...\x1B[0m
Generated Cypher:
\x1B[32;1m\x1B[1;3mcypher
MATCH (r:Researcher &#123;name: "Emily Chen"})-[:PUBLISHED]->(a:Article)
RETURN COUNT(a) AS numberOfArticles
\x1B[0m
Full Context:
\x1B[32;1m\x1B[1;3m[&#123;'numberOfArticles': 7}]\x1B[0m

\x1B[1m> Finished chain.\x1B[0m
`,Xt,be,Yt,Ce,zl="在这个示例中，查询“<em>是否有任何一对研究人员共同发布了超过三篇文章？</em>”将结果转换为以下 Cypher 查询：",Pt,$e,zt,Ee,Dl="该查询首先从 <code>Researcher</code> 节点出发，遍历 <code>PUBLISHED</code> 关系，找到与之连接的 <code>Article</code> 节点，然后再次遍历，查找与另一位 <code>Researcher</code> 节点的连接。通过这种方式，查询找出那些共同发表了超过三篇文章的研究人员对。最终，结果将作为上下文提供给 LLM，LLM 会基于这个上下文生成回答。",Dt,ge,Ol='<img src="https://raw.githubusercontent.com/dcarpintero/generative-ai-101/main/static/kg_sample_02.png"/>',Ot,Ie,qt,ve,ql=`\x1B[1m> Entering new GraphCypherQAChain chain...\x1B[0m
Generated Cypher:
\x1B[32;1m\x1B[1;3mcypher
MATCH (r1:Researcher)-[:PUBLISHED]->(a:Article)<-[:PUBLISHED]-(r2:Researcher)
WHERE r1 <> r2
WITH r1, r2, COUNT(a) AS sharedArticles
WHERE sharedArticles > 3
RETURN r1.name, r2.name, sharedArticles
\x1B[0m
Full Context:
\x1B[32;1m\x1B[1;3m[&#123;'r1.name': 'David Johnson', 'r2.name': 'Emily Chen', 'sharedArticles': 4}, &#123;'r1.name': 'Robert Taylor', 'r2.name': 'Emily Chen', 'sharedArticles': 4}, &#123;'r1.name': 'Emily Chen', 'r2.name': 'David Johnson', 'sharedArticles': 4}, &#123;'r1.name': 'Emily Chen', 'r2.name': 'Robert Taylor', 'sharedArticles': 4}]\x1B[0m

\x1B[1m> Finished chain.\x1B[0m
`,Kt,Re,el,xe,Kl=`让我们找出哪位研究人员与最多的同行合作过。<br/>
我们的查询“<em>哪位研究人员与最多的同行合作过？</em>”现在转换为以下 Cypher 查询：`,tl,Be,ll,Ne,en="在这个查询中，我们从所有 <code>Researcher</code> 节点出发，遍历它们的 <code>PUBLISHED</code> 关系，找到与之连接的 <code>Article</code> 节点。对于每个 <code>Article</code> 节点，Neo4j 会继续回溯，查找那些也发表了同一篇文章的其他 <code>Researcher</code> 节点（同行）。通过这种方式，查询能够计算出每位研究人员与多少位同行合作，并按合作次数降序排列，最终返回合作最多的研究人员及其同行数量。",nl,Ge,tn='<img src="https://raw.githubusercontent.com/dcarpintero/generative-ai-101/main/static/kg_sample_03.png"/>',sl,Ae,al,ke,ln=`\x1B[1m> Entering new GraphCypherQAChain chain...\x1B[0m
Generated Cypher:
\x1B[32;1m\x1B[1;3mcypher
MATCH (r1:Researcher)-[:PUBLISHED]->(:Article)<-[:PUBLISHED]-(r2:Researcher)
WHERE r1 <> r2
WITH r1, COUNT(DISTINCT r2) AS collaborators
RETURN r1.name AS researcher, collaborators
ORDER BY collaborators DESC
LIMIT 1
\x1B[0m
Full Context:
\x1B[32;1m\x1B[1;3m[&#123;'researcher': 'David Johnson', 'collaborators': 6}]\x1B[0m

\x1B[1m> Finished chain.\x1B[0m
`,il,pl,rl,Se,ml,We,hl;return j=new on({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/rag_with_knowledge_graphs_neo4j.ipynb"}]}}),d=new cn({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),f=new J({props:{title:"利用知识图谱增强 RAG 推理能力",local:"利用知识图谱增强-rag-推理能力",headingTag:"h1"}}),g=new J({props:{title:"初始化",local:"初始化",headingTag:"h2"}}),I=new T({props:{code:"JTI1cGlwJTIwaW5zdGFsbCUyMG5lbzRqJTIwbGFuZ2NoYWluJTIwbGFuZ2NoYWluX29wZW5haSUyMGxhbmdjaGFpbi1jb21tdW5pdHklMjBweXRob24tZG90ZW52JTIwLS1xdWlldA==",highlighted:"%pip install neo4j langchain langchain_openai langchain-community python-dotenv --quiet",wrap:!1}}),v=new J({props:{title:"设置 Neo4j 实例",local:"设置-neo4j-实例",headingTag:"h3"}}),N=new T({props:{code:"aW1wb3J0JTIwZG90ZW52JTBBZG90ZW52LmxvYWRfZG90ZW52KCcuZW52JyUyQyUyMG92ZXJyaWRlJTNEVHJ1ZSk=",highlighted:`<span class="hljs-keyword">import</span> dotenv
dotenv.load_dotenv(<span class="hljs-string">&#x27;.env&#x27;</span>, override=<span class="hljs-literal">True</span>)`,wrap:!1}}),A=new T({props:{code:"aW1wb3J0JTIwb3MlMEFmcm9tJTIwbGFuZ2NoYWluX2NvbW11bml0eS5ncmFwaHMlMjBpbXBvcnQlMjBOZW80akdyYXBoJTBBJTBBZ3JhcGglMjAlM0QlMjBOZW80akdyYXBoKCUwQSUyMCUyMCUyMCUyMHVybCUzRG9zLmVudmlyb24lNUInTkVPNEpfVVJJJyU1RCUyQyUyMCUwQSUyMCUyMCUyMCUyMHVzZXJuYW1lJTNEb3MuZW52aXJvbiU1QidORU80Sl9VU0VSTkFNRSclNUQlMkMlMEElMjAlMjAlMjAlMjBwYXNzd29yZCUzRG9zLmVudmlyb24lNUInTkVPNEpfUEFTU1dPUkQnJTVEJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">import</span> os
<span class="hljs-keyword">from</span> langchain_community.graphs <span class="hljs-keyword">import</span> Neo4jGraph

graph = Neo4jGraph(
    url=os.environ[<span class="hljs-string">&#x27;NEO4J_URI&#x27;</span>], 
    username=os.environ[<span class="hljs-string">&#x27;NEO4J_USERNAME&#x27;</span>],
    password=os.environ[<span class="hljs-string">&#x27;NEO4J_PASSWORD&#x27;</span>],
)`,wrap:!1}}),k=new J({props:{title:"将数据集加载到图谱中",local:"将数据集加载到图谱中",headingTag:"h3"}}),Q=new T({props:{code:"ZnJvbSUyMGxhbmdjaGFpbl9jb21tdW5pdHkuZ3JhcGhzJTIwaW1wb3J0JTIwTmVvNGpHcmFwaCUwQSUwQWdyYXBoJTIwJTNEJTIwTmVvNGpHcmFwaCgpJTBBJTBBcV9sb2FkX2FydGljbGVzJTIwJTNEJTIwJTIyJTIyJTIyJTBBTE9BRCUyMENTViUyMFdJVEglMjBIRUFERVJTJTBBRlJPTSUyMCdodHRwcyUzQSUyRiUyRnJhdy5naXRodWJ1c2VyY29udGVudC5jb20lMkZkY2FycGludGVybyUyRmdlbmVyYXRpdmUtYWktMTAxJTJGbWFpbiUyRmRhdGFzZXQlMkZzeW50aGV0aWNfYXJ0aWNsZXMuY3N2JyUyMCUwQUFTJTIwcm93JTIwJTBBRklFTERURVJNSU5BVE9SJTIwJyUzQiclMEFNRVJHRSUyMChhJTNBQXJ0aWNsZSUyMCU3QnRpdGxlJTNBcm93LlRpdGxlJTdEKSUwQVNFVCUyMGEuYWJzdHJhY3QlMjAlM0QlMjByb3cuQWJzdHJhY3QlMkMlMEElMjAlMjAlMjAlMjBhLnB1YmxpY2F0aW9uX2RhdGUlMjAlM0QlMjBkYXRlKHJvdy5QdWJsaWNhdGlvbl9EYXRlKSUwQUZPUkVBQ0glMjAocmVzZWFyY2hlciUyMGluJTIwc3BsaXQocm93LkF1dGhvcnMlMkMlMjAnJTJDJyklMjAlN0MlMjAlMEElMjAlMjAlMjAlMjBNRVJHRSUyMChwJTNBUmVzZWFyY2hlciUyMCU3Qm5hbWUlM0F0cmltKHJlc2VhcmNoZXIpJTdEKSUwQSUyMCUyMCUyMCUyME1FUkdFJTIwKHApLSU1QiUzQVBVQkxJU0hFRCU1RC0lM0UoYSkpJTBBRk9SRUFDSCUyMCh0b3BpYyUyMGluJTIwJTVCcm93LlRvcGljJTVEJTIwJTdDJTIwJTBBJTIwJTIwJTIwJTIwTUVSR0UlMjAodCUzQVRvcGljJTIwJTdCbmFtZSUzQXRyaW0odG9waWMpJTdEKSUwQSUyMCUyMCUyMCUyME1FUkdFJTIwKGEpLSU1QiUzQUlOX1RPUElDJTVELSUzRSh0KSklMEElMjIlMjIlMjIlMEElMEFncmFwaC5xdWVyeShxX2xvYWRfYXJ0aWNsZXMp",highlighted:`<span class="hljs-keyword">from</span> langchain_community.graphs <span class="hljs-keyword">import</span> Neo4jGraph

graph = Neo4jGraph()

q_load_articles = <span class="hljs-string">&quot;&quot;&quot;
LOAD CSV WITH HEADERS
FROM &#x27;https://raw.githubusercontent.com/dcarpintero/generative-ai-101/main/dataset/synthetic_articles.csv&#x27; 
AS row 
FIELDTERMINATOR &#x27;;&#x27;
MERGE (a:Article {title:row.Title})
SET a.abstract = row.Abstract,
    a.publication_date = date(row.Publication_Date)
FOREACH (researcher in split(row.Authors, &#x27;,&#x27;) | 
    MERGE (p:Researcher {name:trim(researcher)})
    MERGE (p)-[:PUBLISHED]-&gt;(a))
FOREACH (topic in [row.Topic] | 
    MERGE (t:Topic {name:trim(topic)})
    MERGE (a)-[:IN_TOPIC]-&gt;(t))
&quot;&quot;&quot;</span>

graph.query(q_load_articles)`,wrap:!1}}),Z=new T({props:{code:"Z3JhcGgucmVmcmVzaF9zY2hlbWEoKSUwQXByaW50KGdyYXBoLmdldF9zY2hlbWEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>graph.refresh_schema()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(graph.get_schema)`,wrap:!1}}),P=new J({props:{title:"构建向量索引",local:"构建向量索引",headingTag:"h3"}}),D=new T({props:{code:"ZnJvbSUyMGxhbmdjaGFpbl9jb21tdW5pdHkudmVjdG9yc3RvcmVzJTIwaW1wb3J0JTIwTmVvNGpWZWN0b3IlMEFmcm9tJTIwbGFuZ2NoYWluX29wZW5haSUyMGltcG9ydCUyME9wZW5BSUVtYmVkZGluZ3MlMEElMEF2ZWN0b3JfaW5kZXglMjAlM0QlMjBOZW80alZlY3Rvci5mcm9tX2V4aXN0aW5nX2dyYXBoKCUwQSUyMCUyMCUyMCUyME9wZW5BSUVtYmVkZGluZ3MoKSUyQyUwQSUyMCUyMCUyMCUyMHVybCUzRG9zLmVudmlyb24lNUInTkVPNEpfVVJJJyU1RCUyQyUwQSUyMCUyMCUyMCUyMHVzZXJuYW1lJTNEb3MuZW52aXJvbiU1QidORU80Sl9VU0VSTkFNRSclNUQlMkMlMEElMjAlMjAlMjAlMjBwYXNzd29yZCUzRG9zLmVudmlyb24lNUInTkVPNEpfUEFTU1dPUkQnJTVEJTJDJTBBJTIwJTIwJTIwJTIwaW5kZXhfbmFtZSUzRCdhcnRpY2xlcyclMkMlMEElMjAlMjAlMjAlMjBub2RlX2xhYmVsJTNEJTIyQXJ0aWNsZSUyMiUyQyUwQSUyMCUyMCUyMCUyMHRleHRfbm9kZV9wcm9wZXJ0aWVzJTNEJTVCJ3RvcGljJyUyQyUyMCd0aXRsZSclMkMlMjAnYWJzdHJhY3QnJTVEJTJDJTBBJTIwJTIwJTIwJTIwZW1iZWRkaW5nX25vZGVfcHJvcGVydHklM0QnZW1iZWRkaW5nJyUyQyUwQSk=",highlighted:`<span class="hljs-keyword">from</span> langchain_community.vectorstores <span class="hljs-keyword">import</span> Neo4jVector
<span class="hljs-keyword">from</span> langchain_openai <span class="hljs-keyword">import</span> OpenAIEmbeddings

vector_index = Neo4jVector.from_existing_graph(
    OpenAIEmbeddings(),
    url=os.environ[<span class="hljs-string">&#x27;NEO4J_URI&#x27;</span>],
    username=os.environ[<span class="hljs-string">&#x27;NEO4J_USERNAME&#x27;</span>],
    password=os.environ[<span class="hljs-string">&#x27;NEO4J_PASSWORD&#x27;</span>],
    index_name=<span class="hljs-string">&#x27;articles&#x27;</span>,
    node_label=<span class="hljs-string">&quot;Article&quot;</span>,
    text_node_properties=[<span class="hljs-string">&#x27;topic&#x27;</span>, <span class="hljs-string">&#x27;title&#x27;</span>, <span class="hljs-string">&#x27;abstract&#x27;</span>],
    embedding_node_property=<span class="hljs-string">&#x27;embedding&#x27;</span>,
)`,wrap:!1}}),q=new J({props:{title:"基于相似性的问答",local:"基于相似性的问答",headingTag:"h2"}}),ee=new T({props:{code:"ZnJvbSUyMGxhbmdjaGFpbi5jaGFpbnMlMjBpbXBvcnQlMjBSZXRyaWV2YWxRQSUwQWZyb20lMjBsYW5nY2hhaW5fb3BlbmFpJTIwaW1wb3J0JTIwQ2hhdE9wZW5BSSUwQSUwQXZlY3Rvcl9xYSUyMCUzRCUyMFJldHJpZXZhbFFBLmZyb21fY2hhaW5fdHlwZSglMEElMjAlMjAlMjAlMjBsbG0lM0RDaGF0T3BlbkFJKCklMkMlMEElMjAlMjAlMjAlMjBjaGFpbl90eXBlJTNEJTIyc3R1ZmYlMjIlMkMlMEElMjAlMjAlMjAlMjByZXRyaWV2ZXIlM0R2ZWN0b3JfaW5kZXguYXNfcmV0cmlldmVyKCklMEEp",highlighted:`<span class="hljs-keyword">from</span> langchain.chains <span class="hljs-keyword">import</span> RetrievalQA
<span class="hljs-keyword">from</span> langchain_openai <span class="hljs-keyword">import</span> ChatOpenAI

vector_qa = RetrievalQA.from_chain_type(
    llm=ChatOpenAI(),
    chain_type=<span class="hljs-string">&quot;stuff&quot;</span>,
    retriever=vector_index.as_retriever()
)`,wrap:!1}}),le=new T({props:{code:"ciUyMCUzRCUyMHZlY3Rvcl9xYS5pbnZva2UoJTBBJTIwJTIwJTIwJTIwJTdCJTIycXVlcnklMjIlM0ElMjAlMjJ3aGljaCUyMGFydGljbGVzJTIwZGlzY3VzcyUyMGhvdyUyMEFJJTIwbWlnaHQlMjBhZmZlY3QlMjBvdXIlMjBkYWlseSUyMGxpZmUlM0YlMjBpbmNsdWRlJTIwdGhlJTIwYXJ0aWNsZSUyMHRpdGxlcyUyMGFuZCUyMGFic3RyYWN0cy4lMjIlN0QlMEEpJTBBcHJpbnQociU1QidyZXN1bHQnJTVEKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>r = vector_qa.invoke(
<span class="hljs-meta">... </span>    {<span class="hljs-string">&quot;query&quot;</span>: <span class="hljs-string">&quot;which articles discuss how AI might affect our daily life? include the article titles and abstracts.&quot;</span>}
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(r[<span class="hljs-string">&#x27;result&#x27;</span>])`,wrap:!1}}),se=new J({props:{title:"通过知识图谱进行推理",local:"通过知识图谱进行推理",headingTag:"h2"}}),pe=new J({props:{title:"Graph-Cypher-Chain 与 LangChain",local:"graph-cypher-chain-与-langchain",headingTag:"h3"}}),ce=new T({props:{code:"ZnJvbSUyMGxhbmdjaGFpbi5jaGFpbnMlMjBpbXBvcnQlMjBHcmFwaEN5cGhlclFBQ2hhaW4lMEFmcm9tJTIwbGFuZ2NoYWluX29wZW5haSUyMGltcG9ydCUyMENoYXRPcGVuQUklMEElMEFncmFwaC5yZWZyZXNoX3NjaGVtYSgpJTBBJTBBY3lwaGVyX2NoYWluJTIwJTNEJTIwR3JhcGhDeXBoZXJRQUNoYWluLmZyb21fbGxtKCUwQSUyMCUyMCUyMCUyMGN5cGhlcl9sbG0lMjAlM0QlMjBDaGF0T3BlbkFJKHRlbXBlcmF0dXJlJTNEMCUyQyUyMG1vZGVsX25hbWUlM0QnZ3B0LTRvJyklMkMlMEElMjAlMjAlMjAlMjBxYV9sbG0lMjAlM0QlMjBDaGF0T3BlbkFJKHRlbXBlcmF0dXJlJTNEMCUyQyUyMG1vZGVsX25hbWUlM0QnZ3B0LTRvJyklMkMlMjAlMEElMjAlMjAlMjAlMjBncmFwaCUzRGdyYXBoJTJDJTBBJTIwJTIwJTIwJTIwdmVyYm9zZSUzRFRydWUlMkMlMEEp",highlighted:`<span class="hljs-keyword">from</span> langchain.chains <span class="hljs-keyword">import</span> GraphCypherQAChain
<span class="hljs-keyword">from</span> langchain_openai <span class="hljs-keyword">import</span> ChatOpenAI

graph.refresh_schema()

cypher_chain = GraphCypherQAChain.from_llm(
    cypher_llm = ChatOpenAI(temperature=<span class="hljs-number">0</span>, model_name=<span class="hljs-string">&#x27;gpt-4o&#x27;</span>),
    qa_llm = ChatOpenAI(temperature=<span class="hljs-number">0</span>, model_name=<span class="hljs-string">&#x27;gpt-4o&#x27;</span>), 
    graph=graph,
    verbose=<span class="hljs-literal">True</span>,
)`,wrap:!1}}),oe=new J({props:{title:"使用自然语言的查询示例",local:"使用自然语言的查询示例",headingTag:"h3"}}),Te=new J({props:{title:"” Emily Chen 发布了多少篇文章？ ”",local:"-emily-chen-发布了多少篇文章-",headingTag:"h4"}}),Ue=new T({props:{code:"TUFUQ0glMjAociUzQVJlc2VhcmNoZXIlMjAlN0JuYW1lJTNBJTIwJTIyRW1pbHklMjBDaGVuJTIyJTdEKS0lNUIlM0FQVUJMSVNIRUQlNUQtJTNFKGElM0FBcnRpY2xlKSUwQVJFVFVSTiUyMENPVU5UKGEpJTIwQVMlMjBudW1iZXJPZkFydGljbGVz",highlighted:`MATCH (r:Researcher {name: <span class="hljs-string">&quot;Emily Chen&quot;</span>})-<span class="hljs-selector-attr">[:PUBLISHED]</span>-&gt;(<span class="hljs-selector-tag">a</span>:Article)
RETURN <span class="hljs-built_in">COUNT</span>(a) AS numberOfArticles`,wrap:!1}}),fe=new T({props:{code:"JTIzJTIwdGhlJTIwYW5zd2VyJTIwc2hvdWxkJTIwYmUlMjAnNyclMEFjeXBoZXJfY2hhaW4uaW52b2tlKCUwQSUyMCUyMCUyMCUyMCU3QiUyMnF1ZXJ5JTIyJTNBJTIwJTIySG93JTIwbWFueSUyMGFydGljbGVzJTIwaGFzJTIwcHVibGlzaGVkJTIwRW1pbHklMjBDaGVuJTNGJTIyJTdEJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># the answer should be &#x27;7&#x27;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>cypher_chain.invoke(
<span class="hljs-meta">... </span>    {<span class="hljs-string">&quot;query&quot;</span>: <span class="hljs-string">&quot;How many articles has published Emily Chen?&quot;</span>}
<span class="hljs-meta">... </span>)`,wrap:!1}}),be=new J({props:{title:"” 是否有任何一对研究人员共同发布了超过三篇文章？ ”",local:"-是否有任何一对研究人员共同发布了超过三篇文章-",headingTag:"h4"}}),$e=new T({props:{code:"TUFUQ0glMjAocjElM0FSZXNlYXJjaGVyKS0lNUIlM0FQVUJMSVNIRUQlNUQtJTNFKGElM0FBcnRpY2xlKSUzQy0lNUIlM0FQVUJMSVNIRUQlNUQtKHIyJTNBUmVzZWFyY2hlciklMEFXSEVSRSUyMHIxJTIwJTNDJTNFJTIwcjIlMEFXSVRIJTIwcjElMkMlMjByMiUyQyUyMENPVU5UKGEpJTIwQVMlMjBzaGFyZWRBcnRpY2xlcyUwQVdIRVJFJTIwc2hhcmVkQXJ0aWNsZXMlMjAlM0UlMjAzJTBBUkVUVVJOJTIwcjEubmFtZSUyQyUyMHIyLm5hbWUlMkMlMjBzaGFyZWRBcnRpY2xlcw==",highlighted:`<span class="hljs-symbol">MATCH</span> (<span class="hljs-built_in">r1</span>:Researcher)-[:PUBLISHED]-&gt;(a:Article)&lt;-[:PUBLISHED]-(<span class="hljs-built_in">r2</span>:Researcher)
<span class="hljs-symbol">WHERE</span> <span class="hljs-built_in">r1</span> &lt;&gt; <span class="hljs-built_in">r2</span>
<span class="hljs-symbol">WITH</span> <span class="hljs-built_in">r1</span>, <span class="hljs-built_in">r2</span>, COUNT(a) AS sharedArticles
<span class="hljs-symbol">WHERE</span> sharedArticles &gt; <span class="hljs-number">3</span>
<span class="hljs-symbol">RETURN</span> <span class="hljs-built_in">r1</span>.name, <span class="hljs-built_in">r2</span>.name, sharedArticles`,wrap:!1}}),Ie=new T({props:{code:"JTIzJTIwdGhlJTIwYW5zd2VyJTIwc2hvdWxkJTIwYmUlMjBEYXZpZCUyMEpvaG5zb24lMjAlMjYlMjBFbWlseSUyMENoZW4lMkMlMjBSb2JlcnQlMjBUYXlsb3IlMjAlMjYlMjBFbWlseSUyMENoZW4lMEFjeXBoZXJfY2hhaW4uaW52b2tlKCUwQSUyMCUyMCUyMCUyMCU3QiUyMnF1ZXJ5JTIyJTNBJTIwJTIyYXJlJTIwdGhlcmUlMjBhbnklMjBwYWlyJTIwb2YlMjByZXNlYXJjaGVycyUyMHdobyUyMGhhdmUlMjBwdWJsaXNoZWQlMjBtb3JlJTIwdGhhbiUyMHRocmVlJTIwYXJ0aWNsZXMlMjB0b2dldGhlciUzRiUyMiU3RCUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># the answer should be David Johnson &amp; Emily Chen, Robert Taylor &amp; Emily Chen</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>cypher_chain.invoke(
<span class="hljs-meta">... </span>    {<span class="hljs-string">&quot;query&quot;</span>: <span class="hljs-string">&quot;are there any pair of researchers who have published more than three articles together?&quot;</span>}
<span class="hljs-meta">... </span>)`,wrap:!1}}),Re=new J({props:{title:"” 哪位研究人员与最多的同行合作过？ ”",local:"-哪位研究人员与最多的同行合作过-",headingTag:"h4"}}),Be=new T({props:{code:"TUFUQ0glMjAociUzQVJlc2VhcmNoZXIpLSU1QiUzQVBVQkxJU0hFRCU1RC0lM0UoJTNBQXJ0aWNsZSklM0MtJTVCJTNBUFVCTElTSEVEJTVELShwZWVyJTNBUmVzZWFyY2hlciklMEFXSVRIJTIwciUyQyUyMENPVU5UKERJU1RJTkNUJTIwcGVlciklMjBBUyUyMHBlZXJDb3VudCUwQVJFVFVSTiUyMHIubmFtZSUyMEFTJTIwcmVzZWFyY2hlciUyQyUyMHBlZXJDb3VudCUwQU9SREVSJTIwQlklMjBwZWVyQ291bnQlMjBERVNDJTBBTElNSVQlMjAx",highlighted:`MATCH (r:Researcher)-[:PUBLISHED]-&gt;(:Article)&lt;-[:PUBLISHED]-(peer:Researcher)
<span class="hljs-keyword">WITH</span> r, COUNT(<span class="hljs-keyword">DISTINCT</span> peer) <span class="hljs-keyword">AS</span> peerCount
<span class="hljs-keyword">RETURN</span> r.name <span class="hljs-keyword">AS</span> researcher, peerCount
<span class="hljs-keyword">ORDER</span> <span class="hljs-keyword">BY</span> peerCount <span class="hljs-keyword">DESC</span>
<span class="hljs-keyword">LIMIT</span> <span class="hljs-number">1</span>`,wrap:!1}}),Ae=new T({props:{code:"JTIzJTIwdGhlJTIwYW5zd2VyJTIwc2hvdWxkJTIwYmUlMjAnRGF2aWQlMjBKb2huc29uJyUwQWN5cGhlcl9jaGFpbi5pbnZva2UoJTBBJTIwJTIwJTIwJTIwJTdCJTIycXVlcnklMjIlM0ElMjAlMjJXaGljaCUyMHJlc2VhcmNoZXIlMjBoYXMlMjBjb2xsYWJvcmF0ZWQlMjB3aXRoJTIwdGhlJTIwbW9zdCUyMHBlZXJzJTNGJTIyJTdEJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># the answer should be &#x27;David Johnson&#x27;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>cypher_chain.invoke(
<span class="hljs-meta">... </span>    {<span class="hljs-string">&quot;query&quot;</span>: <span class="hljs-string">&quot;Which researcher has collaborated with the most peers?&quot;</span>}
<span class="hljs-meta">... </span>)`,wrap:!1}}),Se=new yn({props:{source:"https://github.com/huggingface/cookbook/blob/main/notebooks/zh-CN/rag_with_knowledge_graphs_neo4j.md"}}),{c(){U=i("meta"),_e=s(),Ve=i("p"),He=s(),m(j.$$.fragment),Qe=s(),m(d.$$.fragment),Le=s(),m(f.$$.fragment),Ze=s(),w=i("p"),w.innerHTML=ol,Fe=s(),b=i("p"),b.innerHTML=yl,Xe=s(),C=i("p"),C.innerHTML=Tl,Ye=s(),$=i("p"),$.textContent=Jl,Pe=s(),E=i("ul"),E.innerHTML=Ul,ze=s(),u=i("p"),u.innerHTML=ul,De=s(),m(g.$$.fragment),Oe=s(),m(I.$$.fragment),qe=s(),m(v.$$.fragment),Ke=s(),R=i("p"),R.innerHTML=jl,et=s(),x=i("p"),x.innerHTML=dl,tt=s(),B=i("p"),B.innerHTML=fl,lt=s(),m(N.$$.fragment),nt=s(),G=i("p"),G.innerHTML=wl,st=s(),m(A.$$.fragment),at=s(),m(k.$$.fragment),it=s(),S=i("p"),S.innerHTML=bl,pt=s(),V=i("p"),V.textContent=Cl,rt=s(),W=i("ul"),W.innerHTML=$l,mt=s(),_=i("p"),_.textContent=El,ht=s(),H=i("ul"),H.innerHTML=gl,Mt=s(),m(Q.$$.fragment),ct=s(),L=i("p"),L.textContent=Il,ot=s(),m(Z.$$.fragment),yt=s(),F=i("pre"),F.textContent=vl,Tt=s(),X=i("p"),X.textContent=Rl,Jt=s(),Y=i("p"),Y.innerHTML=xl,Ut=s(),m(P.$$.fragment),ut=s(),z=i("p"),z.innerHTML=Bl,jt=s(),m(D.$$.fragment),dt=s(),O=i("p"),O.innerHTML=Nl,ft=s(),m(q.$$.fragment),wt=s(),K=i("p"),K.innerHTML=Gl,bt=s(),m(ee.$$.fragment),Ct=s(),te=i("p"),te.innerHTML=Al,$t=s(),m(le.$$.fragment),Et=s(),ne=i("pre"),ne.textContent=kl,gt=s(),m(se.$$.fragment),It=s(),ae=i("p"),ae.textContent=Sl,vt=s(),ie=i("p"),ie.textContent=Vl,Rt=s(),m(pe.$$.fragment),xt=s(),re=i("p"),re.innerHTML=Wl,Bt=s(),me=i("p"),me.innerHTML=_l,Nt=s(),he=i("ul"),he.innerHTML=Hl,Gt=s(),Me=i("p"),Me.innerHTML=Ql,At=s(),m(ce.$$.fragment),kt=s(),m(oe.$$.fragment),St=s(),ye=i("p"),ye.textContent=Ll,Vt=s(),m(Te.$$.fragment),Wt=s(),Je=i("p"),Je.innerHTML=Zl,_t=s(),m(Ue.$$.fragment),Ht=s(),ue=i("p"),ue.innerHTML=Fl,Qt=s(),je=i("p"),je.textContent=Xl,Lt=s(),de=i("p"),de.innerHTML=Yl,Zt=s(),m(fe.$$.fragment),Ft=s(),we=i("pre"),we.textContent=Pl,Xt=s(),m(be.$$.fragment),Yt=s(),Ce=i("p"),Ce.innerHTML=zl,Pt=s(),m($e.$$.fragment),zt=s(),Ee=i("p"),Ee.innerHTML=Dl,Dt=s(),ge=i("p"),ge.innerHTML=Ol,Ot=s(),m(Ie.$$.fragment),qt=s(),ve=i("pre"),ve.textContent=ql,Kt=s(),m(Re.$$.fragment),el=s(),xe=i("p"),xe.innerHTML=Kl,tl=s(),m(Be.$$.fragment),ll=s(),Ne=i("p"),Ne.innerHTML=en,nl=s(),Ge=i("p"),Ge.innerHTML=tn,sl=s(),m(Ae.$$.fragment),al=s(),ke=i("pre"),ke.textContent=ln,il=s(),pl=i("hr"),rl=s(),m(Se.$$.fragment),ml=s(),We=i("p"),this.h()},l(e){const t=hn("svelte-u9bgzb",document.head);U=p(t,"META",{name:!0,content:!0}),t.forEach(l),_e=a(e),Ve=p(e,"P",{}),nn(Ve).forEach(l),He=a(e),h(j.$$.fragment,e),Qe=a(e),h(d.$$.fragment,e),Le=a(e),h(f.$$.fragment,e),Ze=a(e),w=p(e,"P",{"data-svelte-h":!0}),r(w)!=="svelte-i0los7"&&(w.innerHTML=ol),Fe=a(e),b=p(e,"P",{"data-svelte-h":!0}),r(b)!=="svelte-1slej1u"&&(b.innerHTML=yl),Xe=a(e),C=p(e,"P",{"data-svelte-h":!0}),r(C)!=="svelte-zc0mv5"&&(C.innerHTML=Tl),Ye=a(e),$=p(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-9mhpcy"&&($.textContent=Jl),Pe=a(e),E=p(e,"UL",{"data-svelte-h":!0}),r(E)!=="svelte-10de7sj"&&(E.innerHTML=Ul),ze=a(e),u=p(e,"P",{align:!0,"data-svelte-h":!0}),r(u)!=="svelte-xuaq4q"&&(u.innerHTML=ul),De=a(e),h(g.$$.fragment,e),Oe=a(e),h(I.$$.fragment,e),qe=a(e),h(v.$$.fragment,e),Ke=a(e),R=p(e,"P",{"data-svelte-h":!0}),r(R)!=="svelte-424c8m"&&(R.innerHTML=jl),et=a(e),x=p(e,"P",{"data-svelte-h":!0}),r(x)!=="svelte-16s4f3q"&&(x.innerHTML=dl),tt=a(e),B=p(e,"P",{"data-svelte-h":!0}),r(B)!=="svelte-f5pyyy"&&(B.innerHTML=fl),lt=a(e),h(N.$$.fragment,e),nt=a(e),G=p(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-htruz2"&&(G.innerHTML=wl),st=a(e),h(A.$$.fragment,e),at=a(e),h(k.$$.fragment,e),it=a(e),S=p(e,"P",{"data-svelte-h":!0}),r(S)!=="svelte-o366tg"&&(S.innerHTML=bl),pt=a(e),V=p(e,"P",{"data-svelte-h":!0}),r(V)!=="svelte-1wdeiyo"&&(V.textContent=Cl),rt=a(e),W=p(e,"UL",{"data-svelte-h":!0}),r(W)!=="svelte-10cni14"&&(W.innerHTML=$l),mt=a(e),_=p(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-1559j1z"&&(_.textContent=El),ht=a(e),H=p(e,"UL",{"data-svelte-h":!0}),r(H)!=="svelte-gyu5q2"&&(H.innerHTML=gl),Mt=a(e),h(Q.$$.fragment,e),ct=a(e),L=p(e,"P",{"data-svelte-h":!0}),r(L)!=="svelte-npbyc6"&&(L.textContent=Il),ot=a(e),h(Z.$$.fragment,e),yt=a(e),F=p(e,"PRE",{"data-svelte-h":!0}),r(F)!=="svelte-rbst4l"&&(F.textContent=vl),Tt=a(e),X=p(e,"P",{"data-svelte-h":!0}),r(X)!=="svelte-14xykdx"&&(X.textContent=Rl),Jt=a(e),Y=p(e,"P",{"data-svelte-h":!0}),r(Y)!=="svelte-s0xiop"&&(Y.innerHTML=xl),Ut=a(e),h(P.$$.fragment,e),ut=a(e),z=p(e,"P",{"data-svelte-h":!0}),r(z)!=="svelte-x7fcz7"&&(z.innerHTML=Bl),jt=a(e),h(D.$$.fragment,e),dt=a(e),O=p(e,"P",{"data-svelte-h":!0}),r(O)!=="svelte-186k0iz"&&(O.innerHTML=Nl),ft=a(e),h(q.$$.fragment,e),wt=a(e),K=p(e,"P",{"data-svelte-h":!0}),r(K)!=="svelte-18efmh4"&&(K.innerHTML=Gl),bt=a(e),h(ee.$$.fragment,e),Ct=a(e),te=p(e,"P",{"data-svelte-h":!0}),r(te)!=="svelte-1d4c1rr"&&(te.innerHTML=Al),$t=a(e),h(le.$$.fragment,e),Et=a(e),ne=p(e,"PRE",{"data-svelte-h":!0}),r(ne)!=="svelte-10f2otb"&&(ne.textContent=kl),gt=a(e),h(se.$$.fragment,e),It=a(e),ae=p(e,"P",{"data-svelte-h":!0}),r(ae)!=="svelte-pzijgi"&&(ae.textContent=Sl),vt=a(e),ie=p(e,"P",{"data-svelte-h":!0}),r(ie)!=="svelte-mnkp3p"&&(ie.textContent=Vl),Rt=a(e),h(pe.$$.fragment,e),xt=a(e),re=p(e,"P",{"data-svelte-h":!0}),r(re)!=="svelte-10m53jk"&&(re.innerHTML=Wl),Bt=a(e),me=p(e,"P",{"data-svelte-h":!0}),r(me)!=="svelte-1n4rf33"&&(me.innerHTML=_l),Nt=a(e),he=p(e,"UL",{"data-svelte-h":!0}),r(he)!=="svelte-1ipzxuv"&&(he.innerHTML=Hl),Gt=a(e),Me=p(e,"P",{"data-svelte-h":!0}),r(Me)!=="svelte-sk0nq"&&(Me.innerHTML=Ql),At=a(e),h(ce.$$.fragment,e),kt=a(e),h(oe.$$.fragment,e),St=a(e),ye=p(e,"P",{"data-svelte-h":!0}),r(ye)!=="svelte-5v4k"&&(ye.textContent=Ll),Vt=a(e),h(Te.$$.fragment,e),Wt=a(e),Je=p(e,"P",{"data-svelte-h":!0}),r(Je)!=="svelte-1jtalvx"&&(Je.innerHTML=Zl),_t=a(e),h(Ue.$$.fragment,e),Ht=a(e),ue=p(e,"P",{"data-svelte-h":!0}),r(ue)!=="svelte-1w38y06"&&(ue.innerHTML=Fl),Qt=a(e),je=p(e,"P",{"data-svelte-h":!0}),r(je)!=="svelte-1vj7s1m"&&(je.textContent=Xl),Lt=a(e),de=p(e,"P",{"data-svelte-h":!0}),r(de)!=="svelte-1y4zmei"&&(de.innerHTML=Yl),Zt=a(e),h(fe.$$.fragment,e),Ft=a(e),we=p(e,"PRE",{"data-svelte-h":!0}),r(we)!=="svelte-1i2j01w"&&(we.textContent=Pl),Xt=a(e),h(be.$$.fragment,e),Yt=a(e),Ce=p(e,"P",{"data-svelte-h":!0}),r(Ce)!=="svelte-1v0x9b3"&&(Ce.innerHTML=zl),Pt=a(e),h($e.$$.fragment,e),zt=a(e),Ee=p(e,"P",{"data-svelte-h":!0}),r(Ee)!=="svelte-xdv97c"&&(Ee.innerHTML=Dl),Dt=a(e),ge=p(e,"P",{"data-svelte-h":!0}),r(ge)!=="svelte-1yvj1cf"&&(ge.innerHTML=Ol),Ot=a(e),h(Ie.$$.fragment,e),qt=a(e),ve=p(e,"PRE",{"data-svelte-h":!0}),r(ve)!=="svelte-1mq04bw"&&(ve.textContent=ql),Kt=a(e),h(Re.$$.fragment,e),el=a(e),xe=p(e,"P",{"data-svelte-h":!0}),r(xe)!=="svelte-ezr54h"&&(xe.innerHTML=Kl),tl=a(e),h(Be.$$.fragment,e),ll=a(e),Ne=p(e,"P",{"data-svelte-h":!0}),r(Ne)!=="svelte-5egzd2"&&(Ne.innerHTML=en),nl=a(e),Ge=p(e,"P",{"data-svelte-h":!0}),r(Ge)!=="svelte-18615mk"&&(Ge.innerHTML=tn),sl=a(e),h(Ae.$$.fragment,e),al=a(e),ke=p(e,"PRE",{"data-svelte-h":!0}),r(ke)!=="svelte-bo2yaw"&&(ke.textContent=ln),il=a(e),pl=p(e,"HR",{}),rl=a(e),h(Se.$$.fragment,e),ml=a(e),We=p(e,"P",{}),nn(We).forEach(l),this.h()},h(){Ml(U,"name","hf:doc:metadata"),Ml(U,"content",Jn),Ml(u,"align","center")},m(e,t){Mn(document.head,U),n(e,_e,t),n(e,Ve,t),n(e,He,t),M(j,e,t),n(e,Qe,t),M(d,e,t),n(e,Le,t),M(f,e,t),n(e,Ze,t),n(e,w,t),n(e,Fe,t),n(e,b,t),n(e,Xe,t),n(e,C,t),n(e,Ye,t),n(e,$,t),n(e,Pe,t),n(e,E,t),n(e,ze,t),n(e,u,t),n(e,De,t),M(g,e,t),n(e,Oe,t),M(I,e,t),n(e,qe,t),M(v,e,t),n(e,Ke,t),n(e,R,t),n(e,et,t),n(e,x,t),n(e,tt,t),n(e,B,t),n(e,lt,t),M(N,e,t),n(e,nt,t),n(e,G,t),n(e,st,t),M(A,e,t),n(e,at,t),M(k,e,t),n(e,it,t),n(e,S,t),n(e,pt,t),n(e,V,t),n(e,rt,t),n(e,W,t),n(e,mt,t),n(e,_,t),n(e,ht,t),n(e,H,t),n(e,Mt,t),M(Q,e,t),n(e,ct,t),n(e,L,t),n(e,ot,t),M(Z,e,t),n(e,yt,t),n(e,F,t),n(e,Tt,t),n(e,X,t),n(e,Jt,t),n(e,Y,t),n(e,Ut,t),M(P,e,t),n(e,ut,t),n(e,z,t),n(e,jt,t),M(D,e,t),n(e,dt,t),n(e,O,t),n(e,ft,t),M(q,e,t),n(e,wt,t),n(e,K,t),n(e,bt,t),M(ee,e,t),n(e,Ct,t),n(e,te,t),n(e,$t,t),M(le,e,t),n(e,Et,t),n(e,ne,t),n(e,gt,t),M(se,e,t),n(e,It,t),n(e,ae,t),n(e,vt,t),n(e,ie,t),n(e,Rt,t),M(pe,e,t),n(e,xt,t),n(e,re,t),n(e,Bt,t),n(e,me,t),n(e,Nt,t),n(e,he,t),n(e,Gt,t),n(e,Me,t),n(e,At,t),M(ce,e,t),n(e,kt,t),M(oe,e,t),n(e,St,t),n(e,ye,t),n(e,Vt,t),M(Te,e,t),n(e,Wt,t),n(e,Je,t),n(e,_t,t),M(Ue,e,t),n(e,Ht,t),n(e,ue,t),n(e,Qt,t),n(e,je,t),n(e,Lt,t),n(e,de,t),n(e,Zt,t),M(fe,e,t),n(e,Ft,t),n(e,we,t),n(e,Xt,t),M(be,e,t),n(e,Yt,t),n(e,Ce,t),n(e,Pt,t),M($e,e,t),n(e,zt,t),n(e,Ee,t),n(e,Dt,t),n(e,ge,t),n(e,Ot,t),M(Ie,e,t),n(e,qt,t),n(e,ve,t),n(e,Kt,t),M(Re,e,t),n(e,el,t),n(e,xe,t),n(e,tl,t),M(Be,e,t),n(e,ll,t),n(e,Ne,t),n(e,nl,t),n(e,Ge,t),n(e,sl,t),M(Ae,e,t),n(e,al,t),n(e,ke,t),n(e,il,t),n(e,pl,t),n(e,rl,t),M(Se,e,t),n(e,ml,t),n(e,We,t),hl=!0},p:an,i(e){hl||(c(j.$$.fragment,e),c(d.$$.fragment,e),c(f.$$.fragment,e),c(g.$$.fragment,e),c(I.$$.fragment,e),c(v.$$.fragment,e),c(N.$$.fragment,e),c(A.$$.fragment,e),c(k.$$.fragment,e),c(Q.$$.fragment,e),c(Z.$$.fragment,e),c(P.$$.fragment,e),c(D.$$.fragment,e),c(q.$$.fragment,e),c(ee.$$.fragment,e),c(le.$$.fragment,e),c(se.$$.fragment,e),c(pe.$$.fragment,e),c(ce.$$.fragment,e),c(oe.$$.fragment,e),c(Te.$$.fragment,e),c(Ue.$$.fragment,e),c(fe.$$.fragment,e),c(be.$$.fragment,e),c($e.$$.fragment,e),c(Ie.$$.fragment,e),c(Re.$$.fragment,e),c(Be.$$.fragment,e),c(Ae.$$.fragment,e),c(Se.$$.fragment,e),hl=!0)},o(e){o(j.$$.fragment,e),o(d.$$.fragment,e),o(f.$$.fragment,e),o(g.$$.fragment,e),o(I.$$.fragment,e),o(v.$$.fragment,e),o(N.$$.fragment,e),o(A.$$.fragment,e),o(k.$$.fragment,e),o(Q.$$.fragment,e),o(Z.$$.fragment,e),o(P.$$.fragment,e),o(D.$$.fragment,e),o(q.$$.fragment,e),o(ee.$$.fragment,e),o(le.$$.fragment,e),o(se.$$.fragment,e),o(pe.$$.fragment,e),o(ce.$$.fragment,e),o(oe.$$.fragment,e),o(Te.$$.fragment,e),o(Ue.$$.fragment,e),o(fe.$$.fragment,e),o(be.$$.fragment,e),o($e.$$.fragment,e),o(Ie.$$.fragment,e),o(Re.$$.fragment,e),o(Be.$$.fragment,e),o(Ae.$$.fragment,e),o(Se.$$.fragment,e),hl=!1},d(e){e&&(l(_e),l(Ve),l(He),l(Qe),l(Le),l(Ze),l(w),l(Fe),l(b),l(Xe),l(C),l(Ye),l($),l(Pe),l(E),l(ze),l(u),l(De),l(Oe),l(qe),l(Ke),l(R),l(et),l(x),l(tt),l(B),l(lt),l(nt),l(G),l(st),l(at),l(it),l(S),l(pt),l(V),l(rt),l(W),l(mt),l(_),l(ht),l(H),l(Mt),l(ct),l(L),l(ot),l(yt),l(F),l(Tt),l(X),l(Jt),l(Y),l(Ut),l(ut),l(z),l(jt),l(dt),l(O),l(ft),l(wt),l(K),l(bt),l(Ct),l(te),l($t),l(Et),l(ne),l(gt),l(It),l(ae),l(vt),l(ie),l(Rt),l(xt),l(re),l(Bt),l(me),l(Nt),l(he),l(Gt),l(Me),l(At),l(kt),l(St),l(ye),l(Vt),l(Wt),l(Je),l(_t),l(Ht),l(ue),l(Qt),l(je),l(Lt),l(de),l(Zt),l(Ft),l(we),l(Xt),l(Yt),l(Ce),l(Pt),l(zt),l(Ee),l(Dt),l(ge),l(Ot),l(qt),l(ve),l(Kt),l(el),l(xe),l(tl),l(ll),l(Ne),l(nl),l(Ge),l(sl),l(al),l(ke),l(il),l(pl),l(rl),l(ml),l(We)),l(U),y(j,e),y(d,e),y(f,e),y(g,e),y(I,e),y(v,e),y(N,e),y(A,e),y(k,e),y(Q,e),y(Z,e),y(P,e),y(D,e),y(q,e),y(ee,e),y(le,e),y(se,e),y(pe,e),y(ce,e),y(oe,e),y(Te,e),y(Ue,e),y(fe,e),y(be,e),y($e,e),y(Ie,e),y(Re,e),y(Be,e),y(Ae,e),y(Se,e)}}}const Jn='{"title":"利用知识图谱增强 RAG 推理能力","local":"利用知识图谱增强-rag-推理能力","sections":[{"title":"初始化","local":"初始化","sections":[{"title":"设置 Neo4j 实例","local":"设置-neo4j-实例","sections":[],"depth":3},{"title":"将数据集加载到图谱中","local":"将数据集加载到图谱中","sections":[],"depth":3},{"title":"构建向量索引","local":"构建向量索引","sections":[],"depth":3}],"depth":2},{"title":"基于相似性的问答","local":"基于相似性的问答","sections":[],"depth":2},{"title":"通过知识图谱进行推理","local":"通过知识图谱进行推理","sections":[{"title":"Graph-Cypher-Chain 与 LangChain","local":"graph-cypher-chain-与-langchain","sections":[],"depth":3},{"title":"使用自然语言的查询示例","local":"使用自然语言的查询示例","sections":[{"title":"” Emily Chen 发布了多少篇文章？ ”","local":"-emily-chen-发布了多少篇文章-","sections":[],"depth":4},{"title":"” 是否有任何一对研究人员共同发布了超过三篇文章？ ”","local":"-是否有任何一对研究人员共同发布了超过三篇文章-","sections":[],"depth":4},{"title":"” 哪位研究人员与最多的同行合作过？ ”","local":"-哪位研究人员与最多的同行合作过-","sections":[],"depth":4}],"depth":3}],"depth":2}],"depth":1}';function Un(cl){return pn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class bn extends rn{constructor(U){super(),mn(this,U,Un,Tn,sn,{})}}export{bn as component};
