Papers
Topics
Authors
Recent
Search
2000 character limit reached

CCCS: Curriculum for Code Completion

Updated 1 March 2026
  • The paper introduces CCCS as a framework that decomposes code completion into graded subtasks, enabling models to learn progressively from simple to complex challenges.
  • It leverages AST analysis and reinforcement learning techniques to quantify task difficulty and mitigate sparse reward issues in code synthesis.
  • Evaluations demonstrate that CCCS improves benchmarks like Pass@1 and exact match, with gains up to 80% in controlled settings and reduced training episodes.

A Curriculum of Code Completion Subtasks (CCCS) is a principled framework for decomposing code-completion and program synthesis problems into a progression of subtasks ordered by difficulty or complexity. CCCS systematically structures learning and evaluation to enhance the performance and efficiency of code completion models, particularly in the context of fill-in-the-middle (FIM) models and reinforcement learning (RL)-based code generation. The CCCS approach treats the code completion process not as a monolithic mapping, but as a staged curriculum in which models are exposed to increasingly complex and challenging infilling or generation scenarios, thereby improving both learning speed and ultimate capability.

1. Formalization and Taxonomy of Subtasks

In the context of FIM code completion, CCCS defines a hierarchy of nine distinct subtasks representing key AST node types or span patterns found in real-world code. These include: Random-Span Infilling (35%), Call-Expression Completions (12%), Full Function Definitions (12%), Class Definitions (10%), Function-Parameters (8%), Function-Definition with Prefix (8%), If-Statements (8%), Try-Catch Blocks (4%), and Assignments (3%) (Sagtani et al., 2024). Each subtask corresponds to a code transformation that is measured for complexity and error frequency.

For RL-based full-program generation, CCCS (as used in StepCoder) formalizes subtasks by splitting canonical solutions at semantically meaningful boundaries such as conditional statements. Given a reference example (x,y,u,e)(x, y, u, e)—with xx the problem, y={at}t=1Ty=\{a_t\}_{t=1}^T the canonical code, uu the unit tests, ee the locations of EE conditionals—the number of subtasks is set to K=EK = \lceil \sqrt{E} \rceil, and the subtasks are sequential completions from progressively shorter prefixes, ordered from easiest (least to complete) to hardest (complete from scratch) (Dou et al., 2024). This decomposition is algorithmically defined to distribute difficulty and leverage curriculum learning principles.

In the block-based domain, CCCS formalizes a progression of tasks ω=((S1,S1),...,(SK,SK))\omega = ((S_1, S_1^*), ..., (S_K, S_K^*)) such that each SkS_k is a subtask of the reference, with solution SkS_k^*, and the sequence ends with the full reference task and solution (Tercan et al., 2023). Subtasks are selected to minimize the maximum “jump” in complexity, measured as a weighted sum of AST depth and size, and subject to constraints on diversity and relevance.

2. Extraction and Quantification of Subtask Difficulty

The selection of subtasks is driven by quantifiable measures of complexity and real-world error rates. For text code, AST parsing (e.g., via Tree-Sitter) is used to extract candidate regions, with each node nn assigned a complexity C(n)C(n) equal to the count of distinct identifiers in its subtree. Node types are then ranked by their average C(n)C(n) and their observed Completion Acceptance Rate (CAR) in production, allowing prioritization of “hard” cases such as call expressions and if-statements (Sagtani et al., 2024).

In the RL curriculum, the partitioning is guided by the number and locations of key control-flow elements, with the stride Δ=E/K\Delta = \lceil E/K \rceil ensuring coverage and progressive expansion of the completion horizon. Each subtask is positioned so as to induce a gradual mastery from near-solution (few lines left) tasks to full-sequence generation (Dou et al., 2024). In the block-based setting, formal metrics such as FcomplexC(c)=κcdepth+csizeF^{\mathcal{C}}_{\mathrm{complex}}(c) = \kappa \cdot c_{\text{depth}} + c_{\text{size}} (with κ1\kappa \gg 1) are used to rank subtasks, and subsequences are chosen via dynamic programming to minimize progression complexity (Tercan et al., 2023).

3. Scheduling and Curriculum Delivery Mechanisms

Unlike traditional curricula, which advance from easy to hard, empirical results in FIM code completion suggest that mixing all difficulty levels at each epoch, with sampling weights αt\alpha_t proportional to subtask prevalence and difficulty, is optimal under low-latency constraints. The learning objective for fine-tuning becomes

L(θ)=tTαt(P,S,M,C)Dtlogpθ(MP,S,C)L(\theta) = - \sum_{t \in T} \alpha_t \sum_{(P, S, M, C) \in D_t} \log p_\theta(M \mid P, S, C)

where PP, SS, MM are FIM prefix, suffix, middle, and CC is retrieved context (Sagtani et al., 2024). A fixed FIM-rate and constant weights are maintained; no time-varying scheduler is used.

In RL settings, the curriculum is traversed in reverse: initial training focuses on the last (“easiest”) subtask, and on achieving a pass threshold, the starting point is moved backward, incrementally increasing the horizon (Dou et al., 2024). This “reverse curriculum generation” exploits denser, less sparse reward signals for short completions. Transitions between subtasks are hard resets; progression proceeds only forward, although extensions may consider stochastic or adaptive scheduling.

