SWEzze: Lightweight Code Compression
- SWEzze is a context compression model that retains essential code segments, reducing computational expense and distracting noise in LLM-based bug fixing.
- It combines Oracle-guided Code Distillation with a fine-tuned Transformer reranker to identify minimal sufficient context for successful patch synthesis.
- Performance evaluations show a 6x compression ratio, 51–71% token reduction, and up to 9% improvement in patch resolution rates across LLM pipelines.
SWEzze is a lightweight context compression model for LLM-based issue resolution pipelines, addressing the dual challenges of computational overhead and degraded effectiveness arising from over-approximated code context windows. By combining Oracle-guided Code Distillation (OCD) for training data generation with a fine-tuned Transformer-based reranker, SWEzze enables the retention of only those code segments (“fix ingredients”) minimally sufficient for patch synthesis, thus improving both efficiency and LLM success rates in code repair and bug-fixing tasks (Jia et al., 30 Mar 2026).
1. Motivation: Code Context Compression in LLM Issue Resolution
Recent advances in LLMs have enabled practical resolution of real-world software issues (e.g., via Agentless or SWE-Agent workflows), where a typical pipeline retrieves an over-approximate set of files, functions, and code blocks related to a GitHub issue. Retrieval is deliberately broad—often selecting the top- elements via retrieval augmented generation (RAG) or heuristics—to avoid missing dependencies. This “maximal context” paradigm leads to hundreds of lines of code as model input, which incurs two principal costs: linear growth in computational expense with respect to context length, and empirical reductions in patch effectiveness as noise in the context window distracts the model from relevant bug-fix signals (see Shi et al., 2023; Liu et al., 2024).
Conventional compressors either degrade code’s semantic integrity by treating it as plain text, or apply superficial code-similarity heuristics that risk omitting essential but non-obvious fix ingredients. SWEzze aims to compress code context by learning, from oracle-generated data, to identify only those segments actually required for a successful fix.
2. Oracle-guided Code Distillation (OCD): Dataset Construction
OCD is a search-based algorithm that constructs for each issue a minimal sufficient code context. Starting from an initial candidate set , OCD reduces it to a “1-minimal sufficient context” : a smallest subset such that an LLM, when provided the issue, fault location, and , can synthesize a patch that passes all validation tests—removing any further segment causes patch validation to fail.
OCD represents the search space hierarchically at three granularity levels: file, function/method, and statement-level block. Leaf units (segments) may be omitted, replaced by placeholders (“# … N lines omitted”) to maintain syntactic validity.
Each segment receives a priority score:
where indicates whether belongs to files changed by the patch, is the set of test-covered lines in , and 0 measures lexical overlap with gold patch identifiers.
OCD proceeds in two phases:
- Genetic Search (GA): Candidate contexts are represented as binary genomes, with search operators (tournament selection, crossover at file level, bit-flip mutation) and a fitness function driven by pass/fail or summed 1. The process stops upon finding any sufficient context.
- Hierarchical Delta Debugging (HDD): The minimality criterion is enforced by iteratively attempting to remove low-priority units at each granularity (file, function, block), provided removal does not break patch validation.
This produces (issue, fault, uncompressed context, 1-minimal sufficient context) tuples for downstream model training.
3. SWEzze Model Architecture and Training
SWEzze is trained using the OCD-generated datasets to score and filter context at inference time. For each (issue 2, fault 3, candidate segment 4), pointwise training examples are created with 5 if 6, else 7. The input query 8 encodes 9, and the goal is to predict, for each 0, its retention label.
Architecture and training details:
- Base model: Qwen3-Reranker-0.6B, a Transformer cross-encoder.
- Adaptation: LoRA with rank 1, 2 on attention projections.
- Prediction: 3, interpreted as the retention probability.
- Objective: Weighted binary cross-entropy loss,
4
where weights 5 correct for a severe positive-to-negative class imbalance (6), and encode semantic-role importance.
- Hyperparameters: 3 epochs, effective batch 16, AdamW learning rate 7, 10% warmup, weight decay 8, gradient clip 9, mixed precision (0), checkpointing.
At inference, the uncompressed context is decomposed into segments, scored, and the top segments are greedily selected up to a preset token limit, with omitted segments replaced by placeholders.
4. Performance Evaluation and Baseline Comparisons
Evaluation is conducted on SWE-bench Verified (500 issues), measuring absolute resolution rates (fraction of instances with test-passing patches), compression rates (input token contraction), total token counts (prompt plus completion), and compression latency per instance.
Key results across three downstream LLMs (DeepSeek-V3.2, Qwen3-Coder-Next, GPT-5.2):
- Stable compression ratio: 1 (6.03, 5.95, 6.55).
- Token budget reduction: 2 to 3 relative to uncompressed baselines.
- Resolution rate improvement: 4–5 absolute, 6 average (e.g., DeepSeek-V3.2 from 47.8% to 52.2%).
- Compression latency: 6.1 s/instance (7 faster than LongCodeZip’s 24.4 s; slower than token-level compressors at 8 s).
Comparison with state-of-the-art compressors:
| Compressor | Compression Ratio | Resolution Gains | Latency |
|---|---|---|---|
| LLMLingua-2 | 9 | Small/Negative | Low |
| LongCodeZip | 0–1 | Modest/Variable | High |
| SWE-Pruner | Up to 2 | Often Negative | Moderate |
| SWEzze | 3 | Highest | Low-Medium |
SWEzze consistently achieves a balance of moderate compression, high resolution rate, and low-to-medium latency.
5. Design Principles and Deployment Recommendations
SWEzze distinguishes itself by prioritizing segment sufficiency (“distilling for sufficiency”), in contrast to traditional methods (“pruning for similarity”). Key practical principles arising from these findings:
- Effective LLM-based issue resolution requires retention of causal fix ingredients rather than maximally broad or heuristically similar code snippets.
- The two-stage SWEzze pipeline—expensive OCD distillation followed by efficient segment-wise reranking—offers a practical balance between cost, compression, and patch success.
- Recommended workflow:
- Apply OCD to a held-out issue set for dataset creation.
- Fine-tune a reranker (e.g., with LoRA) for segment retention prediction.
- At runtime, decompose, score, and compress input contexts, targeting 4–5 reduction.
Outcomes include significant token savings (50–70%), reduced inference cost, and improved or at least non-degraded patch success (6–7) across LLMs.
6. Implications and Application Scope
The results demonstrate that model-driven context compression grounded in semantic sufficiency is a viable route for scaling LLM-based code reasoning to large repositories and complex patches. Application of SWEzze may yield improvements in both computational efficiency and practical bug-fixing success in automated software engineering pipelines, with lessons potentially generalizable to related domains where input window saturation and noisy context remain bottlenecks (Jia et al., 30 Mar 2026).
7. Summary
SWEzze establishes that LLMs tasked with source code repair benefit from context compression strategies focused on Oracle-guided sufficiency, balancing minimal input size against retention of critical patch-enabling information. This achieves reductions in computational cost, improved patch resolution rates, and a robust performance profile compared to competitive baselines in the domain of LLM-driven software maintenance.