Saved in:
Bibliographic Details
Main Authors: Li, Shen, Huang, Li, Zhan, Shaoxiong, Sun, Weifeng, Yin, Tao, Liu, Zhongxin, Yan, Meng
Format: Preprint
Published: 2025
Subjects:
Online Access:https://arxiv.org/abs/2512.14048
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866912767699582976
author Li, Shen
Huang, Li
Zhan, Shaoxiong
Sun, Weifeng
Yin, Tao
Liu, Zhongxin
Yan, Meng
author_facet Li, Shen
Huang, Li
Zhan, Shaoxiong
Sun, Weifeng
Yin, Tao
Liu, Zhongxin
Yan, Meng
contents Large language models (LLMs) exhibit strong generative capabilities and have shown great potential in code generation. Existing chain-of-thought (CoT) prompting methods enhance model reasoning by eliciting intermediate steps, but suffer from two major limitations: First, their uniform application tends to induce overthinking on simple tasks. Second, they lack intention abstraction in code generation, such as explicitly modeling core algorithmic design and efficiency, leading models to focus on surface-level structures while neglecting the global problem objective. Inspired by the cognitive economy principle of engaging structured reasoning only when necessary to conserve cognitive resources, we propose RoutingGen, a novel difficulty-aware routing framework that dynamically adapts prompting strategies for code generation. For simple tasks, it adopts few-shot prompting; for more complex ones, it invokes a structured reasoning strategy, termed Intention Chain-of-Thought (ICoT), which we introduce to guide the model in capturing task intention, such as the core algorithmic logic and its time complexity. Experiments across three models and six standard code generation benchmarks show that RoutingGen achieves state-of-the-art performance in most settings, while reducing total token usage by 46.37% on average across settings. Furthermore, ICoT outperforms six existing prompting baselines on challenging benchmarks.
format Preprint
id arxiv_https___arxiv_org_abs_2512_14048
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Intention Chain-of-Thought Prompting with Dynamic Routing for Code Generation
Li, Shen
Huang, Li
Zhan, Shaoxiong
Sun, Weifeng
Yin, Tao
Liu, Zhongxin
Yan, Meng
Artificial Intelligence
Large language models (LLMs) exhibit strong generative capabilities and have shown great potential in code generation. Existing chain-of-thought (CoT) prompting methods enhance model reasoning by eliciting intermediate steps, but suffer from two major limitations: First, their uniform application tends to induce overthinking on simple tasks. Second, they lack intention abstraction in code generation, such as explicitly modeling core algorithmic design and efficiency, leading models to focus on surface-level structures while neglecting the global problem objective. Inspired by the cognitive economy principle of engaging structured reasoning only when necessary to conserve cognitive resources, we propose RoutingGen, a novel difficulty-aware routing framework that dynamically adapts prompting strategies for code generation. For simple tasks, it adopts few-shot prompting; for more complex ones, it invokes a structured reasoning strategy, termed Intention Chain-of-Thought (ICoT), which we introduce to guide the model in capturing task intention, such as the core algorithmic logic and its time complexity. Experiments across three models and six standard code generation benchmarks show that RoutingGen achieves state-of-the-art performance in most settings, while reducing total token usage by 46.37% on average across settings. Furthermore, ICoT outperforms six existing prompting baselines on challenging benchmarks.
title Intention Chain-of-Thought Prompting with Dynamic Routing for Code Generation
topic Artificial Intelligence
url https://arxiv.org/abs/2512.14048