Notebooks
A
Arize AI
Evaluate User Frustration Classifications

Evaluate User Frustration Classifications

agentsllmsLlamaIndexarize-phoenixopenaitutorialsevalsllmopsai-monitoringaiengineeringprompt-engineeringdatasetsllm-evalai-observabilityllm-evaluationsmolagentslegacyanthropiclangchain

Open In Colab

phoenix logo
Docs | GitHub | Community

User Frustration Evals

Arize provides tooling to evaluate LLM applications, including tools to determine if a user became frustrated during a conversation with an AI assistant.

The purpose of this notebook is:

  • to evaluate the performance of an LLM-assisted user frustration detection
  • to provide an experimental framework for users to iterate and improve on the default classification template.

Install Dependencies and Import Libraries

[1]
[ ]
[4]
/Users/jasonlopatecki/vs_projects/haystack-venv/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
[5]
OrderedDict([(True, 'frustrated'), (False, 'ok')])

Download Benchmark Dataset (need to add this dataset to repo)

[6]

Phoenix UI (link) for Evals Debugging!!

Click the link below to see Evals in Phoenix UI. Runs locally on Colab Server and collects OpenAI calls as they are made by the Evals Library.

[ ]
🌍 To view the Phoenix app in your browser, visit http://localhost:6006/
📺 To view the Phoenix app in a notebook, run `px.active_session().view()`
📖 For more information on how to use Phoenix, check out https://arize.com/docs/phoenix

Screenshot 2023-10-15 at 3.16.25 PM.png

Display User Frustration Classification Template (Need to add below template to repo)

View the default template used to classify user frustration. You can tweak this template and evaluate its performance relative to the default.

[9]

  You are given a conversation where between a user and an assistant.
  Here is the conversation:
  [BEGIN DATA]
  *****************
  Conversation:
  {conversation}
  *****************
  [END DATA]

  Examine the conversation and determine whether or not the user got frustrated from the experience.
  Frustration can range from midly frustrated to extremely frustrated. If the user seemed frustrated
  at the beginning of the conversation but seemed satisfied at the end, they should not be deemed
  as frustrated. Focus on how the user left the conversation.

  Your response must be a single word, either "frustrated" or "ok", and should not
  contain any text or characters aside from that word. "frustrated" means the user was left
  frustrated as a result of the conversation. "ok" means that the user did not get frustrated
  from the conversation.

The template variables are:

  • conversation: the chat conversation between a user and an assistant.

Configure the LLM

Configure your OpenAI API key.

[10]

Benchmark Dataset Sample

Sample size determines run time. It's recommended to start with a small sample (e.g., 100 data points) and iterate from there.

[11]
(100, 2)

LLM Evals: User Frustration Classifications GPT-4

Run user frustration classifications against a subset of the data. Instantiate the LLM and set parameters.

[12]
The `model_name` field is deprecated. Use `model` instead.                 This will be removed in a future release.
[13]
"Hello! I'm working perfectly. How can I assist you today?"

Run User Frustration Classifications

Run user frustration classifications against a subset of the data.

Verbose mode is active below, it will print out RateLimit handeling and rails (railing / cleaning up the text ouptut to fixed values)

Rails will take a messy text output like "frustrated..." -> "frustrated"

[14]
[15]
OrderedDict([(True, 'frustrated'), (False, 'ok')])
[21]
llm_classify |          | 0/100 (0.0%) | ⏳ 00:00<? | ?it/sllm_classify |██████████| 100/100 (100.0%) | ⏳ 00:03<00:00 | 28.89it/s

Evaluate Classifications

Evaluate the predictions against human-labeled ground-truth user frustration labels.

[17]
              precision    recall  f1-score   support

  frustrated       1.00      0.80      0.89        49
          ok       0.84      1.00      0.91        51

    accuracy                           0.90       100
   macro avg       0.92      0.90      0.90       100
weighted avg       0.92      0.90      0.90       100

<Axes: title={'center': 'Confusion Matrix (Normalized)'}, xlabel='Predicted Classes', ylabel='Actual Classes'>
Output

LLM Evals: User Frustration Classifications GPT-3.5

Run user frustration classifications against a subset of the data using GPT-3.5.

[18]
The `model_name` field is deprecated. Use `model` instead.                 This will be removed in a future release.
[19]
llm_classify |██████████| 100/100 (100.0%) | ⏳ 00:19<00:00 |  5.13it/s
[20]
              precision    recall  f1-score   support

  frustrated       0.98      0.96      0.97        49
          ok       0.96      0.98      0.97        51

    accuracy                           0.97       100
   macro avg       0.97      0.97      0.97       100
weighted avg       0.97      0.97      0.97       100

<Axes: title={'center': 'Confusion Matrix (Normalized)'}, xlabel='Predicted Classes', ylabel='Actual Classes'>
Output