Skip to main content
In this guide we will see how to configure trusttest to use any Evaluator of type LLM as a Judge.
For our experience LLM as a Judge Evaluators offer a better evaluation for evaluating LLM outputs than other metrics. As they are able to capture more complex patterns and relationships between the input and output.

Configure LLM client

For this example we will use OpenAI gpt-4o-mini as our LLM client. so we need a token to use the OpenAI API. and to install the openai optional dependency.
Currently we support OpenAI, AzureOpenAI, Anthropic, Google and Ollama as LLM clients.
Define OpenAI token in your .env file.
Once we have installed the optional dependency and we have a token, we can configure the LLM client.

Validate the LLM client

To check that the LLM client is working correctly, you can run:

Configure and run the Evaluator

For this tutorial we will use the CorrectnessEvaluator as our evaluator. This evaluator will check if the information provided by the LLM is correct.
To run the evaluator we can do it directly:

Use the Evaluator in a Evaluation Scenario

So usually you won’t run the evaluator directly, but rather use it in a evaluation scenario. So we will define a scenario that will use the evaluator to check if the LLM is correct.

Global Configuration

LLM clients can be configured globally, so you don’t need to pass the llm_client to the evaluator or other use cases.

Complete Example