Skip to main content
This guide will walk you through the process of evaluating traces captured in Phoenix, and exporting the results to the Phoenix UI. This process is similar to the evaluation quickstart guide, but instead of creating your own dataset or using an existing external one, you’ll export a trace dataset from Phoenix and log the evaluation results to Phoenix.

Install dependencies & Set environment variables

Connect to Phoenix

Note: if you’re self-hosting Phoenix, swap your collector endpoint variable in the snippet below, and remove the Phoenix Client Headers variable.
Now that we have Phoenix configured, we can register that instance with OpenTelemetry, which will allow us to collect traces from our application here.

Prepare trace dataset

For the sake of making this guide fully runnable, we’ll briefly generate some traces and track them in Phoenix. Typically, you would have already captured traces in Phoenix and would skip to “Download trace dataset from Phoenix”

Download trace dataset from Phoenix

Generate evaluations

Now that we have our trace dataset, we can generate evaluations for each trace. Evaluations can be generated in many different ways. Ultimately, we want to end up with a set of labels and/or scores for our traces. You can generate evaluations using:
  • Plain code
  • The Phoenix evals library, which supports both built-in and custom evaluators.
  • Other evaluation packages
As long as you format your evaluation results properly, you can upload them to Phoenix and visualize them in the UI.

Code Eval Example

Let’s start with a simple example of generating evaluations using plain code. OpenAI has a habit of repeating jokes, so we’ll generate evaluations to label whether a joke is a repeat of a previous joke.
We now have a DataFrame with a column for whether each joke is a repeat of a previous joke. Let’s upload this to Phoenix.

Upload evaluations to Phoenix

Our evals_df has a column for the span_id and a column for the evaluation result. The span_id is what allows us to connect the evaluation to the correct trace in Phoenix. Phoenix will also automatically look for columns named “label” and “score” to display in the UI.
You should now see evaluations in the Phoenix UI!

LLM Eval Example

Let’s use the Phoenix Evals library to define an LLM-as-a-judge evaluator that classifies jokes as either “nerdy” or “not nerdy.”
Let’s run this evaluator on our dataset of traces.
And then upload the results to Phoenix as annotations.
From here you can continue collecting and evaluating traces, or move on to one of these other guides: