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.
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
| Stage | Free Cloud Option | Local / Edge Zero-Cost Option | Key Constraint |
|---|---|---|---|
| Embeddings | Cloudflare Workers AI (BGE models, very low Neuron cost) | Ollama nomic-embed-text or bge-m3 | Indexing and queries must use the exact same embedding model |
| Vector Store | Cloudflare Vectorize or Supabase pgvector free tier | sqlite-vec or LanceDB (single-file) | Under 100K chunks, a single-node store is plenty |
| Reranking | Cohere Evaluation API (1,000 calls/month free) | Hybrid BM25 + Vector RRF or local cross-encoder | Compressing Top-20 to Top-4 cuts LLM input tokens by 60%+ |
| Generation | Gemini API Free Tier, OpenRouter, or Groq | Local Ollama qwen2.5:7b or gemma3:12b | Instruct 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:
- 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.
- 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).
- 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.