1 of 56

Evaluating LLMs & LLM Systems

January 2024

2 of 56

Overview

Topics we’ll cover

  • Why is evaluation important?
  • Why is LLM evaluation particularly challenging?
  • Methods we have for evaluating LLMs
  • Evaluating LLM systems on your data

3 of 56

Why is evaluation important?

4 of 56

It’s never been easier to get started with ML…

5 of 56

Building demo != building production system

6 of 56

Why do things quickly fall apart?

A new, un-established technology + lots of moving parts

  1. Models are constantly changing
    • “AI as a service” vendors regularly make changes to the model behind the API
    • Open-source models each perform differently

  1. LLMs are error prone
    • Failure to follow instructions
    • Logical inconsistencies
    • Incorrect output formatting
    • Toxicity / incorrect tone-of-voice
    • Susceptibility to adversarial attacks (“jailbreaking”)
    • Unhelpful + overly cautious/general
    • Sensitive to small changes in prompt
    • Hallucinations
      • Factual fabrication
      • Factual inconsistency
      • Context inconsistency

  1. Improvements in one area often result in degradations in others (changes to prompt, fine-tuning on new data, etc.)

Errors in my LLM system

7 of 56

Building demo != building production system

Demo

Production

  • When does my system work?
  • Where does it fail?
  • Which use cases can it handle?
  • Is it even possible to test for these things?

As we move towards production, it quickly becomes apparent that the landscape for error is vast

8 of 56

How an evaluation framework helps

Enable us to quantitatively measure how well our system or product is doing and detect any regressions

Ensure Performance

and Safety

Make Decisions and Ship Changes Faster

Identify Areas

for Improvement

A representative set of evals takes us a step towards reliably measuring system changes at scale - without evals, we are flying blind!

9 of 56

TL;DR - evaluation builds trust for both developers and users

AI Builder

Product Users

  • Is the system ready to deploy?
  • What could go wrong?
  • What are the potential risks to my company?
  • Does it work well?
  • Is it worth the cost?
  • Can I rely on the answers?
  • Do I need to manually double check them with other sources?

🤝

10 of 56

Why is LLM evaluation particularly challenging?

11 of 56

1. Lack of objective ground truth (and therefore reliable metrics)

  • Focus on learning the underlying data distribution itself

  • Learn the underlying patterns inherent to the data, such that they could produce a new data point of the same distribution

  • Try to model how data is placed throughout space
  • Focus on learning the conditional probability distribution of labels given the input

  • They separate data points by learning boundaries via probability estimates.

  • Draw boundaries in data space

Generative ML is different from discriminative ML

12 of 56

1. Lack of objective ground truth (and therefore reliable metrics)

Discriminative ML has clear, quantifiable metrics

Input

Label

Pred

muffin

chihuahua

muffin

chihuahua

muffin

chihuahua

chihuahua

chihuahua

accuracy = 75%

13 of 56

1. Lack of objective ground truth (and therefore reliable metrics)

Discriminative ML has clear, quantifiable metrics… Generative AI does not

Input

Label

Pred

muffin

chihuahua

muffin

chihuahua

muffin

chihuahua

chihuahua

chihuahua

accuracy = 75%

Input

Label

Pred

“Photo of a sheepdog”

“Dog that looks like a mop”

“A tangled mop”

“Picture of a mop head”

What metric ??

14 of 56

1. Lack of objective ground truth (and therefore reliable metrics)

What makes a piece of generated text “good”?

15 of 56

1. Lack of objective ground truth (and therefore reliable metrics)

It’s very subjective…

Truthful?

Accurate?

Ethical?

Safe?

Helpful?

Honest?

Creative?

Funny?

Formatting?

Relevance?

Concise?

16 of 56

1. Lack of objective ground truth (and therefore reliable metrics)

Often immeasurable…

Truthful?

Accurate?

Ethical?

Safe?

Helpful?

Honest?

Creative?

Funny?

Formatting?

Relevance?

Concise?

Cool, so now how do we measure this??

17 of 56

2. Diversity of possible tasks

LLMs can be used in many ways

18 of 56

