Skip to content
Open access

SynthCoder: Anti-pattern identification and model training for FIM mode code completion

Aug 2025 · Empirical Software Engineering · Vol 32 · 1 citation · 56 references
Computer Science

TL;DR

This work introduces SynthCoder, which adopts optimized masking strategies better aligned with developer’s expectation in FIM, and first refine AST-level node masking and add heuristics that better mimic developers’ expectation to construct the training corpora.

Abstract

As a leading application of large language models (LLMs) in software engineering, Fill-in-the-Middle (FIM) mode code completion has drawn wide attention. Training such models requires masking code corpora, yet common strategies tend to be problematic. For example, character-delimited random masking may yield many unrealistic cases (e.g., cutting keywords or identifiers), while purely AST-based masking cannot mask concurrent elements (subtrees) that span across multiple subtrees. These limitations easily create anti-patterns that rarely occur in real-world code completion scenarios, diminishing FIM performance. We introduce SynthCoder, which adopts optimized masking strategies better aligned with developer’s expectation in FIM. Specifically, we first refine AST-level node masking and add heuristics that better mimic developers’ expectation to construct the training corpora. Subsequently, SynthCoder-Seed and SynthCoder-Qwen, built upon Seed-Coder-8B-Base and Qwen2.5-Coder-7B respectively, employ a two-stage training pipeline, i.e., curriculum-based fine-tuning stage followed by Direct Preference Optimization (DPO) alignment stage with rejected code sampled preference data. Besides, to suppress erroneous context repetition, we include negative samples that duplicate existing code during DPO, mitigating code-echo failures where the model copies neighboring context instead of producing a valid completion. Extensive experiments on Santacoder-fim-task, aiXcoder-FIM-Evaluation and CrossCodeEval benchmarks show that the models trained with our mitigation strategies improve over mainstream baselines on Exact Match (EM) and Edit Similarity (ES) for text-based FIM benchmarks, and on Pass@1 for Santacoder-fim-task, a benchmark with test cases. SynthCoder also yields less code-echo and consumes fewer tokens at inference, yielding higher practical efficiency. Ablation studies further support the contribution of our optimized masking and repetition-suppression mechanisms.

Read PDF

Similar papers

Hunk-Constrained DPO: Segment-Level Optimization for Secure and Correct LLM Code Generation

Hunk-Constrained Direct Preference Optimization is introduced, a training framework that unifies security hardening and functional correction in large language models and demonstrates that HPO achieves substantial security improvements—up to 28 percentage points—while preserving or enhancing functional correctness.

Qian-Shuo Huang, Xin Yin, Xin-Rui Li et al. · 0 citations
#small language model Preprint Aug 2026

Vulnerable Code Search: Transferable Attack for Code Language Models

This paper introduces a programming language-agnostic, transferable, adversarial attack that exploits this CLM vulnerability and demonstrates that this attack, even when computed using smaller code embedding models, is highly effective and transferable to larger, closed-source embedding models.

Kaicheng Wang, Li-Yan Huang, Jesse Thomason et al. · 0 citations
#small language model Preprint Sep 2026

Towards Behavior Tree-Guided Vulnerability Detection with Lightweight LLMs

Investigating Behavior Trees (BTs) as an alternative intermediate representation for LLM-based vulnerability detection suggests that BTs can provide a compact and useful structured representation for vulnerability detection with quantized, locally deployable LLMs.

Enna Bašić, A. Giaretta · 0 citations
#artificial intelligence Preprint Sep 2026

JevVibe: Efficient Classification-Guided Secure Code Generation

This work evaluates Jev, a decision model that instead selects directly from a declared set of candidates and returns a probability for each, against six open-weight autoregressive models and a frontier proprietary model, and builds JevVibe, a diagnosis-guided repair agent that uses predicted CWE labels to repair code...

Arshak Rezvani, Sasha Behrouzi, Ahmad Sadeghi · 0 citations
#machine learning Preprint Oct 2026

Hidden in the Comments: A Context-Injection Attack Surface in Code LLMs

Code large language model (Code LLM) assistants generate code from heterogeneous development contexts, including open files, imported modules, pasted snippets, and comments, much of which may originate from untrusted sources. We investigate whether insecure instructions embedded in such contexts can steer Code LLMs tow...

Noor Munir, Francesco Quinzan, Stephen J. Roberts · 0 citations
Book Open access Aug 2026

Post-hoc Attention Steering of Large Language Models for Robust Code Understanding under Obfuscation

This work proposes CodeSteer, a novel attention steering approach that reallocates model attention toward semantically relevant program elements, including backward slices for output prediction and control-flow paths for execution reasoning in large language models.

Xiao-Kai Rong, Aashish Yadavally, Tien N. Nguyen · 0 citations

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.