# Knowledge bases and RAG

> Extract and index document content, keep embeddings compatible, retrieve useful source passages, and use them to ground a model’s answer.

Source: https://kaitoi.io/docs/studio/rag/
Section: Kaitoi Studio / Research and knowledge
Written for: Anyone building a document-backed question-answering workflow.
Last reviewed: 2026-10-24

---

Retrieval-augmented generation, or RAG, finds relevant document passages and
gives them to a model alongside the question. It helps ground an answer in your
sources; it does not guarantee the answer is correct.

## Trace the answer to its evidence


The fictional visitor guide says the garden opens at 9 am. A retrieved passage supports that answer and retains its source identifier. It says nothing about the designer; the answer should acknowledge missing evidence. Inspect extraction and retrieval before changing the answer prompt. Document and query embeddings need a compatible model and dimensions, plus a configured vector index. Matching dimensions alone is insufficient.

Passage 02 is highlighted in the fictional source document, carried into retrieved context and matched to the supported “9 am” phrase in the answer. The designer question has no matching evidence.

*Figure: Compare a supported answer with a question the source cannot answer.*

## Prepare a small collection

Use the document-to-RAG workflow offered in the node library for a convenient
starting point, or build the individual stages: extract text, split it into
chunks, generate embeddings, and store the vectors with useful source metadata.

Begin with a few documents you know well. Verify extracted text before indexing,
especially for scanned, layout-heavy, or unsupported files. An embedding cannot
repair text that was extracted incorrectly.

## Keep embeddings compatible

The stored documents and the search query need compatible embeddings. Preserve
the chosen embedding model and dimensions for a collection. Changing those
settings can require reindexing rather than mixing incompatible vectors.

Embedding and answer-generation calls can have separate provider requirements
and costs. Check which service receives your document text before indexing
private material.

## Retrieve, then answer

Search the collection with a test question and inspect the returned passages.
Check whether the relevant source was found before changing the final model's
prompt. Pass the retrieved context to the answer step and ask it to identify
the supporting sources and uncertainty.

Try a question the documents do not answer. A useful workflow should say when
its context is insufficient rather than inventing a source-backed claim.

## Maintain the collection

Keep source identifiers so changed documents can be traced. Original uploads
and indexed embeddings are separate retained data; manage each deliberately.
Use the supported browser and indexing workflow rather than assuming a
per-document collection manager is available.

## Verify retrieval before changing the answer

**Extract:** inspect text from known documents before embedding it.
**Index:** use compatible embedding models/dimensions and a configured vector
database with indexes. **Answer:** inspect Technical Details and Sources JSON,
including a question without supporting evidence. RAG Document Browser's
Clear Database clears stored embeddings, not one selected upload.

## Checks and next steps

The built-in workflow requires an installation with the configured MongoDB
vector database and compatible vector-search indexes. A JSON-only local
storage setup does not by itself supply this service. Confirm availability
with the installation administrator before diagnosing every missing result
as an embedding-model problem.

Use **RAG Query → Technical Details** and **Sources JSON** to inspect retrieved
evidence. **RAG Document Browser** offers document reports, statistics, and
tag filtering. Its **Clear Database** action clears the caller's stored
embeddings; it is not a selected-file delete, and it does not delete original
uploads. Treat it as a broad destructive action and retain source documents
and indexing settings if you need to rebuild.

Keep embedding model and dimensions consistent for the query and collection.
Matching dimensions alone does not make two different embedding models
compatible. Test both a known answer and an absent answer before relying on
the final model response.
