Graphiti is an open-source tool designed to build and query dynamic, temporally-aware knowledge graphs. Developed by getzep, Graphiti facilitates the representation of complex, evolving relationships between entities over time. It is particularly suited for applications that require long-term recall and state-based reasoning, such as in sales, customer service, health, and finance sectors.
Graphiti offers several distinctive features that cater to the needs of developers and researchers working with temporally sensitive data:
Temporal Awareness: Graphiti tracks changes in facts and relationships over time. This feature allows users to perform point-in-time queries, with graph edges including temporal metadata to record the lifecycles of relationships.
Episodic Processing: The tool ingests data as discrete episodes, which helps in maintaining data provenance and allows for incremental extraction of entities and relationships.
Hybrid Search Capabilities: Graphiti combines semantic and BM25 full-text search, enabling the reranking of results based on their distance from a central node, such as a specific entity.
Scalability: Designed to handle large datasets efficiently, Graphiti supports the parallelization of large language model (LLM) calls for bulk processing while preserving the chronology of events.
Diverse Data Source Integration: The tool can ingest both unstructured text and structured JSON data, providing flexibility in data utilization.
To install and run Graphiti, the following components are needed:
Optional:
Graphiti can be installed using pip or poetry:
pip install graphiti-core
or
poetry add graphiti-core
Here is a brief example to get started with Graphiti:
Initialize Graphiti:
from graphiti_core import Graphiti
from datetime import datetime, timezone
graphiti = Graphiti("bolt://localhost:7687", "neo4j", "password")
graphiti.build_indices_and_constraints()
Add Episodes:
episodes = [
"Kamala Harris is the Attorney General of California. She was previously the district attorney for San Francisco.",
"As AG, Harris was in office from January 3, 2011 – January 3, 2017"
]
for i, episode in enumerate(episodes):
await graphiti.add_episode(
name=f"Freakonomics Radio {i}",
episode_body=episode,
source=EpisodeType.text,
source_description="podcast",
reference_time=datetime.now(timezone.utc)
)
Search the Graph:
results = await graphiti.search('Who was the California Attorney General?')
Graphiti is a robust tool for developers and researchers looking to explore and utilize knowledge graphs that account for temporal dynamics and complex relationships. Its ability to handle episodic data and perform hybrid searches makes it a valuable resource in various fields requiring nuanced data analysis and retrieval.