ide-code-retrieval-qwen3-0.6b-cochange-mask-hard
A SentenceTransformer model fine-tuned from Qwen/Qwen3-Embedding-0.6B for code→code retrieval -- mapping a source file to files that co-change with it, via dense vector similarity.
Note: This is an intermediate checkpoint at step 6,760 / 6,760 (100.0% through 10 epochs). Training loss is still decreasing, so a later checkpoint may perform better.
Model Description
This model encodes source files into a shared embedding space so that files that historically co-change land near each other. Retrieval is performed by computing cosine similarity between a query-file embedding and candidate embeddings.
- Base model: Qwen/Qwen3-Embedding-0.6B (0.6B parameters)
- Max sequence length: 1024 tokens
- Output dimensionality: 1024 (normalized)
- Similarity function: Cosine similarity
Training Details
Dataset
- Source: aysinghal/code-retrieval-training-dataset
- Query rows: 173,093 train / 28,210 test (repo-level held-out split; no repo appears in both).
- Corpus: 477,864 files, referenced by ID from rows.
- Text handling: collator-side sliding window
- Negatives: Up to 128 mined hard + 128 mined easy negatives per query row, plus group-aware in-batch negatives.
- Pre-tokenized: No (text resolved from corpus in the collator)
Loss Function
MultipleNegativesRankingLoss (InfoNCE) with mined hard/easy negatives and group-aware in-batch negatives (batches are constructed so no two rows share a co-change group_key, preventing false negatives when two rows come from the same cluster).
Hyperparameters
| Parameter | Value |
|---|---|
| Base model | Qwen/Qwen3-Embedding-0.6B |
| Learning rate | 2e-05 |
| LR schedule | Linear with warmup |
| Warmup ratio | 0.1 |
| Epochs | 10 |
| Effective batch size | 256 |
| Per-GPU batch size | 64 |
| Gradient accumulation | 1 |
| Max sequence length | 1024 tokens |
| Precision | BFloat16 |
| Gradient checkpointing | True |
| torch.compile | Enabled (max-autotune) |
| Seed | 42 |
| Eval strategy | Every 680 steps |
| Early stopping patience | 3 |
Hardware
- GPUs: 4x NVIDIA L40S
- Total training steps: 6,760 (10 epochs)
Training Progress (at checkpoint step 6,760)
- Training loss: 3.1436 (step 50) → 0.1502 (step 6750)
- Best eval loss: 0.5257 (step 1,360)
- Progress: 6,760 / 6,760 steps (100.0%)
Evaluation Results
| Step | Epoch | Eval Loss |
|---|---|---|
| 0 | 0.00 | 2.4430 |
| 680 | 1.01 | 0.5413 |
| 1,360 | 2.01 | 0.5257 |
| 2,040 | 3.02 | 0.5555 |
| 2,720 | 4.02 | 0.5541 |
| 3,400 | 5.03 | 0.5612 |
| 4,080 | 6.04 | 0.5803 |
| 4,760 | 7.04 | 0.5789 |
| 5,440 | 8.05 | 0.5982 |
| 6,120 | 9.05 | 0.5974 |
| Step | Epoch | Loss | Learning Rate |
|---|---|---|---|
| 50 | 0.0740 | 3.1436 | 1.45e-06 |
| 100 | 0.1479 | 1.0643 | 2.93e-06 |
| 150 | 0.2219 | 0.6871 | 4.41e-06 |
| 200 | 0.2959 | 0.6243 | 5.89e-06 |
| 250 | 0.3698 | 0.6049 | 7.37e-06 |
| 300 | 0.4438 | 0.5861 | 8.85e-06 |
| 350 | 0.5178 | 0.5513 | 1.03e-05 |
| 400 | 0.5917 | 0.5323 | 1.18e-05 |
| 450 | 0.6657 | 0.5107 | 1.33e-05 |
| 500 | 0.7396 | 0.5024 | 1.48e-05 |
| 550 | 0.8136 | 0.4963 | 1.62e-05 |
| 600 | 0.8876 | 0.4976 | 1.77e-05 |
| 650 | 0.9615 | 0.4760 | 1.92e-05 |
| 700 | 1.0355 | 0.4638 | 1.99e-05 |
| 750 | 1.1095 | 0.4363 | 1.98e-05 |
| 800 | 1.1834 | 0.4274 | 1.96e-05 |
| 850 | 1.2574 | 0.4394 | 1.94e-05 |
| 900 | 1.3314 | 0.4233 | 1.93e-05 |
| 950 | 1.4053 | 0.4013 | 1.91e-05 |
| 1,000 | 1.4793 | 0.4206 | 1.89e-05 |
| 1,050 | 1.5533 | 0.4045 | 1.88e-05 |
| 1,100 | 1.6272 | 0.3841 | 1.86e-05 |
| 1,150 | 1.7012 | 0.3776 | 1.84e-05 |
| 1,200 | 1.7751 | 0.3706 | 1.83e-05 |
| 1,250 | 1.8491 | 0.3661 | 1.81e-05 |
| 1,300 | 1.9231 | 0.3591 | 1.80e-05 |
| 1,350 | 1.9970 | 0.3446 | 1.78e-05 |
| 1,400 | 2.0710 | 0.3377 | 1.76e-05 |
| 1,450 | 2.1450 | 0.3428 | 1.75e-05 |
| 1,500 | 2.2189 | 0.3357 | 1.73e-05 |
| 1,550 | 2.2929 | 0.3423 | 1.71e-05 |
| 1,600 | 2.3669 | 0.3289 | 1.70e-05 |
| 1,650 | 2.4408 | 0.3259 | 1.68e-05 |
| 1,700 | 2.5148 | 0.3377 | 1.66e-05 |
| 1,750 | 2.5888 | 0.3201 | 1.65e-05 |
| 1,800 | 2.6627 | 0.3208 | 1.63e-05 |
| 1,850 | 2.7367 | 0.3226 | 1.61e-05 |
| 1,900 | 2.8107 | 0.3309 | 1.60e-05 |
| 1,950 | 2.8846 | 0.3098 | 1.58e-05 |
| 2,000 | 2.9586 | 0.3106 | 1.57e-05 |
| 2,050 | 3.0325 | 0.2971 | 1.55e-05 |
| 2,100 | 3.1065 | 0.2846 | 1.53e-05 |
| 2,150 | 3.1805 | 0.2871 | 1.52e-05 |
| 2,200 | 3.2544 | 0.2841 | 1.50e-05 |
| 2,250 | 3.3284 | 0.2794 | 1.48e-05 |
| 2,300 | 3.4024 | 0.2839 | 1.47e-05 |
| 2,350 | 3.4763 | 0.2778 | 1.45e-05 |
| 2,400 | 3.5503 | 0.2648 | 1.43e-05 |
| 2,450 | 3.6243 | 0.2835 | 1.42e-05 |
| 2,500 | 3.6982 | 0.2723 | 1.40e-05 |
| 2,550 | 3.7722 | 0.2638 | 1.38e-05 |
| 2,600 | 3.8462 | 0.2735 | 1.37e-05 |
| 2,650 | 3.9201 | 0.2707 | 1.35e-05 |
| 2,700 | 3.9941 | 0.2839 | 1.33e-05 |
| 2,750 | 4.0680 | 0.2503 | 1.32e-05 |
| 2,800 | 4.1420 | 0.2461 | 1.30e-05 |
| 2,850 | 4.2160 | 0.2514 | 1.29e-05 |
| 2,900 | 4.2899 | 0.2381 | 1.27e-05 |
| 2,950 | 4.3639 | 0.2368 | 1.25e-05 |
| 3,000 | 4.4379 | 0.2468 | 1.24e-05 |
| 3,050 | 4.5118 | 0.2382 | 1.22e-05 |
| 3,100 | 4.5858 | 0.2447 | 1.20e-05 |
| 3,150 | 4.6598 | 0.2379 | 1.19e-05 |
| 3,200 | 4.7337 | 0.2321 | 1.17e-05 |
| 3,250 | 4.8077 | 0.2240 | 1.15e-05 |
| 3,300 | 4.8817 | 0.2264 | 1.14e-05 |
| 3,350 | 4.9556 | 0.2286 | 1.12e-05 |
| 3,400 | 5.0296 | 0.2112 | 1.10e-05 |
| 3,450 | 5.1036 | 0.2229 | 1.09e-05 |
| 3,500 | 5.1775 | 0.2215 | 1.07e-05 |
| 3,550 | 5.2515 | 0.2144 | 1.06e-05 |
| 3,600 | 5.3254 | 0.2265 | 1.04e-05 |
| 3,650 | 5.3994 | 0.2168 | 1.02e-05 |
| 3,700 | 5.4734 | 0.2070 | 1.01e-05 |
| 3,750 | 5.5473 | 0.2112 | 9.90e-06 |
| 3,800 | 5.6213 | 0.2076 | 9.73e-06 |
| 3,850 | 5.6953 | 0.2140 | 9.57e-06 |
| 3,900 | 5.7692 | 0.2147 | 9.40e-06 |
| 3,950 | 5.8432 | 0.2128 | 9.24e-06 |
| 4,000 | 5.9172 | 0.2099 | 9.08e-06 |
| 4,050 | 5.9911 | 0.2113 | 8.91e-06 |
| 4,100 | 6.0651 | 0.1928 | 8.75e-06 |
| 4,150 | 6.1391 | 0.2004 | 8.58e-06 |
| 4,200 | 6.2130 | 0.1982 | 8.42e-06 |
| 4,250 | 6.2870 | 0.1918 | 8.25e-06 |
| 4,300 | 6.3609 | 0.1981 | 8.09e-06 |
| 4,350 | 6.4349 | 0.2002 | 7.93e-06 |
| 4,400 | 6.5089 | 0.1960 | 7.76e-06 |
| 4,450 | 6.5828 | 0.1959 | 7.60e-06 |
| 4,500 | 6.6568 | 0.1920 | 7.43e-06 |
| 4,550 | 6.7308 | 0.1945 | 7.27e-06 |
| 4,600 | 6.8047 | 0.1901 | 7.10e-06 |
| 4,650 | 6.8787 | 0.1906 | 6.94e-06 |
| 4,700 | 6.9527 | 0.1856 | 6.78e-06 |
| 4,750 | 7.0266 | 0.1869 | 6.61e-06 |
| 4,800 | 7.1006 | 0.1831 | 6.45e-06 |
| 4,850 | 7.1746 | 0.1822 | 6.28e-06 |
| 4,900 | 7.2485 | 0.1721 | 6.12e-06 |
| 4,950 | 7.3225 | 0.1775 | 5.95e-06 |
| 5,000 | 7.3964 | 0.1785 | 5.79e-06 |
| 5,050 | 7.4704 | 0.1793 | 5.62e-06 |
| 5,100 | 7.5444 | 0.1658 | 5.46e-06 |
| 5,150 | 7.6183 | 0.1746 | 5.30e-06 |
| 5,200 | 7.6923 | 0.1677 | 5.13e-06 |
| 5,250 | 7.7663 | 0.1718 | 4.97e-06 |
| 5,300 | 7.8402 | 0.1660 | 4.80e-06 |
| 5,350 | 7.9142 | 0.1718 | 4.64e-06 |
| 5,400 | 7.9882 | 0.1682 | 4.47e-06 |
| 5,450 | 8.0621 | 0.1645 | 4.31e-06 |
| 5,500 | 8.1361 | 0.1645 | 4.15e-06 |
| 5,550 | 8.2101 | 0.1736 | 3.98e-06 |
| 5,600 | 8.2840 | 0.1670 | 3.82e-06 |
| 5,650 | 8.3580 | 0.1625 | 3.65e-06 |
| 5,700 | 8.4320 | 0.1615 | 3.49e-06 |
| 5,750 | 8.5059 | 0.1579 | 3.32e-06 |
| 5,800 | 8.5799 | 0.1606 | 3.16e-06 |
| 5,850 | 8.6538 | 0.1626 | 2.99e-06 |
| 5,900 | 8.7278 | 0.1635 | 2.83e-06 |
| 5,950 | 8.8018 | 0.1557 | 2.67e-06 |
| 6,000 | 8.8757 | 0.1586 | 2.50e-06 |
| 6,050 | 8.9497 | 0.1511 | 2.34e-06 |
| 6,100 | 9.0237 | 0.1589 | 2.17e-06 |
| 6,150 | 9.0976 | 0.1508 | 2.01e-06 |
| 6,200 | 9.1716 | 0.1561 | 1.84e-06 |
| 6,250 | 9.2456 | 0.1472 | 1.68e-06 |
| 6,300 | 9.3195 | 0.1506 | 1.52e-06 |
| 6,350 | 9.3935 | 0.1446 | 1.35e-06 |
| 6,400 | 9.4675 | 0.1544 | 1.19e-06 |
| 6,450 | 9.5414 | 0.1519 | 1.02e-06 |
| 6,500 | 9.6154 | 0.1436 | 8.58e-07 |
| 6,550 | 9.6893 | 0.1531 | 6.94e-07 |
| 6,600 | 9.7633 | 0.1444 | 5.29e-07 |
| 6,650 | 9.8373 | 0.1476 | 3.65e-07 |
| 6,700 | 9.9112 | 0.1532 | 2.01e-07 |
| 6,750 | 9.9852 | 0.1502 | 3.62e-08 |
Usage
Loading the Model
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("aysinghal/ide-code-retrieval-qwen3-0.6b-cochange-mask-hard")
Computing Embeddings
query_file = open("src/auth/session.py").read()
candidates = [open(p).read() for p in candidate_paths]
query_emb = model.encode([query_file])
cand_embs = model.encode(candidates)
# Compute cosine similarities
from sentence_transformers.util import cos_sim
similarities = cos_sim(query_emb, cand_embs)
print(similarities)
Intended Use
- Primary use case: Given a file the developer is currently editing, retrieve related files across the same codebase that are likely to require changes.
- Search pipeline: Encode a corpus of code documents offline, then at query time encode the query and find nearest neighbors via cosine similarity
Limitations
- This is an early checkpoint (100.0% through training). The loss curve is still decreasing, so later checkpoints will likely perform better.
- Trained on a specific code retrieval dataset; may not generalize to all programming languages or query styles without further fine-tuning.
- Max context is 1024 tokens -- very long files are truncated.
Citation
If you use this model, please cite the base model:
@article{qwen3embedding,
title={Qwen3-Embedding},
author={Qwen Team},
year={2025}
}