atlas

Research map / Large language models / Agents, code and math

Codifying Character Logic in Role-Playing

NeurIPS 2025 · Large language models › Agents, code and math · approach: Reasoning benchmarks and platforms · 0 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes Codified Profiles, which compile textual character profiles into executable parse_by_scene functions with LLM-based condition checks, and a Fandom-based benchmark (83 characters, 5,141 scenes) showing gains in persistence, updatability, and controllable randomness, especially for small models.

Problem

Prompt-based role-playing appends character profiles to prompts, so character behavior depends on the LLM's implicit reasoning, which is inconsistent, hard to debug or update, and computationally costly at runtime.

Approach

Use an LLM to codify each profile paragraph into an executable function whose control flow (if-then-else) is evaluated deterministically, with semantic conditions checked by the role-playing LLM via logits over yes/no/unknown verbalizers, and randomness encoded directly in code.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Replace textual profiles with codified profilesLlama-3.1-8B-Instruct role-playing · Fandom Benchmark (main characters, average)NLI score: 65.98 -> 68.38Helped
Replace textual profiles with codified profilesLlama-3.1-8B-Instruct role-playing · Fandom Benchmark (minor characters, average)NLI score: 65.70 -> 69.87Helped
Replace Codified RAG with structured executable behavior logicLlama-3.1-8B-Instruct role-playing · Fandom Benchmark (main characters, average)NLI score: 66.04 -> 68.38Helped
Add a textual profile on top of the codified profile (ablation)Codified Profile · Fandom Benchmark (main characters, average)NLI score: 68.38 -> 68.62Helped
Add a textual profile on top of the codified profile (ablation)Codified Profile · Fandom Benchmark (minor characters, average)NLI score: 69.87 -> 69.96Helped
Add codified profiles instead of textual profilesLlama-3.2-1B role-playing · Fandom Benchmark (main characters, average)NLI score: 56.00 -> 58.43Helped
Add codified profiles instead of textual profilesLlama-3.2-1B role-playing · Fandom Benchmark (minor characters, average)NLI score: 59.40 -> 62.59Helped
Add a distilled 100M condition checker to 1B + Code (ablation)Llama-3.2-1B role-playing · Fandom Benchmark (main characters, average)NLI score: 58.43 -> 60.21Helped
Add a distilled 100M condition checker to 1B + Code (ablation)Llama-3.2-1B role-playing · Fandom Benchmark (minor characters, average)NLI score: 62.59 -> 64.25Helped
Use paragraph-level rather than section-level profile segmentation (ablation)Codified Profiles · Fandom Benchmark role-playingNLI scoreHelped
Use sentence-level rather than paragraph-level profile segmentation (ablation)Codified Profiles · Fandom Benchmark role-playingNLI scoreMixed
Add targeted reasoning to codified profiles (ablation)Codified Profile · Fandom Benchmark role-playingNLI scoreHelped

Surprising findings

Limitations

Experimental setup

Datasets: Fandom character profiles and storyline summaries (Haruhi, K-On!, JOJO, FMA, AGOT, ATLA)

Benchmarks: Fandom Benchmark (83 characters, 5,141 scenes)

Metrics: NLI score (entailed=100, neutral=50, contradicted=0) Best@K win rate forward pass count codification precision/recall

Baselines: Vanilla (No Profile) Original Textual Profile Codified RAG Chain-of-thought with textual profile

Builds on: chain-of-thought retrieval-augmented generation natural language inference evaluation

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy