Citation Needed: Provenance for LLM-Built Knowledge Graphs — Daniel Chalef, Zep AI
Daniel Chalef discusses how LLM synthesis destroys data provenance, making it difficult to trace information back to its sources. He introduces Graphiti, an open-source temporal graph framework, and Zep, an agent memory infrastructure built upon it. This system models provenance as a graph, treating sources as 'episodes' and derived facts as interconnected nodes and edges. This approach enables robust lineage tracing, handles entity merges and fact invalidation through temporal mechanisms, facilitates metadata-driven trust evaluation, and allows for compliant data deletion (e.g., GDPR) based on source support. The benefits include enhanced compliance, improved data veracity, and debuggable AI agents, addressing a critical engineering challenge in LLM applications.
Daniel Chalef, co-creator of Graphiti and Zep, addresses the critical challenge of provenance in systems leveraging Large Language Models (LLMs). LLMs excel at synthesizing information from diverse sources but do so non-deterministically, destroying the paper trail of how facts and artifacts are generated. This lack of lineage poses significant problems for legal compliance, debugging, trusting data sources, and managing data deletion.
The Provenance Problem with LLMs
LLMs generate summaries, extracted facts, and structured records that may not appear verbatim in source inputs. This synthesis process fundamentally obscures the origin of information. Chalef highlights an example: an agent confidently presents a doctor with a “penicillin allergy” fact, but its origin is a blend of an EHR record, a PDF lab report, and patient input from an AI chatbot. Without knowing the source, especially if it originated from the patient themselves (which might be less reliable than a verified clinical record), it could mislead the doctor. Simply stamping a “source ID” on facts is insufficient because LLMs merge entities (e.g., “J. Smith” and “John Smith”) and new data can invalidate older facts, making the data store constantly shift.
Graphiti’s Solution: Provenance as a Graph
Graphiti, an open-source temporal graph framework, and Zep, an enterprise agent memory infrastructure built on Graphiti, engineer lineage directly into the data structure. In Graphiti:
- Sources as Episodes: Original data sources are modeled as “episodes” (nodes) in the graph.
- Facts as Triples: Extracted entities (e.g., patient, penicillin) and their relationships (e.g., “has allergy to”) form graph triples (subject-verb-object) that represent facts (e.g., “Patient has a penicillin allergy”).
- Graph Walk for Tracing: Tracing a fact back to its origin simply involves walking the graph.
Maintaining Lineage Through Graph Changes
The challenge lies in keeping lineage correct as the knowledge graph evolves:
- Entity Merges: When two entities merge, the resulting merged entity must inherit all source links from both original entities to prevent silent loss of lineage.
- Fact Invalidation: If new data contradicts an existing fact, the old fact isn’t deleted. Instead, Graphiti adds an “invalid date” to the relevant edge, noting the new source episodes that caused the mutation. This preserves the historical record.
Metadata Projection and Trust Evaluation
Graphiti enables metadata projection, allowing classifications (tags) to span episodes and their derived facts:
- Tag Inheritance: Tags applied to source episodes upon ingestion (e.g., “EHR tag” for electronic health records) are automatically inherited by all subsequent entities and facts derived from them.
- Filtering by Veracity: This allows agents to easily filter for facts from trusted sources (e.g., “only facts from verified clinical sources”) by walking the graph and filtering by tags.
- Mixed Trust Scenarios: For facts derived from multiple parents with varying trust levels, Graphiti exposes which parent episodes carry specific tags. The agent then applies business rules. For instance, for a critical “allergy flag,” any unverified parent might block a prescription, while for “consent on file,” every parent must be verified. The framework provides the data; the agent implements the policy.
Data Deletion and Compliance
Lineage is vital for handling data retention policies and “right to be forgotten” requests (GDPR):
- Selective Deletion: If an episode (source data) is deleted, any fact derived from it only survives if other supporting parent episodes still exist. For example, if patient chatbot data (one of three sources for a penicillin allergy fact) is deleted, the allergy fact persists due to support from the EHR and lab reports. However, a “contact preference” fact derived solely from the chatbot data would be deleted.
- Simple Rule: A fact is deleted only if no remaining episodes support it.
Benefits of Provenance with Graphiti
Engineering lineage into the data structure offers numerous advantages:
- Compliance: Provides an auditable trail, satisfying legal requirements.
- Veracity: Enables users to assess the trustworthiness of facts based on their sources.
- Debuggability: Simplifies understanding how and why facts were generated.
- Deletion Management: Facilitates accurate and compliant data deletion.
Q&A Insights
- Cost: Graph construction in Graphiti is inherently expensive, but significant engineering effort has been invested in optimizing cost and latency.
- Graph Mutation for Relevancy: While Graphiti manages core provenance, Zep handles specific issues like weight changes and relevancy for facts using a separate data structure, not entirely within the core Graphiti provenance graph.
- Fact and Entity Creation: Episodes are graph nodes, as are derived artifacts like entities and facts. The
add_episodemethod triggers a complex pipeline involving structured extraction of entities, relationships, and subject-verb-object facts. This is followed by deduplication and de-confliction processes. LLMs are used for extraction, but traditional Information Retrieval and NLP techniques (e.g., SimHash, entropy) are prioritized where possible for their determinism, speed, and cost-effectiveness. A “reflection step” is also integrated to ensure accuracy and enrich lineage with details like why a fact changed. - Why not file-based memory/Markdown?: File-based or Markdown-based memory systems suffer from provenance issues. Mutating lines in a file destroys lineage, and they struggle to manage provenance at scale in multi-agent, multi-user, and multi-source enterprise environments. They are better suited for single-user or desktop scenarios. The core issue is that “lineage needs to be built in to the data structure, engineered into the data structure, which is a graph, not logged afterwards.”