Example data
EDSL allows us to generate data or import it from other sources (CSV, PDF, PNG, MP4, DOC, tables, lists, dicts, etc.). Here we construct a dataset for our exercise: a random list of ages between 22 and 85 with some bad values mixed in. Our goal is to identify them:Quick question
With a small dataset, we may be able to design the entire task as a single question where we prompt a model to review all the data at once and flag bad data:answer.bad_ages | comment.bad_ages_comment | |
---|---|---|
0 | [0.99, -5, 1050, 1.3, ‘old’] | # These values are not realistic human ages because they are either negative, less than 1, or far exceed the maximum human lifespan. “old” is also not a numerical age. |
Constructing a question
We start by creating a question to prompt a model to draft sense check questions for our data. EDSL comes with a variety of question types that we can choose from based on the desired form of the response (multiple choice, free text, etc.). Here we useQuestionList
in order to prompt the model to format its response as a list. We use a {{ placeholder }}
for content that we will add to the question when we run it (a description of the data and a sample); this allows us to re-use the question with other contexts as desired:
Adding context to the question
Next we createScenario
objects representing the content that we want to add to the question when we run it. Here we create a single scenario for our example data:
key | value | |
---|---|---|
0 | data_description | a list of realistic human ages (in years) |
1 | sample_data:0 | 54 |
2 | sample_data:1 | 48 |
3 | sample_data:2 | 57 |
4 | sample_data:3 | 43 |
5 | sample_data:4 | 80 |
6 | sample_data:5 | 58 |
7 | sample_data:6 | 57 |
8 | sample_data:7 | 57 |
9 | sample_data:8 | 23 |
10 | sample_data:9 | 72 |
Running the question
We administer the question to a model by adding the scenarios and calling therun
method. This generates a formatted dataset of Results
that we can access with built-in methods for analysis. Here we inspect the answer:
answer.sense_check_questions | |
---|---|
0 | [‘Is the age a non-negative integer?’, ‘Is the age within a plausible range for a living human (e.g., 0-125)?’, ‘Is the age consistent with other ages in the dataset (considering potential context, if available)?’] |
Conducting the task
Next we want a model to answer each sense check question about each piece of data in the dataset. This can be done by using the sense check questions as scenarios of a new question explaining the task. We can useQuestionYesNo
to easily filter the responses:
ScenarioList
objects to create all the combinations of values to add to the question (learn more about constructing scenarios from different data sources):
data_description | age | sense_check_question | |
---|---|---|---|
0 | a list of realistic human ages (in years) | 22 | Is the age a non-negative integer? |
1 | a list of realistic human ages (in years) | 58 | Is the age consistent with other ages in the dataset (considering potential context, if available)? |
2 | a list of realistic human ages (in years) | 38 | Is the age a non-negative integer? |
scenario.sense_check_question | scenario.age | |
---|---|---|
0 | Is the age a non-negative integer? | 0.99 |
1 | Is the age a non-negative integer? | -5 |
2 | Is the age a non-negative integer? | 1050 |
3 | Is the age a non-negative integer? | old |
4 | Is the age a non-negative integer? | 1.3 |
5 | Is the age consistent with other ages in the dataset (considering potential context, if available)? | 0.99 |
6 | Is the age consistent with other ages in the dataset (considering potential context, if available)? | -5 |
7 | Is the age consistent with other ages in the dataset (considering potential context, if available)? | 1050 |
8 | Is the age consistent with other ages in the dataset (considering potential context, if available)? | old |
9 | Is the age consistent with other ages in the dataset (considering potential context, if available)? | 2 |
10 | Is the age consistent with other ages in the dataset (considering potential context, if available)? | 100 |
11 | Is the age consistent with other ages in the dataset (considering potential context, if available)? | 1.3 |
12 | Is the age within a plausible range for a living human (e.g., 0-125)? | -5 |
13 | Is the age within a plausible range for a living human (e.g., 0-125)? | 1050 |
14 | Is the age within a plausible range for a living human (e.g., 0-125)? | old |
15 | Is the age within a plausible range for a living human (e.g., 0-125)? | 1.3 |