Skip to content

Add optional semantic RAG evaluation - #25

Merged
sakshammaurya merged 1 commit into
mainfrom
feat/semantic-rag-evaluation
Nov 15, 2026
Merged

sakshammaurya merged 1 commit into
mainfrom
feat/semantic-rag-evaluation

Conversation

@sakshammaurya

Copy link
Copy Markdown
Owner

Summary

  • add an optional offline semantic judge for saved RAG evaluation reports
  • score faithfulness, answer relevance, context relevance, and unsupported claims with rubric v1.0.0
  • validate a strict JSON contract and compute pass/fail in code using a configurable threshold
  • compare semantic outcomes with existing deterministic answer/abstention results without combining them
  • record judge failures, skipped cases, latency, and provider token usage
  • add a configurable 512-token safety ceiling with explicit truncation failure
  • document model bias, self-judging, prompt injection, privacy, cost, nondeterminism, and human-calibration requirements

Engineering boundaries

  • offline evaluation only; no production endpoint or request-path changes
  • consumes an existing full RAG report so retrieval and generation are not repeated
  • no LangChain, RAGAS, DeepEval, or new runtime dependency
  • API keys come from JUDGE_API_KEY and are never written to reports
  • model scores remain separate from deterministic and retrieval metrics

Validation

  • python -m pytest tests/test_semantic_evaluation.py -q: 17 passed
  • python -m pytest -m "not integration" -q: 109 passed, 6 deselected
  • python -m ruff check app evals tests: passed
  • git diff --check: passed
  • one live Ollama qwen3:1.7b JSON-mode smoke on the security-incident case succeeded (456 prompt tokens, 365 completion tokens); this is compatibility evidence, not a quality baseline

Important limitations

  • an LLM judge is not ground truth and requires human-label calibration
  • same-model judging creates correlated self-evaluation bias
  • temperature 0 does not guarantee reproducibility across runtime/model versions
  • one aggregate context score does not identify individual noisy chunks
  • hosted judges receive the question, answer, and retrieved content
  • the local 4B uncapped smoke was stopped after five minutes; CPU judge latency is unsuitable for CI and motivated the bounded, configurable output ceiling

Not included

  • no claimed semantic-quality baseline
  • no historical artifact changes
  • no automatic CI model call
  • no production model, prompt, retrieval, or API behavior changes

@sakshammaurya
sakshammaurya merged commit 4ba3b0a into main Nov 15, 2026
2 checks passed
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