Short answer: run a Neo4j database, install ragleap-graph, store each document with upsert_document, then look up documents by entity or search related entities. This guide follows the README of ragleap-graph 0.9.0. The library adds entity extraction, co-occurrence graphs and graph-based document retrieval on top of Neo4j, and is built for RAG systems such as ragleap-rag.
What do you need?
A running Neo4j instance (the README example connects to bolt://localhost:7687) and its password.
pip install ragleap-graph
How do you store a document and query the graph?
This is the README quickstart:
from ragleap_graph import GraphConfig, GraphIndex
graph = GraphIndex(config=GraphConfig(
uri="bolt://localhost:7687",
user="neo4j",
password="...",
))
graph.upsert_document(
document_id="doc-1",
title="Q3 Report",
chunks=[{"text": "Acme Corp reported strong Q3 revenue growth."}],
)
docs = graph.find_documents_by_entities(["Acme Corp"])
related = graph.search_related_entities(["Acme Corp"], max_depth=2)
find_documents_by_entities looks up documents linked to the entities you name. search_related_entities searches for entities related to them, up to max_depth steps away.
How are entities extracted?
The default extraction is regex and heuristic based: fast, free and with no extra dependencies. For messier text, such as Acme Corp written as ACME Corp., the README offers LLM-based extraction and deduplication (since v0.2.0). It needs the llm extra:
pip install ragleap-graph[llm]
from ragleap.generation import ProviderConfig
from ragleap_graph import GraphConfig, GraphIndex, ExtractionConfig
graph = GraphIndex(
config=GraphConfig(uri="bolt://localhost:7687", user="neo4j", password="..."),
extraction=ExtractionConfig(
method="llm",
provider=ProviderConfig(provider="gemini", api_key="...", model="gemini-3.6-flash"),
dedup_enabled=True,
),
)
Note that this example imports ProviderConfig from the ragleap package, which is ragleap-rag.
What else is in the README?
Sections on cross-chunk relation extraction (since v0.8.0), ontology cross-validation (since v0.9.0), operations and status. Read the README and the CHANGELOG for what each version changed.
What this does not do
- It needs Neo4j. There is no built-in graph store.
- The deduplicator merges spelling variants of names that were already extracted. It does not fix a regex extractor that splits one real-world entity into several candidates; the README says
method="llm"avoids that at the source. - With LLM extraction, your text goes to the provider you configure.
- No retrieval quality numbers are claimed here. Measure it on your own data.
RagLeap Core also uses Neo4j for graph-boosted retrieval in its Docker stack; see the knowledge graph documentation.
Sources
ragleap-graph on PyPI (0.9.0), the README on GitHub, and the library page.