Skip to main content
Offline evaluations are run as code and then sent back to Arize AX using client.spans.update_evaluations. This guide assumes you have traces in Arize AX and are looking to run an evaluation to measure your application performance. To add evaluations you can set up online evaluations as a task to run automatically, or you can follow the steps below to generate evaluations and log them to Arize AX:
1

Install the Arize SDK

2

Import your spans in code

3

Run a custom evaluator using Phoenix Evals

4

Log evaluations back to Arize AX

Install dependencies and setup keys

Copy the ARIZE_API_KEY and SPACE_ID from your Space Settings page (shown below) and set them as environment variables alongside your OpenAI key.

Import your spans in code

Once you have traces in Arize AX, you can visit the LLM Tracing tab to see your traces and export them in code. By clicking the export button, you can get the boilerplate code to copy paste to your evaluator.

Run a custom evaluator using Phoenix Evals

Create a classifier for the LLM to judge the quality of your responses. You can utilize any of the Arize AX Evaluator Templates or you can create your own. Below is an example which judges the positivity or negativity of the LLM output. create_classifier relies on the judge’s tool-calling / structured-output support, so use a non-reasoning model such as GPT-4.1.
Notice the variables in brackets for and above. You will need to set those variables appropriately for the dataframe so you can run your custom template. We use OpenInference as a set of conventions (complementary to OpenTelemetry) to trace AI applications. This means depending on the provider you are using, the attributes of the trace will be different. You can use the code below to check which attributes are in the traces in your dataframe.
Use the code below to set the input and output variables needed for the prompt above.
Use the evaluate_dataframe function to run the evaluation using your classifier. You will be using the dataframe from the traces you generated above. It runs the judge calls concurrently and returns the dataframe with a tone_eval_score column holding the label, score, and explanation.
If you’d like more information, see our detailed guide on custom evaluators. You can also use our pre-tested evaluators for evaluating hallucination, toxicity, retrieval, etc.

Log evaluations back to Arize AX

Use the update_evaluations method on the Arize SDK client to attach the evaluations you’ve run to traces. It requires four columns, and the <eval_name> must be alphanumeric and cannot have hyphens or spaces.
  • eval.<eval_name>.label
  • eval.<eval_name>.score
  • eval.<eval_name>.explanation
  • context.span_id
to_annotation_dataframe flattens the nested tone_eval_score column into label, score, and explanation while preserving context.span_id (the join key export_to_df already provides). Rename those to the reserved eval.<eval_name>.* columns and upload: