Skip to main content

Google Colab

End to end example of summarization experimentation

Here, we’ll share a short snippet of code to experiment with different summarization prompts. For the full tutorial, checkout the Colab notebook.

Create a dataset

First, let’s connect to Arize AX using the Arize SDK and upload an example dataset. In the notebook, we use the cnn_dailymail dataset, but we will just upload one example for conciseness here.

Define our experiment

Now let’s define our experiment. Let’s create our function to summarize an article.

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.
Now you can run an experiment with this task, evaluator, and dataset.

Results in the experiments UI