StoryCoder: Narrative Reformulation for Structured Reasoning in LLM Code Generation

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Jang, Geonhui, Han, Dongyoon, Yoo, YoungJoon
Format: Preprint
Published: 2026
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866915940300488704
author Jang, Geonhui
Han, Dongyoon
Yoo, YoungJoon
author_facet Jang, Geonhui
Han, Dongyoon
Yoo, YoungJoon
contents Effective code generation requires both model capability and a problem representation that carefully structures how models reason and plan. Existing approaches augment reasoning steps or inject specific structure into how models think, but leave scattered problem conditions unchanged. Inspired by the way humans organize fragmented information into coherent explanations, we propose StoryCoder, a narrative reformulation framework that transforms code generation questions into coherent natural language narratives, providing richer contextual structure than simple rephrasings. Each narrative consists of three components: a task overview, constraints, and example test cases, guided by the selected algorithm and genre. Experiments across 11 models on HumanEval, LiveCodeBench, and CodeForces demonstrate consistent improvements, with an average gain of 18.7% in zero-shot pass@10. Beyond accuracy, our analyses reveal that narrative reformulation guides models toward correct algorithmic strategies, reduces implementation errors, and induces a more modular code structure. The analyses further show that these benefits depend on narrative coherence and genre alignment, suggesting that structured problem representation is important for code generation regardless of model scale or architecture. Our code is available at https://github.com/gu-ni/StoryCoder.
format Preprint
id arxiv_https___arxiv_org_abs_2604_14631
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle StoryCoder: Narrative Reformulation for Structured Reasoning in LLM Code Generation
Jang, Geonhui
Han, Dongyoon
Yoo, YoungJoon
Computation and Language
Artificial Intelligence
Effective code generation requires both model capability and a problem representation that carefully structures how models reason and plan. Existing approaches augment reasoning steps or inject specific structure into how models think, but leave scattered problem conditions unchanged. Inspired by the way humans organize fragmented information into coherent explanations, we propose StoryCoder, a narrative reformulation framework that transforms code generation questions into coherent natural language narratives, providing richer contextual structure than simple rephrasings. Each narrative consists of three components: a task overview, constraints, and example test cases, guided by the selected algorithm and genre. Experiments across 11 models on HumanEval, LiveCodeBench, and CodeForces demonstrate consistent improvements, with an average gain of 18.7% in zero-shot pass@10. Beyond accuracy, our analyses reveal that narrative reformulation guides models toward correct algorithmic strategies, reduces implementation errors, and induces a more modular code structure. The analyses further show that these benefits depend on narrative coherence and genre alignment, suggesting that structured problem representation is important for code generation regardless of model scale or architecture. Our code is available at https://github.com/gu-ni/StoryCoder.
title StoryCoder: Narrative Reformulation for Structured Reasoning in LLM Code Generation
topic Computation and Language
Artificial Intelligence
url https://arxiv.org/abs/2604.14631