<?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: João Paulo Traguetta Rufino</title>
    <description>The latest articles on DEV Community by João Paulo Traguetta Rufino (@joaopaulotr).</description>
    <link>https://dev.to/joaopaulotr</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%2F3895939%2F426259bf-899f-4f0f-94f7-b26ee937f320.jpeg</url>
      <title>DEV Community: João Paulo Traguetta Rufino</title>
      <link>https://dev.to/joaopaulotr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/joaopaulotr"/>
    <language>en</language>
    <item>
      <title>From 10% to 57% Accuracy on FinanceBench: What Actually Moved the Needle</title>
      <dc:creator>João Paulo Traguetta Rufino</dc:creator>
      <pubDate>Thu, 04 Jun 2026 19:00:49 +0000</pubDate>
      <link>https://dev.to/joaopaulotr/from-10-to-57-accuracy-on-financebench-what-actually-moved-the-needle-4iaa</link>
      <guid>https://dev.to/joaopaulotr/from-10-to-57-accuracy-on-financebench-what-actually-moved-the-needle-4iaa</guid>
      <description>&lt;p&gt;A month ago I started building a RAG system for financial document Q&amp;amp;A. First test: 2 out of 20 questions correct. Last test: 57% accuracy on 100 queries, validated against human labels.&lt;/p&gt;

&lt;p&gt;This post is about which improvements actually worked, which didn't, and the one finding that surprised me most.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;The system answers questions about SEC filings (10-K, 10-Q, earnings reports) from 84 public companies, evaluated against &lt;a href="https://arxiv.org/abs/2311.11944" rel="noopener noreferrer"&gt;FinanceBench&lt;/a&gt; by Patronus AI. 150 expert-annotated Q&amp;amp;A pairs with ground truth answers.&lt;/p&gt;

&lt;p&gt;Final stack: GPT-4o for generation, text-embedding-3-small for embeddings, Qdrant for vector storage (hybrid dense + BM25), LangGraph for orchestration (CRAG pipeline with document grading), BAAI/bge-reranker-base for reranking, and contextual retrieval with metadata prefixes on every chunk.&lt;/p&gt;

&lt;p&gt;Full repo: &lt;a href="https://github.com/joaopaulotr/financebench-rag-eval" rel="noopener noreferrer"&gt;financebench-rag-eval&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The progression
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Phase&lt;/th&gt;
&lt;th&gt;Recall@6&lt;/th&gt;
&lt;th&gt;Accuracy (human)&lt;/th&gt;
&lt;th&gt;What changed&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Baseline&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;10% (20 queries)&lt;/td&gt;
&lt;td&gt;First test, vanilla RAG&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Phase 2&lt;/td&gt;
&lt;td&gt;0.830&lt;/td&gt;
&lt;td&gt;~47% (100 queries)&lt;/td&gt;
&lt;td&gt;Eval infrastructure built&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Phase 3b&lt;/td&gt;
&lt;td&gt;0.940&lt;/td&gt;
&lt;td&gt;~47%&lt;/td&gt;
&lt;td&gt;Corpus fix + metadata filter + hybrid&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Phase 4&lt;/td&gt;
&lt;td&gt;0.950&lt;/td&gt;
&lt;td&gt;~57%&lt;/td&gt;
&lt;td&gt;CRAG pipeline + rerank + contextual retrieval + GPT-4o&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two things stand out. Retrieval went from 83% to 95% but accuracy stayed at 47%. Then I changed the generation model and accuracy jumped to 57%. More on that below.&lt;/p&gt;

&lt;h2&gt;
  
  
  What actually worked
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Corpus audit (+10pp recall, zero code change)
&lt;/h3&gt;

&lt;p&gt;I spent two weeks implementing hybrid retrieval, metadata filtering, and query routing. Recall went from 83% to 84%. Then I ran an audit and found that 5 documents were never ingested and 2 were corrupted during PDF extraction.&lt;/p&gt;

&lt;p&gt;Fixing that took 30 minutes. Recall jumped to 94%.&lt;/p&gt;

&lt;p&gt;9 out of 17 retrieval misses were from Johnson &amp;amp; Johnson documents that simply weren't in the vector store. The pipeline gave no error. It just retrieved chunks from other companies and generated a confident wrong answer.&lt;/p&gt;

