AI platform project 03

A RAG change is a release.

Chunk size, k, a similarity floor or a new embedding model can each quietly break answers. This project treats every one of them as a release candidate that has to pass an evaluation gate.

pgvectorLangChainMLflowBedrock KBAzure AI Search

Pipeline and gate

Select a stage to see what happens there and which file implements it.

Real evaluation results

All three views use the committed results in results/. The top two are real runs; the third is a hands-on drill on the same metrics.

Where should the abstention floor sit?

Real sweep from python -m evaluation.sweep: the tuned config re-evaluated at 11 floors. Below the floor the pipeline says “I can't answer that”. Dashed lines are the gate thresholds.

00.250.50.7510.000.020.040.060.080.100.120.140.160.180.20min_score floor
answer accuracyabstention accuracyfalse abstention rategate passes
Answer accuracy0.96
Abstains correctly0.25
Wrongly declines0.00
Release blocked.
  • abstention_accuracy 0.25 < 1

Only 0.10 to 0.14 pass. That window rests on 4 unanswerable questions, and the sweep ran on the same golden set the gate uses. Treat it as a hint, then confirm on held-out questions.

Four candidate configs through the gate

Committed results from python -m evaluation.run, run in this order. A pass registers a new MLflow model version and moves the champion alias.

00.51baselinepass → v1candidate-badblockedcandidate-looseblockedcandidate-tunedpass → v2
hit rateanswer accuracyabstention accuracyfalse abstention rateblack tick = threshold · outlined = breach
Also apply the no-regression rule against a champion:
configverdict
baseline90-word chunks, k=4, floor 0.12pass
candidate-badwhole docs, k=1, no floor, superseded docs onblockedhit_rate 0.84 < 0.9; mrr 0.84 < 0.85 (+2)
candidate-loose60-word chunks, floor 0.08blockedabstention_accuracy 0.50 < 1
candidate-tuned60-word chunks, floor 0.10pass

With v2 as champion, re-submitting the old baseline is blocked. Its answer accuracy is 0.08 lower, past the 0.05 tolerance, even though it clears every threshold.

Score a retrieval by hand

Question: “When does the deployment change freeze start?” Only deploy-process is relevant. Reorder the results and change k to see each metric move.

  1. 1
    deploy-process-2024superseded Jenkins runbook: freeze Thursday 17:00
  2. 2
    deploy-processcurrent: freeze Friday 15:00 UTC
  3. 3
    incident-severitymentions SEV1/SEV2, not the freeze · outside top-k
  4. 4
    oncall-policyrotation changes Monday 10:00 · outside top-k
hit@k1
reciprocal rank0.50
context precision0.50

The stale runbook ranks first. An extractive or LLM answer will likely say Thursday 17:00. That is exactly how candidate-bad failed. A status filter removes it before ranking.

Test me

RAG and the eval gate8 questions

Concept checks, scenario calls and numbers from the real runs. Answer, then read why. Wrong answers can be retried at the end.

Run it yourself

Free: pytest -q (17 tests), then python -m evaluation.run --config configs/candidate-bad.yaml to watch the gate block it. mlflow ui shows the runs and registry. docker compose adds pgvector and an MLflow server. Optional Terraform creates a Bedrock Knowledge Base on Aurora pgvector and an Azure AI Search service. It is validated but has not been applied.