Skip to navigation

Cleanlab’s state-of-the-art LLM uncertainty estimator scores the trustworthiness of any LLM response, to detect incorrect outputs and hallucinations in real-time.

In question-answering or RAG applications: high trustworthiness is indicative of a correct response. In open-ended chat applications, a high score corresponds to the response being helpful and informative. Low trustworthiness scores indicate outputs that are likely bad or incorrect, or complex prompts where the LLM might have output the right response this time but might output the wrong response when run on the same prompt again (so it cannot be trusted).

The trustworthiness score is further explained and comprehensively benchmarked in Cleanlab’s documentation.

The cleanlab trustworthiness guardrail flow uses a default trustworthiness score threshold of 0.6 to determine if your LLM output should be allowed or not. When the trustworthiness score falls below the threshold, the corresponding LLM response is flagged as unstrustworthy. The threshold is defined in the action. To use a different cutoff, override the flow in your config and compare the score yourself. For example, to change the threshold to 0.7, add the following flow to your config:

define subflow cleanlab trustworthiness
"""Guardrail based on trustworthiness score."""
$result = execute call_cleanlab_api
if $result.metadata["trustworthiness_score"] < 0.7
bot response untrustworthy
stop
define bot response untrustworthy
"Don't place much confidence in this response"

The action returns a RailOutcome with the score in metadata["trustworthiness_score"]. The condition in your flow replaces the built-in 0.6 decision, so $result.is_blocked is not checked and you can raise or lower the cutoff.

Setup

Install the Python client to use Cleanlab’s trustworthiness score:

pip install --upgrade cleanlab-studio

You can get an API key for free by creating a Cleanlab account or experiment with the trustworthiness scores in the playground. Feel free to email Cleanlab with any questions.

Lastly, set the CLEANLAB_API_KEY environment variable with the API key.