2. Diversity of possible tasks

  • Traditional ML focused on narrow tasks for which we could build comprehensive evaluation benchmarks

  • Generative LLMs are capable of general purpose tasks, including tasks for which we have no holistic performance benchmarks

  • Even for tasks we do have benchmarks, it’s hard to summarize performance across diverse set of tasks in intuitive way�
  • Many edge cases

accuracy = 92%

accuracy = ???

Scope of LLM capability >> available eval benchmarks

19 of 56

3. Our current methods aren’t mature enough

Evals are a nascent field - more of an art than a science

Ex 1. Slight changes in prompt format result in wildly different eval scores

Ex 2. Tipping a LLM $300k leads to better response:

20 of 56

So, what options do we have for evaluating LLMs?

21 of 56

Evaluation methods

Four ways LLMs are evaluated today

1. Public Benchmarks

2. Functional Correctness

3. Human Evaluation

4. Model-based Evaluation

22 of 56

Evaluation methods

Four ways LLMs are evaluated today

1. Public Benchmarks

2. Functional Correctness

3. Human Evaluation

4. Model-based Evaluation

23 of 56

1. Public Benchmarks

There are lots of them, of varying quality, for varying tasks…

46 Popular Benchmarks

MMLU has 57 Tasks

Benchmarks often have subtasks

24 of 56

1. Public Benchmarks

Task-specific benchmarks are often grouped into collections to form “test-suites” & “leaderboards”

Popular Collections/Leaderboards:

  1. Open LLM Leaderboard

  1. Holistic Evaluation of Language Models (HELM)

  1. Eleuther AI Eval Harness

  1. MosaicML Eval Gauntlet Scores

Language Understanding

Commonsense Reasoning

Reading Comprehension

Programming

World Knowledge

Symbolic Problem Solving

HellaSwag

LAMBADA

Winograd Schema Challenge

Winogrande

Big-bench: language identification

Big-bench: conceptual combinations

Big-bench: conlang translation

Big-bench: Strategy QA

Big-bench: Strange Stories

Big-bench: Novel Concepts

COPA

OpenBook QA

PIQA

SQuaD

BoolQ

Big-bench: Understanding fables

Pubmed QA Labeled

HumanEval: code generation

MMLU

Jeopardy

Big-bench: wikidata

ARC easy

ARC challenge

Big-bench: misconceptions

Math QA

LogiQA

Simple arithmetic with spaces

Big-bench: elementary math QA

Big-bench: dyck languages

Big-bench: algorithms

Big-bench: logical deduction

25 of 56

1. Public Benchmarks

Ex: MMLU - Measuring Massive Multitask Language Understanding [2020]

About

  • Question answering dataset
  • Multiple choice - four options
  • >14,000 questions in test set
  • 57 tasks that cover different fields of world knowledge
    • Math
    • US history
    • Computer science
    • Law
    • Biology,
    • Chemistry
    • Medicine
    • Philosophy
    • etc.

26 of 56

1. Public Benchmarks

Ex: GSM8K - Grade School Math 8k [2021]

About

  • Set of 8,000 grade-school math word problems
  • Each problem requires two to eight reasoning steps to solve using basic math
  • Assesses LLMs ability to work through multi-step reasoning problems

27 of 56

1. Public Benchmarks

Issues with public benchmarks

  1. Inconsistent reporting of results

  1. Results susceptible to small changes in implementation… are we measuring what we think we are?

  1. Helpful for general indication of performance, but tells you nothing about how the model will perform on your dataset

  1. Since benchmarks are on the internet, and models are trained on the internet…are models overfitting to them (target leakage)?? Is there a way to know??
    1. Are they being gamed?

28 of 56

1. Public Benchmarks

Case Study on MMLU: Are we measuring what we think we are?

MMLU scores on Open LLM Leaderboard didn’t match those reported in the LLaMA paper??

29 of 56

1. Public Benchmarks

Case Study on MMLU: Three different implementations of the same benchmark (Original, HELM, AI Harness)

What are the differences?

  1. First sentence, instruction, and topic: Few differences… HELM adds an extra space, and the Eleuther LM Harness does not include the topic line�
  2. Question: HELM and the LM Harness add a “Question:” prefix�
  3. Choices: Eleuther LM Harness prepends them with the keyword “Choices”