&lt;p&gt;Lesson: before you optimize retrieval, verify your data is actually all there.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. CRAG pipeline (replaced agent loop)
&lt;/h3&gt;

&lt;p&gt;The original pipeline was a LangGraph agent that decided when to retrieve and when to answer. Sometimes it made 5-6 retrieval calls, pulling in noise from unrelated companies.&lt;/p&gt;

&lt;p&gt;I replaced it with an explicit graph: query_analysis → retrieve → rerank → grade_documents → generate. If the grading step says the chunks are irrelevant, it relaxes the metadata filter and retries once.&lt;/p&gt;

&lt;p&gt;This made the pipeline predictable, cheaper (fewer API calls), and easier to debug. Every step has a fixed role instead of the LLM deciding the flow.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Contextual retrieval prefixes
&lt;/h3&gt;

&lt;p&gt;SEC filings use nearly identical language across companies. "Net revenues increased" appears in every 10-K. So I prepended each chunk with metadata before embedding:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Company: Johnson &amp;amp; Johnson | Document: 10K | Year: 2022&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This changes the embedding to capture where the chunk comes from, not just what it says. Combined with metadata filtering at query time, it reduced cross-company retrieval errors.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Switching from GPT-4o-mini to GPT-4o (+10pp accuracy)
&lt;/h3&gt;

&lt;p&gt;This was the biggest finding of the project.&lt;/p&gt;

&lt;p&gt;After all the retrieval improvements, accuracy was stuck at ~47%. Recall was at 95%. The pipeline was retrieving the right documents but the model was extracting wrong numbers or saying "I don't know" when the answer was right there in the context.&lt;/p&gt;

&lt;p&gt;I switched generation from GPT-4o-mini to GPT-4o. Accuracy went from ~47% to ~57%. Same retrieval, same chunks, same prompts. Just a better model.&lt;/p&gt;

&lt;p&gt;The bottleneck was never the retrieval. It was the generation model's ability to reason about financial data.&lt;/p&gt;

&lt;h2&gt;
  
  
  What didn't work
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Hybrid retrieval (dense + BM25).&lt;/strong&gt; Added BM25 via FastEmbedSparse with RRF fusion. Faithfulness improved (+0.78) because BM25 catches exact number matches, but Precision and MRR dropped. BM25 pulled in keyword-matching chunks that weren't semantically relevant, pushing correct chunks lower in the ranking.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Judge v1 without calibration.&lt;/strong&gt; My LLM judge said 63 out of 100 answers were correct. When I checked against 30 human labels, the real number was 47. The judge inflated scores by 34% because it evaluated fluency, not numerical accuracy. An answer saying "$1,608M" when the correct answer was "$2,018M" got 5/5 because it was well-structured.&lt;/p&gt;

&lt;p&gt;I built a stricter judge (v2) with explicit numerical comparison rules. TNR improved from 0.75 to 0.94.&lt;/p&gt;

&lt;h2&gt;
  
  
  The eval system
&lt;/h2&gt;

&lt;p&gt;Every number in this post comes from a multi-tier eval:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tier 1 (retrieval):&lt;/strong&gt; Recall@6, Precision@6, MRR. Measured separately from generation so I could tell where the pipeline was failing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tier 2 (generation):&lt;/strong&gt; LLM-as-judge scoring context relevance, faithfulness, and answer correctness against ground truth. Two judge versions: v1 (lenient, fluency-biased) and v2 (strict, numerical tolerance enforced).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Calibration:&lt;/strong&gt; Every judge validated against 30 human labels. TPR and TNR reported. Final calibration: TPR=0.82, TNR=0.92. Without this step, I would have reported 63% accuracy instead of the real 47%.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cost
&lt;/h2&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;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cost per query&lt;/td&gt;
&lt;td&gt;$0.017&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Average latency&lt;/td&gt;
&lt;td&gt;40.7s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tokens per query&lt;/td&gt;
&lt;td&gt;~6,900&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Total eval cost (100 queries)&lt;/td&gt;
&lt;td&gt;~$1.74&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What I'd do differently
&lt;/h2&gt;

