Skip to main content

PyPI Python Tests License

Contractex

Contractex is a Python library for legal document intelligence. It provides the processing layer that legal AI products are built on: chunking, extraction, retrieval, privacy enforcement and quality measurement. It is not an application.

Most serious legal tooling is closed-source or built in-house at large firms. That leaves small practices, clinics and advice organisations dependent on vendors. An open, auditable processing layer lets them build their own, and measure whether it is accurate enough to rely on.

pip install contractex

Design principles

Principle In the code Measured by
The deterministic/probabilistic boundary is explicit. Every task declares whether it calls a model; the task table says what happens when the output is poor. Structure parsing, PII detection, citation extraction, classification and playbook checks make no model calls. Tests on the deterministic parts; the evaluation harness for the rest.
Every extracted value is traceable to its source. ClauseAwareChunker returns exact substrings; ProvenanceTracker resolves a value to character offsets in the original document. Provenance benchmark on CUAD.
Privacy is enforced in code at the call site. A PrivacyProfile on each document; PrivacyAwareLLMRouter blocks, rejects or redacts on every model call made by tasks, pipelines and RAG. No provider is ever chosen for you. Routing matrix and privacy tests.
Quality is measurable and gateable. EvalHarness scores any extraction function against labelled suites; assertions fail CI when accuracy drops. The benchmarks, regenerated by one command and checked in CI.

What Contractex refuses to do

  • Put the text of a secret document into any model prompt.
  • Send a restricted document to anything but a local model (LocalProvider).
  • Send confidential or restricted text to a model without redacting the personal data it detects.
  • Choose a model vendor for you: a task that needs a model and was not given one raises an error.
  • Install any model vendor's SDK unless you ask for it.

Where it stops

Without Presidio installed, names are not detected. Scanned PDFs need OCR. Chunking and citation patterns are English-centric. The Limitations page lists everything known.

Start here

  • Installation: what to install for your setup.
  • Quick start: parse, redact, chunk and run tasks on a sample NDA.
  • Privacy model: what each sensitivity level enforces, and where.
  • Benchmarks: chunking, provenance and privacy, measured.

Contractex is open source under the Apache License 2.0 and maintained by Quiet Signals Lab.

Measured

Generated by python -m benchmarks and checked in CI.

Measured on Result
Gold clause spans kept in one chunk (102 CUAD contracts, 512-token chunks) clause aware 98.9% · semantic 95.5% · fixed window 88.6%
Verbatim values traced to the right place in the source 97.2%
Privacy routing checks (4 sensitivity levels × 2 providers × 4 entry points) 32 of 32 pass

Changelog · Contributing · Security

Metadata

Release files for contractex 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for contractex 0.5.1
File Size Uploaded
contractex-0.5.1.tar.gz 210.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for contractex 0.5.1
File Interpreter ABI Platform
contractex-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 439.0 kB

Release files / contractex-0.5.1.tar.gz

Download URL contractex-0.5.1.tar.gz
Size 210.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8f10e4e523e50a3ca84f8d35774c37daf96cfbc6ce949b3b2094aad40bd06b7e
BLAKE2b-256 checksum
How to use checksums
d50dbe90369c3b7beda80d9cf8d1be0b24e72abb79b2e7bbb07406b1812a93ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release files / contractex-0.5.1-py3-none-any.whl

Download URL contractex-0.5.1-py3-none-any.whl
Size 228.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f51016e8d2dc2ea37c0cd3ac0018e0c88fee5efa08a2b7a2850d786d0167bf3
BLAKE2b-256 checksum
How to use checksums
35081e1834dd17455b8cf4a18386f0c7a4f38177e6d7539b9547779bf3e91224
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page