How I test contract extraction

Real contracts are confidential, so they cannot be used to test a contract-reading tool in the open. I generate fictional contract stacks that come with an answer key, run extractors over them, and score what comes back against the key. This page reports what I measured, the command behind each number, and what the numbers do not show.

The test set

The answer keys and the document texts are in docs/results/2026-11/corpus-25. The counts above are read from score-qwen-7b-25.json, which the scoring command below writes.

Three extractors, one scorer

Both models got the same prompt, one document at a time, at temperature 0, and then one more call over a summary of the whole stack to flag the planted problems. An item counts as right only when it matches the key: the same party, the same document, the same section. F1 is the balance of precision (how much of what was produced is in the key) and recall (how much of the key was produced); 1.00 is perfect.

F1 against the answer key. The first three columns of figures cover all 25 stacks; the last two cover the 5 stacks both models read.
Item In the key Pattern rules qwen-7b qwen-7b, 5 stacks mistral-24b, 5 stacks
Parties 61 0.77 0.95 1.00 1.00
People 110 0.51 0.93 0.93 1.00
Obligations (who owes what to whom, in which document) 458 0.31 0.56 0.57 0.61
Amendment amends agreement 183 0.76 0.99 1.00 1.00
New section replaces old section 246 0.00 0.29 0.27 0.29
Person signs document 479 0.60 0.99 1.00 1.00
Party is a party to document 483 0.64 0.84 0.87 0.84
Master cites attached exhibit 100 0.43 0.04 0.11 0.62
Planted problems and invented links.
Pattern rules qwen-7b qwen-7b, 5 stacks mistral-24b, 5 stacks
Planted problems noticed 11 of 67 56 of 67 10 of 12 12 of 12
Alarms where nothing was planted 0 94 17 10
Reading chosen matches the house rule 0 of 67 0 of 67 0 of 12 0 of 12
Links produced that are not in the key 0 371 65 72
Links in the key that were missed 933 287 52 44

fabric8r score --truth docs/results/2026-11/corpus-25 --extraction docs/results/2026-11/ext/rules --json docs/results/2026-11/score-rules-25.json, the same with ext/qwen-7b for qwen-7b, and the two-model command in the next section for the last two columns.

What I take from the tables:

What disagreement between two models tells you

A common shortcut is to run two models and send a person only the items they disagree on. I measured what that catches on the 5 stacks both models read (65 documents, 540 items in the key).

Items either model produced, by whether the other produced it too.
Items Not in the key Share wrong
Both models produced it 500 65 13.0%
Only one model produced it 101 67 66.3%

fabric8r study --truth docs/results/2026-11/corpus-25 --a docs/results/2026-11/ext/qwen-7b --b docs/results/2026-11/ext/mistral-24b --json docs/results/2026-11/study-qwen-7b-mistral-24b-5.json

Three failures, traced

Reading the wrong items one by one, three causes account for much of what the tables show.

  1. Parties attached to documents nobody signs. Both models list the main parties as parties to exhibits, notices and emails. Of the 123 party-to-document links that both models produced, 23% were wrong, nearly all in this one way. Same prompt, same mistake, so the two models agreed and disagreement gave no signal.
  2. A file name where the chosen reading belongs. For each planted problem the model is asked which reading the house rule picks. Both models wrote a file name in that field almost every time, so the score for the chosen reading is 0 of 67. That is a failure of the answer format. It does not yet say whether the models can apply the rule.
  3. Cross-references not found. qwen-7b produced 2 of the 100 links from a master to its attached exhibits, where the pattern rules, which read file names and titles, found 27.

Fixing the three, and measuring again

I kept the old prompt as version 1 and wrote a version 2 that changes only what the three failures needed, with each change switchable so it could be measured alone. I tuned it on the five stacks above, froze it, and then ran it once on the 20 stacks the tuning never saw. Every figure in this section is from those 20 stacks (284 documents), qwen-7b, one run per version on the same night.

Before and after, on stacks the tuning never saw.
Version 1 Version 2
Party-to-document links produced (the key has 388) 543 401
Of those, in the key 388 388
Master linked to attached exhibit, found of 82 3 34
Planted problems: items the model raised 121 38
Planted problems: raised items that match nothing planted 77 5
Planted problems matched on kind and document, of 55 22 14
Of those, read the way the house rule reads them 0 13
People named: recall 0.93 0.91
Obligations: F1 0.57 0.54
Links produced that are not in the key 305 153

fabric8r extract docs/results/2026-11/corpus-25 --method local-llm --model qwen-7b --prompt-version 2 --except rel-002,rel-006,rel-008,rel-009,rel-013 --out docs/results/2026-11/b1/held20/qwen-7b/v2, then fabric8r score with the same --except. Version 1 is the same command without --prompt-version 2.

What I take from it:

A review table, scored cell by cell

