Skip to content

Commit baa12d0

Browse files
Already Said That Eval (#1490)
@JunShern will review this # Thank you for contributing an eval! ♥️ 🚨 Please make sure your PR follows these guidelines, **failure to follow the guidelines below will result in the PR being closed automatically**. Note that even if the criteria are met, that does not guarantee the PR will be merged nor GPT-4 access be granted. 🚨 **PLEASE READ THIS**: In order for a PR to be merged, it must fail on GPT-4. We are aware that right now, users do not have access, so you will not be able to tell if the eval fails or not. Please run your eval with GPT-3.5-Turbo, but keep in mind as we run the eval, if GPT-4 gets higher than 90% on the eval, we will likely reject it since GPT-4 is already capable of completing the task. We plan to roll out a way for users submitting evals to see the eval performance on GPT-4 soon. Stay tuned! Until then, you will not be able to see the eval performance on GPT-4. **Starting April 10, the minimum eval count is 15 samples, we hope this makes it easier to create and contribute evals.** Also, please note that we're using **Git LFS** for storing the JSON files, so please make sure that you move the JSON file to Git LFS before submitting a PR. Details on how to use Git LFS are available [here](https://git-lfs.com). ## Eval details 📑 ### Eval name Alaready Said That ### Eval description This eval measures how robust models are to distractors when performing sequential tasks. We construct a toy task where the model needs to determine whether it has already seen a given word, and inject distractor questions into the interaction, keeping track of model performance throughout. ### What makes this a useful eval? [Insert why this eval is worth including and any additional context] ## Criteria for a good eval ✅ Below are some of the criteria we look for in a good eval. In general, we are seeking cases where the model does not do a good job despite being capable of generating a good response (note that there are some things large language models cannot do, so those would not make good evals). Your eval should be: - [x] Thematically consistent: The eval should be thematically consistent. We'd like to see a number of prompts all demonstrating some particular failure mode. For example, we can create an eval on cases where the model fails to reason about the physical world. - [x] Contains failures where a human can do the task, but either GPT-4 or GPT-3.5-Turbo could not. - [x] Includes good signal around what is the right behavior. This means either a correct answer for `Basic` evals or the `Fact` Model-graded eval, or an exhaustive rubric for evaluating answers for the `Criteria` Model-graded eval. - [x] **Include at least 15 high-quality examples.** If there is anything else that makes your eval worth including, please document it below. ### Unique eval value > Insert what makes your eval high quality that was not mentioned above. (Not required) ## Eval structure 🏗️ Your eval should - [x] Check that your data is in `evals/registry/data/{name}` - [x] Check that your YAML is registered at `evals/registry/evals/{name}.yaml` - [x] Ensure you have the right to use the data you submit via this eval (For now, we will only be approving evals that use one of the existing eval classes. You may still write custom eval classes for your own cases, and we may consider merging them in the future.) ## Final checklist 👀 ### Submission agreement By contributing to Evals, you are agreeing to make your evaluation logic and data under the same MIT license as this repository. You must have adequate rights to upload any data used in an Eval. OpenAI reserves the right to use this data in future service improvements to our product. Contributions to OpenAI Evals will be subject to our usual Usage Policies (<https://platform.openai.com/docs/usage-policies>). - [x] I agree that my submission will be made available under an MIT license and complies with OpenAI's usage policies. ### Email address validation If your submission is accepted, we will be granting GPT-4 access to a limited number of contributors. Access will be given to the email address associated with the commits on the merged pull request. - [x] I acknowledge that GPT-4 access will only be granted, if applicable, to the email address used for my merged pull request. ### Limited availability acknowledgment We know that you might be excited to contribute to OpenAI's mission, help improve our models, and gain access to GPT-4. However, due to the requirements mentioned above and the high volume of submissions, we will not be able to accept all submissions and thus not grant everyone who opens a PR GPT-4 access. We know this is disappointing, but we hope to set the right expectation before you open this PR. - [x] I understand that opening a PR, even if it meets the requirements above, does not guarantee the PR will be merged nor GPT-4 access be granted. ### Submit eval - [x] I have filled out all required fields of this form - [x] I have used **Git LFS** for the Eval JSON data - [x] (Ignore if not submitting code) I have run `pip install pre-commit; pre-commit install` and have verified that `mypy`, `black`, `isort`, `autoflake` and `ruff` are running when I commit and push Failure to fill out all required fields will result in the PR being closed. ### Eval JSON data Since we are using Git LFS, we are asking eval submitters to add in as many Eval Samples (at least 5) from their contribution here: <details> <summary>View evals in JSON</summary> ### Eval ```jsonl INSERT_EVAL_HERE ``` </details>
1 parent bd1736e commit baa12d0

File tree

17 files changed

+1569
-3
lines changed

17 files changed

+1569
-3
lines changed

LICENSE.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,12 @@ NOTE: This license applies to all parts of this repository except for the datase
108108
- **License**: Creative Commons Attribution 4.0 International: https://creativecommons.org/licenses/by/4.0/
109109
- **Source**: https://allenai.org/data/socialiqa
110110

111+
#### Already Said That
111112

112-
Please note: While efforts have been made to accurately represent the licenses associated with each dataset, users should consult the original source of the dataset to ensure compliance with any licensing terms and conditions.
113+
- **Location**: evals/registry/data/already_said_that
114+
- **Components**:
115+
- **WordNet**:
116+
- **License**: WordNet License: https://wordnet.princeton.edu/license-and-commercial-use
117+
- **Source**: https://wordnet.princeton.edu/
118+
119+
Please note: While efforts have been made to accurately represent the licenses associated with each dataset, users should consult the original source of the dataset to ensure compliance with any licensing terms and conditions.
+185
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
# Already Said That
2+
3+
This eval measures how robust models are to distractors when performing
4+
sequential tasks. We construct a toy task where the model needs to determine
5+
whether it has already seen a given word, and inject distractor questions into
6+
the interaction, keeping track of model performance throughout.
7+
8+
## Usage
9+
10+
Run with:
11+
12+
```bash
13+
oaieval <solver> already_said_that
14+
```
15+
16+
We have found that `generation/direct/gpt-4-0125-preview` works well on this
17+
eval. For more examples of tested solvers, see
18+
[`./scripts/run_experiments.sh`](./scripts/run_experiments.sh).
19+
20+
## Dataset
21+
22+
The dataset consists of 500 samples, where each sample contains 100 unique words
23+
randomly sampled from the [WordNet corpus](https://wordnet.princeton.edu/) via
24+
the `nltk` library.
25+
26+
We also rely on four sets of distractor questions, sourced directly from the
27+
datasets of pre-existing evals. Specifically we make use of the datasets of the
28+
following evals from our evals registry:
29+
30+
- [`which-is-heavier`](../../registry/evals/which-is-heavier.yaml)
31+
- [`first-letters`](../../registry/evals/first-letters.yaml)
32+
- [`ambigous-sentences`](../../registry/evals/ambiguous-sentences.yaml)
33+
- [`reverse-sort-words-eng`](../../registry/evals/reverse-sort-words-eng.yaml)
34+
35+
## Evaluation Process
36+
37+
The evaluation process is as follows for a given sample from our dataset:
38+
39+
1. The `TASK_DESCRIPTION` prompt is shown to the solver.
40+
2. For 100 turns, we either show a word to the solver or a distractor question,
41+
with probability 2/3 and 1/3 respectively.
42+
3. If a word is shown, we prefix it with `MAIN TASK -`, to indicate that we are
43+
asking the solver to perform the main task of determining whether it has seen
44+
the word before.
45+
4. When showing a word, we randomly show previously seen words with a
46+
probability of 1/2 and new words with a probability of 1/2.
47+
5. If we show a distractor question, we directly show the question to the
48+
solver.
49+
6. The solver should respond with its answer wrapped in the format
50+
`[answer: <answer>]`.
51+
7. The solver's response is parsed and compared to the correct answer.
52+
8. If the solver's response is incorrect or a violation is raised (answered in
53+
the incorrect format), in the case of the main task we stop the interaction
54+
and record the number of turns the solver lasted for. Otherwise we continue
55+
to the next turn.
56+
57+
## Prompts
58+
59+
We refer readers to [`./prompts.py`](./prompts.py) for the `TASK_DESCRIPTION`
60+
used in the eval.
61+
62+
We refer readers to [`./distractors.py`](./distractors.py) for any cosmetic
63+
changes we make to the distractor questions.
64+
65+
## Metrics
66+
67+
Below are the metrics returned by the eval:
68+
69+
<!-- prettier-ignore-start -->
70+
| **Metric** | **Notes** |
71+
|------------------------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
72+
| `avg_num_turns` | The average number of turns shown before the model fails across the samples. Higher is better. Best possible is 100. |
73+
| `stddev_num_turns` | The standard deviation on the above. |
74+
| `median_num_turns` | The median number of turns shown before the model fails across the samples. Higher is better. Best possible is 100. |
75+
| `max_num_turns` | The maximum number of turns shown before the model fails across the samples. |
76+
| `min_num_turns` | The minimum number of turns shown before the model fails across the samples. |
77+
| `false_positive_rate` | How often the model answers “yes” when it should have answered “no” (i.e. a new word is shown, and the model claims to have seen it already). |
78+
| `false_negative_rate` | How often the model answers “no” when it should have answered “yes” (i.e. a word is shown again, and the model claims to not have seen it). |
79+
| `avg_distractor_accuracy` | For a given sample interaction, we measure whether each model response to a given distractor question is accurate. We then compute the accuracy on the distractor questions shown over the interaction. We then average this accuracy across all samples. |
80+
| `violation_rate` | how often the model responds in an invalid format, i.e. not using the `[answer: <answer>]` format. |
81+
| `avg_num_distractors` | The average number of distractors shown before the model fails across the samples. Higher is better. Best possible is around 33. |
82+
| `stddev_num_distractors` | The standard deviation on the above. |
83+
| `median_num_distractors` | The median number of distractors shown before the model fails across the samples. Higher is better. Best possible is around 33. |
84+
| `max_num_distractors` | The maximum number of distractors shown before the model fails across the samples. |
85+
| `min_num_distractors` | The minimum number of distractors shown before the model fails across the samples. |
86+
<!-- prettier-ignore-end -->
87+
88+
## Variants
89+
90+
We consider each of the four distractor datasets mentioned in
91+
[Dataset](#dataset) as a variant of the eval.
92+
93+
```bash
94+
oaieval <solver> already_said_that.<distractor>
95+
```
96+
97+
We also have a `distractorless` variant where we only show words to the solver.
98+
We use this as a baseline to determine how robust the solver is to distractors.
99+
100+
```bash
101+
oaieval <solver> already_said_that.distractorless
102+
```
103+
104+
## Custom Solvers
105+
106+
We implement 2 custom solvers for this eval in [./solvers.py](./solvers.py):
107+
108+
1. `RandomBaselineSolver`: A solver that randomly answers `yes` or `no` for any
109+
input. We view this baseline as equivalent to randomly guessing.
110+
2. `AlreadySaidThatHuman`: A helper solver class that wraps the `HumanCliSolver`
111+
class such that users do not have to wrap their answer in the
112+
`[answer: <answer>]` format and can instead just directly type the answer.
113+
114+
## Token Usage Estimates
115+
116+
Below are approximate token usage estimates for a given run (one run = all
117+
samples) of the eval, for each of the distractor variants.
118+
119+
For Direct gpt-4-0125-preview:
120+
121+
| Distractor variant | Input | Output | Total |
122+
| --------------------- | ---------- | ------- | ---------- |
123+
| which-is-heavier | 17,960,000 | 80,000 | 18,040,000 |
124+
| ambiguous-sentences | 27,750,000 | 110,000 | 27,860,000 |
125+
| first-letters | 19,850,000 | 80,000 | 19,940,000 |
126+
| reverse-sort-words-en | 10,700,000 | 120,000 | 10,820,000 |
127+
| distractorless | 27,550,000 | 120,000 | 27,680,000 |
128+
129+
For Direct gpt-3.5-turbo-0125:
130+
131+
| Distractor variant | Input | Output | Total |
132+
| --------------------- | --------- | ------ | --------- |
133+
| which-is-heavier | 1,200,000 | 10,000 | 1,210,000 |
134+
| ambiguous-sentences | 1,540,000 | 20,000 | 1,550,000 |
135+
| first-letters | 2,120,000 | 20,000 | 2,140,000 |
136+
| reverse-sort-words-en | 910,000 | 20,000 | 940,000 |
137+
| distractorless | 1,250,000 | 20,000 | 1,270,000 |
138+
139+
For Direct gpt-4-base:
140+
141+
| Distractor variant | Input | Output | Total |
142+
| --------------------- | ---------- | --------- | ---------- |
143+
| which-is-heavier | 16,950,000 | 3,670,000 | 20,620,000 |
144+
| ambiguous-sentences | 23,100,000 | 4,390,000 | 27,490,000 |
145+
| first-letters | 25,310,000 | 4,870,000 | 30,180,000 |
146+
| reverse-sort-words-en | 14,380,000 | 2,760,000 | 17,140,000 |
147+
| distractorless | 24,460,000 | 5,000,000 | 29,460,000 |
148+
149+
For CoT gpt-4-0125-preview:
150+
151+
| Distractor variant | Input | Output | Total |
152+
| --------------------- | ----------- | --------- | ----------- |
153+
| which-is-heavier | 263,600,000 | 1,900,000 | 265,500,000 |
154+
| ambiguous-sentences | 383,500,000 | 2,700,000 | 386,200,000 |
155+
| first-letters | 251,700,000 | 1,700,000 | 253,400,000 |
156+
| reverse-sort-words-en | 236,700,000 | 2,100,000 | 238,800,000 |
157+
| distractorless | 395,500,000 | 2,400,000 | 398,000,000 |
158+
159+
For CoT gpt-3.5-turbo-0125:
160+
161+
| Distractor variant | Input | Output | Total |
162+
| --------------------- | ---------- | ------- | ---------- |
163+
| which-is-heavier | 10,100,000 | 190,000 | 10,280,000 |
164+
| ambiguous-sentences | 7,510,000 | 140,000 | 7,650,000 |
165+
| first-letters | 16,450,000 | 220,000 | 16,670,000 |
166+
| reverse-sort-words-en | 4,690,000 | 150,000 | 4,840,000 |
167+
| distractorless | 30,230,000 | 310,000 | 30,540,000 |
168+
169+
## Future modifications
170+
171+
- Extending the range of distractors considered, either by incorporating more
172+
evals or designing new distractor variants.
173+
- Experiment with multiple distractor sources in a single eval run, to see if
174+
the variety of distractors affects the model's robustness.
175+
176+
## Version History
177+
178+
- v0: Initial version released
179+
180+
## Contribution Statement
181+
182+
Eval design, implementation, and results evaluation were primarily conducted by
183+
Giulio Starace, under the guidance of (alphabetically by last-name) Steven
184+
Adler, Andrei Alexandru, James Aung, and Chan Jun Shern who provided research
185+
input, report revisions, and project management support.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
import os
2+
from dataclasses import dataclass
3+
from pathlib import Path
4+
5+
import evals
6+
7+
8+
@dataclass
9+
class DistractorSample:
10+
question: str
11+
ideal: str
12+
13+
14+
VARIANTS = {
15+
"which-is-heavier",
16+
"ambiguous-sentences",
17+
"first-letters",
18+
"reverse-sort-words-eng",
19+
"distractorless",
20+
}
21+
22+
23+
def proc_which_is_heavier(samples) -> list[DistractorSample]:
24+
distractor_samples = []
25+
for sample in samples:
26+
# get rid of ' Answer Yes or No'
27+
question = sample["input"][1]["content"][:-17]
28+
ideal = sample["ideal"].lower()
29+
distractor_samples.append(DistractorSample(question, ideal))
30+
return distractor_samples
31+
32+
33+
def proc_distractors_first_letters(samples) -> list[DistractorSample]:
34+
distractor_samples = []
35+
for sample in samples:
36+
question = sample["input"][1]["content"]
37+
ideal = sample["ideal"].lower()
38+
distractor_samples.append(DistractorSample(question, ideal))
39+
return distractor_samples
40+
41+
42+
def proc_distractors_ambiguous_sentences(samples) -> list[DistractorSample]:
43+
distractor_samples = []
44+
for sample in samples:
45+
sample_content = sample["input"][1]["content"]
46+
question = f"{sample_content}"
47+
ideal = sample["ideal"].lower()
48+
distractor_samples.append(DistractorSample(question, ideal))
49+
return distractor_samples
50+
51+
52+
def proc_distractors_reverse_sort_words_eng(samples) -> list[DistractorSample]:
53+
distractor_samples = []
54+
for sample in samples:
55+
# cut " (respond as concisely as possible and only include the comma-separated words in your response):"
56+
instruction = sample["input"][0]["content"][:-96]
57+
sample_content = sample["input"][1]["content"]
58+
question = f"{instruction}: {sample_content}"
59+
ideal = sample["ideal"].lower()
60+
distractor_samples.append(DistractorSample(question, ideal))
61+
return distractor_samples
62+
63+
64+
variant_to_processor = {
65+
"which-is-heavier": proc_which_is_heavier,
66+
"first-letters": proc_distractors_first_letters,
67+
"ambiguous-sentences": proc_distractors_ambiguous_sentences,
68+
"reverse-sort-words-eng": proc_distractors_reverse_sort_words_eng,
69+
}
70+
71+
72+
def get_basic_distractor_example() -> DistractorSample:
73+
"""
74+
An arbitrary distractor example used in the task description for the
75+
distractorless variant
76+
"""
77+
return DistractorSample(question="What is the capital of Italy?", ideal="rome")
78+
79+
80+
def get_distractors(variant: str) -> list[DistractorSample]:
81+
"""
82+
Gets and optionally processes the corpus of distractor questions for variant
83+
"""
84+
assert variant in VARIANTS, f"Invalid variant {variant}, expected one of {VARIANTS}"
85+
if variant == "distractorless":
86+
# single element will be pop()ed for the task description, leaving an empty list
87+
return [get_basic_distractor_example()]
88+
89+
samples = get_samples(variant)
90+
91+
process_variant_fn = variant_to_processor[variant]
92+
processed_samples = process_variant_fn(samples)
93+
94+
return processed_samples
95+
96+
97+
def get_samples(eval_name) -> list[dict]:
98+
"""
99+
Gets the samples from the samples_jsonl associated with
100+
a given eval.
101+
102+
Adapted from evals.eval.Eval.get_samples
103+
"""
104+
registry = evals.registry.Registry()
105+
eval_spec = registry.get_eval(eval_name)
106+
samples_path = eval_spec.args["samples_jsonl"]
107+
registry_path = eval_spec.registry_path
108+
samples_full_path = get_full_path(samples_path, registry_path)
109+
return evals.data.get_jsonl(samples_full_path.as_posix())
110+
111+
112+
def get_full_path(data_path, registry_path) -> Path:
113+
if os.path.isfile(data_path):
114+
return Path(data_path)
115+
116+
return registry_path / "data" / data_path
117+
118+
119+
def get_distractor_word(question: str) -> str:
120+
"""
121+
Takes the last word of the question (stripped of punctuation and lower-cased)
122+
To be shown in the task description example
123+
"""
124+
words = question.split()
125+
last_word = words[-1]
126+
last_word = last_word.strip(".,!?")
127+
return last_word.lower()
128+
129+
130+
if __name__ == "__main__":
131+
# just for testing
132+
distractors = get_distractors("rectangles")
133+
print(distractors[0])

0 commit comments

Comments
 (0)