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 ensure that you have installed the EDSL library and either activated remote inference from your Expected Parrot account or stored API keys for the language models that you want to use with EDSL. Please also see our documentation page for tips and tutorials on getting started using EDSL.

Importing the data

Persona Hub: https://github.com/tencent-ailab/persona-hub

Selecting data

Here we select some personas to use.

Creating agents

We create an agent in EDSL by passing a dictionary of traits (such as a persona) to an Agent object. Here we use a method for generating a set of agents from a list of traits at once (a list of the personas). Learn more about designing agents in EDSL.

Using agents to answer a survey

Here we construct some questions and administer them to the agents. EDSL comes with many common question types that we can choose from based on the form of the response that we want to get back from a model. Learn more about constructing surveys with different question types, logic and rules.

Selecting language models

EDSL works with many popular language models that we can select to generate the responses for the agents. To see a list of all services:
To see a list of all available models:
We run a survey by adding the agents and models, and then calling the run() method. This generates a formatted dataset of Results:

Analyzing results

EDSL comes with built-in methods for analysis. Here we inspect the responses in a table:

Constructing traits

In comparing model responses it can be convenient to include shortnames for traits in addition to narrative personas–e.g., just the name of the agent’s occupation, age, etc. Here we run a question to extract the occupation from each persona in order to store it as a separate trait of each agent. We use Scenario objects to represent the data (personas) that we add to the question when we run it. Learn more about using scenarios to parameterize questions with data and context.
Creating scenarios for the personas in order to add them to the question:

Designing agents

Here we recreate agents with both the personas and occupations as traits:

Running a survey

Here we rerun the survey and then filter and sort results by agent traits:

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 demonstrate how to post this notebook: