Notebooks
A
Arize AI
Ai Evals Hw1 Solution

Ai Evals Hw1 Solution

agentsllmsLlamaIndexarize-phoenixopenaitutorialsevalsllmopsai-monitoringai_evals_courseaiengineeringprompt-engineeringdatasetsllm-evalai-observabilityllm-evaluationsmolagentsanthropiclangchain

Open In Colab

HW 1: System Prompt Engineering with Phoenix

๐ŸŽฏ Assignment Overview

Welcome to Homework Assignment 1! In this assignment, we'll be building the foundation for our recipe chatbot by focusing on prompt engineering and systematic testing. Our goal is to get a working prompt for us to use in Homework 2.

What We'll Accomplish:

  1. ๐Ÿค– Write an Effective System Prompt: Create a well-crafted system prompt that defines our recipe bot's personality, capabilities, and output format
  2. ๐Ÿ“Š Expand Our Query Dataset: Add diverse test queries to evaluate different aspects of our chatbot's performance
  3. ๐Ÿ”ฌ Set up Phoenix Testing: Use Phoenix to test and improve our prompt.

Let's dive in! ๐Ÿš€

[ ]
[ ]

1. Environment Setup

Before we start prompt engineering, we need to set up Phoenix on our local machine. You can either do this in the notebook with the below code or from the terminal using phoenix serve or python -m phoenix.server.main serve

[ ]

2. Prompt Management - Create and Store Prompts

Now let's create a prompt for our recipe chat bot and store them in Phoenix's prompt management. We'll start with a super basic prompt that we can iterate on later.

[ ]

3. Create Dataset from CSV

Let's create a dataset with some recipe queries and then add 10 new ones.

[ ]

Expanding Our Test Dataset

Now let's add more diverse queries to test different aspects of our recipe chatbot. According to the homework assignment, we need at least 10 new queries that cover:

  • Specific cuisines (Italian, Thai, etc.)
  • Dietary restrictions (vegan, gluten-free)
  • Available ingredients ("What can I make with X?")
  • Meal types (breakfast, lunch, dinner, snacks)
  • Time constraints ("under 30 minutes")
  • Skill levels (beginner-friendly)
  • Vague queries (to test how the bot handles ambiguity)

Note: You can also add queries directly in the Phoenix UI, but we'll do it programmatically here for reproducibility.

[ ]

Testing Our Prompt in Phoenix

Now that we have our prompt and dataset uploaded to Phoenix, it's time to test and iterate!

๐Ÿงช Testing in the Phoenix UI:

  1. Navigate to Phoenix
  2. Find Your Prompt: Go to the "Prompts" section and find your recipe-assistant-v1 prompt
  3. Create an Experiment: Use your recipe-queries dataset to test the prompt
  4. Evaluate Results: Look for:
    • Proper markdown formatting
    • Clear ingredient lists and instructions
    • Appropriate creativity vs. accuracy balance
    • Handling of edge cases (vague queries, dietary restrictions, etc.)

๐Ÿ” What to Look For:

  • Formatting: Are recipes properly structured with ## headers and ### sections?
  • Completeness: Do responses include ingredients, instructions, and helpful tips?
  • Safety: Are unsafe requests properly declined?
  • Creativity: Does the bot provide helpful variations and substitutions?
  • Consistency: Are measurements in standard units and instructions clear?

โœจ Iteration Tips:

  • Test edge cases: very vague queries, dietary restrictions, cooking methods
  • Try different phrasings of the same request
  • Look for patterns in failures and adjust your prompt accordingly
  • Use Phoenix's evaluation tools to systematically measure performance

After testing several queries and feeling confident about your prompt's performance, move on to applying it to the local codebase!

4. Assignment Complete!

Excellent work! We've successfully completed Homework 1 by building and testing our recipe chatbot prompt entirely within the Phoenix platform.

๐ŸŽฏ What We Accomplished:

  • โœ… Created a comprehensive system prompt with clear formatting guidelines
  • โœ… Set up Phoenix for testing and prompt management
  • โœ… Built and uploaded a diverse test dataset with 13+ queries
  • โœ… Tested our prompt systematically in the Phoenix UI
  • โœ… Iterated on prompt performance using Phoenix's evaluation tools
  • โœ… Established LLMOps best practices for prompt development

๐Ÿš€ Ready for Homework 2!

With our solid foundation of prompt engineering and systematic evaluation, we're now prepared to tackle Homework 2.