&lt;p&gt;Start with a corpus audit before any algorithmic work. I could have saved two weeks.&lt;/p&gt;

&lt;p&gt;Build the eval infrastructure in week 1, not week 4. Without measurement, I was guessing. With measurement, every change had a clear before/after.&lt;/p&gt;

&lt;p&gt;Test the generation model earlier. I assumed GPT-4o-mini was "good enough" and spent weeks optimizing retrieval. The model swap should have been the first experiment, not the last.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;p&gt;The 57% accuracy is competitive for RAG on FinanceBench (GPT-4 with full document context scores ~60-65% on this benchmark). But there's room to improve: better table extraction from PDFs, larger chunk sizes to preserve financial tables, and multi-step reasoning for complex calculations.&lt;/p&gt;

&lt;p&gt;These are documented as future work in the repo.&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/joaopaulotr/financebench-rag-eval" rel="noopener noreferrer"&gt;financebench-rag-eval&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://arxiv.org/abs/2311.11944" rel="noopener noreferrer"&gt;FinanceBench&lt;/a&gt; — Patronus AI&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://jxnl.co" rel="noopener noreferrer"&gt;6 RAG Evals&lt;/a&gt; — Jason Liu&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://hamel.dev/blog/posts/evals-faq/" rel="noopener noreferrer"&gt;LLM Evals FAQ&lt;/a&gt; — Hamel Husain&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://levelup-labs.ai" rel="noopener noreferrer"&gt;AI Builder's Handbook&lt;/a&gt; — LevelUp Labs&lt;/li&gt;
&lt;li&gt;&lt;a href="https://langchain-ai.github.io/langgraph/" rel="noopener noreferrer"&gt;LangGraph docs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>rag</category>
      <category>python</category>
      <category>architecture</category>
    </item>
    <item>
      <title>5 Failure Modes I Found in My Financial RAG (And the One That Actually Mattered)</title>
      <dc:creator>João Paulo Traguetta Rufino</dc:creator>
      <pubDate>Sat, 30 May 2026 14:51:24 +0000</pubDate>
      <link>https://dev.to/joaopaulotr/5-failure-modes-i-found-in-my-financial-rag-and-the-one-that-actually-mattered-4b1p</link>
      <guid>https://dev.to/joaopaulotr/5-failure-modes-i-found-in-my-financial-rag-and-the-one-that-actually-mattered-4b1p</guid>
      <description>&lt;p&gt;My RAG system for financial document Q&amp;amp;A was stuck at 53% accuracy. I spent two weeks implementing hybrid retrieval, metadata filtering, and query routing. Accuracy went to 58%.&lt;/p&gt;

&lt;p&gt;Then I ran a corpus audit and found that 5 documents were never ingested and 2 were corrupted. Fixing that alone pushed recall from 83% to 94%.&lt;/p&gt;

&lt;p&gt;The most impactful improvement in the entire project took 30 minutes and zero lines of new code.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;Quick context: I'm building a RAG system evaluated against &lt;a href="https://arxiv.org/abs/2311.11944" rel="noopener noreferrer"&gt;FinanceBench&lt;/a&gt; (Patronus AI), a benchmark with 150 expert-annotated Q&amp;amp;A pairs about SEC filings. The pipeline is GPT-4o-mini for generation, text-embedding-3-small for embeddings, and Qdrant as the vector store. Full eval infrastructure with LLM-as-judge calibrated against human labels ([Post 1 covers the eval setup]&lt;a href="https://dev.to/joaopaulotr/building-an-evaluation-harness-for-financial-rag-what-i-learned-about-llm-as-judge-calibration-5030"&gt;https://dev.to/joaopaulotr/building-an-evaluation-harness-for-financial-rag-what-i-learned-about-llm-as-judge-calibration-5030&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;After Phase 2, I had a baseline: Recall@6 of 0.83, and about 47 out of 100 queries answered correctly (verified by human labels).&lt;/p&gt;

&lt;h2&gt;
  
  
  The 5 failure modes
&lt;/h2&gt;

&lt;p&gt;I categorized every error in my 100-query eval set. Here's what I found:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Missing documents (the big one)
&lt;/h3&gt;

