Skip to main content

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

knowledge_graph_rag-0.1.1.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

knowledge_graph_rag-0.1.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file knowledge_graph_rag-0.1.1.tar.gz.

File metadata

  • Download URL: knowledge_graph_rag-0.1.1.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for knowledge_graph_rag-0.1.1.tar.gz
Algorithm Hash digest
SHA256 502dcc89179c9304f1c1659b5c06f6c07eead6f60eef61ab29a16a05cd55be5f
MD5 868c36cfe14b46d719c323e1dcbb0ffc
BLAKE2b-256 4011b1bc5063556465136477f3eb7a0e269be77c80acc45c58fa7971342e3582

See more details on using hashes here.

File details

Details for the file knowledge_graph_rag-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for knowledge_graph_rag-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c9d3c36114a4c291d8c7c8a1cf614333786e5a936d40eba2c9815a025fa86cdd
MD5 cac3d3a52a87ac8884ec1a1d4094491c
BLAKE2b-256 e367e3c2a50d5e319fe0542c46d8ac7d8158b960542ebe0404a73b6e7a5948ed

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page