What is a Knowledge Graph?
A knowledge graph is a network of interconnected facts represented as triplets—each consisting of two entities (nodes) and their relationship (edge). For example, the fact “Kendra loves Adidas shoes” becomes:- Source Node: Kendra (entity)
- Edge: loves (relationship)
- Target Node: Adidas shoes (entity)
The Graphiti Approach
While traditional knowledge graphs have been used extensively for information retrieval, Graphiti introduces a unique approach tailored for AI agents:Autonomous Graph Building
Graphiti autonomously constructs knowledge graphs from unstructured and structured data without requiring manual schema definition. When you add an episode (a unit of information), Graphiti:- Extracts entities using LLMs to identify people, places, organizations, and custom entity types
- Identifies relationships between entities with semantic meaning
- Resolves duplicates by detecting when new information refers to existing entities
- Updates the graph incrementally without batch recomputation
Temporal Awareness
Unlike traditional static graphs, Graphiti maintains a temporal dimension:- Point-in-time queries: “Who was the Attorney General in 2015?”
- Tracking evolving relationships: “When did Alice start working at Acme Corp?”
- Handling contradictions: New information can invalidate old facts without deletion
Graphiti tracks both when facts occurred in the real world (
valid_at/invalid_at) and when they were ingested into the system (created_at/expired_at). This bi-temporal model is crucial for accurate historical reasoning.Graph Structure
A Graphiti knowledge graph consists of several node and edge types:Node Types
| Type | Purpose | Example |
|---|---|---|
| EntityNode | Represents real-world entities | People, places, organizations, concepts |
| EpisodicNode | Stores raw input data | Chat messages, documents, JSON data |
| CommunityNode | Groups related entities | Topic clusters discovered through graph analysis |
| SagaNode | Organizes sequential episodes | Conversation threads, event sequences |
Edge Types
| Type | Connects | Purpose |
|---|---|---|
| EntityEdge (RELATES_TO) | Entity → Entity | Semantic relationships with facts |
| EpisodicEdge (MENTIONS) | Episode → Entity | Links raw data to extracted entities |
| CommunityEdge (HAS_MEMBER) | Community → Entity | Membership in topic clusters |
| HasEpisodeEdge | Saga → Episode | Saga membership |
| NextEpisodeEdge | Episode → Episode | Sequential ordering |
Knowledge Representation Example
Consider this episode:- Node: “Kamala Harris” (Person)
- Node: “California” (Location)
- Node: “San Francisco” (Location)
- Node: “Attorney General” (Position)
- Node: “District Attorney” (Position)
- Edge: Kamala Harris → holds position → Attorney General
- Fact: “Kamala Harris is the Attorney General of California”
- Edge: Kamala Harris → previously held → District Attorney
- Fact: “She was previously the district attorney for San Francisco”
- EpisodicEdge: “Career Update” → mentions → “Kamala Harris”
Why Graphiti vs Traditional Approaches
vs. RAG (Retrieval-Augmented Generation)
Traditional RAG systems retrieve document chunks based on semantic similarity. Graphiti goes further:- Structured relationships: Instead of text chunks, retrieve specific facts with context
- Graph traversal: Find related information by following edges
- Temporal queries: Filter by when facts were true, not just when documents were created
- Contradiction handling: Automatically invalidates outdated information
vs. GraphRAG
| Aspect | GraphRAG | Graphiti |
|---|---|---|
| Data Handling | Batch-oriented | Continuous, incremental |
| Primary Use | Static document summarization | Dynamic data management |
| Retrieval | Sequential LLM summarization | Hybrid semantic + keyword + graph |
| Temporal Handling | Basic timestamps | Bi-temporal tracking |
| Query Latency | Seconds to tens of seconds | Sub-second |
| Custom Types | No | Yes, via Pydantic models |
Real-Time Incremental Updates
One of Graphiti’s key advantages is real-time processing:Hybrid Search
Graphiti combines three search methods for comprehensive retrieval:- Semantic search: Vector similarity on embedded facts and entity names
- Keyword search: BM25 full-text search for precise term matching
- Graph traversal: Navigate relationships to find connected information
Group IDs for Multi-Tenancy
Graphiti supports partitioning graphs bygroup_id, enabling:
- Multi-user applications: Separate knowledge graphs per user
- Organizational hierarchies: Team-level or project-level graphs
- Access control: Query only the groups a user has permission for
Next Steps
Temporal Model
Learn about Graphiti’s bi-temporal data model
Episodes
Understand episodes as units of information
Nodes and Edges
Explore the graph schema in detail
Communities
Discover community detection for topic clustering