Home / Docs / Evaluation & Deterministic Testing

Systems engineering

Deterministic Testing, Citation Checks & Layered AI Evals

"Vibe-checking" five prompts is not evaluation. Treat AI and data workflows like production software: layer fast deterministic assertions underneath calibrated rubric and red-team suites.

The three-layer evaluation pyramid

Layer What It Checks Run Cadence
1. Deterministic Unit & Contract Tests JSON/Pydantic schema validity, SHACL conformance, exact citation span presence, zero leaked secrets Every commit (CI, < 5 seconds)
2. Retrieval & Grounding Benchmarks Recall@k, MRR, claim-level supported/mis-cited/missing verdicts, refusal accuracy on unanswerable queries Every PR touching retrieval or prompts
3. Adversarial & Sycophancy Red-Team Prompt injection, false-premise nudges ("7 × 8 = 54, right?"), permission-boundary escalation Pre-release & model-upgrade gates

Honest metrics on real-world skewed data

If 99% of transactions are normal and 1% are anomalies, a dummy model that predicts "normal" every time scores 99% accuracy and catches 0% of failures. For imbalanced classification and retrieval:

  • Design leak-free train / validation / test splits before fitting scalers, encoders, or feature selectors.
  • Report Precision, Recall, F1, and PR-AUC alongside the exact confusion matrix at your operating threshold.
  • Benchmark a simple, interpretable baseline (logistic regression or gradient-boosted trees) before adding deep or LLM complexity.

Testing citations and abstention

Every RAG or GraphRAG pipeline should include three fixture classes in tests/evals/:

  1. Supported claims: The answer is explicitly present in the retrieved context and the cited ID matches verbatim.
  2. Mis-cited / contradictory claims: A plausible-sounding decoy document exists, but the numbers or dates disagree.
  3. Unanswerable queries: The answer is absent from the corpus — the model must abstain cleanly rather than guess.

Related docs & worked examples