valueproof 0.5.0__tar.gz → 0.6.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- valueproof-0.6.1/PKG-INFO +206 -0
- valueproof-0.6.1/README.md +178 -0
- {valueproof-0.5.0 → valueproof-0.6.1}/pyproject.toml +1 -1
- {valueproof-0.5.0 → valueproof-0.6.1}/src/valueproof/__init__.py +6 -3
- {valueproof-0.5.0 → valueproof-0.6.1}/src/valueproof/cli.py +33 -3
- {valueproof-0.5.0 → valueproof-0.6.1}/src/valueproof/lever_runner.py +158 -0
- valueproof-0.6.1/src/valueproof.egg-info/PKG-INFO +206 -0
- valueproof-0.6.1/tests/test_runner_cli.py +158 -0
- valueproof-0.5.0/PKG-INFO +0 -279
- valueproof-0.5.0/README.md +0 -251
- valueproof-0.5.0/src/valueproof.egg-info/PKG-INFO +0 -279
- valueproof-0.5.0/tests/test_runner_cli.py +0 -90
- {valueproof-0.5.0 → valueproof-0.6.1}/LICENSE-CODE +0 -0
- {valueproof-0.5.0 → valueproof-0.6.1}/setup.cfg +0 -0
- {valueproof-0.5.0 → valueproof-0.6.1}/src/mixed_model_cost/__init__.py +0 -0
- {valueproof-0.5.0 → valueproof-0.6.1}/src/valueproof/claude.py +0 -0
- {valueproof-0.5.0 → valueproof-0.6.1}/src/valueproof/gemini.py +0 -0
- {valueproof-0.5.0 → valueproof-0.6.1}/src/valueproof/openai.py +0 -0
- {valueproof-0.5.0 → valueproof-0.6.1}/src/valueproof/pipeline.py +0 -0
- {valueproof-0.5.0 → valueproof-0.6.1}/src/valueproof/scout_rescue.py +0 -0
- {valueproof-0.5.0 → valueproof-0.6.1}/src/valueproof/starter.py +0 -0
- {valueproof-0.5.0 → valueproof-0.6.1}/src/valueproof.egg-info/SOURCES.txt +0 -0
- {valueproof-0.5.0 → valueproof-0.6.1}/src/valueproof.egg-info/dependency_links.txt +0 -0
- {valueproof-0.5.0 → valueproof-0.6.1}/src/valueproof.egg-info/entry_points.txt +0 -0
- {valueproof-0.5.0 → valueproof-0.6.1}/src/valueproof.egg-info/requires.txt +0 -0
- {valueproof-0.5.0 → valueproof-0.6.1}/src/valueproof.egg-info/top_level.txt +0 -0
- {valueproof-0.5.0 → valueproof-0.6.1}/tests/test_adapters.py +0 -0
- {valueproof-0.5.0 → valueproof-0.6.1}/tests/test_core.py +0 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: valueproof
|
|
3
|
+
Version: 0.6.1
|
|
4
|
+
Summary: Prove an AI cost cut on your own traffic before you ship it: cheap and strong models working together (Scout & Rescue), measured by cost per outcome with a blind quality review.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/AndyJakob78/valueproof
|
|
7
|
+
Project-URL: Old package name, https://pypi.org/project/ai-mixed-model-cost-optimization/
|
|
8
|
+
Keywords: llm,llm cost,cost per outcome,model cascade,evaluation,finops,llmops
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE-CODE
|
|
15
|
+
Provides-Extra: claude
|
|
16
|
+
Requires-Dist: anthropic>=2.14; extra == "claude"
|
|
17
|
+
Provides-Extra: openai
|
|
18
|
+
Requires-Dist: openai>=3.60; extra == "openai"
|
|
19
|
+
Provides-Extra: gemini
|
|
20
|
+
Requires-Dist: google-genai>=3.6; python_version >= "3.11" and extra == "gemini"
|
|
21
|
+
Provides-Extra: all
|
|
22
|
+
Requires-Dist: anthropic>=2.14; extra == "all"
|
|
23
|
+
Requires-Dist: openai>=3.60; extra == "all"
|
|
24
|
+
Requires-Dist: google-genai>=3.6; python_version >= "3.11" and extra == "all"
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# Valueproof
|
|
30
|
+
|
|
31
|
+
**Prove an AI cost cut before you ship it. Measure cost per usable outcome, not cost per token.**
|
|
32
|
+
|
|
33
|
+
## Cheapest isn't the win
|
|
34
|
+
|
|
35
|
+
The same cheap model answered 40 support tickets twice, with two different eval checks. A frontier model stepped in whenever the check failed. Then a person compared 20 of the replies blind with the frontier model's own replies.
|
|
36
|
+
|
|
37
|
+
| | Eval check: rules in code only | Eval check: the PM's acceptance criteria, in plain language |
|
|
38
|
+
|---|---|---|
|
|
39
|
+
| **Replies as good as the frontier model's** (blind human review, 20 tickets) | ❌ **4 of 20** | ✅ **13 of 20** |
|
|
40
|
+
| **Serious mistakes that reached the customer** | 3 of 20 | 2 of 20 |
|
|
41
|
+
| **Cost vs. the frontier model alone** | 82–92% cheaper | 69–73% cheaper |
|
|
42
|
+
| **Verdict** | Biggest saving, worse outcomes: less value | **Higher value, for a somewhat smaller saving** |
|
|
43
|
+
|
|
44
|
+
Claude Haiku 5.5 answers first, Claude Opus 5.5 steps in; compared with Opus 5.5 alone. The check in plain language is one more call, so replies were 10–35% slower than Opus alone; a mid-size model as the rescuer made it as fast as Opus again (one run). **So choose the eval check first, then the model.**
|
|
45
|
+
|
|
46
|
+
Made-up tickets, one human reviewer: read it as a direction, not a rule. [Full results](#full-results)
|
|
47
|
+
|
|
48
|
+
## Two questions, two sides
|
|
49
|
+
|
|
50
|
+
If you work on an AI product, you probably get two questions:
|
|
51
|
+
|
|
52
|
+
- "What is the value of it, and how do you prove it?"
|
|
53
|
+
- "Our token cost needs to go down, but we can't sacrifice the quality of outcomes."
|
|
54
|
+
|
|
55
|
+
The two sides often work apart. Engineering and FinOps bring token cost down; product managers worry that quality gets sacrificed. When an eval fails, it goes back to engineering, who often don't know what outcome is expected.
|
|
56
|
+
|
|
57
|
+
## Acceptance criteria that run on every answer
|
|
58
|
+
|
|
59
|
+
**Today:** the PM writes acceptance criteria → engineering builds → a user acceptance test checks a sample, late → failures go back to engineering, who guess what "right" means.
|
|
60
|
+
|
|
61
|
+
**With an eval check:** the PM writes the acceptance criteria once, with the source that defines "right" → they run on every answer at runtime; an answer that fails goes to the frontier model before the user sees it → before shipping, a blind review measures how good the check is.
|
|
62
|
+
|
|
63
|
+
Each acceptance criterion becomes two kinds of check, and most tasks need both:
|
|
64
|
+
|
|
65
|
+
| Use case | Your acceptance criterion | Becomes a rule in code (free, instant) | Becomes a check in plain language (a cheap model reads the answer against the source) |
|
|
66
|
+
|---|---|---|---|
|
|
67
|
+
| A **support chatbot** answers routine tickets | "A reply applies our refund policy correctly to this ticket." | The order number is in the reply; no voucher is offered | Is the right rule applied to *this* case? From our test: it offered a carrier trace for a parcel the customer had already received. |
|
|
68
|
+
| An app **writes a match report** after every game | "The report tells the match as it happened." | Score, teams and scorers match the match data | Does it invent quotes or events? |
|
|
69
|
+
| An AI **writes product descriptions** | "It sounds like our brand." | No word from the banned list; length within limits | Calm, friendly, no exaggerated claims? |
|
|
70
|
+
| An **in-car travel guide** tells stories along the route | "Stories are true, family-friendly and safe to hear while driving." | Every place is on the route and in the database; under 60 seconds read aloud | Do the facts match the database? Does it ever ask the driver to look away from the road? |
|
|
71
|
+
|
|
72
|
+
Two things to know:
|
|
73
|
+
|
|
74
|
+
- **The check in plain language has a price:** one more call on every answer, so about twice the cost of rules in code and 10–35% slower than the frontier model alone. A mid-size rescuer, or checking only the topics the PM marks as high-risk, won the speed back in our test.
|
|
75
|
+
- **The blind review doesn't go away; its job changes.** It now tests the check. Ours found a mistake the check had missed twice. Where a wrong answer can hurt someone, such as a vehicle warning or a medical or legal answer, don't let a model write it at all: show fixed, approved text.
|
|
76
|
+
|
|
77
|
+
## What Valueproof is
|
|
78
|
+
|
|
79
|
+
A playbook and a small open-source Python package:
|
|
80
|
+
|
|
81
|
+
- **An LLM cascade.** A cheap model answers first; a frontier model steps in only when the answer fails an eval check. The technique is not new ([FrugalGPT](https://github.com/stanford-futuredata/FrugalGPT)); this repo calls it *Scout & Rescue*.
|
|
82
|
+
- **A test before you ship:** your current setup against the cheaper one, on a fixed set of your own real requests (taken from your logs), with a blind review by an LLM judge or a person.
|
|
83
|
+
- **A measure of the check itself:** what it caught, what it missed, how many false alarms, what it cost.
|
|
84
|
+
- **Cost per usable outcome,** with failed and rescued attempts counted.
|
|
85
|
+
|
|
86
|
+
## Full results
|
|
87
|
+
|
|
88
|
+
**Support replies:** 40 made-up tickets, five runs, against Claude Opus 5.5 alone.
|
|
89
|
+
|
|
90
|
+
| Setup | As good as Opus (blind human review, 20 tickets) | Serious mistakes | Quality, LLM judge | Cost per usable reply | Response time vs. Opus alone |
|
|
91
|
+
|---|---|---|---|---|---|
|
|
92
|
+
| Rules in code as the eval check | ❌ 4 of 20 | the rules caught 0 of 10 (four runs) | 2–6% lower | 82–92% cheaper | 22–35% faster |
|
|
93
|
+
| + an eval check in plain language | ✅ 13 of 20 | caught the one in its run; 2 of 20 got past it in the human review | 3.5–4.9% lower | 69–73% cheaper | 10–35% slower |
|
|
94
|
+
| + a mid-size model as the rescuer (one run) | not checked by a person | none occurred in that run | 5% lower | 87% cheaper | about as fast |
|
|
95
|
+
|
|
96
|
+
- **The LLM judge looked kinder than the person.** "2–6% lower" sounded close; a person preferred the frontier model almost every time. The judge and the person agreed on only one of the three real mistakes the person found with rules in code alone. Check the judge too.
|
|
97
|
+
- **The mistake that got past the check twice:** offering a carrier trace for a parcel that had already arrived. That is the next line for the PM to add to the check.
|
|
98
|
+
|
|
99
|
+
→ [Full support test](https://github.com/AndyJakob78/valueproof/blob/main/docs/support-test.md), with the lever ledger, check ratings and raw data.
|
|
100
|
+
|
|
101
|
+
**A live language-learning app:** the step that searches the web for a news story ran on Claude Sonnet 5.5 for every lesson, at 9.7 ¢ per article. With Haiku first and Sonnet only when a code check finds no usable or only an old story, it cost **4.6–7.7 ¢**. Quality held: an LLM judge scored 18 articles 472 vs 434 for the cheaper setup, and a person comparing 14 German article pairs blind found a tie (6 for the cheaper search, 7 for the old one, 1 equal). Here the cheap model only finds the story; a strong model still writes the lesson. → [Case study](https://github.com/AndyJakob78/valueproof/blob/main/docs/case-study.md)
|
|
102
|
+
|
|
103
|
+
**Twelve cost ideas, tested one at a time:** 7 made things worse or saved nothing. A shorter prompt made the model search *more*. → [Lessons](https://github.com/AndyJakob78/valueproof/blob/main/docs/lessons.md)
|
|
104
|
+
|
|
105
|
+
## Quick start
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
pip install "valueproof[claude]" # or [openai], [gemini], [all]
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from valueproof import scout_and_rescue
|
|
113
|
+
from valueproof.claude import claude
|
|
114
|
+
|
|
115
|
+
POLICY = open("refund_policy.md").read() # the source that defines "right"
|
|
116
|
+
ticket = "Order 48213 arrived yesterday, but the box is damaged."
|
|
117
|
+
checker = claude("claude-haiku-5-5") # a cheap model reads each reply against the policy
|
|
118
|
+
|
|
119
|
+
def check(reply):
|
|
120
|
+
if "48213" not in reply: # rule in code: free and instant
|
|
121
|
+
return "order number missing"
|
|
122
|
+
verdict = checker( # check in plain language: one more cheap call
|
|
123
|
+
f"Policy:\n{POLICY}\n\nTicket:\n{ticket}\n\nReply:\n{reply}\n\n"
|
|
124
|
+
"Does the reply apply the policy correctly to this ticket, without assuming facts "
|
|
125
|
+
"the ticket doesn't give? Answer OK, or NO and the reason."
|
|
126
|
+
).text
|
|
127
|
+
return None if verdict.strip().startswith("OK") else verdict
|
|
128
|
+
|
|
129
|
+
out = scout_and_rescue(
|
|
130
|
+
f"Reply to this support ticket, following this policy:\n{POLICY}\n\nTicket: {ticket}",
|
|
131
|
+
scout=claude("claude-haiku-5-5"), # the cheap model answers first
|
|
132
|
+
rescue=claude("claude-opus-5-5"), # the frontier model runs only if the check fails
|
|
133
|
+
check=check,
|
|
134
|
+
)
|
|
135
|
+
print(out.path, out.cost_usd) # "scout" or "rescue", and what the answers cost
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
A check returns `None` when the answer is fine, or a reason when it is not. Start with the rules in code, and add the check in plain language where a wrong answer is not acceptable. `out.cost_usd` covers the answers; the check's own cost comes on top (about 0.02 ¢ per reply in our test). The [support test example](https://github.com/AndyJakob78/valueproof/blob/main/examples/test_levers_support.py) counts it, and caches it.
|
|
139
|
+
|
|
140
|
+
## Test a change before you ship it
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
valueproof init my_test.py # a starter test that runs straight away, with fake models
|
|
144
|
+
valueproof compare my_test.py # offline, free
|
|
145
|
+
valueproof compare my_test.py --live --estimate # runs 2 requests for real and prints the projected bill
|
|
146
|
+
valueproof compare my_test.py --live --max-spend 5 # the full test; stops starting new requests at $5
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
`compare` runs every setup on every request in the same moment and prints:
|
|
150
|
+
|
|
151
|
+
- **cost per usable outcome**, average and median cost, time, and how often the frontier model ran
|
|
152
|
+
- **blind-review quality**, with hard failures counted separately so no average can hide them
|
|
153
|
+
- **check quality:** how many of the judge's hard failures each eval check caught, missed, and how many false alarms it raised
|
|
154
|
+
- **the lever ledger:** each change against the setup it changes, your estimate written down before the test, and a keep-or-drop verdict
|
|
155
|
+
|
|
156
|
+
To rate a new eval check on replies you already paid for, without running the models again: `--from-results results.json`.
|
|
157
|
+
|
|
158
|
+
**Blind review, two ways.** An LLM judge gets one answer at a time, in random order, never the setup's name. Give it the reference that defines "right"; without it, a judge can only tell whether an answer looks usable. Or review it yourself: every run writes `blind_review.csv` and a separate `blind_key.csv`.
|
|
159
|
+
|
|
160
|
+
→ How to write `my_test.py`, and a demo that runs without an API key: [examples/](https://github.com/AndyJakob78/valueproof/tree/main/examples/) · The step-by-step method: [docs/method.md](https://github.com/AndyJakob78/valueproof/blob/main/docs/method.md)
|
|
161
|
+
|
|
162
|
+
## When it fits
|
|
163
|
+
|
|
164
|
+
It fits when your product sends many requests to a frontier model, most of them routine, and you can say what a usable answer is: support replies, data extraction, document summaries, search and research assistants, code review, code migration (does it compile, do the tests pass).
|
|
165
|
+
|
|
166
|
+
Be careful where a wrong answer carries legal, money or safety risk. Measure your eval check against a blind review first, or keep that step on the frontier model until the check catches the mistakes that matter.
|
|
167
|
+
|
|
168
|
+
## How this differs from other tools
|
|
169
|
+
|
|
170
|
+
| Tool | What it does | How it relates |
|
|
171
|
+
|---|---|---|
|
|
172
|
+
| [RouteLLM](https://github.com/lm-sys/RouteLLM) | Trained routers that pick a model per request | A routing technique. Test it against your setup with `valueproof compare`. |
|
|
173
|
+
| [cascadeflow](https://github.com/lemony-ai/cascadeflow) | A cascading runtime for agents | A runtime for production. Test it here first. |
|
|
174
|
+
| [LiteLLM](https://github.com/BerriAI/litellm) | A gateway to 100+ model APIs | Infrastructure to call models. Works as the model behind a setup here. |
|
|
175
|
+
| [promptfoo](https://github.com/promptfoo/promptfoo) | Broad testing of prompts, agents and RAG | A general eval suite. This repo is narrower. |
|
|
176
|
+
|
|
177
|
+
**Cost-first, not QA-first.** Eval suites such as promptfoo and Braintrust are built around quality regression and observability, and show cost alongside. Valueproof starts from the decision a product manager or CFO has to make: cost per usable outcome, an estimate before the test, and a keep-or-drop verdict after it. Use it to get evidence on your own requests before you commit to a router or gateway.
|
|
178
|
+
|
|
179
|
+
## More
|
|
180
|
+
|
|
181
|
+
- [Why this exists](https://github.com/AndyJakob78/valueproof/blob/main/docs/why.md): who it is for, cost per outcome vs value shipped, and real-world signals from 2026
|
|
182
|
+
- [Support test](https://github.com/AndyJakob78/valueproof/blob/main/docs/support-test.md) · [Case study](https://github.com/AndyJakob78/valueproof/blob/main/docs/case-study.md) · [Game article test](https://github.com/AndyJakob78/valueproof/blob/main/docs/game-article-test.md) · [A chatbot estimate](https://github.com/AndyJakob78/valueproof/blob/main/docs/example-service-chatbot.md)
|
|
183
|
+
- [Scout & Rescue in detail](https://github.com/AndyJakob78/valueproof/blob/main/docs/scout-and-rescue.md) · [Method](https://github.com/AndyJakob78/valueproof/blob/main/docs/method.md) · [Lessons](https://github.com/AndyJakob78/valueproof/blob/main/docs/lessons.md) · [Templates](https://github.com/AndyJakob78/valueproof/tree/main/templates/)
|
|
184
|
+
|
|
185
|
+
## Install
|
|
186
|
+
|
|
187
|
+
Version 0.6, early: the API may still change. Python 3.10+ (the Gemini adapter needs 3.11+). The core has no dependencies; a model is any function `prompt -> ModelResult`, so a local model works too. Adapters come as extras: `[claude]`, `[openai]`, `[gemini]`, `[all]`.
|
|
188
|
+
|
|
189
|
+
The old package name `ai-mixed-model-cost-optimization` still installs and pulls in `valueproof`.
|
|
190
|
+
|
|
191
|
+
## Terms
|
|
192
|
+
|
|
193
|
+
- **LLM cascade / Scout & Rescue:** a cheap model (the scout) answers first; a frontier model (the rescuer) runs only when the answer fails an eval check.
|
|
194
|
+
- **Eval check:** judges one answer at runtime and decides whether the rescuer runs. A rule in code, or a cheap model asked in plain language with a reference.
|
|
195
|
+
- **Eval:** the fixed test before shipping: real requests, the eval checks, and a blind review, run the same way for every change.
|
|
196
|
+
- **Blind review:** answers scored on a fixed rubric without knowing which setup wrote them, by an LLM judge or a person.
|
|
197
|
+
- **Hard failure / serious mistake:** a wrong policy rule, a promise the policy doesn't allow, an invented fact, or no answer.
|
|
198
|
+
- **Usable outcome:** a final answer that passed the checks and had no hard failure.
|
|
199
|
+
- **Cost per usable outcome:** everything a setup spent, failed and rescued attempts included, divided by its usable outcomes.
|
|
200
|
+
- **Lever:** one change meant to lower cost, tested on its own.
|
|
201
|
+
|
|
202
|
+
## About
|
|
203
|
+
|
|
204
|
+
Built from a real cost-reduction project on a live language-learning app. Engineering, testing and blind reviews were done with an AI coding assistant (Claude); a product owner made every keep-or-drop decision and did the human blind checks.
|
|
205
|
+
|
|
206
|
+
Text: [CC BY 4.0](https://github.com/AndyJakob78/valueproof/blob/main/LICENSE). Code in [src/](https://github.com/AndyJakob78/valueproof/tree/main/src/) and [examples/](https://github.com/AndyJakob78/valueproof/tree/main/examples/): [MIT](https://github.com/AndyJakob78/valueproof/blob/main/LICENSE-CODE).
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Valueproof
|
|
2
|
+
|
|
3
|
+
**Prove an AI cost cut before you ship it. Measure cost per usable outcome, not cost per token.**
|
|
4
|
+
|
|
5
|
+
## Cheapest isn't the win
|
|
6
|
+
|
|
7
|
+
The same cheap model answered 40 support tickets twice, with two different eval checks. A frontier model stepped in whenever the check failed. Then a person compared 20 of the replies blind with the frontier model's own replies.
|
|
8
|
+
|
|
9
|
+
| | Eval check: rules in code only | Eval check: the PM's acceptance criteria, in plain language |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| **Replies as good as the frontier model's** (blind human review, 20 tickets) | ❌ **4 of 20** | ✅ **13 of 20** |
|
|
12
|
+
| **Serious mistakes that reached the customer** | 3 of 20 | 2 of 20 |
|
|
13
|
+
| **Cost vs. the frontier model alone** | 82–92% cheaper | 69–73% cheaper |
|
|
14
|
+
| **Verdict** | Biggest saving, worse outcomes: less value | **Higher value, for a somewhat smaller saving** |
|
|
15
|
+
|
|
16
|
+
Claude Haiku 5.5 answers first, Claude Opus 5.5 steps in; compared with Opus 5.5 alone. The check in plain language is one more call, so replies were 10–35% slower than Opus alone; a mid-size model as the rescuer made it as fast as Opus again (one run). **So choose the eval check first, then the model.**
|
|
17
|
+
|
|
18
|
+
Made-up tickets, one human reviewer: read it as a direction, not a rule. [Full results](#full-results)
|
|
19
|
+
|
|
20
|
+
## Two questions, two sides
|
|
21
|
+
|
|
22
|
+
If you work on an AI product, you probably get two questions:
|
|
23
|
+
|
|
24
|
+
- "What is the value of it, and how do you prove it?"
|
|
25
|
+
- "Our token cost needs to go down, but we can't sacrifice the quality of outcomes."
|
|
26
|
+
|
|
27
|
+
The two sides often work apart. Engineering and FinOps bring token cost down; product managers worry that quality gets sacrificed. When an eval fails, it goes back to engineering, who often don't know what outcome is expected.
|
|
28
|
+
|
|
29
|
+
## Acceptance criteria that run on every answer
|
|
30
|
+
|
|
31
|
+
**Today:** the PM writes acceptance criteria → engineering builds → a user acceptance test checks a sample, late → failures go back to engineering, who guess what "right" means.
|
|
32
|
+
|
|
33
|
+
**With an eval check:** the PM writes the acceptance criteria once, with the source that defines "right" → they run on every answer at runtime; an answer that fails goes to the frontier model before the user sees it → before shipping, a blind review measures how good the check is.
|
|
34
|
+
|
|
35
|
+
Each acceptance criterion becomes two kinds of check, and most tasks need both:
|
|
36
|
+
|
|
37
|
+
| Use case | Your acceptance criterion | Becomes a rule in code (free, instant) | Becomes a check in plain language (a cheap model reads the answer against the source) |
|
|
38
|
+
|---|---|---|---|
|
|
39
|
+
| A **support chatbot** answers routine tickets | "A reply applies our refund policy correctly to this ticket." | The order number is in the reply; no voucher is offered | Is the right rule applied to *this* case? From our test: it offered a carrier trace for a parcel the customer had already received. |
|
|
40
|
+
| An app **writes a match report** after every game | "The report tells the match as it happened." | Score, teams and scorers match the match data | Does it invent quotes or events? |
|
|
41
|
+
| An AI **writes product descriptions** | "It sounds like our brand." | No word from the banned list; length within limits | Calm, friendly, no exaggerated claims? |
|
|
42
|
+
| An **in-car travel guide** tells stories along the route | "Stories are true, family-friendly and safe to hear while driving." | Every place is on the route and in the database; under 60 seconds read aloud | Do the facts match the database? Does it ever ask the driver to look away from the road? |
|
|
43
|
+
|
|
44
|
+
Two things to know:
|
|
45
|
+
|
|
46
|
+
- **The check in plain language has a price:** one more call on every answer, so about twice the cost of rules in code and 10–35% slower than the frontier model alone. A mid-size rescuer, or checking only the topics the PM marks as high-risk, won the speed back in our test.
|
|
47
|
+
- **The blind review doesn't go away; its job changes.** It now tests the check. Ours found a mistake the check had missed twice. Where a wrong answer can hurt someone, such as a vehicle warning or a medical or legal answer, don't let a model write it at all: show fixed, approved text.
|
|
48
|
+
|
|
49
|
+
## What Valueproof is
|
|
50
|
+
|
|
51
|
+
A playbook and a small open-source Python package:
|
|
52
|
+
|
|
53
|
+
- **An LLM cascade.** A cheap model answers first; a frontier model steps in only when the answer fails an eval check. The technique is not new ([FrugalGPT](https://github.com/stanford-futuredata/FrugalGPT)); this repo calls it *Scout & Rescue*.
|
|
54
|
+
- **A test before you ship:** your current setup against the cheaper one, on a fixed set of your own real requests (taken from your logs), with a blind review by an LLM judge or a person.
|
|
55
|
+
- **A measure of the check itself:** what it caught, what it missed, how many false alarms, what it cost.
|
|
56
|
+
- **Cost per usable outcome,** with failed and rescued attempts counted.
|
|
57
|
+
|
|
58
|
+
## Full results
|
|
59
|
+
|
|
60
|
+
**Support replies:** 40 made-up tickets, five runs, against Claude Opus 5.5 alone.
|
|
61
|
+
|
|
62
|
+
| Setup | As good as Opus (blind human review, 20 tickets) | Serious mistakes | Quality, LLM judge | Cost per usable reply | Response time vs. Opus alone |
|
|
63
|
+
|---|---|---|---|---|---|
|
|
64
|
+
| Rules in code as the eval check | ❌ 4 of 20 | the rules caught 0 of 10 (four runs) | 2–6% lower | 82–92% cheaper | 22–35% faster |
|
|
65
|
+
| + an eval check in plain language | ✅ 13 of 20 | caught the one in its run; 2 of 20 got past it in the human review | 3.5–4.9% lower | 69–73% cheaper | 10–35% slower |
|
|
66
|
+
| + a mid-size model as the rescuer (one run) | not checked by a person | none occurred in that run | 5% lower | 87% cheaper | about as fast |
|
|
67
|
+
|
|
68
|
+
- **The LLM judge looked kinder than the person.** "2–6% lower" sounded close; a person preferred the frontier model almost every time. The judge and the person agreed on only one of the three real mistakes the person found with rules in code alone. Check the judge too.
|
|
69
|
+
- **The mistake that got past the check twice:** offering a carrier trace for a parcel that had already arrived. That is the next line for the PM to add to the check.
|
|
70
|
+
|
|
71
|
+
→ [Full support test](https://github.com/AndyJakob78/valueproof/blob/main/docs/support-test.md), with the lever ledger, check ratings and raw data.
|
|
72
|
+
|
|
73
|
+
**A live language-learning app:** the step that searches the web for a news story ran on Claude Sonnet 5.5 for every lesson, at 9.7 ¢ per article. With Haiku first and Sonnet only when a code check finds no usable or only an old story, it cost **4.6–7.7 ¢**. Quality held: an LLM judge scored 18 articles 472 vs 434 for the cheaper setup, and a person comparing 14 German article pairs blind found a tie (6 for the cheaper search, 7 for the old one, 1 equal). Here the cheap model only finds the story; a strong model still writes the lesson. → [Case study](https://github.com/AndyJakob78/valueproof/blob/main/docs/case-study.md)
|
|
74
|
+
|
|
75
|
+
**Twelve cost ideas, tested one at a time:** 7 made things worse or saved nothing. A shorter prompt made the model search *more*. → [Lessons](https://github.com/AndyJakob78/valueproof/blob/main/docs/lessons.md)
|
|
76
|
+
|
|
77
|
+
## Quick start
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install "valueproof[claude]" # or [openai], [gemini], [all]
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from valueproof import scout_and_rescue
|
|
85
|
+
from valueproof.claude import claude
|
|
86
|
+
|
|
87
|
+
POLICY = open("refund_policy.md").read() # the source that defines "right"
|
|
88
|
+
ticket = "Order 48213 arrived yesterday, but the box is damaged."
|
|
89
|
+
checker = claude("claude-haiku-5-5") # a cheap model reads each reply against the policy
|
|
90
|
+
|
|
91
|
+
def check(reply):
|
|
92
|
+
if "48213" not in reply: # rule in code: free and instant
|
|
93
|
+
return "order number missing"
|
|
94
|
+
verdict = checker( # check in plain language: one more cheap call
|
|
95
|
+
f"Policy:\n{POLICY}\n\nTicket:\n{ticket}\n\nReply:\n{reply}\n\n"
|
|
96
|
+
"Does the reply apply the policy correctly to this ticket, without assuming facts "
|
|
97
|
+
"the ticket doesn't give? Answer OK, or NO and the reason."
|
|
98
|
+
).text
|
|
99
|
+
return None if verdict.strip().startswith("OK") else verdict
|
|
100
|
+
|
|
101
|
+
out = scout_and_rescue(
|
|
102
|
+
f"Reply to this support ticket, following this policy:\n{POLICY}\n\nTicket: {ticket}",
|
|
103
|
+
scout=claude("claude-haiku-5-5"), # the cheap model answers first
|
|
104
|
+
rescue=claude("claude-opus-5-5"), # the frontier model runs only if the check fails
|
|
105
|
+
check=check,
|
|
106
|
+
)
|
|
107
|
+
print(out.path, out.cost_usd) # "scout" or "rescue", and what the answers cost
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
A check returns `None` when the answer is fine, or a reason when it is not. Start with the rules in code, and add the check in plain language where a wrong answer is not acceptable. `out.cost_usd` covers the answers; the check's own cost comes on top (about 0.02 ¢ per reply in our test). The [support test example](https://github.com/AndyJakob78/valueproof/blob/main/examples/test_levers_support.py) counts it, and caches it.
|
|
111
|
+
|
|
112
|
+
## Test a change before you ship it
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
valueproof init my_test.py # a starter test that runs straight away, with fake models
|
|
116
|
+
valueproof compare my_test.py # offline, free
|
|
117
|
+
valueproof compare my_test.py --live --estimate # runs 2 requests for real and prints the projected bill
|
|
118
|
+
valueproof compare my_test.py --live --max-spend 5 # the full test; stops starting new requests at $5
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`compare` runs every setup on every request in the same moment and prints:
|
|
122
|
+
|
|
123
|
+
- **cost per usable outcome**, average and median cost, time, and how often the frontier model ran
|
|
124
|
+
- **blind-review quality**, with hard failures counted separately so no average can hide them
|
|
125
|
+
- **check quality:** how many of the judge's hard failures each eval check caught, missed, and how many false alarms it raised
|
|
126
|
+
- **the lever ledger:** each change against the setup it changes, your estimate written down before the test, and a keep-or-drop verdict
|
|
127
|
+
|
|
128
|
+
To rate a new eval check on replies you already paid for, without running the models again: `--from-results results.json`.
|
|
129
|
+
|
|
130
|
+
**Blind review, two ways.** An LLM judge gets one answer at a time, in random order, never the setup's name. Give it the reference that defines "right"; without it, a judge can only tell whether an answer looks usable. Or review it yourself: every run writes `blind_review.csv` and a separate `blind_key.csv`.
|
|
131
|
+
|
|
132
|
+
→ How to write `my_test.py`, and a demo that runs without an API key: [examples/](https://github.com/AndyJakob78/valueproof/tree/main/examples/) · The step-by-step method: [docs/method.md](https://github.com/AndyJakob78/valueproof/blob/main/docs/method.md)
|
|
133
|
+
|
|
134
|
+
## When it fits
|
|
135
|
+
|
|
136
|
+
It fits when your product sends many requests to a frontier model, most of them routine, and you can say what a usable answer is: support replies, data extraction, document summaries, search and research assistants, code review, code migration (does it compile, do the tests pass).
|
|
137
|
+
|
|
138
|
+
Be careful where a wrong answer carries legal, money or safety risk. Measure your eval check against a blind review first, or keep that step on the frontier model until the check catches the mistakes that matter.
|
|
139
|
+
|
|
140
|
+
## How this differs from other tools
|
|
141
|
+
|
|
142
|
+
| Tool | What it does | How it relates |
|
|
143
|
+
|---|---|---|
|
|
144
|
+
| [RouteLLM](https://github.com/lm-sys/RouteLLM) | Trained routers that pick a model per request | A routing technique. Test it against your setup with `valueproof compare`. |
|
|
145
|
+
| [cascadeflow](https://github.com/lemony-ai/cascadeflow) | A cascading runtime for agents | A runtime for production. Test it here first. |
|
|
146
|
+
| [LiteLLM](https://github.com/BerriAI/litellm) | A gateway to 100+ model APIs | Infrastructure to call models. Works as the model behind a setup here. |
|
|
147
|
+
| [promptfoo](https://github.com/promptfoo/promptfoo) | Broad testing of prompts, agents and RAG | A general eval suite. This repo is narrower. |
|
|
148
|
+
|
|
149
|
+
**Cost-first, not QA-first.** Eval suites such as promptfoo and Braintrust are built around quality regression and observability, and show cost alongside. Valueproof starts from the decision a product manager or CFO has to make: cost per usable outcome, an estimate before the test, and a keep-or-drop verdict after it. Use it to get evidence on your own requests before you commit to a router or gateway.
|
|
150
|
+
|
|
151
|
+
## More
|
|
152
|
+
|
|
153
|
+
- [Why this exists](https://github.com/AndyJakob78/valueproof/blob/main/docs/why.md): who it is for, cost per outcome vs value shipped, and real-world signals from 2026
|
|
154
|
+
- [Support test](https://github.com/AndyJakob78/valueproof/blob/main/docs/support-test.md) · [Case study](https://github.com/AndyJakob78/valueproof/blob/main/docs/case-study.md) · [Game article test](https://github.com/AndyJakob78/valueproof/blob/main/docs/game-article-test.md) · [A chatbot estimate](https://github.com/AndyJakob78/valueproof/blob/main/docs/example-service-chatbot.md)
|
|
155
|
+
- [Scout & Rescue in detail](https://github.com/AndyJakob78/valueproof/blob/main/docs/scout-and-rescue.md) · [Method](https://github.com/AndyJakob78/valueproof/blob/main/docs/method.md) · [Lessons](https://github.com/AndyJakob78/valueproof/blob/main/docs/lessons.md) · [Templates](https://github.com/AndyJakob78/valueproof/tree/main/templates/)
|
|
156
|
+
|
|
157
|
+
## Install
|
|
158
|
+
|
|
159
|
+
Version 0.6, early: the API may still change. Python 3.10+ (the Gemini adapter needs 3.11+). The core has no dependencies; a model is any function `prompt -> ModelResult`, so a local model works too. Adapters come as extras: `[claude]`, `[openai]`, `[gemini]`, `[all]`.
|
|
160
|
+
|
|
161
|
+
The old package name `ai-mixed-model-cost-optimization` still installs and pulls in `valueproof`.
|
|
162
|
+
|
|
163
|
+
## Terms
|
|
164
|
+
|
|
165
|
+
- **LLM cascade / Scout & Rescue:** a cheap model (the scout) answers first; a frontier model (the rescuer) runs only when the answer fails an eval check.
|
|
166
|
+
- **Eval check:** judges one answer at runtime and decides whether the rescuer runs. A rule in code, or a cheap model asked in plain language with a reference.
|
|
167
|
+
- **Eval:** the fixed test before shipping: real requests, the eval checks, and a blind review, run the same way for every change.
|
|
168
|
+
- **Blind review:** answers scored on a fixed rubric without knowing which setup wrote them, by an LLM judge or a person.
|
|
169
|
+
- **Hard failure / serious mistake:** a wrong policy rule, a promise the policy doesn't allow, an invented fact, or no answer.
|
|
170
|
+
- **Usable outcome:** a final answer that passed the checks and had no hard failure.
|
|
171
|
+
- **Cost per usable outcome:** everything a setup spent, failed and rescued attempts included, divided by its usable outcomes.
|
|
172
|
+
- **Lever:** one change meant to lower cost, tested on its own.
|
|
173
|
+
|
|
174
|
+
## About
|
|
175
|
+
|
|
176
|
+
Built from a real cost-reduction project on a live language-learning app. Engineering, testing and blind reviews were done with an AI coding assistant (Claude); a product owner made every keep-or-drop decision and did the human blind checks.
|
|
177
|
+
|
|
178
|
+
Text: [CC BY 4.0](https://github.com/AndyJakob78/valueproof/blob/main/LICENSE). Code in [src/](https://github.com/AndyJakob78/valueproof/tree/main/src/) and [examples/](https://github.com/AndyJakob78/valueproof/tree/main/examples/): [MIT](https://github.com/AndyJakob78/valueproof/blob/main/LICENSE-CODE).
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "valueproof"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.6.1"
|
|
8
8
|
description = "Prove an AI cost cut on your own traffic before you ship it: cheap and strong models working together (Scout & Rescue), measured by cost per outcome with a blind quality review."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -9,14 +9,17 @@ and measure what each change does to cost and quality before it ships.
|
|
|
9
9
|
Any provider works: a model is just a function `prompt -> ModelResult`.
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
|
-
from .lever_runner import Report, Run, Score, estimate, is_outcome,
|
|
12
|
+
from .lever_runner import (Report, Run, Score, check_quality, estimate, is_outcome, ledger_markdown, lever_ledger,
|
|
13
|
+
load_report, print_check_ratings, print_ledger,
|
|
14
|
+
print_table, rate_checks, run_levers, save, summarize)
|
|
13
15
|
from .pipeline import RunResult, Step, StepLog, run_pipeline
|
|
14
16
|
from .scout_rescue import Check, Model, ModelResult, Outcome, handoff_prompt, scout_and_rescue
|
|
15
17
|
|
|
16
|
-
__version__ = "0.
|
|
18
|
+
__version__ = "0.6.1"
|
|
17
19
|
|
|
18
20
|
__all__ = [
|
|
19
21
|
"Check", "Model", "ModelResult", "Outcome", "handoff_prompt", "scout_and_rescue",
|
|
20
22
|
"RunResult", "Step", "StepLog", "run_pipeline",
|
|
21
|
-
"Report", "Run", "Score", "estimate", "is_outcome", "
|
|
23
|
+
"Report", "Run", "Score", "check_quality", "estimate", "is_outcome", "ledger_markdown", "lever_ledger", "load_report", "print_check_ratings", "print_ledger", "print_table",
|
|
24
|
+
"rate_checks", "run_levers", "save", "summarize",
|
|
22
25
|
]
|
|
@@ -14,6 +14,8 @@ Your test file is plain Python and defines one function:
|
|
|
14
14
|
"cases": [...], # your test requests
|
|
15
15
|
"setups": {"baseline": run, ...}, # name -> run(case) -> Run; first is the baseline
|
|
16
16
|
"judge": judge, # optional: judge(case, text) -> Score
|
|
17
|
+
"checks": {"my new check": fn}, # optional: candidate eval checks to rate, fn(case, text)
|
|
18
|
+
"levers": {"new": {"baseline": "baseline", "estimate": "-30% cost"}}, # optional: keep-or-drop ledger
|
|
17
19
|
"describe": lambda case: str(case), # optional: how a case shows on the review sheet
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -25,12 +27,13 @@ from __future__ import annotations
|
|
|
25
27
|
|
|
26
28
|
import argparse
|
|
27
29
|
import importlib.util
|
|
30
|
+
import json
|
|
28
31
|
import sys
|
|
29
32
|
from datetime import datetime
|
|
30
33
|
from pathlib import Path
|
|
31
34
|
|
|
32
35
|
from . import __version__
|
|
33
|
-
from .lever_runner import estimate, print_table, run_levers, save
|
|
36
|
+
from .lever_runner import estimate, ledger_markdown, lever_ledger, load_report, print_check_ratings, print_ledger, print_table, rate_checks, run_levers, save
|
|
34
37
|
from .starter import STARTER
|
|
35
38
|
|
|
36
39
|
|
|
@@ -48,7 +51,8 @@ def _load(path: Path):
|
|
|
48
51
|
|
|
49
52
|
|
|
50
53
|
def compare(file: str, live: bool = False, out: str | None = None, extra: list[str] | None = None,
|
|
51
|
-
max_spend: float | None = None, estimate_only: bool = False, sample: int = 2
|
|
54
|
+
max_spend: float | None = None, estimate_only: bool = False, sample: int = 2,
|
|
55
|
+
from_results: str | None = None) -> None:
|
|
52
56
|
path = Path(file).resolve()
|
|
53
57
|
spec = _load(path).build(live, extra or [])
|
|
54
58
|
cases, setups, judge = spec["cases"], spec["setups"], spec.get("judge")
|
|
@@ -60,6 +64,21 @@ def compare(file: str, live: bool = False, out: str | None = None, extra: list[s
|
|
|
60
64
|
print(f"Projected full run: ${e['projected_total']:.2f} for {e['cases']} cases, including the review")
|
|
61
65
|
print("A rough guide: hard cases and rescues cost more. Set a ceiling with --max-spend.")
|
|
62
66
|
return
|
|
67
|
+
if from_results: # no model runs: rate the candidate checks on saved replies
|
|
68
|
+
report = load_report(Path(from_results))
|
|
69
|
+
present = list(dict.fromkeys(r.setup for r in report.rows))
|
|
70
|
+
names = [n for n in setups if n in present] + [n for n in present if n not in setups] # first = baseline
|
|
71
|
+
print(f"{mode}: {len(report.rows)} saved results from {from_results} (no model runs)\n")
|
|
72
|
+
print_table(report, names)
|
|
73
|
+
ledger = lever_ledger(report, spec.get("levers") or {})
|
|
74
|
+
print_ledger(ledger)
|
|
75
|
+
if spec.get("checks"):
|
|
76
|
+
print_check_ratings(rate_checks(report, cases, names, spec["checks"]))
|
|
77
|
+
print(f"Spent on the checks: ${report.spent_usd:.4f}")
|
|
78
|
+
if out and ledger:
|
|
79
|
+
Path(out).mkdir(parents=True, exist_ok=True)
|
|
80
|
+
(Path(out) / "ledger.md").write_text(ledger_markdown(ledger) + "\n")
|
|
81
|
+
return
|
|
63
82
|
limit = f", stops at ${max_spend:.2f}" if max_spend is not None else ""
|
|
64
83
|
print(f"{mode}: {len(cases)} cases x {len(setups)} setups{limit}")
|
|
65
84
|
report = run_levers(cases, setups, judge=judge, max_spend=max_spend)
|
|
@@ -68,8 +87,17 @@ def compare(file: str, live: bool = False, out: str | None = None, extra: list[s
|
|
|
68
87
|
return
|
|
69
88
|
print()
|
|
70
89
|
print_table(report, list(setups))
|
|
90
|
+
ledger = lever_ledger(report, spec.get("levers") or {})
|
|
91
|
+
print_ledger(ledger)
|
|
92
|
+
ratings = rate_checks(report, cases, list(setups), spec["checks"]) if spec.get("checks") and judge else {}
|
|
93
|
+
print_check_ratings(ratings)
|
|
71
94
|
out_dir = Path(out) if out else path.parent / "results" / datetime.now().strftime("%Y%m%d-%H%M%S")
|
|
72
95
|
save(report, cases, out_dir, describe=spec.get("describe", str))
|
|
96
|
+
if ledger:
|
|
97
|
+
(out_dir / "ledger.md").write_text(ledger_markdown(ledger) + "\n")
|
|
98
|
+
if ratings:
|
|
99
|
+
(out_dir / "check_ratings.json").write_text(json.dumps(ratings, indent=2))
|
|
100
|
+
print(f"Spent including the check ratings: ${report.spent_usd:.4f}")
|
|
73
101
|
print(f"\nSaved to {out_dir}")
|
|
74
102
|
|
|
75
103
|
|
|
@@ -95,11 +123,13 @@ def main(argv: list[str] | None = None) -> None:
|
|
|
95
123
|
cmp_.add_argument("--estimate", action="store_true",
|
|
96
124
|
help="run only a small sample for real and print the projected cost of the full run")
|
|
97
125
|
cmp_.add_argument("--sample", type=int, default=2, help="cases to run for --estimate (default: 2)")
|
|
126
|
+
cmp_.add_argument("--from-results", metavar="FILE",
|
|
127
|
+
help="skip the runs: rate the test file's candidate checks on a saved results.json")
|
|
98
128
|
ini = sub.add_parser("init", help="write a starter test file that runs offline straight away")
|
|
99
129
|
ini.add_argument("file", nargs="?", default="valueproof_test.py", help="file to create (default: valueproof_test.py)")
|
|
100
130
|
args, extra = parser.parse_known_args(argv)
|
|
101
131
|
if args.command == "compare":
|
|
102
|
-
compare(args.file, args.live, args.out, extra, args.max_spend, args.estimate, args.sample)
|
|
132
|
+
compare(args.file, args.live, args.out, extra, args.max_spend, args.estimate, args.sample, args.from_results)
|
|
103
133
|
elif args.command == "init":
|
|
104
134
|
init(args.file)
|
|
105
135
|
|