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:
Which should I use?
| Approach | Slug Format | Best For |
|---|---|---|
| Built-in Evaluators | provider/evaluator (e.g., ragas/faithfulness) | Quick setup, standard evaluation methods |
| Saved Evaluators | evaluators/{slug} (e.g., evaluators/my-checker) | Team collaboration, UI-based configuration |
| Custom Scoring | N/A - you send the score directly | Proprietary logic, domain-specific metrics |
Do you have your own evaluation logic?├─ Yes → Use Custom Scoring└─ No → Do you want to configure via UI and reuse? ├─ Yes → Use Saved Evaluators └─ No → Use Built-in EvaluatorsWhat 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.
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:
| Category | Examples | Use Case |
|---|---|---|
| Expected Answer | Exact Match, LLM Answer Match, LLM Factual Match, BLEU, ROUGE | Compare the output with a known answer |
| LLM as Judge | LLM-as-a-Judge Boolean, Score and Category, Rubrics Based Scoring | Apply your own criteria with a model |
| RAG Quality | Ragas Faithfulness, Ragas Response Relevancy, Context F1 | Evaluate retrieval-augmented generation |
| Quality Aspects | Valid Format, Language Detection, Sentiment, Query Resolution, SQL Query Equivalence | Check format, language and tone |
| Safety | PII Detection, Jailbreak Detection, Moderation, Off Topic, Competitor Blocklist | Detect harmful or unwanted content |
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
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
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
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:
import langwatchexperiment = 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:
- Create a monitor in LangWatch
- Select evaluators to run
- Configure when to trigger (all traces, sampled, filtered)
- Scores appear on traces and dashboards
Learn more about online evaluation →
As Guardrails
Use evaluators to block harmful content in real-time:
import langwatchguardrail = 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."Evaluator Inputs
Different evaluators require different inputs:
| Input | Description | Example Evaluators |
|---|---|---|
input | User question/prompt | Jailbreak Detection, Off Topic Evaluator |
output | LLM response | PII Detection, Valid Format Evaluator |
contexts | Retrieved documents | Ragas Faithfulness, Ragas Response Context Precision |
expected_output | Ground truth answer | LLM Answer Match, Exact Match Evaluator |
expected_contexts | The documents that should have been retrieved | Context F1, Ragas Response Context Recall |
Check each evaluator's documentation for required and optional inputs.
The name Parameter
Important: Always provide a descriptive name when running evaluators. This helps identify evaluation results in Analytics and traces.
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={...},)