法律检索库

LLM Law Library 是一个免费开源的法律研究基础设施,提供美国法院意见、法规、法律定义和法院规则的检索服务,适用于法律专业人士、研究人员及AI智能体的法律信息查询与验证。

  • by giblfiz
  • Python
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 giblfiz/llm-law-lib

使用说明

LLM Law Library

Open legal research infrastructure for humans and AI. It retrieves real US court opinions, statutes, statutory-definition pointers, and court rules without a subscription. Retrieval does not replace legal judgment: a real citation can still be irrelevant, mischaracterized, stale, or attached to noncontrolling text.

Free. Open. Primary-source grounded.

Only have a chat window and web access? Open For Chat-Window LLMs. It contains complete GET URLs and usable research recipes; no tool installation or skill loader is required.

What's In The Box

Component Coverage Details
Caselaw 10.9M opinions, 76.9M passages All 50 states + federal. Semantic vector + BM25 lexical + hybrid search.
Statutes 2.34M sections, 52 jurisdictions All 50 states + DC + federal (US Code). BM25 deterministic search.
Definitions 882K pointers, 215K unique terms Where each legal term is statutorily defined, across jurisdictions.
Treatment signals 29.5M treatment rows Automated leads about how later courts discussed earlier cases. Not a good-law verdict.
Red Flags 10.8K signals Terms used in statutes but not defined — gaps requiring investigation.

Data Sources

Access

MCP Server (Claude Code / Claude Desktop)

The llm-law-library MCP server exposes 12 tools:

Tool Description
caselaw_search Search court opinions — hybrid/bm25/vector modes
caselaw_case Load full opinion text by ID
caselaw_shepardize Inspect automated later-treatment signals
statute_search Search statutory codes (all 52 jurisdictions)
statute_section Load full statute section text + definitions + red flags
court_rule_search Search federal, state, and local court rules
court_rule_section Load a full court rule and its subsection tree
court_rule_browse Navigate a rule-set hierarchy
term_search Look up where a legal term is defined across states
jurisdiction_terms List all defined terms for a jurisdiction
law_library_help Built-in documentation and usage guide
law_library_stats Index statistics

URL-only GET API

Every research read is available as an ordinary GET URL for capable models that can browse the web but cannot install MCP or send POST bodies. See For Chat-Window LLMs for copyable URLs and complete research plans.

JSON POST API

Base URL: https://implausible.enterprises/api/caselaw/

Endpoint (relative to the base URL) Method Description
search GET or POST Caselaw search (mode: bm25/vector/hybrid)
case GET or POST Full opinion text
caselaw/verify GET or POST Resolve a single citation and return treatment signals
caselaw/verify-brief POST only Extract and verify citations in long text
statute/search GET or POST Statute search
statute/section GET or POST Full statute section
term/search GET or POST Term/definition lookup
term/jurisdiction GET or POST Jurisdiction term list
court_rule/search GET or POST Court-rule search
court_rule/section GET or POST Full court rule
court_rule/browse GET or POST Browse a rule-set hierarchy
stats, health, help GET Service information

Web UI

https://implausible.enterprises/projects/law-library/

Key Concepts

Shepardizer

Named after Shepard's Citations (1873). Tracks how later courts treated earlier decisions. Built from the CourtListener citation graph: 3.7M classified treatments across 16 granular types.

Severity hierarchy: overruled > abrogated > reversed > vacated > superseded > questioned > distinguished > limited > criticized > modified

Treatment fields are automated leads derived from citation-graph and opinion-text analysis. They can be noisy or misattributed and must not be reported as a good-law conclusion without inspecting the later opinions and checking an authoritative citator where the stakes require it.

Red Flags (Used-But-Undefined)

The most dangerous gap in legal research is a definition you don't know exists. A lawyer briefs the ordinary meaning of a term, but the statute defines it to include or exclude key categories.