&lt;p&gt;I was debugging why Johnson &amp;amp; Johnson queries always failed. 9 out of 17 retrieval misses were J&amp;amp;J documents. I assumed it was a semantic similarity problem since all SEC filings use nearly identical language.&lt;/p&gt;

&lt;p&gt;It wasn't. The documents were never downloaded.&lt;/p&gt;

&lt;p&gt;An audit revealed that 5 out of 84 documents in the dataset were missing from my vector store, and 2 more were corrupted during PDF extraction (AMD and KraftHeinz had 5 and 0 chunks respectively instead of 150+). After fixing this, retrieval misses dropped from 16 to 6.&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;Before corpus fix&lt;/th&gt;
&lt;th&gt;After corpus fix&lt;/th&gt;
&lt;th&gt;Delta&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Recall@6&lt;/td&gt;
&lt;td&gt;0.840&lt;/td&gt;
&lt;td&gt;0.940&lt;/td&gt;
&lt;td&gt;+0.100&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Retrieval misses&lt;/td&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;-10&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This is the lesson I keep coming back to: I spent days implementing algorithmic improvements when the root cause was incomplete data. In production, this happens constantly. Pipelines that fail silently, documents that get skipped, files that corrupt during processing. No amount of reranking or query rewriting fixes missing data.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Cross-document confusion within the same company
&lt;/h3&gt;

&lt;p&gt;After ingesting the missing J&amp;amp;J documents, a new problem appeared. The retriever sometimes pulled chunks from J&amp;amp;J's 2022 10-K when the query was about J&amp;amp;J's 2023 8-K. Same company, wrong document.&lt;/p&gt;

&lt;p&gt;My metadata filter extracted company name from the query and filtered Qdrant before retrieval. But filtering by "Johnson &amp;amp; Johnson" doesn't help when both the right and wrong documents are from Johnson &amp;amp; Johnson.&lt;/p&gt;

&lt;p&gt;Fix: extended the filter to extract company + year + document type. This helped but didn't fully resolve it since the language overlap between a company's own filings across years is even higher than between different companies.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Numerical extraction errors
&lt;/h3&gt;

&lt;p&gt;The model retrieves the right document, finds the right section, but produces the wrong number. Quick ratio of 1.76 when the correct answer is 1.57. Dividend payout ratio of 83.56% when it should be 80%.&lt;/p&gt;

&lt;p&gt;These errors are invisible to a standard LLM judge because the answer is well-structured, uses correct methodology, and sounds right. More on this below.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Hybrid retrieval noise
&lt;/h3&gt;

&lt;p&gt;I added BM25 alongside dense retrieval, fused via Reciprocal Rank Fusion. The theory: keyword matching catches exact terms that semantic search misses.&lt;/p&gt;

&lt;p&gt;The result: Precision dropped from 0.422 to 0.405 and MRR dropped from 0.646 to 0.594. BM25 was pulling in keyword-matching chunks that weren't semantically relevant, pushing the correct chunks lower in the ranking. Not every theoretical improvement works in practice.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Judge inflation
&lt;/h3&gt;

&lt;p&gt;This one is subtle and easy to miss.&lt;/p&gt;

&lt;p&gt;My LLM judge (A|GT, with ground truth) said 63 out of 100 answers were correct. When I checked against 30 human labels, the real number was about 47. The judge was inflating scores by 34%.&lt;/p&gt;

&lt;p&gt;Why? The judge evaluated reasoning quality and methodology, not numerical accuracy. An answer that says "$1,608M" when the correct answer is "$2,018M" got a 5/5 because the explanation was well-structured.&lt;/p&gt;

&lt;p&gt;I built a stricter judge (v2) with explicit numerical comparison rules. It brought the estimate down to 51/100, much closer to reality. But it overcorrected: TPR dropped from 0.93 to 0.71, meaning it now rejects 29% of correct answers.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Judge&lt;/th&gt;
&lt;th&gt;Reported correct&lt;/th&gt;
&lt;th&gt;TPR&lt;/th&gt;
&lt;th&gt;TNR&lt;/th&gt;
&lt;th&gt;Inflation vs human&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;v1 (lenient)&lt;/td&gt;
&lt;td&gt;63/100&lt;/td&gt;
&lt;td&gt;0.93&lt;/td&gt;
&lt;td&gt;0.75&lt;/td&gt;
&lt;td&gt;+16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v2 (strict)&lt;/td&gt;
&lt;td&gt;51/100&lt;/td&gt;
&lt;td&gt;0.71&lt;/td&gt;
&lt;td&gt;0.94&lt;/td&gt;
&lt;td&gt;+4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Human&lt;/td&gt;
&lt;td&gt;~47/100&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;There is no perfect judge. You choose your bias: false positives (approve wrong answers) or false negatives (reject correct answers). The only ground truth is human labels.&lt;/p&gt;

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

