Skip to main content

ragleap-graph

Knowledge-graph-augmented retrieval for RAG systems — entity extraction, co-occurrence graphs, and graph-based document retrieval via Neo4j.

pip install ragleap-graph

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)

Current: v0.9.0 · 108 tests (92 passed without live credentials, 16 skipped)

Architecture

ragleap-graph write/read/hybrid-retrieval architecture

LLM-based extraction and dedup (v0.2.0+)

The default entity extraction is regex/heuristic-based (fast, free, zero dependencies). For messier input — e.g. inconsistent capitalization like "Acme Corp" vs "ACME Corp." — LLM-based extraction and dedup produce cleaner graphs. Requires 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: EntityDeduplicator merges spelling variants of an already-extracted name; it does not fix fragmentation caused by the regex extractor splitting one real-world entity into multiple candidates in the first place — see CHANGELOG.md for a real, measured example of this and how method="llm" avoids it at the source.

Cross-chunk relation extraction (v0.8.0+)

Relation extraction normally runs per-chunk, so a relation whose evidence spans two chunks — e.g. an entity named in chunk 1, referred to only by pronoun ("it", "the company") in a later chunk — can be missed. Enable cross_chunk_relations=True for one additional pass over the full document using every entity found across all chunks:

extraction=ExtractionConfig(
    method="llm",
    provider=ProviderConfig(provider="gemini", api_key="...", model="gemini-3.6-flash"),
    extract_relations=True,
    cross_chunk_relations=True,
)

Known limitation: this depends on the provider's reasoning ability to resolve the reference correctly. Live-verified working with Gemini; small local models (e.g. qwen2.5:0.5b) were found, via live testing, to produce an incorrect relation rather than none on this task — not recommended for this feature without independently verifying its output.

Ontology cross-validation (v0.9.0+)

Constrain which relation_type values are valid between which entity_type pairs. A relation violating the ontology is dropped (with a WARNING logged) rather than written to Neo4j; relation_type values not listed remain unconstrained. Requires entity_types= to also be set:

extraction=ExtractionConfig(
    method="llm",
    provider=ProviderConfig(provider="gemini", api_key="...", model="gemini-3.6-flash"),
    extract_relations=True,
    entity_types=["ORGANIZATION", "PERSON"],
    relation_ontology={"FOUNDED_BY": (["ORGANIZATION"], ["PERSON"])},
)

Operations

ragleap-graph is a knowledge-graph retrieval library, not a database administration tool. Backup and restore of the underlying Neo4j database are explicitly the operator's responsibility, not something this library wraps or automates -- see docs/operations/backup-and-restore.md for a concrete, tested procedure using Neo4j's native neo4j-admin tooling, and docs/adr/0001-backup-restore-ownership.md for the reasoning behind this scope decision.

Status

v0.9.0. Ported from a real production GraphService, adapted for standalone open-source use — see HANDOFF.md for the full design history. ragleap-rag >=0.12.0 is an optional dependency, required only for method="llm".

License

MIT

Metadata

Release files for ragleap-graph 0.9.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ragleap-graph 0.9.1
File Size Uploaded Provenance Actions
ragleap_graph-0.9.1.tar.gz 99.3 kB With provenance Details for ragleap_graph-0.9.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ragleap-graph 0.9.1
File Interpreter ABI Platform Actions
ragleap_graph-0.9.1-py3-none-any.whl Python 3 none any Details for ragleap_graph-0.9.1-py3-none-any.whl

Total release size: 136.8 kB

Release files / ragleap_graph-0.9.1.tar.gz

Download URL ragleap_graph-0.9.1.tar.gz
Size 99.3 kB
Tags Source
SHA-256 checksum
How to use checksums
95c52f2bc79db5425892f5801e3cb9c4fb6beb164b4ba8ba695117152d5a475a
BLAKE2b-256 checksum
How to use checksums
e0c2d42d16b418981cd98cf305e82272c8db89899bd612312cd2e9bb1fe4d3ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / ragleap_graph-0.9.1-py3-none-any.whl

Download URL ragleap_graph-0.9.1-py3-none-any.whl
Size 37.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
719f95258be90b5757fe89388b37b12da540ea1f07724d8f98bc27ad72433187
BLAKE2b-256 checksum
How to use checksums
c961ca199a6ba1546d6f8c0a4196d87834441d95d13a4d9e47f8a56b657ea285
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for ragleap-graph 0.9.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ragleap_graph-0.9.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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