1. Executive Summary
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending
.mdto the page URL.
1.1. Purpose and Audience
This notebook provides a hands-on guide for building temporally-aware knowledge graphs and performing multi-hop retrieval directly over those graphs.
It's designed for engineers, architects, and analysts working on temporally-aware knowledge graphs. Whether you’re prototyping, deploying at scale, or exploring new ways to use structured data, you’ll find practical workflows, best practices, and decision frameworks to accelerate your work.
This cookbook presents two hands-on workflows you can use, extend, and deploy right away:
<ol style="margin-left: 1em; line-height: 1.6; padding-left: 0.5em;"> <li style="margin-bottom: 1.2em;"> <strong>Temporally-aware knowledge graph (KG) construction</strong><br /> <p style="margin-top: 0.5em; margin-bottom: 0.5em;"> A key challenge in developing knowledge-driven AI systems is maintaining a database that stays current and relevant. While much attention is given to boosting retrieval accuracy with techniques like semantic similarity and re-ranking, this guide focuses on a fundamental—yet frequently overlooked—aspect: <em>systematically updating and validating your knowledge base as new data arrives</em>. </p> <p style="margin-top: 0.5em; margin-bottom: 0.5em;"> No matter how advanced your retrieval algorithms are, their effectiveness is limited by the quality and freshness of your database. This cookbook demonstrates how to routinely validate and update knowledge graph entries as new data arrives, helping ensure that your knowledge base remains accurate and up to date. </p> </li> <li style="margin-bottom: 1.2em;"> <strong>Multi-hop retrieval using knowledge graphs</strong><br /> <p style="margin-top: 0.5em; margin-bottom: 0.5em;"> Learn how to combine OpenAI models (such as o3, o4-mini, GPT-4.1, and GPT-4.1-mini) with structured graph queries via tool calls, enabling the model to traverse your graph in multiple steps across entities and relationships. </p> <p style="margin-top: 0.5em; margin-bottom: 0.5em;"> This method lets your system answer complex, multi-faceted questions that require reasoning over several linked facts, going well beyond what single-hop retrieval can accomplish. </p> </li> </ol>Inside, you'll discover:
- Practical decision frameworks for choosing models and prompting techniques at each stage
- Plug-and-play code examples for easy integration into your ML and data pipelines
- Links to in-depth resources on OpenAI tool use, fine-tuning, graph backend selection, and more
- A clear path from prototype to production, with actionable best practices for scaling and reliability
Note: All benchmarks and recommendations are based on the best available models and practices as of June 2025. As the ecosystem evolves, periodically revisit your approach to stay current with new capabilities and improvements.
1.2. Key takeaways
本篇目录
- Creating a Temporally-Aware Knowledge Graph with a Temporal Agent
- Multi-Step Retrieval Over a Knowledge Graph
- Prototype to Production
- 3.1.1. Key enhancements introduced in this cookbook
- 3.1.2. The Temporal Agent Pipeline
- 3.1.3. Selecting the right model for a Temporal Agent
- Architecture diagram
- 3.2.1. Load transcripts
- 3.2.2. Creating a Semantic Chunker
- 3.2.3. Laying the Foundations for our Temporal Agent
- 3.2.4. Statement Extraction
- 3.2.5. Temporal Range Extraction
- 3.2.6. Creating our Triplets
- 3.2.7. Temporal Event
- 3.2.8. Defining our Temporal Agent
- 3.2.9. Entity Resolution
- 3.2.10. Invalidation agent
- 3.2.11. Putting it all together
- 3.3.1 Building our Knowledge Graph with NetworkX
- 3.3.2 NetworkX versus Neo4j in Production
- 3.4.1. Temporal Agent
- 3.4.2. Invalidation Agent
- 4.1.1. Imports
- 4.1.2. (Re-)Initialise OpenAI Client
- 4.1.3. (Re-)Load our Temporal Knowledge Graph
- 4.1.4. Planner
- 4.1.5. Function calling
- 4.1.6. Retriever
- 4.1.7. Selecting the right model for Multi-Step Knowledge-Graph Retrieval
- Which is the best evaluation method?
- A.1. Storing and Retrieving High-Volume Graph Data
- A.2. Managing and Pruning Datasets
- A.3. Implementing Concurrency in the Ingestion Pipeline
- Advantages of Batch Processing
- A.4. Minimizing Token Cost
- A.5. Scaling and Productionizing our Retrieval Agent
- A.6. Safeguards
- A.7. Prompt Optimization