Metadata-Version: 2.5
Name: evalpen
Version: 0.0.1
Summary: LLM evaluation you can trust: compare prompts, catch hallucinations, and calibrate your LLM judge. From your coding agent, CLI, Python or CI.
Project-URL: Homepage, https://github.com/Emmrui/evalpen
Project-URL: Issues, https://github.com/Emmrui/evalpen/issues
Author: Emmanuelle Ruimy
License-Expression: MIT
License-File: LICENSE
Keywords: evaluation,hallucination,llm,llm-as-a-judge,mcp,prompt-engineering
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.10
Requires-Dist: mcp<3,>=2.0
Description-Content-Type: text/markdown

# EvalPen

**Know if your prompt change actually made things better, with a judge you've verified.**

EvalPen is a Python library for LLM evaluation, with four ways in: an MCP server and skill for your coding agent (Claude Code, Cursor, or any MCP client), a CLI, a Python API and a CI check. There's no dashboard and no account. In your agent, you ask in plain language and get a report back in the conversation.

> "Compare prompt v1 and v2 on my 50 test cases."
> "Is this answer supported by these documents?"
> "Here are 30 hand-labeled examples. Can I trust my judge?"

> ⚠️ Work in progress. Name and API may change before v0.1.

## Why

- **Prompt changes get tested by vibes.** Three examples, eyeballed. Regressions ship.
- **LLM judges get trusted blindly.** Judges have known biases (position, length) and can disagree with humans on hard cases. Most setups never check.
- **Eval frameworks take setup.** Many teams never get past it.

EvalPen makes evaluation a one-sentence ask, and every report states how reliable its judge is.

## Tools

| Tool | What it does |
| --- | --- |
| `create_eval_set` | Builds a varied test set (JSONL) from logs or a task description |
| `compare_prompts` | Pairwise comparison of two prompts: win rate, confidence interval, regressions with explanations |
| `check_faithfulness` | Splits an answer into atomic claims and checks each against the source documents |
| `calibrate_judge` | Measures judge vs. human agreement (raw agreement, Cohen's kappa, position bias) |

## Example report

```
Prompt v2 wins 34/50 (68%, 95% CI: 54–80%)
Judge: kappa = 0.78 vs. human labels (reliable)

Regressions (4):
- case_12: v2 drops the currency from the amount
- case_27: v2 answers in English to a French question
...
```

*(Illustrative format, not real results.)*

## How it works

- **Pairwise judging.** The judge picks the better of two answers against your criteria. This is more stable than absolute 1–10 scores.
- **Position-bias control.** Each pair is judged twice with A/B swapped. A flipped verdict counts as a tie and gets flagged.
- **Confidence intervals.** Win rates come with an interval, so you don't conclude from 10 examples.
- **Local first.** Test cases, runs and reports stay on your machine as JSONL and Markdown. LLM calls use your own API key.

## Try it now (v0.0.1)

v0.0.1 ships the first tool: **judge calibration**. Give it a JSONL file where each line has a human label and your LLM judge's label:

```json
{"id": "case_01", "human": "pass", "judge": "pass"}
{"id": "case_05", "human": "fail", "judge": "pass"}
```

```bash
uvx evalpen calibrate examples/judge_vs_human.jsonl
```

```
Judge calibration on 20 examples: **reliable**

- Raw agreement: 85% (95% CI 64%–95%)
- Cohen's kappa: 0.69 (substantial)
- Threshold used: kappa >= 0.6

Disagreements (3):
- case_05: human='fail', judge='pass'
...
```

Add `--fail-if-unreliable` to exit with code 1 in CI when kappa is below 0.6.

The same tool is available to your agent through the MCP server:

```bash
claude mcp add evalpen -- uvx evalpen mcp
```

## Usage (planned for v0.1)

*The commands below are the target interface. They may change.*

**In your agent (MCP + skill)**

```bash
claude mcp add evalpen -- uvx evalpen mcp
```

Then just ask: *"I changed the classification prompt. Compare it with the old one on my test cases."* The agent calls `compare_prompts`, summarizes the regressions, and can fix the prompt and re-run.

**From the terminal (CLI)**

```bash
evalpen compare prompts/v1.txt prompts/v2.txt --cases tests.jsonl
```

**From Python**

```python
from evalpen import compare, check_faithfulness

result = compare(prompt_a, prompt_b, cases="tests.jsonl", judge="claude-haiku")
claims = check_faithfulness(answer, sources=docs)
```

**In CI (block regressions before merge)**

```yaml
- run: evalpen compare main.txt pr.txt --cases tests.jsonl --fail-if-win-rate-below 0.5
```

## Architecture

```
  MCP + skill     CLI      Python API      CI
        \          |           |          /
         ──────  evalpen core library  ──────
         create_eval_set · compare_prompts
         check_faithfulness · calibrate_judge
         runner · judge · stats
            /                        \
     local files (JSONL)        LLM APIs (your key)
```

All logic lives in the core library. The CLI, MCP server, skill and CI check are thin layers on top.

## Roadmap

- [x] Core library + CLI + MCP server skeleton
- [x] `calibrate_judge` + Cohen's kappa (v0.0.1)
- [ ] `check_faithfulness`
- [ ] `compare_prompts` with position-bias control and CIs
- [ ] `create_eval_set`
- [ ] MCP server, skill, GitHub Action
- [ ] Demo dataset, GIF, tests
- [ ] v0.1 release: PyPI + MCP registry

## Background

Built by an AI engineer who shipped LLM classification and recommendation systems at scale, where every release was validated with human review plus LLM-as-a-judge. EvalPen packages that workflow so anyone can use it from their agent.

## License

MIT