A review table asks the same questions of every document set and fills a grid, each cell tied to its source. The hard cell is the one whose answer sits in another file: a fee, a term end or a party name that a later amendment changed. I built that test on the same 25 stacks: seven questions per stack (status, term end, current fee, payment days, each party's current legal name, assignee), each with an answer and a verbatim quote, 175 cells in all. The answer key knows which document set each current answer, so every result splits in two: 102 cells whose answer a later document changed, and 73 cells where the master's answer still stands.

The reader is mistral-24b. It was run twice: once shown the whole stack, and once shown only the master agreement, which is what a table gets when each document is read on its own.

Share of cells right. A cell left blank counts as wrong.
Master only Whole stack
Answers: cells a later document changed 2% (2 of 102) 78% (80 of 102)
Answers: cells never changed 95% (69 of 73) 90% (66 of 73)
Wrong answers on changed cells that gave an earlier, replaced value 63 7
Verbatim quotes: cells a later document changed 0% (0 of 98) 69% (68 of 98)
Verbatim quotes: cells never changed 93% (51 of 55) 85% (47 of 55)
Quotes given that are exact text from some document in the stack 134 of 139 148 of 152

A quote is right only when it is exact text, character for character, from the file that holds the current answer, and overlaps the key's evidence for it. fabric8r grid run docs/results/2026-11/corpus-25 --model mistral-24b --mode stack --out docs/results/2026-11/b2/mistral-24b-stack (and --mode master-only), then fabric8r grid score --truth docs/results/2026-11/corpus-25 --grid docs/results/2026-11/b2/mistral-24b-stack --json docs/results/2026-11/grid-mistral-24b-stack.json.

Checking a model judge against the answer key

Teams that use a model to grade output can usually check the grader only against a sample of human grades. Here the answer is known, so the judge itself can be scored. The judge was shown one extracted obligation (who owes what to whom) with the paragraph it cites, and asked: supported, or not supported? Then every obligation the key confirms was turned into a wrong one by swapping who owes whom, and judged again; the right answer to each of those is "not supported". Last, the right claim and its swap were shown side by side, in both orders.

Two judges on the same items: the obligations qwen-7b extracted from all 25 stacks.
qwen-7b as judge (the model that did the extraction) mistral-24b as judge
Verdict agrees with the key, on items the key can grade 85% (211 of 247) 85% (210 of 247)
Right items the judge failed 5% (10 of 204) 9% (18 of 204)
Swapped claims the judge passed as supported 31% (63 of 204) 37% (76 of 204)
Side by side: the pick changed when the order changed 17% (34 of 204) 31% (63 of 204)

python -m fabric8r.judge run --truth docs/results/2026-11/corpus-25 --extraction docs/results/2026-11/b1/qwen-7b-v1 --judge-model qwen-7b --out docs/results/2026-11/b3/judge-qwen-7b-on-qwen-7b-v1, then python -m fabric8r.judge score --judged ... --json docs/results/2026-11/judge-qwen-7b-on-qwen-7b-v1.json; the same with --judge-model mistral-24b. Of the 444 obligations extracted, the key could grade 204 as right and 43 as wrong; the rest sit in passages the key lists no obligation for, or quote text that is not in the document, and are left out.

Limits

Reproduce

The repository is private; I am glad to walk through it, or to run any of these live.

fabric8r extract docs/results/2026-11/corpus-25 --method rules --out docs/results/2026-11/ext/rules
fabric8r extract docs/results/2026-11/corpus-25 --method local-llm --model qwen-7b --out docs/results/2026-11/ext/qwen-7b
fabric8r score --truth docs/results/2026-11/corpus-25 --extraction docs/results/2026-11/ext/rules --json docs/results/2026-11/score-rules-25.json
fabric8r score --truth docs/results/2026-11/corpus-25 --extraction docs/results/2026-11/ext/qwen-7b --json docs/results/2026-11/score-qwen-7b-25.json
fabric8r study --truth docs/results/2026-11/corpus-25 --a docs/results/2026-11/ext/qwen-7b --b docs/results/2026-11/ext/mistral-24b --json docs/results/2026-11/study-qwen-7b-mistral-24b-5.json
fabric8r extract docs/results/2026-11/corpus-25 --method local-llm --model qwen-7b --prompt-version 2 --except rel-002,rel-006,rel-008,rel-009,rel-013 --out docs/results/2026-11/b1/held20/qwen-7b/v2
fabric8r score --truth docs/results/2026-11/corpus-25 --extraction docs/results/2026-11/b1/held20/qwen-7b/v2 --except rel-002,rel-006,rel-008,rel-009,rel-013 --json docs/results/2026-11/b1-qwen-7b-v2-held20.json
fabric8r grid run docs/results/2026-11/corpus-25 --model mistral-24b --mode stack --out docs/results/2026-11/b2/mistral-24b-stack
fabric8r grid score --truth docs/results/2026-11/corpus-25 --grid docs/results/2026-11/b2/mistral-24b-stack --json docs/results/2026-11/grid-mistral-24b-stack.json
python -m fabric8r.judge run --truth docs/results/2026-11/corpus-25 --extraction docs/results/2026-11/b1/qwen-7b-v1 --judge-model qwen-7b --out docs/results/2026-11/b3/judge-qwen-7b-on-qwen-7b-v1
python -m fabric8r.judge score --judged docs/results/2026-11/b3/judge-qwen-7b-on-qwen-7b-v1 --json docs/results/2026-11/judge-qwen-7b-on-qwen-7b-v1.json
python scripts/build_results_page.py --results docs/results/2026-11 --template docs/results/2026-11/page.template.html --out docs/results/2026-11/index.html

Every figure on this page is read from the result files by the last command; none is typed by hand. The first three sections were measured in September 2026; the last three on 14 and 15 November 2026.