Sentence Similarity
sentence-transformers
ONNX
English
code
bert
code-search
embeddings
LoRA
E5
cqs
Eval Results
text-embeddings-inference
Instructions to use jamie8johnson/e5-base-v2-code-search with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use jamie8johnson/e5-base-v2-code-search with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("jamie8johnson/e5-base-v2-code-search") sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
Update model card with corrected eval numbers (296q expanded eval, CoIR 19-subtask avg)
Browse files
README.md
CHANGED
|
@@ -1,96 +1,63 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
language:
|
| 3 |
- en
|
| 4 |
- code
|
| 5 |
-
library_name: sentence-transformers
|
| 6 |
-
pipeline_tag: sentence-similarity
|
| 7 |
tags:
|
| 8 |
-
- sentence-transformers
|
| 9 |
-
- feature-extraction
|
| 10 |
- code-search
|
| 11 |
-
-
|
| 12 |
-
-
|
| 13 |
-
-
|
| 14 |
-
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
datasets:
|
| 19 |
- jamie8johnson/cqs-code-search-200k
|
| 20 |
-
license: apache-2.0
|
| 21 |
-
base_model: intfloat/e5-base-v2
|
| 22 |
-
model-index:
|
| 23 |
-
- name: e5-base-v2-code-search
|
| 24 |
-
results:
|
| 25 |
-
- task:
|
| 26 |
-
type: Retrieval
|
| 27 |
-
dataset:
|
| 28 |
-
type: code_search_net
|
| 29 |
-
name: CodeSearchNet
|
| 30 |
-
metrics:
|
| 31 |
-
- type: ndcg_at_10
|
| 32 |
-
value: 0.615
|
| 33 |
-
name: NDCG@10 (avg, 6 languages)
|
| 34 |
-
- task:
|
| 35 |
-
type: Retrieval
|
| 36 |
-
dataset:
|
| 37 |
-
type: custom
|
| 38 |
-
name: cqs Pipeline Eval (55 confusable functions)
|
| 39 |
-
metrics:
|
| 40 |
-
- type: recall_at_1
|
| 41 |
-
value: 0.945
|
| 42 |
-
name: Pipeline R@1
|
| 43 |
-
- type: mrr
|
| 44 |
-
value: 0.966
|
| 45 |
-
name: MRR
|
| 46 |
-
- type: recall_at_1
|
| 47 |
-
value: 0.709
|
| 48 |
-
name: Raw R@1 (no enrichment)
|
| 49 |
---
|
| 50 |
|
| 51 |
-
#
|
| 52 |
-
|
| 53 |
-
A fine-tuned code search embedding model based on [intfloat/e5-base-v2](https://huggingface.co/intfloat/e5-base-v2) (110M parameters). Trained with call-graph false-negative filtering on 200K balanced pairs across 9 programming languages.
|
| 54 |
|
| 55 |
-
Built for [cqs](https://github.com/jamie8johnson/cqs) — code intelligence and RAG for AI agents.
|
| 56 |
|
| 57 |
## Key Results
|
| 58 |
|
| 59 |
-
| Eval | Metric |
|
| 60 |
-
|------|--------|-------|
|
| 61 |
-
|
|
| 62 |
-
|
|
| 63 |
-
| Raw code embedding (no enrichment) | R@1 | **70.9%** |
|
| 64 |
-
|
|
|
|
|
| 65 |
|
| 66 |
-
|
| 67 |
|
| 68 |
-
|
| 69 |
|
| 70 |
-
|
|
|
|
|
|
|
| 71 |
- **Data:** 200K balanced pairs (22,222 per language × 9 languages) from cqs-indexed Stack repos
|
| 72 |
-
- **Key
|
| 73 |
-
- **Loss:** CachedGISTEmbedLoss + MatryoshkaLoss (768/384/192/128 dims)
|
| 74 |
-
- **LoRA:** rank 16, alpha 32
|
| 75 |
- **Epochs:** 1 (more epochs degrades enrichment compatibility)
|
| 76 |
- **Dataset:** [jamie8johnson/cqs-code-search-200k](https://huggingface.co/datasets/jamie8johnson/cqs-code-search-200k)
|
| 77 |
|
| 78 |
-
##
|
| 79 |
|
| 80 |
-
|
| 81 |
|
| 82 |
-
## Usage
|
| 83 |
|
| 84 |
-
|
| 85 |
-
# Default model in cqs v1.9.0+
|
| 86 |
-
cqs init && cqs index
|
| 87 |
|
| 88 |
-
|
| 89 |
-
export CQS_EMBEDDING_MODEL=
|
| 90 |
-
cqs index
|
| 91 |
```
|
| 92 |
|
| 93 |
-
##
|
| 94 |
|
| 95 |
```python
|
| 96 |
from sentence_transformers import SentenceTransformer
|
|
@@ -100,14 +67,6 @@ query_emb = model.encode("query: find functions that validate email addresses")
|
|
| 100 |
code_emb = model.encode("passage: def validate_email(addr): ...")
|
| 101 |
```
|
| 102 |
|
| 103 |
-
##
|
| 104 |
-
|
| 105 |
-
Go, Java, JavaScript, PHP, Python, Ruby, Rust, TypeScript, C++
|
| 106 |
-
|
| 107 |
-
## ONNX
|
| 108 |
-
|
| 109 |
-
Includes `model.onnx` for inference with ONNX Runtime (used by cqs for local GPU/CPU inference).
|
| 110 |
-
|
| 111 |
-
## Citation
|
| 112 |
|
| 113 |
-
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
language:
|
| 4 |
- en
|
| 5 |
- code
|
|
|
|
|
|
|
| 6 |
tags:
|
|
|
|
|
|
|
| 7 |
- code-search
|
| 8 |
+
- embeddings
|
| 9 |
+
- LoRA
|
| 10 |
+
- E5
|
| 11 |
+
- cqs
|
| 12 |
+
library_name: sentence-transformers
|
| 13 |
+
pipeline_tag: sentence-similarity
|
| 14 |
+
base_model: intfloat/e5-base-v2
|
| 15 |
datasets:
|
| 16 |
- jamie8johnson/cqs-code-search-200k
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
---
|
| 18 |
|
| 19 |
+
# E5-base Code Search v9-200k (LoRA fine-tuned)
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
A fine-tuned code search embedding model based on **intfloat/e5-base-v2** (110M parameters, 768 dimensions). Trained with call-graph false-negative filtering on 200K balanced pairs across 9 programming languages. Built for [cqs](https://github.com/jamie8johnson/cqs) — code intelligence and RAG for AI agents.
|
| 22 |
|
| 23 |
## Key Results
|
| 24 |
|
| 25 |
+
| Eval | Metric | This Model | BGE-large (335M) | BGE-large FT (335M) |
|
| 26 |
+
|------|--------|-----------|-------------------|---------------------|
|
| 27 |
+
| Fixture (296q, 7 languages, enriched) | R@1 | 90.5% | 90.9% | **91.6%** |
|
| 28 |
+
| Fixture | MRR | 0.948 | 0.949 | **0.952** |
|
| 29 |
+
| Raw code embedding (55q, no enrichment) | R@1 | **70.9%** | 61.8% | 66.2% |
|
| 30 |
+
| CoIR 9-task (19 subtasks) | Overall | 52.7 | 55.7 | **57.5** |
|
| 31 |
+
| CoIR CodeSearchNet (6 languages) | NDCG@10 | 0.615 | 0.721 | **0.779** |
|
| 32 |
|
| 33 |
+
**Best raw R@1 of any model tested (70.9%)** — the call-graph filtered training signal produces the sharpest code-only embeddings. On the enriched pipeline (with doc comments, call graph context, file paths), ties BGE-large at 1/3 the parameter count.
|
| 34 |
|
| 35 |
+
**Enrichment dependency:** This model is 2-3× more dependent on the cqs enrichment stack than BGE-large. Without enrichment, R@1 drops from 90.5% to 74.3% (-16.2pp). BGE-large only drops from 90.9% to 84.8% (-6.1pp). Use with cqs for best results.
|
| 36 |
|
| 37 |
+
## Training Details
|
| 38 |
+
|
| 39 |
+
- **Base Model:** intfloat/e5-base-v2 (110M params, 768 dimensions)
|
| 40 |
- **Data:** 200K balanced pairs (22,222 per language × 9 languages) from cqs-indexed Stack repos
|
| 41 |
+
- **Key Technique:** Call-graph false-negative filtering — excludes structurally related functions from contrastive negatives (zero API cost, SQLite lookup)
|
| 42 |
+
- **Loss:** CachedGISTEmbedLoss (guide: intfloat/e5-base-v2) + MatryoshkaLoss (768/384/192/128 dims)
|
| 43 |
+
- **LoRA:** rank 16, alpha 32 (targets: query, key, value, dense)
|
| 44 |
- **Epochs:** 1 (more epochs degrades enrichment compatibility)
|
| 45 |
- **Dataset:** [jamie8johnson/cqs-code-search-200k](https://huggingface.co/datasets/jamie8johnson/cqs-code-search-200k)
|
| 46 |
|
| 47 |
+
## Supported Languages
|
| 48 |
|
| 49 |
+
Go, Java, JavaScript, PHP, Python, Ruby, Rust, TypeScript, C++
|
| 50 |
|
| 51 |
+
## Usage
|
| 52 |
|
| 53 |
+
### With cqs
|
|
|
|
|
|
|
| 54 |
|
| 55 |
+
```bash
|
| 56 |
+
export CQS_EMBEDDING_MODEL=v9-200k
|
| 57 |
+
cqs index --force
|
| 58 |
```
|
| 59 |
|
| 60 |
+
### With sentence-transformers
|
| 61 |
|
| 62 |
```python
|
| 63 |
from sentence_transformers import SentenceTransformer
|
|
|
|
| 67 |
code_emb = model.encode("passage: def validate_email(addr): ...")
|
| 68 |
```
|
| 69 |
|
| 70 |
+
## License
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
+
Apache 2.0 (same as base model)
|