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
@@ -183,7 +201,9 @@ any `--doc` and any `--config` to benchmark a different document.
183
201
184
202
---
185
203
186
-
## Architecture
204
+
## 🧩 Learn More
205
+
206
+
### Architecture
187
207
188
208
```
189
209
contextdb/
@@ -202,12 +222,9 @@ contextdb/
202
222
└── prompts/ # Jinja2 prompt templates
203
223
```
204
224
205
-
---
225
+
### Extending
206
226
207
-
## Extending
208
-
209
-
<details>
210
-
<summary><b>Custom Storage Backend</b></summary>
227
+
**Custom Storage Backend**
211
228
212
229
```python
213
230
from contextdb import StorageProtocol
@@ -219,10 +236,8 @@ class MyStorage:
219
236
220
237
ct = ContextTree(storage=MyStorage())
221
238
```
222
-
</details>
223
239
224
-
<details>
225
-
<summary><b>Custom LLM Provider</b></summary>
240
+
**Custom LLM Provider**
226
241
227
242
```python
228
243
from contextdb import LLMProtocol
@@ -233,25 +248,32 @@ class MyLLM:
233
248
234
249
ct = ContextTree("db.sqlite", llm=MyLLM())
235
250
```
236
-
</details>
237
251
238
-
---
239
-
240
-
## Testing
252
+
### Testing
241
253
242
254
```bash
243
255
./run_tests.sh all
244
256
```
245
257
246
258
---
247
259
248
-
## Related Projects
260
+
## 💬 Community
261
+
262
+
### Related Projects
249
263
250
-
-[**PageIndex**](https://github.com/VectifyAI/PageIndex) — one possible external producer of pageindex-compatible document trees
264
+
-[**PageIndex**](https://github.com/VectifyAI/PageIndex) — vectorless, reasoning-based RAG that builds hierarchical tree indexes from long documents
265
+
-[**ChatIndex**](https://github.com/VectifyAI/ChatIndex) — tree indexing for long conversations, enabling reasoning-based retrieval over chat histories
251
266
-[**AgentFS**](https://github.com/anthropics/agentfs) — filesystem for AI agents
0 commit comments