Metadata-Version: 2.4
Name: legal-citation-check
Version: 0.1.0
Summary: Verifies whether a legal citation exists and supports the proposition it is offered for. Not a legal-advice tool.
Author: LegalCiteCheck contributors
License: Apache-2.0
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch==2.4.1
Requires-Dist: transformers==4.44.2
Requires-Dist: sentencepiece==0.2.0
Requires-Dist: peft==0.12.0
Requires-Dist: trl==0.9.6
Requires-Dist: accelerate==0.33.0
Requires-Dist: bitsandbytes==0.43.3
Requires-Dist: datasets==2.21.0
Requires-Dist: eyecite==2.6.4
Requires-Dist: courts-db==0.10.20
Requires-Dist: reporters-db==3.2.53
Requires-Dist: pyarrow==17.0.0
Requires-Dist: polars==1.7.1
Requires-Dist: pandas==2.2.2
Requires-Dist: gradio==4.44.0
Requires-Dist: wandb==0.17.9
Requires-Dist: python-dotenv==1.0.1
Requires-Dist: requests==2.32.3
Requires-Dist: pypdf==5.0.1
Requires-Dist: pyyaml==6.0.2
Provides-Extra: dev
Requires-Dist: pytest==8.3.2; extra == "dev"
Requires-Dist: ruff==0.6.4; extra == "dev"
Dynamic: license-file

# LegalCiteCheck

Checks whether a legal citation exists and whether the cited authority actually
supports the proposition it's offered for. It does not check the law itself.

> **Automated verification only. Not legal advice.** Every citation flagged or
> cleared here must be independently confirmed by a licensed attorney before
> filing. Jurisdiction: US federal and state case law only.

## Status

Core pipeline built and working end-to-end: corpus ingestion, label
synthesis, encoder training, decoder (explanation) training, the
verification pipeline, and the CLI. See
`docs/LegalCiteCheck_Architecture_Spec.md` for the full build plan and
`docs/LegalCiteCheck_Research_Report.md` for the rationale.

**Trained artifacts:**
- `legalcite-support-base` (primary) — DeBERTa-v3-base, 4-way citation
  support classifier. Held-out macro F1 0.9377, false-negative rate
  0.0475. See `model_cards/encoder-support-base.md` for full eval
  numbers and known limitations, including a documented
  out-of-distribution generalization gap on synthetically-phrased
  propositions.
- `legalcite-explain-7b-lora` (secondary) — Qwen2.5-7B-Instruct QLoRA
  adapter that explains (never decides) the encoder's label. See
  `model_cards/explain-7b-lora.md`.

**Not yet done:** publishing the trained weights to Hugging Face Hub
(the CLI's model-path default is currently a placeholder), publishing to
PyPI, the GitHub Action / LangChain tool / LlamaIndex pack integrations,
a demo Space, and the LePhantomCite/CaseHOLD benchmark integrations.

## What this is not

Not a legal chatbot, not a research tool, not a source of legal recommendations.
It never suggests an alternative citation and never produces argument text. See
`docs/LegalCiteCheck_Architecture_Spec.md` section 0 for the full non-goal list.

## Setup

```bash
python -m venv .venv
source .venv/bin/activate   # or .venv\Scripts\activate on Windows
pip install -e ".[dev]"
cp .env.example .env         # fill in COURTLISTENER_API_TOKEN and CONTACT_EMAIL
pytest
```

Some tests (`test_citegraph.py`, `test_pipeline.py`, `test_train_lora.py`)
require the full dependency stack (`torch`, `transformers`, `eyecite`,
etc.) and are skipped in a lightweight dev install.

## Usage

```bash
legalcite check brief.pdf --json
```

Exits non-zero if any citation is found to be `FABRICATED` (CI-gate
friendly). Requires a trained encoder (`--model-path`, or
`LEGALCITE_MODEL_PATH`) and, for fast/free existence lookups, a local
citation index (`--index-path`, or `LEGALCITE_INDEX_PATH`) — without an
index configured, every citation falls through to the CourtListener API,
which is rate-limited to 125 requests/day.

## Repository layout

Tracks `docs/LegalCiteCheck_Architecture_Spec.md` section 2:
`src/legal_citation_check/{ingest,gen,models,verify,train,eval}`,
`configs/`, `model_cards/`, `integrations/`, `tests/`.
