Feature Extraction
sentence-transformers
Safetensors
English
code
roberta
python
javascript
go
java
ruby
php
code-search
code-embeddings
multilingual
matryoshka
unixcoder
mteb
Eval Results (legacy)
text-embeddings-inference
Instructions to use divakantpandey/code-embed-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use divakantpandey/code-embed-v2 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("divakantpandey/code-embed-v2") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
Release CodeEmbed v2: Multilingual code embeddings (MTEB 40.64% NDCG@10)
Browse files- 1_Pooling/config.json +5 -0
- 2_Dense/config.json +8 -0
- 2_Dense/model.safetensors +3 -0
- 3_Dense/config.json +8 -0
- 3_Dense/model.safetensors +3 -0
- 4_Normalize/config.json +4 -0
- LICENSE +49 -0
- README.md +343 -0
- backbone/model.safetensors +1 -1
- backbone/tokenizer_config.json +9 -2
- code_embed_config.json +1 -1
- config.json +31 -0
- config_sentence_transformers.json +14 -0
- model.safetensors +3 -0
- modules.json +32 -0
- projection_head.pt +1 -1
- pycode_embed_config.json +1 -1
- sentence_bert_config.json +11 -0
- tokenizer_config.json +9 -2
1_Pooling/config.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"embedding_dimension": 768,
|
| 3 |
+
"pooling_mode": "mean",
|
| 4 |
+
"include_prompt": true
|
| 5 |
+
}
|
2_Dense/config.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"in_features": 768,
|
| 3 |
+
"out_features": 1536,
|
| 4 |
+
"bias": true,
|
| 5 |
+
"activation_function": "torch.nn.modules.activation.GELU",
|
| 6 |
+
"module_input_name": "sentence_embedding",
|
| 7 |
+
"module_output_name": "sentence_embedding"
|
| 8 |
+
}
|
2_Dense/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:84c6062f52b38491ffab8f5d8765889210e1710b867ea202830d86104249dab8
|
| 3 |
+
size 4724896
|
3_Dense/config.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"in_features": 1536,
|
| 3 |
+
"out_features": 1536,
|
| 4 |
+
"bias": true,
|
| 5 |
+
"activation_function": "torch.nn.modules.linear.Identity",
|
| 6 |
+
"module_input_name": "sentence_embedding",
|
| 7 |
+
"module_output_name": "sentence_embedding"
|
| 8 |
+
}
|
3_Dense/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d74a1b8b40906a3b9b125c6f01af726354406e19caeabac9d983bee25a597cc4
|
| 3 |
+
size 9443488
|
4_Normalize/config.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"module_input_name": "sentence_embedding",
|
| 3 |
+
"module_output_name": "sentence_embedding"
|
| 4 |
+
}
|
LICENSE
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Creative Commons Attribution-NonCommercial 4.0 International Public License
|
| 2 |
+
|
| 3 |
+
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
|
| 4 |
+
|
| 5 |
+
Section 1 – Definitions.
|
| 6 |
+
|
| 7 |
+
a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor.
|
| 8 |
+
b. Commercial means primarily intended for or directed towards commercial advantage or monetary compensation.
|
| 9 |
+
c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized.
|
| 10 |
+
d. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License (including CodeEmbed model weights, architectures, and associated materials).
|
| 11 |
+
e. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
|
| 12 |
+
f. Licensor means Divakant Pandey.
|
| 13 |
+
g. NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation.
|
| 14 |
+
h. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation.
|
| 15 |
+
i. You means the individual or entity exercising the Licensed Rights under this Public License.
|
| 16 |
+
|
| 17 |
+
Section 2 – Scope.
|
| 18 |
+
|
| 19 |
+
a. License grant.
|
| 20 |
+
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
|
| 21 |
+
a. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
|
| 22 |
+
b. produce, reproduce, and Share Adapted Material for NonCommercial purposes only.
|
| 23 |
+
2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
|
| 24 |
+
3. Term. The term of this Public License is specified in Section 6(a).
|
| 25 |
+
4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so.
|
| 26 |
+
|
| 27 |
+
b. Other rights.
|
| 28 |
+
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights.
|
| 29 |
+
2. Patent and trademark rights are not licensed under this Public License.
|
| 30 |
+
|
| 31 |
+
Section 3 – License Conditions.
|
| 32 |
+
|
| 33 |
+
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
|
| 34 |
+
|
| 35 |
+
a. Attribution.
|
| 36 |
+
1. If You Share the Licensed Material (including in modified form), You must:
|
| 37 |
+
a. retain the identification of the creator(s) of the Licensed Material: Divakant Pandey (https://github.com/divakantpandey);
|
| 38 |
+
b. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
|
| 39 |
+
c. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
|
| 40 |
+
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material.
|
| 41 |
+
|
| 42 |
+
b. NonCommercial.
|
| 43 |
+
You may not exercise any of the Licensed Rights granted under Section 2(a) for Commercial purposes.
|
| 44 |
+
|
| 45 |
+
For inquiries regarding commercial licensing, enterprise deployment, or fine-tuning partnerships:
|
| 46 |
+
Contact: Divakant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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
- code
|
| 5 |
+
tags:
|
| 6 |
+
- python
|
| 7 |
+
- javascript
|
| 8 |
+
- go
|
| 9 |
+
- java
|
| 10 |
+
- ruby
|
| 11 |
+
- php
|
| 12 |
+
- code-search
|
| 13 |
+
- code-embeddings
|
| 14 |
+
- multilingual
|
| 15 |
+
- sentence-transformers
|
| 16 |
+
- matryoshka
|
| 17 |
+
- unixcoder
|
| 18 |
+
- mteb
|
| 19 |
+
- feature-extraction
|
| 20 |
+
license: cc-by-nc-4.0
|
| 21 |
+
pipeline_tag: feature-extraction
|
| 22 |
+
library_name: sentence-transformers
|
| 23 |
+
metrics:
|
| 24 |
+
- mrr
|
| 25 |
+
- ndcg
|
| 26 |
+
- map
|
| 27 |
+
model-index:
|
| 28 |
+
- name: code-embed-v2
|
| 29 |
+
results:
|
| 30 |
+
- task:
|
| 31 |
+
type: retrieval
|
| 32 |
+
name: MTEB(Code, v1)
|
| 33 |
+
dataset:
|
| 34 |
+
name: MTEB(Code, v1) Macro-Average
|
| 35 |
+
type: mteb/code
|
| 36 |
+
metrics:
|
| 37 |
+
- type: ndcg_at_10
|
| 38 |
+
value: 0.4064
|
| 39 |
+
name: NDCG@10 (meanTask)
|
| 40 |
+
- type: mrr_at_10
|
| 41 |
+
value: 0.3781
|
| 42 |
+
name: MRR@10 (meanTask)
|
| 43 |
+
- task:
|
| 44 |
+
type: retrieval
|
| 45 |
+
name: CoIR
|
| 46 |
+
dataset:
|
| 47 |
+
name: CoIR Benchmark Macro-Average
|
| 48 |
+
type: coir
|
| 49 |
+
metrics:
|
| 50 |
+
- type: ndcg_at_10
|
| 51 |
+
value: 0.3729
|
| 52 |
+
name: NDCG@10 (meanTask)
|
| 53 |
+
- type: mrr_at_10
|
| 54 |
+
value: 0.3478
|
| 55 |
+
name: MRR@10 (meanTask)
|
| 56 |
+
- task:
|
| 57 |
+
type: retrieval
|
| 58 |
+
name: CoREB(v1)
|
| 59 |
+
dataset:
|
| 60 |
+
name: CoREB(v1) Macro-Average
|
| 61 |
+
type: coreb
|
| 62 |
+
metrics:
|
| 63 |
+
- type: ndcg_at_10
|
| 64 |
+
value: 0.2711
|
| 65 |
+
name: NDCG@10 (meanTask)
|
| 66 |
+
- task:
|
| 67 |
+
type: retrieval
|
| 68 |
+
name: Code Search
|
| 69 |
+
dataset:
|
| 70 |
+
name: CodeSearchNetRetrieval
|
| 71 |
+
type: code_search_net
|
| 72 |
+
split: test
|
| 73 |
+
metrics:
|
| 74 |
+
- type: ndcg_at_10
|
| 75 |
+
value: 0.7778
|
| 76 |
+
name: NDCG@10 (Multilingual)
|
| 77 |
+
- type: mrr_at_10
|
| 78 |
+
value: 0.7385
|
| 79 |
+
name: MRR@10 (Multilingual)
|
| 80 |
+
- task:
|
| 81 |
+
type: retrieval
|
| 82 |
+
name: COIR Code Search
|
| 83 |
+
dataset:
|
| 84 |
+
name: COIRCodeSearchNetRetrieval
|
| 85 |
+
type: coir_code_search_net
|
| 86 |
+
split: test
|
| 87 |
+
metrics:
|
| 88 |
+
- type: ndcg_at_10
|
| 89 |
+
value: 0.7443
|
| 90 |
+
name: NDCG@10 (Multilingual)
|
| 91 |
+
- type: mrr_at_10
|
| 92 |
+
value: 0.7137
|
| 93 |
+
name: MRR@10 (Multilingual)
|
| 94 |
+
- task:
|
| 95 |
+
type: retrieval
|
| 96 |
+
name: StackOverflow QA
|
| 97 |
+
dataset:
|
| 98 |
+
name: StackOverflowQA
|
| 99 |
+
type: stackoverflow_qa
|
| 100 |
+
split: test
|
| 101 |
+
metrics:
|
| 102 |
+
- type: ndcg_at_10
|
| 103 |
+
value: 0.5530
|
| 104 |
+
name: NDCG@10
|
| 105 |
+
- type: mrr_at_10
|
| 106 |
+
value: 0.5159
|
| 107 |
+
name: MRR@10
|
| 108 |
+
- task:
|
| 109 |
+
type: retrieval
|
| 110 |
+
name: Code Feedback (Single-Turn)
|
| 111 |
+
dataset:
|
| 112 |
+
name: CodeFeedbackST
|
| 113 |
+
type: code_feedback_st
|
| 114 |
+
split: test
|
| 115 |
+
metrics:
|
| 116 |
+
- type: ndcg_at_10
|
| 117 |
+
value: 0.4693
|
| 118 |
+
name: NDCG@10
|
| 119 |
+
- type: mrr_at_10
|
| 120 |
+
value: 0.4251
|
| 121 |
+
name: MRR@10
|
| 122 |
+
- task:
|
| 123 |
+
type: retrieval
|
| 124 |
+
name: Code-to-Code Search
|
| 125 |
+
dataset:
|
| 126 |
+
name: CodeSearchNetCCRetrieval
|
| 127 |
+
type: code_search_net_cc
|
| 128 |
+
split: test
|
| 129 |
+
metrics:
|
| 130 |
+
- type: ndcg_at_10
|
| 131 |
+
value: 0.4170
|
| 132 |
+
name: NDCG@10
|
| 133 |
+
- type: mrr_at_10
|
| 134 |
+
value: 0.3784
|
| 135 |
+
name: MRR@10
|
| 136 |
+
- task:
|
| 137 |
+
type: retrieval
|
| 138 |
+
name: Code Edit Search
|
| 139 |
+
dataset:
|
| 140 |
+
name: CodeEditSearchRetrieval
|
| 141 |
+
type: code_edit_search
|
| 142 |
+
split: train
|
| 143 |
+
metrics:
|
| 144 |
+
- type: ndcg_at_10
|
| 145 |
+
value: 0.3703
|
| 146 |
+
name: NDCG@10
|
| 147 |
+
- type: mrr_at_10
|
| 148 |
+
value: 0.3283
|
| 149 |
+
name: MRR@10
|
| 150 |
+
- task:
|
| 151 |
+
type: retrieval
|
| 152 |
+
name: Cross-Language Translation
|
| 153 |
+
dataset:
|
| 154 |
+
name: CodeTransOceanContest
|
| 155 |
+
type: code_trans_ocean_contest
|
| 156 |
+
split: test
|
| 157 |
+
metrics:
|
| 158 |
+
- type: ndcg_at_10
|
| 159 |
+
value: 0.3640
|
| 160 |
+
name: NDCG@10
|
| 161 |
+
- type: mrr_at_10
|
| 162 |
+
value: 0.3150
|
| 163 |
+
name: MRR@10
|
| 164 |
+
- task:
|
| 165 |
+
type: retrieval
|
| 166 |
+
name: Framework Translation
|
| 167 |
+
dataset:
|
| 168 |
+
name: CodeTransOceanDL
|
| 169 |
+
type: code_trans_ocean_dl
|
| 170 |
+
split: test
|
| 171 |
+
metrics:
|
| 172 |
+
- type: ndcg_at_10
|
| 173 |
+
value: 0.3439
|
| 174 |
+
name: NDCG@10
|
| 175 |
+
- type: mrr_at_10
|
| 176 |
+
value: 0.2204
|
| 177 |
+
name: MRR@10
|
| 178 |
+
- task:
|
| 179 |
+
type: retrieval
|
| 180 |
+
name: Text to SQL
|
| 181 |
+
dataset:
|
| 182 |
+
name: SyntheticText2SQL
|
| 183 |
+
type: synthetic_text2sql
|
| 184 |
+
split: test
|
| 185 |
+
metrics:
|
| 186 |
+
- type: ndcg_at_10
|
| 187 |
+
value: 0.3277
|
| 188 |
+
name: NDCG@10
|
| 189 |
+
- type: mrr_at_10
|
| 190 |
+
value: 0.2513
|
| 191 |
+
name: MRR@10
|
| 192 |
+
- task:
|
| 193 |
+
type: retrieval
|
| 194 |
+
name: Code Feedback (Multi-Turn)
|
| 195 |
+
dataset:
|
| 196 |
+
name: CodeFeedbackMT
|
| 197 |
+
type: code_feedback_mt
|
| 198 |
+
split: test
|
| 199 |
+
metrics:
|
| 200 |
+
- type: ndcg_at_10
|
| 201 |
+
value: 0.3188
|
| 202 |
+
name: NDCG@10
|
| 203 |
+
- type: mrr_at_10
|
| 204 |
+
value: 0.2882
|
| 205 |
+
name: MRR@10
|
| 206 |
+
- task:
|
| 207 |
+
type: retrieval
|
| 208 |
+
name: Web Query Code Search
|
| 209 |
+
dataset:
|
| 210 |
+
name: CosQA
|
| 211 |
+
type: cosqa
|
| 212 |
+
split: test
|
| 213 |
+
metrics:
|
| 214 |
+
- type: ndcg_at_10
|
| 215 |
+
value: 0.1599
|
| 216 |
+
name: NDCG@10
|
| 217 |
+
- type: mrr_at_10
|
| 218 |
+
value: 0.1135
|
| 219 |
+
name: MRR@10
|
| 220 |
+
- task:
|
| 221 |
+
type: retrieval
|
| 222 |
+
name: Algorithmic Problem Retrieval
|
| 223 |
+
dataset:
|
| 224 |
+
name: AppsRetrieval
|
| 225 |
+
type: apps_retrieval
|
| 226 |
+
split: test
|
| 227 |
+
metrics:
|
| 228 |
+
- type: ndcg_at_10
|
| 229 |
+
value: 0.0306
|
| 230 |
+
name: NDCG@10
|
| 231 |
+
- type: mrr_at_10
|
| 232 |
+
value: 0.0241
|
| 233 |
+
name: MRR@10
|
| 234 |
+
---
|
| 235 |
+
|
| 236 |
+
# 💻 code-embed-v2
|
| 237 |
+
|
| 238 |
+
**CodeEmbed v2** is a lightweight, state-of-the-art multilingual code embedding model (≤131M parameters) developed by **[Divakant Pandey](https://github.com/divakantpandey)**. Specialized for semantic code search, code-to-code retrieval, text-to-SQL mapping, and repository navigation across **6 major programming languages** with an extended **8,192 token context window** and native **Matryoshka Representation Learning (MRL)**.
|
| 239 |
+
|
| 240 |
+
---
|
| 241 |
+
|
| 242 |
+
## 🚀 Highlights & Functional Capabilities
|
| 243 |
+
|
| 244 |
+
- **Multilingual Support**: High-accuracy semantic search across **Python, JavaScript, Go, Java, Ruby, and PHP**.
|
| 245 |
+
- **Extended Context**: Full **8,192 token context window** allowing whole-file, multi-function, and long class embeddings without aggressive truncation.
|
| 246 |
+
- **Matryoshka Representation Learning (MRL)**: Embeddings can be dynamically truncated from **1536** down to **768, 384, 256, 128, or 64 dimensions** with negligible loss in accuracy, enabling significant vector database memory and latency savings.
|
| 247 |
+
- **Compact & Efficient**: ~131M parameters (**~484 MB** safetensors footprint) optimized for low-latency CPU inference and fast GPU batch indexing.
|
| 248 |
+
- **Universal Compatibility**: Works out of the box with `sentence-transformers`, `transformers`, and PyTorch.
|
| 249 |
+
|
| 250 |
+
---
|
| 251 |
+
|
| 252 |
+
## 📊 Benchmark Performance
|
| 253 |
+
|
| 254 |
+
CodeEmbed v2 was thoroughly evaluated across **18 official benchmark tasks** comprising the primary code retrieval suites on the Massive Text Embedding Benchmark (MTEB):
|
| 255 |
+
|
| 256 |
+
### 🏆 Benchmark Suite Macro-Averages (`meanTask`)
|
| 257 |
+
|
| 258 |
+
| Benchmark Suite | Total Tasks | Metric | Official Macro-Average | Coverage |
|
| 259 |
+
| :--- | :---: | :---: | :---: | :---: |
|
| 260 |
+
| **`MTEB(Code, v1)`** | **12 / 12** | **NDCG@10** | **`40.64%`** | **100% (Complete)** |
|
| 261 |
+
| **`CoIR` (Code IR)** | **10 / 10** | **NDCG@10** | **`37.29%`** | **100% (Complete)** |
|
| 262 |
+
| **`CoREB(v1)`** | **6 / 6** | **NDCG@10** | **`27.11%`** | **100% (Complete)** |
|
| 263 |
+
|
| 264 |
+
### 📋 Detailed Task-by-Task Scorecard
|
| 265 |
+
|
| 266 |
+
| Task | Category | NDCG@10 | MRR@10 | Evaluation Scope |
|
| 267 |
+
| :--- | :--- | :---: | :---: | :--- |
|
| 268 |
+
| **`CodeSearchNetRetrieval`** | Text-to-Code Search | **77.78%** | 73.85% | 6 Languages (Python, JS, Go, Java, Ruby, PHP) |
|
| 269 |
+
| **`COIRCodeSearchNetRetrieval`** | Multilingual Search | **74.43%** | 71.37% | Full-scale 300k+ codebase corpus |
|
| 270 |
+
| **`CorebC2TReranking`** | Code-to-Text Reranking | **66.74%** | 57.59% | Cross-lingual code description ranking |
|
| 271 |
+
| **`StackOverflowQA`** | Developer Q&A Search | **55.30%** | 51.59% | Real-world developer query matching |
|
| 272 |
+
| **`CodeFeedbackST`** | Instruction Feedback | **46.93%** | 42.51% | Single-turn instruction and code feedback |
|
| 273 |
+
| **`CodeSearchNetCCRetrieval`** | Code-to-Code Search | **41.70%** | 37.84% | Cross-language code function matching |
|
| 274 |
+
| **`CodeEditSearchRetrieval`** | Edit / Patch Search | **37.03%** | 32.83% | 13 Git commit and patch subsets |
|
| 275 |
+
| **`CorebC2CReranking`** | Code-to-Code Reranking | **36.87%** | 34.40% | Direct code snippet similarity ranking |
|
| 276 |
+
| **`CodeTransOceanContest`** | Code Translation | **36.40%** | 31.50% | Cross-language algorithmic translation |
|
| 277 |
+
| **`CodeTransOceanDL`** | Framework Translation | **34.39%** | 22.04% | Deep learning API cross-matching |
|
| 278 |
+
| **`SyntheticText2SQL`** | Text-to-SQL | **32.77%** | 25.13% | Natural language to structured SQL queries |
|
| 279 |
+
| **`CodeFeedbackMT`** | Multi-Turn Feedback | **31.88%** | 28.82% | Conversational multi-turn code context |
|
| 280 |
+
| **`CorebT2CReranking`** | Text-to-Code Reranking | **26.44%** | 27.65% | Natural language to code reranking |
|
| 281 |
+
| **`CorebC2TRetrieval`** | Code-to-Text Search | **22.32%** | 18.83% | Source code to documentation retrieval |
|
| 282 |
+
| **`CosQA`** | Web Query Code Search | **15.99%** | 11.35% | Real-world noisy web search queries |
|
| 283 |
+
| **`CorebT2CRetrieval`** | Text-to-Code Search | **7.45%** | 8.10% | Zero-shot query to code retrieval |
|
| 284 |
+
| **`AppsRetrieval`** | Algorithmic Problem Search | **3.06%** | 2.41% | Hard algorithmic programming specifications |
|
| 285 |
+
| **`CorebC2CRetrieval`** | Code-to-Code Retrieval | **2.87%** | 2.25% | Direct code-to-code corpus retrieval |
|
| 286 |
+
|
| 287 |
+
---
|
| 288 |
+
|
| 289 |
+
## 💻 Quickstart Usage
|
| 290 |
+
|
| 291 |
+
### 1. Basic Semantic Code Search with `sentence-transformers`
|
| 292 |
+
|
| 293 |
+
```python
|
| 294 |
+
from sentence_transformers import SentenceTransformer
|
| 295 |
+
|
| 296 |
+
# Load model directly from Hugging Face Hub
|
| 297 |
+
model = SentenceTransformer("divakantpandey/code-embed-v2")
|
| 298 |
+
|
| 299 |
+
queries = [
|
| 300 |
+
"binary search implementation",
|
| 301 |
+
"fetch json from api endpoint",
|
| 302 |
+
"goroutine channel worker pool"
|
| 303 |
+
]
|
| 304 |
+
|
| 305 |
+
code_snippets = [
|
| 306 |
+
"def binary_search(arr, target):\n left, right = 0, len(arr) - 1\n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target: return mid\n elif arr[mid] < target: left = mid + 1\n else: right = mid - 1\n return -1",
|
| 307 |
+
"async function fetchJSON(url) {\n const response = await fetch(url);\n return await response.json();\n}",
|
| 308 |
+
"func worker(id int, jobs <-chan int, results chan<- int) {\n for j := range jobs {\n results <- j * 2\n }\n}"
|
| 309 |
+
]
|
| 310 |
+
|
| 311 |
+
# Generate normalized embeddings
|
| 312 |
+
query_embeddings = model.encode(queries, normalize_embeddings=True)
|
| 313 |
+
code_embeddings = model.encode(code_snippets, normalize_embeddings=True)
|
| 314 |
+
|
| 315 |
+
# Compute cosine similarity
|
| 316 |
+
similarity_matrix = query_embeddings @ code_embeddings.T
|
| 317 |
+
print(similarity_matrix)
|
| 318 |
+
```
|
| 319 |
+
|
| 320 |
+
### 2. Matryoshka Dimension Truncation (Adaptive Dimensions)
|
| 321 |
+
|
| 322 |
+
CodeEmbed v2 natively supports Matryoshka Representation Learning. You can truncate embeddings to smaller dimensions (e.g., 768, 384, 256) for faster vector database indexing with minimal accuracy impact:
|
| 323 |
+
|
| 324 |
+
```python
|
| 325 |
+
# Truncate to 768 dimensions (50% storage & compute reduction)
|
| 326 |
+
compact_query_embs = model.encode(queries, truncate_dim=768, normalize_embeddings=True)
|
| 327 |
+
compact_code_embs = model.encode(code_snippets, truncate_dim=768, normalize_embeddings=True)
|
| 328 |
+
|
| 329 |
+
similarity = compact_query_embs @ compact_code_embs.T
|
| 330 |
+
```
|
| 331 |
+
|
| 332 |
+
---
|
| 333 |
+
|
| 334 |
+
## 📜 License & Commercial Terms
|
| 335 |
+
|
| 336 |
+
This model and its associated weights are licensed under the **Creative Commons Attribution-NonCommercial 4.0 International Public License (CC-BY-NC 4.0)**.
|
| 337 |
+
|
| 338 |
+
- **Non-Commercial Use:** Free for academic research, educational use, personal exploration, open-source evaluations, and non-commercial benchmarking with appropriate attribution.
|
| 339 |
+
- **Attribution:** Please attribute **Divakant Pandey** and reference the repository at [https://github.com/divakantpandey/code-embed](https://github.com/divakantpandey/code-embed).
|
| 340 |
+
- **Commercial Licensing:** To license CodeEmbed v2 for commercial products, enterprise SaaS applications, closed-source systems, or proprietary developer tools, please contact:
|
| 341 |
+
- **Licensor / Maintainer:** Divakant Pandey
|
| 342 |
+
- **Email:** `divakant01@gmail.com`
|
| 343 |
+
- **GitHub:** [@divakantpandey](https://github.com/divakantpandey)
|
backbone/model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 503741296
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cee5b2e4cde154164d9dbabab7f8dedaecc81f5cc9e605b0ca1774ef38577837
|
| 3 |
size 503741296
|
backbone/tokenizer_config.json
CHANGED
|
@@ -5,13 +5,20 @@
|
|
| 5 |
"cls_token": "<s>",
|
| 6 |
"eos_token": "</s>",
|
| 7 |
"errors": "replace",
|
| 8 |
-
"is_local":
|
| 9 |
"local_files_only": false,
|
| 10 |
"mask_token": "<mask>",
|
| 11 |
-
"
|
|
|
|
|
|
|
| 12 |
"pad_token": "<pad>",
|
|
|
|
|
|
|
| 13 |
"sep_token": "</s>",
|
|
|
|
| 14 |
"tokenizer_class": "RobertaTokenizer",
|
| 15 |
"trim_offsets": true,
|
|
|
|
|
|
|
| 16 |
"unk_token": "<unk>"
|
| 17 |
}
|
|
|
|
| 5 |
"cls_token": "<s>",
|
| 6 |
"eos_token": "</s>",
|
| 7 |
"errors": "replace",
|
| 8 |
+
"is_local": true,
|
| 9 |
"local_files_only": false,
|
| 10 |
"mask_token": "<mask>",
|
| 11 |
+
"max_length": 1024,
|
| 12 |
+
"model_max_length": 8192,
|
| 13 |
+
"pad_to_multiple_of": null,
|
| 14 |
"pad_token": "<pad>",
|
| 15 |
+
"pad_token_type_id": 0,
|
| 16 |
+
"padding_side": "right",
|
| 17 |
"sep_token": "</s>",
|
| 18 |
+
"stride": 0,
|
| 19 |
"tokenizer_class": "RobertaTokenizer",
|
| 20 |
"trim_offsets": true,
|
| 21 |
+
"truncation_side": "right",
|
| 22 |
+
"truncation_strategy": "longest_first",
|
| 23 |
"unk_token": "<unk>"
|
| 24 |
}
|
code_embed_config.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"base_model_name_or_path": "
|
| 3 |
"backbone_hidden_size": 768,
|
| 4 |
"embedding_dim": 1536,
|
| 5 |
"projection_hidden_dim": 1536,
|
|
|
|
| 1 |
{
|
| 2 |
+
"base_model_name_or_path": "checkpoints_v2/stage2/last_model/backbone",
|
| 3 |
"backbone_hidden_size": 768,
|
| 4 |
"embedding_dim": 1536,
|
| 5 |
"projection_hidden_dim": 1536,
|
config.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_cross_attention": false,
|
| 3 |
+
"architectures": [
|
| 4 |
+
"RobertaModel"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"bos_token_id": 0,
|
| 8 |
+
"classifier_dropout": null,
|
| 9 |
+
"dtype": "float32",
|
| 10 |
+
"eos_token_id": 2,
|
| 11 |
+
"gradient_checkpointing": false,
|
| 12 |
+
"hidden_act": "gelu",
|
| 13 |
+
"hidden_dropout_prob": 0.1,
|
| 14 |
+
"hidden_size": 768,
|
| 15 |
+
"initializer_range": 0.02,
|
| 16 |
+
"intermediate_size": 3072,
|
| 17 |
+
"is_decoder": false,
|
| 18 |
+
"layer_norm_eps": 1e-05,
|
| 19 |
+
"max_position_embeddings": 1026,
|
| 20 |
+
"model_type": "roberta",
|
| 21 |
+
"num_attention_heads": 12,
|
| 22 |
+
"num_hidden_layers": 12,
|
| 23 |
+
"output_past": true,
|
| 24 |
+
"pad_token_id": 1,
|
| 25 |
+
"position_embedding_type": "absolute",
|
| 26 |
+
"tie_word_embeddings": true,
|
| 27 |
+
"transformers_version": "5.20.1",
|
| 28 |
+
"type_vocab_size": 10,
|
| 29 |
+
"use_cache": true,
|
| 30 |
+
"vocab_size": 51416
|
| 31 |
+
}
|
config_sentence_transformers.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"__version__": {
|
| 3 |
+
"pytorch": "2.6.0+cu124",
|
| 4 |
+
"sentence_transformers": "6.1.0",
|
| 5 |
+
"transformers": "5.20.1"
|
| 6 |
+
},
|
| 7 |
+
"default_prompt_name": null,
|
| 8 |
+
"model_type": "SentenceTransformer",
|
| 9 |
+
"prompts": {
|
| 10 |
+
"document": "",
|
| 11 |
+
"query": ""
|
| 12 |
+
},
|
| 13 |
+
"similarity_fn_name": "cosine"
|
| 14 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cee5b2e4cde154164d9dbabab7f8dedaecc81f5cc9e605b0ca1774ef38577837
|
| 3 |
+
size 503741296
|
modules.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"idx": 0,
|
| 4 |
+
"name": "0",
|
| 5 |
+
"path": "",
|
| 6 |
+
"type": "sentence_transformers.base.modules.transformer.Transformer"
|
| 7 |
+
},
|
| 8 |
+
{
|
| 9 |
+
"idx": 1,
|
| 10 |
+
"name": "1",
|
| 11 |
+
"path": "1_Pooling",
|
| 12 |
+
"type": "sentence_transformers.sentence_transformer.modules.pooling.Pooling"
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"idx": 2,
|
| 16 |
+
"name": "2",
|
| 17 |
+
"path": "2_Dense",
|
| 18 |
+
"type": "sentence_transformers.base.modules.dense.Dense"
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"idx": 3,
|
| 22 |
+
"name": "3",
|
| 23 |
+
"path": "3_Dense",
|
| 24 |
+
"type": "sentence_transformers.base.modules.dense.Dense"
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"idx": 4,
|
| 28 |
+
"name": "4",
|
| 29 |
+
"path": "4_Normalize",
|
| 30 |
+
"type": "sentence_transformers.base.modules.normalize.Normalize"
|
| 31 |
+
}
|
| 32 |
+
]
|
projection_head.pt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 14170320
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cab1e7ca82bb911a0b6362f2d543ae62d7053c74db66be77563faf8334b9d917
|
| 3 |
size 14170320
|
pycode_embed_config.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"base_model_name_or_path": "
|
| 3 |
"backbone_hidden_size": 768,
|
| 4 |
"embedding_dim": 1536,
|
| 5 |
"projection_hidden_dim": 1536,
|
|
|
|
| 1 |
{
|
| 2 |
+
"base_model_name_or_path": "checkpoints_v2/stage2/last_model/backbone",
|
| 3 |
"backbone_hidden_size": 768,
|
| 4 |
"embedding_dim": 1536,
|
| 5 |
"projection_hidden_dim": 1536,
|
sentence_bert_config.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"transformer_task": "feature-extraction",
|
| 3 |
+
"modality_config": {
|
| 4 |
+
"text": {
|
| 5 |
+
"method": "forward",
|
| 6 |
+
"method_output_name": "last_hidden_state"
|
| 7 |
+
}
|
| 8 |
+
},
|
| 9 |
+
"module_output_name": "token_embeddings",
|
| 10 |
+
"max_seq_length": 8192
|
| 11 |
+
}
|
tokenizer_config.json
CHANGED
|
@@ -5,13 +5,20 @@
|
|
| 5 |
"cls_token": "<s>",
|
| 6 |
"eos_token": "</s>",
|
| 7 |
"errors": "replace",
|
| 8 |
-
"is_local":
|
| 9 |
"local_files_only": false,
|
| 10 |
"mask_token": "<mask>",
|
| 11 |
-
"
|
|
|
|
|
|
|
| 12 |
"pad_token": "<pad>",
|
|
|
|
|
|
|
| 13 |
"sep_token": "</s>",
|
|
|
|
| 14 |
"tokenizer_class": "RobertaTokenizer",
|
| 15 |
"trim_offsets": true,
|
|
|
|
|
|
|
| 16 |
"unk_token": "<unk>"
|
| 17 |
}
|
|
|
|
| 5 |
"cls_token": "<s>",
|
| 6 |
"eos_token": "</s>",
|
| 7 |
"errors": "replace",
|
| 8 |
+
"is_local": true,
|
| 9 |
"local_files_only": false,
|
| 10 |
"mask_token": "<mask>",
|
| 11 |
+
"max_length": 1024,
|
| 12 |
+
"model_max_length": 8192,
|
| 13 |
+
"pad_to_multiple_of": null,
|
| 14 |
"pad_token": "<pad>",
|
| 15 |
+
"pad_token_type_id": 0,
|
| 16 |
+
"padding_side": "right",
|
| 17 |
"sep_token": "</s>",
|
| 18 |
+
"stride": 0,
|
| 19 |
"tokenizer_class": "RobertaTokenizer",
|
| 20 |
"trim_offsets": true,
|
| 21 |
+
"truncation_side": "right",
|
| 22 |
+
"truncation_strategy": "longest_first",
|
| 23 |
"unk_token": "<unk>"
|
| 24 |
}
|