Zero-Cost RAG Stack: Combining Free Embeddings, Vector Search, Rerank & LLMs

Design a four-stage Retrieval-Augmented Generation pipeline using free cloud tiers or local models, with chunking, hybrid search, and offline evaluation tips.

2026-11-26 · FreeTokenBox Editorial · Review method · Token Calculator

Retrieval-Augmented Generation (RAG) lets an LLM answer questions accurately over your own documentation and notes without expensive fine-tuning. Breaking RAG into four decoupled stages makes it straightforward to assemble a zero-cost stack.

1. Four-Stage Zero-Cost Architecture

StageFree Cloud OptionLocal / Edge Zero-Cost OptionKey Constraint
EmbeddingsCloudflare Workers AI (BGE models, very low Neuron cost)Ollama nomic-embed-text or bge-m3Indexing and queries must use the exact same embedding model
Vector StoreCloudflare Vectorize or Supabase pgvector free tiersqlite-vec or LanceDB (single-file)Under 100K chunks, a single-node store is plenty
RerankingCohere Evaluation API (1,000 calls/month free)Hybrid BM25 + Vector RRF or local cross-encoderCompressing Top-20 to Top-4 cuts LLM input tokens by 60%+
GenerationGemini API Free Tier, OpenRouter, or GroqLocal Ollama qwen2.5:7b or gemma3:12bInstruct the model to cite chunks and abstain when evidence is missing

2. Three Parameters That Matter More Than Model Size

Most inaccurate RAG prototypes fail at retrieval rather than generation:

  1. Structure-Aware Chunking: Split along Markdown headings and paragraphs at roughly 350–500 tokens per chunk with 10%–15% overlap. Never slice code blocks or tables in half.
  2. Hybrid Search (BM25 + Dense Vectors): Pure dense embeddings miss exact error codes, SKU strings, and symbol names. Combine full-text search (SQLite FTS5 / BM25) with vector similarity via Reciprocal Rank Fusion (RRF).
  3. Tight Final Context Budget: Retrieve 15–20 candidates, rerank down to the best 3–5 chunks (~1,500–2,500 tokens), and keep generation prompts lean so you stay comfortably inside free TPM caps.

3. Minimal Offline Evaluation Before Launch

Maintain a fixed set of 15–20 realistic questions — including 3 unanswerable questions not present in your corpus. First verify Recall@5 (did the right chunk get retrieved?), then verify Groundedness (does the model refuse cleanly on the 3 unanswerable queries?). Model your expected daily volume with the RAG Docs preset in our AI Token Calculator.