AI Workflow Templates
RetrievalintermediateCI-safeupdated 2026-08-11

RAG Over Your Docs

A retrieval-augmented Q&A pipeline: chunk, embed, retrieve, and answer with citations over your own documents.

#rag#embeddings#retrieval#qa
View source →

Tools in the pipeline

  • validator
    chunker
    Split docs into ~500-token chunks with overlap.
  • api
    embedder
    Store vectors plus source metadata.
  • retriever
    retriever
    Top-k by cosine similarity with a minimum threshold.
  • llm
    answer-model
    Answer only from retrieved context, with citations.
Stack: embeddings · vector DB · LLM

What it does

Answers questions grounded in a document set instead of the model's memory. Chunks source docs, embeds them, retrieves the top-k relevant chunks per query, and asks the model to answer only from retrieved context, with inline citations back to the source.

Pipeline

  1. Ingest — split docs into ~500-token chunks with ~50-token overlap.
  2. Embed — store vectors + source metadata in a vector DB.
  3. Retrieve — embed the query, pull top-k (start with k=5) by cosine similarity.
  4. Answer — prompt the model with the chunks and require citations.
  5. Fallback — if no chunk clears a similarity threshold, say 'not found in the docs' rather than guessing.

Prompt skeleton

Answer the question using ONLY the context below.
Cite each claim as [source: <file>#<chunk>].
If the context doesn't contain the answer, say so.

Context:
{retrieved_chunks}

Question: {user_question}

Guardrails

Require citations and reject answers without them. Set a minimum similarity threshold so off-topic questions return 'not found' instead of a hallucination. Log the retrieved chunk IDs with every answer so you can audit wrong results.

Structural dry-run

No model call. Validates required fields only.

Prefills the example payload for Policy question. Edit it, then run.

Related