persado-benchmark 0.7.0__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.
- persado_benchmark-0.7.0/LICENSE +57 -0
- persado_benchmark-0.7.0/MANIFEST.in +4 -0
- persado_benchmark-0.7.0/PKG-INFO +498 -0
- persado_benchmark-0.7.0/README.md +468 -0
- persado_benchmark-0.7.0/pyproject.toml +49 -0
- persado_benchmark-0.7.0/setup.cfg +4 -0
- persado_benchmark-0.7.0/src/persado_benchmark/__init__.py +3 -0
- persado_benchmark-0.7.0/src/persado_benchmark/__main__.py +3 -0
- persado_benchmark-0.7.0/src/persado_benchmark/cli.py +458 -0
- persado_benchmark-0.7.0/src/persado_benchmark/data.py +609 -0
- persado_benchmark-0.7.0/src/persado_benchmark/demo.py +76 -0
- persado_benchmark-0.7.0/src/persado_benchmark/harness.py +177 -0
- persado_benchmark-0.7.0/src/persado_benchmark/metrics.py +230 -0
- persado_benchmark-0.7.0/src/persado_benchmark/output.py +276 -0
- persado_benchmark-0.7.0/src/persado_benchmark/prompts.py +120 -0
- persado_benchmark-0.7.0/src/persado_benchmark/report.py +196 -0
- persado_benchmark-0.7.0/src/persado_benchmark/scorers.py +728 -0
- persado_benchmark-0.7.0/src/persado_benchmark.egg-info/PKG-INFO +498 -0
- persado_benchmark-0.7.0/src/persado_benchmark.egg-info/SOURCES.txt +21 -0
- persado_benchmark-0.7.0/src/persado_benchmark.egg-info/dependency_links.txt +1 -0
- persado_benchmark-0.7.0/src/persado_benchmark.egg-info/entry_points.txt +2 -0
- persado_benchmark-0.7.0/src/persado_benchmark.egg-info/requires.txt +3 -0
- persado_benchmark-0.7.0/src/persado_benchmark.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Copyright (c) 2026 Persado
|
|
2
|
+
|
|
3
|
+
# PolyForm Internal Use License 1.0.0
|
|
4
|
+
|
|
5
|
+
<https://polyformproject.org/licenses/internal-use/1.0.0>
|
|
6
|
+
|
|
7
|
+
## Acceptance
|
|
8
|
+
|
|
9
|
+
In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license), and you may not distribute the software.
|
|
14
|
+
|
|
15
|
+
## Changes and New Works License
|
|
16
|
+
|
|
17
|
+
The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
|
|
18
|
+
|
|
19
|
+
## Patent License
|
|
20
|
+
|
|
21
|
+
The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
|
|
22
|
+
|
|
23
|
+
## Fair Use
|
|
24
|
+
|
|
25
|
+
You may have "fair use" rights for the software under the law. These terms do not limit them.
|
|
26
|
+
|
|
27
|
+
## Internal Business Use
|
|
28
|
+
|
|
29
|
+
Use of the software for the internal business operations of you and your company is use for a permitted purpose.
|
|
30
|
+
|
|
31
|
+
## No Other Rights
|
|
32
|
+
|
|
33
|
+
These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
|
|
34
|
+
|
|
35
|
+
## Patent Defense
|
|
36
|
+
|
|
37
|
+
If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
38
|
+
|
|
39
|
+
## Violations
|
|
40
|
+
|
|
41
|
+
The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
|
|
42
|
+
|
|
43
|
+
## No Liability
|
|
44
|
+
|
|
45
|
+
***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
|
|
46
|
+
|
|
47
|
+
## Definitions
|
|
48
|
+
|
|
49
|
+
The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
|
|
50
|
+
|
|
51
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
52
|
+
|
|
53
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
54
|
+
|
|
55
|
+
**Your licenses** are all the licenses granted to you for the software under these terms.
|
|
56
|
+
|
|
57
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: persado-benchmark
|
|
3
|
+
Version: 0.7.0
|
|
4
|
+
Summary: Test a marketing-performance predictor on your own A/B tests, blind.
|
|
5
|
+
Author: Persado
|
|
6
|
+
License-Expression: LicenseRef-PolyForm-Internal-Use-1.0.0
|
|
7
|
+
Project-URL: Source, https://github.com/persado/persado-benchmark
|
|
8
|
+
Project-URL: Changelog, https://github.com/persado/persado-benchmark/blob/main/CHANGELOG.md
|
|
9
|
+
Project-URL: API reference, https://api.persado.com/api/reference.html
|
|
10
|
+
Keywords: marketing,a/b testing,benchmark,persado,email,prediction
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Provides-Extra: excel
|
|
28
|
+
Requires-Dist: openpyxl; extra == "excel"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# persado-benchmark
|
|
32
|
+
|
|
33
|
+
**Don't take our word for it. Run Persado against your own A/B tests and try to prove us wrong.**
|
|
34
|
+
|
|
35
|
+
`persado-benchmark` takes A/B tests you have already run, hides the results, asks
|
|
36
|
+
Persado's prediction API which message would win, puts a general-purpose LLM
|
|
37
|
+
through the same test, locks every prediction, and only then checks them against
|
|
38
|
+
what actually happened.
|
|
39
|
+
|
|
40
|
+
- Bring messages from any tool: four columns in a CSV are enough
|
|
41
|
+
- About 50 past A/B tests is a good starting set
|
|
42
|
+
- Only message text leaves your machine. Results never do
|
|
43
|
+
- Same rules as Persado's model-evaluation workbook, so the numbers match
|
|
44
|
+
- Zero dependencies: Python 3.9+ standard library only
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install persado-benchmark # or: git clone … && pip install -e .
|
|
48
|
+
persado-benchmark demo # 50 synthetic tests, no API key needed
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Quick start
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
persado-benchmark template # writes ab_tests.csv to fill in
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```csv
|
|
58
|
+
campaign,message,unique_clicks,delivered
|
|
59
|
+
Spring sale reminder,Your spring picks are 20% off until Sunday,412,18000
|
|
60
|
+
Spring sale reminder,Last call: 20% off ends Sunday,538,18100
|
|
61
|
+
Welcome email,Welcome! Here is what to do first,1210,9400
|
|
62
|
+
Welcome email,You're in. Start with these three things,1105,9350
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
One row per message. Rows with the same campaign name form one A/B test.
|
|
66
|
+
Copy the text and the two numbers from whatever tool sent the messages.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
export PERSADO_API_KEY=…
|
|
70
|
+
export PERSADO_API_URL=… # optional: API base, if not https://api.persado.com/api
|
|
71
|
+
export LLM_API_KEY=… # optional, for the LLM comparison
|
|
72
|
+
|
|
73
|
+
persado-benchmark run ab_tests.csv --baseline LLM=llm:<model-name>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The report has this shape. The numbers below come from `persado-benchmark demo`,
|
|
77
|
+
which uses simulated tests and simulated scorers; they are not Persado results.
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
A/B tests: 50
|
|
81
|
+
Messages scored: 133
|
|
82
|
+
Predictions locked: 2026-11-11T09:08:26+00:00 sha256 6d582bf7fcf8… (before results were read)
|
|
83
|
+
|
|
84
|
+
HEADLINE (same rules as Persado's model-evaluation workbook)
|
|
85
|
+
Calls the winner Tests judged Rank correlation
|
|
86
|
+
simulated-strong 82.8% [68.2, 96.0] 29 0.77
|
|
87
|
+
simulated-weak 65.5% [47.6, 82.1] 29 0.11
|
|
88
|
+
shortest-wins 25.0% [10.0, 41.7] 28 -0.22
|
|
89
|
+
Random baseline 43.0% 0.00
|
|
90
|
+
|
|
91
|
+
simulated-strong: 29 of 50 tests judged (24 called correctly) · 0 tied · 21 too close to call (p ≥ 0.05)
|
|
92
|
+
Chance of guessing 24 or more of 29 winners: p < 0.001
|
|
93
|
+
|
|
94
|
+
ALL 50 TESTS, NOTHING FILTERED
|
|
95
|
+
Winner accuracy Pairwise Top-2 Lift captured
|
|
96
|
+
simulated-strong 70.0% [56.0, 82.0] 71.8% 94.7% 83%
|
|
97
|
+
…
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Each run writes `report.md`, `results.json`, `predictions.jsonl` and `lock.json`
|
|
101
|
+
to `runs/<timestamp>/`, and a copy of your file with the scores added (see
|
|
102
|
+
[The scored file](#the-scored-file)).
|
|
103
|
+
|
|
104
|
+
## Your data
|
|
105
|
+
|
|
106
|
+
Anything that gives you the message text and a result per message works:
|
|
107
|
+
an ESP, a CRM, an ad platform, an experimentation tool, a spreadsheet someone
|
|
108
|
+
kept. It reads:
|
|
109
|
+
|
|
110
|
+
- **delimited text**: `.csv` and `.tsv`; commas, semicolons, tabs and pipes
|
|
111
|
+
are told apart on their own;
|
|
112
|
+
- **JSON**: `.json`, a list of records or one under `data`, `results`,
|
|
113
|
+
`records`, `rows` or `items`; and `.jsonl` / `.ndjson`, one record a line;
|
|
114
|
+
- **spreadsheets**: `.xlsx` and `.xlsm`, either the Persado model-evaluation
|
|
115
|
+
workbook or any sheet whose first row is the header (`--sheet` picks one).
|
|
116
|
+
These need `pip install 'persado-benchmark[excel]'`.
|
|
117
|
+
|
|
118
|
+
### Supported data formats
|
|
119
|
+
|
|
120
|
+
Two choices, independent of each other: how the rows are laid out, and what the
|
|
121
|
+
outcome column holds. All four combinations are supported and shipped as
|
|
122
|
+
examples — the same six A/B tests written four ways.
|
|
123
|
+
|
|
124
|
+
| | **Counts** (`unique_clicks` + `delivered`) | **A rate** (`click_rate`, `ctr`, `response_rate`) |
|
|
125
|
+
|---|---|---|
|
|
126
|
+
| **Long** — one message per row | [`long_counts.csv`](https://github.com/persado/persado-benchmark/blob/main/examples/long_counts.csv) | [`long_rate.csv`](https://github.com/persado/persado-benchmark/blob/main/examples/long_rate.csv) |
|
|
127
|
+
| **Wide** — one test per row, `_a` / `_b` / `_c` suffixes | [`wide_counts.csv`](https://github.com/persado/persado-benchmark/blob/main/examples/wide_counts.csv) | [`wide_rate.csv`](https://github.com/persado/persado-benchmark/blob/main/examples/wide_rate.csv) |
|
|
128
|
+
|
|
129
|
+
A filled-in model-evaluation workbook (`.xlsx`) is a fifth input and reads as
|
|
130
|
+
long + counts; [`worked_example.csv`](https://github.com/persado/persado-benchmark/blob/main/examples/worked_example.csv) is the same
|
|
131
|
+
data as a CSV.
|
|
132
|
+
|
|
133
|
+
Every one of those runs is in [`examples/results/`](https://github.com/persado/persado-benchmark/tree/main/examples/results), and the
|
|
134
|
+
test suite re-runs each example and compares it with the committed report, so
|
|
135
|
+
the files below are what the tool actually prints today.
|
|
136
|
+
|
|
137
|
+
**Layout changes nothing.** `long_counts` and `wide_counts` are the same six
|
|
138
|
+
tests and produce identical numbers, as do `long_rate` and `wide_rate`. Use
|
|
139
|
+
whichever shape your export already has.
|
|
140
|
+
|
|
141
|
+
**The outcome column changes what can be concluded.** On those six tests:
|
|
142
|
+
|
|
143
|
+
| | Tests judged | Calls the winner |
|
|
144
|
+
|---|---|---|
|
|
145
|
+
| counts | 3 of 6 | 66.7% |
|
|
146
|
+
| a rate | 6 of 6 | 50.0% |
|
|
147
|
+
|
|
148
|
+
Same data, same scores. With counts, a test is judged only once its best
|
|
149
|
+
message beat the runner-up in a two-proportion test (p < 0.05), and three of
|
|
150
|
+
the six differences are too small to call. With a rate alone that test cannot
|
|
151
|
+
be run — a 2.02% against a 2.00% could be ten thousand sends or ten — so every
|
|
152
|
+
test with an untied best result is judged, noise included, and the headline is
|
|
153
|
+
diluted by tests the data cannot settle.
|
|
154
|
+
|
|
155
|
+
So **counts are the real test and a rate is a weaker one.** A rate-only file
|
|
156
|
+
still runs, and the report says plainly in its notes that the significance gate
|
|
157
|
+
was not applied, but a benchmark meant to prove or disprove a model should be
|
|
158
|
+
exported with clicks and deliveries.
|
|
159
|
+
|
|
160
|
+
Column names are matched loosely (`Campaign Name`, `Subject`, `Unique Clicks`,
|
|
161
|
+
`Delivered` and many variations). Check how a file is read before spending API calls:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
persado-benchmark inspect my_export.csv
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
If a column is not recognised, name it:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
persado-benchmark run my_export.csv \
|
|
171
|
+
--map experiment="Test Name" --map text="Headline" \
|
|
172
|
+
--map successes="Conversions" --map delivered="Impressions" --metric conversion
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Fields: `experiment`, `variant`, `text`, `preheader`, `headline`, `body`, `cta`,
|
|
176
|
+
`successes`, `delivered`, `sent`, `rate`, `channel`, `industry`, `account`,
|
|
177
|
+
`country`, `language`. The last five are optional: a flag of the same name
|
|
178
|
+
sets them for the whole run.
|
|
179
|
+
|
|
180
|
+
For a few platforms there are optional presets that already know the export's
|
|
181
|
+
column names: `--source salesforce | klaviyo | sailthru | braze | iterable`
|
|
182
|
+
(`persado-benchmark sources` lists them). They are shortcuts, not requirements.
|
|
183
|
+
|
|
184
|
+
**Which result to use.** `--metric click` (default), `open` or `conversion`.
|
|
185
|
+
Use the same basis for every message of a test, and counts rather than a rate
|
|
186
|
+
wherever the export has them (see above). Avoid open rates, which automatic
|
|
187
|
+
mail-privacy opens make unreliable.
|
|
188
|
+
|
|
189
|
+
**No need to prefilter.** Put in every test from a period. The report lists what
|
|
190
|
+
was set aside and why: campaigns with a single message, tests with a missing
|
|
191
|
+
result, exact ties. The same message sent to several segments is pooled.
|
|
192
|
+
|
|
193
|
+
### How many tests?
|
|
194
|
+
|
|
195
|
+
About **50 A/B tests** is enough to start. Not all of them will be judged: a test
|
|
196
|
+
only counts toward "calls the winner" when its best message clearly beat the
|
|
197
|
+
runner-up, and typically a third to a half are too close to call. Fifty tests
|
|
198
|
+
usually leaves 25 to 35 judged, which is enough to tell a model that calls most
|
|
199
|
+
winners from one that is guessing, and the report prints the exact probability
|
|
200
|
+
that guessing would do as well. It is not enough to separate two models that
|
|
201
|
+
are a few points apart; for that, add more tests. Fewer than 50 still runs.
|
|
202
|
+
|
|
203
|
+
## Compare with an LLM
|
|
204
|
+
|
|
205
|
+
The same prompt is used either way. It gives the LLM the messages, the channel
|
|
206
|
+
and industry, and a clear target, and nothing about results.
|
|
207
|
+
|
|
208
|
+
**With an API key** (any OpenAI-compatible endpoint; set `LLM_BASE_URL` for
|
|
209
|
+
providers other than OpenAI):
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
persado-benchmark run ab_tests.csv --baseline LLM=llm:<model-name>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Without an API key**, paste the prompt into any chat assistant:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
persado-benchmark prompt ab_tests.csv # writes llm_prompts/prompt_01.txt …
|
|
219
|
+
# paste each prompt into a new chat, save all replies in llm_prompts/replies.txt
|
|
220
|
+
persado-benchmark run ab_tests.csv --baseline LLM=reply:llm_prompts/replies.txt
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
The prompt (`prompts.py`):
|
|
224
|
+
|
|
225
|
+
```text
|
|
226
|
+
You are an expert direct-response marketer. You predict which marketing message
|
|
227
|
+
will get the best response from its audience.
|
|
228
|
+
|
|
229
|
+
Below are marketing messages from past A/B tests (channel: …, industry: …).
|
|
230
|
+
Within each test, the messages went to comparable random splits of the same
|
|
231
|
+
audience at the same time, so differences in response come from the wording.
|
|
232
|
+
|
|
233
|
+
For every message, predict its click-through rate relative to the other messages
|
|
234
|
+
in the same test. Give each message a score from 0 to 100, where a higher score
|
|
235
|
+
means a higher click-through rate. Scores are only compared within a test, never
|
|
236
|
+
across tests.
|
|
237
|
+
|
|
238
|
+
Rules
|
|
239
|
+
- Judge only the text shown. You have not been given results; do not ask for
|
|
240
|
+
them or search for them.
|
|
241
|
+
- Consider what drives response on this channel: clarity of the offer,
|
|
242
|
+
relevance, emotional appeal, urgency, specificity, length and tone.
|
|
243
|
+
- Score every message. Keep the messages in the order given.
|
|
244
|
+
- Reply with JSON only. No explanation, no markdown.
|
|
245
|
+
|
|
246
|
+
Reply format: one line per test, {"test": "<test id>", "scores": [s1, s2, ...]},
|
|
247
|
+
with one number per message in the order given. Copy each test id exactly.
|
|
248
|
+
|
|
249
|
+
Test T720430
|
|
250
|
+
1. Your February statement is ready
|
|
251
|
+
2. Your overdraft terms are changing on 1 October
|
|
252
|
+
…
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Think a better prompt would beat Persado? Copy `TEMPLATE` from `prompts.py` into
|
|
256
|
+
a file, edit it, and pass `--llm-prompt my_prompt.txt`. Each scorer is run five
|
|
257
|
+
times by default (`--runs`), which is what the ranking-stability number measures;
|
|
258
|
+
for the paste flow, repeat in fresh chats and pass the reply files comma separated.
|
|
259
|
+
|
|
260
|
+
## Compare with your own model
|
|
261
|
+
|
|
262
|
+
If you already predict which message will win, put your model in the run as a
|
|
263
|
+
baseline. It gets exactly what Persado gets — the messages, channel, industry
|
|
264
|
+
and brand, never the results — its predictions are locked alongside Persado's,
|
|
265
|
+
and the report measures both the same way, side by side, with a head-to-head
|
|
266
|
+
line saying which one called more winners and whether the gap is more than
|
|
267
|
+
chance.
|
|
268
|
+
|
|
269
|
+
Your model can come in four ways:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
--baseline internal=column:model_score # scores already logged in your file
|
|
273
|
+
--baseline internal=py:examples/my_model.py:score # a Python function
|
|
274
|
+
--baseline internal="cmd:./examples/score.sh" # any program, in any language
|
|
275
|
+
--baseline length # "shortest wins" sanity floor
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
The two files in [`examples/`](https://github.com/persado/persado-benchmark/tree/main/examples)
|
|
279
|
+
are working starting points; copy one and replace its scoring with a call to
|
|
280
|
+
your model:
|
|
281
|
+
|
|
282
|
+
- [`my_model.py`](https://github.com/persado/persado-benchmark/blob/main/examples/my_model.py)
|
|
283
|
+
defines `score(texts, context)`, which returns one number per message,
|
|
284
|
+
higher meaning predicted to perform better. Its placeholder counts urgency
|
|
285
|
+
words.
|
|
286
|
+
- [`score.sh`](https://github.com/persado/persado-benchmark/blob/main/examples/score.sh)
|
|
287
|
+
reads one test as JSON on stdin and prints a JSON list of scores. Its
|
|
288
|
+
placeholder scores by length.
|
|
289
|
+
|
|
290
|
+
Both receive the same context for each test: `experiment_id`, `channel`,
|
|
291
|
+
`industry`, `account`, `country`, `language` (`null` where neither the file
|
|
292
|
+
nor a flag gives one), and `variants`, each with its `id`, `text`, and all
|
|
293
|
+
its content parts (text, preheader and so on) as `fields`. Scores are only compared within a test, so
|
|
294
|
+
any scale works.
|
|
295
|
+
|
|
296
|
+
`--scorer` takes the same specs. `--scorer workbook` uses the scores in a
|
|
297
|
+
model-evaluation workbook that Persado has already returned, so the LLM
|
|
298
|
+
comparison can be run on it without API access.
|
|
299
|
+
|
|
300
|
+
## How the blind test works
|
|
301
|
+
|
|
302
|
+
1. **Split.** The loader separates message text from results. Scorers receive
|
|
303
|
+
`BlindExperiment` objects, which have no result fields at all.
|
|
304
|
+
2. **Score.** Every scorer ranks the messages within each test.
|
|
305
|
+
3. **Lock.** Predictions are written to `predictions.jsonl` and their SHA-256
|
|
306
|
+
goes into `lock.json`. So do the brand, channel, industry, country and
|
|
307
|
+
language each request to Persado carried (`scored_as`), as sent, with how
|
|
308
|
+
many tests carried each: industry changes Persado's score, so a score is
|
|
309
|
+
only reproducible with them. The report shows them on its "Sent as" line.
|
|
310
|
+
4. **Reveal.** Results are read only after the lock exists. `evaluate` refuses
|
|
311
|
+
to run if the predictions were edited afterwards.
|
|
312
|
+
5. **Measure.** Metrics and confidence intervals are computed.
|
|
313
|
+
|
|
314
|
+
If you would rather not trust our code with step 1, do it yourself. Delete the
|
|
315
|
+
result columns from a copy of your file, then:
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
persado-benchmark predict blind_copy.csv --out runs/blind
|
|
319
|
+
persado-benchmark evaluate runs/blind ab_tests.csv
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
The request body is built in one function, `PersadoScorer.build_request`, and
|
|
323
|
+
contains the message texts plus channel and industry. Nothing else.
|
|
324
|
+
|
|
325
|
+
### The scored file
|
|
326
|
+
|
|
327
|
+
`run` and `predict` also write your file back into the run folder, named
|
|
328
|
+
after it with `_scored` added (`ab_tests.csv` → `ab_tests_scored.csv`), with
|
|
329
|
+
each scorer's score next to each message,
|
|
330
|
+
so you can sort and filter the predictions in the tool you exported from.
|
|
331
|
+
Every original cell is kept as it was, in the same order; the scores are added:
|
|
332
|
+
|
|
333
|
+
| Your file | What is added |
|
|
334
|
+
|---|---|
|
|
335
|
+
| CSV, TSV, JSON, JSONL, a spreadsheet table | a `persado_score` column after the last one, and one for each baseline you ran (`--baseline LLM=…` adds `llm_score`) |
|
|
336
|
+
| a wide file, one test per row | one column per message: `persado_score_a`, `persado_score_b`, … |
|
|
337
|
+
| the model-evaluation workbook | Persado's runs in its Run 1–Run 5 columns, where the workbook's own formulas read them; baselines on a sheet of their own, *Other scorers* |
|
|
338
|
+
|
|
339
|
+
- A score is the average of a message's runs. Persado's are whole numbers, and
|
|
340
|
+
every run gives the same one.
|
|
341
|
+
- A message that was not scored has an empty cell (`null` in JSON), never a
|
|
342
|
+
zero: a campaign with a single message, a test that was set aside, or one
|
|
343
|
+
the scorer failed on. The same message sent to several segments gets its
|
|
344
|
+
score on every row.
|
|
345
|
+
- Scores that came from the file itself (`column:` or `workbook`) are already
|
|
346
|
+
in it, so they are not written again.
|
|
347
|
+
- Scoring a scored file again replaces its score columns rather than adding a
|
|
348
|
+
second set.
|
|
349
|
+
- A spreadsheet's cells, formulas, styles and conditional formatting are kept,
|
|
350
|
+
and formulas recalculate when the file is opened. Charts and pictures cannot
|
|
351
|
+
be carried over; if the file has any, the run says so, and your original
|
|
352
|
+
still has them.
|
|
353
|
+
|
|
354
|
+
The scored file is a convenience copy, written after the predictions are
|
|
355
|
+
locked. `predictions.jsonl` and `lock.json` remain the record of what was
|
|
356
|
+
predicted, and they are what `evaluate` checks.
|
|
357
|
+
|
|
358
|
+
## Metrics
|
|
359
|
+
|
|
360
|
+
**Headline, identical to the model-evaluation workbook.** Not a claim but a
|
|
361
|
+
test: `tests/workbook_oracle.py` is the spreadsheet's own formulas transcribed
|
|
362
|
+
by hand, and `tests/test_workbook_parity.py` holds the two implementations to
|
|
363
|
+
the same numbers — on the workbook's worked example, and on 400 random datasets
|
|
364
|
+
built to land on the awkward cases (ties in the scores, ties in the results,
|
|
365
|
+
two-message tests, tests nobody can judge).
|
|
366
|
+
|
|
367
|
+
Where the harness knowingly goes beyond the workbook, it says so in the report:
|
|
368
|
+
a file carrying rates but no clicks and deliveries cannot have the
|
|
369
|
+
two-proportion test applied, so an untied best result is accepted and a note
|
|
370
|
+
records it.
|
|
371
|
+
|
|
372
|
+
| Metric | Meaning |
|
|
373
|
+
|---|---|
|
|
374
|
+
| Calls the winner | Share of judged tests where the top-scored message had the best result. A test is judged when its best message beat the runner-up in a two-proportion test (`--alpha`, default 0.05) and neither the top score nor the top result is tied |
|
|
375
|
+
| Rank correlation | Spearman: ranks centred within each test, pooled across tests. Two-message tests without a clear winner are left out |
|
|
376
|
+
| Ranking stability | Share of tests ranked identically on every repeat run |
|
|
377
|
+
|
|
378
|
+
**Detail, on every test with nothing filtered.**
|
|
379
|
+
|
|
380
|
+
| Metric | Meaning |
|
|
381
|
+
|---|---|
|
|
382
|
+
| Winner accuracy | As above but on all tests; a scorer that ties its top picks gets partial credit |
|
|
383
|
+
| Pairwise accuracy | Share of message pairs within a test ordered correctly |
|
|
384
|
+
| Top-k accuracy | The winner is among the top k predictions (`--top-k`, default 2) |
|
|
385
|
+
| Lift captured | How much of the gap between "pick at random" and "always pick the winner" the scorer closes |
|
|
386
|
+
| Random baseline | What guessing scores on these exact tests. Below 50% once tests have more than two messages |
|
|
387
|
+
| Head to head | Paired difference between the primary scorer and each baseline, with an interval and an exact sign test |
|
|
388
|
+
|
|
389
|
+
Brackets are 95% bootstrap intervals that resample whole tests.
|
|
390
|
+
|
|
391
|
+
`results.json` records how the run was paced: `meta.runs` (repeat scorings per
|
|
392
|
+
message), `meta.concurrency` (calls in flight at once, `--concurrency`,
|
|
393
|
+
default 1) and `meta.rate_limited` (how many times the API answered
|
|
394
|
+
`rate_limited`, and the seconds the run paused for it). Only scorers that go
|
|
395
|
+
over the network are paced, so a run with none records `null`. When a rate
|
|
396
|
+
limit is what failed a run, the pacing is the first thing to look at, and the
|
|
397
|
+
report prints it beside the data line. If you raised `--concurrency`, lower it
|
|
398
|
+
and run again; at one call at a time, run again later.
|
|
399
|
+
|
|
400
|
+
## Reading the result fairly
|
|
401
|
+
|
|
402
|
+
- **Scores compare within a test.** A 70 in one campaign and a 60 in another
|
|
403
|
+
says nothing about which campaign did better.
|
|
404
|
+
- **Wording tests only.** If messages also differed in audience, send time,
|
|
405
|
+
offer or imagery, the result measures those too.
|
|
406
|
+
- **History the model may have seen.** If Persado already works with your brand,
|
|
407
|
+
ask which campaigns were in its training data and leave those out.
|
|
408
|
+
- **Use every test in a period**, not a hand-picked set.
|
|
409
|
+
|
|
410
|
+
## Persado API
|
|
411
|
+
|
|
412
|
+
The Persado scorer calls `POST /v1/performance` of the Martech API
|
|
413
|
+
([reference](https://api.persado.com/api/reference.html)), up to 10 messages
|
|
414
|
+
per call. [docs/api-contract.md](https://github.com/persado/persado-benchmark/blob/main/docs/api-contract.md) describes the request,
|
|
415
|
+
the response and the errors.
|
|
416
|
+
|
|
417
|
+
```bash
|
|
418
|
+
export PERSADO_API_KEY=pmk_… # from the developer dashboard
|
|
419
|
+
export PERSADO_API_URL=… # optional, the API base; defaults to https://api.persado.com/api
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
The request carries copy, channel and account identity. Unknown fields are
|
|
423
|
+
rejected by the API with `400`, so nothing else can be sent by accident.
|
|
424
|
+
|
|
425
|
+
**Scores are whole numbers**, rounded half up from the API's two decimals
|
|
426
|
+
(64.5 → 65, 64.49 → 64) — the same scores the model-evaluation workbook uses,
|
|
427
|
+
so the same messages count as tied.
|
|
428
|
+
|
|
429
|
+
What to expect from a run:
|
|
430
|
+
|
|
431
|
+
- **A test with more than 10 messages** is split across calls; each message
|
|
432
|
+
is scored on its own, so no score changes.
|
|
433
|
+
- **A missing score is an error**, never read as zero.
|
|
434
|
+
- **A call that times out after it was sent is not retried.** Persado may
|
|
435
|
+
already have scored and charged it, so a retry could pay twice; the test is
|
|
436
|
+
reported as failed. A connection that never opened is retried.
|
|
437
|
+
- **Copy with personal data is refused** (`422 sensitive_data_detected`), and
|
|
438
|
+
the run reports it as a scorer error for that test.
|
|
439
|
+
- **`429 rate_limited` is waited out**; **`429 quota_exhausted` stops the run
|
|
440
|
+
at once**, because the key's run budget is spent and no wait will help. What
|
|
441
|
+
had come back is cached, so a rerun with a funded key does not pay for it
|
|
442
|
+
again.
|
|
443
|
+
|
|
444
|
+
**Industry changes the score; the brand name matters only to existing Persado
|
|
445
|
+
customers.** Set the industry on every run, with `--industry` or an industry
|
|
446
|
+
column, and pick the one the copy was written for: it is a measurement
|
|
447
|
+
setting, not a label. For a brand Persado does not already work with, the name
|
|
448
|
+
changes nothing; for an existing customer it may, so use the real brand name.
|
|
449
|
+
|
|
450
|
+
The API requires `account.name`, so a run needs a brand, given the same way as
|
|
451
|
+
channel and industry — a column in the file, or a flag for the whole run:
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
persado-benchmark run ab_tests.csv --account "Acme Bank"
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
```csv
|
|
458
|
+
brand,campaign,message,unique_clicks,delivered
|
|
459
|
+
Acme Bank,Spring sale reminder,Your spring picks are 20% off until Sunday,412,18000
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
The column wins where both are given, and is read as `account`, `brand`,
|
|
463
|
+
`client`, `advertiser` or `company`; `--account` also fills any blank cells in
|
|
464
|
+
that column. In the model-evaluation workbook the brand is the Account cell
|
|
465
|
+
(`B1`), read like the Channel and Industry cells below it; there, a
|
|
466
|
+
`--account` that names another brand stops the run, since a cell left over
|
|
467
|
+
from the workbook it was copied from is as likely to be the mistake as the
|
|
468
|
+
flag. If any test is left without a brand, the run stops before spending a
|
|
469
|
+
single API call and names those tests. The brand appears in the report header
|
|
470
|
+
and in `lock.json`, so a saved run always says which brand it was scored for.
|
|
471
|
+
|
|
472
|
+
Country and language work the same way, with defaults: `--country` and
|
|
473
|
+
`--language`, or `country` (also `market`) and `language` (also `lang`)
|
|
474
|
+
columns for a file that mixes markets. Neither is needed for US English. A
|
|
475
|
+
run sends `US` and `en` unless told otherwise, the API's own defaults; for any
|
|
476
|
+
other country without a language, the API uses that country's language,
|
|
477
|
+
since a fixed `en` would score German copy as English. Both go into
|
|
478
|
+
`lock.json` and the report's "Sent as" line. `PERSADO_COUNTRY` and
|
|
479
|
+
`PERSADO_LANGUAGE` are no longer read; a run that finds them set stops and
|
|
480
|
+
names the flag to use.
|
|
481
|
+
|
|
482
|
+
Responses are cached in `.persado-benchmark/cache`, so an interrupted run
|
|
483
|
+
resumes without paying twice.
|
|
484
|
+
|
|
485
|
+
## Development
|
|
486
|
+
|
|
487
|
+
```bash
|
|
488
|
+
pip install -e '.[excel]'
|
|
489
|
+
python -m unittest discover -s tests -v
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
## Licence
|
|
493
|
+
|
|
494
|
+
[PolyForm Internal Use 1.0.0](https://github.com/persado/persado-benchmark/blob/main/LICENSE).
|
|
495
|
+
The source is open to read, but this is not an open-source licence. You may
|
|
496
|
+
use and change the tool for the internal business operations of your company,
|
|
497
|
+
which includes benchmarking Persado on your own A/B tests. You may not
|
|
498
|
+
distribute it, sell it, or offer it to others as a product or service.
|