Download

Context Manager & RAG — User Guide | YoBench

How to use the Context Manager & RAG module in YoBench: upload PDF/DOCX/XLSX, embedding providers, LanceDB vector search, AI Chat integration.

What the Context Manager & RAG module does

The module turns your documents into knowledge bases available to AI Chat. You create a context, upload files (PDF, DOCX, XLSX, CSV, images) or text into it, the module automatically chunks the content, computes embeddings via the chosen provider, and stores vectors in a local LanceDB. When you talk to AI Chat, YoBench retrieves the most relevant chunks and injects them into the system prompt — so the model answers from your documents, not just general knowledge.

What you get:

  • Named knowledge bases — a separate context per project / topic.
  • Supported formats — PDF, DOCX, XLSX/XLS, CSV, TXT, MD, images (PNG, JPG, GIF, WebP). Images and PDFs go through built-in OCR; XLSX/CSV are converted to flat text per sheet.
  • Local LanceDB — vectors live under userData/lancedb/, one table per context (ctx_{id}).
  • Multiple embedding providers — OpenAI, LM Studio, Ollama (any OpenAI-compatible endpoint). Exactly one is active; switching it marks every context as stale and triggers async re-indexing.
  • AI Chat integration — relevant chunks are auto-injected into the system prompt on the first user message of a conversation.

Data structure

  • Contextname, embedding_provider_id, embedding_model (snapshot of the model), vectorization_status (ready / stale / indexing / error).
  • Context items — units of uploaded content: type (text / file / image / module_ref), content, file metadata, chunk_count.
  • Vectors (LanceDB) — table ctx_{id} with item_id, chunk_index, text, vector.

Embedding providers

In Context Manager → Embedding providers you add a provider:

  • Name — an arbitrary label.
  • Base URL — OpenAI-compatible /v1/embeddings endpoint. Examples:
    • OpenAI: https://api.openai.com/v1, model text-embedding-3-small.
    • LM Studio (local): http://localhost:1234/v1, model text-embedding-nomic-embed-text-v1.5.
    • Ollama (local): http://localhost:11434/v1, model bge-m3.
  • API key — when needed (often empty for local servers).
  • Model — embedding model name on the server.

One provider is marked active — used for every context. Changing the active provider or model marks every existing context as stale, and they're re-indexed in the background.

Chunking and search

Chunking parameters are baked into the code:

  • Heading-aware chunking — for Markdown and structured text, the splitter prefers headings as cut points so a chunk stays semantically self-contained. Plain text falls back to fixed-size chunks.
  • Overlap between adjacent chunks — preserves context across the boundary.
  • Top-K at search time — default 5 chunks per query.

These knobs are not exposed in the UI — they're tuned for typical models and most workloads.

Search modes

Each chat session picks one of two retrieval modes:

  • Fast (default) — hybrid search (vector + keyword) over the context. Returns results in a fraction of a second; good for everyday questions.
  • Accurate — the same hybrid search, then a reranker re-orders the top candidates for relevance. A little slower, noticeably better on long or ambiguous queries.

Supported formats

Type What the module does
PDF OCR via the built-in service, page-level text extraction.
DOCX Plain-text extraction via mammoth.
XLSX, XLS, CSV Sheets converted to CSV text and concatenated.
TXT, MD Read as is.
PNG, JPG, GIF, WebP OCR-based text recognition on the image.

AI Chat integration

In AI Chat you pick a context for the conversation. On the first user message the module:

  1. Sends your query as a search phrase to LanceDB.
  2. Gets the top-K chunks for the context.
  3. Formats them as a Markdown block (# Reference context: {name} + ## [N] {title} + chunk text).
  4. Injects the block into the system prompt, alongside the heading and instructions.

On later turns retrieval does not repeat (the context is already in the system prompt).

Retrieval is skipped when:

  • The context is indexing (not ready).
  • No active embedding provider is configured.
  • The model snapshot in the context doesn't match the active provider — wait for re-indexing to finish.

In those cases the chat keeps working, just without context injection.

Global settings

There are no dedicated context* keys in the central settings — all configuration is in the database (embedding_providers and contexts tables). Managed from the module itself.

Workflow

1. Wire up an embedding provider

  1. Open the Context Manager from the left sidebar.
  2. Go to Embedding providers.
  3. Add a provider: name, Base URL, API key, model.
  4. Mark it active.

2. Create a context

  1. On the module home click New context.
  2. Name it (e.g. "Product docs", "Legal corpus").
  3. Save.

3. Upload documents

  1. In the context click Add file or drag a file onto the panel.
  2. Supported formats: PDF, DOCX, XLSX, CSV, TXT, MD, PNG/JPG/GIF/WebP.
  3. You can also paste text directly or wire in articles via the RSS module.
  4. Wait for indexing to finish (the badge flips to "Vectors up to date").

4. Connect the context to a chat

In AI Chat pick the context in the session settings. Now ask away — the model answers from your documents.

5. Manage the context

  • Remove item — drop a specific document from the context.
  • Re-index — force vector rebuild.
  • Delete context — removes it together with its LanceDB table.

Next steps

  • Configure AI providers for answer generation.
  • Use the RSS module to feed articles into contexts.
  • The Web Parser can scrape sites into JSON that you can later import into a context.

Help and feedback

Want default local embeddings or UI-tunable chunking? Contact us via the feedback form.