Skip to main content

Python client library for Cleanlab Trustworthy Language Model

Project description

Cleanlab Trustworthy Language Model (TLM) - Trust Scores for every LLM output

Build Status PyPI - Version PyPI - Python Version

In one line of code, Cleanlab TLM adds real-time evaluation of every response in LLM, RAG, and Agent systems.

Setup

TLM requires an API key. Get one here for free.

export CLEANLAB_TLM_API_KEY=<YOUR_API_KEY_HERE>

Install the package:

pip install cleanlab-tlm

Usage

TLM automatically scores the trustworthiness of responses generated from your own LLM in real-time:

from cleanlab_tlm import TLM

tlm = TLM(options={"log": ["explanation"]})
tlm.get_trustworthiness_score(
    prompt="What's the third month of the year alphabetically?",
    response="August"  # generated from any LLM model using the same prompt
)

This returns a dictionary with trustworthiness_score and optionally requested fields like explanation.

{
  "trustworthiness_score": 0.02993446111679077,
  "explanation": "Found alternate plausible response: December"
}

Alternatively, you generate responses and simultaneously score them with TLM:

tlm = TLM(options={"log": ["explanation"], "model": "gpt-4.1-mini"})  # GPT, Claude, etc.
tlm.prompt("What's the third month of the year alphabetically?")

This additionally returns a response.

{
  "response": "March.",
  "trustworthiness_score": 0.4590804375945598,
  "explanation": "Found alternate plausible response: December"
}

Why TLM?

  • Trustworthiness Scores: Every LLM response is scored via state-of-the-art uncertainty estimation, helping you reliably gauge the likelihood of hallucinated/incorrect responses.
  • Higher accuracy: Rigorous benchmarks show TLM consistently produces more accurate scores than other hallucination detectors and responses than other LLMs.
  • Scalable API: TLM is suitable for all enterprise applications where correct LLM responses are vital, including data extraction, tagging/labeling, Q&A (RAG), Agents, and more.

Documentation

Comprehensive documentation and tutorials can be found here.

License

cleanlab-tlm is distributed under the terms of the MIT license.

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

cleanlab_tlm-1.1.39.tar.gz (105.2 kB view details)

Uploaded Source

Built Distribution

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

cleanlab_tlm-1.1.39-py3-none-any.whl (70.5 kB view details)

Uploaded Python 3

File details

Details for the file cleanlab_tlm-1.1.39.tar.gz.

File metadata

  • Download URL: cleanlab_tlm-1.1.39.tar.gz
  • Upload date:
  • Size: 105.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cleanlab_tlm-1.1.39.tar.gz
Algorithm Hash digest
SHA256 1f6352750a93632a36d8f19503f977ee5089ec9776be0c784835fdf3e03e69d2
MD5 a0d52ce803661c24412f68b1af076411
BLAKE2b-256 0906af923425da52e62c1127589461c416c36ea4346e3be6911f5fe0a591adf9

See more details on using hashes here.

Provenance

The following attestation bundles were made for cleanlab_tlm-1.1.39.tar.gz:

Publisher: release.yml on cleanlab/cleanlab-tlm

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

File details

Details for the file cleanlab_tlm-1.1.39-py3-none-any.whl.

File metadata

  • Download URL: cleanlab_tlm-1.1.39-py3-none-any.whl
  • Upload date:
  • Size: 70.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cleanlab_tlm-1.1.39-py3-none-any.whl
Algorithm Hash digest
SHA256 82edeed3ab05edb860daa981ae6a7d8f0d8d7fd7027521f68987711398b168ea
MD5 63a865ff5617a462edeb0973e1b93eda
BLAKE2b-256 a6bcf7a7a50025fedb7e3c37185171488418118de7c2e07d4b907e381691db02

See more details on using hashes here.

Provenance

The following attestation bundles were made for cleanlab_tlm-1.1.39-py3-none-any.whl:

Publisher: release.yml on cleanlab/cleanlab-tlm

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