// PART 04
RAG, Knowledge Base, and memory
Retrieval decides what the model knows when it answers. This page is the authoritative description of how General Bots retrieves text today, which retrieval strategies exist, and which ones the field has moved on to that this platform does not implement.
Verified September 2026 against
botserver/src/core/bot/kb_context/. If a claim here disagrees with the code, the code is right — please open an issue.
Retrieval modes
Retrieval is selected per bot with a single setting, rag-mode. Six modes are implemented and all of them are reachable from chat.
| Mode | What it actually does | Cost |
|---|---|---|
standard |
Embeds the query, searches Qdrant by cosine similarity, drops results scoring below 0.20 | One embedding call |
hybrid |
Runs the dense search and a keyword search, then merges both with Reciprocal Rank Fusion, k = 60. Falls back to whichever side returned results |
One embedding call + one scroll |
corrective |
Asks the LLM for 2–3 search variants, searches each, merges and de-duplicates, then has the LLM grade every chunk 0–10 and keeps those scoring 3 or better. If nothing is found locally it tries a web crawl (depth 1, up to 3 pages) | 1 + N embedding calls, one grading call per chunk |
graph |
Has the LLM extract up to 5 named entities, searches each entity separately, then merges them with the original query’s results. This is entity-expansion retrieval, not a knowledge graph — see the limits below | 1 + N embedding calls |
agentic |
Has the LLM decompose the query into 2–3 focused sub-queries, searches each, then merges and re-ranks by score | 1 + N embedding calls |
multimodal |
Expands the query into three variants biased toward visual language, searches each, then boosts chunks containing terms like diagram, chart, figure or screenshot |
1 + 3 embedding calls |
Every mode degrades rather than failing: if the LLM is unavailable, the LLM-assisted modes fall back to heuristic splitting (expand_query, decompose_query) instead of returning nothing.
Which mode to choose
| Situation | Mode |
|---|---|
| Default, cheapest, good precision floor | standard |
| Keyword-heavy corpora (codes, part numbers) | hybrid |
| Noisy corpora where precision matters more than cost | corrective |
| Questions about specific named things | graph |
| Broad questions that need decomposition | agentic |
| Diagrams, screenshots, UI documentation | multimodal |
Configuration
| Key | Default | Meaning |
|---|---|---|
rag-mode |
standard |
selects the retrieval mode (kb_context_ops.rs) |
embedding-url |
(empty → built-in default) | embedding service endpoint |
embedding-model |
all-MiniLM-L6-v2 |
embedding model name |
Knowledge comes from {bot}.gbkb/ collections in Drive; USE KB "collection"
activates one for the session. Collections are indexed by the knowledge
pipeline; the Drive compilers page describes the storage side.
What the platform does not implement
Stated plainly, because retrieval marketing moves fast:
| Strategy | Status |
|---|---|
| True knowledge graphs (entities + relations traversed at query time) | not implemented — graph mode is entity-expansion only |
| Reranking with a cross-encoder model | not implemented |
| Multi-vector / ColBERT-style retrieval | not implemented |
| HyDE or other hypothetical-document techniques | not implemented |
| A BM25 tuner or query decomposer as configurable services | dead code with no consumers — do not configure them |
Memory, briefly
Retrieval is per-turn knowledge; memory is cross-session knowledge. They are
separate systems: SET/GET USER MEMORY and the Memory app (extraction, recall
with a token budget, deliberate forgetting) live in botmemory and
core/user_memory.rs, and do not route through rag-mode. See User memory,
consent, and secrets for that machinery.
Reading the code
| Question | File |
|---|---|
| Which mode is active for a bot? | kb_context_ops.rs (rag-mode read) |
| Where do the modes live? | kb_context/rag_modes/ |
| How does the query get embedded? | botcore/src/kb/embedding_generator/ |
| What does Qdrant see? | botqdrant crate |