Entity resolution

LangChain और Neo4j के साथ Graph RAG

Adam Cowley

Manager, Developer Education at Neo4j

LLMs स्टेटलेस होते हैं

कॉल #1

नीचे दिए गए टेक्स्ट में पात्रों की सूची दें:

{text}
इस टेक्स्ट में ये पात्र हैं:

* Sampson - Capulet परिवार का नौकर।
* Gregory - Capulet परिवार का एक और नौकर।
* Abram - Montague परिवार का नौकर।
* Balthasar - Montague परिवार का नौकर।

कॉल #2

नीचे दिए गए टेक्स्ट में पात्रों की सूची दें:

{text}
इस टेक्स्ट में सूचीबद्ध पात्र:

* Sampson - Servant Capulet
* Gregory - Servant of Capulet
* Abram - Servant of the Montague
* Benvolio - Servant of the Montague
LangChain और Neo4j के साथ Graph RAG

एंटिटी सुझाव

examples = graph.query("""
MATCH (c:Character)-[:BELONGS_TO]->(f:Family)
RETURN c.id AS id, c.name AS name, f.name AS belongsToFamily
""")

for character in example:
    print(character)
{"id": "romeo-montague", "name": "Romeo", "family": "Montague"},

{"id": "juliet-capulet", "name": "Juliet", "family": "Capulet"},
{"id": "sampson", "name": "Sampson", "family": "Capulet"},
...
LangChain और Neo4j के साथ Graph RAG

एंटिटी सुझाव

SystemMessagePromptTemplate.from_template("""
निम्न एंटिटीज़ से संबंधित जानकारी निकालें।


निम्न सूची में शामिल नहीं पात्रों को नज़रअंदाज़ करें:
{examples}
""",
partial_variables={"examples": [ dict(e) for e in examples ]}
)
LangChain और Neo4j के साथ Graph RAG

ग्राफ-आधारित एंटिटी रेज़ोल्यूशन

entity_resolution1.jpg

LangChain और Neo4j के साथ Graph RAG

ग्राफ-आधारित एंटिटी रेज़ोल्यूशन

entity_resolution2.jpg

LangChain और Neo4j के साथ Graph RAG

ग्राफ-आधारित एंटिटी रेज़ोल्यूशन

entity_resolution3.jpg

LangChain और Neo4j के साथ Graph RAG

ग्राफ-आधारित एंटिटी रेज़ोल्यूशन

entity_resolution4.jpg

LangChain और Neo4j के साथ Graph RAG

กรाफ-आधारित एंटिटी रेज़ोल्यूशन

entity_resolution5.jpg

LangChain और Neo4j के साथ Graph RAG

मिलते-जुलते लोग पहचानना

MATCH path = (c:Character {id: "romeo-capulet"})-[r]-(inCommon:Character),

(inCommon)-[r2]-(other:Character)
RETURN c.id AS id, c.name AS name, other.name AS otherName, other.id AS otherId,
c.name = other.name AS shareName,
EXISTS { (c)-[:BELONGS_TO]->(:Family)<-[:BELONGS_TO]-(other) } AS belongToFamily,
count(*) as nodesInCommon,
collect(path) AS paths
ORDER BY nodesInCommon DESC LIMIT 10
LangChain और Neo4j के साथ Graph RAG

Similarity रिश्तों का उपयोग

a graph diagram of person nodes with two person nodes and a similar relationship.  Both have relationships to Line nodes

MATCH (:Character {id: 'romeo-montague'})-[:SIMILAR_TO*0..1]-(character),
  (character)-[:HAS_LINE]->(line),
  (line)-[:SPOKEN_TO]->(target)
RETURN character, line
LangChain और Neo4j के साथ Graph RAG

अभ्यास करते हैं!

LangChain और Neo4j के साथ Graph RAG

Preparing Video For Download...