Python client library for Cleanlab Trustworthy Language Model
Low maintenance activity. Last release 12 months ago, commits in 0 of the last 26 weeks. Weaker on commit activity and recent releases.
pip install cleanlab-tlmREADME as published on PyPI with version 1.1.39.
Cleanlab Trustworthy Language Model (TLM) - Trust Scores for every LLM output
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"
}