In-line Evaluations
In-line evaluations are a way to evaluate within a trace.
Overview
In-line evaluations provide a streamlined method for adding evaluations directly to any span within your trace. This approach simplifies the process compared to setting attributes and defining evaluation tasks with filters. With in-line evaluations, you can define and execute an evaluation from our AI Evaluations library within the context of a specific span, and the results will be automatically linked.
How it works
When you call evaluator.evaluate()
with the trace_eval=True
parameter inside an active span, the evaluation is executed, and its results are attached to that span as attributes. This allows you to see evaluation results directly in the context of the operation you are tracing, like an LLM call.
Usage
Here’s how to get started with in-line evaluations.
1. Setup and Initialization
First, you need to set up your environment, register a tracer, and initialize the Evaluator
.
2. Configure and Run In-line Evaluations
To link an evaluation to a specific part of your code, run the evaluation within a span’s context. The span will be automatically linked to the evaluation result.
Key Parameters
When calling evaluator.evaluate()
:
trace_eval=True
: This is the essential parameter that enables the in-line evaluation feature. It tells the system to find the current active span and attach the evaluation results to it.custom_eval_name
: This parameter is required and provides a unique, human-readable name for your evaluation instance. It helps distinguish between multiple evaluations, especially of the same type, within a trace. The name will appear in the UI.