Skip to content

About

eval-driven ci gate for llm quality - fail the build when a prompt change regresses

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

EvalForge

Python YAML CI Gate tests license

Unit tests for your prompts. A CI gate for LLM quality.

Teams ship LLM/prompt changes and silently regress quality. EvalForge defines graded eval sets in YAML, scores your agent on every commit, and fails the build if quality drops below a threshold - turning eval-driven development into a real CI gate.

Why it matters

LLM apps have no "unit tests." A prompt tweak that helps one case can quietly break ten others. EvalForge makes quality a first-class, versioned, enforced artifact.

Quickstart

pip install -r requirements.txt
python -m evalforge.cli examples/eval_set.yaml --target examples.demo_target:target

Exit code is 0 if the aggregate score meets the threshold, non-zero otherwise - drop it straight into CI.

Define an eval set (YAML)

threshold: 0.75
cases:
  - id: refund-window
    input: "How many days do I have to request a refund?"
    scorer: contains
    expected: "30 days"
    weight: 2.0
    pass_score: 1.0

Scorers: exact_match, contains, regex, semantic (extensible - add LLM-as-judge, embedding cosine, etc.).

Point it at your agent

Any module:function that maps str -> str:

python -m evalforge.cli my_evals.yaml --target myapp.agent:answer --threshold 0.85

CI: catch regressions before merge

The included GitHub Action runs the eval gate on every PR. See tests/test_evalforge.py::test_regressed_target_fails_gate for a demonstration of a regression being caught.

Six languages, one behavior

The scorers (including a from-scratch Ratcliff/Obershelp sequence ratio matching Python's difflib), the weighted-aggregate runner, and the YAML eval-set loader — run against the same examples/eval_set.yaml — in each language. Each uses its platform's YAML library (pyyaml / YamlDotNet / SnakeYAML / gopkg.in/yaml.v3 / serde_yaml / the yaml npm package).

Two subtleties are pinned down by the ports and their tests:

  • semantic sequence ratio. difflib.SequenceMatcher(...).ratio() is reimplemented from scratch (the b2j index, the find_longest_match DP, and the recursive block sum) so every language reproduces Python's score to the fourth decimal. Autojunk is intentionally not applied — it only kicks in for 200+ element sequences, far longer than anything scored here.
  • regex inline flags. Python re, Go's RE2, and the Rust regex crate all accept a leading (?i) prefix directly. JavaScript's RegExp does not, so the TypeScript port parses a leading inline-flag group and maps i/m/s to native RegExp flags before matching.
Language Toolchain Tests Run
Python 3.15 (.python-version) 4 pytest -q
C# .NET 10 SDK (csharp/global.json) 4 cd csharp && dotnet test
Java JDK 25 + Maven 3.9 4 cd java && mvn test
Go 1.27 (go/go.mod) 36 cd go && go test ./...
Rust 1.99+, edition 2024 42 cd rust && cargo test
TypeScript Node 26 LTS (ts/.nvmrc) 45 cd ts && npm test

CI (.github/workflows/tests.yml) reads the same version files, so bumping a toolchain is a one-file change.

How it works

flowchart LR
  classDef proc fill:#eff6ff,stroke:#3b82f6,color:#1e3a8a
  classDef good fill:#f0fdf4,stroke:#22c55e,color:#14532d
  classDef bad fill:#fef2f2,stroke:#ef4444,color:#7f1d1d
  classDef work fill:#faf5ff,stroke:#a855f7,color:#581c87
  ES["Eval set"]:::proc
  RUN["Run target"]:::work
  SCORE["Score cases"]:::work
  AGG{"Meets bar?"}:::work
  PASS["Deploy"]:::good
  FAIL["Block"]:::bad
  ES --> RUN --> SCORE --> AGG
  AGG -->|yes| PASS
  AGG -->|no| FAIL
Loading

Layout

eval-forge/
├── evalforge/            the runner, CLI, and scorers (Python)
│   ├── runner.py       # loads a YAML eval set, runs each case, aggregates the score
│   ├── cli.py          # `python -m evalforge.cli` — the CI entry point (exit code = the gate)
│   └── scorers/        # exact_match, contains, regex, semantic — add your own here
├── csharp/               the same scorers + runner, ported to .NET 10 (xUnit v3 + YamlDotNet)
├── java/                 the same, in Java 25 (JUnit / Maven + SnakeYAML)
├── go/                   the same, in Go 1.27 (testing + gopkg.in/yaml.v3)
├── rust/                 the same, in Rust (cargo test + serde_yaml + regex)
├── ts/                   the same, in TypeScript (vitest + the yaml package)
├── examples/
│   ├── eval_set.yaml   # a worked example eval set (shared by every test suite)
│   └── demo_target.py  # a str -> str target to score against
├── tests/              # incl. a regression that proves the gate fails on a worse target
└── DESIGN.md           # deterministic-first scoring, the two-threshold model, the non-goals

Design notes

  • DESIGN.md - why scoring is deterministic-first, the two-threshold (per-case + weighted aggregate) design, why the gate is just an exit code, and the non-goals (it's a gate, not a scoring model or a dataset tool).

Part of parag-labs

Small, focused tools for building AI systems you can trust.

LedgerRAG · EvalForge · AgentGuard · PromptShield · DeployKit

License

MIT

About

eval-driven ci gate for llm quality - fail the build when a prompt change regresses

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages