packed-contracts / README.md
LarrisX's picture
Update README.md
fb3a899 verified
|
Raw History Blame Contribute Delete
4.33 kB
---
language: en
license: cc-by-4.0
pretty_name: Packed-contracts long document test
task_categories:
- text-classification
tags:
- long-context
- decision-model
- benchmark
- legal
- kev
size_categories:
- 1K<n<10K
viewer: true
---
# Packed contracts
A long context test for decision models: pack several real contracts into one review file and ask about **every**
contract in it, not one needle.
121 commercial contracts from [CUAD](https://www.atticusprojectai.org/cuad), each with the questions of
[Kev](https://github.com/jaredpalmer/kev)'s long-document contract benchmark: two "does the contract contain this
clause?" questions, a clause-category choice and, where the governing law is a common one, a jurisdiction choice.
Labels are CUAD's lawyer annotations. The same contracts are asked alone, then packed into review files of 16k, 32k and
64k tokens, holding about 3, 7 and 14 contracts each. Because every contract is also asked alone, accuracy at each
length pairs with the same model's score on the contract by itself.
Packing hurts far less here than on [packed-complaints](https://huggingface.co/datasets/LarrisX/packed-complaints),
where a 64k input holds about 246 short complaints: here it holds about 14 long, distinctively named contracts.
## Reference scores
Accuracy over all 1,773 questions, scored with Kev's own scorer. Runs are from the
[code repo](https://github.com/Profilist/kev-selfteach); none of them trained on CUAD.
| Model | Alone | 16k (3) | 32k (7) | 64k (14) |
|---|---|---|---|---|
| [Kev-0.8B 1.0](https://huggingface.co/jaredpalmer/kev-0.8b) | 0.709 | 0.683 | 0.639 | 0.620 |
| Self-taught on complaints (`fresh-32k`, mean of 2 runs) | 0.712 | 0.732 | 0.694 | 0.667 |
| Self-taught, plus ContractNLI NDAs (`fresh-32k-ndas`) | 0.729 | 0.735 | 0.708 | 0.701 |
| Same, with Kev-27B as the teacher (`fresh-32k-ndas-kev27b`) | 0.744 | 0.733 | 0.710 | 0.732 |
| Trained on real complaint labels (`labels-32k`) | 0.714 | 0.718 | 0.694 | 0.691 |
## Contents
One suite, `packed-contracts-v0/`, in Kev's format (`manifest.json` + `development.jsonl`), scored with `kev.benchmark --suite`.
`index.json` maps each record to its length and contracts.
| Length | Review files | Contracts per file |
|---|---|---|
| alone | 121 | 1 |
| 16k | 37 | about 3 |
| 32k | 17 | about 7 |
| 64k | 8 | about 14 |
207 records in all: a long file's questions are split into groups that share the file, so Kev's scorer fits in GPU
memory; every question is still answered on its own. A record is one review file (`state`) and its questions, each
naming its contract by title:
```json
{"state": "Contract review file: 1 commercial contracts filed with the SEC, in no particular order.\n\n===== Contract 1 of 1: 2ThemartComInc_19990826_..._Co-Branding Agreement_ Agency Agreement =====\n...",
"questions": {"...": {"type": "noul",
"instructions": "Consider only the contract titled \"2ThemartComInc_..._Co-Branding Agreement_ Agency Agreement\" in this file. Does one party ...",
"label": true}, "...": "..."}}
```
## How it was built
- **Contracts.** CUAD v1 (`theatticusproject/cuad` @ a3c393f), at most 7,500 tokens each. Only the contracts that Kev's
long-document benchmark (longdoc-v1) assigns to its **development** partition are used, dealt with Kev's own
function, so its locked test contracts are never included. Contracts from one company never share a file.
- **Questions and labels.** Kev's longdoc-v1 builder (`scripts/build_longdoc_v1.py` @ a0255ce), with CUAD's lawyer
annotations as labels. No model is involved in labelling.
- **Packing.** Whole contracts packed first-fit into review files filling 70–93% of their nominal length under the
Qwen3.5 tokenizer, in a fresh random order at every length.
## Licence and credit
CC BY 4.0, as CUAD. Changes from CUAD: contracts selected as above, set in Kev's review-file layout, packed into files of
16k–64k tokens, and given Kev's questions.
- **CUAD:** Dan Hendrycks, Collin Burns, Anya Chen and Spencer Ball, "CUAD: An Expert-Annotated NLP Dataset for Legal
Contract Review", NeurIPS 2021 Datasets and Benchmarks; The Atticus Project. CC BY 4.0.
- **Kev** by Jared Palmer (Apache-2.0): the review-file layout, the question wording and the partition dealing.