Red flags detect this: a term is heavily used in a jurisdiction's statutes but has no statutory definition found there. Four possible causes:

  1. Cross-reference gap — definition exists in a general definitions chapter we haven't linked
  2. Cross-reference we missed — "fiduciary has the meaning given in 15 U.S.C. § 80a-2"
  3. Common-law reliance — legislature intentionally uses common-law meaning (legitimate, worth flagging)
  4. Recall gap — we missed something in extraction

All four are worth surfacing. Cases 1-2 are actionable; case 3 is informative; case 4 improves the system.

Definition Pointers

We store where terms are defined, not the definitions themselves. "Person" might have 40 different statutory definitions across 30 jurisdictions, each with different scope ("as used in this chapter," "for purposes of this title," etc.). We point you to the right section; you read it in context.

Signal types (trust hierarchy, highest first):

  • xml_structured — from authoritative XML source (federal USLM)
  • caselaw_cite — found in court opinions citing the statute as defining this term
  • bm25_pattern — found via BM25 phrase search (linking phrases: "means," "shall include," etc.)
  • flash_classification — LLM-classified definition section
  • red_flag — term used but not defined in this jurisdiction

Search Modes (Caselaw)

Mode Best For How It Works
hybrid (default) General legal research Fuses BM25 + vector via Reciprocal Rank Fusion
bm25 Exact citations, party names Deterministic lexical search — same query always returns same results
vector Conceptual queries Semantic similarity via 384-dim embeddings

Determinism matters for auditability. BM25 makes the same lexical query reproducible; that is useful evidence of what was searched, not a guarantee that the search was complete or legally adequate.

Jurisdiction Codes

  • Federal: federal
  • States: state:XX where XX is the two-letter code (e.g., state:CA, state:NY, state:TX)
  • DC: state:DC

All 50 states + DC + federal are loaded and searchable.

Architecture

Client (MCP/API/Web)
  -> fauna-box API (port 8030, LRU cache, CORS)
  -> HTTP -> Mac server (port 8031, embedding model in memory)
  -> PostgreSQL 17 + pgvector + ParadeDB pg_search

Two-box architecture: fauna-box runs the API/proxy/MCP layer; Mac hosts the PostgreSQL corpus with pgvector and ParadeDB.

Database Tables

Caselaw

  • rag_passages — 76.9M passages with 384-dim embeddings
  • opinion_search — 10.9M opinions, denormalized BM25 index
  • shepardizer_treatment_v2 — 29.5M treatment rows

Statutes

  • statute_search — 2.34M sections with BM25 index, all 52 jurisdictions

Definitions

  • definition_pointers — 882K rows, where terms are defined
  • term_registry — 215K unique legal terms
  • extracted_definitions — 715K extracted definition records
  • definition_embeddings — 135K definition embeddings for alias discovery
  • statute_embeddings — 1.79M statute section embeddings
  • term_aliases — 160 LLM-confirmed cross-state term aliases

Scripts

Shepardizer v2

  • scripts/shepardizer-v2-pass1.py — Citation graph + regex treatment classification
  • scripts/shepardizer-v2-pass2.py — Haiku verification of treatments
  • scripts/shepardizer-v2-gemini-grinder.py — Gemini Batch verification (50% cheaper)
  • scripts/shepardizer-driver.py — Autonomous verification driver

Definition Discovery

  • scripts/statutes/bm25_definition_seed.py — BM25 phrase search across statute corpus
  • scripts/statutes/batch_classify_all.py — Gemini Batch API classification
  • scripts/statutes/batch_extract_all.py — Gemini Batch API extraction
  • scripts/statutes/batch_red_flags_all.py — Used-but-undefined scan (SQL only, no LLM)
  • scripts/statutes/{xx}_full_cook/ — Per-state processing directories

BM25

  • scripts/bm25/01_schema.sql — opinion_search table + extraction function
  • scripts/bm25/03_index.sql — BM25 index with field boosts
  • scripts/bm25/run_eval.py — Evaluation harness (30 queries)

License

Caselaw corpus: CC0 (CourtListener/Free Law Project). Statutory text: Public law, not copyrightable. Code: This project.