Technical setup
Before running the code below, ensure that you have (1) installed the EDSL library and (2) created a Expected Parrot account to activate remote inference or stored your own API keys for language models that you want to use with EDSL. Please also see our tutorials and documentation page on getting started using the EDSL library.Constructing questions
We start by selecting appropriate question types for the above questions. EDSL comes with a variety of common question types that we can choose from based on the form of the response that we want to get back from the model. The first quesiton is linear scale; we import the class type and then construct a question in the relevant template:{{ placeholder }} for an “experience” that we will insert when repeating the base question:
Creating variants of questions with scenarios
Next we want to create a version of the “satisfied” question for each “experience”. This can be done withScenario objects–dictionaries of key/value pairs representing the content to be added to questions. Scenarios can be automatically generated from a variety of data sources (PDFs, CSVs, images, tables, etc.). Here we have import a simple list:
To create the question variants, we pass the scenario list to the question
loop() method, which returns a list of new questions. We can see that each question has a new unique name and a question text with the placeholder replaced with an experience:
loop() method to create copies of the “improve” question in order to present it as a follow-up question to each of the “satisfied” questions that have been parameterized with experiences. Here, we’re simply duplicating the base question without a scenario {{ placeholder }} because we will instead add a “memory” of the relevant “satisfied” question when administering each copy of it:
Creating a survey
Next we pass a list of all the questions to aSurvey in order to administer them together:
Adding survey logic
In the next step we add logic to the survey specifying that each “improve” question should include a “memory” of a “satisfied” question (the question and answer that was provided):AI agent personas
EDSL comes with a variety of methods for designing AI agents to answer surveys. AnAgent is constructed by passing a dictionary of relevant traits with optional additional instructions for the language model to reference in generating responses for the agent. Agents can be constructed from a variety of data sources, including existing survey data (e.g., a dataset of responses that were provided to some other questions). We can also use an EDSL question to draft some personas for agents. Here, we ask for a list of them:
Selecting language models
EDSL works with many popular large language models that we can select to use with a survey. To see a list of available models:Model:
ModelList instead:
Note:If no model is specified when running a survey, the default model gpt-5.2 is used (as above when we generated personas).
Running a survey
We administer the survey by adding the agents and models with theby() method and then calling the run() method:
Results that includes a response for each agent/model that was used. We can access the results with built-in methods for analysis. To see a list of all the components of the results:
For example, we can filter, sort and display columns of results in a table:
