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.6.0

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.6.0
File Size Uploaded Provenance Actions
contractex-0.6.0.tar.gz 293.3 kB With provenance Details for contractex-0.6.0.tar.gz

Built distribution (wheel)

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

Total release size: 517.6 kB

Release files / contractex-0.6.0.tar.gz

Download URL contractex-0.6.0.tar.gz
Size 293.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2ec66dece9d6fc55662dce93684f3d084f2d3c5493fbc03277fc5f982b0d4c8c
BLAKE2b-256 checksum
How to use checksums
cef8b0ede7ec0a3ebf0f8ca91aac4f908af106dc103c3d5c762db51b75143ad1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 14, 2026.

Transparency log

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

Download URL contractex-0.6.0-py3-none-any.whl
Size 224.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba30efa02cf4a8216f8200a60f61973645a9746b309490b06a106fc6209861b4
BLAKE2b-256 checksum
How to use checksums
f3ed19f8f964f6d1b6bea305fee522d1c20d582a3add77bc46e58e196a94c366
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 14, 2026.

Transparency log

Security for contractex 0.6.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for contractex-0.6.0.tar.gz

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 Nov 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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