In block-based task progression, a synthesis pipeline iterates over possible grid orderings and code prefixes, with dynamic programming selecting subsequences that optimize the curriculum objective (Tercan et al., 2023). Quality criteria such as maximal total quality, minimal change to the reference, and diversity among subtasks act as tie-breakers.

4. Representative Datasets, Implementation, and Evaluation

CCCS in FIM code completion leverages fine-tuning sets derived from BigCode and targeted GitHub scraping, filtered for both linguistic coverage (e.g., under-represented languages such as React TS/JS) and structural diversity. Total data points are \approx200K, with distribution by subtask following observed error prevalence in production logs (Sagtani et al., 2024). Illustrative examples include call-expression infilling, if-statement completions, and multi-line function completions.

Backbones include DeepSeek-Coder (1B, 7B), StarCoder2 (3B, 7B), and DeepSeek-Coder-v2-lite (MoE), fine-tuned with LoRA adapters and hyperparameters tuned for real-time low-latency use (batch=16, LR=3×1043 \times 10^{-4}, tokens \leq16K, fim_rate=0.5).

Evaluation comprises both offline metrics (Exact Match for single-line, Prefix Match for benchmarks, Edit Similarity, Pass@1 for multi-line) and online metrics (CAR and CPR for completion acceptance and persistence under interactive conditions). Benchmarks span SantaCoder FIM, Amazon CCEval, and SWE-bench-derived multi-line infilling (Sagtani et al., 2024).

Ablation studies indicate that both curriculum and additional context retrieval provide additive improvements, with context alone often outperforming curriculum, but their combination (CMFT) yielding the best results, especially for small parameter models.

5. Theoretical Rationale and Learning Dynamics

CCCS addresses the exploration challenge in RL by transforming a sparse-reward, long-horizon MDP into a series of shorter-horizon subproblems where rewards are less delayed and state–goal proximity is higher. The probability of success for long sequences, modeled as i=1npi\prod_{i=1}^n p_i, decays exponentially in nn. By reducing effective nn (the number of contiguous “hard” code blocks), CCCS enables more efficient bootstrapping of per-block capabilities (Dou et al., 2024). This operationalizes reverse curriculum generation, as formalized in robotic learning and policy gradient literature.

Empirical analysis demonstrates that CCCS reduces the number of episodes necessary for target-level mastery by 30%\approx30\% over vanilla PPO and improves overall Pass@1, especially on harder subsets of the APPS+ benchmark (Dou et al., 2024). Similar superiority is demonstrated in supervised and RL training of neural program synthesizers on block-based environments, with CCCS yields of up to an 80% relative gain in exact match (Tercan et al., 2023).

6. Applications to Diverse Programming Domains

CCCS methods extend beyond text-based completion in mainstream languages to block-based visual programming environments, neuro-symbolic agents, and K-12 computing pedagogy (Tercan et al., 2023). The synthesis of progression of subtasks, leveraging AST analysis, execution traces, and symbolic grid modifications, enables neural program synthesizers to generalize more effectively and learn with steeper curves.

Key implementation best practices include oversampling AST nodes with low production CAR, integrating context via compiler APIs (such as TypeScript Compiler for TS/JS or BM25 retrieval otherwise), and maintaining static curriculum weights. For block-based/DSL environments, CCCS can be adapted to measure complexity in terms of tree-edit distance and block counts, and to select subtasks via dynamic programming on execution traces.

7. Limitations, Empirical Insights, and Prospects for Extension

While CCCS assigns difficulty primarily via syntactic or semantic constructs (conditionals, AST depth, block count), other program features—such as loops, recursion, or domain-specific markers—could further enrich curricula (Dou et al., 2024). Hyperparameters, such as the number of subtasks KK and stride Δ\Delta, are empirically chosen; more adaptive scheduling could accelerate convergence. Currently, transition between subproblems is one-way, and stochastic multi-level sampling remains unexplored.

The core principles of CCCS are not domain-specific and can be extended to other structured sequence generation domains, including mathematical theorem proving and symbolic reasoning, by adapting the criterion for partitioning and measuring task difficulty.

CCCS consistently delivers improvements in both offline benchmark performance (e.g., EM, PM, Pass@1) and online acceptance/persistence (CAR +4%, CPR +2%) for low-latency code completion, with ablation studies confirming the synergistic benefit of combining curriculum sampling with context-aware retrieval (Sagtani et al., 2024). These gains are especially pronounced for smaller, resource-efficient models.


Selected Comparative Table: Subtasks in FIM CCCS (Sagtani et al., 2024)

Subtask Type Definition/Span Pattern Curriculum Proportion (%)
Random-Span Infilling Arbitrary code span 35
Call-Expression Completions API calls 12
Full Function Definitions Multi-line infilling 12
Class Definitions Multi-line infill (class) 10
Function-Parameters Signature/parameter completion 8
Function-Def w/ Prefix Partial multi-line function 8
If-Statements Conditional logic 8
Try-Catch Blocks Exception handling 4
Assignments Single-line assignment 3

A plausible implication is that the prioritization and balancing of these subtasks—guided by real error rates and complexity metrics—are critical for maximizing real-world performance, especially in production systems subject to stringent latency requirements.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Curriculum of Code Completion Subtasks (CCCS).