StoryCoder: Narrative Reformulation for Structured Reasoning in LLM Code Generation

Geonhui Jang, Dongyoon Han, YoungJoon Yoo


Abstract
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.
Anthology ID:
2026.acl-long.872
Volume:
Proceedings of the 64th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)
Month:
July
Year:
2026
Address:
San Diego, California, United States
Editors:
Maria Liakata, Viviane P. Moreira, Jiajun Zhang, David Jurgens
Venue:
ACL
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
19092–19112
Language:
URL:
https://aclanthology.org/2026.acl-long.872/
DOI:
10.18653/v1/2026.acl-long.872
Bibkey:
Cite (ACL):
Geonhui Jang, Dongyoon Han, and YoungJoon Yoo. 2026. StoryCoder: Narrative Reformulation for Structured Reasoning in LLM Code Generation. In Proceedings of the 64th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 19092–19112, San Diego, California, United States. Association for Computational Linguistics.
Cite (Informal):
StoryCoder: Narrative Reformulation for Structured Reasoning in LLM Code Generation (Jang et al., ACL 2026)
Copy Citation:
PDF:
https://aclanthology.org/2026.acl-long.872.pdf
Checklist:
 2026.acl-long.872.checklist.pdf