Skip to main content
Summarization is a good task for prompt experimentation because the output is hard to eyeball at scale: two summaries can both look fine and still score very differently against a human reference. This guide builds a summarization task, scores it with ROUGE, and then runs the same dataset and evaluators against three different prompts so you can see which one actually wins in Arize AX.

Before you start

You need an Arize AX account and an OpenAI API key.

Create a dataset

Connect to Arize AX with the Arize SDK and upload a dataset. We use ten rows from cnn_dailymail, which pairs each news article with a human-written summary. Those reference summaries are what the evaluators score against, so the dataset needs both an article and a summary column.

Define our experiment

Now let’s define our experiment. The task summarizes one article per dataset row. Taking the prompt template and the model as arguments is what lets us reuse the identical task across prompt variants later — only the template changes.

Define our evaluators

Next, we can run evaluations on the results. Evaluators take the output of a task (in this case, a string) and grade it, often with the help of an LLM. In this case, we will create ROUGE evaluators to compare the LLM-generated summaries with the human reference summaries you uploaded as part of your dataset. There are several variants of ROUGE, but we’ll use ROUGE-1 F1 score for simplicity:
  • ROUGE-1 precision is the proportion of overlapping tokens (present in both reference and generated summaries) that are present in the generated summary (number of overlapping tokens / number of tokens in the generated summary)
  • ROUGE-1 recall is the proportion of overlapping tokens that are present in the reference summary (number of overlapping tokens / number of tokens in the reference summary)
  • ROUGE-1 F1 score is the harmonic mean of precision and recall, providing a single number that balances these two scores.
Higher ROUGE scores mean that a generated summary is more similar to the corresponding reference summary. Scores near 1 / 2 are considered excellent, and a model fine-tuned on this particular dataset achieved a rouge score of ~0.44. Logging precision and recall alongside F1 costs nothing extra and shows you why a prompt scored the way it did: a terse prompt tends to raise precision and lower recall, a verbose one does the reverse. Each evaluator returns an EvaluationResult. Return the full object rather than a bare float: label and explanation are reserved columns that cannot be null, so a float-only return fails the upload.
Before spending a full experiment run, check the task and one evaluator on a single row:

Run the experiment

Now you can run an experiment with this task, evaluator, and dataset.

Results in the experiments UI

Compare prompt variants

The point of holding the dataset and evaluators fixed is that any score change is attributable to the prompt. Run the same experiment again with a stricter instruction:
Then try few-shot. The examples are drawn from the dataset’s train split, so they never overlap with the ten test rows you are scoring against.
Open the dataset’s Experiments tab to compare the three runs. Each experiment is a row and each evaluator its own score column, so you can read F1 against precision and recall together and see which prompt traded which for which.