Introduction
CoRRPUS (Code Representations to Reason & Prompt over for Understanding in Stories) is a neurosymbolic framework designed to enhance story understanding in Large Language Models (LLMs). By representing story states as executable-like Python code, CoRRPUS enables models to track state changes with high precision. This approach bridges the gap between the fluent text generation of LLMs (System 1) and the rigorous logical tracking of symbolic AI (System 2), achieving near-perfect accuracy on complex reasoning tasks where standard models often fail.
The Challenge of Logical Consistency
While LLMs excel at generating fluent, contextually relevant text, they frequently struggle with long-term coherence. In narrative contexts, models often "lose the plot," forgetting character locations or object ownership over time. Traditional symbolic AI can handle these states but requires labor-intensive manual encoding. CoRRPUS addresses this by using Code-LLMs (such as OpenAI’s Codex) to automatically bootstrap symbolic world models from natural language, providing a structured "source of truth" for reasoning.
Methodology: Code-based Structured Prompting
The core innovation of CoRRPUS is the translation of natural language stories into Python class updates. Instead of direct natural language querying, the model is prompted to "write" the story's state changes. The researchers explored three primary prompting strategies:
- Comment Only: Story sentences are treated as code comments, followed by simple attribute assignments (e.g.,
self.Sandra.location = "bedroom"). - Specific Functions: The model generates a unique function for every sentence in the story (e.g.,
def Sandra_journeyed_to_the_bedroom(self): ...). - Abstract Functions: The model is provided with a predefined API (e.g.,
go(character, location)) and must map story events to these general functions.
By forcing the model to translate "Sandra went to the garden" into a state change in a World class, the system maintains a consistent state that can be queried programmatically.
Experimental Setup and Datasets
The framework was evaluated on two distinct benchmarks:
- bAbI Task 2: A reasoning dataset focused on tracking characters and objects across various locations (e.g., "Where is the milk?").
- Re3: A complex dataset involving long-form stories where the model must detect character-based contradictions, such as a character's physical attributes changing midway through the narrative.
Results and Key Insights
CoRRPUS demonstrated significant improvements over baseline methods:
- Reasoning Accuracy: On bAbI Task 2, the "Abstract Functions" method achieved 99.1% accuracy with 1-shot prompting. In contrast, vanilla GPT-3 and Chain-of-Thought (CoT) prompting scored 56.5% and ~46%, respectively.
- Inconsistency Detection: On the Re3 dataset, CoRRPUS (Specific Functions) achieved an ROC-AUC of 0.79, significantly outperforming the previous state-of-the-art "Structured-Detect" method (0.684).
- Code as a Reasoning Intermediate: The success of CoRRPUS suggests that code is a superior intermediate representation for reasoning because it is less ambiguous than natural language and follows strict logical rules. Furthermore, Code-LLMs appear to be inherently better reasoners due to their training on structured data and state transitions.
Limitations and Future Work
Despite its success, CoRRPUS currently requires users to define which attributes to track (e.g., location, inventory). Future iterations could aim for autonomous salience mapping to identify important details in complex narratives. Additionally, while the system performs exceptionally on simple English sentences, its scalability to metaphorical or linguistically dense literature remains an open question.
Summary updated