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 OpenAIgpt-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.
.env file.
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 theCorrectnessEvaluator as our evaluator. This evaluator will check if the information provided by the LLM is correct.
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 thellm_client to the evaluator or other use cases.