30 of 56

1. Public Benchmarks

Case Study on MMLU: Three different implementations of the same benchmark (Original, HELM, AI Harness)

Original

31 of 56

1. Public Benchmarks

Case Study on MMLU: Three different implementations of the same benchmark (Original, HELM, AI Harness)

HELM

32 of 56

1. Public Benchmarks

Case Study on MMLU: Three different implementations of the same benchmark (Original, HELM, AI Harness)

Eleuther AI Harness

33 of 56

1. Public Benchmarks

Evaluation results are strongly tied to their implementation details. This shows importance of standard evals.

34 of 56

Evaluation methods

Four ways LLMs are evaluated today

1. Public Benchmarks

2. Functional Correctness

3. Human Evaluation

4. Model-based Evaluation

35 of 56

2. Functional Correctness

Using functional tests to explicitly determine if output of model solves the task at hand

Prompt

Unit tests

Predicted solution

HumanEval Benchmark

  • 164 programming challenges
  • Model gets function definition and docstring
  • Must generate functional code
  • Generated code must pass unit tests

Example Leaderboards:

  • EvalPlus: HumanEval, MBPP
  • BigCode Leaderboard: HumanEval

36 of 56

2. Functional Correctness

How can this apply outside of code generation?

  • IFEval - a benchmark to evaluate the instruction following ability of LLMs
  • Uses a set of prompts containing verifiable instructions
  • Instructions are atomic such that a simple, interpretable, and deterministic program can verify if responses follow instructions

37 of 56

Evaluation methods

Four ways LLMs are evaluated today

1. Public Benchmarks

2. Functional Correctness

3. Human Evaluation

4. Model-based Evaluation

38 of 56

3. Human Evaluation

Vibe check!

  • Manually interacting with a model is a great way to get a feel for its general capability!
  • Have a set of 3-5 standard questions that you play with on newly released models
  • However, this isn’t comprehensive, and certainly doesn’t scale…

39 of 56

3. Human Evaluation

Manual review + annotation

  • Can provide more comprehensive and accurate feedback
  • Can sometimes be crowdsourced
  • Level of expertise of evaluators is a critical considerations… is domain expertise required?
  • Slow, expensive, and still prone to bias due to cultural and individual differences

Common Human Assessment Criteria

40 of 56

3. Human Evaluation

Live, continuous human preference evaluation

LMSYS Chatbot Arena

  • Users can chat with two anonymous models side-by-side
  • They vote for which responses are better / preferred
  • ELO rating system is used to calculate relative skill level of players (from chess)
  • Crowdsourcing data collection can better represent use cases of LLMs in the wild

41 of 56

Evaluation methods

Four ways LLMs are evaluated today

1. Public Benchmarks

2. Functional Correctness

3. Human Evaluation

4. Model-based Evaluation

42 of 56

4. Model-based Evaluation

“LLM as a Judge”

  • Using a model to evaluate another model - powerful because of how flexible / general purpose it can be…
  • Anything you can write a prompt for can be evaluated (in theory)
  • Types of “LLM as a Judge” eval:
    • Pairwise comparison (AlpacaEval)
    • Reference-guided
    • Reference-free

“Strong LLM judges like GPT-4 achieve over 80% agreement rate - on par with that of human experts.”

Example Prompt

43 of 56

4. Model-based Evaluation

“LLM as a Judge”: alternatives to GPT4

Open-source LLMs that are fine-tuned to be evaluators of other models.

Demonstrate evaluation capability on par with GPT4.

Can be further fine-tuned!

  1. Prometheus
  2. Pearson correlation of 0.897 with human evaluators when evaluating with 45 customized score rubrics, which is on par with GPT-4
  3. 7B & 13B variants

  1. JudgeLM
  2. Achieves an agreement exceeding 90% that surpasses the human-to-human agreement
  3. 7B, 13B, & 33B variants

44 of 56

4. Model-based Evaluation

Limitations of “LLM as a Judge”

If LLMs need to be evaluated because they’re unreliable… why should we trust an LLM to do the evaluation???

Known Biases

  • Position bias - LLMs tend to favor the response in the first position (multiple choice)
  • Verbosity bias - LLMs tend to favor longer responses over more concise ones
  • Self-enhancement bias - LLMs have a bias towards their own answers

