Skip to content
KallamoDocsBack to the site

How Kallamo finds context

A model only knows what is in the request. Kallamo’s job, before every reply, is to put the right part of your story in it: the canon that matters, the passages that answer the question, the conversation from fifty chapters ago. This is retrieval-augmented generation (RAG), and in Kallamo it runs entirely on your computer.

Source Where it comes from
Profile knowledge The replying profile’s knowledge base.
Workspace files and notes The workspace’s Memory.
Long-term memory Archived conversation, and chapters in AI memory.
Worldbuild Entity sheets, their relationships, facts and, in roleplay, Knowledge.

Anything marked always on is not searched: it is sent with every request.

When you add a searchable file, write a note, archive a conversation or put a chapter in AI memory, Kallamo prepares it for search:

  1. Text is extracted (PDF, DOCX, TXT, MD).
  2. It is split into passages that follow paragraphs, with a small overlap so an idea is not cut in half. Passage length is set in Settings › Retrieval; archived chat uses longer passages.
  3. Each passage gets an embedding: a list of numbers that captures its meaning. The default engine, multilingual-e5-small, runs on your computer and reads many languages. Settings › Embeddings can use a connection instead.
  4. Passages are stored in the local database with a keyword index beside them.
  5. The World Index tags each passage with the Worldbuild names it mentions.

Every search runs two ways at once and merges them:

  • By meaning. Your message gets an embedding too, and passages close to it in meaning score high, even with none of the same words. This carries most of the weight.
  • By words. A keyword search finds exact names and rare terms that meaning alone can blur. It breaks ties and rescues exact matches.
  • By names. A passage that mentions a Worldbuild entity your message names gets a small boost, larger when the name is rare in the workspace.

Strictness, in Settings › Retrieval, is the cut-off: how close in meaning a passage must be to count. A keyword or name match can reorder what passed, but never rescues a passage that is off topic.

Strictness Good for
Broad, Balanced Wide questions, brainstorming.
Moderate Most use.
Focused, Strict Specific lookups, large libraries with lots of similar text.

Entities named in the conversation are looked up in Worldbuild and their sheets enter the context. Worldbuild breadth, in Settings › Retrieval, decides how far relationships are followed: Focused, Balanced or Broad. In roleplay, what enters is filtered by perspective: a character’s scene only gets what they could know.

A profile with smart search on goes further: after the plain search, a planner reads the conversation, writes its own searches, reads whole files, looks up entities and recalls archived conversation, for up to five rounds.

Everything found competes for room in the request. See Context budget and prompt cache for the full picture; in short:

  • The conversation is measured first, so retrieval cannot push it out, and retrieval always keeps at least 40% of the room.
  • Each search brings at least a minimum number of passages per source (Settings › Retrieval: profile knowledge, workspace files, long-term memory, Worldbuild entities), and more when the budget can hold them.
  • What does not fit is left out in order of priority: Worldbuild facts first, then whole files, then search hits, then everything else.
  • Answers miss facts you know are there? Lower Strictness one band, or raise the minimum passages for that source. Make sure the name in your question matches the Worldbuild name or one of its other names.
  • Answers pull in unrelated lore? Raise Strictness, or narrow Worldbuild breadth.
  • Long files cost too much? Make them searchable, not always on.
  • A profile keeps missing context spread across the story? Turn on smart search.