Update benchmark comparison tables (SOTA on CodeTrans-DL, Top-4 on CSN-Python)
Browse files
README.md
CHANGED
|
@@ -21,6 +21,16 @@ base_model: Qwen/Qwen2.5-Coder-0.5B
|
|
| 21 |
model-index:
|
| 22 |
- name: CodeCompass-Embed
|
| 23 |
results:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
- task:
|
| 25 |
type: retrieval
|
| 26 |
name: Code Retrieval
|
|
@@ -42,7 +52,8 @@ model-index:
|
|
| 42 |
|
| 43 |
## Model Highlights
|
| 44 |
|
| 45 |
-
- π **SOTA on
|
|
|
|
| 46 |
- β‘ **Efficient**: 494M parameters, runs on consumer GPUs
|
| 47 |
- π **Bidirectional Attention**: Converted from causal to bidirectional for embedding tasks
|
| 48 |
- π **Flexible Context**: Trained at 512 tokens, supports up to 32K via RoPE extrapolation
|
|
@@ -64,30 +75,46 @@ model-index:
|
|
| 64 |
|
| 65 |
We evaluate on the [CoIR Benchmark](https://github.com/CoIR-team/coir) (ACL 2025), the gold standard for code retrieval evaluation.
|
| 66 |
|
| 67 |
-
###
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
|
| 72 |
-
|
| 73 |
-
|
|
| 74 |
-
|
|
| 75 |
-
|
|
| 76 |
-
|
|
| 77 |
-
|
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
|
| 87 |
-
|
| 88 |
-
|
|
| 89 |
-
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
## Usage
|
| 93 |
|
|
@@ -111,8 +138,7 @@ model.eval()
|
|
| 111 |
def encode(texts, is_query=False):
|
| 112 |
# Add instruction prefix for queries
|
| 113 |
if is_query:
|
| 114 |
-
texts = [f"Instruct: Find the most relevant code snippet given the following query:
|
| 115 |
-
Query: {t}" for t in texts]
|
| 116 |
|
| 117 |
inputs = tokenizer(texts, padding=True, truncation=True, max_length=512, return_tensors="pt")
|
| 118 |
|
|
@@ -132,12 +158,9 @@ Query: {t}" for t in texts]
|
|
| 132 |
# Example: Code Search
|
| 133 |
query = "How to sort a list in Python"
|
| 134 |
code_snippets = [
|
| 135 |
-
"def sort_list(lst)
|
| 136 |
-
|
| 137 |
-
"def
|
| 138 |
-
return a + b",
|
| 139 |
-
"def reverse_string(s):
|
| 140 |
-
return s[::-1]",
|
| 141 |
]
|
| 142 |
|
| 143 |
query_emb = encode([query], is_query=True)
|
|
@@ -156,14 +179,10 @@ For optimal performance, use these instruction prefixes for queries:
|
|
| 156 |
|
| 157 |
| Task | Instruction Template |
|
| 158 |
|------|---------------------|
|
| 159 |
-
| NL β Code | `Instruct: Find the most relevant code snippet given the following query:
|
| 160 |
-
|
| 161 |
-
|
|
| 162 |
-
|
| 163 |
-
| Tech Q&A | `Instruct: Find the most relevant answer given the following question:
|
| 164 |
-
Query: {query}` |
|
| 165 |
-
| Text β SQL | `Instruct: Given a natural language question and schema, find the corresponding SQL query:
|
| 166 |
-
Query: {query}` |
|
| 167 |
|
| 168 |
**Note**: Document/corpus texts do NOT need instruction prefixes.
|
| 169 |
|
|
@@ -181,7 +200,7 @@ Query: {query}` |
|
|
| 181 |
|
| 182 |
## Limitations
|
| 183 |
|
| 184 |
-
- Optimized for **NL β Code** retrieval; weaker on
|
| 185 |
- Trained primarily on Python/JavaScript/Java/Go/PHP/Ruby
|
| 186 |
- May not generalize well to low-resource programming languages
|
| 187 |
|
|
|
|
| 21 |
model-index:
|
| 22 |
- name: CodeCompass-Embed
|
| 23 |
results:
|
| 24 |
+
- task:
|
| 25 |
+
type: retrieval
|
| 26 |
+
name: Code Retrieval
|
| 27 |
+
dataset:
|
| 28 |
+
type: CoIR-Retrieval/codetrans-dl
|
| 29 |
+
name: CodeTrans-DL
|
| 30 |
+
metrics:
|
| 31 |
+
- type: ndcg@10
|
| 32 |
+
value: 0.3305
|
| 33 |
+
name: NDCG@10
|
| 34 |
- task:
|
| 35 |
type: retrieval
|
| 36 |
name: Code Retrieval
|
|
|
|
| 52 |
|
| 53 |
## Model Highlights
|
| 54 |
|
| 55 |
+
- π **SOTA on CodeTrans-DL**: #1 on code translation benchmark (+20.7% over next best)
|
| 56 |
+
- π₯ **Top-4 on CodeSearchNet-Python**: NDCG@10 = 0.9228 (competitive with 400M models)
|
| 57 |
- β‘ **Efficient**: 494M parameters, runs on consumer GPUs
|
| 58 |
- π **Bidirectional Attention**: Converted from causal to bidirectional for embedding tasks
|
| 59 |
- π **Flexible Context**: Trained at 512 tokens, supports up to 32K via RoPE extrapolation
|
|
|
|
| 75 |
|
| 76 |
We evaluate on the [CoIR Benchmark](https://github.com/CoIR-team/coir) (ACL 2025), the gold standard for code retrieval evaluation.
|
| 77 |
|
| 78 |
+
### π CodeTrans-DL β State-of-the-Art
|
| 79 |
+
|
| 80 |
+
CodeCompass-Embed achieves **#1** on CodeTrans-DL (code translation between deep learning frameworks), beating all existing models by **+20.7%**.
|
| 81 |
+
|
| 82 |
+
| Rank | Model | Params | CodeTrans NDCG@10 |
|
| 83 |
+
|------|-------|--------|-------------------|
|
| 84 |
+
| **π₯ 1** | **CodeCompass-Embed (ours)** | **494M** | **0.3305** |
|
| 85 |
+
| 2 | Jina-Code-v2 | 161M | 0.2739 |
|
| 86 |
+
| 3 | SFR-Embedding-Code | 400M | 0.2683 |
|
| 87 |
+
| 4 | CodeRankEmbed | 137M | 0.2604 |
|
| 88 |
+
| 5 | BGE-M3 | 568M | 0.2194 |
|
| 89 |
+
| 6 | BGE-Base-en-v1.5 | 109M | 0.2125 |
|
| 90 |
+
| 7 | Snowflake-Arctic-Embed-L | 568M | 0.1958 |
|
| 91 |
+
| 8 | CodeT5+-110M | 110M | 0.1794 |
|
| 92 |
+
|
| 93 |
+
### CodeSearchNet-Python β Top 4
|
| 94 |
+
|
| 95 |
+
Strong performance on the primary code search benchmark (NL β Code retrieval).
|
| 96 |
+
|
| 97 |
+
| Rank | Model | Params | CSN-Python NDCG@10 |
|
| 98 |
+
|------|-------|--------|-------------------|
|
| 99 |
+
| 1 | SFR-Embedding-Code | 400M | 0.9505 |
|
| 100 |
+
| 2 | Jina-Code-v2 | 161M | 0.9439 |
|
| 101 |
+
| 3 | CodeRankEmbed | 137M | 0.9378 |
|
| 102 |
+
| **4** | **CodeCompass-Embed (ours)** | **494M** | **0.9228** |
|
| 103 |
+
| 5 | Snowflake-Arctic-Embed-L | 568M | 0.9146 |
|
| 104 |
+
| 6 | BGE-M3 | 568M | 0.8976 |
|
| 105 |
+
| 7 | BGE-Base-en-v1.5 | 109M | 0.8944 |
|
| 106 |
+
| 8 | CodeT5+-110M | 110M | 0.8702 |
|
| 107 |
+
|
| 108 |
+
### Full Results (All Tasks)
|
| 109 |
+
|
| 110 |
+
| Task | NDCG@10 | MRR@10 |
|
| 111 |
+
|------|---------|--------|
|
| 112 |
+
| **codesearchnet-python** | **0.9228** | **0.9106** |
|
| 113 |
+
| stackoverflow-qa | 0.6480 | 0.6156 |
|
| 114 |
+
| synthetic-text2sql | 0.5673 | 0.4853 |
|
| 115 |
+
| codefeedback-st | 0.4080 | 0.3698 |
|
| 116 |
+
| **codetrans-dl** | **0.3305** π | **0.2161** |
|
| 117 |
+
| apps | 0.1277 | 0.1097 |
|
| 118 |
|
| 119 |
## Usage
|
| 120 |
|
|
|
|
| 138 |
def encode(texts, is_query=False):
|
| 139 |
# Add instruction prefix for queries
|
| 140 |
if is_query:
|
| 141 |
+
texts = [f"Instruct: Find the most relevant code snippet given the following query:\nQuery: {t}" for t in texts]
|
|
|
|
| 142 |
|
| 143 |
inputs = tokenizer(texts, padding=True, truncation=True, max_length=512, return_tensors="pt")
|
| 144 |
|
|
|
|
| 158 |
# Example: Code Search
|
| 159 |
query = "How to sort a list in Python"
|
| 160 |
code_snippets = [
|
| 161 |
+
"def sort_list(lst):\n return sorted(lst)",
|
| 162 |
+
"def add_numbers(a, b):\n return a + b",
|
| 163 |
+
"def reverse_string(s):\n return s[::-1]",
|
|
|
|
|
|
|
|
|
|
| 164 |
]
|
| 165 |
|
| 166 |
query_emb = encode([query], is_query=True)
|
|
|
|
| 179 |
|
| 180 |
| Task | Instruction Template |
|
| 181 |
|------|---------------------|
|
| 182 |
+
| NL β Code | `Instruct: Find the most relevant code snippet given the following query:\nQuery: {query}` |
|
| 183 |
+
| Code β Code | `Instruct: Find an equivalent code snippet given the following code snippet:\nQuery: {query}` |
|
| 184 |
+
| Tech Q&A | `Instruct: Find the most relevant answer given the following question:\nQuery: {query}` |
|
| 185 |
+
| Text β SQL | `Instruct: Given a natural language question and schema, find the corresponding SQL query:\nQuery: {query}` |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
**Note**: Document/corpus texts do NOT need instruction prefixes.
|
| 188 |
|
|
|
|
| 200 |
|
| 201 |
## Limitations
|
| 202 |
|
| 203 |
+
- Optimized for **NL β Code** retrieval; weaker on Q&A style tasks
|
| 204 |
- Trained primarily on Python/JavaScript/Java/Go/PHP/Ruby
|
| 205 |
- May not generalize well to low-resource programming languages
|
| 206 |
|