File size: 9,888 Bytes
916a451
 
 
 
 
 
 
 
 
 
 
 
 
 
2e511b5
 
916a451
2e511b5
 
 
 
 
916a451
 
 
2e511b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6f5156a
 
 
 
 
2e511b5
 
6f5156a
2e511b5
 
 
 
 
 
6f5156a
 
2e511b5
 
 
6f5156a
2e511b5
 
 
6f5156a
2e511b5
 
 
 
6f5156a
2e511b5
 
 
 
 
 
 
6f5156a
2e511b5
 
 
6f5156a
 
c432715
 
 
 
 
 
916a451
2e511b5
 
916a451
2e511b5
916a451
 
 
 
2e511b5
916a451
2e511b5
 
 
 
 
6f5156a
 
2e511b5
 
 
 
 
6f5156a
 
2e511b5
 
 
6f5156a
2e511b5
 
 
 
 
 
916a451
2e511b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6f5156a
 
 
2e511b5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
---
license: mit
pretty_name: "LEGEX Reproduction Bundle: Code, Pipeline, and Analysis Outputs"
language:
  - en
tags:
  - legal
  - benchmark
  - llm-evaluation
  - information-extraction
  - reproducibility
viewer: false
---

# LEGEX — Reproduction Bundle (release/icml2026)

**LEGEX** is an expert-coded benchmark for civil-judgment review-table
extraction: judgments from the highest civil courts of 19 jurisdictions,
annotated by legal experts on a shared schema (monetary outcomes, cost
allocation, party structure, industry classification), against which we
evaluate two commercial review-table systems (Harvey, Legora) and two
schema-constrained LLM pipelines (Gemini, ChatGPT). This bundle is the
versioned code + data payload behind the paper *LEGEX: An Eight-Jurisdiction
Benchmark for Legal Review-Table Extraction* (ICML 2026 Workshop on AI for
Law); it contains an eight-jurisdiction core benchmark (≥100 judgments each,
double-annotated on a 28–30-case overlap) and eleven preview jurisdictions.

The release consists of three Hugging Face repositories, pinned to the
`release/icml2026` branch:

| Artifact | Contents | URL |
|---|---|---|
| `goldensets` | Expert gold labels, `data/<cc>/goldenset_<cc>.jsonl` | <https://huggingface.co/datasets/legexbenchmark/goldensets/tree/release/icml2026> |
| `inference-results` | System predictions, `data/<cc>/inference_{harvey,harvey_2,gemini,gpt,legora_1,legora_2}.jsonl`, plus the as-run per-column prompts of the commercial runs in `prompts/` | <https://huggingface.co/datasets/legexbenchmark/inference-results/tree/release/icml2026> |
| `code` | This bundle (package, scripts, shipped analysis outputs) | <https://huggingface.co/datasets/legexbenchmark/code/tree/release/icml2026> |

## Layout of this bundle

```
submission/
├── README.md                       this file
├── pyproject.toml · LICENSE · .env.template
├── legex/                          the LEGEX package, pruned to what the release uses:
│   ├── scrapers/                   one scraper per jurisdiction
│   ├── fulltext/                   full-text acquisition for the goldenset workbooks
│   ├── prompts/                    versioned system prompts (paper runs use v3)
│   ├── inference.py                legex-classify (LLM pipelines)
│   ├── harvey.py                   legex-harvey-ingest (review-table export ingest)
│   ├── evaluation/                 tolerant cell comparator + scoring engine
│   └── analysis/                   aggregates, IAA, AAT rendering, report, plots
├── scripts/                        paper-facing scripts (tables, figures, AAT adapter)
├── tests/                          unit tests (uv run pytest -q)
├── data/analysis/                  SHIPPED analysis outputs (see "Recompute" below)
│   ├── per_country_per_column.csv · per_country.csv · per_column.csv
│   ├── per_tradition.csv · per_language.csv
│   ├── quant_results.tex           paper Table tab:overall
│   ├── paper_tables.tex            tab:metrics-by-jurisdiction / tab:metrics-by-field
│   ├── tables/                     diversity.tex, currency_frequencies.tex, ...
│   ├── figures/                    isic_frequencies.pdf, legal_subject_wordcloud.png
│   ├── iaa/                        ANALYSIS.md, pairwise_agreement.csv, kappa_audit.csv,
│   │                               alt_test_pooled.csv, alt_test_reference_*.csv
│   ├── hallucinations/             hallucination_review_ch.csv (hand-classified error case study)
│   └── quality/                    by_country.csv, by_variable.csv
├── goldensets/                     1:1 copy of legexbenchmark/goldensets (dataset card + data)
├── inference-results/              1:1 copy of legexbenchmark/inference-results
├── convert_goldenset_to_jsonl.py   XLSX gold workbooks -> goldenset_<cc>.jsonl
├── build_inference_jsonl.py        cleaned working JSONL -> inference_<model>.jsonl
├── docs/Jurisdictions.md           per-jurisdiction research catalogue
└── HUGGINGFACE_UPLOAD.md           how this bundle maps onto the three HF repos
```

## Reproduce the paper tables and figures

