Skip to main content
EDSL is an open-source library for simulating surveys, experiments and other research with AI agents and large language models. Before running the code below please see instructions on getting started and tips and tutorials at our documentation page.

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:
This approach may be feasible for a small dataset that is easily checked. For larger datasets, we may encounter problems with input token limits, a model’s ability to accurately check a large volume of data at once, and responses that are not usefully formatted. Below we demonstrate some ways of approaching the task in an iterative manner instead.

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 use QuestionList 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 create Scenario 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:

Running the question

We administer the question to a model by adding the scenarios and calling the run method. This generates a formatted dataset of Results that we can access with built-in methods for analysis. Here we inspect the answer:

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 use QuestionYesNo to easily filter the responses:
We need to create a new set of scenarios for the question. We use ScenarioList objects to create all the combinations of values to add to the question (learn more about constructing scenarios from different data sources):
We can inspect the scenarios that we created:
ScenarioList scenarios: 3; keys: [‘sense_check_question’, ‘age’, ‘data_description’]; Same as with a single scenario, we add all the scenarios to the question at once when we run it:
We can filter, sort, select and print any components of the results that are generated:

Further exploration

This notebook can be readily edited and expanded for other data cleaning and data labeling purposes, or to add personas for AI agents answering the questions with relevant background and expertise. Learn more about using AI agents for your EDSL surveys. Please see our documentation page for examples of other methods and use cases and let us know if you have any questions!

Posting to Expected Parrot

Expected Parrot is a platform for creating, storing and sharing LLM-based research. It is fully integrated with EDSL and accessible from your workspace or Expected Parrot account page. Learn more about creating an account and the platform. Here we post this notebook:
To update an object at Expected Parrot: