Importing the data
Persona Hub: https://github.com/tencent-ailab/persona-hubSelecting data
Here we select some personas to use.Creating agents
We create an agent in EDSL by passing a dictionary oftraits
(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:Service Name | |
---|---|
0 | anthropic |
1 | azure |
2 | bedrock |
3 | deep_infra |
4 | deepseek |
5 | |
6 | groq |
7 | mistral |
8 | ollama |
9 | openai |
10 | perplexity |
11 | together |
12 | xai |
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:model.model | agent.persona | answer.preferred_mode_commute | answer.work_from_home | |
---|---|---|---|---|
0 | gemini-1.5-flash | A theater manager or events coordinator interested in understanding the operational aspects, facilities, and programming of performing arts centers, such as the Broward Center. | Car | 1 |
1 | gpt-4o | A theater manager or events coordinator interested in understanding the operational aspects, facilities, and programming of performing arts centers, such as the Broward Center. | Car | 2 |
2 | gemini-1.5-flash | An urban planner looking to understand the distribution and organization of public services in the Halifax Regional Municipality. | Public transportation | 3 |
3 | gpt-4o | An urban planner looking to understand the distribution and organization of public services in the Halifax Regional Municipality. | Public transportation | 4 |
4 | gemini-1.5-flash | A high school literature teacher looking for supplementary materials to enrich their curriculum and provide students with a deeper understanding of their state’s cultural heritage. | Car | 3 |
5 | gpt-4o | A high school literature teacher looking for supplementary materials to enrich their curriculum and provide students with a deeper understanding of their state’s cultural heritage. | Car | 3 |
6 | gemini-1.5-flash | A science fiction writer, exploring the use of secret trials as a theme in stories that examine surveillance, privacy, and power dynamics in society. | Work from home | 5 |
7 | gpt-4o | A science fiction writer, exploring the use of secret trials as a theme in stories that examine surveillance, privacy, and power dynamics in society. | Work from home | 5 |
8 | gemini-1.5-flash | A financial analyst specializing in Asian markets and wealthy individuals, interested in tracking the investments and philanthropic activities of billionaires like Gerald Chan. | Work from home | 4 |
9 | gpt-4o | A financial analyst specializing in Asian markets and wealthy individuals, interested in tracking the investments and philanthropic activities of billionaires like Gerald Chan. | Work from home | 5 |
10 | gemini-1.5-flash | A high school physics teacher who enjoys applying physics concepts to various sports, curious about the effects of water resistance and body positioning in Paralympic swimming. | Car | 3 |
11 | gpt-4o | A high school physics teacher who enjoys applying physics concepts to various sports, curious about the effects of water resistance and body positioning in Paralympic swimming. | Bike | 2 |
12 | gemini-1.5-flash | A high school physical education teacher seeking to incorporate Paralympic history and achievements into the curriculum to inspire and educate students about inclusivity in sports. | Car | 1 |
13 | gpt-4o | A high school physical education teacher seeking to incorporate Paralympic history and achievements into the curriculum to inspire and educate students about inclusivity in sports. | Bike | 1 |
14 | gemini-1.5-flash | A high school history teacher creating lesson plans on South American civilizations and their regional diversity. | Car | 3 |
15 | gpt-4o | A high school history teacher creating lesson plans on South American civilizations and their regional diversity. | Car | 4 |
16 | gemini-1.5-flash | A cultural anthropologist studying the representation and adaptation of traditional folklore in contemporary media, particularly in television and film. | Work from home | 4 |
17 | gpt-4o | A cultural anthropologist studying the representation and adaptation of traditional folklore in contemporary media, particularly in television and film. | Work from home | 4 |
18 | gemini-1.5-flash | A high school earth science teacher looking for real-world examples to explain climate zones, soil types, and human-environment interactions. | Car | 2 |
19 | gpt-4o | A high school earth science teacher looking for real-world examples to explain climate zones, soil types, and human-environment interactions. | Car | 3 |
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 separatetrait
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.
scenario.persona | answer.occupation | |
---|---|---|
0 | A theater manager or events coordinator interested in understanding the operational aspects, facilities, and programming of performing arts centers, such as the Broward Center. | {'occupation': 'theater manager or events coordinator'} |
1 | An urban planner looking to understand the distribution and organization of public services in the Halifax Regional Municipality. | {'occupation': 'urban planner'} |
2 | A high school literature teacher looking for supplementary materials to enrich their curriculum and provide students with a deeper understanding of their state’s cultural heritage. | {'occupation': 'high school literature teacher'} |
3 | A science fiction writer, exploring the use of secret trials as a theme in stories that examine surveillance, privacy, and power dynamics in society. | {'occupation': 'science fiction writer'} |
4 | A financial analyst specializing in Asian markets and wealthy individuals, interested in tracking the investments and philanthropic activities of billionaires like Gerald Chan. | {'occupation': 'financial analyst'} |
5 | A high school physics teacher who enjoys applying physics concepts to various sports, curious about the effects of water resistance and body positioning in Paralympic swimming. | {'occupation': 'high school physics teacher'} |
6 | A high school physical education teacher seeking to incorporate Paralympic history and achievements into the curriculum to inspire and educate students about inclusivity in sports. | {'occupation': 'high school physical education teacher'} |
7 | A high school history teacher creating lesson plans on South American civilizations and their regional diversity. | {'occupation': 'high school history teacher'} |
8 | A cultural anthropologist studying the representation and adaptation of traditional folklore in contemporary media, particularly in television and film. | {'occupation': 'cultural anthropologist'} |
9 | A high school earth science teacher looking for real-world examples to explain climate zones, soil types, and human-environment interactions. | {'occupation': 'high school earth science teacher'} |
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:model.model | agent.occupation | answer.preferred_mode_commute | answer.work_from_home | |
---|---|---|---|---|
0 | gpt-4o | science fiction writer | Work from home | 5 |
1 | gpt-4o | financial analyst | Work from home | 5 |
2 | gpt-4o | cultural anthropologist | Work from home | 5 |
3 | gpt-4o | urban planner | Public transportation | 4 |
4 | gpt-4o | high school literature teacher | Car | 3 |
5 | gpt-4o | high school physics teacher | Bike | 3 |
6 | gpt-4o | high school history teacher | Car | 3 |
7 | gpt-4o | high school earth science teacher | Car | 3 |
8 | gpt-4o | theater manager or events coordinator | Car | 2 |
9 | gpt-4o | high school physical education teacher | Bike | 1 |