Clémentine commited on
Commit
49f71ca
·
1 Parent(s): adc672a
app/src/content/article.mdx CHANGED
@@ -22,24 +22,14 @@ import HtmlEmbed from "../components/HtmlEmbed.astro";
22
 
23
  import Intro from "./chapters/intro.mdx";
24
  import DesigningAutomaticEvaluation from "./chapters/automated-benchmarks/designing-your-automatic-evaluation.mdx";
25
- import PickingYourEval from "./chapters/picking-your-evaluation.mdx";
26
- import EvalsIn2025 from "./chapters/2025-evaluations-for-useful-models.mdx"
27
- import AutomatedBenchmarksTips from "./chapters/automated-benchmarks/tips-and-tricks.mdx";
28
- import HumanEvaluationBasics from "./chapters/human-evaluation/basics.mdx";
29
- import UsingHumanAnnotators from "./chapters/human-evaluation/using-human-annotators.mdx";
30
- import HumanEvaluationTips from "./chapters/human-evaluation/tips-and-tricks.mdx";
31
- import ModelAsJudgeBasics from "./chapters/model-as-a-judge/basics.mdx";
32
- import GettingJudgeLLM from "./chapters/model-as-a-judge/getting-a-judge-llm.mdx";
33
- import DesigningEvaluationPrompt from "./chapters/model-as-a-judge/designing-your-evaluation-prompt.mdx";
34
- import EvaluatingYourEvaluator from "./chapters/model-as-a-judge/evaluating-your-evaluator.mdx";
35
- import WhatAboutRewardModels from "./chapters/model-as-a-judge/what-about-reward-models.mdx";
36
- import ModelAsJudgeTips from "./chapters/model-as-a-judge/tips-and-tricks.mdx";
37
  import TroubleshootingInference from "./chapters/troubleshooting/troubleshooting-inference.mdx";
38
  import TroubleshootingReproducibility from "./chapters/troubleshooting/troubleshooting-reproducibility.mdx";
39
  import ModelInferenceAndEvaluation from "./chapters/general-knowledge/model-inference-and-evaluation.mdx";
40
 
41
- https://x.com/sasuke___420/status/1984168256568226286
42
-
43
 
44
  <Intro />
45
 
@@ -49,19 +39,23 @@ Now that you have an idea of why evaluation is important, and how it's done, let
49
 
50
  <ModelInferenceAndEvaluation />
51
 
52
- ## Doing evaluations with existing benchmarks
53
 
54
- ### State of evaluations in 2025
55
 
56
  <EvalsIn2025 />
57
 
58
- ### Understanding what's in an eval
 
 
 
 
59
 
60
- Ok, we made a list of benchmarks, now what? Well, now you need to check if these benchmarks are relevant for you and your specific use cases (unless you just want to compare your model to other models, in which case you can skim and go to the next section).
61
 
62
- The first and most important step is, and always will be, to look at the data. You want to study the following.
63
 
64
- #### Creation process
65
  - **Who created the actual samples?**
66
  Ideally, you want dataset created by experts, then next tier is paid annotators, then crowdsourced, then synthetic, then MTurked. You also want to look for a data card, where you'll find annotator demographics - this can be important to understand the dataset language diversity, or potential cultural bias.
67
 
@@ -72,7 +66,7 @@ This is especially important for datasets with the help of underpaid annotators
72
  - **Were the annotators provided with clear data creation guidelines?**
73
  In other words, is your dataset consistent?
74
 
75
- #### Samples
76
  Take 50 random samples and manually inspect them; and I mean do it yourself, not "prompt an LLM to find unusual stuff in the data for you".
77
 
78
  First, you want to check the content quality. Are the prompts clear and unambiguous? Are the answers correct? (*Eg: TriviaQA contains several gold answers (aliases field) per question, sometimes conflicting.*) Is information missing? (*Eg: MMLU misses reference schematics in a number of questions.*) It's important to keep in mind that it's not because a dataset is a standard that it's a good one - and this happens because most people skip this step.
@@ -91,52 +85,24 @@ You want to check what metrics are used: are they automatic, functional, or usin
91
 
92
  Best (but rarest) metrics are functional or based on rule based verifiers (though beware of pass/fail for coding models and code evaluations, as recent LLMs have become very good at overwriting globals to 'cheat' on such tests, especially in languages like Python where you can mess up variable scope).
93
 
94
- ### Troubleshooting reproducibility
95
 
96
  <TroubleshootingReproducibility />
97
 
98
- ### Selecting good evaluations for ablations
99
 
100
- <PickingYourEval />
101
- For these ablations, it's good to focus on tasks that give good early signal and avoid noisy benchmarks. In [FineTasks](https://huggingface.co/spaces/HuggingFaceFW/blogpost-fine-tasks) and [FineWeb2](https://arxiv.org/pdf/2506.20920), reliable evaluation tasks are defined by four key principles:
102
-
103
- - **Monotonicity:** The benchmark scores should consistently improve as models train longer.
104
- - **Low noise:** When we train models with the same setup but different random seeds, the benchmark scores shouldn't vary wildly.
105
- - **Above-random performance:** Many capabilities only emerge later in training, so tasks that show random-level performance for extended periods aren't useful for ablations. This is the case, for example, for MMLU in multiple choice format as we will explain later.
106
- - **Ranking consistency:** If one approach outperforms another at early stages, this ordering should remain stable as training continues.
107
 
108
 
 
109
 
110
- ## So you want to create your own evaluation
111
 
112
- ### Automated Benchmarks
113
 
114
  <DesigningAutomaticEvaluation />
115
 
116
 
117
- <AutomatedBenchmarksTips />
118
-
119
- ### Human Evaluations
120
- <HumanEvaluationBasics />
121
-
122
- <UsingHumanAnnotators />
123
-
124
- <HumanEvaluationTips />
125
-
126
- ### Model judges
127
-
128
  https://x.com/Kangwook_Lee/status/1993438649963164121
129
- <ModelAsJudgeBasics />
130
-
131
- <GettingJudgeLLM />
132
-
133
- <DesigningEvaluationPrompt />
134
 
135
- <EvaluatingYourEvaluator />
136
 
137
- <WhatAboutRewardModels />
138
 
139
- <ModelAsJudgeTips />
140
 
141
  <TroubleshootingInference />
142
 
 
22
 
23
  import Intro from "./chapters/intro.mdx";
24
  import DesigningAutomaticEvaluation from "./chapters/automated-benchmarks/designing-your-automatic-evaluation.mdx";
25
+ import PickingYourEval from "./chapters/general-knowledge/picking-your-evaluation.mdx";
26
+ import EvalsIn2025 from "./chapters/general-knowledge/2025-evaluations-for-useful-models.mdx"
 
 
 
 
 
 
 
 
 
 
27
  import TroubleshootingInference from "./chapters/troubleshooting/troubleshooting-inference.mdx";
28
  import TroubleshootingReproducibility from "./chapters/troubleshooting/troubleshooting-reproducibility.mdx";
29
  import ModelInferenceAndEvaluation from "./chapters/general-knowledge/model-inference-and-evaluation.mdx";
30
 
31
+ - https://arxiv.org/abs/2109.02550
32
+ - https://arxiv.org/abs/2511.21140
33
 
34
  <Intro />
35
 
 
39
 
40
  <ModelInferenceAndEvaluation />
41
 
42
+ ## Evaluating with existing benchmarks
43
 
44
+ ### Benchmarks to know in 2025
45
 
46
  <EvalsIn2025 />
47
 
48
+ ### Selecting good benchmarks automatically for model training
49
+
50
+ <PickingYourEval />
51
+
52
+ ### Understanding what's in there
53
 
54
+ No matter how you selected your initial datasets, the most important step is, and always will be, to look at the data, both what you have, what the model generates, and its scores. In the end, that's the only way you'll see if your evaluations are actually relevant for your specific use case.
55
 
56
+ You want to study the following.
57
 
58
+ #### Data creation process
59
  - **Who created the actual samples?**
60
  Ideally, you want dataset created by experts, then next tier is paid annotators, then crowdsourced, then synthetic, then MTurked. You also want to look for a data card, where you'll find annotator demographics - this can be important to understand the dataset language diversity, or potential cultural bias.
61
 
 
66
  - **Were the annotators provided with clear data creation guidelines?**
67
  In other words, is your dataset consistent?
68
 
69
+ #### Samples inspection
70
  Take 50 random samples and manually inspect them; and I mean do it yourself, not "prompt an LLM to find unusual stuff in the data for you".
71
 
72
  First, you want to check the content quality. Are the prompts clear and unambiguous? Are the answers correct? (*Eg: TriviaQA contains several gold answers (aliases field) per question, sometimes conflicting.*) Is information missing? (*Eg: MMLU misses reference schematics in a number of questions.*) It's important to keep in mind that it's not because a dataset is a standard that it's a good one - and this happens because most people skip this step.
 
85
 
86
  Best (but rarest) metrics are functional or based on rule based verifiers (though beware of pass/fail for coding models and code evaluations, as recent LLMs have become very good at overwriting globals to 'cheat' on such tests, especially in languages like Python where you can mess up variable scope).
87
 
88
+ ### So, you can't reproduce reported model scores?
89
 
90
  <TroubleshootingReproducibility />
91
 
 
92
 
 
 
 
 
 
 
 
93
 
94
 
95
+ ## Creating your own evaluation
96
 
 
97
 
 
98
 
99
  <DesigningAutomaticEvaluation />
100
 
101
 
 
 
 
 
 
 
 
 
 
 
 
102
  https://x.com/Kangwook_Lee/status/1993438649963164121
 
 
 
 
 
103
 
 
104
 
 
105
 
 
106
 
107
  <TroubleshootingInference />
108
 
app/src/content/assets/finetasks/code.js ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Papa from 'papaparse';
2
+ import { DataTable } from 'simple-datatables';
3
+
4
+ const languageMap = {
5
+ 'Arabic': 'ar',
6
+ 'Turkish': 'tr',
7
+ 'Swahili': 'sw',
8
+ 'Russian': 'ru',
9
+ 'Telugu': 'te',
10
+ 'Thai': 'th',
11
+ 'Chinese': 'zh',
12
+ 'French': 'fr',
13
+ 'Hindi': 'hi',
14
+ };
15
+
16
+ const metricTypes = [
17
+ { value: 'max_score', label: 'Max Score' },
18
+ { value: 'avg_snr', label: 'Low Noise' },
19
+ { value: 'avg_spearman', label: 'Monotonicity' },
20
+ { value: 'max_n_std', label: 'Non-Randomness' },
21
+ { value: 'avg_kendall_tau_a', label: 'Ordering Consistency' }
22
+ ];
23
+
24
+ const tableTypes = [
25
+ { value: 'gen', label: 'Generative' },
26
+ { value: 'mc', label: 'Multichoice' }
27
+ ];
28
+
29
+ const taskFolders = [
30
+ { value: 'selected', label: 'FineTasks' },
31
+ { value: 'non_selected', label: 'Non-Selected' }
32
+ ];
33
+
34
+ function createDropdown(options, onChange) {
35
+ const select = document.createElement('select');
36
+ options.forEach(option => {
37
+ const optionElement = document.createElement('option');
38
+ if (typeof option === 'object' && option.value && option.label) {
39
+ optionElement.value = option.value;
40
+ optionElement.textContent = option.label;
41
+ } else {
42
+ optionElement.value = option;
43
+ optionElement.textContent = option;
44
+ }
45
+ select.appendChild(optionElement);
46
+ });
47
+ select.addEventListener('change', onChange);
48
+ return select;
49
+ }
50
+
51
+ function createPerTaskResultsTable(data, tableType, metric) {
52
+ const tableWrapper = document.createElement('div');
53
+ tableWrapper.className = 'table-wrapper fine-tasks-table-wrapper';
54
+
55
+ const table = document.createElement('table');
56
+ table.className = 'results-table fine-tasks-results-table';
57
+
58
+ const columns = ['Task', 'Type', ...(tableType === 'gen' ? ['f1', 'prefix_match'] : ['acc', 'acc_norm', 'acc_norm_token', 'acc_norm_pmi'])];
59
+
60
+ const columnNameMap = {
61
+ // 'Task': 'Task',
62
+ // 'Type': 'Type',
63
+ // 'f1': 'f1',
64
+ // 'prefix_match': 'prefix_match',
65
+ // 'acc': 'acc',
66
+ 'acc_norm': 'acc_char',
67
+ 'acc_norm_token': 'acc_token',
68
+ 'acc_norm_pmi': 'acc_pmi',
69
+ 'prefix_match': 'prefix'
70
+ };
71
+
72
+ const taskMetricMap = {
73
+ 'max_score': 'score',
74
+ 'avg_snr': 'snr',
75
+ 'avg_spearman': 'monotonicity',
76
+ 'max_n_std': 'non-randomness',
77
+ 'avg_kendall_tau_a': 'ordering'
78
+ // 'avg_spearman': 'monotonicity',
79
+ }
80
+
81
+ const header = table.createTHead();
82
+ const headerRow = header.insertRow();
83
+ columns.forEach(column => {
84
+ const th = document.createElement('th');
85
+ th.textContent = columnNameMap[column] || column;
86
+
87
+ if (th.textContent !== "Task" && th.textContent !== "Type") {
88
+ th.textContent += " " + (taskMetricMap[metric] || metric);
89
+ }
90
+ th.title = th.textContent;
91
+ if (column === 'Type')
92
+ th.style.width = '40px';
93
+ headerRow.appendChild(th);
94
+ });
95
+
96
+ const body = table.createTBody();
97
+ data.forEach(row => {
98
+ if (Object.values(row).every(value => value === '' || value === undefined || value === null)) {
99
+ return;
100
+ }
101
+
102
+ const tr = body.insertRow();
103
+ columns.forEach(column => {
104
+ const td = tr.insertCell();
105
+ let value = row[column];
106
+ if (column === 'Task') {
107
+ const fullTaskName = value; // Store the full task name
108
+ const parts = value.split('|');
109
+ value = parts.length > 1 ? parts[1] : value;
110
+ value = value.split('_mcf')[0].split('_cf')[0];
111
+ td.title = fullTaskName; // Set the title attribute to show the full name on hover
112
+ } else if (column === 'Type') {
113
+ // Keep the task type as is
114
+ } else if (typeof value === 'number') {
115
+ value = value.toFixed(2);
116
+ } else if (value && !isNaN(parseFloat(value))) {
117
+ value = parseFloat(value).toFixed(2);
118
+ } else {
119
+ value = '';
120
+ }
121
+ td.textContent = value;
122
+ });
123
+ });
124
+
125
+ tableWrapper.appendChild(table);
126
+ return tableWrapper;
127
+ }
128
+
129
+ export function initFineTasks(containerId) {
130
+ const container = document.getElementById(containerId);
131
+ if (!container) return;
132
+
133
+ const perTaskTitleElement = document.createElement('h3');
134
+ perTaskTitleElement.textContent = 'Task Results';
135
+ perTaskTitleElement.className = 'fine-tasks-title';
136
+
137
+ const perTaskTableContainer = document.createElement('div');
138
+ perTaskTableContainer.className = 'table-container';
139
+
140
+ let perTaskDataTable;
141
+
142
+ function updatePerTaskResults() {
143
+ const language = languageDropdownPerTask.value;
144
+ const metric = metricDropdownPerTask.value;
145
+ const tableType = tableTypeDropdownPerTask.value;
146
+ const taskFolder = taskFolderDropdownPerTask.value;
147
+
148
+ const languageCode = languageMap[language];
149
+
150
+ if (!languageCode) {
151
+ console.error(`Language code not found for ${language}`);
152
+ perTaskTableContainer.innerHTML = `<p>Error: Language code not found for ${language}</p>`;
153
+ return;
154
+ }
155
+
156
+ let url = `data/tasks/${taskFolder}/${languageCode}/${metric}/${tableType}_stats.csv`;
157
+
158
+ fetch(url)
159
+ .then(response => {
160
+ if (!response.ok) {
161
+ throw new Error(`HTTP error! status: ${response.status}`);
162
+ }
163
+ return response.text();
164
+ })
165
+ .then(csvText => {
166
+ const results = Papa.parse(csvText, { header: true }).data;
167
+ perTaskTableContainer.innerHTML = '';
168
+ const tableWrapper = createPerTaskResultsTable(results, tableType, metric);
169
+ perTaskTableContainer.appendChild(tableWrapper);
170
+
171
+ if (perTaskDataTable) {
172
+ perTaskDataTable.destroy();
173
+ }
174
+
175
+ perTaskDataTable = new DataTable('.fine-tasks-results-table', {
176
+ perPage: 10,
177
+ perPageSelect: false,
178
+ searchable: false,
179
+ sortable: true,
180
+ fixedHeight: true,
181
+ labels: {
182
+ info: '' // This removes the "Showing 1 to X of Y entries" text
183
+ }
184
+ });
185
+
186
+ })
187
+ .catch(error => {
188
+ console.error('Error fetching CSV:', error);
189
+ perTaskTableContainer.innerHTML = `<p>Error loading data: ${error.message}</p>`;
190
+ });
191
+ }
192
+
193
+ const perTaskControls = document.createElement('div');
194
+ perTaskControls.className = 'controls fine-tasks-controls';
195
+
196
+ // Task folder control group
197
+ const taskFolderControlGroup = document.createElement('div');
198
+ taskFolderControlGroup.className = 'control-group';
199
+ const taskFolderLabelPerTask = document.createElement('label');
200
+ taskFolderLabelPerTask.textContent = 'Task Set: ';
201
+ const taskFolderDropdownPerTask = createDropdown(taskFolders, updatePerTaskResults);
202
+ taskFolderDropdownPerTask.value = 'selected'; // Set default to FineTasks
203
+ taskFolderControlGroup.appendChild(taskFolderLabelPerTask);
204
+ taskFolderControlGroup.appendChild(taskFolderDropdownPerTask);
205
+
206
+ // Language control group
207
+ const languageControlGroup = document.createElement('div');
208
+ languageControlGroup.className = 'control-group';
209
+ const languageLabelPerTask = document.createElement('label');
210
+ languageLabelPerTask.textContent = 'Language: ';
211
+ const languageDropdownPerTask = createDropdown(Object.keys(languageMap), updatePerTaskResults);
212
+ languageControlGroup.appendChild(languageLabelPerTask);
213
+ languageControlGroup.appendChild(languageDropdownPerTask);
214
+
215
+ // Table type control group
216
+ const tableTypeControlGroup = document.createElement('div');
217
+ tableTypeControlGroup.className = 'control-group';
218
+ const tableTypeLabelPerTask = document.createElement('label');
219
+ tableTypeLabelPerTask.textContent = 'Type: ';
220
+ const tableTypeDropdownPerTask = createDropdown(tableTypes, updatePerTaskResults);
221
+ tableTypeControlGroup.appendChild(tableTypeLabelPerTask);
222
+ tableTypeControlGroup.appendChild(tableTypeDropdownPerTask);
223
+
224
+ // Metric control group
225
+ const metricControlGroup = document.createElement('div');
226
+ metricControlGroup.className = 'control-group';
227
+ const metricLabelPerTask = document.createElement('label');
228
+ metricLabelPerTask.textContent = 'Criteria: ';
229
+ const metricDropdownPerTask = createDropdown(metricTypes, updatePerTaskResults);
230
+ metricDropdownPerTask.value = 'max_score'; // Set default to Max Score
231
+ metricControlGroup.appendChild(metricLabelPerTask);
232
+ metricControlGroup.appendChild(metricDropdownPerTask);
233
+
234
+ perTaskControls.appendChild(taskFolderControlGroup);
235
+ perTaskControls.appendChild(languageControlGroup);
236
+ perTaskControls.appendChild(tableTypeControlGroup);
237
+ perTaskControls.appendChild(metricControlGroup);
238
+
239
+ container.appendChild(perTaskControls);
240
+ // container.appendChild(perTaskTitleElement);
241
+ container.appendChild(perTaskTableContainer);
242
+
243
+ // Initialize with default values
244
+ updatePerTaskResults();
245
+ }
app/src/content/chapters/automated-benchmarks/designing-your-automatic-evaluation.mdx CHANGED
@@ -4,45 +4,23 @@ title: "Designing your automatic evaluation"
4
 
5
  import Note from "../../../components/Note.astro";
6
  import Sidenote from "../../../components/Sidenote.astro";
 
7
 
8
- ### Designing your automatic evaluation
9
 
 
 
 
10
 
11
- #### Selecting or creating a dataset
12
- For your evaluation, you can either select an existing dataset or design your own. Through this process, it's very important to keep in mind that **your evaluation result will only be as good as your evaluation dataset**.
13
 
14
- ##### Designing your own
15
- You can go 3 ways when designing your own dataset.
16
- - **Aggregating existing data**: You can aggregate existing data from different sources, evaluating a relevant capability for your task. A number of evaluation datasets are for example constructed from aggregating human evaluation datasets (such as MATH, LSAT, etc). In this case, follow the steps above.
17
- - **Using human annotators**: There's a whole section on using human annotators in `Human evaluation`, see [Using human annotators](https://github.com/huggingface/evaluation-guidebook/blob/main/contents/human-evaluation/using-human-annotators.md).
18
 
19
- <Note title="See also" emoji="👥" variant="info">
20
 
21
- For detailed guidance on using human annotators to create evaluation datasets, see the [Using human annotators](/human-evaluation/using-human-annotators) section.
22
- </Note>
23
  - **Using synthetic data from models**: On this, you can check the very cool [Cosmopedia](https://huggingface.co/blog/cosmopedia) blog by cool HF colleagues! It's mostly studying how to create a synthetic training dataset, but similar techniques can be used for evaluation. Make sure to manually check/filter/inspect your dataset afterwards (following the above steps).
24
  - **Using rule-based techniques**: If your task allows, this is a very good way to get a virtually infinite supply of samples and avoid contamination! For some examples, you can look at [NPHardEval](https://arxiv.org/abs/2312.14890), [DyVal](https://arxiv.org/abs/2309.17167), [MuSR](https://arxiv.org/abs/2310.16049), [BabiQA](https://arxiv.org/abs/1502.05698), etc.
25
 
26
- #### Choosing an inference method for your model
27
- You'll need to choose what kind of inference method you need.
28
-
29
- Using log-probabilities (MCQA, multi-choice question answer) is very good for multiple choice question answers (usually to test model knowledge, or ability to disambiguate).
30
- - Pros:
31
- - Makes sure that all models have access to the correct answer
32
- - Provides a proxy for model "confidence" (and calibration)
33
- - Fast to evaluate, especially when we ask the model to predict only one token (A/B/C/D the indices of the choices, or Yes/No, etc).
34
- - Allow to get signal on small models' task performance
35
- - Cons:
36
- - Slightly over-scores small models which would have generated something outside of the range of available choices if given free rein.
37
- - Some models [favor specific choices based on the order in which they have been presented](https://arxiv.org/abs/2309.03882), which could lead to unrepresentative evaluations
38
-
39
- Using generations (QA, question answering) is very good for any task where you want to test fluency, reasoning, or the ability of your model to actually answer questions.
40
- - Pros:
41
- - Should actually correlates with LLM ability to generate fluent text, will most of the time be what people are actually interested in
42
- - Cons:
43
- - Can be harder to score (see the `metrics` section below)
44
- - Usually slightly more expensive than log likelihood evaluations, especially if they include sampling
45
-
46
  #### Choosing a prompt
47
  The prompt is going to define:
48
  - how much information is given to your model about the task
@@ -62,37 +40,105 @@ When defining your prompt, you need to be aware that:
62
  - A costly way is to re-run the evaluation several times with prompt variations
63
  - A less costly way is to run your evaluation once using a range of prompt formats allocated to different samples of equivalent difficulty
64
  - you can provide examples to your model to help it follow the expected format (using few-shot examples), and adding connector words helps this overall
65
- - but models now tend to overfit specific prompt formats.
66
- - [This paper](https://arxiv.org/abs/2407.07890) is great on the topic, showing notably how some models can be over-evaluated because they have overfitted the test set **format**
67
- - On the Open LLM Leaderboard 2, we've notably observed that Llama 3.2 and Qwen 2.5 are no longer following the format of the prompt provided in a few-shot setup for this reason.
68
 
69
  <Note title="Models can overfit prompt formats" emoji="⚠️" variant="warning">
70
 
71
- Recent research shows models can overfit specific prompt formats rather than learning the underlying task. [This paper](https://arxiv.org/abs/2407.07890) demonstrates how some models are over-evaluated because they've memorized test set formats. We've observed Llama 3.2 and Qwen 2.5 no longer following few-shot prompt formats for this reason.
 
72
  </Note>
73
- - for a number of metrics, you want a very constrained generation or output.
74
- *You can learn more about this in the `Constraining model outputs` section of the [Model inference and evaluation](https://github.com/huggingface/evaluation-guidebook/blob/main/contents/general-knowledge/model-inference-and-evaluation.md) page.*
75
 
76
- #### Choosing a metric
77
- If you are looking at **log-probabilities**, your metrics are going to be easy: you'll want to look at accuracy (how often the most likely choice is the best choice). It's important to normalize it by length (either character, token, or pmi). You could also look at perplexity, recall, or f1 score.
78
 
79
- For **generative** evaluations, your range of metrics is going to be wider.
80
- You'll need to
81
- 1. decide if you compare generations as they are, or first normalize them with something.
82
- - Normalizations can easily [be unfair if not designed well](https://huggingface.co/blog/open-llm-leaderboard-drop), but overall they still provide signal at the task level.
 
83
 
84
- <Sidenote>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
 
86
- Normalizations can [be unfair if not designed well](https://huggingface.co/blog/open-llm-leaderboard-drop), though they generally provide useful signal. Design normalization rules carefully and test them across diverse model outputs.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  </Sidenote>
88
- - They are very important for specific tasks, such as math evaluations, where you might want to extract your result from formatted outputs.
89
- - They will also be important if you want to evaluate with added mechanisms for accuracy, such as Chain of Thought, as you'll need to remove the reasoning trace from the actual result
90
- 2. decide how you compare the generation with the reference.
91
- You could use anything ranging from match-based metrics (exact match, prefix match, etc) to summarization and translation metrics (ROUGE, BLEU, character n gram comparisons). For a list of existing metrics, you can look [here](https://github.com/huggingface/lighteval/wiki/Metric-List), I'll add a section later on which metric to use when.
92
 
93
- More generally, when picking your metric, you need to keep in mind what your task is really about. For some domains (ex: medical, chatbots with public interaction), you don't want to measure the average performance, but need a way to evaluate the **worst performance** you'll get (on medical quality of output, on toxicity, etc). (*To go further, take a look at this [blog](https://ehudreiter.com/2024/07/10/challenges-in-evaluating-llms/)*)
 
 
 
 
 
94
 
95
- #### Smart new tasks: what about functional testing?
 
 
 
 
 
 
 
96
  In the field of code, you want to evaluate generated programs not only on their semantics, but on their actual function. A good way to do so is therefore to check if code generated to follow a prompt passes correctly a suite of unit-tests designed to fit the task.
97
 
98
  This functionality approach is extremely promising, as it
@@ -100,15 +146,311 @@ This functionality approach is extremely promising, as it
100
  - therefore reducing overfitting
101
  - tests models on specific active capabilities
102
 
103
- <Note title="The promise of functional testing" emoji="✨" variant="success">
 
 
 
 
 
 
 
 
 
 
 
104
 
105
- Functional testing (like unit tests for code) offers major advantages:
106
- - Easier test case generation (often rule-based)
107
- - Reduces overfitting risk
108
- - Tests specific active capabilities
109
- - Extends beyond code to other domains (e.g., IFEval for instruction following)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  </Note>
111
 
112
- It's however an approach which requires creativity to be translated to text!
113
 
114
- A good example of this is IFEval, an evaluation benchmark which tests if models can follow instructions. It works by creating a number of formatting instructions (*Add this number of bullet points. Capitalize only one sentence.* etc), and strictly testing if the format is followed. More work is clearly needed to extend this idea to other features of text to analyze!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  import Note from "../../../components/Note.astro";
6
  import Sidenote from "../../../components/Sidenote.astro";
7
+ import UsingHumanAnnotators from "../human-evaluation/using-human-annotators.mdx";
8
 
9
+ ### Dataset
10
 
11
+ #### Using existing data
12
+ - Use existing datasets, and assemble them differently
13
+ You can aggregate existing data from different sources, evaluating a relevant capability for your task. A number of evaluation datasets are for example constructed from aggregating human evaluation datasets (such as MATH, LSAT, etc). In this case, follow the steps above.
14
 
15
+ #### Creating a dataset manually
 
16
 
17
+ <UsingHumanAnnotators />
 
 
 
18
 
19
+ #### Creating a dataset synthetically
20
 
 
 
21
  - **Using synthetic data from models**: On this, you can check the very cool [Cosmopedia](https://huggingface.co/blog/cosmopedia) blog by cool HF colleagues! It's mostly studying how to create a synthetic training dataset, but similar techniques can be used for evaluation. Make sure to manually check/filter/inspect your dataset afterwards (following the above steps).
22
  - **Using rule-based techniques**: If your task allows, this is a very good way to get a virtually infinite supply of samples and avoid contamination! For some examples, you can look at [NPHardEval](https://arxiv.org/abs/2312.14890), [DyVal](https://arxiv.org/abs/2309.17167), [MuSR](https://arxiv.org/abs/2310.16049), [BabiQA](https://arxiv.org/abs/1502.05698), etc.
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  #### Choosing a prompt
25
  The prompt is going to define:
26
  - how much information is given to your model about the task
 
40
  - A costly way is to re-run the evaluation several times with prompt variations
41
  - A less costly way is to run your evaluation once using a range of prompt formats allocated to different samples of equivalent difficulty
42
  - you can provide examples to your model to help it follow the expected format (using few-shot examples), and adding connector words helps this overall
43
+ - for a number of metrics, you want a very constrained generation or output.
 
 
44
 
45
  <Note title="Models can overfit prompt formats" emoji="⚠️" variant="warning">
46
 
47
+ Recent research shows models can overfit specific prompt formats rather than learning the underlying task. [This paper](https://arxiv.org/abs/2407.07890) is great on the topic, showing notably how some models can be over-evaluated because they have overfitted the test set **format**.
48
+ On the Open LLM Leaderboard 2, we've notably observed that Llama 3.2 and Qwen 2.5 are no longer following the format of the prompt provided in a few-shot setup for this reason.
49
  </Note>
 
 
50
 
51
+ #### Managing contamination
52
+ In general, you should assume that a dataset publicly available on the internet is or will be contaminated.
53
 
54
+ Solutions to mitigate this include:
55
+ - providing a **canary string** in the evaluation set (like in [BigBench](https://github.com/google/BIG-bench)): it is a specific character combination that model creators can look for in their training sets, which would indicate that it contains an evaluation
56
+ - providing evaluation sets in **[encrypted](https://arxiv.org/abs/2309.16575) or [gated](https://huggingface.co/datasets/Idavidrein/gpqa)** forms so that they can't be parsed easily by web crawlers - therefore not ending up accidentally in training sets
57
+ - running [dynamic benchmarks](https://arxiv.org/abs/2104.14337): benchmarks regularly updated through time so that models can't "learn the answers by heart" (but it makes datasets more costly)
58
+ - if you are running a benchmark, trying to [detect contamination](https://arxiv.org/abs/2311.06233) post-hoc (for example, by looking at the generation perplexity or designing adversarial versions of the prompts - however, no method is a foolproof contamination detection method)
59
 
60
+ However, it's not because a dataset is contaminated that it won't still be interesting and have signal during training, as we saw in the ablations section.
61
+
62
+
63
+ ### Choosing an inference method for your model
64
+ You'll need to choose what kind of inference method you need.
65
+
66
+ #### Loglikelihood evaluations
67
+ <Note title="Reminder">
68
+ Using log-probabilities (MCQA, multi-choice question answer) is good for multiple choice question answers (usually to test model knowledge, or ability to disambiguate).
69
+ - Pros:
70
+ - Makes sure that all models have access to the correct answer
71
+ - Provides a proxy for model "confidence" (and calibration)
72
+ - Fast to evaluate, especially when we ask the model to predict only one token (A/B/C/D the indices of the choices, or Yes/No, etc).
73
+ - Allow to get signal on small models' task performance
74
+ - Cons:
75
+ - Slightly over-scores small models which would have generated something outside of the range of available choices if given free rein.
76
+ - Some models [favor specific choices based on the order in which they have been presented](https://arxiv.org/abs/2309.03882), which could lead to unrepresentative evaluations (unless you're re-running the evaluation n times by shuffling samples orders, which you should do for significance if you have the budget for!)
77
+ </Note>
78
+
79
+ <Note title="Tip: an easy speed up for MCQA evaluations">
80
+ You can speed up your MCQA predictions by a lot if you make sure your model needs to predict only one token for the task.
81
+
82
+ This way, instead of running your `number_of_choices` predictions (`context + choice 1`, `context + choice 2`, etc), you can simply run inference on `context` and compute the probability distribution on the full vocabulary (which will include all your one token choices) to get your logprobabilities of interest, and do this step in one pass.
83
+ </Note>
84
+
85
+ #### Generative evaluations
86
+ However, nowadays most evaluations are generative: using generations (QA, question answering) is very good for any task where you want to test fluency, reasoning, or the ability of your model to actually answer questions. It's also the most relevant way to evaluate reasoning models.
87
+
88
+ <Note title="Reminder">
89
+ - Pros:
90
+ - Should actually correlates with LLM ability to generate fluent text, will most of the time be what people are actually interested in
91
+ - The only way to evaluate both closed and open source models
92
+ - Cons:
93
+ - Can be harder to score (see below)
94
+ - More expensive than log likelihood evaluations, especially if they include sampling or reasoning models
95
+ </Note>
96
+
97
+ ### Scoring
98
+
99
+ If you are looking at **log-probabilities**, your metrics are going to be easy: you'll likely want to look at a variant of accuracy (how often the most likely choice is the best choice). It's important to normalize it by length (either character, token, or pmi). You could also look at perplexity, recall, or f1 score.
100
 
101
+ If you're looking at generative evaluations, you'll need to decide if you compare generations as they are, or first normalize them with something.
102
+
103
+ <Note title="Normalization">
104
+
105
+ Normalizations can easily [be unfair if not designed well](https://huggingface.co/blog/open-llm-leaderboard-drop), but overall they still provide signal at the task level.
106
+ They are very important for specific tasks, such as math evaluations, where you might want to extract your result from formatted outputs.
107
+ They will also be important if you want to evaluate with added mechanisms for accuracy, such as Chain of Thought, as you'll need to remove the reasoning trace from the actual result
108
+ </Note>
109
+
110
+ Then, you'll need to select what to use to score your prediction, and this is where it gets trickyyy, so let's jump to the next chapter specifically on this!
111
+
112
+
113
+ ## The hardest part of evaluation: Scoring free form text
114
+
115
+ ### Automatically
116
+
117
+ #### Metrics
118
+ You could use anything ranging from match-based metrics (exact match, prefix match, etc) to summarization and translation metrics (ROUGE, BLEU, character n gram comparisons).
119
+
120
+ TODO: Add shortcimings of different metrics
121
+
122
+ More generally, when picking your metric, you need to keep in mind what your task is really about. For some domains (ex: medical, chatbots with public interaction), you don't want to measure the average performance, but need a way to evaluate the **worst performance** you'll get (on medical quality of output, on toxicity, etc).
123
+ <Sidenote>
124
+ To go further, take a look at this [blog](https://ehudreiter.com/2024/07/10/challenges-in-evaluating-llms/).
125
  </Sidenote>
 
 
 
 
126
 
127
+ <Note title="Pros and cons of using automated metrics">
128
+ Automated benchmarks have the following advantages:
129
+ - **Consistency and reproducibility**: You can run the same automated benchmark 10 times on the same model and you'll get the same results (baring variations in hardware or inherent model randomness). This means that you can easily create fair rankings of models for a given task.
130
+ - **Scale at limited cost**: They are one of the cheapest way to evaluate models at the moment.
131
+ - **Understandability**: Most automated metrics are very understandable.
132
+ *Eg: an exact match will tell you if the generated text matches perfectly with the reference, and an accuracy score will tell you in how many cases the selected choice was the correct one (this will be a bit less the case for metrics such as `BLEU` or `ROUGE` for example).*
133
 
134
+ However, they also present the following limitations:
135
+ - **Reduced use on more complex tasks**: Automated benchmarks are working well for tasks where performance is easy to define and assess (for example, classification). More complex capabilities, on the other hand, are harder to decompose into well-defined and precise tasks.
136
+ *Eg: what does "good at math" mean? Is it being good at arithmetic? - at logic? - able to reason on new mathematical concepts?*
137
+ This led to the use of more **generalist** evaluations, which no longer decompose capabilities in sub-tasks, but assuming that general performance will be a **good proxy** for what we aim to measure.
138
+ - **Contamination**: Once a dataset is published publicly in plain text, it will end up in model training datasets. This means that you have no guarantee when scoring a model that it has not parsed the evaluation data before.
139
+ </Note>
140
+
141
+ #### Using functional testing
142
  In the field of code, you want to evaluate generated programs not only on their semantics, but on their actual function. A good way to do so is therefore to check if code generated to follow a prompt passes correctly a suite of unit-tests designed to fit the task.
143
 
144
  This functionality approach is extremely promising, as it
 
146
  - therefore reducing overfitting
147
  - tests models on specific active capabilities
148
 
149
+ It's however an approach which requires creativity to be translated to text!
150
+
151
+ A good example of this is IFEval, an evaluation benchmark which tests if models can follow instructions. It works by creating a number of formatting instructions (*Add this number of bullet points. Capitalize only one sentence.* etc), and strictly testing if the format is followed. More work is clearly needed to extend this idea to other features of text to analyze!
152
+
153
+ ### With humans
154
+ Human evaluation is simply asking humans to score predictions.
155
+
156
+ Human evaluation is very interesting, because it's **flexibility** (if you define clearly enough what you are evaluating, you can get scores for about anything!), **uncontaminated** (If you ask humans to write new questions to test your system, they should not be present in your training data (hopefully)), and correlates well with human preference for obvious reasons.
157
+
158
+ <Sidenote>
159
+ However, when doing evaluation with humans, you need to make sure your annotators are diverse enough that your results generalizes.*
160
+ </Sidenote>
161
 
162
+ However, it also present a number of biases:
163
+ - **First impressions bias**: Human evaluators tend to estimate the quality of answers [based on first impressions](https://arxiv.org/abs/2309.16349), instead of actual factuality or faithfulness.
164
+ - **Tone bias**: Crowdsourced annotators are notably very sensitive to tone, and underestimate the number of factual or logical errors in an assertive answer. In other terms, if a model says wrong things in a confident tone, human evaluators are much less likely to notice it, which could skew ratings towards the more assertive models. (Expert annotators are less likely to fall prey to these biases.)
165
+ - **Self-preference bias**: Humans are [most likely to prefer answers which appeal to their views or align with their opinions or errors](https://arxiv.org/abs/2310.13548), rather than answers which are factually correct.
166
+ - **Identity bias**: People with different identities tend to have different values, and rate model answers very differently (for example on [toxicity](https://arxiv.org/abs/2205.00501))
167
+
168
+ There are 3 main ways to do evaluation with paid annotators:
169
+ - If **you don't have a dataset**, but want to explore a set of capabilities, you provide humans with a task and scoring guidelines (e.g *Try to make both these model output toxic language; a model gets 0 if it was toxic, 1 if it was not.*), and access to one (or several) model(s) that they can interact with, then ask them to provide their scores and reasoning.
170
+ - If **you already have a dataset** (eg: a set of *prompts that you want your model to never answer*, for example for safety purposes), you preprompt your model with them, and provide the prompt, output and scoring guidelines to humans.
171
+ - If **you already have a dataset and scores**, you can ask humans to review your evaluation method by doing [error annotation](https://ehudreiter.com/2022/06/01/error-annotations-to-evaluate/) (*it can also be used as a scoring system in the above category*). It's a very important step of testing new evaluation system, but it technically falls under evaluating an evaluation, so it's slightly out of scope here.
172
+
173
+ Pros of systematic human evaluations, especially with paid annotators, are that you're **getting high quality and private data** adapted to your use case (especially if you rely on in house annotators), which are mostly **explainable** (scores obtained by the models will be explainable by the humans who gave them).
174
+ However, it's more costly (especially as you'll most likely need rounds of annotations to adapt your guidelines) and does not scale well.
175
+
176
+ Two other approaches exist to do human-based evaluation in a more casual way:
177
+ - **Vibes-checks**: manual evaluations done by individuals to get an overall feeling of how well models perform on many use cases (from coding to quality of smut written). Often shared on Twitter and Reddit, results mostly constitute anecdotal evidence, and tend to be highly sensitive to confirmation bias (in other words, people tend to find what they look for). However, they can be [good starting point for your own use cases](https://olshansky.substack.com/p/vibe-checks-are-all-you-need).
178
+ - **Arenas**: crowdsourced human evaluation to rank models. A well known example of this is the [LMSYS chatbot arena](https://huggingface.co/spaces/lmsys/chatbot-arena-leaderboard), where community users are asked to chat with models until they find one is better than the other. Votes are then aggregated in an Elo ranking (a ranking of matches) to select which model is "the best".
179
+
180
+ Pros of casual human evaluations are that they are cheap, scale better and allow to discover fun edge cases since you leverage user's creativity in a mostly unbounded manner, you can discover interesting edge cases. However, the obvious issues are that it's easy to game externally, you can't mitigate the **high subjectivity** easily, it's usually not representative of the broader population as since young western men are over re-represented on tech-sides of the internet (both in terms of topics explored and overall rankings).
181
+ <Sidenote>
182
+ it's hard to enforce a consistent grading from many community members using broad guidelines, especially since annotators preferences tend to be [culturally bound](https://arxiv.org/abs/2404.16019v1). One can hope that these effect is smoothed over by the sheer scale of the votes, through a "wisdom of the crowd" effect (see Galton's wikipedia page).
183
+ </Sidenote>
184
+
185
+
186
+
187
+ ### With judge models
188
+ Judge models are simply **neural network used to evaluate the output of other neural networks**. In most cases, they evaluate text generations.
189
+
190
+ Judge models range from small specialized classifiers (think "spam filter", but for toxicity for example) to LLMs, either large and generalist or small and specialized. In the latter case, when using an LLM as a judge, you give it a prompt to explain how to score models (ex: `Score the fluency from 0 to 5, 0 being completely un-understandable, ...`).
191
+
192
+ Model as judges allow to score text on complex and nuanced properties.
193
+ For example, an exact match between a prediction and reference can allow you to test if a model predicted the correct fact or number, but assessing more open-ended empirical capabilities (like fluency, poetry quality, or faithfulness to an input) requires more complex evaluators.
194
+
195
+ That's where models as judges come into play.
196
+
197
+ They are used on 3 main tasks:
198
+ - *Scoring a model generation*, on a provided scale, to assess a property of the text (fluency, toxicity, coherence, persuasiveness, etc).
199
+ - *Pairwise scoring*: comparing a pair model outputs to pick the best text with respect to a given property
200
+ - *Computing the similarity* between a model output and a reference
201
+
202
+ *Note: In this document, I'll focus on the LLMs + prompt approach for now, but you should definitely check out how classifier judges work, as I think it can be fairly robust and well adapted to a number of use cases, and the recently introduced and promising reward model as judge approach (introduced in [this tech report](https://research.nvidia.com/publication/2024-06_nemotron-4-340b), and on which we have a small page [here](https://github.com/huggingface/evaluation-guidebook/blob/main/contents/model-as-a-judge/what-about-reward-models.md))*
203
+
204
+ #### Pros and cons of using judge-LLMs
205
+ People in favor of judge LLMs have been claiming they provide better:
206
+ - **Objectivity** when compared to humans: They automate empirical judgments in an objective and reproducible manner (theoretically - in my opinion, they add more subtle bias than they are worth)
207
+ - **Scale and reproducibility**: They are more scalable than human annotators, which allows to reproduce scoring on large amounts of data (if you control for temperature).
208
+ - **Cost**: They are cheap to instantiate, as they don't require to train a new model, and can just rely on good prompting and an existing high quality LLM. They are also cheaper than paying actual human annotators (capitalism...).
209
+ - **Alignment with human judgments**: They are somehow correlated with human judgments.
210
+
211
+ In my opinion, using LLM judges correctly is extremely tricky, and it's easy to be deceived for critical use cases:
212
+ - LLM as judges seem objective, but they have many **hidden biases** that can be harder to detect than the ones in humans, since we're not as actively looking for them (see [model-as-a-judge/Tips and tricks]). Besides, there are ways to reduce human bias by designing survey questions in specific and statistically robust ways (which has been studied in sociology for about a century), where LLM-prompting is not as robust yet. Using LLMs to evaluate LLMs has been compared to creating an echo-chamber effect, by reinforcing biases subtly.
213
+ - They are indeed scalable, but contribute to creating massive amounts of data which themselves need to be examined to ensure their quality (for example, you can improve the quality of LLM-judges by asking them to generate a thinking trace, or reasoning around their data, which makes even more new artificial data to analyse)
214
+ - They are indeed cheap to instantiate, but paying actual expert human annotators is likely to give you qualitatively better results for your specific use cases.
215
+
216
+ <Note title="Critical limitations of LLM judges" emoji="⚠️" variant="warning">
217
+
218
+ Using LLM judges is extremely tricky:
219
+ - **Hidden biases**: Harder to detect than human biases; creates echo-chamber effects
220
+ - **Data overload**: Generates massive synthetic data needing quality examination
221
+ - **False objectivity**: Seems objective but reinforces subtle biases
222
+ - **Expert humans better**: For critical use cases, expert annotators provide higher quality
223
+
224
+ See [Tips and tricks](./tips-and-tricks) for bias mitigation strategies.
225
  </Note>
226
 
227
+ This section is a bit long, because you need to be well aware of their limitations: a lot of people are blindly jumping into using model judges because they seem easier, but then end up with uninsterpretable data with tricky bias to extract.
228
 
229
+ If you want to give it a go, I suggest first reading this [very good guide](https://huggingface.co/learn/cookbook/en/llm_judge) (⭐) by Aymeric Roucher on how to setup your first LLM as judge!
230
+ You can also try the [distilabel](https://distilabel.argilla.io/latest/) library, which allows you to generate synthetic data and update it using LLMs. They have a nice [tutorial](https://distilabel.argilla.io/latest/sections/pipeline_samples/papers/ultrafeedback/) applying the methodology of the [Ultrafeedback paper](https://arxiv.org/abs/2310.01377) as well as a [tutorial on benchmarking](https://distilabel.argilla.io/latest/sections/pipeline_samples/examples/benchmarking_with_distilabel/) implementing the Arena Hard benchmark.
231
+
232
+ #### Getting a Judge-Model
233
+
234
+ When using an existing LLM, you can go for [generalist, high capability models](https://arxiv.org/abs/2306.05685v4), using [small specialist models](https://arxiv.org/abs/2405.01535) trained specifically to discriminate from preference data, or training your own.
235
+
236
+ **Using a generalist LLM**
237
+
238
+ With the introduction of more capable LLMs (such as ChatGPT), some researchers started exploring using big models as judges.
239
+
240
+ <Note title="Closed vs open source judge models" emoji="⚖️" variant="warning">
241
+
242
+ **Closed source models (Claude, GPT-o) tradeoffs:**
243
+
244
+ Disadvantages:
245
+ - **Non-reproducible**: Models can change without notice via API updates
246
+ - **Black box**: Un-interpretable decision-making
247
+ - **Privacy risks**: Data sent to third parties, potential leakage
248
+
249
+ Advantages:
250
+ - Easy access without local setup or hardware requirements
251
+
252
+ **Open source models are closing the gap** while solving reproducibility and interpretability issues. Models like DeepSeek R1, gpt-oss, and the recent Qwen models are now competitive alternatives.
253
+
254
+ </Note>
255
+
256
+ You'll find a good cost analysis of model providers [here](https://huggingface.co/spaces/ArtificialAnalysis/LLM-Performance-Leaderboard) if you need help picking one.
257
+
258
+ **Using a tiny specialized LLM judge model**
259
+
260
+ You can also make the choice to use tiny specialized LLM judges. With often a couple billion parameters, they can run locally on most recent consumer hardware, while being trained from scratch or fine-tuned using instruction data. You often need to follow their specific prompt formats.
261
+
262
+ Some existing models:
263
+ - Flow-Judge-v0.1 ([weights](https://huggingface.co/collections/flowaicom/flow-judge-v01-66e6af5fc3b3a128bde07dec)), 3.8B parameters, a Phi-3.5-mini-instruct fine-tuned on a synthetic preference dataset
264
+ - Prometheus ([weights](https://huggingface.co/prometheus-eval/prometheus-13b-v1.0), [paper](https://arxiv.org/abs/2310.08491)), 13B parameters, a model trained from scratch on synthetic preference dataset. A 7B parameter [v2](https://huggingface.co/prometheus-eval/prometheus-7b-v2.0) also exists, a Mistral-7B-Instruct-v0.2 fine-tune on a bigger synthetic preference dataset, with added weight merging
265
+ - JudgeLM ([paper](https://arxiv.org/abs/2310.17631)), 7B to 33B parameters, models trained from scratch on synthetic preference datasets generated with a variety of models.
266
+
267
+ **Training your own**
268
+ You can also make the choice to train or fine-tune your own LLM-as-judge. (I would avoid doing this, unless you are on a very niche topic).
269
+
270
+ You first need to gather preference data for your task of interest, which can come
271
+ - From existing [human preference datasets](https://www.kaggle.com/competitions/lmsys-chatbot-arena)
272
+ - From model generated preference data (which you can generate following the above tiny-model judges papers data sections, or get directly, for example from the Prometheus [preference](https://huggingface.co/datasets/prometheus-eval/Preference-Collection) and [feedback](https://huggingface.co/datasets/prometheus-eval/Feedback-Collection) collections).
273
+
274
+ Then you need to decide whether to start from a small model to train from scratch, or from an existing model, that you can
275
+ - distill into a new smaller model
276
+ - quantize.
277
+ - then fine-tune (using peft or adapter weights if the model is big and your training compute low) using the above data
278
+ - apparently [starting from a reward model works better than from an instruct model](https://x.com/dk21/status/1826292289930674590)
279
+
280
+ #### Designing your evaluation prompt
281
+
282
+ Once you've selected your model, you need to define what is the best possible prompt for your task.
283
+
284
+ Some general guidelines I've come across online when designing the prompt itself are:
285
+ - Provide a clear description of the task at hand:
286
+ - `Your task is to do X`.
287
+ - `You will be provided with Y`.
288
+ - Provide clear instructions on the evaluation criteria, including a detailed scoring system if needed:
289
+ - `You should evaluate property Z on a scale of 1 - 5, where 1 means ...`
290
+ - `You should evaluate if property Z is present in the sample Y. Property Z is present if ...`
291
+ - Provide some additional "reasoning" evaluation steps:
292
+ - `To judge this task, you must first make sure to read sample Y carefully to identify ..., then ...`
293
+ - Specify the desired output format (adding fields will help consistency)
294
+ - `Your answer should be provided in JSON, with the following format {"Score": Your score, "Reasoning": The reasoning which led you to this score}`
295
+
296
+ <Note title="Core prompt design principles" emoji="📝" variant="info">
297
+
298
+ **Essential elements for effective judge prompts:**
299
+ - **Clear task description**: Specify exactly what the judge needs to do
300
+ - **Detailed criteria**: Provide explicit scoring scales with clear definitions
301
+ - **Reasoning steps**: Guide the judge through the evaluation process
302
+ - **Structured output**: Use JSON format for consistency and parsability
303
+
304
+ </Note>
305
+
306
+ You can and should take inspiration from [MixEval](https://github.com/huggingface/lighteval/blob/main/src/lighteval/tasks/extended/mix_eval/judge_prompts.pyy) or [MTBench](https://github.com/huggingface/lighteval/blob/main/src/lighteval/tasks/extended/mt_bench/judge_prompt_templates.py) prompt templates.
307
+
308
+ Other tidbits:
309
+ - Pairwise comparison [correlates better with human preference](https://arxiv.org/abs/2403.16950) than scoring, and is more robust generally.
310
+ - If you really want a score, use an integer scale make sure you provide a detailed explanation for what [each score represents](https://x.com/seungonekim/status/1749289437165769177), or an additive prompt (`provide 1 point for this characteristic of the answer, 1 additional point if ...` etc)
311
+ - Using one prompt per capability to score tends to give better and more robust results
312
+
313
+ You can also improve accuracy using the following, possibly more costly, techniques:
314
+ - **Few shot examples**: like in many other tasks, if you provide examples it can help its reasoning. However, this adds to your context length.
315
+ - **Reference**: you can also enhance your prompt with a reference if present, which increases accuracy
316
+ - **CoT**: [improves accuracy for older gen models](https://arxiv.org/abs/2212.08073), if you ask the model to output its chain of thought **before** the score (also observed [here](https://x.com/seungonekim/status/1749289437165769177))
317
+ - **Multiturn analysis**: can improve [factual error detection](https://arxiv.org/abs/2305.13281)
318
+ - Using **a jury** (many judges, where you pick an aggregate of the answers): [gives better results](https://arxiv.org/abs/2404.18796) than using a single model.
319
+ - It can be made considerably less costly by leveraging many smaller models instead of one big expensive model.
320
+ - You can also experiment with using one model with variations on temperature
321
+ - Surprisingly, the community has found that adding stakes to the prompts (`answer correctly and you'll get a kitten`) can increase correctness. Your mileage may vary on this one, adapt to your needs.
322
+
323
+ <Note title="High-stakes evaluation requires rigor" emoji="⚠️" variant="warning">
324
+
325
+ For production or critical use cases, use methodologies transferred from the humanities:
326
+ - Compute inter-annotator agreement metrics
327
+ - Use proper survey design methodology to mitigate bias
328
+ </Note>
329
+
330
+ However, most people don't really want a reproducible and high quality unbiased eval, and will be happy with quick and dirty evaluation through OK-ish prompts. (Which is an OK situation to be in! Just depends on the consequences attached).
331
+
332
+ #### Evaluating your evaluator
333
+
334
+ Before using a judge-LLM in production or at scale, you want to evaluate its quality for your task, to make sure its scores are actually relevant and useful for you.
335
+
336
+
337
+ <Note>
338
+ This will be easier to do if it predicts binary outputs, because you'll be able to interpretable classification metrics (accuracy/recall/precision). If it predicts scores on a scale, it will be much harder to estimate the quality of the correlation with a reference.*
339
+ </Note>
340
+
341
+ So, once you have selected your model judge and its prompt, you'll need to do the following.
342
+
343
+ 1. **Pick your baseline**
344
+ You'll need to compare your evaluator judgments to a baseline: it can be human annotations, the output of another judge model that you know is qualitative on your task, a gold truth, itself with another prompt, etc.
345
+
346
+ <Note title="Quality over quantity for baseline" emoji="🎯" variant="info">
347
+
348
+ You don't need many baseline examples (50 can suffice), but they must be:
349
+ - **Representative**: Cover the full range of your task
350
+ - **Discriminative**: Include edge cases and challenging examples
351
+ - **High quality**: Use the best reference data you can obtain
352
+
353
+ </Note>
354
+
355
+ 2. **Pick your metric**
356
+ Your metric will be used to compare your judge's evaluations with your reference.
357
+
358
+ In general, this comparison is considerably easier to do if your model is predicting binary classes or doing pairwise comparison, as you'll be able to compute accuracy (for pairwise comparison), or precision and recall (for binary classes), which are all very easy to interpret metrics.
359
+
360
+ Comparing the correlation of scores with human or model scoring will be harder to do. To understand why in more detail, I advise you to read this cool [blog section on the topic](https://eugeneyan.com/writing/llm-evaluators/#key-considerations-before-adopting-an-llm-evaluator).
361
+
362
+ In general, if you're a bit lost about what metrics to pick when (in terms of models, metrics, ...), you can also look at [this interesting graph](https://eugeneyan.com/assets/llm-eval-tree.jpg) from [the same above blog](https://eugeneyan.com/writing/llm-evaluators/) ⭐.
363
+
364
+ 3. **Evaluate your evaluator**
365
+ For this step, you simply need to use your model and its prompt to evaluate your test samples! Then, once you get the evaluations, use your above metric and reference to compute a score for your evaluations.
366
+
367
+ You need to decide what your threshold for acceptance is. Depending on how hard your task is, you can aim for 80% to 95% accuracy, if you're doing pairwise comparison. Regarding correlations (if you're using scores), people in the literature tend to seem happy with 0.8 Pearson correlation with a reference. However, I've seen some papers declare that 0.3 indicates a good correlation with human annotators (^^") so ymmv.
368
+
369
+ #### Tips and tricks
370
+
371
+ **Mitigating well known biases of LLM as judges**
372
+
373
+ <Note title="Known LLM judge biases and mitigations" emoji="⚠️" variant="warning">
374
+ - **Lack of internal consistency**: a judge might give you different judgments if you prompt it several times (if the temperature is not 0)
375
+ - You can mitigate this by doing self-consistency prompting of your judge, prompting it multiple times and keeping the majority output
376
+ - **Self-preference**: they tend to [favor their own outputs](https://arxiv.org/abs/2404.13076) when scoring answers
377
+ - You can mitigate this by using a jury
378
+ - **Blindness to input perturbation**: models are bad at identifying [perturbated input](https://arxiv.org/abs/2406.13439) and tangentially [bad at providing consistent score ranges](https://twitter.com/aparnadhinak/status/1748368364395721128) (extended experiments on this [here](https://github.com/LeonEricsson/llmjudge/blob/main/README.md)). For example, if asked to rank text quality on text where noise has been added on a consistent scale, the grades predicted do not reflect this scale.
379
+ - You can mitigate this by
380
+ - asking the model to explain its reasoning [before providing a score](https://twitter.com/seungonekim/status/1749289437165769177)
381
+ - providing a coherent grading scale in the prompt.
382
+ - **Position-bias**: they tend to [favor specific answer positions](https://arxiv.org/abs/2306.05685). For example, when presented with pairwise comparisons, Claude and GPT3.5 tend to quite systematically prefer the first choice, or the second choice
383
+ - You can mitigate this by
384
+ - switching answer positions randomly
385
+ - computing the log-probabilities of all possible choices to get a normalized answer
386
+ - **Verbosity-bias** (or length-bias): they tend to like more verbose answers
387
+ - You can mitigate this by [accounting for the answer difference in length](https://arxiv.org/abs/2404.04475)
388
+ - **Debatable consistency [with human answers](https://arxiv.org/abs/2308.15812):**
389
+ - However, it's also [debatable if non-expert humans are a good baseline for absolutely all evaluations](https://arxiv.org/abs/2202.06935). For some specific domains (medical, legal, mathematics, etc), relying on non-expert human annotators is as bad a baseline as using an LLM directly.
390
+ - **Format bias**: they tend to fail to evaluate accurately if the prompt format [is too far away](https://arxiv.org/abs/2310.17631) from what it's been trained with. For example, a model trained to do pairwise comparison with an added reference answer will fail if said answer is not provided, and failures will also occur the other way around.
391
+ - You can mitigate this by paying attention to the training prompt format (if the model was instruction tuned) and ensuring you follow it.
392
+ </Note>
393
+
394
+ **Picking correct tasks for an LLM judge**
395
+
396
+ LLM evaluators:
397
+ - are **bad at identifying hallucinations** in general, particularly what are called partial hallucinations (which look close to the ground truth but are actually slightly different) (see [this](https://arxiv.org/abs/2305.11747) and [this](https://arxiv.org/abs/2303.08896))
398
+ - have a low to OK-ish correlation with human annotators on [summarization](https://arxiv.org/abs/2304.02554) ([here too](https://arxiv.org/abs/2303.16634)), [faithfulness](https://arxiv.org/abs/2307.16877), and are not consistently correlated with human judgement more broadly against [a scope of tasks](https://arxiv.org/abs/2406.18403)
399
+
400
+ #### What about Reward Models?
401
+
402
+ Reward models learn to predict a score from human annotations for given prompt/completion pairs. The end goal is for them to do predictions aligned with human preference.
403
+ Once trained, these models can then be used to improve other models, by acting as a a reward function which is a proxy for human judgment.
404
+
405
+ The most common type of reward model is the Bradley-Terry model, which outputs a single **pairwise score**, following:
406
+
407
+ $$p(\text{completion b is better than completion a}) = \text{sigmoid}(\text{score}_b - \text{score}_a)$$
408
+
409
+ This model is trained using only pairwise comparisons of completions, which are easier to collect than scores, but can only compare several completions for one prompt, and not completions across prompts.
410
+
411
+ Other models have expanded on this approach to predict a more nuanced probability that a completion is better than the other one ([example](https://huggingface.co/RLHFlow/pair-preference-model-LLaMA3-8B)).
412
+
413
+ This allows them to (theoretically) judge subtle differences between completions, at the cost of not being able to easily save and compare many different scores across prompts for the same test set. In addition, context length and memory limits can become an issue when comparing too long completions.
414
+
415
+ Some reward models such as [SteerLM](https://arxiv.org/abs/2311.09528) output **absolute scores**, which can be used to evaluate completions directly without the need for pairwise comparisions. These models can be easier to use for evaluation, but are also harder to collect data for, as absolute scores tend to be less stable than pairwise scores in human preferences.
416
+
417
+ More recently, models have been proposed that output both absolute and relative scores, such as [HelpSteer2-Preference](https://arxiv.org/abs/2410.01257) and [ArmoRM](https://arxiv.org/abs/2406.12845).
418
+
419
+ <Note title="How do I use a Reward Model for Evaluation?">
420
+
421
+ Given a dataset of prompts, we can generate completions from a language model and ask a reward model to score them.
422
+
423
+ For models that give absolute scores, the resulting scores can be averaged to get a reasonable summary score.
424
+
425
+ However, in the more common case of relative scores, the average reward can be biased by outliers (a few very good or very bad completions) as different prompts may have inherently different reward scales (some prompts are way harder or easier than others).
426
+
427
+ <Sidenote>
428
+
429
+ For relative scores, don't just average raw rewards—outliers and varying prompt difficulty scales will bias results. Use win rates or win probabilities against a reference instead.
430
+
431
+ </Sidenote>
432
+
433
+ Instead, we can use
434
+ - win rates: take a reference set of completions and calculate the percentage of completions from the model that are ranked higher than the reference completions. It is slightly more granular.
435
+ - win probabilities: the mean probability of the completions being better than the reference completions, which can give a more fine-grained and smoothly changing signal.
436
+ </Note>
437
+
438
+ <Note title="Pros and Cons of Reward Models">
439
+ Reward models are typically:
440
+ - **Very fast**: Getting a score is as simple as running a forward pass of a relatively small model once (since we only get a score, and not long text, contrary to judge-LLMs)
441
+ - **Deterministic**: The same scores will be reproduced through the same forward pass
442
+ - **Unlikely to suffer from positional bias**: As most models take only one completion, they can not be influenced by the order. For pairwise models, positional bias is often also minimal, as long as the training data was balanced with respect to containing both first and second answers as being the best.
443
+ - **Require no prompt engineering**: since the model will simply output a score from one or two completions depending on preference data it's been trained on.
444
+
445
+ On the other hand they:
446
+ - **Require specific fine-tuning**: This can be a relatively costly step, and elthough they inherit many capabilities from a base model, they may still perform poorly on tasks that are out of the training distribution.
447
+ - **Loose efficiency when used both in reinforcement learning and evaluation** (or when using direct alignment algorithms on datasets that are similar to the training data of the reward model), as the language model may overfit to the reward model's preferences.
448
+ </Note>
449
+
450
+
451
+ <Note title="Going further">
452
+ - A good place to find high performing models is the [RewardBench Leaderboard](https://huggingface.co/spaces/allenai/reward-bench).
453
+ - You can look at how reward models have been used in the [Nemotron](https://arxiv.org/abs/2406.11704) paper.
454
+ - For reward models that rate single prompts and completions, you can cache the scores of many reference models and easily see how a new model performs.
455
+ - Tracking of win rates or probabilities over training, e.g. as in [this](https://arxiv.org/abs/2410.11677v1) paper, can allow you to detect model degradation and select optimal checkpoints.
456
+ </Note>
app/src/content/chapters/automated-benchmarks/tips-and-tricks.mdx DELETED
@@ -1,73 +0,0 @@
1
- ---
2
- title: "Automated Benchmarks: Tips and tricks"
3
- ---
4
-
5
- import Note from "../../../components/Note.astro";
6
- import Sidenote from "../../../components/Sidenote.astro";
7
-
8
-
9
- ### Pros and cons of using automated benchmarks
10
- Automated benchmarks have the following advantages:
11
- - **Consistency and reproducibility**: You can run the same automated benchmark 10 times on the same model and you'll get the same results (baring variations in hardware or inherent model randomness). This means that you can easily create fair rankings of models for a given task.
12
- - **Scale at limited cost**: They are one of the cheapest way to evaluate models at the moment.
13
- - **Understandability**: Most automated metrics are very understandable.
14
- *Eg: an exact match will tell you if the generated text matches perfectly with the reference, and an accuracy score will tell you in how many cases the selected choice was the correct one (this will be a bit less the case for metrics such as `BLEU` or `ROUGE` for example).*
15
- - **Dataset quality**: A number of automated benchmarks are using expert generated datasets or pre-existing high quality data (like MMLU or MATH). However, this does not mean these datasets are perfect: for MMLU, several errors have been identified in samples afterwards, from parsing issues to actually non-sensical questions, leading to the creation of several follow-up datasets, like MMLU-Pro and MMLU-Redux.
16
-
17
- <Sidenote>
18
-
19
- Several errors in MMLU (parsing issues, nonsensical questions) led to improved versions like MMLU-Pro and MMLU-Redux. Always inspect benchmark samples manually before relying on them for evaluation.
20
- </Sidenote>
21
-
22
- However, they also present the following limitations:
23
- - **Reduced use on more complex tasks**: Automated benchmarks are working well for tasks where performance is easy to define and assess (for example, classification). More complex capabilities, on the other hand, are harder to decompose into well-defined and precise tasks.
24
- *Eg: what does "good at math" mean? Is it being good at arithmetic? - at logic? - able to reason on new mathematical concepts?*
25
- This led to the use of more **generalist** evaluations, which no longer decompose capabilities in sub-tasks, but assuming that general performance will be a **good proxy** for what we aim to measure.
26
- - **Contamination**: Once a dataset is published publicly in plain text, it will end up in model training datasets. This means that you have no guarantee when scoring a model that it has not parsed the evaluation data before.
27
-
28
-
29
- ### Tips and tricks
30
-
31
- #### Managing contamination
32
- In general, you should assume that a dataset publicly available on the internet is or will be contaminated.
33
-
34
- <Note title="Assume contamination" emoji="🔍" variant="warning">
35
-
36
- You should assume that any dataset publicly available on the internet is or will be contaminated in model training data. Design your evaluation strategy with this assumption in mind.
37
- </Note>
38
-
39
- Solutions to mitigate this include:
40
- - providing a **canary string** in the evaluation set (like in [BigBench](https://github.com/google/BIG-bench)): it is a specific character combination that model creators can look for in their training sets, which would indicate that it contains an evaluation
41
- - providing evaluation sets in **[encrypted](https://arxiv.org/abs/2309.16575) or [gated](https://huggingface.co/datasets/Idavidrein/gpqa)** forms so that they can't be parsed easily by web crawlers - therefore not ending up accidentally in training sets
42
- - running [dynamic benchmarks](https://arxiv.org/abs/2104.14337): benchmarks regularly updated through time so that models can't "learn the answers by heart" (but it makes datasets more costly)
43
- - if you are running a benchmark, trying to [detect contamination](https://arxiv.org/abs/2311.06233) post-hoc (for example, by looking at the generation perplexity or designing adversarial versions of the prompts - however, no method is a foolproof contamination detection method)
44
-
45
- <Sidenote>
46
-
47
- Even contaminated datasets can provide useful signal during training. Performance improvements on contaminated benchmarks often correlate with genuine capability improvements, though the absolute scores may be inflated.
48
- </Sidenote>
49
-
50
- However, it's not because a dataset is contaminated that it won't still be interesting and have signal during training.
51
-
52
- #### Tip: an easy speed up for MCQA evaluations
53
- You can speed up your MCQA predictions by a lot if you make sure your model needs to predict only one token for the task.
54
-
55
- This way, instead of running your `number_of_choices` predictions (`context + choice 1`, `context + choice 2`, etc), you can simply run inference on `context` and compute the probability distribution on the full vocabulary (which will include all your one token choices) to get your logprobabilities of interest, and do this step in one pass.
56
-
57
- <Note title="Speed optimization for MCQA" emoji="⚡" variant="success">
58
-
59
- Speed up MCQA evaluations by using single-token choices. Instead of running N predictions for N choices, run inference once on the context and examine the probability distribution over all vocabulary tokens (which includes your choices). This is how `lighteval` achieves fast MCQA evaluation.
60
- </Note>
61
-
62
- (That's how we do it in `lighteval`).
63
-
64
- #### What to do if you get unexpectedly bad results on generative evaluations
65
-
66
- The first thing to do is always to inspect your model generations in detail. Some frequent things to look for when troubleshooting are:
67
- - too strict model output parsing (before computing the metric) which leads to the answer being lost
68
- - Fixing: adapt your parsing
69
- - unability of the models to follow your output format in few shot (frequent in recent models trained with instructions data, like llama 3.2 or Qwen 2.5)
70
- - Fixing: either adapt your prompt format, or just assume that models should be able to follow it in few shot
71
- - exceedingly verbose model which never gets to the correct answer (more frequent in long context models and something we observed with Qwen and CommandR models)
72
- - Fixing: either increase the allowed context length, add instructions to be concise in the task prompt, or just assume that models should be able to answer succinctly
73
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/src/content/chapters/{2025-evaluations-for-useful-models.mdx → general-knowledge/2025-evaluations-for-useful-models.mdx} RENAMED
@@ -2,8 +2,8 @@
2
  title: "2025 evaluations"
3
  ---
4
 
5
- import Note from "../../components/Note.astro";
6
- import Sidenote from "../../components/Sidenote.astro";
7
 
8
  You can evaluate **specific capabilities** on their own - it's usually quite interesting to get signal when training, or when comparing base/pretrained models. (However, if you select and validate your training methods with the following evaluations, reporting on them on the final model is slightly biased as you have already oriented your training method towards good results on them).
9
 
 
2
  title: "2025 evaluations"
3
  ---
4
 
5
+ import Note from "../../../components/Note.astro";
6
+ import Sidenote from "../../../components/Sidenote.astro";
7
 
8
  You can evaluate **specific capabilities** on their own - it's usually quite interesting to get signal when training, or when comparing base/pretrained models. (However, if you select and validate your training methods with the following evaluations, reporting on them on the final model is slightly biased as you have already oriented your training method towards good results on them).
9
 
app/src/content/chapters/{picking-your-evaluation.mdx → general-knowledge/picking-your-evaluation.mdx} RENAMED
@@ -4,11 +4,8 @@ title: "Picking good automatic evaluations for pretraining"
4
 
5
  import Note from "../../../components/Note.astro";
6
  import Sidenote from "../../../components/Sidenote.astro";
7
- import HtmlEmbed from "../../../components/HtmlEmbed.astro";
8
 
9
- ## What Makes a Task "Fine"?
10
-
11
- Covering all 7000+ languages spoken over the world would be monumental endeavor, so we settled on using **9 languages** that offered diversity in script, language family and resource availability: **Chinese, French, Arabic, Russian, Thai, Hindi, Turkish, Swahili, and Telugu**.
12
 
13
  For these languages, we collected all available tasks that we could find, implementing a total of **185 tasks across languages** in [LightEval](https://github.com/huggingface/lighteval), HuggingFace's model evaluation library.
14
 
@@ -24,8 +21,6 @@ For evaluation diversity, we aimed to assess a broad range of model capabilities
24
 
25
  We consider that tasks provide a reliable signal if they provide a dependable score. This means the score should be above the random baseline, increase as training progresses, show low variability across different seeds, and provide consistent model ranking at each training step<d-footnote>For similar sized models trained with the same hyperparameters on the same amount of data.</d-footnote>.
26
 
27
- ### Finding how much signal our tasks give during pre-training
28
-
29
  To thoroughly examine the signal our tasks provide, we trained many 1.5B parameter models for each language, using 30B tokens from subsets of the supported languages of the five largest openly available multilingual web datasets. These models were trained with the same hyperparameters and tokenizer. We then evaluated them at regular checkpoint intervals on the collected tasks (with no instruction and no system prompt in a 0-shot setting).
30
 
31
  This process required multiple evaluation runs for each task due to iterations on its implementation, resulting in a total of **73 000 GPU hours consumed** 🔥!
@@ -101,26 +96,7 @@ We had no strict minimum value requirement for this property, instead using it t
101
  </div>
102
 
103
 
104
- ## Important properties of evaluation impacting stability
105
-
106
- Now that we covered what we were looking for in our tasks, let's examine two important aspects that can affect the above properties: task formulations and metric choice.
107
-
108
- <Note>Both of these aspects are thoroughly described and studied in the brilliant OLMES paper [Gu et al., 2024](https://arxiv.org/abs/2406.08446), which greatly inspired our work.</Note>
109
-
110
- ### Task Formulations
111
-
112
- The way tasks are presented to the model is crucial, particularly for multiple-choice (MC) tasks. In these scenarios, we must carefully determine how the choices are displayed and what the model is expected to predict.
113
-
114
- There are two common approaches: **Cloze Formulation** (CF) and **Multi-Choice Formulation** (MCF). In CF, choices are not provided in context, allowing the model to predict each option directly. In contrast, MCF presents the choices in the prompt, using A/B/C/D prefixes, with the targets being those letter prefixes.
115
-
116
- It's important to know that:
117
-
118
- - The choice of formulation significantly impacts task scores (see [the release blog of the Open LLM Leaderboard 2](https://huggingface.co/spaces/open-llm-leaderboard/blog)).
119
- - Both formulations **behave very differently during training**. As noted by both OLMES [Gu et al., 2024](https://arxiv.org/abs/2406.08446) and DataComp-LM [Li et al., 2024](https://arxiv.org/abs/2406.11794), when employing MCF, task scores initially show random performance over extended training periods before experiencing a sudden increase. Conversely, with CF, task scores improve right from the beginning but tend to plateau relatively early.
120
-
121
- Therefore, we decided to utilize CF for task selection and MCF for later evaluation of major open source models, as they have generally undergone enough training for these evaluations to have a signal.
122
-
123
- ### Metrics
124
 
125
  As the targets in CF of multiple choice tasks are choices themselves, each target can have a different number of tokens, characters, and unconditional probability (probability of generating the choice without a context prefix).
126
 
@@ -129,15 +105,15 @@ As the targets in CF of multiple choice tasks are choices themselves, each targe
129
  To account for this, we consider the following accuracy variations:
130
 
131
  - **Accuracy** :
132
- `acc` = <d-math>\underset{i}{\arg\max}(ln(P (a_i|q)))</d-math>
133
  - **Accuracy normalized over character length** :
134
- `acc_char` = <d-math> \underset{i}{\arg\max}\frac{ln(P (a_i|q))}{num\_characters(a_i)}</d-math>
135
  - **Accuracy normalized over token length** :
136
- `acc_token` = <d-math> \underset{i}{\arg\max}\frac{ln(P (a_i|q))}{num\_tokens(a_i)}</d-math>
137
  - **PMI Accuracy** :
138
- `acc_pmi` = <d-math> \underset{i}{\arg\max}ln\frac{P (a_i|q)}{P (a_i|u)}</d-math>, where <d-math>u =</d-math>''Answer:''
139
 
140
- Where <d-math>a_i</d-math> is the answer choice <d-math>i</d-math>, <d-math>q</d-math> is a question prompt and <d-math>P (a_i|q)</d-math> is the probability of having <d-math>a_i</d-math> follow <d-math>q</d-math>. For more details see [Gu et al., 2024](https://arxiv.org/abs/2406.08446) and [Biderman et al., 2024](https://arxiv.org/abs/2405.14782).
141
 
142
  <Note>`acc_pmi` metric measures how much more likely a model is to predict A_i if provided with question context compared to if there was no context at all. This can be useful if the correct choice contains generally unlikely tokens, making the model less likely to choose such an answer.</Note>
143
 
@@ -148,56 +124,14 @@ For our generative tasks on the other hand, we used the following metrics:
148
 
149
  For both generative metrics, minor preprocessing is applied to remove articles and punctuation, and lowercase the text.
150
 
151
- ## The Fine selection
152
-
153
- With our goals and evaluation setup properly defined, we proceeded with **task selection**!
154
-
155
- We reviewed tasks one by one, choosing based on the quantified properties. For each language, we aimed to have at least one task for each of the four categories outlined above. Additionally we wanted to have at least 1 generative task for each language.
156
-
157
- In cases where multiple versions of a task existed (e.g., MMLU with different translation methods or native versions), we **prioritized native versions** as long as their metrics were reasonable, followed by human translations of English tasks. If no such version was available, we made our selection entirely based on metrics.
158
-
159
- Thus, **after removing about half of the tasks**, we arrived at **96 final ones**, forming "FineTasks."
160
-
161
- ### Explore tasks
162
-
163
- Use the dropdowns below to navigate the list of tasks and how different metrics affect them.
164
-
165
- <div id="fine-tasks-results"></div>
166
-
167
- All tasks from the selection **comply with the criteria** outlined in previous sections, with the only exception being indicqa_tel, which we chose to include to ensure we had at least one generative task for Telugu. Overall we managed to cover all task categories for each language (the only exception being Thai Reasoning, where all tasks were unfortunately too noisy with low monotonicity to consider them).
168
-
169
- One of the **biggest surprises** was that some tasks, even when translated using the same method, were **reliable in one language but not in others**. This was evident with xWinograd, which worked quite well for Russian but did not meet our conditions for French. An even more extreme example was XNLI, which performed well for 6 out of 7 languages, failing to satisfy the reliability properties for Chinese. We had to test four different implementations before finding a reliable version, which, interestingly, was the only one that was created by native speakers and not machine translated.
170
-
171
- Feel free to use the dropdowns below to explore the evolution of scores over training for all tested tasks and metrics.
172
-
173
- <div class="task-signal-plot" data-language="French" data-task="frenchbench_hellaswag_fra_cf" data-show-controls="true" data-metric="acc_norm_token" data-group-seeds="true" data-title=""></div>
174
-
175
-
176
- ### Metrics recommendation
177
-
178
  Selecting the best evaluation metrics proved to be a **challenging task**. Not only is there no single metric that consistently outperforms the rest, but we often encountered situations where one metric had better monotonicity while another had a higher signal-to-noise ratio. In such cases, we typically made our decision based on the selected metric for tasks' implementation in a different language. We are aware that such hand-picking is often not possible and thus offer the following recommendations:
179
 
180
- #### Multichoice Tasks
181
 
182
  - We found **base accuracy** to perform well for tasks with answer options varying subtly (e.g. Yes/No/Also), particularly NLI tasks. In such cases, where the answer options are often each a single token, the base accuracy is advisable to use.
183
  - While OLMES [Gu et al., 2024](https://arxiv.org/abs/2406.08446) recommends using PMI for tasks with unusual words, we found **PMI** to be highly effective for "difficult" reasoning and knowledge tasks like AGIEVAL or MMLU. In these cases, PMI provided the best results and was often the only metric delivering performance above random. That said, PMI was, on average, the weakest metric across all other tasks, while also being two times more expensive to compute. We therefore only recommend its use for complex reasoning and knowledge tasks.
184
  - The metrics we found to be **most reliable overall** were length normalization metrics (token or character-based). However, the best choice was dependent on language, rather than being consistent for a given task. Due to that, we recommend using the maximum of acc_char and acc_token for the most reliable results.<d-footnote>Note that acc_token is heavily tokenizer dependent. On our ablations all models were trained using the same tokenizer.</d-footnote>
185
 
186
- #### Generative Tasks
187
 
188
  For **generative metrics**, the choice is clearer: we suggest using the F1 score unless exact matching is required, as in math-related tasks. F1 is generally less noisy and more resilient to small changes in the generations.
189
-
190
-
191
- ## Open/Closed Source models tackle FineTasks
192
-
193
- Since we spent a lot of time and compute on task selection, we were interested in how well major **open-source** models would do on FineTasks. Given that our evaluation suite primarily targets pretrained models, we focused on these, with a few exceptions for models that don't offer a base (pretrained) version. These exceptions were included mainly out of curiosity, and their results should be interpreted with **caution**. Such models may significantly outperform other models due to the inclusion of supervised fine-tuning (SFT) data.
194
-
195
- To assess the multilingual performance disparity between open-source and closed-source models, we expanded our selection by adding a closed source model: **gpt-4o-mini**.
196
-
197
- As outlined in the task formulations, we are using MCF for this evaluation and employing a 5-shot approach, as recommended by OLMES [Gu et al., 2024](https://arxiv.org/abs/2406.08446) (and made possible by the large context size of the models).
198
-
199
- ### Computing a global "multilingual" score
200
-
201
- In the previous sections, we treated each task independently. However, to determine an overall "multilingual" score of a model, we need to **aggregate** the results from these tasks. We begin by **rescaling** the individual task scores in line with the OpenLLM leaderboard [Fourrier et al., 2024](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard). Then, we **average the scores** across task types (GK, RES, etc) for each language separately. To compute the score for each language, we take the average of the task type scores.<d-footnote>We first average by task type to properly measure all model capabilities without letting a single category dominate.</d-footnote>
202
-
203
- For the final global "multilingual" score we followed a different approach. Instead of averaging the language scores directly, we **ranked the model's performance across languages** in comparison to other models and then averaged those rank scores. This method ensures that the result reflects the overall model's performance across all languages, preventing an exceptionally high score in one language from skewing the final outcome.
 
4
 
5
  import Note from "../../../components/Note.astro";
6
  import Sidenote from "../../../components/Sidenote.astro";
 
7
 
8
+ This section mostly comes from the FineTasks blog, which describes how our FineWeb team designed a method to select the best evaluations for pre-training ablations, across 9 languages!
 
 
9
 
10
  For these languages, we collected all available tasks that we could find, implementing a total of **185 tasks across languages** in [LightEval](https://github.com/huggingface/lighteval), HuggingFace's model evaluation library.
11
 
 
21
 
22
  We consider that tasks provide a reliable signal if they provide a dependable score. This means the score should be above the random baseline, increase as training progresses, show low variability across different seeds, and provide consistent model ranking at each training step<d-footnote>For similar sized models trained with the same hyperparameters on the same amount of data.</d-footnote>.
23
 
 
 
24
  To thoroughly examine the signal our tasks provide, we trained many 1.5B parameter models for each language, using 30B tokens from subsets of the supported languages of the five largest openly available multilingual web datasets. These models were trained with the same hyperparameters and tokenizer. We then evaluated them at regular checkpoint intervals on the collected tasks (with no instruction and no system prompt in a 0-shot setting).
25
 
26
  This process required multiple evaluation runs for each task due to iterations on its implementation, resulting in a total of **73 000 GPU hours consumed** 🔥!
 
96
  </div>
97
 
98
 
99
+ #### Metrics
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  As the targets in CF of multiple choice tasks are choices themselves, each target can have a different number of tokens, characters, and unconditional probability (probability of generating the choice without a context prefix).
102
 
 
105
  To account for this, we consider the following accuracy variations:
106
 
107
  - **Accuracy** :
108
+ `acc` = $\underset{i}{\arg\max}(ln(P (a_i|q)))$
109
  - **Accuracy normalized over character length** :
110
+ `acc_char` = $\underset{i}{\arg\max}\frac{ln(P (a_i|q))}{num\_characters(a_i)}$
111
  - **Accuracy normalized over token length** :
112
+ `acc_token` = $\underset{i}{\arg\max}\frac{ln(P (a_i|q))}{num\_tokens(a_i)}$
113
  - **PMI Accuracy** :
114
+ `acc_pmi` = $\underset{i}{\arg\max}ln\frac{P (a_i|q)}{P (a_i|u)}$, where $u =$ ''Answer:''
115
 
116
+ Where $a_i$ is the answer choice $i$, $q$ is a question prompt and $P (a_i|q)$ is the probability of having $a_i$ follow $q$. For more details see [Gu et al., 2024](https://arxiv.org/abs/2406.08446) and [Biderman et al., 2024](https://arxiv.org/abs/2405.14782).
117
 
118
  <Note>`acc_pmi` metric measures how much more likely a model is to predict A_i if provided with question context compared to if there was no context at all. This can be useful if the correct choice contains generally unlikely tokens, making the model less likely to choose such an answer.</Note>
119
 
 
124
 
125
  For both generative metrics, minor preprocessing is applied to remove articles and punctuation, and lowercase the text.
126
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  Selecting the best evaluation metrics proved to be a **challenging task**. Not only is there no single metric that consistently outperforms the rest, but we often encountered situations where one metric had better monotonicity while another had a higher signal-to-noise ratio. In such cases, we typically made our decision based on the selected metric for tasks' implementation in a different language. We are aware that such hand-picking is often not possible and thus offer the following recommendations:
128
 
129
+ ➡️ Multichoice Tasks
130
 
131
  - We found **base accuracy** to perform well for tasks with answer options varying subtly (e.g. Yes/No/Also), particularly NLI tasks. In such cases, where the answer options are often each a single token, the base accuracy is advisable to use.
132
  - While OLMES [Gu et al., 2024](https://arxiv.org/abs/2406.08446) recommends using PMI for tasks with unusual words, we found **PMI** to be highly effective for "difficult" reasoning and knowledge tasks like AGIEVAL or MMLU. In these cases, PMI provided the best results and was often the only metric delivering performance above random. That said, PMI was, on average, the weakest metric across all other tasks, while also being two times more expensive to compute. We therefore only recommend its use for complex reasoning and knowledge tasks.
133
  - The metrics we found to be **most reliable overall** were length normalization metrics (token or character-based). However, the best choice was dependent on language, rather than being consistent for a given task. Due to that, we recommend using the maximum of acc_char and acc_token for the most reliable results.<d-footnote>Note that acc_token is heavily tokenizer dependent. On our ablations all models were trained using the same tokenizer.</d-footnote>
134
 
135
+ ➡️ Generative Tasks
136
 
137
  For **generative metrics**, the choice is clearer: we suggest using the F1 score unless exact matching is required, as in math-related tasks. F1 is generally less noisy and more resilient to small changes in the generations.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/src/content/chapters/human-evaluation/basics.mdx DELETED
@@ -1,88 +0,0 @@
1
- ---
2
- title: "Human Evaluation: Basics"
3
- ---
4
-
5
- import Note from "../../../components/Note.astro";
6
- import Sidenote from "../../../components/Sidenote.astro";
7
-
8
- Human evaluation is simply asking humans to evaluate models. In this document, we'll look at post-hoc evaluation: your model has been trained, you have a given task in mind, and humans are providing scores.
9
-
10
- ### Systematic evaluation
11
- There are 3 main ways to do this in a systematic manner.
12
-
13
- If **you don't have a dataset**, but want to explore a set of capabilities, you provide humans with
14
- - a task and scoring guidelines (e.g *Try to make both these model output toxic language; a model gets 0 if it was toxic, 1 if it was not.*)
15
- - access to one (or several) model(s) that they can interact with,
16
-
17
- then ask them to provide their scores and reasoning.
18
-
19
- If **you already have a dataset** (eg: a set of *prompts that you want your model to never answer*, for example for safety purposes), you preprompt your model with them, and provide the prompt, output and scoring guidelines to humans.
20
-
21
- Lastly, if **you already have a dataset and scores**, you can ask humans to review your evaluation method by doing [error annotation](https://ehudreiter.com/2022/06/01/error-annotations-to-evaluate/) (*it can also be used as a scoring system in the above category*). It's a very important step of testing new evaluation system, but it technically falls under evaluating an evaluation, so it's slightly out of scope here.
22
-
23
- Notes:
24
- - For evaluation of already deployed production models, you can also ask users for feedback, and do A/B testing then.
25
- - [AI audits](https://arxiv.org/abs/2401.14462) (external systematic evaluation of models) are usually human based, but out of scope for this document.
26
-
27
- ### Casual evaluation
28
- Two other approaches exist to do human-based evaluation, in a more casual way.
29
-
30
- **Vibes-checks** are manual evaluations done by individuals, usually on undisclosed prompts, to get an overall feeling of how well models perform on many use cases (from coding to quality of smut written). Often shared on Twitter and Reddit, results mostly constitute anecdotal evidence, and tend to be highly sensitive to confirmation bias (in other words, people tend to find what they look for). However, they can be [good starting point for your own use cases](https://olshansky.substack.com/p/vibe-checks-are-all-you-need).
31
-
32
- <Sidenote>
33
-
34
- While vibe-checks are anecdotal and subject to confirmation bias, systematic approaches like [Wolfram Ravenwolf's comparisons](https://olshansky.substack.com/p/vibe-checks-are-all-you-need) can provide useful starting points for identifying use cases to evaluate formally.
35
- </Sidenote>
36
-
37
- **Arenas** are crowdsourced human evaluation to rank models.
38
- A well known example of this is the [LMSYS chatbot arena](https://huggingface.co/spaces/lmsys/chatbot-arena-leaderboard), where community users are asked to chat with models until they find one is better than the other. Votes are then aggregated in an Elo ranking (a ranking of matches) to select which model is "the best".
39
- ### Pros and cons of human evaluation
40
-
41
- Human evaluation is very interesting for the following reasons:
42
- - **Flexibility**: If you define clearly enough what you are evaluating, you can get scores for about anything!
43
- - **Absence of contamination**: If you ask humans to write new questions to test your system, they should not be present in your training data (hopefully)
44
- - **Correlation with human preference**: That one is quite obvious, since that's what you're using to score.
45
- *Note: However, when doing evaluation with humans, you need to make sure your annotators are diverse enough that your results generalizes.*
46
-
47
- However, it also present a number of limitations:
48
- - **First impressions bias**: Human evaluators tend to estimate the quality of answers [based on first impressions](https://arxiv.org/abs/2309.16349), instead of actual factuality or faithfulness.
49
- - **Tone bias**: Crowdsourced annotators are notably very sensitive to tone, and underestimate the number of factual or logical errors in an assertive answer. In other terms, if a model says wrong things in a confident tone, human evaluators are much less likely to notice it, which could skew ratings towards the more assertive models. (Expert annotators are less likely to fall prey to these biases.)
50
- - **Self-preference bias**: Humans are [most likely to prefer answers which appeal to their views or align with their opinions or errors](https://arxiv.org/abs/2310.13548), rather than answers which are factually correct.
51
- - **Identity bias**: People with different identities tend to have different values, and rate model answers very differently (for example on [toxicity](https://arxiv.org/abs/2205.00501))
52
-
53
- <Note title="Critical human evaluation biases" emoji="⚠️" variant="warning">
54
-
55
- Human evaluators have significant biases:
56
- - **First impressions**: Judge on presentation over factuality
57
- - **Tone**: Confident incorrect answers score higher than hesitant correct ones
58
- - **Self-preference**: Prefer answers aligning with their views over factually correct ones
59
- - **Identity**: Different demographics rate identical content very differently
60
-
61
- Expert annotators are less susceptible, but these biases affect crowdsourced evaluation significantly.
62
- </Note>
63
- ### Systematic human evaluation
64
- Pros of systematic human evaluations, especially with paid annotators, are
65
- - **Getting high quality data** adapted to your use case, that you will be able to build on later (if you need to develop preference models for example)
66
- - **Data privacy**: If you rely on paid human annotators, especially if in-house, your datasets should be relatively safe, whereas using LLM-evalution with closed source API models presents less guarantee on what happens to your data, since you send it to an external service.
67
- - **Explainability**: Scores obtained by the models will be explainable by the humans who annotated them.
68
-
69
- Systematic human evaluations present some added issues:
70
- - **Cost**: If you pay your annotators correctly, this can get expensive fast. It's also likely you'll need rounds of iterative evaluation so that you can refine your guidelines, which adds to the cost.
71
- - **Un-scalability**: Unless you are evaluating a production like system with user feedback, human evaluations are not really scalable, as each new round requires mobilizing new evaluators (and paying them).
72
- - **Lack of reproducibility**: Unless you keep the exact same annotators continuously and your guidelines are perfectly unambiguous, it's likely some evaluations are going to be hard to reproduce precisely.
73
-
74
- ### Casual human evaluation
75
- Pros of casual human evaluations are:
76
- - **Lesser cost**: since you rely on your crowd's good will
77
- - **Edge case discovery**: since you leverage user's creativity in a mostly unbounded manner, you can discover interesting edge cases
78
- - **Better scalability**: as long as you have many interested and willing participants, casual human evaluation scales better and has a lower entry cost
79
-
80
- The obvious problems of casual approaches (without annotator selection) are:
81
- - **High subjectivity**: it's hard to enforce a consistent grading from many community members using broad guidelines, especially since annotators preferences tend to be [culturally bound](https://arxiv.org/abs/2404.16019v1). One can hope that these effect is smoothed over by the sheer scale of the votes, through a "wisdom of the crowd" effect (see Galton's wikipedia page).
82
-
83
- <Sidenote>
84
-
85
- The "wisdom of the crowd" effect (discovered by statistician Galton) suggests individual biases cancel out at scale. However, this requires truly diverse crowds—tech forums skew heavily toward young western men, potentially undermining this effect.
86
- </Sidenote>
87
- - **Unrepresentative preference ranking**: since young western men are over re-represented on tech-sides of the internet, it can lead to very skewed preferences, mismatched to those of the general population, both in terms of topics explored and overall rankings.
88
- - **Easy to game**: if you're using unfiltered crowdsourced annotators, it's quite easy for a 3rd party to game your evaluation, for example to raise the score of a given model (since a number of models have a distinctive writing style)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/src/content/chapters/human-evaluation/tips-and-tricks.mdx DELETED
@@ -1,49 +0,0 @@
1
- ---
2
- title: "Human Evaluation: Tips and tricks"
3
- ---
4
-
5
- import Note from "../../../components/Note.astro";
6
- import Sidenote from "../../../components/Sidenote.astro";
7
-
8
- ### Tips and tricks
9
- Here are a few practical tips you might want consider when using human annotators to build an evaluation dataset. If you haven't done so yet, we recommend reading first the page on "Using human annotators" and then come back to this page.
10
-
11
- ### Designing the task
12
-
13
- - **Simple is better**: Annotation tasks can get unnecessarily complex, so keep it as simple as possible. Keeping the cognitive load of the annotators to a minimum will help you ensure that they stay focused and make annotations of a higher quality.
14
-
15
- - **Check what you show**: Only show the necessary information for annotators to complete the task and make sure you don't include anything that could introduce extra bias.
16
-
17
- - **Consider your annotators time**: Where and how things are displayed can introduce extra work or cognitive load and therefore negatively impact in the quality of results. For example, make sure that the texts and the task are visible together and avoid unnecessary scrolling. If you combine tasks and the result of one informs the other, you can display them sequentially. Think about how everything is displayed in your annotation tool and see if there's any way you can simplify even more.
18
-
19
- - **Test the setup**: Once you have your task designed and some guidelines in place, make sure you test it yourself on a few samples before involving the whole team, and iterate as needed.
20
-
21
- ### During the annotation
22
-
23
- - **Annotators should work independently**: It's better if annotators don't help each other or see each other's work during the task, as they can propagate their own biases and cause annotation drift. Alignment should always happen through comprehensive guidelines. You may want to train any new team members first on a separate dataset and/or use inter-annotator agreement metrics to make sure the team is aligned.
24
-
25
- <Note title="Prevent annotation drift" emoji="🎯" variant="info">
26
-
27
- Annotators must work independently. Collaboration can propagate individual biases and cause "annotation drift" where the team gradually diverges from guidelines. Alignment should happen only through comprehensive written guidelines.
28
- </Note>
29
-
30
- - **Consistency is key**: If you make important changes to your guidelines (e.g., changed a definition or instruction, or have added/removed labels), consider if you need to iterate over the annotated data. At least, you should track the changes in your dataset through a metadata value like `guidelines-v1`.
31
-
32
- ### Hybrid human-machine annotation
33
-
34
- Sometimes teams face contraints on time and resources but don't want to sacrifice on the pros of human evaluation. In these cases, you may use the help of models to make the task more efficient.
35
-
36
- - **Model-aided annotation**: You may use the predictions or generations of a model as pre-annotations, so that the annotation team doesn't need to start from scratch. Just note that this could introduce the model's biases into human annotations, and that if the model's accuracy is poor it may increase work for annotators.
37
-
38
- <Sidenote>
39
-
40
- Model-aided annotation (using predictions as pre-annotations) can speed up work but introduces model biases into human annotations. If model accuracy is poor, fixing errors may take longer than annotating from scratch.
41
- </Sidenote>
42
-
43
- - **Supervise model as a judge**: You can combine the power of the model as a judge methodology (see the section on "Model as a judge") and human supervisors who validate or discard the results. Note that the biases discussed in the "Pros and cons of human evaluation" will apply here.
44
-
45
- - **Idenfity edge cases**: For an even faster task, use a jury of models and then have your human supervisor(s) step in where models disagree or there's a tie to break. Again, be aware of the biases discussed in the "Pros and cons of human evaluation".
46
-
47
- ### End to end tutorial
48
-
49
- To build you own custom evaluation setup following these tips, you can follow this [practical tutorial](https://github.com/argilla-io/argilla-cookbook/tree/main/domain-eval) from Argilla. It guides you through building a custom evaluation task for your domain, using synthetic data and manual evaluation with [Argilla](https://github.com/argilla-io/argilla/) and [distilabel](https://github.com/argilla-io/distilabel). The guide starts from domain documents and results in a custom evaluation task that you can use to evaluate your model with [lighteval](https://github.com/huggingface/lighteval).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/src/content/chapters/human-evaluation/using-human-annotators.mdx CHANGED
@@ -6,8 +6,9 @@ import bestAnnotationPractices from '../../assets/image/best_annotation_practice
6
  import Image from '../../../components/Image.astro';
7
  import Note from "../../../components/Note.astro";
8
  import Sidenote from "../../../components/Sidenote.astro";
 
9
 
10
- ### Using human annotators
11
 
12
  I suggest reading Section 3 of this [review](https://aclanthology.org/2024.cl-3.1/) of good practices in data annotation quality. If you want production level quality and have the means to implement all of these methods, go ahead!
13
 
@@ -49,8 +50,36 @@ Be ready to try several rounds of annotations, as your annotators will misunders
49
  You want to control answers (notably via inter-annotator agreement if you can get it) and do a final selection to keep only the highest quality/most relevant answers.
50
 
51
  Specialized tools to build annotated high quality datasets like [Argilla](https://argilla.io/) can also help you.
52
- ### Going further
 
53
  - ⭐ [How to set up your own annotator platform in a couple minutes](https://huggingface.co/learn/cookbook/enterprise_cookbook_argilla), by Moritz Laurer. A good read to get some hands on experience using open source tools (like Argilla and Hugging Face), and understanding better the dos and don'ts of human annotation at scale.
54
  - ⭐ [A guide on annotation good practices](https://aclanthology.org/2024.cl-3.1/). It's a review of all papers about human annotation dating from 2023, and it is very complete. Slightly dense, but very understandable.
55
  - [Another guide on annotation good practices](https://scale.com/guides/data-labeling-annotation-guide), by ScaleAI, specialised in human evaluations. Its a more lightweigth complement to the above document.
56
  - [Assumptions and Challenges of Capturing Human Labels](https://aclanthology.org/2024.naacl-long.126/) is a paper on how to look at source of annotator disagreement and mitigate them in practice
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  import Image from '../../../components/Image.astro';
7
  import Note from "../../../components/Note.astro";
8
  import Sidenote from "../../../components/Sidenote.astro";
9
+ import Accordion from "../../../components/Accordion.astro";
10
 
11
+ #### Using human annotators
12
 
13
  I suggest reading Section 3 of this [review](https://aclanthology.org/2024.cl-3.1/) of good practices in data annotation quality. If you want production level quality and have the means to implement all of these methods, go ahead!
14
 
 
50
  You want to control answers (notably via inter-annotator agreement if you can get it) and do a final selection to keep only the highest quality/most relevant answers.
51
 
52
  Specialized tools to build annotated high quality datasets like [Argilla](https://argilla.io/) can also help you.
53
+
54
+ <Note title="Going further">
55
  - ⭐ [How to set up your own annotator platform in a couple minutes](https://huggingface.co/learn/cookbook/enterprise_cookbook_argilla), by Moritz Laurer. A good read to get some hands on experience using open source tools (like Argilla and Hugging Face), and understanding better the dos and don'ts of human annotation at scale.
56
  - ⭐ [A guide on annotation good practices](https://aclanthology.org/2024.cl-3.1/). It's a review of all papers about human annotation dating from 2023, and it is very complete. Slightly dense, but very understandable.
57
  - [Another guide on annotation good practices](https://scale.com/guides/data-labeling-annotation-guide), by ScaleAI, specialised in human evaluations. Its a more lightweigth complement to the above document.
58
  - [Assumptions and Challenges of Capturing Human Labels](https://aclanthology.org/2024.naacl-long.126/) is a paper on how to look at source of annotator disagreement and mitigate them in practice
59
+ </Note>
60
+
61
+ <Accordion title="Practical tips and tricks">
62
+ Here are a few practical tips you might want consider when using human annotators to build an evaluation dataset.
63
+
64
+
65
+ **Designing the task**
66
+
67
+ - **Simple is better**: Annotation tasks can get unnecessarily complex, so keep it as simple as possible. Keeping the cognitive load of the annotators to a minimum will help you ensure that they stay focused and make annotations of a higher quality.
68
+ - **Check what you show**: Only show the necessary information for annotators to complete the task and make sure you don't include anything that could introduce extra bias.
69
+ - **Consider your annotators time**: Where and how things are displayed can introduce extra work or cognitive load and therefore negatively impact in the quality of results. For example, make sure that the texts and the task are visible together and avoid unnecessary scrolling. If you combine tasks and the result of one informs the other, you can display them sequentially. Think about how everything is displayed in your annotation tool and see if there's any way you can simplify even more.
70
+ - **Test the setup**: Once you have your task designed and some guidelines in place, make sure you test it yourself on a few samples before involving the whole team, and iterate as needed.
71
+
72
+ **During the annotation**
73
+
74
+ - **Annotators should work independently**: It's better if annotators don't help each other or see each other's work during the task, as they can propagate their own biases and cause annotation drift. Alignment should always happen through comprehensive guidelines. You may want to train any new team members first on a separate dataset and/or use inter-annotator agreement metrics to make sure the team is aligned.
75
+ - **Consistency is key**: If you make important changes to your guidelines (e.g., changed a definition or instruction, or have added/removed labels), consider if you need to iterate over the annotated data. At least, you should track the changes in your dataset through a metadata value like `guidelines-v1`.
76
+
77
+ **Hybrid human-machine annotation**
78
+
79
+ Sometimes teams face contraints on time and resources but don't want to sacrifice on the pros of human evaluation. In these cases, you may use the help of models to make the task more efficient.
80
+
81
+ - **Model-aided annotation**: You may use the predictions or generations of a model as pre-annotations, so that the annotation team doesn't need to start from scratch. Just note that this could introduce the model's biases into human annotations, and that if the model's accuracy is poor it may increase work for annotators.
82
+ - **Supervise model as a judge**: You can combine the power of the model as a judge methodology (see the section on "Model as a judge") and human supervisors who validate or discard the results. Note that the biases discussed in the "Pros and cons of human evaluation" will apply here.
83
+ - **Idenfity edge cases**: For an even faster task, use a jury of models and then have your human supervisor(s) step in where models disagree or there's a tie to break. Again, be aware of the biases discussed in the "Pros and cons of human evaluation".
84
+
85
+ </Accordion>
app/src/content/chapters/model-as-a-judge/basics.mdx DELETED
@@ -1,50 +0,0 @@
1
- ---
2
- title: "Model as a Judge: Basics"
3
- ---
4
-
5
- import Note from "../../../components/Note.astro";
6
- import Sidenote from "../../../components/Sidenote.astro";
7
-
8
- Judge models are simply **neural network used to evaluate the output of other neural networks**. In most cases, they evaluate text generations.
9
-
10
- Judge models range from small specialized classifiers (think "spam filter", but for toxicity for example) to LLMs, either large and generalist or small and specialized. In the latter case, when using an LLM as a judge, you give it a prompt to explain how to score models (ex: `Score the fluency from 0 to 5, 0 being completely un-understandable, ...`).
11
-
12
- Model as judges allow to score text on complex and nuanced properties.
13
- For example, an exact match between a prediction and reference can allow you to test if a model predicted the correct fact or number, but assessing more open-ended empirical capabilities (like fluency, poetry quality, or faithfulness to an input) requires more complex evaluators.
14
-
15
- That's where models as judges come into play.
16
-
17
- They are used on 3 main tasks:
18
- - *Scoring a model generation*, on a provided scale, to assess a property of the text (fluency, toxicity, coherence, persuasiveness, etc).
19
- - *Pairwise scoring*: comparing a pair model outputs to pick the best text with respect to a given property
20
- - *Computing the similarity* between a model output and a reference
21
-
22
- *Note: In this document, I'll focus on the LLMs + prompt approach for now, but you should definitely check out how classifier judges work, as I think it can be fairly robust and well adapted to a number of use cases, and the recently introduced and promising reward model as judge approach (introduced in [this tech report](https://research.nvidia.com/publication/2024-06_nemotron-4-340b), and on which we have a small page [here](https://github.com/huggingface/evaluation-guidebook/blob/main/contents/model-as-a-judge/what-about-reward-models.md))*
23
-
24
- ### Pros and cons of using judge-LLMs
25
- People in favor of judge LLMs have been claiming they provide better:
26
- - **Objectivity** when compared to humans: They automate empirical judgments in an objective and reproducible manner (theoretically - in my opinion, they add more subtle bias than they are worth)
27
- - **Scale and reproducibility**: They are more scalable than human annotators, which allows to reproduce scoring on large amounts of data (if you control for temperature).
28
- - **Cost**: They are cheap to instantiate, as they don't require to train a new model, and can just rely on good prompting and an existing high quality LLM. They are also cheaper than paying actual human annotators (capitalism...).
29
- - **Alignment with human judgments**: They are somehow correlated with human judgments.
30
-
31
- In my opinion, using LLM judges correctly is extremely tricky, and it's easy to be deceived for critical use cases:
32
- - LLM as judges seem objective, but they have many **hidden biases** that can be harder to detect than the ones in humans, since we're not as actively looking for them (see [model-as-a-judge/Tips and tricks]). Besides, there are ways to reduce human bias by designing survey questions in specific and statistically robust ways (which has been studied in sociology for about a century), where LLM-prompting is not as robust yet. Using LLMs to evaluate LLMs has been compared to creating an echo-chamber effect, by reinforcing biases subtly.
33
- - They are indeed scalable, but contribute to creating massive amounts of data which themselves need to be examined to ensure their quality (for example, you can improve the quality of LLM-judges by asking them to generate a thinking trace, or reasoning around their data, which makes even more new artificial data to analyse)
34
- - They are indeed cheap to instantiate, but paying actual expert human annotators is likely to give you qualitatively better results for your specific use cases.
35
-
36
- <Note title="Critical limitations of LLM judges" emoji="⚠️" variant="warning">
37
-
38
- Using LLM judges is extremely tricky:
39
- - **Hidden biases**: Harder to detect than human biases; creates echo-chamber effects
40
- - **Data overload**: Generates massive synthetic data needing quality examination
41
- - **False objectivity**: Seems objective but reinforces subtle biases
42
- - **Expert humans better**: For critical use cases, expert annotators provide higher quality
43
-
44
- See [Tips and tricks](./tips-and-tricks) for bias mitigation strategies.
45
- </Note>
46
-
47
- This section is a bit long, because you need to be well aware of their limitations: a lot of people are blindly jumping into using model judges because they seem easier, but then end up with uninsterpretable data with tricky bias to extract.
48
-
49
- If you want to give it a go, I suggest first reading this [very good guide](https://huggingface.co/learn/cookbook/en/llm_judge) (⭐) by Aymeric Roucher on how to setup your first LLM as judge!
50
- You can also try the [distilabel](https://distilabel.argilla.io/latest/) library, which allows you to generate synthetic data and update it using LLMs. They have a nice [tutorial](https://distilabel.argilla.io/latest/sections/pipeline_samples/papers/ultrafeedback/) applying the methodology of the [Ultrafeedback paper](https://arxiv.org/abs/2310.01377) as well as a [tutorial on benchmarking](https://distilabel.argilla.io/latest/sections/pipeline_samples/examples/benchmarking_with_distilabel/) implementing the Arena Hard benchmark.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/src/content/chapters/model-as-a-judge/designing-your-evaluation-prompt.mdx DELETED
@@ -1,81 +0,0 @@
1
- ---
2
- title: "Designing your evaluation prompt"
3
- ---
4
-
5
- import Note from "../../../components/Note.astro";
6
- import Sidenote from "../../../components/Sidenote.astro";
7
-
8
- ### Designing your evaluation prompt
9
-
10
- Once you've selected your model, you need to define what is the best possible prompt for your task.
11
-
12
- Some general guidelines I've come across online when designing the prompt itself are:
13
- - Provide a clear description of the task at hand:
14
- - `Your task is to do X`.
15
- - `You will be provided with Y`.
16
- - Provide clear instructions on the evaluation criteria, including a detailed scoring system if needed:
17
- - `You should evaluate property Z on a scale of 1 - 5, where 1 means ...`
18
- - `You should evaluate if property Z is present in the sample Y. Property Z is present if ...`
19
- - Provide some additional "reasoning" evaluation steps:
20
- - `To judge this task, you must first make sure to read sample Y carefully to identify ..., then ...`
21
- - Specify the desired output format (adding fields will help consistency)
22
- - `Your answer should be provided in JSON, with the following format {"Score": Your score, "Reasoning": The reasoning which led you to this score}`
23
-
24
- <Note title="Core prompt design principles" emoji="📝" variant="info">
25
-
26
- **Essential elements for effective judge prompts:**
27
- - **Clear task description**: Specify exactly what the judge needs to do
28
- - **Detailed criteria**: Provide explicit scoring scales with clear definitions
29
- - **Reasoning steps**: Guide the judge through the evaluation process
30
- - **Structured output**: Use JSON format for consistency and parsability
31
-
32
- </Note>
33
-
34
- You can and should take inspiration from [MixEval](https://github.com/huggingface/lighteval/blob/main/src/lighteval/tasks/extended/mix_eval/judge_prompts.pyy) or [MTBench](https://github.com/huggingface/lighteval/blob/main/src/lighteval/tasks/extended/mt_bench/judge_prompt_templates.py) prompt templates.
35
-
36
- Other tidbits:
37
- - Pairwise comparison [correlates better with human preference](https://arxiv.org/abs/2403.16950) than scoring, and is more robust generally.
38
- - If you really want a score, use an integer scale make sure you provide a detailed explanation for what [each score represents](https://x.com/seungonekim/status/1749289437165769177), or an additive prompt (`provide 1 point for this characteristic of the answer, 1 additional point if ...` etc)
39
- - Using one prompt per capability to score tends to give better and more robust results
40
-
41
- <Sidenote>
42
-
43
- Pairwise comparison consistently outperforms absolute scoring for judging model outputs. It correlates better with human preferences and is less sensitive to judge biases and scale interpretation issues.
44
-
45
- </Sidenote>
46
-
47
- You can also improve accuracy using the following, possibly more costly, techniques:
48
- - **Few shot examples**: like in many other tasks, if you provide examples it can help its reasoning. However, this adds to your context length.
49
- - **Reference**: you can also enhance your prompt with a reference if present, which increases accuracy
50
- - **CoT**: [improves accuracy](https://arxiv.org/abs/2212.08073), if you ask the model to output its chain of thought **before** the score (also observed [here](https://x.com/seungonekim/status/1749289437165769177))
51
- - **Multiturn analysis**: can improve [factual error detection](https://arxiv.org/abs/2305.13281)
52
- - Using **a jury** (many judges, where you pick an aggregate of the answers): [gives better results](https://arxiv.org/abs/2404.18796) than using a single model.
53
- - It can be made considerably less costly by leveraging many smaller models instead of one big expensive model.
54
- - You can also experiment with using one model with variations on temperature
55
- - Surprisingly, the community has found that adding stakes to the prompts (`answer correctly and you'll get a kitten`) can increase correctness. Your mileage may vary on this one, adapt to your needs.
56
-
57
- <Note title="Advanced techniques to improve accuracy" emoji="⚡" variant="success">
58
-
59
- **More sophisticated but effective approaches:**
60
- - **Chain-of-Thought (CoT)**: Ask for reasoning BEFORE the score
61
- - **Judge jury**: Multiple judges with aggregated results (can use smaller models to reduce cost)
62
- - **Few-shot examples**: Provide examples, though this increases context length
63
- - **Reference answers**: Include reference material to improve accuracy
64
- - **Multi-turn analysis**: Better for detecting factual errors
65
-
66
- </Note>
67
-
68
- Note on prompting: Depending on the stakes of your use case, to remove as much bias as possible, you would want to look at work done in sociology on how to design good surveys. If you treat your evaluator as a replacement for a human annotator, then you need to look at similar metrics: computing inter-annotator agreement, using correct survey design methodology to mitigate bias, etc.
69
-
70
- <Note title="High-stakes evaluation requires rigor" emoji="⚠️" variant="warning">
71
-
72
- For production or critical use cases, apply rigorous methodologies from sociology:
73
- - Compute inter-annotator agreement metrics
74
- - Use proper survey design methodology to mitigate bias
75
- - Treat the evaluator like a human annotator with similar quality standards
76
-
77
- Quick evaluations with "OK-ish prompts" may suffice for low-stakes exploration, but don't mistake convenience for quality when decisions matter.
78
-
79
- </Note>
80
-
81
- However, most people don't really want a reproducible and high quality unbiased eval, and will be happy with quick and dirty evaluation through OK-ish prompts. (Which is an OK situation to be in! Just depends on the consequences attached).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/src/content/chapters/model-as-a-judge/evaluating-your-evaluator.mdx DELETED
@@ -1,61 +0,0 @@
1
- ---
2
- title: "Evaluating your evaluator"
3
- ---
4
-
5
- import Note from "../../../components/Note.astro";
6
- import Sidenote from "../../../components/Sidenote.astro";
7
-
8
- ### Evaluating your evaluator
9
-
10
- Before using a judge-LLM in production or at scale, you want to first evaluate its quality for your task, to make sure its scores are actually relevant and useful for you.
11
-
12
- Note: *This will be easier to do if it predicts binary outputs, because you'll be able to interpretable classification metrics (accuracy/recall/precision). If it predicts scores on a scale, it will be much harder to estimate the quality of the correlation with a reference.*
13
-
14
- <Sidenote>
15
-
16
- Binary outputs (yes/no, pass/fail) are much easier to evaluate than continuous scores. You can use clear metrics like accuracy, precision, and recall. Continuous scores require correlation analysis which is harder to interpret.
17
-
18
- </Sidenote>
19
-
20
- So, once you have selected your model judge and its prompt, you'll need to do the following.
21
-
22
- 1. **Pick your baseline**
23
- You'll need to compare your evaluator judgments to a baseline: it can be human annotations, the output of another judge model that you know is qualitative on your task, a gold truth, itself with another prompt, etc.
24
-
25
- You don't necessarily need a lot of examples (50 can be enough), but you need them to be extremely representative of your task, discriminative (representative of edge cases notably), and of as high quality as you can manage.
26
-
27
- <Note title="Quality over quantity for baseline" emoji="🎯" variant="info">
28
-
29
- You don't need many baseline examples (50 can suffice), but they must be:
30
- - **Representative**: Cover the full range of your task
31
- - **Discriminative**: Include edge cases and challenging examples
32
- - **High quality**: Use the best reference data you can obtain
33
-
34
- </Note>
35
-
36
- 2. **Pick your metric**
37
- Your metric will be used to compare your judge's evaluations with your reference.
38
-
39
- In general, this comparison is considerably easier to do if your model is predicting binary classes or doing pairwise comparison, as you'll be able to compute accuracy (for pairwise comparison), or precision and recall (for binary classes), which are all very easy to interpret metrics.
40
-
41
- Comparing the correlation of scores with human or model scoring will be harder to do. To understand why in more detail, I advise you to read this cool [blog section on the topic](https://eugeneyan.com/writing/llm-evaluators/#key-considerations-before-adopting-an-llm-evaluator).
42
-
43
- In general, if you're a bit lost about what metrics to pick when (in terms of models, metrics, ...), you can also look at [this interesting graph](https://eugeneyan.com/assets/llm-eval-tree.jpg) from [the same above blog](https://eugeneyan.com/writing/llm-evaluators/) ⭐.
44
-
45
- 3. **Evaluate your evaluator**
46
- For this step, you simply need to use your model and its prompt to evaluate your test samples! Then, once you get the evaluations, use your above metric and reference to compute a score for your evaluations.
47
-
48
- You need to decide what your threshold for acceptance is. Depending on how hard your task is, you can aim for 80% to 95% accuracy, if you're doing pairwise comparison. Regarding correlations (if you're using scores), people in the literature tend to seem happy with 0.8 Pearson correlation with a reference. However, I've seen some papers declare that 0.3 indicates a good correlation with human annotators (^^") so ymmv.
49
-
50
- <Note title="Acceptance thresholds vary widely" emoji="📊" variant="warning">
51
-
52
- **Realistic thresholds for judge quality:**
53
- - **Pairwise comparison**: Aim for 80-95% accuracy depending on task difficulty
54
- - **Score correlation**: 0.8 Pearson correlation is considered good, but some papers claim 0.3 is acceptable
55
-
56
- The wide range in reported "acceptable" correlations (0.3 to 0.8) suggests you should carefully set your own thresholds based on your specific use case requirements.
57
-
58
- </Note>
59
-
60
-
61
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/src/content/chapters/model-as-a-judge/getting-a-judge-llm.mdx DELETED
@@ -1,78 +0,0 @@
1
- ---
2
- title: "Getting a Judge-LLM"
3
- ---
4
-
5
- import Note from "../../../components/Note.astro";
6
- import Sidenote from "../../../components/Sidenote.astro";
7
-
8
- ### Getting a Judge-Model
9
-
10
- When using an existing LLM, you can go for [generalist, high capability models](https://arxiv.org/abs/2306.05685v4), using [small specialist models](https://arxiv.org/abs/2405.01535) trained specifically to discriminate from preference data, or training your own.
11
-
12
- #### Using a generalist LLM
13
-
14
- With the introduction of more capable LLMs (such as ChatGPT), some researchers started exploring using big models as judges. The best current big model judges tend to be closed source models (like Claude or gpt-o models) though the gap with open source is closing very fast thanks to high quality models such as [Qwen 2.5](https://huggingface.co/collections/Qwen/qwen25-66e81a666513e518adb90d9e), [Command R+](https://huggingface.co/CohereForAI/c4ai-command-r-plus-08-2024) or [Llama 3.1-405-Instruct](meta-llama/Llama-3.1-405B-Instruct).
15
-
16
- Closed source models, despite their performance, present the multiple disadvantages of being:
17
- - under APIs, which mean that models (therefore results) can change with no notice, hurting the reproducibility of evals
18
- - black boxes, which makes them un-interpretable
19
- - possible sources of data leakage/lack of data privacy, as you send your data to a third party through the internet (which tends to be less safe than locally managed data), and you don't know for certain what is done with it (you often need to opt out of it being used in training sets).
20
-
21
- <Note title="Closed vs open source judge models" emoji="⚖️" variant="warning">
22
-
23
- **Closed source models (Claude, GPT-o) tradeoffs:**
24
-
25
- Disadvantages:
26
- - **Non-reproducible**: Models can change without notice via API updates
27
- - **Black box**: Un-interpretable decision-making
28
- - **Privacy risks**: Data sent to third parties, potential leakage
29
-
30
- Advantages:
31
- - Easy access without local setup or hardware requirements
32
-
33
- **Open source models are closing the gap** while solving reproducibility and interpretability issues. Models like Qwen 2.5, Command R+, and Llama 3.1-405-Instruct are now competitive alternatives.
34
-
35
- </Note>
36
-
37
- However, they also allow anyone to have access to a high quality model without needing to setup things locally or requiring access to hardware. This pros are now also present for most high quality open models, which are accessible through model providers, and solve the first 2 problems above.
38
-
39
- You'll find a good cost analysis of model providers [here](https://huggingface.co/spaces/ArtificialAnalysis/LLM-Performance-Leaderboard) if you need help picking one.
40
-
41
- #### Using a tiny specialized LLM judge model
42
-
43
- You can also make the choice to use tiny specialized LLM judges. With often a couple billion parameters, they can run locally on most recent consumer hardware, while being trained from scratch or fine-tuned using instruction data. You often need to follow their specific prompt formats.
44
-
45
- <Sidenote>
46
-
47
- Tiny specialized judge models (3-13B parameters) can run on consumer hardware while being trained specifically for evaluation tasks. They require following specific prompt formats but offer local deployment and fast inference.
48
-
49
- </Sidenote>
50
-
51
- Some existing models:
52
- - Flow-Judge-v0.1 ([weights](https://huggingface.co/collections/flowaicom/flow-judge-v01-66e6af5fc3b3a128bde07dec)), 3.8B parameters, a Phi-3.5-mini-instruct fine-tuned on a synthetic preference dataset
53
- - Prometheus ([weights](https://huggingface.co/prometheus-eval/prometheus-13b-v1.0), [paper](https://arxiv.org/abs/2310.08491)), 13B parameters, a model trained from scratch on synthetic preference dataset. A 7B parameter [v2](https://huggingface.co/prometheus-eval/prometheus-7b-v2.0) also exists, a Mistral-7B-Instruct-v0.2 fine-tune on a bigger synthetic preference dataset, with added weight merging
54
- - JudgeLM ([paper](https://arxiv.org/abs/2310.17631)), 7B to 33B parameters, models trained from scratch on synthetic preference datasets generated with a variety of models.
55
-
56
- #### Training your own
57
- You can also make the choice to train or fine-tune your own LLM-as-judge.
58
-
59
- You first need to gather preference data for your task of interest, which can come
60
- - From existing [human preference datasets](https://www.kaggle.com/competitions/lmsys-chatbot-arena)
61
- - From model generated preference data (which you can generate following the above tiny-model judges papers data sections, or get directly, for example from the Prometheus [preference](https://huggingface.co/datasets/prometheus-eval/Preference-Collection) and [feedback](https://huggingface.co/datasets/prometheus-eval/Feedback-Collection) collections).
62
-
63
- Then you need to decide whether to start from a small model to train from scratch, or from an existing model, that you can
64
- - distill into a new smaller model
65
- - quantize.
66
- - then fine-tune (using peft or adapter weights if the model is big and your training compute low) using the above data
67
- - apparently [starting from a reward model works better than from an instruct model](https://x.com/dk21/status/1826292289930674590)
68
-
69
- <Note title="Training your own judge model" emoji="🔧" variant="info">
70
-
71
- **Key steps for custom judge training:**
72
-
73
- 1. **Gather preference data**: Use human preference datasets or synthetic data from other models
74
- 2. **Choose starting point**: Train from scratch, distill from larger model, or fine-tune existing model
75
- 3. **Optimize for compute**: Use PEFT/adapter weights for efficient training on limited hardware
76
- 4. **Pro tip**: Starting from a reward model reportedly works better than starting from an instruct model
77
-
78
- </Note>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/src/content/chapters/model-as-a-judge/tips-and-tricks.mdx DELETED
@@ -1,51 +0,0 @@
1
- ---
2
- title: "Model as a Judge: Tips and tricks"
3
- ---
4
-
5
- import Note from "../../../components/Note.astro";
6
- import Sidenote from "../../../components/Sidenote.astro";
7
-
8
- ### Tips and tricks
9
-
10
- **Mitigating well known biases of LLM as judges**
11
-
12
- <Note title="Known LLM judge biases and mitigations" emoji="⚠️" variant="warning">
13
-
14
- - **Lack of internal consistency**: Different judgments at temperature > 0
15
- - Mitigation: Self-consistency prompting (multiple runs, majority vote)
16
- - **Self-preference**: [Favor own outputs](https://arxiv.org/abs/2404.13076)
17
- - Mitigation: Use judge jury
18
- - **Blindness to perturbation**: Can't identify [perturbed input](https://arxiv.org/abs/2406.13439)
19
- - Mitigation: Chain-of-thought before scoring, coherent grading scale
20
- - **Position bias**: [Favor specific positions](https://arxiv.org/abs/2306.05685)
21
- - Mitigation: Random position switching, log-probability normalization
22
- - **Verbosity bias**: Prefer verbose answers
23
- - Mitigation: [Account for length differences](https://arxiv.org/abs/2404.04475)
24
- - **Format bias**: Fail when format differs from training
25
- - Mitigation: Match training prompt format
26
- </Note>
27
-
28
- - **Lack of internal consistency**: a judge might give you different judgments if you prompt it several times (if the temperature is not 0)
29
- - You can mitigate this by doing self-consistency prompting of your judge, prompting it multiple times and keeping the majority output
30
- - **Self-preference**: they tend to [favor their own outputs](https://arxiv.org/abs/2404.13076) when scoring answers
31
- - You can mitigate this by using a jury
32
- - **Blindness to input perturbation**: models are bad at identifying [perturbated input](https://arxiv.org/abs/2406.13439) and tangentially [bad at providing consistent score ranges](https://twitter.com/aparnadhinak/status/1748368364395721128) (extended experiments on this [here](https://github.com/LeonEricsson/llmjudge/blob/main/README.md)). For example, if asked to rank text quality on text where noise has been added on a consistent scale, the grades predicted do not reflect this scale.
33
- - You can mitigate this by
34
- - asking the model to explain its reasoning [before providing a score](https://twitter.com/seungonekim/status/1749289437165769177)
35
- - providing a coherent grading scale in the prompt.
36
- - **Position-bias**: they tend to [favor specific answer positions](https://arxiv.org/abs/2306.05685). For example, when presented with pairwise comparisons, Claude and GPT3.5 tend to quite systematically prefer the first choice, or the second choice
37
- - You can mitigate this by
38
- - switching answer positions randomly
39
- - computing the log-probabilities of all possible choices to get a normalized answer
40
- - **Verbosity-bias** (or length-bias): they tend to like more verbose answers
41
- - You can mitigate this by [accounting for the answer difference in length](https://arxiv.org/abs/2404.04475)
42
- - **Debatable consistency [with human answers](https://arxiv.org/abs/2308.15812):**
43
- - However, it's also [debatable if non-expert humans are a good baseline for absolutely all evaluations](https://arxiv.org/abs/2202.06935). For some specific domains (medical, legal, mathematics, etc), relying on non-expert human annotators is as bad a baseline as using an LLM directly.
44
- - **Format bias**: they tend to fail to evaluate accurately if the prompt format [is too far away](https://arxiv.org/abs/2310.17631) from what it's been trained with. For example, a model trained to do pairwise comparison with an added reference answer will fail if said answer is not provided, and failures will also occur the other way around.
45
- - You can mitigate this by paying attention to the training prompt format (if the model was instruction tuned) and ensuring you follow it.
46
-
47
- **Picking correct tasks for an LLM judge**
48
-
49
- LLM evaluators:
50
- - are **bad at identifying hallucinations** in general, particularly what are called partial hallucinations (which look close to the ground truth but are actually slightly different) (see [this](https://arxiv.org/abs/2305.11747) and [this](https://arxiv.org/abs/2303.08896))
51
- - have a low to OK-ish correlation with human annotators on [summarization](https://arxiv.org/abs/2304.02554) ([here too](https://arxiv.org/abs/2303.16634)), [faithfulness](https://arxiv.org/abs/2307.16877), and are not consistently correlated with human judgement more broadly against [a scope of tasks](https://arxiv.org/abs/2406.18403)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/src/content/chapters/model-as-a-judge/what-about-reward-models.mdx DELETED
@@ -1,85 +0,0 @@
1
- ---
2
- title: "What about Reward Models?"
3
- ---
4
-
5
- import Note from "../../../components/Note.astro";
6
- import Sidenote from "../../../components/Sidenote.astro";
7
-
8
- ### What about Reward Models?
9
-
10
- Reward models learn to predict a score from human annotations for given prompt/completion pairs. The end goal is for them to do predictions aligned with human preference.
11
- Once trained, these models can then be used to improve other models, by acting as a a reward function which is a proxy for human judgment.
12
-
13
- The most common type of reward model is the Bradley-Terry model, which outputs a single **pairwise score**, following:
14
-
15
- $$p(\text{completion b is better than completion a}) = \text{sigmoid}(\text{score}_b - \text{score}_a)$$
16
-
17
- This model is trained using only pairwise comparisons of completions, which are easier to collect than scores, but can only compare several completions for one prompt, and not completions across prompts.
18
-
19
- Other models have expanded on this approach to predict a more nuanced probability that a completion is better than the other one ([example](https://huggingface.co/RLHFlow/pair-preference-model-LLaMA3-8B)).
20
-
21
- This allows them to (theoretically) judge subtle differences between completions, at the cost of not being able to easily save and compare many different scores across prompts for the same test set. In addition, context length and memory limits can become an issue when comparing too long completions.
22
-
23
- <Note title="Types of reward models" emoji="📊" variant="info">
24
-
25
- **Three main approaches:**
26
-
27
- - **Pairwise (Bradley-Terry)**: Most common. Compares two completions for same prompt. Easier to train (pairwise comparisons) but can't compare across different prompts.
28
- - **Absolute scores** (e.g., SteerLM): Direct evaluation without comparison. Easier to use but harder to collect training data (absolute scores less stable in human preferences).
29
- - **Hybrid models** (HelpSteer2, ArmoRM): Output both absolute and relative scores for maximum flexibility.
30
-
31
- </Note>
32
-
33
- Some reward models such as [SteerLM](https://arxiv.org/abs/2311.09528) output **absolute scores**, which can be used to evaluate completions directly without the need for pairwise comparisions. These models can be easier to use for evaluation, but are also harder to collect data for, as absolute scores tend to be less stable than pairwise scores in human preferences.
34
-
35
- More recently, models have been proposed that output both absolute and relative scores, such as [HelpSteer2-Preference](https://arxiv.org/abs/2410.01257) and [ArmoRM](https://arxiv.org/abs/2406.12845).
36
-
37
- #### How do I use a Reward Model for Evaluation?
38
-
39
- Given a dataset of prompts, we can generate completions from a language model and ask a reward model to score them.
40
-
41
- For models that give absolute scores, the resulting scores can be averaged to get a reasonable summary score.
42
-
43
- However, in the more common case of relative scores, the average reward can be biased by outliers (a few very good or very bad completions) as different prompts may have inherently different reward scales (some prompts are way harder or easier than others).
44
-
45
- <Sidenote>
46
-
47
- For relative scores, don't just average raw rewards—outliers and varying prompt difficulty scales will bias results. Use win rates or win probabilities against a reference instead.
48
-
49
- </Sidenote>
50
-
51
- Instead, we can use
52
- - win rates: take a reference set of completions and calculate the percentage of completions from the model that are ranked higher than the reference completions. It is slightly more granular.
53
- - win probabilities: the mean probability of the completions being better than the reference completions, which can give a more fine-grained and smoothly changing signal.
54
-
55
- #### Pros and Cons of Reward Models
56
-
57
- Reward models are typically:
58
- - **Very fast**: Getting a score is as simple as running a forward pass of a relatively small model once (since we only get a score, and not long text, contrary to judge-LLMs)
59
- - **Deterministic**: The same scores will be reproduced through the same forward pass
60
- - **Unlikely to suffer from positional bias**: As most models take only one completion, they can not be influenced by the order. For pairwise models, positional bias is often also minimal, as long as the training data was balanced with respect to containing both first and second answers as being the best.
61
- - **Require no prompt engineering**: since the model will simply output a score from one or two completions depending on preference data it's been trained on.
62
-
63
- On the other hand they:
64
- - **Require specific fine-tuning**: This can be a relatively costly step, and elthough they inherit many capabilities from a base model, they may still perform poorly on tasks that are out of the training distribution.
65
- - **Loose efficiency when used both in reinforcement learning and evaluation** (or when using direct alignment algorithms on datasets that are similar to the training data of the reward model), as the language model may overfit to the reward model's preferences.
66
-
67
- <Note title="Reward models vs LLM judges" emoji="⚡" variant="success">
68
-
69
- **Reward models excel at:**
70
- - **Speed**: Single forward pass for a score (no text generation)
71
- - **Determinism**: Reproducible scores, no temperature variation
72
- - **No positional bias**: Models trained on balanced data avoid order effects
73
- - **Zero prompt engineering**: Just pass completions, get scores
74
-
75
- **But beware:**
76
- - **Require fine-tuning**: Costly setup, may fail out-of-distribution
77
- - **Overfitting risk**: Language models can learn to game the reward model during RL training
78
-
79
- </Note>
80
-
81
- Some notes:
82
- - A good place to find high performing models is the [RewardBench Leaderboard](https://huggingface.co/spaces/allenai/reward-bench).
83
- - You can look at how reward models have been used in the [Nemotron](https://arxiv.org/abs/2406.11704) paper.
84
- - For reward models that rate single prompts and completions, you can cache the scores of many reference models and easily see how a new model performs.
85
- - Tracking of win rates or probabilities over training, e.g. as in [this](https://arxiv.org/abs/2410.11677v1) recent paper, can allow you to detect model degradation and select optimal checkpoints.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/src/content/chapters/troubleshooting/troubleshooting-inference.mdx CHANGED
@@ -7,6 +7,17 @@ import Sidenote from "../../../components/Sidenote.astro";
7
 
8
  ## Troubleshooting inference
9
 
 
 
 
 
 
 
 
 
 
 
 
10
  ### My model is very slow!
11
  ➡️ Changing the batch size
12
 
 
7
 
8
  ## Troubleshooting inference
9
 
10
+ ### My results are very bad
11
+
12
+ The first thing to do is always to inspect your model generations in detail. Some frequent things to look for when troubleshooting are:
13
+ - too strict model output parsing (before computing the metric) which leads to the answer being lost
14
+ - Fixing: adapt your parsing
15
+ - unability of the models to follow your output format in few shot (frequent in recent models trained with instructions data, like llama 3.2 or Qwen 2.5)
16
+ - Fixing: either adapt your prompt format, or just assume that models should be able to follow it in few shot
17
+ - exceedingly verbose model which never gets to the correct answer (more frequent in long context models and something we observed with Qwen and CommandR models)
18
+ - Fixing: either increase the allowed context length, add instructions to be concise in the task prompt, or just assume that models should be able to answer succinctly
19
+
20
+
21
  ### My model is very slow!
22
  ➡️ Changing the batch size
23
 
app/src/content/chapters/troubleshooting/troubleshooting-reproducibility.mdx CHANGED
@@ -5,12 +5,10 @@ title: "Troubleshooting reproducibility"
5
  import Note from "../../../components/Note.astro";
6
  import Sidenote from "../../../components/Sidenote.astro";
7
 
8
- ## Troubleshooting reproducibility
9
-
10
  Let's say you have read a recent tech report about a cool new model, and you want to reproduce their results on your machine... but you're not managing to?
11
  Let's explore why.
12
 
13
- ### Different code base
14
  To reproduce evaluation scores to the decimal point, you first need to make sure you're using exactly the same code base as the paper you want to reproduce.
15
 
16
  Usually, this means either using the evaluation default code as provided by the authors, or a standard implementation in a reference library like Eleuther's AI `lm_eval` or HuggingFace's `lighteval`. However, if the code source for evaluation is not provided, then, I'm sorry for you but it's unlikely that you'll be able to reproduce the results precisely.
@@ -19,7 +17,7 @@ If you want to easily understand what kind of discrepancies happen when using di
19
 
20
  *Note: This is precisely for this reason that a Hugging Face team decided to launch the [Open LLM Leaderboard](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard), to get unified and homogeneous comparisons of models scores in order to compare them to internal experiments.*
21
 
22
- ### Other subtle ways in which the implementation can be different
23
  We've observed that the following were easy things to mess up, even when using the same code base:
24
  - **Different random seeds.**
25
  - Normally, inference is less affected by random seeds than training. However, they can still affect some CUDA operations (see the PyTorch page on [reproducibility](https://pytorch.org/docs/stable/notes/randomness.html)) and change predictions if you're using a non greedy generation strategy. They can also affect the prompt if you're using few-shots, and some pre or post-processing functions.
@@ -35,21 +33,22 @@ We've observed that the following were easy things to mess up, even when using t
35
  (The `lm_eval` v2 now includes the normalization name in most metric names.)
36
  -> This is one of the easiest things to mess up, especially for tasks which require a lot of normalization/answer post processing, like math evaluations (where you want to extract the answer from a generated explanation).
37
 
38
- <Note title="Subtle reproducibility pitfalls" emoji="⚠️" variant="warning">
39
-
40
- **Common sources of score differences (even with same codebase):**
41
 
42
- - **Random seeds**: Can affect CUDA ops, sampling strategies, and few-shot prompt selection (multi-point differences possible)
43
- - **Metric ambiguity**: "Exact match" can mean log-likelihood matching, generative matching, prefix/suffix/quasi-matching—always check the code, not just the name
44
- - **Hidden normalization**: Predictions may be normalized (punctuation removal, number formatting) before comparison—easy to miss especially in math evals
45
 
46
- **Key lesson**: Never trust metric names alone. Read the actual implementation.
 
 
 
47
 
48
  </Note>
49
 
50
- ### Different prompt
51
  3 main things can come into play for prompt variation.
52
- ### Prompt itself
 
 
53
  The format you are using for the prompt can and will change scores wildly.
54
 
55
  For example, for multichoice question answers, some common formats include very simple variations when presenting the choices, such as:
@@ -68,63 +67,45 @@ Answer:
68
  ```
69
  and predicting either `A`/`B`/`C`/`D` or `<Choice A/B/C/D>`.
70
 
71
- These prompts are **semantically equivalent**, as they contain the exact same content - but they can still result in a difference of *several points for the same model*. We did some experiments on this [here](https://x.com/clefourrier/status/1777319187913875893/photo/1) (you'll see up to a 7 points difference for the same model) and a [paper observed similar results](https://arxiv.org/abs/2310.11324).
72
 
73
- Some tasks are also prefixed with a task prompt (eg: `The following questions are about <topic>`) - its presence or absence will also affect the scores.
74
 
75
  <Note title="Prompt format sensitivity" emoji="📝" variant="danger">
 
76
 
77
- **Semantically identical prompts can cause 7+ point score differences!**
78
 
79
  Even tiny formatting variations (like `A.` vs `(A)` vs just listing choices) significantly impact scores. Models increasingly overfit to specific benchmark prompt formats during training, losing adaptation ability.
80
 
81
  **Real example**: Llama 3.1 models predicted correct MATH-Hard answers but scored poorly because they overfit to GSM8K's prompt format and couldn't adapt to different few-shot templates.
82
-
83
  </Note>
84
 
85
  This [great paper](https://arxiv.org/abs/2407.07890)⭐ also highlights a side effect of this: a number of models are now trained to overfit benchmark prompts and answer formats, to the cost of adaptation to other prompts at evaluation time.
86
 
87
- This is something we observed on the Open LLM Leaderboard 2 for the Llama3.1 models. They were predicting the correct answers to our MATH-Hard evaluations, but were getting low scores, being unable to fit to the template provided in few-shot because they overfit the GSM8K prompt and answer format (another math eval).
88
- ### System prompt and chat template
 
 
89
  Chat models usually have been through instruction/preference training or fine-tuning. During this stage, they have learned to follow specific templates when inferring. For example, templates can require starting rounds of dialogue with a general prompt (called the `system prompt`) prefixed by specific tokens (usually `System: `). Said prompt is here to provide high-level instructions for the model, such as the contents of a persona, or general answering style instructions. Rounds of dialogue can also require adding prefix key words to text, such as `User` for queries and `Assistant` for answers.
90
 
91
  When using few shot, you also need to select if you want examples to be provided multi-turn (mimicking user/assistant turns) or all at once (in a single user prompt).
92
 
93
  Not following the chat template expected by the model at inference will kill its performance, as it will drive its output outside of the probability space it's been converging on.
94
 
95
- ### Few-shots samples
96
- Two things are easy to mess up with few-shot samples (see `general-knowledge/Model inference` if you're unsure what it is).
97
 
98
- Obviously, you need to use the **same number of few-shot samples** as your task of reference.
99
 
100
- However, you also need to use the **exact same samples** as the model you are comparing to, as using different samples will change results (which is not too surprising, if we assume some samples are better at expressing the task than others). More surprising maybe: you not only need to use the exact same samples, but also present them in the **exact same order**. Varying the order on the same samples led us to observe up to 3 points of difference on some subsets of MMLU (you can see [some results here](https://huggingface.co/blog/evaluation-structured-outputs) , it's the third colorgrid).
101
-
102
- This is also a place where paying attention to the random seeds is important.
103
 
104
- ### Different generation parameters
105
- For generative evaluations, parameters to pay attention to are:
106
- - making sure you are using the **same end of sentence token**
107
- - making sure you are allowing your model to **generate the same number of tokens** for the evaluation
108
- - making sure, if using sampling, that you are using the **same seed/temperature parameters**
109
-
110
- ### Different model loading
111
- Some sources of differences that we have observed are:
112
- - using **different hardware**.
113
- Pytorch does not ensure reproducibility of non deterministic operations across hardware
114
- - using **different libraries**.
115
- For example, if you use `transformers` vs `vllm` as your backend for inference, matrix computations are not managed exactly in the same way)
116
- - using **different batch sizes**.
117
- It's been documented in several evaluation libraries and model backends that using different batch sizes will change inference results - if you want fully reproducible evaluations, you should fix the batch size, though it might not always be possible for memory issues
118
- - using **different loading precision** for your model weights.
119
- Using a lower precision can reduce memory and inference costs, but it will also change the numerical results, since you are using different versions of the weights.
120
 
121
- <Note title="Model loading affects reproducibility" emoji="🔧" variant="warning">
122
 
123
- **Four factors that change results even with identical code:**
124
 
125
- - **Hardware**: PyTorch doesn't guarantee reproducibility across different GPUs/hardware
126
- - **Inference library**: transformers vs vllm handle matrix ops differently
127
- - **Batch size**: Different batch sizes = different results (fix batch size for reproducibility, though memory may limit this)
128
- - **Loading precision**: Lower precision (float16 vs float32) changes numerical results
129
 
130
- </Note>
 
5
  import Note from "../../../components/Note.astro";
6
  import Sidenote from "../../../components/Sidenote.astro";
7
 
 
 
8
  Let's say you have read a recent tech report about a cool new model, and you want to reproduce their results on your machine... but you're not managing to?
9
  Let's explore why.
10
 
11
+ #### Different code base
12
  To reproduce evaluation scores to the decimal point, you first need to make sure you're using exactly the same code base as the paper you want to reproduce.
13
 
14
  Usually, this means either using the evaluation default code as provided by the authors, or a standard implementation in a reference library like Eleuther's AI `lm_eval` or HuggingFace's `lighteval`. However, if the code source for evaluation is not provided, then, I'm sorry for you but it's unlikely that you'll be able to reproduce the results precisely.
 
17
 
18
  *Note: This is precisely for this reason that a Hugging Face team decided to launch the [Open LLM Leaderboard](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard), to get unified and homogeneous comparisons of models scores in order to compare them to internal experiments.*
19
 
20
+ #### Subtle implementation or loading difference
21
  We've observed that the following were easy things to mess up, even when using the same code base:
22
  - **Different random seeds.**
23
  - Normally, inference is less affected by random seeds than training. However, they can still affect some CUDA operations (see the PyTorch page on [reproducibility](https://pytorch.org/docs/stable/notes/randomness.html)) and change predictions if you're using a non greedy generation strategy. They can also affect the prompt if you're using few-shots, and some pre or post-processing functions.
 
33
  (The `lm_eval` v2 now includes the normalization name in most metric names.)
34
  -> This is one of the easiest things to mess up, especially for tasks which require a lot of normalization/answer post processing, like math evaluations (where you want to extract the answer from a generated explanation).
35
 
36
+ <Note title="Model loading affects reproducibility" emoji="🔧" variant="warning">
 
 
37
 
38
+ **Four factors that change results even with identical code:**
 
 
39
 
40
+ - **Hardware**: PyTorch doesn't guarantee reproducibility across different GPUs/hardware
41
+ - **Inference library**: transformers, vllm and sglang handle batching and matrix operations slightly differently as of 2025
42
+ - **Batch size**: Different batch sizes = different results (you should fix the batch size for reproducibility, though careful about OOM errors)
43
+ - **Loading precision**: Lower precision (especially quantized models vs floating point models) will change numerical results
44
 
45
  </Note>
46
 
47
+ #### Different prompt
48
  3 main things can come into play for prompt variation.
49
+
50
+ **Prompt itself**
51
+
52
  The format you are using for the prompt can and will change scores wildly.
53
 
54
  For example, for multichoice question answers, some common formats include very simple variations when presenting the choices, such as:
 
67
  ```
68
  and predicting either `A`/`B`/`C`/`D` or `<Choice A/B/C/D>`.
69
 
70
+ These prompts are **semantically equivalent**, as they contain the exact same content - but they can still result in a difference of *several points for the same model*.
71
 
 
72
 
73
  <Note title="Prompt format sensitivity" emoji="📝" variant="danger">
74
+ We did some experiments on this [here](https://x.com/clefourrier/status/1777319187913875893/photo/1) (you'll see up to a 7 points difference for the same model) and a [paper observed similar results](https://arxiv.org/abs/2310.11324).
75
 
76
+ Semantically identical prompts can cause 7+ point score differences!
77
 
78
  Even tiny formatting variations (like `A.` vs `(A)` vs just listing choices) significantly impact scores. Models increasingly overfit to specific benchmark prompt formats during training, losing adaptation ability.
79
 
80
  **Real example**: Llama 3.1 models predicted correct MATH-Hard answers but scored poorly because they overfit to GSM8K's prompt format and couldn't adapt to different few-shot templates.
81
+ This is something we observed on the Open LLM Leaderboard 2 for the Llama3.1 models. They were predicting the correct answers to our MATH-Hard evaluations, but were getting low scores, being unable to fit to the template provided in few-shot because they overfit the GSM8K prompt and answer format (another math eval).
82
  </Note>
83
 
84
  This [great paper](https://arxiv.org/abs/2407.07890)⭐ also highlights a side effect of this: a number of models are now trained to overfit benchmark prompts and answer formats, to the cost of adaptation to other prompts at evaluation time.
85
 
86
+ Some tasks are also prefixed with a task prompt (eg: `The following questions are about <topic>`) - its presence or absence will also affect the scores.
87
+
88
+ **System prompt and chat template**
89
+
90
  Chat models usually have been through instruction/preference training or fine-tuning. During this stage, they have learned to follow specific templates when inferring. For example, templates can require starting rounds of dialogue with a general prompt (called the `system prompt`) prefixed by specific tokens (usually `System: `). Said prompt is here to provide high-level instructions for the model, such as the contents of a persona, or general answering style instructions. Rounds of dialogue can also require adding prefix key words to text, such as `User` for queries and `Assistant` for answers.
91
 
92
  When using few shot, you also need to select if you want examples to be provided multi-turn (mimicking user/assistant turns) or all at once (in a single user prompt).
93
 
94
  Not following the chat template expected by the model at inference will kill its performance, as it will drive its output outside of the probability space it's been converging on.
95
 
96
+ Similarly, if you are using a reasoning model, you need to make sure whether you are comparing with or without thinking enabled.
 
97
 
98
+ **Few-shots samples**
99
 
100
+ Two things are easy to mess up with few-shot samples: the number of few-shot examples, which ones you are using, and their specific ordering
 
 
101
 
102
+ <Sidenote>
103
+ The importance of using the same examples is not too surprising, if we assume some samples are better at expressing the task than others. More surprising maybe: you not only need to use the exact same samples, but also present them in the **exact same order**. Varying the order on the same samples led us to observe up to 3 points of difference on some subsets of MMLU (you can see [some results here](https://huggingface.co/blog/evaluation-structured-outputs) , it's the third colorgrid)
104
+ </Sidenote>
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
+ This is also a place where paying attention to the random seeds is important.
107
 
108
+ **Parameters**
109
 
110
+ For generative evaluations, parameters to pay attention to are making sure you are 1) using the **same end of sentence token** (you probably should not be using a default one for chat and reasoning models); 2) allowing your model to **generate the same number of tokens** for the evaluation (this is particularly crucial for reasoning models, which require a huge numbers of tokens in thinking mode); 3) if using sampling, that you are using the **same seed/temperature parameters**.
 
 
 
111