Character-LLM: A Trainable Agent for Role-Playing

Yunfan Shao, Linyang Li, Junqi Dai, Xipeng Qiu

Abstract

While Large Language Models (LLMs) demonstrate remarkable instruction-following capabilities, they often struggle to maintain the deep, consistent persona required for authentic role-playing. This paper presents Character-LLM, a framework that moves beyond superficial prompting to create "personal simulacra." By fine-tuning models on a curated pipeline of "reconstructed experiences" and "protective scenes," we transform standard 7B models into vivid characters that outperform significantly larger models in role-playing authenticity and historical accuracy.

Introduction

Role-playing in AI has traditionally relied on prompt engineering—instructing a model to "act like" a specific individual. However, this approach often results in superficial mimicry. The model might adopt a specific tone but lacks the underlying memories, emotional depth, and era-appropriate constraints of the character. Character-LLM addresses this by treating character development as a training process rather than a prompting task, aiming to create agents that truly embody specific historical or fictional figures.

The Problem of Character Hallucination

A primary obstacle in role-playing is "Character Hallucination." Because LLMs are trained on vast, modern datasets, an agent playing a historical figure like Socrates might inadvertently reference modern technology or concepts (e.g., Python programming) because that data exists in its pre-training set. To create a believable simulacrum, the model must not only learn who the character is but also learn to ignore information that falls outside the character's identity and era. The authors argue that a model needs to "experience" a character's life to learn these boundaries effectively.

Methodology: The Experience Upload Framework

The researchers propose a framework called Experience Upload, which consists of three main stages designed to move character data into the model's weights:

  1. Experience Reconstruction: Since detailed, formatted personal diaries are rare, the authors use a powerful teacher model (GPT-3.5-turbo) to transform concise Wikipedia profiles into thousands of detailed "flashback scenes." This involves Scene Extraction (identifying key life events) and Experience Completion (expanding events into scripts that include dialogue, internal thoughts, and emotional reflections).
  2. Protective Experience: To combat character hallucination, the framework generates scenes where the character is asked about things they shouldn't know (e.g., asking Julius Caesar about the internet). In these scenes, the character is trained to express confusion or ignorance, effectively "teaching" the model its own cognitive boundaries.
  3. Experience Upload (Fine-Tuning): A LLaMA 7B base model is fine-tuned on these reconstructed scenes (roughly 1K–2K scenes per character) using Supervised Fine-Tuning (SFT).

Experimental Setup

The researchers curated a diverse set of nine characters for their experiments, spanning historical figures (Cleopatra VII, Julius Caesar, Isaac Newton, Ludwig van Beethoven, Socrates, Martin Luther King Jr.) and fictional personas (Lord Voldemort, Hermione Granger, Spartacus). The resulting dataset for each character contains between 1.4K and 2.2K scenes, averaging about 13 turns of interaction per scene. Evaluation was conducted via a "test playground" consisting of over 1,300 single-turn and multi-turn interview questions.

Key Insights and Results

The study yielded several critical insights into the nature of AI role-playing:

  • Internal Monologue Matters: Including "thinking" blocks in the training data significantly boosts the believability of the agent's "speaking" actions, as it provides context for the character's motivations.
  • The "Protective" Catalyst: Training a model on what it doesn't know is as vital as training it on what it does know. A few dozen protective scenes allowed the model to generalize and refuse out-of-character questions across various domains.
  • Experience vs. Instruction: Fine-tuning on a person's "life experiences" creates a more stable and vivid personality than simply providing a long list of instructions in a system prompt.

Using GPT-3.5 as a judge to score agents on a 7-point Likert scale across five dimensions (Memorization, Values, Personality, Hallucination, and Stability), the researchers found that Character-LLM (7B) significantly outperformed other 7B models like Alpaca and Vicuna. Furthermore, it achieved performance comparable to—and sometimes exceeding—ChatGPT in role-playing quality, particularly in maintaining character-specific values and avoiding modern-day hallucinations.

Limitations and Future Work

While promising, the framework currently relies on Wikipedia, which provides a "public" view of a person. Future iterations may use biographies and interviews for more intimate character portraits. Additionally, the quality of the simulacrum remains tied to the pre-training of the base model. The authors also acknowledge the ethical trade-off between acting accuracy and safety, particularly when creating vivid simulacra of "vicious" characters. Future work will explore scaling to larger base models and expanding agent capabilities within sandbox environments.

Summary updated

BibTeX
@inproceedings{shao2023character,
  author = {Yunfan Shao and Linyang Li and Junqi Dai and Xipeng Qiu},
  title = {{Character-LLM: A Trainable Agent for Role-Playing}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.emnlp-main.814},
}
Figure