CoolFace
Modelpublic

aysinghal/ide-code-retrieval-qwen3-0.6b-cochange-mask-hard

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes104downloads
Model Card

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

ParameterValue
Base modelQwen/Qwen3-Embedding-0.6B
Learning rate2e-05
LR scheduleLinear with warmup
Warmup ratio0.1
Epochs10
Effective batch size256
Per-GPU batch size64
Gradient accumulation1
Max sequence length1024 tokens
PrecisionBFloat16
Gradient checkpointingTrue
torch.compileEnabled (max-autotune)
Seed42
Eval strategyEvery 680 steps
Early stopping patience3

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
StepEpochEval Loss
00.002.4430
6801.010.5413
1,3602.010.5257
2,0403.020.5555
2,7204.020.5541
3,4005.030.5612
4,0806.040.5803
4,7607.040.5789
5,4408.050.5982
6,1209.050.5974

<details> <summary>Full training loss history (click to expand)</summary>

StepEpochLossLearning Rate
500.07403.14361.45e-06
1000.14791.06432.93e-06
1500.22190.68714.41e-06
2000.29590.62435.89e-06
2500.36980.60497.37e-06
3000.44380.58618.85e-06
3500.51780.55131.03e-05
4000.59170.53231.18e-05
4500.66570.51071.33e-05
5000.73960.50241.48e-05
5500.81360.49631.62e-05
6000.88760.49761.77e-05
6500.96150.47601.92e-05
7001.03550.46381.99e-05
7501.10950.43631.98e-05
8001.18340.42741.96e-05
8501.25740.43941.94e-05
9001.33140.42331.93e-05
9501.40530.40131.91e-05
1,0001.47930.42061.89e-05
1,0501.55330.40451.88e-05
1,1001.62720.38411.86e-05
1,1501.70120.37761.84e-05
1,2001.77510.37061.83e-05
1,2501.84910.36611.81e-05
1,3001.92310.35911.80e-05
1,3501.99700.34461.78e-05
1,4002.07100.33771.76e-05
1,4502.14500.34281.75e-05
1,5002.21890.33571.73e-05
1,5502.29290.34231.71e-05
1,6002.36690.32891.70e-05
1,6502.44080.32591.68e-05
1,7002.51480.33771.66e-05
1,7502.58880.32011.65e-05
1,8002.66270.32081.63e-05
1,8502.73670.32261.61e-05
1,9002.81070.33091.60e-05
1,9502.88460.30981.58e-05
2,0002.95860.31061.57e-05
2,0503.03250.29711.55e-05
2,1003.10650.28461.53e-05
2,1503.18050.28711.52e-05
2,2003.25440.28411.50e-05
2,2503.32840.27941.48e-05
2,3003.40240.28391.47e-05
2,3503.47630.27781.45e-05
2,4003.55030.26481.43e-05
2,4503.62430.28351.42e-05
2,5003.69820.27231.40e-05
2,5503.77220.26381.38e-05
2,6003.84620.27351.37e-05
2,6503.92010.27071.35e-05
2,7003.99410.28391.33e-05
2,7504.06800.25031.32e-05
2,8004.14200.24611.30e-05
2,8504.21600.25141.29e-05
2,9004.28990.23811.27e-05
2,9504.36390.23681.25e-05
3,0004.43790.24681.24e-05
3,0504.51180.23821.22e-05
3,1004.58580.24471.20e-05
3,1504.65980.23791.19e-05
3,2004.73370.23211.17e-05
3,2504.80770.22401.15e-05
3,3004.88170.22641.14e-05
3,3504.95560.22861.12e-05
3,4005.02960.21121.10e-05
3,4505.10360.22291.09e-05
3,5005.17750.22151.07e-05
3,5505.25150.21441.06e-05
3,6005.32540.22651.04e-05
3,6505.39940.21681.02e-05
3,7005.47340.20701.01e-05
3,7505.54730.21129.90e-06
3,8005.62130.20769.73e-06
3,8505.69530.21409.57e-06
3,9005.76920.21479.40e-06
3,9505.84320.21289.24e-06
4,0005.91720.20999.08e-06
4,0505.99110.21138.91e-06
4,1006.06510.19288.75e-06
4,1506.13910.20048.58e-06
4,2006.21300.19828.42e-06
4,2506.28700.19188.25e-06
4,3006.36090.19818.09e-06
4,3506.43490.20027.93e-06
4,4006.50890.19607.76e-06
4,4506.58280.19597.60e-06
4,5006.65680.19207.43e-06
4,5506.73080.19457.27e-06
4,6006.80470.19017.10e-06
4,6506.87870.19066.94e-06
4,7006.95270.18566.78e-06
4,7507.02660.18696.61e-06
4,8007.10060.18316.45e-06
4,8507.17460.18226.28e-06
4,9007.24850.17216.12e-06
4,9507.32250.17755.95e-06
5,0007.39640.17855.79e-06
5,0507.47040.17935.62e-06
5,1007.54440.16585.46e-06
5,1507.61830.17465.30e-06
5,2007.69230.16775.13e-06
5,2507.76630.17184.97e-06
5,3007.84020.16604.80e-06
5,3507.91420.17184.64e-06
5,4007.98820.16824.47e-06
5,4508.06210.16454.31e-06
5,5008.13610.16454.15e-06
5,5508.21010.17363.98e-06
5,6008.28400.16703.82e-06
5,6508.35800.16253.65e-06
5,7008.43200.16153.49e-06
5,7508.50590.15793.32e-06
5,8008.57990.16063.16e-06
5,8508.65380.16262.99e-06
5,9008.72780.16352.83e-06
5,9508.80180.15572.67e-06
6,0008.87570.15862.50e-06
6,0508.94970.15112.34e-06
6,1009.02370.15892.17e-06
6,1509.09760.15082.01e-06
6,2009.17160.15611.84e-06
6,2509.24560.14721.68e-06
6,3009.31950.15061.52e-06
6,3509.39350.14461.35e-06
6,4009.46750.15441.19e-06
6,4509.54140.15191.02e-06
6,5009.61540.14368.58e-07
6,5509.68930.15316.94e-07
6,6009.76330.14445.29e-07
6,6509.83730.14763.65e-07
6,7009.91120.15322.01e-07
6,7509.98520.15023.62e-08

</details>

Usage

Loading the Model

python
from sentence_transformers import SentenceTransformer

model = SentenceTransformer("aysinghal/ide-code-retrieval-qwen3-0.6b-cochange-mask-hard")

Computing Embeddings

python
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:

bibtex
@article{qwen3embedding,
  title={Qwen3-Embedding},
  author={Qwen Team},
  year={2025}
}