Introduction to Temporal Knowledge
Most knowledge graphs treat time as a simple timestamp—when a fact was added to the database. Graphiti takes a more sophisticated approach with a bi-temporal model that distinguishes between:- Valid Time: When a fact was true in the real world
- Transaction Time: When the system learned about the fact
The Bi-Temporal Model
Graphiti implements bi-temporality through two sets of timestamps on edges and nodes:Valid Time Dimension
Tracks when facts were actually true in the real world:valid_at: January 3, 2011invalid_at: January 3, 2017
Transaction Time Dimension
Tracks when the system learned about facts:created_at: March 15, 2025expired_at: None (edge is still current in the graph)
The distinction between valid time and transaction time allows Graphiti to answer questions like “What did the system know about X on date Y?” versus “What was actually true about X on date Y?”
Why Bi-Temporality Matters
Handling Contradictions
When new information contradicts existing knowledge, Graphiti invalidates old edges without deleting them:Graphiti uses temporal edge invalidation rather than deletion, preserving the complete history of what the system knew and when.
Late-Arriving Information
Bi-temporality elegantly handles information that arrives out of chronological order:- Historical accuracy: Query “Who worked at Acme in 2020?” → Correct answer: Alice
- Audit trails: Query “What did we know on March 1, 2025?” → We didn’t know about Alice yet
Temporal Queries
Graphiti’s temporal model enables sophisticated queries:Point-in-Time Retrieval
Find facts that were valid at a specific time:Time Range Queries
Find all facts valid during a period:Recent Updates Query
Find what the system learned recently:Temporal Data on Nodes
Episodic Nodes
Episodes have both dimensions of time:Entity Nodes
Entities only track transaction time (when first created):Episode Time vs Edge Time
Understanding the relationship between episode time and edge time is crucial:Temporal Edge Invalidation
When Graphiti detects contradictory information, it uses temporal invalidation:How It Works
- New episode arrives with contradicting information
- LLM analyzes the contradiction during edge resolution (see
graphiti_core/utils/maintenance/edge_operations.py:484) - Old edge is updated:
invalid_at← new fact’svalid_atexpired_at← current timestamp
- New edge is created with the updated information
Code Example from Source
Real-World Example
Temporal Awareness in Retrieval
Graphiti’s search automatically considers temporal validity:Implementation Details
Timestamp Sources
Date Parsing
Graphiti usesparse_db_date() to handle various database date formats:
Best Practices
1. Always Set reference_time Accurately
2. Use Temporal Filters for Historical Queries
When you need point-in-time information, always useSearchFilters:
3. Preserve Episode Metadata
When processing documents, preserve original timestamps:Comparison with Other Systems
Next Steps
Episodes
Learn how episodes carry temporal information
Nodes and Edges
Explore the complete graph schema
Search & Retrieval
Use temporal filters in search queries
Add Episodes
Set reference_time correctly when adding data