Skip to main content
W&B Weave offers several predefined scorers for evaluating your AI applications, such as Hallucination detection and Summarization quality. These can help you quickly define an evaluation and score your application’s outputs. This page describes each built-in scorer, what it measures, and how to use it in an evaluation.
Local scorers are only available for the Weave Python SDK. They aren’t yet available for the Weave TypeScript SDK.To use Weave scorers in TypeScript, see function-based scorers.

Installation

To use Weave’s predefined scorers, install some additional dependencies:
LLM-evaluators The predefined scorers that use LLMs integrate with litellm automatically. You don’t need to pass an LLM client. Set the model_id instead. See the supported models.

HallucinationFreeScorer

This scorer checks whether your AI system’s output includes any hallucinations based on the input data.
Customization
  • Customize the system_prompt and user_prompt fields of the scorer to define what “hallucination” means for you.
Notes
  • The score method expects an input column named context. If your dataset uses a different name, use the column_map attribute to map context to the dataset column.
The following example uses HallucinationFreeScorer in the context of an evaluation:

SummarizationScorer

Use an LLM to compare a summary to the original text and evaluate the quality of the summary.
How it works This scorer evaluates summaries in two ways:
  1. Entity density: Checks the ratio of unique entities (such as names, places, or objects) mentioned in the summary to the total word count in the summary to estimate the “information density” of the summary. Uses an LLM to extract the entities. Similar to how entity density is used in the Chain of Density paper.
  2. Quality grading: An LLM evaluator grades the summary as poor, ok, or excellent. These grades are then mapped to scores (0.0 for poor, 0.5 for ok, and 1.0 for excellent) for aggregate performance evaluation.
Customization
  • Adjust summarization_evaluation_system_prompt and summarization_evaluation_prompt to tailor the evaluation process.
Notes
  • The scorer uses litellm internally.
  • The score method expects the original text (the text being summarized) to be present in the input column. Use the column_map attribute if your dataset uses a different name.
The following example uses SummarizationScorer in the context of an evaluation:

OpenAIModerationScorer

The OpenAIModerationScorer uses OpenAI’s Moderation API to check whether the AI system’s output contains disallowed content, such as hate speech or explicit material.
How it works
  • Sends the AI’s output to the OpenAI Moderation endpoint and returns a structured response indicating whether the content is flagged.
The following example uses OpenAIModerationScorer in the context of an evaluation:

EmbeddingSimilarityScorer

The EmbeddingSimilarityScorer computes the cosine similarity between the embeddings of the AI system’s output and a target text from your dataset. Use it to measure how similar the AI’s output is to a reference text.
Parameters
  • threshold (float): The minimum cosine similarity score (between -1 and 1) needed to consider the two texts similar (defaults to 0.5).
The following example uses EmbeddingSimilarityScorer in the context of an evaluation:

ValidJSONScorer

The ValidJSONScorer checks whether the AI system’s output is valid JSON. This scorer is useful when you expect the output to be in JSON format and need to verify its validity.
The following example uses ValidJSONScorer in the context of an evaluation:

ValidXMLScorer

The ValidXMLScorer checks whether the AI system’s output is valid XML. Use it when you expect XML-formatted outputs.
The following example uses ValidXMLScorer in the context of an evaluation:

PydanticScorer

The PydanticScorer validates the AI system’s output against a Pydantic model to ensure it adheres to a specified schema or data structure.

RAGAS - ContextEntityRecallScorer

The ContextEntityRecallScorer estimates context recall by extracting entities from both the AI system’s output and the provided context, then computing the recall score. It’s based on the Retrieval Augmented Generation Assessment (RAGAS) evaluation library.
How it works
  • Uses an LLM to extract unique entities from the output and context and calculates recall.
  • Recall indicates the proportion of important entities from the context that are captured in the output.
  • Returns a dictionary with the recall score.
Notes

RAGAS - ContextRelevancyScorer

The ContextRelevancyScorer evaluates the relevancy of the provided context to the AI system’s output. It’s based on the RAGAS evaluation library.
How it works
  • Uses an LLM to rate the relevancy of the context to the output on a scale from 0 to 1.
  • Returns a dictionary with the relevancy_score.
Notes
  • Expects a context column in your dataset. Use the column_map attribute if the column name is different.
  • Customize the relevancy_prompt to define how relevancy is assessed.
The following example uses ContextEntityRecallScorer and ContextRelevancyScorer together in the context of an evaluation:
Note: The built-in scorers are calibrated using OpenAI models, such as openai/gpt-4o and openai/text-embedding-3-small. To use a different provider, update the model_id field. For example, to use an Anthropic model: