Answer Relevance
The answer-relevance
assertion evaluates whether an LLM's output is relevant to the original query. It uses a combination of embedding similarity and LLM evaluation to determine relevance.
How to use it
To use the answer-relevance
assertion type, add it to your test configuration like this:
assert:
- type: answer-relevance
threshold: 0.7 # Score between 0 and 1
How it works
The answer relevance checker:
- Uses an LLM to generate potential questions that the output could be answering
- Compares these questions with the original query using embedding similarity
- Calculates a relevance score based on the similarity scores
A higher threshold requires the output to be more closely related to the original query.