← Beyond AI · ContextForge article
ContextForge · plain-English demo

How do you give a chatbot a memory bigger than its brain?

Imagine you run Nimbus, a coffee subscription company. You want a support bot that knows everything — shipping, refunds, every coffee, every brewing guide. But a chatbot can only read so much text at once. Your help docs don't fit. So what do you do? This page is the answer you can click.

The problem, in one picture

A language model has a fixed reading limit per message (its "context window"). Your knowledge base does not.

✕ The naive way paste everything

Stuff all your docs into every single message. Works with 5 docs. Falls apart with 500: it's slow, it's expensive, and eventually it just doesn't fit.

LLM PROMPT
every doc · every message · 💸

✓ The ContextForge way retrieve what's needed

Store every doc on disk. For each question, pull only the 2–3 docs that actually answer it into the message. The other 9,997 stay on the shelf.

DATABASE LLM PROMPT
3 docs · this message · ✓

Try it yourself — this is real retrieval

Ask the Nimbus bot a question. On the right, watch exactly what happens under the hood: which words it pulls out, which docs it grabs, and the actual message it builds. Nothing here is faked — the panel runs the same keyword-ranking math (BM25) that ContextForge uses internally.

Nimbus Support Bot
Under the hood

👆 Ask a question and this panel shows the retrieval, step by step.

The magic trick: grow the knowledge base to 10,000 docs

Here's the part that matters. Drag the slider to add more help docs to Nimbus. Watch what happens to the size of each message the bot sends.

Knowledge base
24 docs
✕ Naive — paste every doc each message—
✓ ContextForge — retrieve top 3—
—
That flat green bar is the whole point. The naive message grows without limit and eventually overflows the model entirely. ContextForge's message stays the same tiny size whether you have 24 docs or 10 million — because it only ever sends the handful that answer this question. Your cost stops depending on how much you know.

And the honest part: where it breaks

This isn't magic, it's keyword matching — so it has a real blind spot. It finds docs that share words with your question. Ask the same thing in different words, and it can whiff. Click this and watch it miss:

Why it missed: the shipping doc says "orders arrive in 3–5 business days." Your question said "show up at my door." Zero shared words → the keyword search never finds it, even though the answer is sitting right there. This is the one real limitation, and it's why you pair ContextForge with a capable model and a strict "don't guess" instruction — so when retrieval misses, the bot says "I don't have that" instead of inventing an answer.

The whole thing, in real code

Everything you just clicked is about 15 lines. This is the actual ContextForge API:

✓ With ContextForge
# Once: load your whole knowledge base
from contextforge import ContextForge

cf = ContextForge(
    db_path="nimbus.db",
    min_score=2.0,   # ignore weak matches
)
await cf.ingest("./help_docs")  # 10,000 files

# Per question: it grabs only what's needed
reply = await cf.chat("How do I get a refund?")
# → only the Returns doc enters the prompt.
# The other 9,999 stay on disk. ~150 tokens.
✕ The naive way
# Paste the entire knowledge base into
# every single message, forever:

docs = load_all("./help_docs")   # 10,000 files

prompt = (
    SYSTEM +
    "\n".join(docs) +        # 👈 everything
    user_question
)
reply = await llm.chat(prompt)
# → ~600,000 tokens. Every turn.
# Slow, expensive, and won't even fit. 💸

So… how is this useful to you?

Swap "Nimbus coffee" for anything with more docs than fits in a prompt. Same trick, instant payoff:

The one-sentence version: ContextForge lets a chatbot act like it has read everything you own, while only ever reading the few paragraphs each question needs. Cheap, fast, and it doesn't fall over when your knowledge base grows — as long as people ask using words your docs actually contain.
Live demo · real BM25 retrieval running in your browser · synthetic "Nimbus" data.
Companion to the empirical report — the article that walks through where this SDK holds up and where it breaks.