Skip to main content

A linter for your RAG knowledge base

Project description

corpuslint

PyPI version Python versions License: MIT

A linter for your RAG knowledge base. RAGAS & co. evaluate the answer. corpuslint evaluates the data that feeds it — before it reaches your users.

Why

Most bad RAG answers are a corpus problem, not a model problem: duplicates, near-duplicates, low-information chunks, size anomalies, embedding outliers, and contradictions. corpuslint scores your corpus and shows you exactly what to fix.

Install

pip install corpuslint            # core, runs offline and free
pip install "corpuslint[local]"   # + local embeddings (near-dupes, outliers)
pip install "corpuslint[llm]"     # + LLM contradiction check (OpenAI / Azure OpenAI)
pip install "corpuslint[azure]"   # + Azure AI Search source connector

Use

corpuslint ./docs                       # terminal report
corpuslint ./docs --html report.html    # shareable HTML
corpuslint ./docs --fail-under 70       # CI gate (exit 1 if score < 70)
corpuslint ./chunks.jsonl               # pre-chunked input

# LLM contradiction check (needs the [llm] extra + an API key):
export OPENAI_API_KEY=sk-...
corpuslint ./docs --llm                             # OpenAI, default gpt-4o-mini
corpuslint ./docs --llm --llm-model gpt-4o          # pick a model
corpuslint ./docs --llm --llm-max-pairs 50          # cap paid calls (default 200)

# Azure OpenAI — reads AZURE_OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT and
# AZURE_OPENAI_API_VERSION (default 2024-10-21) from the environment.
# --llm-model is the Azure *deployment* name.
export AZURE_OPENAI_API_KEY=...  AZURE_OPENAI_ENDPOINT=https://<res>.openai.azure.com
corpuslint ./docs --llm --llm-provider azure --llm-model my-deployment

The contradiction check is O(n²): it prefilters candidate pairs by embedding similarity, then asks the LLM about each. --llm-max-pairs bounds how many pairs reach the LLM (highest-similarity first) so cost stays predictable; skipped pairs are reported (--llm-max-pairs 0 skips the LLM entirely).

Sources

By default corpuslint reads files and directories. It can also pull the corpus straight from a vector store and run the same checks on it.

Azure AI Search

Needs the [azure] extra. Reads the endpoint and admin/query key from the environment; the index is passed with --index:

pip install "corpuslint[azure]"
export AZURE_SEARCH_ENDPOINT=https://<service>.search.windows.net
export AZURE_SEARCH_API_KEY=<key>

corpuslint --source azure-search --index my-index
corpuslint --source azure-search --index my-index --content-field body --id-field key

It pages through every document in the index (no silent cap), maps each to a document whose source is azure-search://<index>/<id>, and feeds them through the normal chunking + check pipeline. --content-field (default content) selects the field holding the text; --id-field (default id) selects the id field. Documents missing the content field are skipped with a warning.

Checks

exact duplicates · near duplicates · low-information chunks · chunk-size anomalies · embedding outliers · contradictions (opt-in).

Config

Optional .corpuslint.yml overrides thresholds and check selection.

Architecture

Library-first: corpuslint.analyze(paths, config) -> Report. The CLI is a thin wrapper; an MCP server, Azure AI Search connector, eval-set generation, and drift monitoring are on the roadmap.

MIT licensed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

corpuslint-0.2.0.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

corpuslint-0.2.0-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file corpuslint-0.2.0.tar.gz.

File metadata

  • Download URL: corpuslint-0.2.0.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for corpuslint-0.2.0.tar.gz
Algorithm Hash digest
SHA256 75f9763b7ec5c0188f0f5a74c94096555c2744a02cd4284086abf588ded66547
MD5 acc133f1af824c17194695140c9f051a
BLAKE2b-256 7e7e01e742496cb24711641d11d853a01b03a5690f985d442a64311de8dad12e

See more details on using hashes here.

Provenance

The following attestation bundles were made for corpuslint-0.2.0.tar.gz:

Publisher: release.yml on mediapuls/corpuslint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file corpuslint-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: corpuslint-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for corpuslint-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4daf74754c853c1d86f3d625514cdd00502e64d87c69a8b706c7286b855ec634
MD5 368fa653b1f0ce8f70a2632ae0e47663
BLAKE2b-256 ea3a60d866b2ae389c279752a24418e3d7d963092411fa914319de4df78b5877

See more details on using hashes here.

Provenance

The following attestation bundles were made for corpuslint-0.2.0-py3-none-any.whl:

Publisher: release.yml on mediapuls/corpuslint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page