Skip to content

docs(examples): add heterogeneous financial document RAG evaluation example with threshold_overrides#2790

Draft
Ruthwik-Data wants to merge 8 commits into
confident-ai:mainfrom
Ruthwik-Data:docs/heterogeneous-rag-eval-example
Draft

docs(examples): add heterogeneous financial document RAG evaluation example with threshold_overrides#2790
Ruthwik-Data wants to merge 8 commits into
confident-ai:mainfrom
Ruthwik-Data:docs/heterogeneous-rag-eval-example

Conversation

@Ruthwik-Data

Copy link
Copy Markdown
Contributor

Summary

Adds examples/rag_evaluation/heterogeneous_document_eval.py — a runnable example demonstrating how to evaluate a financial RAG pipeline that retrieves chunks from mixed document types (balance sheets, 10-K narratives, earnings call transcripts) using document-type-specific thresholds.

Relates to #2775 and complements PR #2785 (threshold_overrides implementation).

Why this example is needed

Issue #2775 raised a real gap: the existing examples/rag_evaluation/ directory has no example covering heterogeneous corpora. A single global threshold causes systematic false failures or false passes when evaluating mixed document types:

  • Balance sheets (structured, numeric): threshold 0.95 — hallucinated figures are dangerous
  • 10-K narratives (dense text): threshold 0.80 — some paraphrase acceptable
  • Earnings calls (hedged, forward-looking): threshold 0.70 — hedged language should not fail faithfulness

This example shows users exactly how to use additional_metadata["document_type"] today (readable pattern), with commented-out threshold_overrides lines that will activate once PR #2785 is merged.

What this PR adds

examples/rag_evaluation/heterogeneous_document_eval.py

Sections:

  1. THRESHOLD_OVERRIDES — dict mapping document types to thresholds (balance_sheet: 0.95, annual_report: 0.80, earnings_call: 0.70)
  2. build_test_cases() — three LLMTestCase instances with document_type metadata for each document type
  3. build_metrics()FaithfulnessMetric, ContextualPrecisionMetric, ContextualRecallMetric with commented threshold_overrides lines (forward-compatible with PR feat(metrics): add document-type threshold overrides for heterogeneous RAG evaluation #2785)
  4. run_heterogeneous_eval() — runs evaluate() and prints per-document-type scores with expected thresholds

Design notes

Type of change

  • Documentation (non-breaking addition or improvement to examples/docs)

…xample with threshold_overrides

This script evaluates a financial RAG pipeline using document-type-specific thresholds for various document types, including balance sheets and earnings calls. It implements metrics for faithfulness, precision, and recall, and demonstrates how to handle different thresholds based on document type.
@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

@Ruthwik-Data is attempting to deploy a commit to the Confident AI Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant