<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Charles</title>
    <description>The latest articles on DEV Community by Charles (@ksgg).</description>
    <link>https://dev.to/ksgg</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3974658%2F3ca36c37-4dba-4a29-995e-08ca606a2531.png</url>
      <title>DEV Community: Charles</title>
      <link>https://dev.to/ksgg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ksgg"/>
    <language>en</language>
    <item>
      <title>How I benchmarked a 100% local RAG pipeline to 9/9 (zero API keys)</title>
      <dc:creator>Charles</dc:creator>
      <pubDate>Mon, 08 Jun 2026 18:14:35 +0000</pubDate>
      <link>https://dev.to/ksgg/how-i-benchmarked-a-100-local-rag-pipeline-to-99-zero-api-keys-1koh</link>
      <guid>https://dev.to/ksgg/how-i-benchmarked-a-100-local-rag-pipeline-to-99-zero-api-keys-1koh</guid>
      <description>&lt;p&gt;Most "chat with your documents" demos work in an afternoon. Then you hit the last&lt;br&gt;
20%: retrieval that misses the right passage, an LLM that confidently makes things&lt;br&gt;
up, a reranker that wrecks your latency, chunking you re-tune ten times. And if&lt;br&gt;
your documents are sensitive — legal, medical, internal — you can't just paste&lt;br&gt;
them into a cloud API.&lt;/p&gt;

&lt;p&gt;So I built a fully local RAG pipeline and, more importantly, a &lt;strong&gt;reproducible&lt;br&gt;
benchmark&lt;/strong&gt; to prove it actually works. Everything runs on the machine. No&lt;br&gt;
OpenAI, no Anthropic, no Cohere. Here's the stack, the numbers, and what actually&lt;br&gt;
moved them.&lt;/p&gt;

&lt;h2&gt;
  
  
  The stack (all local, permissively licensed)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Embeddings:&lt;/strong&gt; Qwen3-Embedding-0.6B (bge-m3 as a fallback)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vector store:&lt;/strong&gt; Qdrant in local/embedded mode (no Docker)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retrieval:&lt;/strong&gt; dense + sparse BM25, fused with Reciprocal Rank Fusion (RRF)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reranker:&lt;/strong&gt; a cross-encoder (MiniLM) over the top-k&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LLM:&lt;/strong&gt; Gemma3:4b via Ollama&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Eval judge:&lt;/strong&gt; the same local LLM (so even evaluation makes zero external calls)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The targets (from current RAG benchmarks)
&lt;/h2&gt;

&lt;p&gt;I wanted pass/fail thresholds, not vibes:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Target&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hit Rate@5&lt;/td&gt;
&lt;td&gt;≥ 0.90&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MRR&lt;/td&gt;
&lt;td&gt;≥ 0.75&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Context Precision@3&lt;/td&gt;
&lt;td&gt;≥ 0.70&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Context Recall&lt;/td&gt;
&lt;td&gt;≥ 0.85&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Faithfulness&lt;/td&gt;
&lt;td&gt;≥ 0.90&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Answer Relevancy&lt;/td&gt;
&lt;td&gt;≥ 0.85&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Retrieval latency (p50)&lt;/td&gt;
&lt;td&gt;≤ 1.0s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;End-to-end (p50)&lt;/td&gt;
&lt;td&gt;≤ 8.0s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What actually moved the numbers
&lt;/h2&gt;

&lt;p&gt;Starting from a naive dense-only baseline (5/9 passing), four changes did the work:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Hybrid + RRF&lt;/strong&gt; took Hit Rate@5 from 0.90 (dense only) to &lt;strong&gt;1.0&lt;/strong&gt;. Keyword
matching catches what embeddings miss, and vice versa.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The reranker&lt;/strong&gt; took Context Precision@3 from &lt;strong&gt;0.45 → 0.89&lt;/strong&gt;. The single
biggest precision lever. Cross-encoders are slow, so it only runs on the top-k.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A strict prompt&lt;/strong&gt; ("answer ONLY from the context; if it's not there, say you
don't know") plus temperature 0.1 took Faithfulness from &lt;strong&gt;0.62 → 1.0&lt;/strong&gt;. Most
"hallucination" is really a prompt + retrieval problem.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Putting Ollama on the GPU&lt;/strong&gt; cut end-to-end p50 from &lt;strong&gt;14s → 6.5s&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Results (validated at 3 scales)
&lt;/h2&gt;

&lt;p&gt;To rule out "it only works because the corpus is tiny", I ran it on 42, 124, and&lt;br&gt;
274 questions with chunk-level ground truth. Scores stayed flat-to-rising as the&lt;br&gt;
corpus grew 16×:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;42Q&lt;/th&gt;
&lt;th&gt;124Q&lt;/th&gt;
&lt;th&gt;274Q&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hit Rate@5&lt;/td&gt;
&lt;td&gt;1.00&lt;/td&gt;
&lt;td&gt;1.00&lt;/td&gt;
&lt;td&gt;1.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MRR&lt;/td&gt;
&lt;td&gt;0.95&lt;/td&gt;
&lt;td&gt;0.98&lt;/td&gt;
&lt;td&gt;0.98&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Context Precision@3&lt;/td&gt;
&lt;td&gt;0.89&lt;/td&gt;
&lt;td&gt;0.92&lt;/td&gt;
&lt;td&gt;0.93&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Faithfulness&lt;/td&gt;
&lt;td&gt;1.00&lt;/td&gt;
&lt;td&gt;0.99&lt;/td&gt;
&lt;td&gt;0.97&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Answer Relevancy&lt;/td&gt;
&lt;td&gt;0.88&lt;/td&gt;
&lt;td&gt;0.90&lt;/td&gt;
&lt;td&gt;0.92&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;9/9 at every scale.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Measure first.&lt;/strong&gt; Without an eval harness, you optimize blind. The retrieval
metrics alone (no LLM) run in seconds and catch most regressions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;"Hallucination" is usually retrieval.&lt;/strong&gt; If faithfulness is fine but relevancy
is low, your problem is upstream in retrieval, not the model.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local is a feature, not a compromise.&lt;/strong&gt; For sensitive data it's the only
option, and a small local stack hits production-grade numbers in 2026.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Want the whole thing done for you?
&lt;/h2&gt;

&lt;p&gt;I packaged the full pipeline — code, the eval suite, 13 input formats, metadata&lt;br&gt;
filters, a CLI and a Streamlit UI, 60+ tests, docs — as a one-time download so&lt;br&gt;
you can skip the weeks of tuning: &lt;a href="https://buy.polar.sh/polar_cl_XV4ksHBnFjkEGMnKLzFc2HFB16agYFEORQ0Ov3oo7HK" rel="noopener noreferrer"&gt;https://buy.polar.sh/polar_cl_XV4ksHBnFjkEGMnKLzFc2HFB16agYFEORQ0Ov3oo7HK&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Either way, happy to answer questions about the stack or the eval methodology in&lt;br&gt;
the comments.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>rag</category>
      <category>python</category>
      <category>machinelearning</category>
    </item>
  </channel>
</rss>
