[Paper Review] Enhancing Code Generation Performance of Smaller Models by Distilling the Reasoning Ability of LLMs
The paper introduces CodePLAN, a multi-task distillation framework that teaches smaller code generation models to generate and use high-quality solution plans distilled from LLMs, significantly boosting pass@1 on APPS by over 130%.
Large Language Models (LLMs) have recently made significant advances in code generation through the 'Chain-of-Thought' prompting technique. This technique empowers the model to autonomously devise "solution plans" to tackle intricate programming challenges, thereby improving its performance in code generation. Nevertheless, smaller models have been struggling to keep up with LLMs in deducing these plans, adversely affecting their code generation capabilities. Given the considerable size and associated deployment costs, along with concerns about data security, many teams opt for deploying smaller models for code generation. Consequently, there arises a compelling need for transferring LLMs' code generation reasoning abilities to the smaller models. In this paper, we propose the CodePLAN framework, which aims to transfer LLMs' reasoning capabilities to smaller models through distillation. We adopt a multi-task learning approach, jointly undertaking code generation and solution plan generation tasks, to enhance the code generation capabilities of the smaller model. To ensure the superior quality of the solution plans, we advocate for the utilization of backward reasoning and plan sampling strategies. Our experiments show that in comparison to the conventional fine-tuning approach, our approach improves the smaller model's code generation performance (measured in pass@1 metric) by over 130% on the challenging APPS benchmark.
Motivation & Objective
- Motivate enabling smaller models to achieve LLM-like code generation performance without deployment costs or data-security concerns.
- Develop a multi-task framework that jointly trains code generation and plan generation by distilling LLM reasoning.
- Enhance plan quality through backward reasoning and plan sampling to guide training and inference.
- Investigate how plan quality and sampling affect downstream code generation performance.
Proposed method
- Propose CodePLAN: a multi-task framework where the base model learns to both generate code and generate solution plans.
- Use LLMs as teachers to provide high-quality solution plans, training with a combined loss that optimizes both code generation and plan generation (L = (1-λ)L_code + λL_plan, with λ=0.5).
- Introduce backward reasoning to extract programmer-like solution plans from actual solutions, improving plan quality over forward problem-description-based planning.
- During inference, apply plan sampling to generate multiple candidate plans, evaluate them via unit tests, and select the best plan to guide code generation.
- Augment the base model with a plan head to output plans, enabling alternating multi-task fine-tuning between code and plan tasks.
- Evaluate on APPS and MBPP datasets using pass@k metrics and compare against standard fine-tuning, CoT, and RL-based baselines.
Experimental results
Research questions
- RQ1Can distilling LLMs’ solution plans into a smaller model improve its code generation performance?
- RQ2Does backward reasoning from solutions yield higher-quality planning signals than forward planning from problem descriptions?
- RQ3How does plan sampling during inference affect the quality and reliability of generated code?
- RQ4What is the relative improvement of CodePLAN over standard fine-tuning across different datasets and problem difficulties?
Key findings
- CodePLAN improves smaller-model code generation performance (pass@1 on APPS) by over 130% compared to standard fine-tuning.
- Plan-focused distillation yields consistent gains over standard finetuning and CoT-based approaches on APPS and MBPP.
- Backward reasoning produces higher-quality plans than plans derived directly from problem descriptions, enhancing downstream code quality.
- Plan sampling (testing multiple plans with unit tests) significantly boosts code correctness, with benefits increasing as sampling grows beyond N=1.
- CodePLAN is complementary to ranking-based post-processing (CodeRanker), yielding large combined gains in code correctness.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.