Skip to content
Generative Agents: Interactive Simulacra of Human Behavior 4 min

Joon Sung Park, Joseph C. O'Brien, Carrie J. Cai, Meredith Ringel Morris, Percy Liang, Michael S. Bernstein · UIST, arXiv 2023

Generative Agents: Interactive Simulacra of Human Behavior

Twenty-five AI characters live in a tiny town and throw a party nobody scripted. See how a memory stream makes it work, and try the retrieval yourself.

Read the original paper

AI & ML · White Belt · Free · 4 min read

Generative Agents: Interactive Simulacra of Human Behavior

What if a video game character could remember what happened to it yesterday, form an opinion of the neighbors, and decide for itself what to do today? A Stanford and Google team built a tiny town to find out. Twenty-five characters live in it, each run by a language model. They wake up, make breakfast, go to work and talk to each other.

The paper calls them generative agents. The headline story is a party. A user gave one agent the idea of throwing a Valentine's Day party, and then stepped back. The town did the rest.

Generative agents are language-model characters with a memory. The design has three parts: a memory stream that records everything in plain English, retrieval that picks the few memories that matter right now, and reflection that turns many memories into insights. In tests, each part made the agents more believable.

A small town of 25

The world is called Smallville, a sprite-based town like The Sims, with houses, a cafe, shops and a park. Each agent starts with a short description in plain English: a name, a job, a few traits and a few relationships. Then the simulation runs. Agents plan their days, walk to places, chat when they meet and update their plans when something happens.

Two things were planted by the researchers. One agent, Isabella, was given the intent to throw a Valentine's Day party. Another, Maria, had a crush on Klaus. Everything else, including spreading the word, decorating the cafe and asking each other out, came from the agents themselves.

Nobody scripted the spread. The user only gave one agent the idea of a party, and the news reached more than half of the town. Of the twelve agents invited, five showed up at the cafe on the day.

Over two game days, the number of agents who knew about the party rose from one to thirteen of the twenty-five. News of one agent's run for mayor rose from one to eight. The town's friendship network went from sparse to dense. When the team checked what agents claimed to know, only about 1.3 percent of the answers about other agents were found to be made up.

The hard part: a memory that scales

A language model can only read a limited amount of text at once. A character that lives for days piles up thousands of events. If you paste them all in, the prompt overflows. If you paste a few, the character forgets who it is.

The paper's answer is a memory stream: a long list of everything the agent experiences, written in plain English, each with a time stamp. Before the agent acts, a retrieval step looks at the situation and selects the few memories most worth showing the model. Each memory gets a score from three ingredients:

  • Recency. Newer memories score higher. In the paper this fades by a factor of 0.995 for every game hour since the memory was last used.
  • Importance. The language model rates each memory from 1 to 10. Brushing teeth is a 1. A breakup or a college acceptance is near 10.
  • Relevance. How close the memory is in meaning to what is happening now, found by comparing embeddings.
The paper's three parts. The memory stream stores everything. Retrieval picks what to show the language model. Reflection and planning turn raw memories into insights and a plan, which also go back into the memory stream.

Each ingredient is scaled to between 0 and 1, then added together with equal weight. The best-scoring memories that fit in the prompt are what the agent "remembers" at that moment.

Try it: be the memory

This agent has eight memories. Pick a question and see which three get into the prompt. Then change the weights to see what happens if the agent cares only about recent events, or only about important ones.

Reflection and planning

Raw memories do not make a personality. The agents also reflect. When the importance of recent events adds up past a threshold of 150, the agent looks at its latest 100 memories, asks itself what the most important questions are, and writes down higher-level insights. In the paper's example an agent who spends hours on research notes that he is passionate about his work. The agents reflected two or three times a day. Reflections go into the memory stream, so they can be retrieved like any other memory.

They also plan. An agent writes a rough plan for the day first, then breaks it into smaller steps, and changes the plan if something surprising happens, such as meeting a neighbor with news.

Does each part matter?

The authors "interviewed" agents with questions about themselves, their plans and what they knew, and asked 100 people to rank the believability of different answers. They compared the full design against versions with parts removed, and against answers written by human crowdworkers pretending to be the character.

Version of the agentBelievability score
Full design: memory, reflection and planning29.89
No reflection26.88
No reflection and no planning25.64
Answers written by human crowdworkers22.95
No memory at all (the earlier approach)21.21

Each missing part lowered the score. The full design was ranked most believable, ahead of even the human-written answers. The paper reports an effect size of more than eight standard deviations between the full design and the version with no memory, no planning and no reflection.

The agents are not perfect. The paper reports that they sometimes fail to find a memory they had, embellish the details of what they remember, or follow the wrong social rule, such as treating a one-person bathroom as shared. The authors also warn that people might form parasocial relationships with such agents, and recommend keeping logs of what they say.

Key takeaways: Characters built on language models need a memory system, because the model can only read so much at once. Retrieval scores memories by recency, importance and relevance. Reflection turns many memories into a few lasting insights. Believable group behavior, such as a party, can emerge without a script.

Go deeper

Found this breakdown useful?

Share it with someone else wrestling with this paper.

Discussion0

Join the Discussion

Sign in to leave comments, reply to others, or like insights.

Sign In to ScaleDojo

No comments yet. Be the first to start the thread!

Enjoyed this? Get more like it.

New paper breakdowns, levels, and one concept worth knowing, straight to your inbox.

No spam, ever. Unsubscribe in one click.

Enjoyed this content?

Your support keeps us creating free resources

We put a lot of hours into researching and writing these guides. If it helped you, consider buying us a coffee. Every bit goes toward keeping ScaleDojo's content free and growing.

$

One-time payment via Stripe. ScaleDojo account required.