How to Build a Grounded RAG Prompt That Cites Sources and Admits Gaps
Assemble retrieved chunks into a prompt with source labels, so the answer cites sources and says when it does not know.
THE FIELD GUIDE
Understand model formats, context windows, quantization, embeddings, and sampling before choosing settings for a real task.
Assemble retrieved chunks into a prompt with source labels, so the answer cites sources and says when it does not know.
Write questions with known answers, run retrieval, and measure whether the right chunks come back.
Retrieve a broad set of chunks, score each one against the question with a cross-encoder, and keep the best shortlist.
Run dense vector search and BM25 keyword search together so exact terms and meanings both match.
Enable pgvector, store embeddings in a table with an HNSW index, and run a cosine similarity query.
Create a persistent Chroma collection, add embeddings with metadata, and query it by semantic similarity.
Send chunks to the embedding API in batches of 100 to 500 inputs so ingestion finishes without hitting rate limits.
Compare embedding models by dimensions, input limit and cost, then check the pick fits your vector store.
Split documents at heading tags so each chunk keeps its title and the paragraphs that belong to it.
Split documents into fixed-size chunks with overlap so no sentence is lost at a boundary.