Skip to contentSkip to page list

Docs

Evaluators Overview

Understand evaluators - the scoring functions that assess your LLM outputs for quality, safety, and correctness.

On this page

Let your agent set this up. Copy the evaluations prompt into your coding agent to get started automatically.

Evaluators are scoring functions that assess the quality of your LLM's outputs. They're the building blocks for experiments, online evaluation, and guardrails.

Choose Your Approach

You can score an output in three ways:

Built-in Evaluators

Use LangWatch's library of evaluators directly in your code.

Saved Evaluators

Create reusable evaluator configs on the platform.

Custom Scoring

Send scores from your own evaluation logic.

Which should I use?

ApproachSlug FormatBest For
Built-in Evaluatorsprovider/evaluator (e.g., ragas/faithfulness)Quick setup, standard evaluation methods
Saved Evaluatorsevaluators/{slug} (e.g., evaluators/my-checker)Team collaboration, UI-based configuration
Custom ScoringN/A - you send the score directlyProprietary logic, domain-specific metrics

What is an Evaluator?

An evaluator takes inputs (like the user question, LLM response, and optionally context or expected output) and returns a score indicating quality along some dimension.

example.txtText
Input + Output + Context → Evaluator → Score                                        ↓                              passed: true/false                              score: 0.0 - 1.0                              details: "explanation"

Built-in Evaluator Categories

LangWatch provides a library of ready-to-use evaluators:

CategoryExamplesUse Case
Expected AnswerExact Match, LLM Answer Match, LLM Factual Match, BLEU, ROUGECompare the output with a known answer
LLM as JudgeLLM-as-a-Judge Boolean, Score and Category, Rubrics Based ScoringApply your own criteria with a model
RAG QualityRagas Faithfulness, Ragas Response Relevancy, Context F1Evaluate retrieval-augmented generation
Quality AspectsValid Format, Language Detection, Sentiment, Query Resolution, SQL Query EquivalenceCheck format, language and tone
SafetyPII Detection, Jailbreak Detection, Moderation, Off Topic, Competitor BlocklistDetect harmful or unwanted content

Browse all evaluators →

The evaluator picker in the platform has two more entries. Custom (Code) runs a Python function you write in a sandbox with requests, httpx, pydantic and the LangWatch SDK available, with a 10 minute limit per call by default. Custom (from Workflow) runs one of your workflows as the evaluator.

Quick Examples

Using a Built-in Evaluator

example.pyPython
import langwatch​# Use directly by sluglangwatch.evaluation.evaluate(    "ragas/faithfulness",  # Built-in evaluator    name="Faithfulness Check",    data={        "input": user_input,        "output": response,        "contexts": contexts,    },)

Using a Saved Evaluator

example.pyPython
import langwatch​# Use your saved evaluator by its sluglangwatch.evaluation.evaluate(    "evaluators/my-tone-checker",  # Saved on platform    name="Tone Check",    data={        "input": user_input,        "output": response,    },)

Sending Custom Scores

example.pyPython
import langwatch​# Run your own logic and send the resultscore = my_custom_evaluator(input, output)​langwatch.get_current_span().add_evaluation(    name="my_custom_metric",    passed=score > 0.7,    score=score,)

Using Evaluators

In Experiments

Run evaluators on each row of your test dataset for batch evaluation:

example.pyPython
import langwatch​experiment = langwatch.experiment.init("my-experiment")​for idx, row in experiment.loop(df.iterrows()):    response = my_llm(row["input"])​    experiment.evaluate(        "ragas/faithfulness",        index=idx,        data={            "input": row["input"],            "output": response,            "contexts": row["contexts"],        },    )

Learn more about experiments →

In Online Evaluation (Monitors)

Run evaluators automatically on production traces:

  1. Create a monitor in LangWatch
  2. Select evaluators to run
  3. Configure when to trigger (all traces, sampled, filtered)
  4. Scores appear on traces and dashboards

Learn more about online evaluation →

As Guardrails

Use evaluators to block harmful content in real-time:

example.pyPython
import langwatch​guardrail = langwatch.evaluation.evaluate(    "azure/jailbreak",    name="Jailbreak Detection",    data={"input": user_input},    as_guardrail=True,)​if not guardrail.passed:    return "I can't help with that request."

Learn more about guardrails →

Evaluator Inputs

Different evaluators require different inputs:

InputDescriptionExample Evaluators
inputUser question/promptJailbreak Detection, Off Topic Evaluator
outputLLM responsePII Detection, Valid Format Evaluator
contextsRetrieved documentsRagas Faithfulness, Ragas Response Context Precision
expected_outputGround truth answerLLM Answer Match, Exact Match Evaluator
expected_contextsThe documents that should have been retrievedContext F1, Ragas Response Context Recall

Check each evaluator's documentation for required and optional inputs.

The name Parameter

Warning

Important: Always provide a descriptive name when running evaluators. This helps identify evaluation results in Analytics and traces.

example.pyPython
import langwatch​# Good - descriptive namelangwatch.evaluation.evaluate(    "langevals/llm_category",    name="Answer Completeness Check",  # Descriptive!    data={...},)​# Bad - no name, hard to tracklangwatch.evaluation.evaluate(    "langevals/llm_category",    data={...},)

Next Steps

Built-in Evaluators

Use LangWatch's evaluator library directly.

Saved Evaluators

Create and reuse evaluator configurations.

Custom Scoring

Send scores from your own evaluation logic.

Evaluators List

Browse all available evaluators.

Documentation