mlsanityData to 7 Oct 2026

Think Anywhere in Code Generation

arXiv 2603.29957 ↗First posted 31 Mar 2026cs.SE cs.LGcited by 1

On the map: LLM reasoning → Reasoning for agents, planning and code

Abstract (arXiv)

Recent advances in reasoning Large Language Models (LLMs) have primarily relied on upfront thinking, where reasoning occurs before final answer. However, this approach suffers from critical limitations in code generation, where upfront thinking is often insufficient as problems' full complexity only reveals itself during code implementation. Moreover, it cannot adaptively allocate reasoning effort throughout the code generation process where difficulty varies significantly. In this paper, we propose Think-Anywhere, a novel reasoning mechanism that enables LLMs to invoke thinking on-demand at any token position during code generation. We achieve Think-Anywhere by first teaching LLMs to imitate the reasoning patterns through cold-start training, then leveraging outcome-based RL rewards to drive the model's autonomous exploration of when and where to invoke reasoning. Extensive experiments on four mainstream code generation benchmarks (i.e., LeetCode, LiveCodeBench, HumanEval, and MBPP) show that Think-Anywhere achieves state-of-the-art performance over both existing reasoning methods and recent post-training approaches, while demonstrating consistent generalization across diverse LLMs. Our analysis further reveals that Think-Anywhere enables the model to adaptively invoke reasoning at high-entropy positions, providing enhanced interpretability.

Key facts. Cited by 1 paper in the map (data through 7 Oct 2026). Placed in Reasoning for agents, planning and code, one of 17 directions in LLM reasoning. Builds on 16 of its 45 references that are in the map. First posted on arXiv 31 Mar 2026.

Builds on

16 of 45 references.

Closest ancestors · 5

Same direction, newest first

  1. 2025CodeReasoner: Enhancing the Code Reasoning Ability with Reinforcement Learning23 Jul
  2. 2025LeetCodeDataset: A Temporal Dataset for Robust Evaluation and Efficient Training of Code LLMs20 Apr
  3. 2025OpenCodeReasoning: Advancing Data Distillation for Competitive Coding2 Apr
  4. 2024Qwen2.5-Coder Technical Report18 Sep
  5. 2024LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Code12 Mar

Other references · 11

  1. 2017Proximal Policy Optimization Algorithmscited by 14,441
  2. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  3. 2025Gemini 2.5: Pushing the Frontier with Advanced Reasoning, Multimodality, Long Context, and Next Generation Agentic Capabilitiescited by 3,655
  4. 2023Code Llama: Open Foundation Models for Codecited by 2,105
  5. 2024HybridFlow: A Flexible and Efficient RLHF Frameworkcited by 1,980
  6. 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,154
  7. 2024StarCoder 2 and The Stack v2: The Next Generationcited by 484
  8. 2025Skywork Open Reasoner 1 Technical Reportcited by 161
  9. 2025Thinking-while-Generating: Interleaving Textual Reasoning throughout Visual Generationcited by 17
  10. 2025CodeBoost: Boosting Code LLMs by Squeezing Knowledge from Code Snippets with RLcited by 7
  11. 2025Plantain: Plan-Answer Interleaved Reasoningcited by 5

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2026: 1.

1 paper.

Similar, not cited

Close in wording, no citation either way

  1. 2025An Empirical Study of Reasoning Steps in Thinking Code LLMs
  2. 2023Think Outside the Code: Brainstorming Boosts Large Language Models in Code Generation
  3. 2024Enhancing Code Generation Performance of Smaller Models by Distilling the Reasoning Ability of LLMs
  4. 2025Understanding Chain-of-Thought Effectiveness in Code Generation: An Empirical and Information-Theoretic Analysis
  5. 2025Reasoning as a Resource: Optimizing Fast and Slow Thinking in Code Generation Models
  6. 2025Code to Think, Think to Code: A Survey on Code-Enhanced Reasoning and Reasoning-Driven Code Intelligence in LLMs
  7. 2025The Valley of Code Reasoning: Scaling Knowledge Distillation of Large Language Models
  8. 2024What Makes Large Language Models Reason in (Multi-Turn) Code Generation?