Model CI/CD Course: Setting up LLM evaluation
Key Takeaways
The video demonstrates setting up LLM evaluation using Weights & Biases, specifically utilizing LLMs as judges to compare Baseline and candidate models, and calculating a candidate preference score to determine which model performs better.
Full Transcript
the model that we just trained is still being evaluated it's generating samples for our evaluation data set so this might be a good time to take a look at our evaluation code in um this case study we will use the concept of llm as a judge and that means that we will provide an advanced llm like GPT 4 um the instructions that we need to that we need to respond to and we will provide two responses one will be from our Baseline model this is what uh what we are evaluating against and we're trying to improve on top of the Baseline and we will provide the instructions from a candidate model and because we are using model registry we'll pull both the the Baseline and the candidate from model registry based on aliases so let's take a look at this code as you can see we are um starting with with a configuration object and we're uh providing the model that we will use as a judge so in this case is gp4 specifically version um o.6 uh 13 uh we're providing it with a system prompt and the system prompt says you will be presented with a choice of model A and model B response for an instruction the response should follow the instructions and use the provided context if there is some and we are using the chain of Chain of Thought prompting so we're asking the model to think step by step which respon respon is better provide the reason why and then asking it to answer with a choice if Model A or B or equivalent is better um we are uh providing it with a baseline the candidate model names that we will use to parse our our data we can limit evaluation to certain number of samples we're again providing uh our weight Andes project entity and again for your use case you may want to change that entity to your uh either personal entity or the team that you're working in um and uh we're also providing it specifically the aliases of our of the model we are evaluating so in this case it's our candidate model and the Baseline and this is something we need to make sure exists in the model registry so we have models that are assigned both Baseline Alas and the candidate alas um we will be using instructor to get structured outputs uh from our um from our from our llm from our evaluation llm and I want to highlight here um a great course that we have on getting structured outputs from llms uh that you can also access on on weight Andes courses and there you can go deeper into how instructor uses pantic to get the structured outputs in this case we're collecting two fields from our llm one is the The Chain of Thought which is actually the reason why the model selected uh Model A or model B and then the choice which is either a b or equivalent then we have the about evaluator class which uh takes in config um it patches the the open AI client with instructor so that we can get the structured outputs out of the client um and then we're providing it the the is the the instructions and the responses from both models the candidate and Baseline um when uh using LM as a judge we need to be careful about some of the biases that LMS has and one of the biases is position bias so sometimes um whether a response comes first or second that might influence the choices of an llm and for that reason we are shuffling the answers randomly so with enough samples like we will will be able to avoid that that position bias so shuffling the answers we're giving the uh the llm um the the system prompt that we we already reviewed and the and the input which is the instruction the generation from model a generation from model B and uh we're asking it to respond with with a choice and then um the there are different metrics that you might use with llm as a judge When comparing to models one classic metric is Win rate but um I find I find win rate sometimes uh difficult to interpret especially if you account for ties between models um you need to do certain estimation on how that win rate should be calculated and I like simple metrics so the simple metric that we will use is whenever um Whenever there is a tie we will return zero score whenever the Baseline is chosen the score will be minus one this is the the score for the the Baseline is minus one whenever the candidate is chosen as a better response we'll get a score one now if we average all of the scores across our evaluation data set we'll get a metric which we will call candidate preference score and if that metric is positive then that means that the candidate is better than the B Bine if that metric is negative that means that um the Baseline is better and that metric goes between minus one and one in the case of minus one all of the responses in our evaluation set were better for the Baseline in the case of one all of the responses of the candidate were better so it's a it's a pretty good metric that is very easy to interpret the higher the score uh the better the candidate so you can make certain um you can put certain certain rules for examp example if the metric is above 0.5 that means like we're always switching the candidate for the Baseline if it's around zero like it means think maybe it's borderline maybe you need to do some more some more F uning or get a better candidate and if it's negative that means strictly that the Baseline is better so that will be the the metric that we'll use and and we'll send off all of the responses to to the to the llm uh via the the API client will um gather the response and and calculate our candidate preference score and log it into weights and biases one thing I want to uh I want to do here and highlight that I I like to do personally I think it's a good practice is um as you store the the evaluation uh results in weight and run I'd like to add lineage specifically to the to the both the candidate uh and the Baseline model and update this in the config so you will see that I'm I'm using our um our artifacts API I'm calling wb. use art uh artifact with the with the evaluation baseline from from the model registry and then I'm taking the path of that model and saving it in my config as evaluation model path and I'm doing the same with the Baseline and that will make sure that whenever I look at the results from this evaluation I understand exactly which model was evaluated against which Baseline so I'm downloading the table uh from from each of this this models the evaluation the Baseline merging the table passing this to our evaluation that we reviewed uh then saving the results into into a results data frame calculating our candidate preference score and again positive score will mean that our candidate is better and then also saving the results into W and bu table that we can inspect uh logging it into a weights and bies both as a table and um and also storing a a CSV file that we can can use locally if needed so uh our our evaluation run is almost finished so in in the next video we'll take this evaluation script and we'll try to set this up for for running in an automated way based off model registry triggers see you there
Original Description
This is lesson 16 of 22 in the Model CI/CD course, where we dive into the evaluation process using LLMs as judges.
*Full course with certification* and class materials available free at http://wandb.me/course_emm.
*Episode Description*
In this chapter of the Model CI/CD course from Weights & Biases, we explore how to evaluate fine-tuned language models using advanced LLMs like GPT-4. Learn how to set up an evaluation script that compares responses from a baseline and a candidate model, using LLMs to determine which model performs better.
*Chapter Highlights*
- Evaluating Models with LLMs as Judges: Understand the concept of using advanced LLMs to compare model responses and assess performance.
- Setting Up the Evaluation Script: Follow along as we configure the evaluation script, including specifying the models, system prompt, and handling biases.
- Calculating the Candidate Preference Score: Learn how to interpret evaluation results using a simple metric that reflects the relative performance of the candidate model compared to the baseline.
- Logging and Inspecting Results: See how to log evaluation results into Weights & Biases, including adding lineage information to ensure clear tracking of which models were evaluated.
- Preparing for Automation: Get ready to automate the evaluation process by understanding how the evaluation script works and how it integrates with model registry triggers.
*Enroll in the full course free:* http://wandb.me/course_emm
*Next Chapter:* Setting Up Launch
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Weights & Biases · Weights & Biases · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
0. What is machine learning?
Weights & Biases
1. Build Your First Machine Learning Model
Weights & Biases
Intro to ML: Course Overview
Weights & Biases
2. Multi-Layer Perceptrons
Weights & Biases
3. Convolutional Neural Networks
Weights & Biases
Weights & Biases at OpenAI
Weights & Biases
Why Experiment Tracking is Crucial to OpenAI
Weights & Biases
4. Autoencoders
Weights & Biases
5. Sentiment Analysis
Weights & Biases
6. Recurrent Neural Networks [RNNs]
Weights & Biases
7. Text Generation using LSTMs and GRUs
Weights & Biases
8. Text Classification Using Convolutional Neural Networks
Weights & Biases
9. Hybrid LSTMs [Long Short-Term Memory]
Weights & Biases
Toyota Research Institute on Experiment Tracking with Weights & Biases
Weights & Biases
Weights and Biases - Developer Tools for Deep Learning
Weights & Biases
Introducing Weights & Biases
Weights & Biases
10. Seq2Seq Models
Weights & Biases
11. Transfer Learning for Domain-Specific Image Classification with Small Datasets
Weights & Biases
12. One-shot learning for teaching neural networks to classify objects never seen before
Weights & Biases
13. Speech Recognition with Convolutional Neural Networks in Keras/TensorFlow
Weights & Biases
14. Data Augmentation | Keras
Weights & Biases
15. Batch Size and Learning Rate in CNNs
Weights & Biases
Applied Deep Learning Fellowship Overview and Project Selection with Josh Tobin (2019)
Weights & Biases
Grading Rubric for AI Applications with Sergey Karayev (2019)
Weights & Biases
16. Video Frame Prediction using CNNs and LSTMs (2019)
Weights & Biases
Image to LaTeX - Applied Deep Learning Fellowship (2019)
Weights & Biases
17. Build and Deploy an Emotion Classifier (2019)
Weights & Biases
Applied Deep Learning - Data Management with Josh Tobin (2019)
Weights & Biases
Snorkel: Programming Training Data with Paroma Varma of Stanford University (2019)
Weights & Biases
Applied Deep Learning - Troubleshooting and Debugging with Josh Tobin (2019)
Weights & Biases
Troubleshooting and Iterating ML Models with Lee Redden (2019)
Weights & Biases
Designing a Machine Learning Project with Neal Khosla (2019)
Weights & Biases
Lukas Beiwald on ML Tools and Experiment Management (2019)
Weights & Biases
Building Machine Learning Teams with Josh Tobin (2019)
Weights & Biases
Pieter Abeel on Potential Deep Learning Research Directions (2019)
Weights & Biases
Testing and Deployment of Deep Learning Models with Josh Tobin (2019)
Weights & Biases
Five Lessons for Team-Oriented Research with Peter Welder (2019)
Weights & Biases
Applied Deep Learning - Rosanne Liu on AI Research (2019)
Weights & Biases
Making the Mid-career Leap from Urban Design to Deep Learning/Data Science
Weights & Biases
Organizing ML projects — W&B walkthrough (2020)
Weights & Biases
Brandon Rohrer — Machine Learning in Production for Robots
Weights & Biases
Nicolas Koumchatzky — Machine Learning in Production for Self-Driving Cars
Weights & Biases
My experiments with Reinforcement Learning with Jariullah Safi
Weights & Biases
Applications of Machine Learning to COVID-19 Research with Isaac Godfried
Weights & Biases
Testing Machine Learning Models with Eric Schles
Weights & Biases
How Linear Algebra is not like Algebra with Charles Frye
Weights & Biases
Predicting Protein Structures using Deep Learning with Jonathan King
Weights & Biases
Rachael Tatman — Conversational AI and Linguistics
Weights & Biases
Reformer by Han Lee
Weights & Biases
Sequence Models with Pujaa Rajan
Weights & Biases
GitHub Actions & Machine Learning Workflows with Hamel Husain
Weights & Biases
Look Mom, No Indices! Vector Calculus with the Fréchet Derivative by Charles Frye
Weights & Biases
Jack Clark — Building Trustworthy AI Systems
Weights & Biases
Surprising Utility of Surprise: Why ML Uses Negative Log Probabilities - Charles Frye
Weights & Biases
Track your machine learning experiments locally, with W&B Local - Chris Van Pelt
Weights & Biases
Antipatterns in open source research code with Jariullah Safi
Weights & Biases
Attention for time series forecasting & COVID predictions - Isaac Godfried
Weights & Biases
Made with ML - Goku Mohandas
Weights & Biases
Angela & Danielle — Designing ML Models for Millions of Consumer Robots
Weights & Biases
Deep Learning Salon by Weights & Biases
Weights & Biases
More on: LLM Engineering
View skill →Related Reads
📰
📰
📰
📰
ChatGPT for Eco-Friendly Living: Small Changes That Add Up
Dev.to AI
What If the Future of AI Isn't About Generating More... But Generating Less?
Dev.to AI
Integrating Open-Weight LLMs Into Your App: A Hands-On API Guide
Dev.to AI
5 AI Skills to Boost Freelance Rates by 50% in 2026
Dev.to AI
🎓
Tutor Explanation
DeepCamp AI