Skip to content

sarthakrastogi/graph-rag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Knowledge Graph RAG

Automatically create knowledge graphs + document networks to boost performance on RAG

1. Install Knowledge Graph RAG:

pip install knowledge_graph_rag

2. Create a Knowledge Graph or a Document Graph:

# Creating KG on medical documents
documents = ["Cardiovascular disease ...",
             "Emerging therapeutic interventions ...",
             "The epidemiological burden ...
             "Cardiovascular disease also ...",
             "Advanced imaging techniques, ...",
             "Role of novel biomarkers ..."
]
knowledge_graph = KnowledgeGraph(documents)
knowledge_graph.create()
knowledge_graph.plot()

Knowledge graph

documents_graph = DocumentsGraph(documents=documents)
documents_graph.plot()

Documents graph

3. Search knowledge graph entities or find interconnected documents, to augment your LLM context:

knowledge_graph.search_document(user_query)
>> Entity: cardiovascular disease
  -> antihypertensive agents (Relationship: involves treatment with)
  -> statins (Relationship: used to modulate dyslipidemia)
  -> antiplatelet therapy (Relationship: utilized to mitigate thrombosis risk)
  -> biomarkers (Relationship: detection and prognostication of acute coronary syndromes and heart failure)
  -> high-sensitivity troponins (Relationship: detection of acute coronary syndromes and heart failure)
  -> natriuretic peptides (Relationship: prognostication of acute coronary syndromes and heart failure)
documents_containing_connected_terminology = documents_graph.find_connected_documents(vectordb_search_result)
documents_containing_connected_terminology
>> [{'document': 'emerging therapeutic intervention ...'},
 {'document': 'management cardiovascular ...'},
 {'document': 'role novel biomarkers ...'}]

Star History

Star History Chart

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages