code / README.md
anonymous
Document known deviations of re-scored numbers from the submitted PDF
c432715
|
Raw History Blame Contribute Delete
9.89 kB
---
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).