Back to Feed
Training & Fine-Tuning / Benchmarks & Evals

Selecting Better Training Data for Agents

Original: SWE-Prime: Fewer Trajectories, Better Performance

Listen to the summary

Uses a voice available on your device

Audio options
On this page 5 sections
Related concepts 4 concepts

Key Takeaways

  • Training on just 10% of selected trajectories outperforms training on the full dataset.
  • The method achieved a 12.2% relative performance gain on SWE-Bench Pro.
  • The method achieved a 24.2% relative performance gain on SWE-Bench Verified.
  • The process uses the Qwen3-Embedding-8B model to encode issue descriptions.

Summary & Methodology Analysis

The researchers addressed the challenge of noisy data in fine-tuning, which is the process of further training a pre-trained model on specific datasets to refine its performance. By implementing a multi-stage filtering process, they identified higher-quality segments within successful software resolution trajectories. The approach involves trajectory-level screening based on quality and representativeness, followed by segment-level selection to isolate steps that offer the most contribution and learnability while minimizing risk. This selective supervised fine-tuning ensures the model learns from the most effective patterns within the dataset.

The system architecture utilizes the Qwen3-Embedding-8B model to encode issue descriptions, allowing for effective semantic alignment. By performing boundary-aware chunking, the method prevents behavioral segments from being split across context windows. The researchers validated this approach by training the GLM-4.7-Flash model and evaluating its performance against full-dataset training on SWE-Bench Pro and SWE-Bench Verified. This focused training approach allows for superior performance outcomes using only 10% of the available training data.

A primary limitation identified by the authors is that the proportion of high-quality supervision within a raw trajectory pool is not known a priori. Because the optimal selection configuration depends on the distribution of this quality, the researchers must determine the selection settings before starting the main evaluation. The paper does not specify the computational cost or the exact time required to perform the filtering process compared to standard training methods.

Interactive System Flowchart

Click diagram to expand and zoom

Illustrative Implementation

A short sketch of the paper's core idea, not the authors' own code.

# Illustrative sketch (not from the paper)
import torch
import hdbscan
from qwen3_embedding import Qwen3Embedding8B  # placeholder import
from glm import GLM4_7Flash  # placeholder import

# 1. Encode issue descriptions (SWE‑Bench trajectories) with Qwen3‑Embedding‑8B

def encode_issues(issues):
    embedder = Qwen3Embedding8B()
    return embedder.encode(issues)  # -> Tensor[N, D]

# 2. Trajectory‑level screening using HDBSCAN clustering on the embeddings

def trajectory_screening(traj_embeddings):
    clusterer = hdbscan.HDBSCAN(min_cluster_size=5)
    labels = clusterer.fit_predict(traj_embeddings)
    # keep trajectories belonging to dense, high‑quality clusters (label >= 0)
    return [i for i, l in enumerate(labels) if l >= 0]

# 3. Segment‑level selection (placeholder heuristics for contribution & risk)

def segment_selection(segments):
    selected = []
    for idx, seg in enumerate(segments):
        if seg["contribution"] > 0.5 and seg["risk"] < 0.3:
            selected.append(idx)
    return selected

# 4. Boundary‑aware chunking to avoid splitting semantic segments

def boundary_aware_chunk(segments, max_len=512):
    chunks, cur, cur_len = [], [], 0
    for seg in segments:
        seg_len = len(seg["tokens"])
        if cur_len + seg_len > max_len:
            chunks.append(cur)
            cur, cur_len = [], 0
        cur.append(seg)
        cur_len += seg_len
    if cur:
        chunks.append(cur)
    return chunks

# 5. Selective SFT: all segments are context, loss only on selected ones

def selective_sft(model, chunks, selected_idxs):
    optimizer = torch.optim.Adam(model.parameters(), lr=1e-5)
    for chunk in chunks:
        # flatten tokens for the whole chunk (context)
        inputs = torch.tensor([t for seg in chunk for t in seg["tokens"]])
        outputs = model(inputs)
        # mask loss to selected segments only
        mask = torch.zeros_like(outputs.logits, dtype=torch.bool)
        offset = 0
        for i, seg in enumerate(chunk):
            seg_len = len(seg["tokens"])
            if i in selected_idxs:
                mask[offset:offset+seg_len] = True
            offset += seg_len
        loss = torch.nn.functional.cross_entropy(outputs.logits[mask], inputs[mask])
        loss.backward()
        optimizer.step()
        optimizer.zero_grad()

Cross-Examination & FAQs

A deeper dive clarifying mechanics, constraints, and baseline evaluations.

Q1. What is the core contribution of SWE-Prime?

SWE-Prime provides a method to select high-quality training data from software resolution trajectories, leading to better model performance using less data.

Q2. Does using less training data hurt performance?

No, models trained on 10% of trajectories selected by SWE-Prime actually outperformed models trained on the full dataset.

Q3. Which benchmarks were used to test this method?

The researchers evaluated SWE-Prime on SWE-Bench Pro and SWE-Bench Verified.

Q4. What is the role of Qwen3-Embedding-8B in this process?

It is used to encode the issue description associated with each trajectory.

Q5. What base models did the researchers test?

The paper evaluated SWE-Prime on the GLM-4.7-Flash model.

Q6. How does the selection process handle the unknown quality of data?

Because the proportion of high-quality supervision is not known a priori, the researchers determine the selection configuration before conducting the main evaluation.

Q7. What specific performance gains were observed?

The method yielded relative performance gains of up to 12.2% on SWE-Bench Pro and 24.2% on SWE-Bench Verified.

Q8. Are there limitations to the current method?

Yes, the main limitation is that the proportion of high-quality supervision within a trajectory pool is not known before the selection process begins.

Q9. How much does the filtering process cost in terms of time or hardware?

The paper does not specify the computational cost or hardware requirements for the filtering process.

Flag an issue

What is wrong with this summary?

What is wrong?