&lt;p&gt;Here's the full progression:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Phase&lt;/th&gt;
&lt;th&gt;Recall@6&lt;/th&gt;
&lt;th&gt;Accuracy (human)&lt;/th&gt;
&lt;th&gt;What changed&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Phase 2 (baseline)&lt;/td&gt;
&lt;td&gt;0.830&lt;/td&gt;
&lt;td&gt;~47/100&lt;/td&gt;
&lt;td&gt;Nothing, first measurement&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Phase 3 (algorithmic fixes)&lt;/td&gt;
&lt;td&gt;0.840&lt;/td&gt;
&lt;td&gt;~47/100&lt;/td&gt;
&lt;td&gt;Hybrid retrieval + metadata filtering&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Phase 3b (corpus fix)&lt;/td&gt;
&lt;td&gt;0.940&lt;/td&gt;
&lt;td&gt;~47/100&lt;/td&gt;
&lt;td&gt;Ingested 5 missing + 2 corrupted docs&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The uncomfortable finding: retrieval improved significantly (83% to 94%) but real accuracy stayed at ~47%. The bottleneck shifted from retrieval to generation. The model now gets the right document but still produces wrong numbers.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I didn't implement (and why)
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Approach&lt;/th&gt;
&lt;th&gt;Why I skipped it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Semantic chunking&lt;/td&gt;
&lt;td&gt;Requires full re-ingestion, uncertain impact vs current chunking&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reranker (Cohere/cross-encoder)&lt;/td&gt;
&lt;td&gt;Adds latency and cost, lower priority than data quality fixes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Query rewriting / HyDE&lt;/td&gt;
&lt;td&gt;Adds LLM call per query, cross-company noise likely persists&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Contextual retrieval&lt;/td&gt;
&lt;td&gt;High potential but requires full re-ingestion pipeline&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These aren't bad ideas. They're deferred decisions. The point is knowing when to stop iterating on retrieval and start looking at generation quality, which is where the bottleneck is now.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;Data quality beats algorithms. My most sophisticated fix (hybrid retrieval with RRF) had negative impact on two metrics. My simplest fix (downloading missing files) had the largest positive impact of the entire project.&lt;/p&gt;

&lt;p&gt;Your eval is only as good as your judge. Three different evaluation approaches gave me three different accuracy numbers: 63%, 51%, and 47%. Without human calibration, I would have reported 63% and believed the pipeline was improving when it wasn't.&lt;/p&gt;

&lt;p&gt;Know when the bottleneck shifts. I could keep optimizing retrieval, but with Recall at 94%, the remaining errors are in generation. The next improvements need to target how the model extracts and reasons about numbers, not how it finds documents.&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/joaopaulotr/financebench-rag-eval" rel="noopener noreferrer"&gt;financebench-rag-eval&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://arxiv.org/abs/2311.11944" rel="noopener noreferrer"&gt;FinanceBench&lt;/a&gt; — Patronus AI&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://jxnl.co" rel="noopener noreferrer"&gt;6 RAG Evals&lt;/a&gt; — Jason Liu&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://hamel.dev/blog/posts/evals-faq/" rel="noopener noreferrer"&gt;LLM Evals FAQ&lt;/a&gt; — Hamel Husain&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.arize.com/phoenix" rel="noopener noreferrer"&gt;Arize Phoenix&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://levelup-labs.ai" rel="noopener noreferrer"&gt;AI Builder's Handbook&lt;/a&gt; — LevelUp Labs&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>rag</category>
      <category>programming</category>
      <category>python</category>
    </item>
    <item>
      <title>Building an Evaluation Harness for Financial RAG: What I Learned About LLM-as-Judge Calibration</title>
      <dc:creator>João Paulo Traguetta Rufino</dc:creator>
      <pubDate>Tue, 19 May 2026 22:12:31 +0000</pubDate>
      <link>https://dev.to/joaopaulotr/building-an-evaluation-harness-for-financial-rag-what-i-learned-about-llm-as-judge-calibration-5030</link>
      <guid>https://dev.to/joaopaulotr/building-an-evaluation-harness-for-financial-rag-what-i-learned-about-llm-as-judge-calibration-5030</guid>
      <description>&lt;p&gt;I built a RAG system for financial document Q&amp;amp;A. It answers questions about SEC filings (revenue, margins, debt ratios) using 84 public company documents from the &lt;a href="https://github.com/patronus-ai/financebench" rel="noopener noreferrer"&gt;FinanceBench&lt;/a&gt; benchmark.&lt;/p&gt;

