The URL Correctness Evaluator is a specialized tool designed to assess the relevance of webpage or document content to a user’s question. It uses an LLM (Large Language Model) as a judge to determine if the content of provided URLs is relevant and contains the information needed to answer the user’s query.
import asynciofrom trusttest.evaluation_contexts import QuestionContextfrom trusttest.evaluators import UrlCorrectnessEvaluatorasync def evaluate(): evaluator = UrlCorrectnessEvaluator() result = await evaluator.evaluate( response="You can find more information about credit card cancellation at https://example.com/cancel-card", context=QuestionContext( question="How do I cancel my credit card?" ) ) print(result)if __name__ == "__main__": asyncio.run(evaluate())
The evaluator returns a tuple containing:
A score (0-2) indicating the level of URL relevance
A list of explanations for the given score, including specific references to relevant content