mirror of
https://github.com/qdrant/landing_page.git
synced 2026-10-02 17:38:31 +02:00
docs: Updated Cognee integration
Signed-off-by: Anush008 <anushshetty90@gmail.com>
This commit is contained in:
@@ -1,85 +1,92 @@
|
||||
---
|
||||
title: cognee
|
||||
title: Cognee
|
||||
---
|
||||
|
||||
# cognee
|
||||
# Cognee
|
||||
|
||||
[cognee](https://www.cognee.ai) is a memory management tool for AI Apps and Agents
|
||||
Embeddings make it easy to retrieve similar chunks of information — but most agent tasks require more: structure, temporal context, and cross-document reasoning. That's where Cognee comes in: it turns raw data sources into AI memory —a semantic data layer based on a modular, queryable knowledge graph backed by embeddings, so agents can retrieve, reason, and remember with structure.
|
||||
|
||||
Qdrant is available as a native built-in vector database to store and retrieve embeddings.
|
||||
## Why Qdrant For The Memory Layer
|
||||
|
||||
At runtime, Cognee's semantic memory layer requires fast and predictable lookups to surface candidates for graph reasoning, as well as tight control over metadata to ground multi-hop traversals. Qdrant's design aligns with those needs with its:
|
||||
|
||||
- Nearest-neighbor search for fast candidate recall.
|
||||
- Expressive payload filtering to constrain by factors like timestamp windows, document type, or source tags.
|
||||
- Operational simplicity so teams can keep focus on the memory layer.
|
||||
|
||||
This integration brings Qdrant's vector search and Cognee's graph reasoning into the same loop. A user's query doesn't just hit a single store — it's embedded, searched, mapped, and fused into evidence before final generation.
|
||||
|
||||
## 📦 Installation
|
||||
1. Embed the query → send to Qdrant for nearest-neighbor retrieval.
|
||||
2. Identify entities/relations → Cognee's graph layer maps candidates to the knowledge graph.
|
||||
3. Fuse and rank → Cognee combines vector candidates with graph context and ranks the evidence.
|
||||
4. Generate → final answer grounded by both vector breadth and graph precision.
|
||||
|
||||
You can install Cognee using either **pip**, **poetry**, **uv** or any other python package manager.
|
||||
Cognee supports Python 3.8 to 3.12
|
||||
The result is breadth from vectors and precision from the graph — useful when questions hinge on who-connected-to-what and how those ties changed over time.
|
||||
|
||||
### With pip
|
||||
## Native Integration
|
||||
|
||||
Cognee ships a Qdrant adapter and documents Qdrant as a preferred, built-in vector database option. That means you configure one URI and key, and Cognee's pipelines will read/write embeddings directly to Qdrant while building and querying the graph.
|
||||
|
||||
```bash
|
||||
pip install cognee
|
||||
pip install Cognee-community-vector-adapter-qdrant
|
||||
```
|
||||
|
||||
## Local Cognee installation
|
||||
## A Minimal Setup
|
||||
|
||||
You can install the local Cognee repo using **pip**, **poetry** and **uv**.
|
||||
For local pip installation please make sure your pip version is above version 21.3.
|
||||
|
||||
### with UV with all optional dependencies
|
||||
|
||||
```bash
|
||||
uv sync --all-extras
|
||||
```
|
||||
|
||||
## 💻 Basic Usage
|
||||
|
||||
### Setup
|
||||
|
||||
```
|
||||
import os
|
||||
os.environ["LLM_API_KEY"] = "YOUR OPENAI_API_KEY"
|
||||
VECTOR_DB_PROVIDER="qdrant"
|
||||
VECTOR_DB_URL=https://url-to-your-qdrant-cloud-instance.cloud.qdrant.io:6333
|
||||
VECTOR_DB_KEY=your-qdrant-api-key
|
||||
|
||||
```
|
||||
|
||||
You can also set the variables by creating .env file, using our <a href="https://github.com/topoteretes/cognee/blob/main/.env.template">template.</a>
|
||||
To use different LLM providers, for more info check out our <a href="https://docs.cognee.ai">documentation</a>
|
||||
|
||||
|
||||
### Simple example
|
||||
|
||||
This script will run the default pipeline:
|
||||
The below example comes from Cognee-community repo and mirrors the structure many teams start with: SQLite for small relational metadata, Qdrant for vectors, and Kùzu for the graph. The register import is enough for Cognee to discover and use the Qdrant adapter.
|
||||
|
||||
```python
|
||||
import cognee
|
||||
import asyncio
|
||||
|
||||
import asyncio, os, pathlib
|
||||
from os import path
|
||||
from cognee_community_vector_adapter_qdrant import register
|
||||
|
||||
async def main():
|
||||
# Add text to cognee
|
||||
await cognee.add("Natural language processing (NLP) is an interdisciplinary subfield of computer science and information retrieval.")
|
||||
from Cognee import SearchType, add, cognify, config, prune, search
|
||||
|
||||
# Generate the knowledge graph
|
||||
await cognee.cognify()
|
||||
system_path = pathlib.Path(__file__).parent
|
||||
config.system_root_directory(path.join(system_path, ".cognee_system"))
|
||||
config.data_root_directory(path.join(system_path, ".data_storage"))
|
||||
|
||||
# Query the knowledge graph
|
||||
results = await cognee.search("Tell me about NLP")
|
||||
config.set_relational_db_config({"db_provider": "sqlite"})
|
||||
config.set_vector_db_config({
|
||||
"vector_db_provider": "qdrant",
|
||||
"vector_db_url": os.getenv("QDRANT_API_URL", "http://localhost:6333"),
|
||||
"vector_db_key": os.getenv("QDRANT_API_KEY", ""),
|
||||
})
|
||||
config.set_graph_db_config({"graph_database_provider": "kuzu"})
|
||||
|
||||
# Display the results
|
||||
for result in results:
|
||||
print(result)
|
||||
await prune.prune_data(); await prune.prune_system(metadata=True)
|
||||
await add("Natural language processing (NLP) ...")
|
||||
await cognify()
|
||||
|
||||
for txt in await search(query_type=SearchType.GRAPH_COMPLETION,
|
||||
query_text="Tell me about NLP"):
|
||||
print(txt)
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
```
|
||||
|
||||
```
|
||||
Example output:
|
||||
```
|
||||
Natural Language Processing (NLP) is a cross-disciplinary and interdisciplinary field that involves computer science and information retrieval. It focuses on the interaction between computers and human language, enabling machines to understand and process natural language.
|
||||
## How It Works
|
||||
|
||||
```
|
||||
Cognee's memory pipelines move content through extraction → embedding → graph construction → retrieval, with consistent configuration across laptops, distributed jobs, and hosted runs. The graph-aware semantic layer is where retrieval becomes reasoning.
|
||||
|
||||
Here's what stands out in production:
|
||||
|
||||
- **Temporal context / as-of queries** — analyze how entities and relationships evolve over time.
|
||||
- **Feedback-driven refinement** — routines to consolidate duplicates and refine edges.
|
||||
- **Ongoing experiments** — testing graph embeddings so similarity can operate over subgraphs, not only text.
|
||||
- **Ontology** — domain ontologies (finance, clinical, customer ops) support consistency, enrichment, and control
|
||||
|
||||
These capabilities are designed to enhance multi-hop performance; for example, Cognee reports 92.5% in recent evaluations, noting that its open-source chain-of-thought retriever helped connect concepts across contexts, especially in multi-hop scenarios.
|
||||
|
||||
A note on evaluation:
|
||||
|
||||
> The Cognee team ran 45 evaluation cycles on 24 questions in HotPotQA, a benchmark that requires answers that combine information from multiple parts of a text. It's still a narrow context compared to real-world memory systems, but it's a useful baseline. The metrics used were Exact Match (EM), F1, DeepEval Correctness (LLM-based), and Human-like Correctness (LLM-based approximation of human eval).
|
||||
|
||||
If you prefer not to run infrastructure, Cognee's hosted option — [cogwit](https://platform.Cognee.ai/) — is in beta. It exposes Cognee's API as a managed service so teams can load data and query the memory layer without maintaining clusters.
|
||||
|
||||
## Further Reading
|
||||
|
||||
- [Cognee Documentation](https://docs.Cognee.ai/getting-started/introduction)
|
||||
- [Cognee Source](https://github.com/topoteretes/Cognee)
|
||||
Reference in New Issue
Block a user