Introduction
The "Plan-then-Code" paradigm has emerged as the gold standard for complex code generation. By prompting a model to first generate a natural language plan before implementing the code, this approach breaks down complex reasoning into explicit, interpretable steps. However, this paradigm introduces a significant challenge: it creates a massive context window.
For small-scale Large Language Models (LLMs) with fewer than 8 billion parameters, this expanded context leads to a critical bottleneck known as Attention Allocation Imbalance. This imbalance manifests in two primary ways:
- Attention Dispersion: The model's limited "attention budget" is spread too thin across irrelevant tokens, causing it to overlook critical constraints within the prompt or plan.
- Attention Drift: As the model generates more code, it increasingly attends to its own recently generated tokens, effectively "forgetting" the original plan it was supposed to follow.
To address this, researchers introduce PADA (Perturbation-Verified Attention Distillation and Dynamic Alignment), a framework designed to help small models maintain focus and strictly follow complex reasoning plans.
The PADA Framework
PADA tackles attention imbalance through a sophisticated three-step methodology:
1. Attention Extraction & Perturbation Verification
Standard distillation often forces a "student" (small model) to blindly mimic a "teacher" (large model), which can introduce the teacher's idiosyncratic noise—a phenomenon known as Teacher Imitation Bias. PADA avoids this by extracting attention matrices from both models and applying Perturbation Analysis. By masking specific tokens in the plan and measuring the resulting change in Perplexity ($\Delta PPL$), the system verifies "Key Tokens." If masking a token causes a massive spike in uncertainty, it is confirmed as essential.
2. Distillation Information Density (DID)
Researchers discovered an "Inverted U-shape" relationship in attention distillation: more information isn't always better. Distilling too little leaves the model without context, while distilling too much causes "Attention Dilution." PADA mathematically models an optimal density for attention targets, focusing only on a semantically dense set of key tokens (roughly 4-6% of the context) to prevent overwhelming the student model.
3. Dynamic Attention Alignment
During training, PADA employs two dynamic mechanisms to keep the model on track:
- Progress-Aware Sliding Window: Rather than looking at the entire plan simultaneously, the model only attends to the current and two previous plan steps. This keeps the model's focus synchronized with the specific code being written.
- Difficulty-Aware Gating: A gating mechanism adjusts the intensity of attention guidance based on the structural complexity of the code (measured via Abstract Syntax Tree depth) and model perplexity. Simple code receives lighter guidance, while complex logic receives stronger alignment.
Experimental Setup
The researchers fine-tuned models using 4,000 samples from the APPS training set. To rigorously test the framework, evaluation was conducted across seven major benchmarks, including APPS (Introductory, Interview, and Computational tiers), HumanEval, MBPP, MBPP+, and LiveCodeBench v5. LiveCodeBench v5 was specifically chosen to prevent data contamination, as its problems post-date the training cutoff of the base models.
Key Results and Insights
The implementation of PADA yielded striking improvements, proving that the performance gap between small and ultra-large models is often a matter of focus rather than raw capability.
- Accuracy Boost: PADA improved Pass@1 scores by up to 16.7% across various experimental settings.
- Rivaling the Giants: Remarkably, PADA-Qwen3 (a 4B parameter model) achieved an average score of 77.8% across benchmarks. This outperformed massive frontier models like Gemini-2.5-pro (73.8%) and DeepSeek-v3.2 (68.7%).
- High Efficiency: Compared to agentic methods like LPW (which rely on iterative reflection), PADA is vastly more token-efficient. On the APPS benchmark, PADA achieved higher accuracy while using 3.6x fewer tokens.
- Cross-Domain Generalization: While explicitly designed for code generation, PADA also demonstrated significant improvements on mathematical reasoning tasks (GSM8K and MATH-500). This suggests that Attention Allocation Imbalance is a generalized hurdle in sequential reasoning tasks.
Limitations and Future Work
While highly effective, PADA operates as a "plan-following" enhancer. Its primary limitation is its dependency on plan quality: if the model generates a logically flawed initial plan, PADA will simply help the model execute that bad plan more accurately. Additionally, current evaluations are heavily focused on Python. Different programming languages (like C++ or Rust) possess distinct syntactic constraints that may require retuning the Distillation Information Density parameters.
Future work will explore "Joint Distillation," a paradigm where the model simultaneously learns to improve its underlying planning logic alongside its plan-following attention mechanisms.
Reference: Huang, Y., et al. (2026). PADA-Coder: Improving Plan-Following Code Generation via Perturbation-Verified Attention Distillation and Dynamic Alignment. Proceedings of the 43rd International Conference on Machine Learning (ICML).
Summary updated