All commands are run **from this directory** (the bundle root). Requires
[uv](https://docs.astral.sh/uv/) and Python ≥ 3.11.

```bash
uv sync
```

**Table `tab:overall` (headline metrics).** Re-render from the shipped
per-cell aggregate and check it is byte-identical to the shipped table:

```bash
uv run legex-quant-results --input data/analysis/per_country_per_column.csv --out /tmp/quant_results.tex
diff /tmp/quant_results.tex data/analysis/quant_results.tex
```

**Tables `tab:metrics-by-jurisdiction` and `tab:metrics-by-field`.**

```bash
uv run python scripts/paper_tables.py > /tmp/paper_tables.tex
diff /tmp/paper_tables.tex data/analysis/paper_tables.tex
```

**IAA / kappa / Alternative Annotator Test report** (`ANALYSIS.md`, the
source of the paper's `tab:iaa` and AAT numbers). The report is rendered
purely from the shipped CSVs:

```bash
uv run legex-analysis-report --iaa-dir data/analysis/iaa --analysis-dir data/analysis --out /tmp/ANALYSIS.md
diff /tmp/ANALYSIS.md data/analysis/iaa/ANALYSIS.md
```

**One-shot reproduction.** `scripts/reproduce_paper.sh` regenerates every
artifact under `data/analysis/` — IAA CSVs, scoring aggregates, all tables,
the diversity/frequency figures, the hallucination shares, and `ANALYSIS.md`
— from the published bundles in `goldensets/data/` and
`inference-results/data/`. The run is byte-stable, so a clean
`git status data/analysis` afterwards is the verification that the shipped
numbers reproduce:

```bash
bash scripts/reproduce_paper.sh
git status data/analysis
```

There are minimal known deviations from the submitted PDF. The gold labels are normalised during export to JSONL (controlled-token case, thousands separators, Excel dates → ISO), and the paper's tables were computed from the raw annotator workbooks before that normalisation, where, for example, a gold cell coded `Nonpecuniary` counted against a system answering the schema literal `nonpecuniary`. Re-scoring on the published gold therefore yields slightly higher values in a few places than the PDF: Philippines recall (+7–9 pp for every system), Spain (≈ +1 pp), `tab:overall` within ±0.2 pp, and the
money/ratio agreement rows of `tab:iaa` (+1–2 pp). The κ values, pair
counts, denominators, the hallucination case study, and all remaining
numbers match the PDF. The shipped outputs under `data/analysis/` are the
published-data regeneration. The deviations could not be resolved due to time constraints and are made transparent here.

## Unpublished raw data — scope

The expert-annotated XLSX workbooks (`data/<cc>/Goldenset_*_final*.xlsx`)
behind the goldensets are **not published**: Microsoft Office embeds author
metadata, and the re-annotation assignment structure could identify
individual annotators. The gold *labels* are published in full as
`goldensets/data/<cc>/goldenset_<cc>.jsonl` (primary + anonymized secondary
annotator rows), and every analysis in this bundle runs from those published
files — the workbooks are not needed for reproduction.

**Alternative Annotator Test (AAT).** The AAT (Calderon, Reichart & Dror,
ACL 2025, [arXiv:2501.10970](https://arxiv.org/abs/2501.10970)) is run with
the authors' original implementation via the adapter
`scripts/alt_test_reference.py`, which extracts `alt_test()` from the
upstream notebook at runtime and feeds it LEGEX data from the published
bundles:

```bash
git clone https://github.com/nitaytech/AltTest /tmp/AltTest
ALTTEST_DIR=/tmp/AltTest bash scripts/reproduce_paper.sh   # or:
uv run python scripts/alt_test_reference.py --alttest /tmp/AltTest \
    --gold-dir goldensets/data --inference-dir inference-results/data \
    [--countries ge,sg,tw] [--epsilon 0.2] [--out data/analysis/iaa] [--per-field]
```

Its outputs (`alt_test_pooled.csv`, `alt_test_reference_*.csv`) are shipped
under `data/analysis/iaa/` and rendered into `ANALYSIS.md` by
`legex-analysis-report`.

## Scraping

The scrapers that built the corpus are included (`legex/scrapers/`, one file
per jurisdiction; see `docs/Jurisdictions.md` for the per-country catalogue).

```bash
cp .env.template .env   # then fill in what you need
uv run legex-run
```

`legex-run` executes the idempotent pipeline (scrape → filter/sample →
fill goldenset → dist) for every registered jurisdiction and skips countries
whose access is not set up or whose output already exists. Some sources need
manual prerequisites (all keys go into `.env`, see
[.env.template](.env.template)):

- **Hugging Face** (`au`, `ch`, `de`, `us`): a read token as `HF_TOKEN`;
  `de` and `us` additionally require accepting the gated-dataset terms of
  `openlegaldata/court-decisions-germany` and
  `free-law/Caselaw_Access_Project`.
- **France**: register at <https://piste.gouv.fr>, subscribe to the
  Judilibre API, set `JUDILIBRE_CLIENT_ID` / `JUDILIBRE_CLIENT_SECRET`.
- **New Zealand**: copy the WAF cookie from a justice.govt.nz session into
  `NZ_WAF_COOKIE`.
- **India**: `legex-india-extract` pulls selected PDFs from the AWS Open
  Data TAR archives (see `legex/scrapers/in_.py`).

Model inference over the scraped full texts (the paper runs use prompt v3):

```bash
uv run legex-classify --model <model> --full_text --prompt_version v3
```

Tests: `uv run pytest -q`.

## Citation

```bibtex
@inproceedings{legex2026,
  title     = {{LEGEX}: An Eight-Jurisdiction Benchmark for Legal Review-Table Extraction},
  author    = {K{\"o}nig, Adrian and others},
  booktitle = {ICML 2026 Workshop on AI for Law (AI4Law)},
  year      = {2026},
  url       = {https://huggingface.co/legexbenchmark}
}
```

## License

MIT. See [LICENSE](LICENSE).