import{s as ln,n as nn,o as sn}from"../chunks/scheduler.65852ee5.js";import{S as an,i as pn,g as i,s,r as m,A as rn,h as p,f as l,c as a,j as tn,u as h,x as r,k as ml,y as mn,a as n,v as M,d as o,t as c,w as y}from"../chunks/index.aa74147d.js";import{D as hn,C as T}from"../chunks/DocNotebookDropdown.1a7e6a42.js";import{H as J,E as Mn}from"../chunks/index.e2566494.js";function on(hl){let U,We,_e,Ve,j,xe,w,Fe,d,Ml='<em>作者: <a href="https://github.com/dcarpintero" rel="nofollow">Diego Carpintero</a></em>',Le,b,ol="知识图谱提供了一种以既能为人类又能为机器理解的格式建模和存储互联信息的方法。这些图谱由<em>节点</em>和<em>边</em>组成，分别表示实体及其关系。与传统数据库不同，图谱固有的表达能力允许更丰富的语义理解，同时提供了灵活性，可以在不受固定模式限制的情况下，适应新的实体类型和关系。",Qe,f,cl="通过将知识图谱与嵌入（向量搜索）结合，我们可以利用<em>多跳连接性</em>和<em>信息的上下文理解</em>，来增强大语言模型（LLMs）的推理能力和可解释性。",Ze,C,yl="本文档探讨了这一方法的实际应用，展示了如何：",Xe,$,Tl='<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>',Ye,u,Jl='<img src="https://raw.githubusercontent.com/dcarpintero/generative-ai-101/main/static/knowledge-graphs.png"/>',ze,I,Pe,g,qe,E,De,v,Ul='我们将使用 <a href="https://neo4j.com/docs/" rel="nofollow">Neo4j</a> 来创建我们的知识图谱，它是一个开源的数据库管理系统，专门用于图数据库技术。',Oe,R,ul='为了快速且简便地设置，您可以在 <a href="https://neo4j.com/product/auradb/" rel="nofollow">Neo4j Aura</a>上 启动一个免费的实例。',Ke,B,jl="接着，你可以使用 <code>.env</code> 文件将 <code>NEO4J_URI</code>、<code>NEO4J_USERNAME</code> 和 <code>NEO4J_PASSWORD</code> 设置为环境变量：",et,G,tt,N,wl="LangChain 提供了 <code>Neo4jGraph</code> 类来与 Neo4j 进行交互：",lt,S,nt,k,st,A,dl='以下示例演示了如何与我们的 <code>Neo4j</code> 数据库建立连接，并使用<a href="https://github.com/dcarpintero/generative-ai-101/blob/main/dataset/synthetic_articles.csv" rel="nofollow">合成数据</a>填充它，这些数据包括研究文章及其作者。',at,_,bl="实体包括：",it,H,fl="<li><em>研究人员</em>（Researcher）</li> <li><em>文章</em>（Article）</li> <li><em>主题</em>（Topic）</li>",pt,W,Cl="关系包括：",rt,V,$l="<li><em>研究人员</em> —[PUBLISHED]—&gt; <em>文章</em></li> <li><em>文章</em> —[IN_TOPIC]—&gt; <em>主题</em></li>",mt,x,ht,F,Il="让我们检查节点和关系是否已正确初始化：",Mt,L,ot,Q,gl=`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)
`,ct,Z,El="我们可以在 Neo4j 工作区中检查我们的知识图谱：",yt,X,vl='<img src="https://raw.githubusercontent.com/dcarpintero/generative-ai-101/main/static/kg_sample_00.png"/>',Tt,Y,Jt,z,Rl="现在，我们构建一个向量索引，以便根据<em>主题、标题和摘要</em>高效地搜索相关的<em>文章</em>。这一过程包括使用这些字段计算每篇文章的嵌入。在查询时，系统通过使用相似性度量（例如余弦距离）来找到与用户输入最相似的文章。",Ut,P,ut,q,Bl='<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>集成，进行实验和对比。',jt,D,wt,O,Gl="<code>Langchain RetrievalQA</code> 创建了一个问答（QA）链，使用上述的向量索引作为检索器。",dt,K,bt,ee,Nl="我们来问一下：“<em>哪些文章讨论了人工智能如何影响我们的日常生活？</em>”",ft,te,Ct,le,Sl=`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.
`,$t,ne,It,se,kl="知识图谱非常适合于在实体之间建立连接，能够提取模式并发现新的洞察。",gt,ae,Al="本节将演示如何实现这一过程，并通过自然语言查询将结果集成到大语言模型（LLM）管道中。",Et,ie,vt,pe,_l="为了构建富有表现力且高效的查询，<code>Neo4j</code> 使用 <code>Cypher</code>，一种受 SQL 启发的声明式查询语言。<code>LangChain</code> 提供了封装器 <code>GraphCypherQAChain</code>，它是一个抽象层，允许通过自然语言查询图数据库，从而更容易将基于图的数据检索集成到大语言模型（LLM）管道中。",Rt,re,Hl="在实际应用中，<code>GraphCypherQAChain</code>：",Bt,me,Wl="<li>从用户输入（自然语言）生成 Cypher 语句（图数据库的查询，如 Neo4j），并应用上下文学习（提示工程），</li> <li>将这些语句执行到图数据库中，</li> <li>将结果作为上下文提供，帮助 LLM 基于准确、最新的信息生成回答。</li>",Gt,he,Vl="<strong>注意：</strong> 该实现涉及执行模型生成的图查询，这可能带来潜在风险，例如意外访问或修改数据库中的敏感数据。为减少这些风险，请确保数据库连接权限尽可能受限，以满足链/代理的特定需求。虽然这种方法能够降低风险，但并不能完全消除风险。",Nt,Me,St,oe,kt,ce,xl="请注意，在以下示例中，Cypher 查询执行的结果是如何作为上下文提供给大语言模型（LLM）的：",At,ye,_t,Te,Fl="在这个示例中，我们的问题“<em>Emily Chen 发布了多少篇文章？</em>”将被转换为以下 Cypher 查询：",Ht,Je,Wt,Ue,Ll="该查询通过匹配名称为“Emily Chen”的 <code>Researcher</code> 节点，并遍历与之相关的 <code>PUBLISHED</code> 关系，连接到 <code>Article</code> 节点。然后，它计算与“Emily Chen”连接的 <code>Article</code> 节点的数量。",Vt,ue,Ql="执行查询后，结果将作为上下文提供给 LLM，LLM 基于这个上下文来生成回答。",xt,je,Zl='<img src="https://raw.githubusercontent.com/dcarpintero/generative-ai-101/main/static/kg_sample_01.png" width="40%"/>',Ft,we,Lt,de,Xl=`\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
`,Qt,be,Zt,fe,Yl="在这个示例中，查询“<em>是否有任何一对研究人员共同发布了超过三篇文章？</em>”将结果转换为以下 Cypher 查询：",Xt,Ce,Yt,$e,zl="该查询首先从 <code>Researcher</code> 节点出发，遍历 <code>PUBLISHED</code> 关系，找到与之连接的 <code>Article</code> 节点，然后再次遍历，查找与另一位 <code>Researcher</code> 节点的连接。通过这种方式，查询找出那些共同发表了超过三篇文章的研究人员对。最终，结果将作为上下文提供给 LLM，LLM 会基于这个上下文生成回答。",zt,Ie,Pl='<img src="https://raw.githubusercontent.com/dcarpintero/generative-ai-101/main/static/kg_sample_02.png"/>',Pt,ge,qt,Ee,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
`,Dt,ve,Ot,Re,Dl=`让我们找出哪位研究人员与最多的同行合作过。<br/>
我们的查询“<em>哪位研究人员与最多的同行合作过？</em>”现在转换为以下 Cypher 查询：`,Kt,Be,el,Ge,Ol="在这个查询中，我们从所有 <code>Researcher</code> 节点出发，遍历它们的 <code>PUBLISHED</code> 关系，找到与之连接的 <code>Article</code> 节点。对于每个 <code>Article</code> 节点，Neo4j 会继续回溯，查找那些也发表了同一篇文章的其他 <code>Researcher</code> 节点（同行）。通过这种方式，查询能够计算出每位研究人员与多少位同行合作，并按合作次数降序排列，最终返回合作最多的研究人员及其同行数量。",tl,Ne,Kl='<img src="https://raw.githubusercontent.com/dcarpintero/generative-ai-101/main/static/kg_sample_03.png"/>',ll,Se,nl,ke,en=`\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
`,sl,al,il,Ae,pl,He,rl;return j=new hn({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"}]}}),w=new J({props:{title:"利用知识图谱增强 RAG 推理能力",local:"利用知识图谱增强-rag-推理能力",headingTag:"h1"}}),I=new J({props:{title:"初始化",local:"初始化",headingTag:"h2"}}),g=new T({props:{code:"JTI1cGlwJTIwaW5zdGFsbCUyMG5lbzRqJTIwbGFuZ2NoYWluJTIwbGFuZ2NoYWluX29wZW5haSUyMGxhbmdjaGFpbi1jb21tdW5pdHklMjBweXRob24tZG90ZW52JTIwLS1xdWlldA==",highlighted:"%pip install neo4j langchain langchain_openai langchain-community python-dotenv --quiet",wrap:!1}}),E=new J({props:{title:"设置 Neo4j 实例",local:"设置-neo4j-实例",headingTag:"h3"}}),G=new T({props:{code:"aW1wb3J0JTIwZG90ZW52JTBBJTBBZG90ZW52LmxvYWRfZG90ZW52KCUyMi5lbnYlMjIlMkMlMjBvdmVycmlkZSUzRFRydWUp",highlighted:`<span class="hljs-keyword">import</span> dotenv

dotenv.load_dotenv(<span class="hljs-string">&quot;.env&quot;</span>, override=<span class="hljs-literal">True</span>)`,wrap:!1}}),S=new T({props:{code:"aW1wb3J0JTIwb3MlMEFmcm9tJTIwbGFuZ2NoYWluX2NvbW11bml0eS5ncmFwaHMlMjBpbXBvcnQlMjBOZW80akdyYXBoJTBBJTBBZ3JhcGglMjAlM0QlMjBOZW80akdyYXBoKCUwQSUyMCUyMCUyMCUyMHVybCUzRG9zLmVudmlyb24lNUIlMjJORU80Sl9VUkklMjIlNUQlMkMlMEElMjAlMjAlMjAlMjB1c2VybmFtZSUzRG9zLmVudmlyb24lNUIlMjJORU80Sl9VU0VSTkFNRSUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHBhc3N3b3JkJTNEb3MuZW52aXJvbiU1QiUyMk5FTzRKX1BBU1NXT1JEJTIyJTVEJTJDJTBBKQ==",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">&quot;NEO4J_URI&quot;</span>],
    username=os.environ[<span class="hljs-string">&quot;NEO4J_USERNAME&quot;</span>],
    password=os.environ[<span class="hljs-string">&quot;NEO4J_PASSWORD&quot;</span>],
)`,wrap:!1}}),k=new J({props:{title:"将数据集加载到图谱中",local:"将数据集加载到图谱中",headingTag:"h3"}}),x=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}}),L=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}}),Y=new J({props:{title:"构建向量索引",local:"构建向量索引",headingTag:"h3"}}),P=new T({props:{code:"ZnJvbSUyMGxhbmdjaGFpbl9jb21tdW5pdHkudmVjdG9yc3RvcmVzJTIwaW1wb3J0JTIwTmVvNGpWZWN0b3IlMEFmcm9tJTIwbGFuZ2NoYWluX29wZW5haSUyMGltcG9ydCUyME9wZW5BSUVtYmVkZGluZ3MlMEElMEF2ZWN0b3JfaW5kZXglMjAlM0QlMjBOZW80alZlY3Rvci5mcm9tX2V4aXN0aW5nX2dyYXBoKCUwQSUyMCUyMCUyMCUyME9wZW5BSUVtYmVkZGluZ3MoKSUyQyUwQSUyMCUyMCUyMCUyMHVybCUzRG9zLmVudmlyb24lNUIlMjJORU80Sl9VUkklMjIlNUQlMkMlMEElMjAlMjAlMjAlMjB1c2VybmFtZSUzRG9zLmVudmlyb24lNUIlMjJORU80Sl9VU0VSTkFNRSUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHBhc3N3b3JkJTNEb3MuZW52aXJvbiU1QiUyMk5FTzRKX1BBU1NXT1JEJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwaW5kZXhfbmFtZSUzRCUyMmFydGljbGVzJTIyJTJDJTBBJTIwJTIwJTIwJTIwbm9kZV9sYWJlbCUzRCUyMkFydGljbGUlMjIlMkMlMEElMjAlMjAlMjAlMjB0ZXh0X25vZGVfcHJvcGVydGllcyUzRCU1QiUyMnRvcGljJTIyJTJDJTIwJTIydGl0bGUlMjIlMkMlMjAlMjJhYnN0cmFjdCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGVtYmVkZGluZ19ub2RlX3Byb3BlcnR5JTNEJTIyZW1iZWRkaW5nJTIyJTJDJTBBKQ==",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">&quot;NEO4J_URI&quot;</span>],
    username=os.environ[<span class="hljs-string">&quot;NEO4J_USERNAME&quot;</span>],
    password=os.environ[<span class="hljs-string">&quot;NEO4J_PASSWORD&quot;</span>],
    index_name=<span class="hljs-string">&quot;articles&quot;</span>,
    node_label=<span class="hljs-string">&quot;Article&quot;</span>,
    text_node_properties=[<span class="hljs-string">&quot;topic&quot;</span>, <span class="hljs-string">&quot;title&quot;</span>, <span class="hljs-string">&quot;abstract&quot;</span>],
    embedding_node_property=<span class="hljs-string">&quot;embedding&quot;</span>,
)`,wrap:!1}}),D=new J({props:{title:"基于相似性的问答",local:"基于相似性的问答",headingTag:"h2"}}),K=new T({props:{code:"ZnJvbSUyMGxhbmdjaGFpbi5jaGFpbnMlMjBpbXBvcnQlMjBSZXRyaWV2YWxRQSUwQWZyb20lMjBsYW5nY2hhaW5fb3BlbmFpJTIwaW1wb3J0JTIwQ2hhdE9wZW5BSSUwQSUwQXZlY3Rvcl9xYSUyMCUzRCUyMFJldHJpZXZhbFFBLmZyb21fY2hhaW5fdHlwZShsbG0lM0RDaGF0T3BlbkFJKCklMkMlMjBjaGFpbl90eXBlJTNEJTIyc3R1ZmYlMjIlMkMlMjByZXRyaWV2ZXIlM0R2ZWN0b3JfaW5kZXguYXNfcmV0cmlldmVyKCkp",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}}),te=new T({props:{code:"ciUyMCUzRCUyMHZlY3Rvcl9xYS5pbnZva2UoJTBBJTIwJTIwJTIwJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIycXVlcnklMjIlM0ElMjAlMjJ3aGljaCUyMGFydGljbGVzJTIwZGlzY3VzcyUyMGhvdyUyMEFJJTIwbWlnaHQlMjBhZmZlY3QlMjBvdXIlMjBkYWlseSUyMGxpZmUlM0YlMjBpbmNsdWRlJTIwdGhlJTIwYXJ0aWNsZSUyMHRpdGxlcyUyMGFuZCUyMGFic3RyYWN0cy4lMjIlMEElMjAlMjAlMjAlMjAlN0QlMEEpJTBBcHJpbnQociU1QiUyMnJlc3VsdCUyMiU1RCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>r = vector_qa.invoke(
<span class="hljs-meta">... </span>    {
<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">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(r[<span class="hljs-string">&quot;result&quot;</span>])`,wrap:!1}}),ne=new J({props:{title:"通过知识图谱进行推理",local:"通过知识图谱进行推理",headingTag:"h2"}}),ie=new J({props:{title:"Graph-Cypher-Chain 与 LangChain",local:"graph-cypher-chain-与-langchain",headingTag:"h3"}}),Me=new T({props:{code:"ZnJvbSUyMGxhbmdjaGFpbi5jaGFpbnMlMjBpbXBvcnQlMjBHcmFwaEN5cGhlclFBQ2hhaW4lMEFmcm9tJTIwbGFuZ2NoYWluX29wZW5haSUyMGltcG9ydCUyMENoYXRPcGVuQUklMEElMEFncmFwaC5yZWZyZXNoX3NjaGVtYSgpJTBBJTBBY3lwaGVyX2NoYWluJTIwJTNEJTIwR3JhcGhDeXBoZXJRQUNoYWluLmZyb21fbGxtKCUwQSUyMCUyMCUyMCUyMGN5cGhlcl9sbG0lM0RDaGF0T3BlbkFJKHRlbXBlcmF0dXJlJTNEMCUyQyUyMG1vZGVsX25hbWUlM0QlMjJncHQtNG8lMjIpJTJDJTBBJTIwJTIwJTIwJTIwcWFfbGxtJTNEQ2hhdE9wZW5BSSh0ZW1wZXJhdHVyZSUzRDAlMkMlMjBtb2RlbF9uYW1lJTNEJTIyZ3B0LTRvJTIyKSUyQyUwQSUyMCUyMCUyMCUyMGdyYXBoJTNEZ3JhcGglMkMlMEElMjAlMjAlMjAlMjB2ZXJib3NlJTNEVHJ1ZSUyQyUwQSk=",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">&quot;gpt-4o&quot;</span>),
    qa_llm=ChatOpenAI(temperature=<span class="hljs-number">0</span>, model_name=<span class="hljs-string">&quot;gpt-4o&quot;</span>),
    graph=graph,
    verbose=<span class="hljs-literal">True</span>,
)`,wrap:!1}}),oe=new J({props:{title:"使用自然语言的查询示例",local:"使用自然语言的查询示例",headingTag:"h3"}}),ye=new J({props:{title:"” Emily Chen 发布了多少篇文章？ ”",local:"-emily-chen-发布了多少篇文章-",headingTag:"h4"}}),Je=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}}),we=new T({props:{code:"JTIzJTIwdGhlJTIwYW5zd2VyJTIwc2hvdWxkJTIwYmUlMjAnNyclMEFjeXBoZXJfY2hhaW4uaW52b2tlKCU3QiUyMnF1ZXJ5JTIyJTNBJTIwJTIySG93JTIwbWFueSUyMGFydGljbGVzJTIwaGFzJTIwcHVibGlzaGVkJTIwRW1pbHklMjBDaGVuJTNGJTIyJTdEKQ==",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-string">&quot;query&quot;</span>: <span class="hljs-string">&quot;How many articles has published Emily Chen?&quot;</span>})`,wrap:!1}}),be=new J({props:{title:"” 是否有任何一对研究人员共同发布了超过三篇文章？ ”",local:"-是否有任何一对研究人员共同发布了超过三篇文章-",headingTag:"h4"}}),Ce=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}}),ge=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}}),ve=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}}),Se=new T({props:{code:"JTIzJTIwdGhlJTIwYW5zd2VyJTIwc2hvdWxkJTIwYmUlMjAnRGF2aWQlMjBKb2huc29uJyUwQWN5cGhlcl9jaGFpbi5pbnZva2UoJTdCJTIycXVlcnklMjIlM0ElMjAlMjJXaGljaCUyMHJlc2VhcmNoZXIlMjBoYXMlMjBjb2xsYWJvcmF0ZWQlMjB3aXRoJTIwdGhlJTIwbW9zdCUyMHBlZXJzJTNGJTIyJTdEKQ==",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-string">&quot;query&quot;</span>: <span class="hljs-string">&quot;Which researcher has collaborated with the most peers?&quot;</span>})`,wrap:!1}}),Ae=new Mn({props:{source:"https://github.com/huggingface/cookbook/blob/main/notebooks/zh-CN/rag_with_knowledge_graphs_neo4j.md"}}),{c(){U=i("meta"),We=s(),_e=i("p"),Ve=s(),m(j.$$.fragment),xe=s(),m(w.$$.fragment),Fe=s(),d=i("p"),d.innerHTML=Ml,Le=s(),b=i("p"),b.innerHTML=ol,Qe=s(),f=i("p"),f.innerHTML=cl,Ze=s(),C=i("p"),C.textContent=yl,Xe=s(),$=i("ul"),$.innerHTML=Tl,Ye=s(),u=i("p"),u.innerHTML=Jl,ze=s(),m(I.$$.fragment),Pe=s(),m(g.$$.fragment),qe=s(),m(E.$$.fragment),De=s(),v=i("p"),v.innerHTML=Ul,Oe=s(),R=i("p"),R.innerHTML=ul,Ke=s(),B=i("p"),B.innerHTML=jl,et=s(),m(G.$$.fragment),tt=s(),N=i("p"),N.innerHTML=wl,lt=s(),m(S.$$.fragment),nt=s(),m(k.$$.fragment),st=s(),A=i("p"),A.innerHTML=dl,at=s(),_=i("p"),_.textContent=bl,it=s(),H=i("ul"),H.innerHTML=fl,pt=s(),W=i("p"),W.textContent=Cl,rt=s(),V=i("ul"),V.innerHTML=$l,mt=s(),m(x.$$.fragment),ht=s(),F=i("p"),F.textContent=Il,Mt=s(),m(L.$$.fragment),ot=s(),Q=i("pre"),Q.textContent=gl,ct=s(),Z=i("p"),Z.textContent=El,yt=s(),X=i("p"),X.innerHTML=vl,Tt=s(),m(Y.$$.fragment),Jt=s(),z=i("p"),z.innerHTML=Rl,Ut=s(),m(P.$$.fragment),ut=s(),q=i("p"),q.innerHTML=Bl,jt=s(),m(D.$$.fragment),wt=s(),O=i("p"),O.innerHTML=Gl,dt=s(),m(K.$$.fragment),bt=s(),ee=i("p"),ee.innerHTML=Nl,ft=s(),m(te.$$.fragment),Ct=s(),le=i("pre"),le.textContent=Sl,$t=s(),m(ne.$$.fragment),It=s(),se=i("p"),se.textContent=kl,gt=s(),ae=i("p"),ae.textContent=Al,Et=s(),m(ie.$$.fragment),vt=s(),pe=i("p"),pe.innerHTML=_l,Rt=s(),re=i("p"),re.innerHTML=Hl,Bt=s(),me=i("ul"),me.innerHTML=Wl,Gt=s(),he=i("p"),he.innerHTML=Vl,Nt=s(),m(Me.$$.fragment),St=s(),m(oe.$$.fragment),kt=s(),ce=i("p"),ce.textContent=xl,At=s(),m(ye.$$.fragment),_t=s(),Te=i("p"),Te.innerHTML=Fl,Ht=s(),m(Je.$$.fragment),Wt=s(),Ue=i("p"),Ue.innerHTML=Ll,Vt=s(),ue=i("p"),ue.textContent=Ql,xt=s(),je=i("p"),je.innerHTML=Zl,Ft=s(),m(we.$$.fragment),Lt=s(),de=i("pre"),de.textContent=Xl,Qt=s(),m(be.$$.fragment),Zt=s(),fe=i("p"),fe.innerHTML=Yl,Xt=s(),m(Ce.$$.fragment),Yt=s(),$e=i("p"),$e.innerHTML=zl,zt=s(),Ie=i("p"),Ie.innerHTML=Pl,Pt=s(),m(ge.$$.fragment),qt=s(),Ee=i("pre"),Ee.textContent=ql,Dt=s(),m(ve.$$.fragment),Ot=s(),Re=i("p"),Re.innerHTML=Dl,Kt=s(),m(Be.$$.fragment),el=s(),Ge=i("p"),Ge.innerHTML=Ol,tl=s(),Ne=i("p"),Ne.innerHTML=Kl,ll=s(),m(Se.$$.fragment),nl=s(),ke=i("pre"),ke.textContent=en,sl=s(),al=i("hr"),il=s(),m(Ae.$$.fragment),pl=s(),He=i("p"),this.h()},l(e){const t=rn("svelte-u9bgzb",document.head);U=p(t,"META",{name:!0,content:!0}),t.forEach(l),We=a(e),_e=p(e,"P",{}),tn(_e).forEach(l),Ve=a(e),h(j.$$.fragment,e),xe=a(e),h(w.$$.fragment,e),Fe=a(e),d=p(e,"P",{"data-svelte-h":!0}),r(d)!=="svelte-i0los7"&&(d.innerHTML=Ml),Le=a(e),b=p(e,"P",{"data-svelte-h":!0}),r(b)!=="svelte-1slej1u"&&(b.innerHTML=ol),Qe=a(e),f=p(e,"P",{"data-svelte-h":!0}),r(f)!=="svelte-zc0mv5"&&(f.innerHTML=cl),Ze=a(e),C=p(e,"P",{"data-svelte-h":!0}),r(C)!=="svelte-9mhpcy"&&(C.textContent=yl),Xe=a(e),$=p(e,"UL",{"data-svelte-h":!0}),r($)!=="svelte-10de7sj"&&($.innerHTML=Tl),Ye=a(e),u=p(e,"P",{align:!0,"data-svelte-h":!0}),r(u)!=="svelte-xuaq4q"&&(u.innerHTML=Jl),ze=a(e),h(I.$$.fragment,e),Pe=a(e),h(g.$$.fragment,e),qe=a(e),h(E.$$.fragment,e),De=a(e),v=p(e,"P",{"data-svelte-h":!0}),r(v)!=="svelte-424c8m"&&(v.innerHTML=Ul),Oe=a(e),R=p(e,"P",{"data-svelte-h":!0}),r(R)!=="svelte-16s4f3q"&&(R.innerHTML=ul),Ke=a(e),B=p(e,"P",{"data-svelte-h":!0}),r(B)!=="svelte-f5pyyy"&&(B.innerHTML=jl),et=a(e),h(G.$$.fragment,e),tt=a(e),N=p(e,"P",{"data-svelte-h":!0}),r(N)!=="svelte-htruz2"&&(N.innerHTML=wl),lt=a(e),h(S.$$.fragment,e),nt=a(e),h(k.$$.fragment,e),st=a(e),A=p(e,"P",{"data-svelte-h":!0}),r(A)!=="svelte-o366tg"&&(A.innerHTML=dl),at=a(e),_=p(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-1wdeiyo"&&(_.textContent=bl),it=a(e),H=p(e,"UL",{"data-svelte-h":!0}),r(H)!=="svelte-10cni14"&&(H.innerHTML=fl),pt=a(e),W=p(e,"P",{"data-svelte-h":!0}),r(W)!=="svelte-1559j1z"&&(W.textContent=Cl),rt=a(e),V=p(e,"UL",{"data-svelte-h":!0}),r(V)!=="svelte-gyu5q2"&&(V.innerHTML=$l),mt=a(e),h(x.$$.fragment,e),ht=a(e),F=p(e,"P",{"data-svelte-h":!0}),r(F)!=="svelte-npbyc6"&&(F.textContent=Il),Mt=a(e),h(L.$$.fragment,e),ot=a(e),Q=p(e,"PRE",{"data-svelte-h":!0}),r(Q)!=="svelte-rbst4l"&&(Q.textContent=gl),ct=a(e),Z=p(e,"P",{"data-svelte-h":!0}),r(Z)!=="svelte-14xykdx"&&(Z.textContent=El),yt=a(e),X=p(e,"P",{"data-svelte-h":!0}),r(X)!=="svelte-s0xiop"&&(X.innerHTML=vl),Tt=a(e),h(Y.$$.fragment,e),Jt=a(e),z=p(e,"P",{"data-svelte-h":!0}),r(z)!=="svelte-x7fcz7"&&(z.innerHTML=Rl),Ut=a(e),h(P.$$.fragment,e),ut=a(e),q=p(e,"P",{"data-svelte-h":!0}),r(q)!=="svelte-186k0iz"&&(q.innerHTML=Bl),jt=a(e),h(D.$$.fragment,e),wt=a(e),O=p(e,"P",{"data-svelte-h":!0}),r(O)!=="svelte-18efmh4"&&(O.innerHTML=Gl),dt=a(e),h(K.$$.fragment,e),bt=a(e),ee=p(e,"P",{"data-svelte-h":!0}),r(ee)!=="svelte-1d4c1rr"&&(ee.innerHTML=Nl),ft=a(e),h(te.$$.fragment,e),Ct=a(e),le=p(e,"PRE",{"data-svelte-h":!0}),r(le)!=="svelte-10f2otb"&&(le.textContent=Sl),$t=a(e),h(ne.$$.fragment,e),It=a(e),se=p(e,"P",{"data-svelte-h":!0}),r(se)!=="svelte-pzijgi"&&(se.textContent=kl),gt=a(e),ae=p(e,"P",{"data-svelte-h":!0}),r(ae)!=="svelte-mnkp3p"&&(ae.textContent=Al),Et=a(e),h(ie.$$.fragment,e),vt=a(e),pe=p(e,"P",{"data-svelte-h":!0}),r(pe)!=="svelte-10m53jk"&&(pe.innerHTML=_l),Rt=a(e),re=p(e,"P",{"data-svelte-h":!0}),r(re)!=="svelte-1n4rf33"&&(re.innerHTML=Hl),Bt=a(e),me=p(e,"UL",{"data-svelte-h":!0}),r(me)!=="svelte-1ipzxuv"&&(me.innerHTML=Wl),Gt=a(e),he=p(e,"P",{"data-svelte-h":!0}),r(he)!=="svelte-sk0nq"&&(he.innerHTML=Vl),Nt=a(e),h(Me.$$.fragment,e),St=a(e),h(oe.$$.fragment,e),kt=a(e),ce=p(e,"P",{"data-svelte-h":!0}),r(ce)!=="svelte-5v4k"&&(ce.textContent=xl),At=a(e),h(ye.$$.fragment,e),_t=a(e),Te=p(e,"P",{"data-svelte-h":!0}),r(Te)!=="svelte-1jtalvx"&&(Te.innerHTML=Fl),Ht=a(e),h(Je.$$.fragment,e),Wt=a(e),Ue=p(e,"P",{"data-svelte-h":!0}),r(Ue)!=="svelte-1w38y06"&&(Ue.innerHTML=Ll),Vt=a(e),ue=p(e,"P",{"data-svelte-h":!0}),r(ue)!=="svelte-1vj7s1m"&&(ue.textContent=Ql),xt=a(e),je=p(e,"P",{"data-svelte-h":!0}),r(je)!=="svelte-1y4zmei"&&(je.innerHTML=Zl),Ft=a(e),h(we.$$.fragment,e),Lt=a(e),de=p(e,"PRE",{"data-svelte-h":!0}),r(de)!=="svelte-1i2j01w"&&(de.textContent=Xl),Qt=a(e),h(be.$$.fragment,e),Zt=a(e),fe=p(e,"P",{"data-svelte-h":!0}),r(fe)!=="svelte-1v0x9b3"&&(fe.innerHTML=Yl),Xt=a(e),h(Ce.$$.fragment,e),Yt=a(e),$e=p(e,"P",{"data-svelte-h":!0}),r($e)!=="svelte-xdv97c"&&($e.innerHTML=zl),zt=a(e),Ie=p(e,"P",{"data-svelte-h":!0}),r(Ie)!=="svelte-1yvj1cf"&&(Ie.innerHTML=Pl),Pt=a(e),h(ge.$$.fragment,e),qt=a(e),Ee=p(e,"PRE",{"data-svelte-h":!0}),r(Ee)!=="svelte-1mq04bw"&&(Ee.textContent=ql),Dt=a(e),h(ve.$$.fragment,e),Ot=a(e),Re=p(e,"P",{"data-svelte-h":!0}),r(Re)!=="svelte-ezr54h"&&(Re.innerHTML=Dl),Kt=a(e),h(Be.$$.fragment,e),el=a(e),Ge=p(e,"P",{"data-svelte-h":!0}),r(Ge)!=="svelte-5egzd2"&&(Ge.innerHTML=Ol),tl=a(e),Ne=p(e,"P",{"data-svelte-h":!0}),r(Ne)!=="svelte-18615mk"&&(Ne.innerHTML=Kl),ll=a(e),h(Se.$$.fragment,e),nl=a(e),ke=p(e,"PRE",{"data-svelte-h":!0}),r(ke)!=="svelte-bo2yaw"&&(ke.textContent=en),sl=a(e),al=p(e,"HR",{}),il=a(e),h(Ae.$$.fragment,e),pl=a(e),He=p(e,"P",{}),tn(He).forEach(l),this.h()},h(){ml(U,"name","hf:doc:metadata"),ml(U,"content",cn),ml(u,"align","center")},m(e,t){mn(document.head,U),n(e,We,t),n(e,_e,t),n(e,Ve,t),M(j,e,t),n(e,xe,t),M(w,e,t),n(e,Fe,t),n(e,d,t),n(e,Le,t),n(e,b,t),n(e,Qe,t),n(e,f,t),n(e,Ze,t),n(e,C,t),n(e,Xe,t),n(e,$,t),n(e,Ye,t),n(e,u,t),n(e,ze,t),M(I,e,t),n(e,Pe,t),M(g,e,t),n(e,qe,t),M(E,e,t),n(e,De,t),n(e,v,t),n(e,Oe,t),n(e,R,t),n(e,Ke,t),n(e,B,t),n(e,et,t),M(G,e,t),n(e,tt,t),n(e,N,t),n(e,lt,t),M(S,e,t),n(e,nt,t),M(k,e,t),n(e,st,t),n(e,A,t),n(e,at,t),n(e,_,t),n(e,it,t),n(e,H,t),n(e,pt,t),n(e,W,t),n(e,rt,t),n(e,V,t),n(e,mt,t),M(x,e,t),n(e,ht,t),n(e,F,t),n(e,Mt,t),M(L,e,t),n(e,ot,t),n(e,Q,t),n(e,ct,t),n(e,Z,t),n(e,yt,t),n(e,X,t),n(e,Tt,t),M(Y,e,t),n(e,Jt,t),n(e,z,t),n(e,Ut,t),M(P,e,t),n(e,ut,t),n(e,q,t),n(e,jt,t),M(D,e,t),n(e,wt,t),n(e,O,t),n(e,dt,t),M(K,e,t),n(e,bt,t),n(e,ee,t),n(e,ft,t),M(te,e,t),n(e,Ct,t),n(e,le,t),n(e,$t,t),M(ne,e,t),n(e,It,t),n(e,se,t),n(e,gt,t),n(e,ae,t),n(e,Et,t),M(ie,e,t),n(e,vt,t),n(e,pe,t),n(e,Rt,t),n(e,re,t),n(e,Bt,t),n(e,me,t),n(e,Gt,t),n(e,he,t),n(e,Nt,t),M(Me,e,t),n(e,St,t),M(oe,e,t),n(e,kt,t),n(e,ce,t),n(e,At,t),M(ye,e,t),n(e,_t,t),n(e,Te,t),n(e,Ht,t),M(Je,e,t),n(e,Wt,t),n(e,Ue,t),n(e,Vt,t),n(e,ue,t),n(e,xt,t),n(e,je,t),n(e,Ft,t),M(we,e,t),n(e,Lt,t),n(e,de,t),n(e,Qt,t),M(be,e,t),n(e,Zt,t),n(e,fe,t),n(e,Xt,t),M(Ce,e,t),n(e,Yt,t),n(e,$e,t),n(e,zt,t),n(e,Ie,t),n(e,Pt,t),M(ge,e,t),n(e,qt,t),n(e,Ee,t),n(e,Dt,t),M(ve,e,t),n(e,Ot,t),n(e,Re,t),n(e,Kt,t),M(Be,e,t),n(e,el,t),n(e,Ge,t),n(e,tl,t),n(e,Ne,t),n(e,ll,t),M(Se,e,t),n(e,nl,t),n(e,ke,t),n(e,sl,t),n(e,al,t),n(e,il,t),M(Ae,e,t),n(e,pl,t),n(e,He,t),rl=!0},p:nn,i(e){rl||(o(j.$$.fragment,e),o(w.$$.fragment,e),o(I.$$.fragment,e),o(g.$$.fragment,e),o(E.$$.fragment,e),o(G.$$.fragment,e),o(S.$$.fragment,e),o(k.$$.fragment,e),o(x.$$.fragment,e),o(L.$$.fragment,e),o(Y.$$.fragment,e),o(P.$$.fragment,e),o(D.$$.fragment,e),o(K.$$.fragment,e),o(te.$$.fragment,e),o(ne.$$.fragment,e),o(ie.$$.fragment,e),o(Me.$$.fragment,e),o(oe.$$.fragment,e),o(ye.$$.fragment,e),o(Je.$$.fragment,e),o(we.$$.fragment,e),o(be.$$.fragment,e),o(Ce.$$.fragment,e),o(ge.$$.fragment,e),o(ve.$$.fragment,e),o(Be.$$.fragment,e),o(Se.$$.fragment,e),o(Ae.$$.fragment,e),rl=!0)},o(e){c(j.$$.fragment,e),c(w.$$.fragment,e),c(I.$$.fragment,e),c(g.$$.fragment,e),c(E.$$.fragment,e),c(G.$$.fragment,e),c(S.$$.fragment,e),c(k.$$.fragment,e),c(x.$$.fragment,e),c(L.$$.fragment,e),c(Y.$$.fragment,e),c(P.$$.fragment,e),c(D.$$.fragment,e),c(K.$$.fragment,e),c(te.$$.fragment,e),c(ne.$$.fragment,e),c(ie.$$.fragment,e),c(Me.$$.fragment,e),c(oe.$$.fragment,e),c(ye.$$.fragment,e),c(Je.$$.fragment,e),c(we.$$.fragment,e),c(be.$$.fragment,e),c(Ce.$$.fragment,e),c(ge.$$.fragment,e),c(ve.$$.fragment,e),c(Be.$$.fragment,e),c(Se.$$.fragment,e),c(Ae.$$.fragment,e),rl=!1},d(e){e&&(l(We),l(_e),l(Ve),l(xe),l(Fe),l(d),l(Le),l(b),l(Qe),l(f),l(Ze),l(C),l(Xe),l($),l(Ye),l(u),l(ze),l(Pe),l(qe),l(De),l(v),l(Oe),l(R),l(Ke),l(B),l(et),l(tt),l(N),l(lt),l(nt),l(st),l(A),l(at),l(_),l(it),l(H),l(pt),l(W),l(rt),l(V),l(mt),l(ht),l(F),l(Mt),l(ot),l(Q),l(ct),l(Z),l(yt),l(X),l(Tt),l(Jt),l(z),l(Ut),l(ut),l(q),l(jt),l(wt),l(O),l(dt),l(bt),l(ee),l(ft),l(Ct),l(le),l($t),l(It),l(se),l(gt),l(ae),l(Et),l(vt),l(pe),l(Rt),l(re),l(Bt),l(me),l(Gt),l(he),l(Nt),l(St),l(kt),l(ce),l(At),l(_t),l(Te),l(Ht),l(Wt),l(Ue),l(Vt),l(ue),l(xt),l(je),l(Ft),l(Lt),l(de),l(Qt),l(Zt),l(fe),l(Xt),l(Yt),l($e),l(zt),l(Ie),l(Pt),l(qt),l(Ee),l(Dt),l(Ot),l(Re),l(Kt),l(el),l(Ge),l(tl),l(Ne),l(ll),l(nl),l(ke),l(sl),l(al),l(il),l(pl),l(He)),l(U),y(j,e),y(w,e),y(I,e),y(g,e),y(E,e),y(G,e),y(S,e),y(k,e),y(x,e),y(L,e),y(Y,e),y(P,e),y(D,e),y(K,e),y(te,e),y(ne,e),y(ie,e),y(Me,e),y(oe,e),y(ye,e),y(Je,e),y(we,e),y(be,e),y(Ce,e),y(ge,e),y(ve,e),y(Be,e),y(Se,e),y(Ae,e)}}}const cn='{"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 yn(hl){return sn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class jn extends an{constructor(U){super(),pn(this,U,yn,on,ln,{})}}export{jn as component};