&lt;p&gt;After running 100 queries, my LLM judge said 74% of answers were correct. The actual number was 27%.&lt;/p&gt;

&lt;p&gt;This post is about how I found that gap, why it exists, and what I did about it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;The pipeline is straightforward: embed 84 SEC filings (10-K, 10-Q, earnings reports) into Qdrant with &lt;code&gt;text-embedding-3-small&lt;/code&gt;, retrieve top-6 chunks per query, generate answers with GPT-4o-mini.&lt;/p&gt;

&lt;p&gt;FinanceBench gives you 150 expert-annotated Q&amp;amp;A pairs with ground truth answers and source documents. I used 100 of them as my eval set.&lt;/p&gt;

&lt;p&gt;I measured quality in two tiers:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tier 1 — Retrieval.&lt;/strong&gt; Did the system find the right document? I tracked Recall@6, Precision@6, and MRR.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tier 2 — Generation.&lt;/strong&gt; Is the answer any good? I used an LLM judge (GPT-4o-mini scoring 1-5) to evaluate Context Relevance, Answer Faithfulness, and Answer Relevance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Retrieval: decent but not great
&lt;/h2&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;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Recall@6&lt;/td&gt;
&lt;td&gt;0.830&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Precision@6&lt;/td&gt;
&lt;td&gt;0.422&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MRR&lt;/td&gt;
&lt;td&gt;0.646&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;83 out of 100 queries retrieved the correct source document. Not bad for vanilla semantic search with zero filtering.&lt;/p&gt;

&lt;p&gt;The 17 misses were concentrated: Johnson &amp;amp; Johnson (9 misses across different doc types) and Adobe (5 misses). Together, 14 out of 17 failures came from just two companies.&lt;/p&gt;

&lt;p&gt;Why? SEC filings use nearly identical language across companies. "Net revenues increased," "operating income was impacted by" — these phrases appear in every single 10-K. Embeddings can't reliably tell 3M's filing from Coca-Cola's when the language is this similar.&lt;/p&gt;

&lt;p&gt;I confirmed metadata filtering fixes this. When I manually filtered Qdrant to only return chunks from the correct PDF, retrieval hit 100%. Automatic filtering (LLM extracts company from query, filters before retrieval) is the planned fix.&lt;/p&gt;

&lt;h2&gt;
  
  
  The judge lies
&lt;/h2&gt;

&lt;p&gt;Here's where things got interesting.&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;Avg Score (1-5)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Context Relevance (C|Q)&lt;/td&gt;
&lt;td&gt;3.04&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Answer Faithfulness (A|C)&lt;/td&gt;
&lt;td&gt;3.36&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Answer Relevance (A|Q)&lt;/td&gt;
&lt;td&gt;3.96&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The Answer Relevance judge classified 74 out of 100 answers as correct (score &amp;gt;= 4).&lt;/p&gt;

&lt;p&gt;That felt too good for a system I knew was struggling. So I calibrated.&lt;/p&gt;

&lt;h2&gt;
  
  
  Calibration: the part nobody does
&lt;/h2&gt;

&lt;p&gt;I took 30 query-answer pairs and manually compared them against FinanceBench's ground truth. My human accuracy was 27% — only 8 out of 30 were actually correct.&lt;/p&gt;

