You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<palign="center"><b>Context Database for Hierarchical Document Trees</b></p>
5
+
<br/>
6
6
7
-
<palign="center">
8
-
Store, navigate, and query hierarchical document structures with LLM-powered reasoning retrieval.
9
-
</p>
7
+
# ConDB: The KV-Cache Native Context Database
8
+
9
+
<palign="center"><i>A new context database for reasoning-driven retrieval via tree search.<br/>
10
+
Fast, context-aware retrieval at scale with up to 70% less token cost.</i></p>
10
11
11
12
</div>
12
13
13
14
---
14
15
15
-
## What is ConDB?
16
+
## 🌲 What is ConDB?
17
+
18
+
**ConDB** (Context Database) is a tree-structured context database that uses LLM-powered **reasoning-based retrieval** via tree search instead of vector similarity — no vector DB, no chunking. It accepts [PageIndex](https://github.com/VectifyAI/PageIndex)-compatible document trees, [ChatIndex](https://github.com/VectifyAI/ChatIndex) conversation trees, filesystem trees, and custom hierarchical JSON — with no runtime dependency on either. The LLM reasons over the tree, like a human expert using a table of contents, to locate relevant content.
19
+
20
+
### Why not vector search?
21
+
22
+
-**Similarity ≠ relevance** — vector search retrieves what looks similar, not what is truly relevant. Similar-looking chunks may differ in intent (low accuracy), while truly relevant information may be expressed in very different language and get missed entirely (low recall). True relevance requires reasoning
23
+
-**Chunking breaks semantic continuity** — documents must be split into fixed-size segments to fit embedding models, causing context fragmentation that destroys their natural structure and cross-section relationships
24
+
-**Retrieval is blind to context** — embedding models encode the query alone, ignoring conversational history, user intent, and other contextual signals
25
+
26
+
ConDB replaces this with **reasoning-based tree search**: the LLM performs node-level relevance classification over a hierarchical index, incorporating full context — making retrieval adaptive, explainable, and traceable.
16
27
17
-
**ConDB** stores hierarchical document trees in a SQLite database and provides LLM-powered **reasoning-based retrieval** to query them — no vector DB, no chunking. It accepts pageindex-compatible trees, chat trees, and custom hierarchical JSON without taking a runtime code dependency on PageIndex itself.
28
+
### What makes ConDB different
18
29
19
-
**Key capabilities:**
30
+
-**Fast tree search at scale** — reasoning-driven tree search with block partitioning and parallel processing, supporting complex, context-aware retrieval over large hierarchical structures
31
+
-**KV-cache native** — the first database designed around LLM KV-cache reuse. By caching intermediate results during tree search, ConDB reduces token usage by up to 70% with no loss in accuracy. The same efficiency gains extend to memory systems for long-context reasoning at scale
32
+
-**Unified long-context infrastructure** — a single system for both static and dynamic long-context workloads
20
33
21
-
-**Hierarchical storage** — store document trees, chat trees, and custom hierarchical JSON in SQLite
22
-
-**Reasoning-based retrieval** — LLM navigates the tree to find relevant content, like a human expert
34
+
### Static long context
35
+
Structured, persistent knowledge — documents (via [PageIndex](https://github.com/VectifyAI/PageIndex)), file systems, and codebases. Scalable retrieval within large, organized hierarchies.
36
+
37
+
### Dynamic long context
38
+
Evolving, runtime context — agent memory, long conversations (via [ChatIndex](https://github.com/VectifyAI/ChatIndex)), and autoresearch. Systems can continuously update, retrieve, and reason over newly generated information.
39
+
40
+
### Key capabilities
41
+
42
+
-**Hierarchical storage** — document trees, chat trees, and custom hierarchical JSON in SQLite
23
43
-**Multiple retrieval strategies** — beam search for small trees, block retrieval for large documents
24
-
-**Multi-provider LLM support** — works with Anthropic (Claude) and OpenAI (GPT) out of the box
44
+
-**Multi-provider LLM support** — Anthropic (Claude) and OpenAI (GPT) out of the box
25
45
-**Extensible** — plug in custom storage backends, LLM providers, or retrieval strategies
ConDB automatically selects the best retrieval strategy based on tree size:
110
128
111
129
| Strategy | Best for | How it works |
112
130
|----------|----------|--------------|
113
-
|**Beam**| Small trees (< 50 nodes) | LLM evaluates and selects promising branches at each depth level |
114
-
|**Block**| Large documents (50+ nodes) | Splits tree into token-bounded blocks, LLM reasons over each block |
131
+
|**Beam**| Small trees <br/> (< 50 nodes) | LLM evaluates and selects promising branches at each depth level |
132
+
|**Block**| Large documents <br/> (50+ nodes) | Splits tree into token-bounded blocks, LLM reasons over each block. KV-cache native — caches intermediate block results to cut token usage by up to 70%|
115
133
116
134
You can also specify a strategy explicitly:
117
135
@@ -121,7 +139,7 @@ result = db.query(tree_id, "question", strategy="block", beam_size=3)
121
139
122
140
---
123
141
124
-
## Benchmark
142
+
## 📈 Benchmark Snapshot
125
143
126
144
Two benchmarks live under `bench/`.
127
145
@@ -171,7 +189,9 @@ any `--doc` and any `--config` to benchmark a different document.
171
189
172
190
---
173
191
174
-
## Architecture
192
+
## 🧩 Learn More
193
+
194
+
### Architecture
175
195
176
196
```
177
197
contextdb/
@@ -190,12 +210,9 @@ contextdb/
190
210
└── prompts/ # Jinja2 prompt templates
191
211
```
192
212
193
-
---
213
+
### Extending
194
214
195
-
## Extending
196
-
197
-
<details>
198
-
<summary><b>Custom Storage Backend</b></summary>
215
+
**Custom Storage Backend**
199
216
200
217
```python
201
218
from contextdb import StorageProtocol
@@ -207,10 +224,8 @@ class MyStorage:
207
224
208
225
ct = ContextTree(storage=MyStorage())
209
226
```
210
-
</details>
211
227
212
-
<details>
213
-
<summary><b>Custom LLM Provider</b></summary>
228
+
**Custom LLM Provider**
214
229
215
230
```python
216
231
from contextdb import LLMProtocol
@@ -221,25 +236,32 @@ class MyLLM:
221
236
222
237
ct = ContextTree("db.sqlite", llm=MyLLM())
223
238
```
224
-
</details>
225
239
226
-
---
227
-
228
-
## Testing
240
+
### Testing
229
241
230
242
```bash
231
243
./run_tests.sh all
232
244
```
233
245
234
246
---
235
247
236
-
## Related Projects
248
+
## 💬 Community
249
+
250
+
### Related Projects
237
251
238
-
-[**PageIndex**](https://github.com/VectifyAI/PageIndex) — one possible external producer of pageindex-compatible document trees
252
+
-[**PageIndex**](https://github.com/VectifyAI/PageIndex) — vectorless, reasoning-based RAG that builds hierarchical tree indexes from long documents
253
+
-[**ChatIndex**](https://github.com/VectifyAI/ChatIndex) — tree indexing for long conversations, enabling reasoning-based retrieval over chat histories
239
254
-[**AgentFS**](https://github.com/anthropics/agentfs) — filesystem for AI agents
0 commit comments