๐ PersonaForge has been accepted to ACL 2026 Findings!
Large Language Models excel at role-playing but struggle to maintain consistent personalities across extended multi-turn interactions. PersonaForge is a framework that combines a three-layer personality architecture grounded in psychological theory with a dual-process generation mechanism inspired by cognitive science to enable personality-consistent, long-term role-playing.
- Three-Layer Personality Architecture: A functionally decomposed structure integrating Core Traits (Big Five / Wu Xing), Speaking Style, and Dynamic State (mood, energy, relationships).
- Selective Dual-Process Generation: A "Think-then-Speak" Inner Monologue mechanism that activates only for critical interactions (~40% of turns), achieving 96% of full dual-process performance with only 13.4% token overhead.
- Long-Dialogue Robustness: Proven to significantly reduce drift over 50-turn conversations (6.3% drift vs. 31.7% baseline), heavily outperforming standard LoRA SFT approaches in long-context scenarios.
- Real-Time Viable: Features an Asynchronous State Update mechanism, reducing perceived latency to standard single-pass LLM speeds (~0.94s) without sacrificing consistency.
- Culturally Adaptable: Ontology-agnostic architecture compatible with diverse psychological frameworks.
PersonaForge/
โโโ modules/ # Core implementation
โ โโโ dual_process_agent.py # Inner Monologue + Styled Response
โ โโโ dynamic_state_manager.py # Dynamic State Layer
โ โโโ personality_model.py # Big Five + Defense Mechanisms
โ โโโ main_performer.py # Full Performer agent
โ โโโ orchestrator.py # World-level orchestration
โ โโโ llm/ # LLM interface wrappers
โโโ experiments/ # Experiment scripts
โ โโโ evaluation_framework.py # Core evaluation metrics
โ โโโ run_experiment.py # Main experiment runner
โ โโโ run_main_experiment.py # Scenario-based experiments (Table 1)
โ โโโ authentic_long_dialogue.py # Long dialogue benchmark (Table 2)
โ โโโ ablation_psychology.py # Ablation studies (Table 3)
โ โโโ trigger_diagnostics.py # Trigger precision/recall
โ โโโ configs/ # Experiment configurations
โโโ data/ # Character profiles & world settings
โ โโโ roles/ # 88 character profiles (JSON)
โโโ rebuttal/ # For rebuttal
โโโ requirements.txt # Python dependencies
- Python 3.8+
- 8GB+ RAM recommended
- API access to one of: Gemini, DeepSeek, OpenAI, or local models via Ollama
# Clone repository
git clone https://github.com/fQwQf/PersonaForge
cd PersonaForge
# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Linux/Mac
# or: venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Configure API keys
cp config.json.example config.json
# Edit config.json with your API keys# Run scenario-based experiment (Table 1)
python experiments/run_main_experiment.py
# Run long-dialogue benchmark (Table 2)
python experiments/authentic_long_dialogue.py
# Run ablation studies (Table 3)
python experiments/ablation_psychology.pyEdit experiments/config.json:
{
"role_llm_name": "gemini-2.5-flash", // Generator model
"world_llm_name": "gemini-2.5-flash", // Orchestrator model
"embedding_model_name": "bge-small", // Embedding model
"characters_to_test": ["lin_daiyu", "tyrion_lannister", ...]
}python experiments/run_main_experiment.py --output results/main.jsonReproduces: PC, SA, DM, RD metrics across all baselines.
python experiments/authentic_long_dialogue.py \
--turns 50 \
--characters 10 \
--output results/long_dialogue.jsonReproduces: Drift rate, Average PC, Recovery rate over 50 turns.
python experiments/ablation_psychology.py \
--ablations "no_dual,no_bigfive,no_dm,no_style,no_state,generic" \
--output results/ablation.jsonReproduces: Per-component contribution analysis.
python experiments/run_experiment.py \
--mode fourtest \
--output results/sft_comparison.jsonReproduces: Comparison with LoRA-based SFT on Qwen2.5-7B.
| Metric | Description |
|---|---|
| PC (Personality Consistency) | Pairwise LLM-as-Judge evaluation of trait alignment |
| SA (Style Adherence) | Composite of sentence length, catchphrase, tone, vocabulary |
| DM (Defense Mechanism) | Activation precision and manifestation accuracy |
| RD (Response Diversity) | 1 - Self-BLEU to measure lexical diversity |
| Drift Rate | % of turns where PC drops below threshold |
| Recovery Rate | % recovering to high PC within N turns after perturbation |
Each character profile in data/roles/ follows this schema:
{
"name": "Lin Daiyu",
"big_five": {
"openness": 0.9,
"conscientiousness": 0.4,
"extraversion": 0.3,
"agreeableness": 0.5,
"neuroticism": 0.9
},
"defense_mechanism": "sublimation",
"speaking_style": {
"sentence_length": "medium",
"vocabulary": "academic",
"punctuation": "excessive",
"catchphrases": ["็ฝขไบ", "ไฝ ๅช็ฎก..."],
"tone_markers": ["ๅข", "็ฝข"]
},
"background": "...",
"interests": ["poetry", "flowers"]
}PersonaForge runs fully on open-source models with minimal degradation:
| Component | Closed-Source | Open-Source | ฮ |
|---|---|---|---|
| Generator | Gemini 2.5 | DeepSeek-V3 | -0.02 PC |
| State Extraction | Gemini 2.5 | DeepSeek-V3 | +4.2% drift |
| Judge | Gemini 2.5 | DeepSeek-V3 | r=0.84 |
To use open-source models:
python experiments/run_opensource_experiment.py- Zero-Shot: Role name only
- Character-LLM-style: Profile + few-shot exemplars
- Structured-CoT: Chain-of-thought with natural language descriptions
- RAG-Persona: Retrieval-augmented memory proxy
- RoleLLM-style: Role-profile-guiding with retrieval
- Periodic Re-grounding: Re-inject prompt every 5 turns
- Memory+Reflection: Simplified generative agent with 10-turn reflections
If you use PersonaForge in your research, please cite:
@inproceedings{tong2026personaforge,
title={PersonaForge: Psychology-Grounded Dual-Process Architecture for Personality-Consistent Role-Playing Agents},
author={Tong, Jizhou and Zou, Sirui},
booktitle={Findings of the Association for Computational Linguistics: ACL 2026},
year={2026}
}This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
This codebase is built upon the BookWorld multi-agent simulation framework (Ran et al., 2025). We thank the authors for releasing their code, which served as the foundation for our agent interaction loop.