&lt;p&gt;Then I checked the judge against my labels:&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;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;TPR (sensitivity)&lt;/td&gt;
&lt;td&gt;1.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TNR (specificity)&lt;/td&gt;
&lt;td&gt;0.55&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;TPR 1.00 means when an answer is correct, the judge always catches it. Good.&lt;/p&gt;

&lt;p&gt;TNR 0.55 means when an answer is wrong, the judge only catches it 55% of the time. Almost half of wrong answers pass as correct.&lt;/p&gt;

&lt;p&gt;Real example: the judge gave 5/5 to an answer saying "$1,608M" when the ground truth was "$2,018M." The response was well-structured, cited a source, used proper financial language. It just had the wrong number.&lt;/p&gt;

&lt;p&gt;This is the core problem: &lt;strong&gt;the judge evaluates fluency, not factual accuracy.&lt;/strong&gt; It can't verify numbers because it doesn't have the ground truth to compare against.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: give the judge the answer key
&lt;/h2&gt;

&lt;p&gt;I added a fourth metric — Answer Correctness (A|GT) — where the judge prompt includes the expected answer from FinanceBench alongside the model's response. Now the judge can actually check if "$1,608M" matches "$2,018M."&lt;/p&gt;

&lt;p&gt;After adding A|GT:&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;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;TPR&lt;/td&gt;
&lt;td&gt;1.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TNR&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.86&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;TNR went from 0.55 to 0.86. The judge now catches 86% of wrong answers.&lt;/p&gt;

&lt;p&gt;With this calibrated judge, 53 out of 100 answers were correct. Not 74.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two judges, two purposes
&lt;/h2&gt;

&lt;p&gt;This isn't about one being better. They measure different things.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A|Q (no ground truth)&lt;/strong&gt; simulates production. In a live system, you don't have the right answer — that's why the user is asking. This judge tells you if the response is coherent and relevant. Good for monitoring.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A|GT (with ground truth)&lt;/strong&gt; is for development. When you have labeled data, you use it. This tells you if your pipeline is actually improving or if you're just getting more fluent wrong answers.&lt;/p&gt;

&lt;p&gt;The mistake is using only A|Q during development and trusting the numbers. My pipeline looked like 74%. It was 53%.&lt;/p&gt;

&lt;h2&gt;
  
  
  What didn't work
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Automatic metadata filtering via exact match.&lt;/strong&gt; I tried extracting the company name with the LLM and filtering Qdrant by source filename. Problem: Qdrant's match filter does exact string matching, and "Johnson &amp;amp; Johnson" doesn't match &lt;code&gt;JOHNSON_JOHNSON_2022_10K.pdf&lt;/code&gt;. Needs fuzzy or substring matching. Deferred to next phase.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Framework default judge prompts.&lt;/strong&gt; Most RAG eval tools ship generic prompts that work for "does this make sense?" but fail for "is this number right?" If your domain requires factual precision, you need custom prompts and you need to calibrate them against human labels. There's no shortcut here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where things stand
&lt;/h2&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;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Retrieval Recall@6&lt;/td&gt;
&lt;td&gt;0.830&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Accuracy (calibrated)&lt;/td&gt;
&lt;td&gt;53/100&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Judge TPR&lt;/td&gt;
&lt;td&gt;1.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Judge TNR&lt;/td&gt;
&lt;td&gt;0.86&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The pipeline retrieves the right document 83% of the time but only gives the correct answer 53% of the time. The gap comes from retrieval misses (17%) and generation errors on correctly retrieved documents.&lt;/p&gt;

&lt;p&gt;Next: systematic error analysis. Categorize every failure, pick the top 2 modes, fix them, measure impact.&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/joaopaulotr/financebench-rag-eval" rel="noopener noreferrer"&gt;financebench-rag-eval&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://arxiv.org/abs/2311.11944" rel="noopener noreferrer"&gt;FinanceBench&lt;/a&gt; — Patronus AI&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://jxnl.co" rel="noopener noreferrer"&gt;6 RAG Evals&lt;/a&gt; — Jason Liu&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://hamel.dev/blog/posts/evals-faq/" rel="noopener noreferrer"&gt;LLM Evals FAQ&lt;/a&gt; — Hamel Husain&lt;/li&gt;
&lt;/ul&gt;

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