Ontologically Faithful Generation of Non-Player Character Dialogues (2024)

Abstract: We introduce a language generation dataset grounded in a popular video game. KNUDGE (**KN**owledge Constrained **U**ser-NPC **D**ialogue **GE**neration) requires models to produce trees of dialogue between video game characters that accurately reflect quest and entity specifications stated in natural language. KNUDGE is constructed from side quest dialogues drawn directly from game data of Obsidian Entertainment’s _The Outer Worlds_, leading to real-world complexities in generation: (1) utterances must remain faithful to the game lore, including character personas and backstories; (2) a dialogue must accurately reveal new quest details to the human player; and (3) dialogues are large trees as opposed to linear chains of utterances. We report results for a set of neural generation models using supervised and in-context learning techniques; we find competent performance but room for future work addressing the challenges of creating realistic, game-quality dialogues.

## introduction player interactions with non-player characters (npcs) in role-playing games (rpgs) often serve to flesh out backstories while allowing the player to progress through engaging quest storylines @xcite . figure 1 shows a dialogue turn, taken from the outer worlds (obsidian entertainment, 2019), 1 an rpg known for its writing. a key challenge in creating npc dialogues is that they should serve coherent narratives: utterances must faithfully reflect quest structure and game lore-characters, histories, and entity relationships. dialogues are often purposely designed to start/end quests according to granular specifications (e.g. if player says option a then it starts quest b; if player says option c, then the **data and code available at https://github.com/ nweir127/knudge . however, there is a lack of realistic benchmarks to train and evaluate models for this purpose. van @xcite highlight that game text corpora should come from real, professionally written games; most research that explores game dialogue relies on crowdsourced or academicallycurated text, which is not representative of the highly game-and context-sensitive text of real dialogues. moreover, related work on game dialogue @xcite , story generation @xcite , and knowledge conditioning for dialogue agents @xcite @xcite does not address complex dialogue trees and interweaving narratives found in deployed rpgs. to address this dearth of realistic benchmarks for game dialogue authoring, we introduce knudge: knowledge constrained user-npc dialogue generation, a set of dialogue trees (in english) extracted from the outer worlds, an existing video game, and paired with granular ontological constraints. knudge contains 159 dialogues from all 45 side quests in the outer worlds. it contains 4.7k utterances and 1.3k input constraint tokens per tree. we annotate each turn in the dialogues with relevant grounding information: quest-and lore-related natural language (nl) support facts pulled from fan-written wikis. such fine-grained support fact annotations are useful for training models to generate game dialogues grounded in quest specifications and game lore. to our knowledge, ours is the first dataset that consists of a set of real game-quality npc dialogues paired with granular quest and biographical specifications consistent with a well-formed game ontology. using knudge as a test bed, we pose the task of knowledge-constrained npc dialogue generation (figure 2 ). the complex input specifications and limited training data target a realistic development scenario where a designer works on a new, partially written game. for this task, we introduce an llmbased model class, termed dialoguewriters, that generates dialogue trees given input constraints. to address the challenges of long specification passages and branching tree structures, we introduce techniques for prompt construction and tree structure representation. to encourage using the ontology to produce engaging dialogue, we explore mechanisms to select relevant knowledge, leveraging the rich node-level annotations of knudge. we prescribe testing protocols for knudge that measure faithfulness to game ontology constraints and realism of the dialogue. we conduct automatic and human evaluations of utterances and trees generated from specifications for game quests, as well as for never-before-seen quests written by a professional game designer. our experiments reveal further room for improvement in aspects such as ontology usage and maintaining coherence. ## task definition as communities seek to develop ai-based writing tools such as ubisoft's ghostwriter @xcite , there arises a need to reconcile the challenge of dialogue authoring with current nlg techniques. an ideal writing tool might allow a designer to provide inputs like granular quest information and bios from a game's lore and receive a set of generated utterances or entire trees to aid in drafting content, similar to github copilot. as a game ontology can be large, so too might the amount of user-provided knowledge specifications. our task targets this scenario, for which no dataset exists. we define the task of knowledge-constrained npc dialogue generation as the mapping from a set of quest constraint statements q, biographical constraint statements b, and participant names p to a dialogue tree d. we consider two task scenarios: next utterance prediction from a partial tree, and full dialogue generation of branching trees. depicted in figure 2 (upper), q contains statements [q 1 , . . . , q m ] about active objectives upon entering the dialogue, about what should occur dur-ing it (e.g., pieces of information the npc should mention), and about new active objectives upon leaving it. b comprises background statements [b 1 , . . . , b n ] about game entities that the dialogue must reflect (figure 2 , middle). the participant list p contains the player character and one or more npcs with corresponding facts in b. we designed these inputs to reflect the specifications that a developer would provide to the generator during their quest writing process. dialogue d is a directed graph ⟨n, e⟩; each utterance node @xmath0. branches occur due to the multiple dialogue options for players. which of the pre-written options the player chooses can have major effects on the outcome of the interaction. for example, the dialogue whose start is depicted in figure 1 gives the player the option either to ask follow-up questions about the npc's missing son or to refuse her request to help find him and end the interaction immediately. the full structure of this interaction's dialogue tree is shown in figure 3 ; d can have multiple exit nodes and can contain cycles. to simulate a realistic writing scenario, we provide models with a small set of training dialogues from the particular game domain, some (q 1 , b 1 , p 1 , d 1 ), . . . (q t , b t , p t , d t ), t≈100. 2 while this is not enough to perform sgdbased fine-tuning, models such as those described in §4 can leverage it for in-context learning. ## knudge dataset writing rpg-quality dialogue trees is difficult for human developers for its many interweaving considerations. 1) the tree must serve its quest function, containing input-specified player utterance options, npc responses (e.g. specified emotions), and facts the player must learn by the end (e.g. the log entry in figure 2 ). 2) the utterances must be coherent and engaging to the player. 3) the npc should embody the persona described in their bio passage explaining personality, history, and relationships. 4) to facilitate world building, the npc should exposit details about other entities whenever contextually relevant, but should never violate the ontology through contradiction. with these desiderata in mind, we design knudge to pose a 2 this reflects a realistic writing scenario, in which a designer has written a partial ontology for a brand-new game with only a handful of full dialogues at their disposal. little to no media-text, image, or otherwise-about the game is available for models during private development by a company. multi-faceted challenge to generation models. knudge contains dialogue trees from all 45 side quests in the outer worlds. this rpg is appealing for our investigation because of its large trees, its writing, and its tendency for entities to re-appear in many quests. construction of knudge entails gathering details for each quest (q) and each entity referenced during its dialogues (b) ( §3.1), then extracting trees (d) from the game data ( §3.2). ## dialoguewriter methods we introduce a set of methods called dialoguewriters for generating candidate utterances given the ontological specifications (q, b, and p ) from §2 and a partial subtree s for a dialogue in knudge. ## experiments we split knudge into train, development, and test splits based on quests (60/10/30%). test set b's contain a combination of seen and unseen entities. baselines to measure the effect of node-level knowledge selection (ks), we compare against an icl model that selects only one statement instead of many, and an oracle ks icl model, which selects the gold knowledge annotations for reference utterances. we maximize the number of in-context examples for all icl ablations; e.g. the no knowledge model's prompt can have dozens of examples that are quite short. these ablations thus explore the trade-off between the number of in-context examples and the presence of ontological statements. to measure the effect of ks, we compare against sl and icl no ks models. to measure the effect of conditioning on q and b, we compare against ablations to the non-ks icl model: a no knowledge model that conditions only on the participants p and utterance history h, and a quest only model that conditions on p , h, and q, but not b. ## related work while older work using nlg for game applications relied on templates and rule-based systems @xcite @xcite , much of recent work has focused on using machine learning models @xcite . past work on game dialogue has generally not been concern with the notion of grounding knowledge or quest objectives to be covered in the generated dialog. si et al. (2021) focus on the task of story continuation through dialogue between characters while modeling the inter-character relations. van stegeren and theune (2020) propose three sources for building npc dialogue corpora. their proposed datasets do not contain any ground-history: > agnes needham: please, you have to help me get my little tucker back! he ran away and is going to get himself killed! oh, i just know a raptidon is melting him with acid as we speak! > player: your child is missing? where'd you last see him? > agnes needham: oh, i just knew you were a good person. 'agnes,' i said, 'this is the man to save your little tuckie!' and i was right! gold: agnes needham: he ran out into the wilderness a few days ago. i warned him about the raptidons, mantisaurs, and marauders -the toxic sulfur pools, and poisonous plants. but he didn't listen! icl-ks: agnes needham: he was always such a good boy, but lately he's been acting so strange. i just don't understand why he would want to leave stellar bay. it's the only place he's ever known. icl: agnes needham: he left a few weeks ago. said he was going to amber heights to join some revolutionary group. i just know he's going to get himself killed if he's not careful! icl-quest only: agnes needham: he left a few weeks ago, headed for amber heights. he's going to get himself killed, i just know it! icl-no knowledge: agnes needham: he was playing in the street. but then he saw a sweet little kitty and chased it into the sewers! oh, the horror! sl-ks: agnes needham: if you're willing to pay handsomely, i'll even pay you handsomely if you convince him to return to me. sl: player: i'll do everything i can. history: > agnes needham: please! won't you go and find my boy? > why would tucker run away? gold: agnes needham: he's been pining for an adventure, says he's tired of living cooped up behind the walls. but he doesn't understand how dangerous it is out there. icl-ks: agnes needham: i just wanted to keep him safe! it's not like he could experience life cooped up in stellar bay his whole life. but the second he steps outside the walls, he's in danger! icl: agnes needham: oh, he's just like his father. always running off and getting into trouble. i just worry about him so much. i know he's a grown man, but he's still my little boy. icl-quest only: agnes needham: you know how teenage boys are. they just do things without thinking. they don't realize how much their mothers worry about them. icl-no knowledge: agnes needham: i just don't know. he's been acting strange lately. ever since that little girl went missing. sl-ks: agnes needham: because he was scared, and i couldn't let him get away with it! sl: agnes needham: because he's scared of the things he'll find out there! and i'm scared he'll get eaten by some vile creature! history: > graham bryant: or... now, here's an idea. there's an old printing press i've been trying to get up and running. > player: ...why? gold: graham bryant: i have always dreamed of subverting the colony's periodicals and turning the board's own propaganda against them. icl-ks: graham bryant: i want to use it to print our message. to spread the word of the iconoclasts to the people of halcyon. icl: graham bryant: the printed word is a powerful tool, captain. one that can be used to enlighten the masses and bring them into the light of the eternal truth. icl-quest only: graham bryant: to spread our message. help it take root in the colony. i've had a request for replacement rollers, but they haven't arrived yet. icl-no knowledge: graham bryant: ah. to spread the word, of course. sl-ks: graham bryant: because the van noys sent me. they didn't want to pay me until i got the press running again. sl: graham bryant: well, the eternal has a different plan. it's called the philosophist plan. figure 6: [best viewed in color] example generations by the in-context learning (icl) dialoguewriter and supervised learning (sl) dialoguewriter. models that condition on both biographical and quest passages are more likely to mention relevant quest information while also referencing game entities and their backgrounds without creating inconsistency, incoherence, or incongruity. see §c and §d for full documentation of quests and entities referenced. ing annotation and are not accompanied by explicit descriptions of entities and characters. callison-burch et al. (2022) explore automatic generation of conversational turns by players of the tabletop rpg, dungeons and dragons, in which npcs serve a very different role in the gameplay. scheherazade's tavern (aljammaz et al., 2020) augments a patternmatching-based npc interaction system with facts the character knows about the game world. more broadly, past work has nlg in various tasks such as quest description generation (van stegeren and mysliwiec, 2021), dialogue generation (si et al., 2021), persona-specific agents in text environments (urbanek et al., 2019b), and new text world generation @xcite . past work has pursued dialogue systems that steer the conversation towards a topic @xcite or an nl sentence @xcite . other work in nlg has explored generating outputs with high-level nl specifications such as item agendas @xcite , sets of facts (orbach and goldberg, 2020), or author goals @xcite . knudge comprises nl specifications that are comparably richer. ## conclusion when dialogue is used to advance a carefully crafted storyline in a video game, it should be both engaging and consistent with the larger narrative. language models are capable of producing engaging dialogue, but to date, research on ensuring dialogue's consistency with underlying knowledge specifications has not used actual highquality game data. this paper introduces knudge, a dataset of real npc dialogue trees drawn from the game, the outer worlds, thereby exemplifying real-world complexities in dialogue authoring. we pose a knowledge-grounded generation task that mirrors a realistic development scenario with limited training data over a complex ontology of quests and lore. we find that lm-based methods are able to generate fluent dialogue that relates to specifications, but they do not match the quality of professional writers, particularly in terms of coherence and use of the game lore. we hope that knudge drives the development of new techniques for faithful game dialogue generation.