code / README.md
anonymous
[code] Initial release of the code.
6f5156a
metadata
license: mit
pretty_name: 'LEGEX Code: Scrapers, Inference and Evaluation Pipeline'
tags:
  - legal
  - benchmark
  - code
  - llm-evaluation
  - information-extraction

LEGEX Code, Scrapers, Inference and Evaluation Pipeline

Python source for the LEGEX benchmark of civil-judgment review-table extraction. This repository contains:

Setup

git clone https://huggingface.co/datasets/legexbenchmark/code legex-code
cd legex-code
uv sync
cp .env.template .env

Required tokens depend on which scrapers / models you run, see .env.template.

End-to-end workflow

# Acquire raw judgments per jurisdiction.
uv run legex-run

# Run inference for one system on one jurisdiction, Harvey has do be done separately as this is a commercial tool
uv run legex-classify --country us --model gpt-5.4-mini --full_text

# Evaluate one system on one jurisdiction.
uv run legex-evaluate --country us --system gpt

# Aggregate across all 12 evaluated jurisdictions and 3 systems.
uv run legex-analysis --out data/analysis

# Render the paper-headline LaTeX table.
uv run legex-quant-results \
    --input data/analysis/per_country_per_column.csv \
    --out   data/analysis/quant_results.tex

To evaluate against the published goldensets and inference outputs, pull the two data repos into the expected layout:

huggingface-cli download legexbenchmark/goldensets         --repo-type dataset --local-dir data --include "data/*"
huggingface-cli download legexbenchmark/inference-results  --repo-type dataset --local-dir data --include "data/*"
# After these, data/<cc>/ contains goldenset_<cc>.jsonl + inference_*.csv
uv run legex-analysis --out data/analysis

CLI entrypoints

Command Module Purpose
legex-run legex.main:main Top-level scrape + filter + sample pipeline.
legex-classify legex.inference:main Run an LLM over the goldenset and write predictions to CSV.
legex-harvey-ingest legex.harvey:main Ingest a Harvey Vault Review export into the per-jurisdiction CSV format.
legex-evaluate legex.evaluation:main Per-country, per-field bucket counts and recall / hallucination.
legex-analysis legex.analysis:main Cross-jurisdiction analysis → CSV + LaTeX tables.
legex-quant-results legex.quant_results:main Paper-headline summary from the analysis CSV.
legex-pdf legex.pdf_export.cli:main Render per-row PDFs from a goldenset workbook.
legex-plots legex.plots:main Plot helpers used in the paper.

License

MIT.