Notebooks
A
Arize AI
Running Experiments With Repetitions

Running Experiments With Repetitions

agentsllmsLlamaIndexarize-phoenixopenaitutorialsevalsllmopsai-monitoringaiengineeringprompt-engineeringdatasetsllm-evalai-observabilityllm-evaluationsmolagentsanthropiclangchainexperiments

Open In Colab

Evaluation of Customer Reviews using Repetitions in Phoenix

This notebook walks through how to generate synthetic customer reviews, upload them into Phoenix, and run evaluations to identify patterns and repetitions.
We’ll go step by step: generating data, structuring it into a dataset, and finally running experiments inside Phoenix to compare model outputs against reference labels.
Along the way, we’ll also look at screenshots of the Phoenix UI to see how datasets and experiments are visualized.

In the background, please set up a local instance of Phoenix. One way to do that is in your terminal, install arize-phoenix & run phoenix serve. For more information on other ways to run Phoenix locally, please check out our documentation on self hosting.

Setup & Installation

We start by installing the required dependencies:

  • pandas for data manipulation
  • openai for LLM calls
  • arize-phoenix to log and evaluate results
[ ]

Importing Libraries

Next, we import the libraries needed to:

  • Generate synthetic customer reviews using the OpenAI API
  • Register Phoenix for tracking experiments
  • Prepare data and send it into Phoenix for evaluation
[ ]

Generating Synthetic Customer Reviews

Here, we create a few-shot prompt that instructs the model to generate 25 product reviews for clothing items.
This ensures we have a realistic dataset to evaluate with multiple tones and sentiments.

[ ]

Running the LLM to Generate Data

We send our prompt to the OpenAI model to generate the reviews.
The output will be a structured set of text responses simulating customer feedback.

[ ]

Creating a DataFrame

We load the generated responses into a pandas DataFrame with two columns:

  • input: the customer review text
  • label: the sentiment category we will later evaluate
[ ]

Uploading to Phoenix

We now create a Phoenix dataset named clothing-product-reviews from our DataFrame. This allows us to track, explore, and evaluate the generated reviews inside Phoenix.

[ ]

This is what your uploaded dataset will look like in the Phoenix UI!

uploaded dataset image

Defining the Evaluation Task

We define a task function that represents how we want to evaluate each review.
This is where you could run another LLM pass (or a heuristic) to classify the review.
Phoenix wraps each run into an Example object for easy logging.

[ ]

Running an Experiment

We run an experiment on our dataset using the defined task.
This produces a labeled set of outputs that we can compare against our expectations.
Phoenix records:

  • inputs (customer reviews)
  • outputs (model classifications)
  • metadata (timing, tokens, cost, etc.)
[ ]

This is what your uploaded experiment will look like in the Phoenix UI! You can click through the arrows as you want to look through each of the repetitions

uploaded dataset image

Improving our Task

After analyzing our experiment results and the results of our repetitions, we can iterate on our eval template and see if there are any gaps in our prompt, or other things we may need to redefine.

Using the same Task Prompt, I added clearer definitions for the labels as the biggest change to see if there's any improvement.

[ ]
[ ]