A production-grade framework for automated benchmarking, probabilistic evaluation, and continuous statistical regression testing for non-deterministic Large Language Model systems.
π Documentation: https://subasah.github.io/probabilistic-llm-eval-suite/ | π Live Sample Report β
Evaluating generative AI models is fundamentally different from evaluating classical software:
- Non-Determinism & Sampling Jitter: Even at
temperature=0, floating-point arithmetic across GPU tensor cores, dynamic batching, and mixture-of-experts (MoE) token routing cause output variance. A single-shot assertion (assert response == expected) is statistically meaningless. - The "Silent Regression" Crisis: An engineer tweaks a system prompt or model checkpoint to fix an edge case, inadvertently degrading structured JSON compliance or safety guardrails by 8% across existing workloads.
- Flaky Evaluations vs. Real Degradation: Without statistical hypothesis testing, teams cannot differentiate between expected random sampling noise and statistically significant regressions, leading to noisy CI pipelines or degraded production deployments.
- Judge Cognitive Biases: LLM-as-a-judge evaluators suffer from severe Position Bias (favoring Option A by 10β20%), Length Bias (favoring verbosity), and Self-Enhancement Bias.
ProbEval provides the mathematical foundation, execution pipeline, and CI/CD quality gates required to reliably deploy generative AI systems into production.
flowchart TD
subgraph Ingestion ["1. Benchmark Ingestion"]
TC[Standardized Benchmark Datasets]
D1[(Structured Extraction)]
D2[(RAG Faithfulness)]
D3[(Tool Calling Specs)]
D4[(Code & Reasoning)]
D1 & D2 & D3 & D4 --> TC
end
subgraph Runner ["2. Stochastic Execution Engine"]
TC --> Engine[Async Parallel Runner]
Engine -->|Repeated Sampling n=5| Samples[Probabilistic Output Distributions]
Model[LLM Provider / Realistic Simulator] <--> Samples
end
subgraph Matrix ["3. Multi-Tiered Evaluator Matrix"]
Samples --> MatrixRouter{Evaluation Tier}
MatrixRouter --> Tier1[Deterministic Tier<br/>β’ JSON Schema<br/>β’ Regex Match<br/>β’ Tool Call Verification<br/>β’ Latency SLAs]
MatrixRouter --> Tier2[Semantic Tier<br/>β’ Token F1 SQuAD<br/>β’ N-gram Cosine Similarity<br/>β’ Normalized Exact Match]
MatrixRouter --> Tier3[RAG Triad Tier<br/>β’ Context Faithfulness<br/>β’ Answer Relevance]
MatrixRouter --> Tier4[Calibrated Judge Tier<br/>β’ Anchored Rubrics<br/>β’ Bidirectional Swapped Pairwise]
end
subgraph Stats ["4. Statistical Inference Engine"]
Tier1 & Tier2 & Tier3 & Tier4 --> StatEngine[Statistical Inference Core]
StatEngine --> Boot[Bootstrap 95% Confidence Intervals]
StatEngine --> PassK[Chen et al. Unbiased Pass@k]
StatEngine --> McNemar[McNemar Paired Test on Discordant Cases]
StatEngine --> Welch[Welch t-test on Continuous Metrics]
end
subgraph Gate ["5. Continuous Regression Gating & Delivery"]
StatEngine --> RegGate[Continuous Regression Gatekeeper]
Base[(Golden Baseline Run)] -.-> RegGate
RegGate -->|Ξ < -3% and p < 0.05| Fail[π¨ Quality Gate FAILED: Block Merge]
RegGate -->|Variation within Noise Floor| Pass[β
Quality Gate PASSED]
RegGate --> Artifacts[Terminal Tables, Markdown PR Comment & HTML Dashboard]
end
ProbEval replaces naive assertions with formal statistical hypothesis testing:
Standard Gaussian assumptions (ProbEval draws
Evaluates generative multi-sample yield across
When comparing candidate prompts against a golden baseline on identical test cases, independent tests lose statistical power. ProbEval isolates discordant pairs (regressions
Pairs are evaluated across bidirectional swaps:
- Trial 1: Option A = Candidate, Option B = Baseline
- Trial 2: Option A = Baseline, Option B = Candidate
- Candidate is declared winner only if it defeats baseline in both orientations. If Option A is picked in both trials, position bias is flagged and discounted.
Clone the repository and install dependencies in editable mode:
git clone https://github.com/subasah/probabilistic-llm-eval-suite.git cd probabilistic-llm-eval-suite pip install -e ".[dev]"
ProbEval includes zero-cost, reproducible scenarios powered by its built-in realistic LLM simulator (or live OpenAI/Anthropic/Gemini APIs):
# Scenario 1: Detect subtle prompt regressions using McNemar's test make demo # or: python examples/01_prompt_regression_test.py # Scenario 2: Benchmark legacy enterprise model vs high-speed candidate model make migration # or: python examples/02_model_migration_benchmark.py # Scenario 3: Measure Pass@k across sampling temperatures (0.0 vs 0.4 vs 0.8) make passk # or: python examples/03_probabilistic_pass_at_k.py # Scenario 4: Mitigate LLM judge position bias with bidirectional swapping make bias # or: python examples/04_llm_judge_bias_mitigation.py
make test # or: pytest -v tests/
ProbEval includes a rich CLI for automated testing and CI/CD pipelines:
probeval run --benchmark structured_extraction --samples 5 --temperature 0.2
Outputs Rich terminal tables and compiles an interactive HTML dashboard at reports/eval_report.html.
probeval compare \ --benchmark structured_extraction \ --regression-factor 0.12 \ --samples 6 \ --html reports/regression_report.html
Every evaluation run compiles into a standalone, interactive HTML dashboard featuring:
- Glassmorphism dark-mode UI with Tailwind CSS
- KPI Metric Cards with Bootstrap 95% Confidence Interval error bands
- Pass@1, Pass@3, and Pass@k yield metrics
- Continuous Regression Gate table with p-values and significance verdicts
- Interactive Test Case Explorer: Click any prompt to inspect raw completions, latencies, and evaluator scores across all probabilistic trials.
(Saved automatically to reports/eval_report.html or viewable offline).
ProbEval is configured for continuous integration via GitHub Actions (.github/workflows/llm_eval_regression.yml):
- name: Run Continuous Regression Quality Gate run: | python -m probeval.cli compare \ --benchmark structured_extraction \ --regression-factor 0.05 \ --samples 6 \ --html reports/ci_regression_report.html
When a pull request triggers the regression gate, ProbEval generates a structured markdown summary:
| Metric | Baseline | Candidate | Delta (Ξ) | p-value | Significant? | Status |
|---|---|---|---|---|---|---|
overall_pass_rate |
0.960 | 0.800 | -0.160 (-16.7%) | 0.0082 | YES | π΄ FAIL |
json_schema_valid |
0.980 | 0.820 | -0.160 (-16.3%) | 0.0041 | YES | π΄ FAIL |
latency_sla |
0.973 | 0.973 | +0.000 (+0.0%) | 0.8500 | No (noise) | π’ PASS |
ProbEval's architectural design, statistical algorithms, and bias mitigation protocols adhere to and directly infer from foundational research papers in natural language processing, LLM benchmarking, and statistical inference:
- Paper: Evaluating Large Language Models Trained on Code (Chen et al., OpenAI 2021) β arXiv:2107.03374
-
Description: Introduced the HumanEval benchmark and derived the mathematically unbiased closed-form estimator for the
$\text{pass@}k$ metric across$n$ samples ($n \ge k$ ) with$c$ passing trials:$$\text{pass@}k = \mathbb{E}\left[1 - \frac{\binom{n-c}{k}}{\binom{n}{k}}\right]$$ This formulation eliminates the severe sampling variance and systematic underestimation caused by naive sampling evaluations. -
How It Inspired & Relevant to ProbEval: Implemented directly in
src/probeval/statistics/pass_at_k.py. Rather than running fragile single-shot assertions that miss intermittent probabilistic failures, ProbEval executes$n$ stochastic generations per test case and calculates closed-form unbiased Pass@1, Pass@k, and exact combinatorial sample variances.
- Paper: Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena (Zheng et al., LMSYS Org / UC Berkeley, NeurIPS 2023) β arXiv:2306.05685
- Description: Quantified and formalized systemic cognitive biases when using large language models as autonomous evaluatorsβmost prominently Position Bias (models favor candidate A over candidate B by up to 70% regardless of quality), Verbosity Bias (favoring long answers), and Self-Enhancement Bias.
- How It Inspired & Relevant to ProbEval: Implemented in
src/probeval/evaluators/llm_judge.py(PairwiseJudge). ProbEval mandates a symmetric bidirectional position swap: presenting (Candidate, Baseline) and then (Baseline, Candidate). A candidate is awarded a win only if it succeeds across both permutations. Inconsistent judgements are identified as position bias and normalized to a calibrated tie.
- Paper: A Hitchhikerβs Guide to Statistical Significance in Natural Language Processing (Dror et al., ACL 2018) β ACL Anthology P18-1139
- Description: Demonstrated that naive aggregate metric comparisons (such as raw accuracy point deltas) result in rampant Type I (false positives) and Type II (false negatives) errors in NLP benchmarks. Formalized paired non-parametric significance testing as the gold standard for evaluating paired NLP model outputs.
-
How It Inspired & Relevant to ProbEval: Implemented in
src/probeval/statistics/hypothesis_tests.pyand enforced insrc/probeval/statistics/regression_gate.py. When comparing a candidate against a golden baseline on identical test cases, ProbEval constructs a$2 \times 2$ contingency matrix of discordant pairs (Passed β Failed vs. Failed β Passed) and calculates McNemar's paired test with continuity correction (or exact binomial tests for small samples) before failing CI/CD builds.
- Paper: An Empirical Investigation of Statistical Significance in NLP (Berg-Kirkpatrick, Burkett, and Klein, EMNLP 2012) β ACL Anthology D12-1091
-
Description: Investigated significance testing and non-parametric bootstrap resampling across NLP evaluation tasks, demonstrating that empirical bootstrap resampling (
$B \ge 1,000$ ) provides faithful confidence intervals without making unrealistic Gaussian normality assumptions on bounded metrics. -
How It Inspired & Relevant to ProbEval: Implemented in
src/probeval/statistics/bootstrap.py. Every aggregated metric reported by ProbEval (Pass Rate, SQuAD F1, Faithfulness, Latency) includes empirical 95% bootstrap confidence intervals computed over$B=1,500$ Monte Carlo replicates, enabling developers to differentiate between true performance improvements and sampling noise.
- Paper: RAGAS: Automated Evaluation of Retrieval Augmented Generation (Es et al., EACL 2024) β arXiv:2305.14283
- Description: Introduced a reference-free framework for assessing Retrieval-Augmented Generation (RAG) pipelines by breaking generated text into atomic factual claims and evaluating Context Faithfulness (hallucination detection) and Answer Relevance without requiring ground truth references.
- How It Inspired & Relevant to ProbEval: Inferred in
src/probeval/evaluators/rag_triad.py. ProbEval performs sentence-level atomic claim decomposition and context overlap verification as an ultra-fast Tier 3 screening step (<10ms, $0 cost) to catch ungrounded statements and hallucinations before escalating to expensive LLM-as-a-judge evaluators.
- Paper: How Is ChatGPT's Behavior Changing over Time? (Chen, Zaharia, and Zou, Stanford & UC Berkeley, 2023) β arXiv:2307.09009
- Description: Documented significant longitudinal drift, unexpected capability regressions, and formatting shifts in production foundation model APIs over monthly vendor updates across reasoning, code synthesis, and safety guardrails.
- How It Inspired & Relevant to ProbEval: Formed the foundational motivation for ProbEval's continuous regression testing architecture in
src/probeval/statistics/regression_gate.pyand GitHub Actions workflow. Demonstrates that LLM APIs must be continuously guarded by frozen golden baselines and automated statistical gates in CI/CD, treating model checkpoints as dynamic, shifting dependencies.
Explore comprehensive guides in the docs/ directory:
- ποΈ System Architecture & Technical Design - Component lifecycle and multi-tiered evaluation flow.
- π Statistical Foundations & Mathematics - Bootstrap resampling, Pass@k derivation, Wilson intervals, and McNemar testing.
- βοΈ LLM-as-a-Judge Calibration & Bias Mitigation - Eliminating position, length, and self-enhancement biases.
- π‘οΈ Continuous Regression Testing in CI/CD - Quality gates, golden baselines, and production triage.
probabilistic-llm-eval-suite/
βββ .github/workflows/
β βββ llm_eval_regression.yml # CI workflow for regression gating
β βββ test_suite.yml # Matrix test suite across Python versions
βββ benchmarks/ # Benchmark datasets (JSONL)
β βββ structured_extraction.jsonl
β βββ rag_faithfulness.jsonl
β βββ code_and_reasoning.jsonl
β βββ tool_calling.jsonl
βββ docs/ # Architecture and technical guides
β βββ index.html # Documentation site
β βββ ARCHITECTURE.md
β βββ STATISTICAL_FOUNDATIONS.md
β βββ LLM_AS_A_JUDGE_CALIBRATION.md
β βββ CONTINUOUS_REGRESSION_TESTING.md
βββ examples/ # Runnable production scenarios
β βββ 01_prompt_regression_test.py
β βββ 02_model_migration_benchmark.py
β βββ 03_probabilistic_pass_at_k.py
β βββ 04_llm_judge_bias_mitigation.py
βββ src/probeval/ # Core package
β βββ cli.py # Typer CLI application
β βββ config.py # Pydantic schemas & data models
β βββ models/ # Model providers & simulator
β βββ evaluators/ # Deterministic, semantic, and judge evaluators
β βββ statistics/ # Bootstrap, Pass@k, McNemar, regression gate
β βββ runner/ # Async parallel execution engine
β βββ reporting/ # Console, HTML, and GitHub PR reporters
βββ tests/ # Pytest test suite (15 unit tests)
βββ Makefile # Developer command shortcuts
βββ pyproject.toml # Modern package configuration
βββ LICENSE # MIT License
Subasa
GitHub: @subasah
Repository: probabilistic-llm-eval-suite
This project is licensed under the MIT License - see the LICENSE file for details.