Other Issues

  • LLMs struggle with scoring continuous ranges
  • Correlations to human evaluators might not hold for your specific task

45 of 56

Comparison of methods

Benefits

Limitations

1. Public Benchmarks

  • Consistent, reproducible, standardized baselines
  • High quality datasets
  • Limited to specific tasks/domains
  • Good measure for LLMs…but poor measure for applications built on LLMs

46 of 56

Comparison of methods

Benefits

Limitations

1. Public Benchmarks

  • Consistent, reproducible, standardized baselines
  • High quality datasets
  • Limited to specific tasks/domains
  • Good measure for LLMs…but poor measure for applications built on LLMs

2. Functional Correctness

  • Measures what we care about!
  • Only some tasks & aspects of language are explicitly verifiable

47 of 56

Comparison of methods

Benefits

Limitations

1. Public Benchmarks

  • Consistent, reproducible, standardized baselines
  • High quality datasets
  • Limited to specific tasks/domains
  • Good measure for LLMs…but poor measure for applications built on LLMs

2. Functional Correctness

  • Measures what we care about!
  • Only some tasks & aspects of language are explicitly verifiable

3. Human Evaluation

  • Comprehensive feedback
  • No task is “too complex”
  • Quality - humans are biased
  • Cost - robust evals are expensive
  • Slow - significant time to iterate

48 of 56

Comparison of methods

Benefits

Limitations

1. Public Benchmarks

  • Consistent, reproducible, standardized baselines
  • High quality datasets
  • Limited to specific tasks/domains
  • Good measure for LLMs…but poor measure for applications built on LLMs

2. Functional Correctness

  • Measures what we care about!
  • Only some tasks & aspects of language are explicitly verifiable

3. Human Evaluation

  • Comprehensive feedback
  • No task is “too complex”
  • Quality - humans are biased
  • Cost - robust evals are expensive
  • Slow - significant time to iterate

4. Model-based Evaluation

  • Flexible with prompting
  • Qualitative or quantitative
  • Quick feedback and iterations
  • Cheaper than human eval
  • Sensitive to instructions & prompt formatting
  • Known biases
  • Can we trust it??

49 of 56

Evaluating LLM systems on your data

50 of 56

Evaluation Driven Development (EDD)

Curate a task-specific eval dataset and use it to guide prompt engineering and design choices while developing

Develop

Auto Evaluation Framework

Approve?

Curate & Validate Eval Dataset

Deploy

Feedback

No

Yes

51 of 56

Invest in building an evaluation framework

What makes a good evaluation framework?

  1. Evaluation data that is representative of production data

  • Evaluation metrics that are correlated with outcomes

  • Evaluation method that is fast, automated, and reliable

52 of 56

Case Study: RAG for Factoid QA Over Internal Documents

53 of 56

1. Evaluation data that is representative of production data

Generate synthetic data to start quickly, improve the dataset over time with feedback

Given the following context, write a factoid question that is answerable from the context alone, and then provide the correct answer.

Output Format:

```

{

“question”: <question>,

“answer”: <answer>

}

```

Context:

<context>

Output:

Knowledge Base

Context Chunk

(from knowledge base)

“We offer a comprehensive vacation policy that allows full-time employees to accrue 25 days of paid vacation per year, accruing monthly, starting after the completion of the probationary period of 3 months.”

Question

(generated)

How long does it take to start accruing paid vacation days?

Answer

(generated)

3 months

Prompt

Synthetic Eval Data

54 of 56

2. Evaluation metrics that are correlated with outcomes

Select a few meaningful metrics that provide signal on the efficacy of your system

Retriever: Precision @ K

Generator: Answer Correctness

How many items in the top-k ranked search results contain the reference answer?

Is the generated response consistent with the reference answer?

(b)

(a)

“LLM as a Judge”

“LLM as a Judge”

55 of 56

3. Evaluation method that is fast, automated, and reliable

Method should be representative of human evaluation, but allow for quick development iterations

LLM

Developer

Auto-Eval

“LLM as Judge”

Manual Human

Evaluation/Validation

Fast & Automated

Reliable

56 of 56

Thank You!