jamie8johnson commited on
Commit
b9fd3f5
·
verified ·
1 Parent(s): f5c8878

docs: update model card for LoRA v7 (0.707 CSN, 49.19 CoIR)

Browse files
Files changed (1) hide show
  1. README.md +28 -26
README.md CHANGED
@@ -28,7 +28,7 @@ model-index:
28
  name: CodeSearchNet
29
  metrics:
30
  - type: ndcg_at_10
31
- value: 0.683
32
  name: NDCG@10 (avg, 6 languages)
33
  - task:
34
  type: Retrieval
@@ -37,13 +37,13 @@ model-index:
37
  name: CosQA
38
  metrics:
39
  - type: ndcg_at_10
40
- value: 0.348
41
  name: NDCG@10
42
  ---
43
 
44
  # e5-base-v2-code-search
45
 
46
- A fine-tuned code search embedding model based on [intfloat/e5-base-v2](https://huggingface.co/intfloat/e5-base-v2) (110M parameters). Optimized for natural language → code retrieval across 6 programming languages.
47
 
48
  Built for [cqs](https://github.com/jamie8johnson/cqs), a semantic code search tool for AI agents.
49
 
@@ -51,8 +51,9 @@ Built for [cqs](https://github.com/jamie8johnson/cqs), a semantic code search to
51
 
52
  | Benchmark | Metric | Score | vs Base E5 |
53
  |-----------|--------|-------|------------|
54
- | CodeSearchNet (6 lang avg) | NDCG@10 | **0.683** | **+5.6pp** |
55
- | CosQA (out-of-distribution) | NDCG@10 | **0.348** | **+1.9pp** |
 
56
  | Hard eval (55 confusable pairs) | Recall@1 | **92.7%** | +1.8pp* |
57
 
58
  *Hard eval improvement from full pipeline (LoRA + NL enrichment + doc comments), not LoRA alone.
@@ -61,38 +62,38 @@ Built for [cqs](https://github.com/jamie8johnson/cqs), a semantic code search to
61
 
62
  | Language | Base E5 | This Model | Delta |
63
  |----------|---------|------------|-------|
64
- | Go | 0.624 | **0.746** | +0.122 |
65
- | Java | 0.571 | **0.621** | +0.050 |
66
- | JavaScript | 0.487 | **0.535** | +0.048 |
67
- | Ruby | 0.526 | **0.592** | +0.066 |
68
- | Python | 0.888 | **0.909** | +0.021 |
69
- | PHP | 0.601 | **0.623** | +0.022 |
70
 
71
  ### CoIR Leaderboard Context
72
 
73
- Among 110M-class models on the [CoIR benchmark](https://archersama.github.io/coir/) (ACL 2025), E5-base-v2 is already #7 out of 13 entries. This LoRA fine-tune extends the lead over other 110M models (BGE-Base 42.77, GTE-Base 36.75, UniXcoder 37.33) while remaining CPU-runnable in <100ms per query.
74
 
75
  ## Training
76
 
77
  - **Method:** LoRA (rank 16) fine-tuning of E5-base-v2
78
- - **Data:** 166,000 CodeSearchNet triplets (query, positive code, negative code) + docstring-as-query pairs
79
- - **Training time:** ~30 minutes on A6000
 
80
  - **Epochs:** 1
81
- - **Loss:** Triplet loss with in-batch negatives
82
 
83
- ### Why LoRA v5?
84
 
85
- We trained 10 LoRA variants with different data sizes (10k–186k), ranks (16, 32), epochs (1–3), and data mixes. v5 (166k/1ep) is the best overall:
86
 
87
- | Config | Samples | Epochs | CSN NDCG@10 | CosQA (transfer) |
88
- |--------|---------|--------|-------------|-------------------|
89
- | Base E5 | — | — | 0.627 | 0.329 |
90
- | v3 (previous) | 50k | 1 | 0.671 | 0.334 |
91
- | **v5 (current)** | **166k** | **1** | **0.683** | **0.348** |
92
- | v4 | 166k | 3 | 0.695 | 0.305 (over-specialized) |
93
- | rank-32 | 186k | 1 | 0.681 | 0.350 |
94
 
95
- v4 achieves higher CSN but catastrophically regresses on out-of-distribution queries (CosQA drops below base). v5 uses the full dataset at 1 epoch — more data without over-specialization.
96
 
97
  ## Usage
98
 
@@ -149,9 +150,10 @@ The enrichment transforms code into richer text before the embedding model sees
149
 
150
  ## Limitations
151
 
152
- - Trained primarily on CodeSearchNet (Go, Java, JavaScript, Ruby, Python, PHP). Performance on other languages (Rust, C++, TypeScript) relies on E5's base multilingual capability.
153
  - English queries only. E5-base-v2's multilingual capability is untested for code search.
154
  - 512 token max sequence length. Long functions are truncated.
 
155
 
156
  ## Citation
157
 
 
28
  name: CodeSearchNet
29
  metrics:
30
  - type: ndcg_at_10
31
+ value: 0.707
32
  name: NDCG@10 (avg, 6 languages)
33
  - task:
34
  type: Retrieval
 
37
  name: CosQA
38
  metrics:
39
  - type: ndcg_at_10
40
+ value: 0.354
41
  name: NDCG@10
42
  ---
43
 
44
  # e5-base-v2-code-search
45
 
46
+ A fine-tuned code search embedding model based on [intfloat/e5-base-v2](https://huggingface.co/intfloat/e5-base-v2) (110M parameters). Optimized for natural language → code retrieval across 9 programming languages.
47
 
48
  Built for [cqs](https://github.com/jamie8johnson/cqs), a semantic code search tool for AI agents.
49
 
 
51
 
52
  | Benchmark | Metric | Score | vs Base E5 |
53
  |-----------|--------|-------|------------|
54
+ | CodeSearchNet (6 lang avg) | NDCG@10 | **0.707** | **+8.0pp** |
55
+ | CoIR (9 tasks overall) | Avg NDCG@10 | **49.19** | -0.3pp |
56
+ | CosQA (out-of-distribution) | NDCG@10 | **0.354** | **+2.5pp** |
57
  | Hard eval (55 confusable pairs) | Recall@1 | **92.7%** | +1.8pp* |
58
 
59
  *Hard eval improvement from full pipeline (LoRA + NL enrichment + doc comments), not LoRA alone.
 
62
 
63
  | Language | Base E5 | This Model | Delta |
64
  |----------|---------|------------|-------|
65
+ | Go | 0.624 | **0.785** | +0.161 |
66
+ | Java | 0.571 | **0.656** | +0.085 |
67
+ | JavaScript | 0.487 | **0.545** | +0.058 |
68
+ | Ruby | 0.526 | **0.613** | +0.087 |
69
+ | Python | 0.888 | **0.975** | +0.087 |
70
+ | PHP | 0.601 | **0.667** | +0.066 |
71
 
72
  ### CoIR Leaderboard Context
73
 
74
+ Among 110M-class models on the [CoIR benchmark](https://archersama.github.io/coir/) (ACL 2025), E5-base-v2 is already #7 out of 13 entries. This LoRA fine-tune nearly matches the base model's generalist performance (49.19 vs 49.48) while dramatically improving code search (+8.0pp CSN). It extends the lead over other 110M models (BGE-Base 42.77, GTE-Base 36.75, UniXcoder 37.33) while remaining CPU-runnable in <100ms per query.
75
 
76
  ## Training
77
 
78
  - **Method:** LoRA (rank 16) fine-tuning of E5-base-v2
79
+ - **Data:** 200,000 pairs from 9 languages (CSN: Go/Java/JS/Ruby/Python/PHP + Stack: Rust/TS/C++), with CoRNStack hard negatives
80
+ - **Loss:** CachedGISTEmbedLoss (guide model: base E5, margin 0.05) + MatryoshkaLoss (768/384/192/128)
81
+ - **Training time:** ~7 hours on A6000
82
  - **Epochs:** 1
83
+ - **Hardware:** NVIDIA A6000 48GB
84
 
85
+ ### Why v7?
86
 
87
+ We trained 10+ LoRA variants with different data sizes, ranks, epochs, losses, and data mixes. v7 uses GISTEmbedLoss with hard negatives to prevent the generalist degradation seen in earlier versions:
88
 
89
+ | Config | Data | Loss | CSN NDCG@10 | CoIR Overall |
90
+ |--------|------|------|-------------|--------------|
91
+ | Base E5 | — | — | 0.627 | 49.48 |
92
+ | v5 (previous) | 166k CSN, MNR | MNR | 0.683 | 48.67 |
93
+ | **v7 (current)** | **200k 9-lang, hard negs** | **GIST+Matryoshka** | **0.707** | **49.19** |
94
+ | v4 | 166k CSN | MNR, 3ep | 0.695 | — (over-specialized) |
 
95
 
96
+ v5 improved CSN but degraded generalist tasks (-0.81pp overall). v7 uses GISTEmbedLoss (false negative filtering via frozen guide model) and hard negatives (CoRNStack recipe) to recover most of the generalist loss while pushing CSN even higher.
97
 
98
  ## Usage
99
 
 
150
 
151
  ## Limitations
152
 
153
+ - Trained on 9 languages (Go, Java, JavaScript, Ruby, Python, PHP, Rust, TypeScript, C++). Other languages rely on E5's base capability.
154
  - English queries only. E5-base-v2's multilingual capability is untested for code search.
155
  - 512 token max sequence length. Long functions are truncated.
156
+ - Adversarial confusable-function pairs (e.g., 6 sorting variants) regress vs base model. Real-world NL→code retrieval improves.
157
 
158
  ## Citation
159