将角色扮演中的角色逻辑编纂成法典
Codifying Character Logic in Role-Playing
AI总结:
本文提出 Codified Profiles,用结构化可执行函数显式编码角色决策逻辑,并基于 83 个角色、5,141 个场景的基准验证其持久性、可更新性与可控随机性。
摘要:
本文介绍了用于角色扮演的 Codified Profiles(编纂式角色档案),这是一种将角色逻辑表示为用于行为决策的结构化、可执行函数的新颖方法。每个档案定义了一组函数 parse_by_scene(scene),该函数输出一系列基于逻辑的断言 triggered_statements,同时使用显式控制结构(例如 if-then-else)和 check_condition(scene, question) 等条件检查,其中每个 question 都是关于场景的语义有意义的提示(例如,“角色是否处于危险之中?”),由扮演角色的 LLM 判定为真、假或未知。与将角色描述直接附加到文本提示中的传统基于提示的档案相比,这种显式表示具有三个关键优势:(1)持久性,通过强制完整且一致地执行角色逻辑,而不是依赖模型的隐式推理;(2)可更新性,通过对行为逻辑进行系统性检查和修订,而这在仅使用提示的方法中难以追踪或调试;(3)可控随机性,通过在逻辑内直接支持随机行为,实现仅凭提示难以达到的细粒度可变性。为验证这些优势,我们引入了一个新基准,该基准由从 Fandom 中精选的 83 个角色和 5,141 个场景构建而成,使用基于 NLI 的评分来比较角色响应与真实动作。我们的实验证明了编纂式档案在提升持久性、可更新性和行为多样性方面的显著收益。值得注意的是,通过将很大一部分推理卸载到预处理阶段,编纂式档案甚至使具有 1B 参数的模型也能进行高质量角色扮演,为本地部署角色扮演智能体提供了可扩展且高效的基础。
英文摘要:
This paper introduces Codified Profiles for role-playing, a novel approach that represents character logic as structured, executable functions for behavioral decision-making. Each profile defines a set of functions parse_by_scene(scene) that outputs a list of logic-grounded assertions triggered_statements, using both explicit control structures (e.g., if-then-else) and condition checks like check_condition(scene, question), where each question is a semantically meaningful prompt about the scene (e.g., "Is the character in danger?") discriminated by the role-playing LLM as true, false, or unknown. This explicit representation offers three key advantages over traditional prompt-based profiles, which append character descriptions directly into text prompts: (1) Persistence, by enforcing complete and consistent execution of character logic, rather than relying on the model's implicit reasoning; (2) Updatability, through systematic inspection and revision of behavioral logic, which is difficult to track or debug in prompt-only approaches; (3) Controllable Randomness, by supporting stochastic behavior directly within the logic, enabling fine-grained variability that prompting alone struggles to achieve. To validate these advantages, we introduce a new benchmark constructed from 83 characters and 5,141 scenes curated from Fandom, using NLI-based scoring to compare character responses against ground-truth actions. Our experiments demonstrate the significant benefits of codified profiles in improving persistence, updatability, and behavioral diversity. Notably, by offloading a significant portion of reasoning to preprocessing, codified profiles enable even 1B-parameter models to perform high-quality role-playing, providing a scalable and efficient foundation for local deployment of role-play agents.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。