Skip to main content
The following questions are used in the sample survey: On a scale from 0-10, how likely are you to recommend our company to a friend or colleague? (0=Not at all likely, 10=Very likely) Please tell us why you gave a rating. How satisfied are you with the following experience with our company? Product quality Customer support Purchasing experience Is there anything specific that our company can do to improve your experience?

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:
Each question type other than free text automatically includes a “comment” field for the model to provide commentary on its response to the main question. When we run the survey, we can check that it has effectively captured the follow-on question from above–Please tell us why you gave a rating–and modify or add questions as needed. For the next question, we use a {{ placeholder }} for an “experience” that we will insert when repeating the base question:
The third question is a simple free text question that we can choose whether to administer once or individually for each “experience” question. In the steps that follow we show how to apply survey logic to achieve this effect:

Creating variants of questions with scenarios

Next we want to create a version of the “satisfied” question for each “experience”. This can be done with Scenario 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:
We could also use a specific method for creating scenarios from a list:
We can check the scenarios that have been created:
ScenarioList scenarios: 3; keys: [‘experience’]; 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:
We can also use the 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 a Survey 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):
We can inspect the survey details:

AI agent personas

EDSL comes with a variety of methods for designing AI agents to answer surveys. An Agent 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:
We can run this question alone and extract the response list (more on working with results below):
[‘John, a retired teacher who is thrilled with the eco-friendly garden design’, ‘Maria, a busy professional who is satisfied with the maintenance services but desires quicker responses’, ‘Liam, a young homeowner who is disappointed with the delayed project completion’, ‘Sophia, a new parent who appreciates the child-safe landscaping features but finds them costly’, ‘Raj, a tech-savvy entrepreneur who loves the innovative designs but is frustrated with the lack of digital communication options’] Next we pass the personas to create a set of agents:

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:
To select a model to use with a survey we pass a model name to a Model:
If we want to compare responses for several models, we can use a 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 the by() method and then calling the run() method:
This generates a dataset of 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:

Posting to Expected Parrot

Expected Parrot is a platform for creating, storing and sharing LLM-based research. It is fully integrated with EDSL, allowing you to access objects from your workspace or your account. Learn more about creating an account and using the platform. The surveys and results above were already posted automatically using remote inference. Here we demonstrate local methods for posting the same content from your workspace (if you are working locally):
We can also post a notebook, such as this one: