Skip to main content

Autograft

The cost-efficient Entity Resolution middleware for GraphRAG.

English | Français | 中文

PyPI - Version PyPI - Python Version

Stop duplicating entities in your Neo4j Knowledge Graph. AutoGraft intercepts entities extracted by LangChain or LlamaIndex, uses a 3-layer hybrid approach (Deterministic -> Vector -> LLM) to merge duplicates, and generates clean Cypher queries.

Installation

pip install autograft

(To use integrations, install with pip install autograft[langchain] or pip install autograft[llamaindex])

Why AutoGraft?

  • LLM-Agnostic: Works with OpenAI, Groq, Ollama, OpenRouter via litellm.
  • Massive Cost Savings: Reduces Entity Resolution token costs by up to 100% by resolving locally.
  • Plug & Play: Drop-in replacement before your Neo4j database.
  • Blazing Fast: C/C++ (RapidFuzz) and NumPy local matching.

Performance Benchmark (660 Documents / 10 Industries)

Evaluated across a massive suite of 660 real-world enterprise documents spanning 10 key sectors: Legal, Tech, Insurance, Finance, Healthcare, Manufacturing, Retail, Energy, Education, and Real Estate (with complex acronyms like GDPR, K8s, AWS, D&O, EBITDA, KYC/AML, SOFR, SCOTUS).

LLM Engine Configured: groq/llama-3.1-8b-instant for extraction & arbitration, and groq/llama-3.3-70b-versatile for precision auditing.

Metric LangChain Naive (No ER) LangChain + Full LLM ER LangChain + AutoGraft Hybrid ER
Processed Documents 660 documents 660 documents 660 documents
Extracted Entities 2448 entities 2448 entities 2448 entities
LLM ER API Calls 0 calls 2448 calls 0 calls (100% Local Short-Circuit)
Tokens Consumed 0 tokens 685,608 tokens 0 tokens (100% Token Savings)
Duplicates Created 620 duplicates 0 duplicates 0 duplicates
Duplicates Avoided (MATCH) 0 queries 620 queries 620 queries
New Entities Created (MERGE) 2448 queries 1828 queries 1828 queries
LLM ER Cost $0.00000 $0.13712 $0.00000
Knowledge Graph Quality Polluted with Duplicates Deduplicated (Expensive) Deduplicated & Cost-Free

Figure 1.1: Enterprise RAG Entity Resolution Performance Metrics (660 Docs / 10 Industries)

Figure 1.1

Detailed Metric Breakdown:

  • Top-Left (Total Tokens Consumed): LangChain Naive and AutoGraft consume 0 resolution tokens, while Full LLM ER consumes 685,608 tokens.
  • Top-Right (LLM ER API Calls): LangChain Naive and AutoGraft make 0 API calls, while Full LLM ER makes 2,448 external API calls.
  • Bottom-Left (Neo4j Duplicates Avoided): LangChain Naive creates 620 duplicates (0 avoided), while Full LLM ER and AutoGraft resolve all 620 duplicates.
  • Bottom-Right (Estimated LLM Cost): Compares the Entity Resolution financial cost. LangChain Naive costs $0 (but fails to deduplicate), Full LLM ER costs $0.13712, and AutoGraft costs $0 (while perfectly deduplicating the graph).

Figure 1.2: Enterprise Knowledge Graph Cost Scaling (Up to 1,000,000 Documents)

For 1,000,000 documents, AutoGraft maintains $0.00 LLM Entity Resolution API costs while guaranteeing a 100% clean, deduplicated Knowledge Graph.

Figure 1.2


Figure 1.3: Entity Resolution Precision by Industry Sector (100.0% Overall)

Figure 1.3

For complete evaluation methodology and dataset documentation, see BENCHMARK.md.


Configuration & Credentials

AutoGraft can be configured via environment variables (.env) or programmatically via the AutoGraftConfig class.

from autograft import AutoGraftConfig
from autograft.integrations import AutoGraftNeo4jMiddleware

config = AutoGraftConfig(
    model="openai/gpt-4o",
    api_key="sk-...",
    api_base="https://custom.endpoint/v1",  # Optional: for proxies, Azure, or local LLMs
    match_threshold=0.85,
    id_attr="id",
    aliases_attr="aliases",
    matching_algorithm="token_sort_ratio"
)
autograft_graph = AutoGraftNeo4jMiddleware(graph, config=config)

Architecture (3-Layer Short-Circuit)

  1. Layer 1 (Deterministic): Exact string match & alias matching via rapidfuzz (0 tokens, 0.1ms).
  2. Layer 2 (Semantic): Vector cosine similarity via numpy (0 tokens, 0.5ms).
  3. Layer 3 (LLM Arbiter): LiteLLM call ONLY for residual ambiguous cases (e.g., "J. Dupont" vs "Jean Dupont").

Plug & Play Integrations

AutoGraft provides native 1-line integrations for both LangChain and LlamaIndex. By wrapping your Graph store, AutoGraft intercepts entities, deduplicates them locally at 0 cost, and safely forwards them to your database.

LangChain

from langchain_community.graphs import Neo4jGraph
from autograft.integrations import AutoGraftNeo4jMiddleware

# 1. Connect to your Neo4j Database
graph = Neo4jGraph(url="bolt://localhost:7687", username="neo4j", password="password")

# 2. Wrap it with AutoGraft (1 line of code!)
autograft_graph = AutoGraftNeo4jMiddleware(graph)

# 3. Add your extracted documents. AutoGraft will silently deduplicate everything locally!
autograft_graph.add_graph_documents(extracted_graph_documents)

LlamaIndex

from llama_index.graph_stores.neo4j import Neo4jPropertyGraphStore
from autograft.integrations import AutoGraftLlamaIndexMiddleware

# 1. Connect to Neo4j Graph Store
store = Neo4jPropertyGraphStore(username="neo4j", password="password", url="bolt://localhost:7687")

# 2. Wrap it with AutoGraft
autograft_store = AutoGraftLlamaIndexMiddleware(store)

# 3. Use in your LlamaIndex pipeline (upsert_nodes will be automatically deduplicated)
# e.g., index = PropertyGraphIndex.from_documents(documents, property_graph_store=autograft_store)

License

MIT

Metadata

Release files for autograft 1.2.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 autograft 1.2.1
File Size Uploaded Provenance
autograft-1.2.1.tar.gz 20.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for autograft 1.2.1
File Interpreter ABI Platform
autograft-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 38.3 kB

Release files / autograft-1.2.1.tar.gz

Download URL autograft-1.2.1.tar.gz
Size 20.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7f3a44a77c4a3a5517ca00d10fd6436aafc58bd92b86ea2b844cfe08ee104bfe
BLAKE2b-256 checksum
How to use checksums
42a8cf2920ef61163566f29ab11c408754a1ca71e49b17300e294e4841a28b08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 7, 2026.

Transparency log

Release files / autograft-1.2.1-py3-none-any.whl

Download URL autograft-1.2.1-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b010f5ff87afdaa954981f54d07faf39a70c4e9b3657d033a9a74ccb7f406de
BLAKE2b-256 checksum
How to use checksums
0e2a2f114672ababf74b1f2013cf4208f1b785604e6cae67c01208ba4b5f515f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 7, 2026.

Transparency log

Security for autograft 1.2.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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for autograft-1.2.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 Aug 7, 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.

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