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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model:
|
| 3 |
+
- jinaai/jina-code-embeddings-1.5b
|
| 4 |
+
base_model_relation: quantized
|
| 5 |
+
license: cc-by-nc-4.0
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
<p align="center">
|
| 9 |
+
<img src="https://huggingface.co/datasets/jinaai/documentation-images/resolve/main/logo.webp" alt="Jina AI: Your Search Foundation, Supercharged!" width="150px">
|
| 10 |
+
</p>
|
| 11 |
+
|
| 12 |
+
<p align="center">
|
| 13 |
+
<b>The GGUF version of the code embedding model trained by <a href="https://jina.ai/"><b>Jina AI</b></a>.</b>
|
| 14 |
+
</p>
|
| 15 |
+
|
| 16 |
+
# Jina Code Embeddings: A Small but Performant Code Embedding Model
|
| 17 |
+
|
| 18 |
+
## Intended Usage & Model Info
|
| 19 |
+
|
| 20 |
+
`jina-code-embeddings-1.5b-GGUF` is the **GGUF export** of our [jina-code-embeddings-1.5b](https://huggingface.co/jinaai/jina-code-embeddings-1.5b), built on [Qwen/Qwen2.5-Coder-1.5B](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B).
|
| 21 |
+
|
| 22 |
+
The model supports code retrieval and technical QA across **15+ programming languages** and multiple domains, including web development, software development, machine learning, data science, and educational coding problems.
|
| 23 |
+
|
| 24 |
+
### Key Features
|
| 25 |
+
| Feature | Jina Code Embeddings 1.5B GGUF |
|
| 26 |
+
|------------------------|--------------------------------|
|
| 27 |
+
| Base Model | Qwen2.5-Coder-1.5B |
|
| 28 |
+
| Supported Tasks | `nl2code`, `code2code`, `code2nl`, `code2completion`, `qa` |
|
| 29 |
+
| Max Sequence Length | 32768 (**recommended ≤ 8192**) |
|
| 30 |
+
| Embedding Vector Dim | **896** |
|
| 31 |
+
| Matryoshka Dimensions | 64, 128, 256, 512, 896 (**client-side slice**) |
|
| 32 |
+
| Pooling Strategy | **MUST use `--pooling last`** (EOS) |
|
| 33 |
+
|
| 34 |
+
> **Matryoshka note:** `llama.cpp` always returns **896-d** embeddings for this model. To use 64/128/256/512, **slice client-side** (e.g., take the first *k* elements).
|
| 35 |
+
|
| 36 |
+
---
|
| 37 |
+
|
| 38 |
+
## Task Instructions
|
| 39 |
+
|
| 40 |
+
Prefix inputs with task-specific instructions:
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
INSTRUCTION_CONFIG = {
|
| 44 |
+
"nl2code": {
|
| 45 |
+
"query": "Find the most relevant code snippet given the following query:\n",
|
| 46 |
+
"passage": "Candidate code snippet:\n"
|
| 47 |
+
},
|
| 48 |
+
"qa": {
|
| 49 |
+
"query": "Find the most relevant answer given the following question:\n",
|
| 50 |
+
"passage": "Candidate answer:\n"
|
| 51 |
+
},
|
| 52 |
+
"code2code": {
|
| 53 |
+
"query": "Find an equivalent code snippet given the following code snippet:\n",
|
| 54 |
+
"passage": "Candidate code snippet:\n"
|
| 55 |
+
},
|
| 56 |
+
"code2nl": {
|
| 57 |
+
"query": "Find the most relevant comment given the following code snippet:\n",
|
| 58 |
+
"passage": "Candidate comment:\n"
|
| 59 |
+
},
|
| 60 |
+
"code2completion": {
|
| 61 |
+
"query": "Find the most relevant completion given the following start of code snippet:\n",
|
| 62 |
+
"passage": "Candidate completion:\n"
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
````
|
| 66 |
+
|
| 67 |
+
Use the appropriate prefix for **queries** and **passages** at inference time.
|
| 68 |
+
|
| 69 |
+
---
|
| 70 |
+
|
| 71 |
+
## Install `llama.cpp`
|
| 72 |
+
|
| 73 |
+
Follow the official instructions: **[https://github.com/ggerganov/llama.cpp](https://github.com/ggerganov/llama.cpp)**
|
| 74 |
+
|
| 75 |
+
---
|
| 76 |
+
|
| 77 |
+
## Model files
|
| 78 |
+
|
| 79 |
+
Hugging Face repo (GGUF): **[https://huggingface.co/jinaai/jina-code-embeddings-1.5b-GGUF](https://huggingface.co/jinaai/jina-code-embeddings-1.5b-GGUF)**
|
| 80 |
+
|
| 81 |
+
Pick a file (e.g., `jina-code-embeddings-1.5b-F16.gguf`). You can either:
|
| 82 |
+
|
| 83 |
+
* **auto-download** by passing the **repo and file directly** to `llama.cpp`
|
| 84 |
+
* **use a local path** with `-m`
|
| 85 |
+
|
| 86 |
+
---
|
| 87 |
+
|
| 88 |
+
## A) CLI embeddings with `llama-embedding`
|
| 89 |
+
|
| 90 |
+
### Auto-download from Hugging Face (repo + file)
|
| 91 |
+
|
| 92 |
+
```bash
|
| 93 |
+
./llama-embedding \
|
| 94 |
+
--hf-repo jinaai/jina-code-embeddings-1.5b-GGUF \
|
| 95 |
+
--hf-file jina-code-embeddings-1.5b-F16.gguf \
|
| 96 |
+
--pooling last \
|
| 97 |
+
-p "Find the most relevant code snippet given the following query:
|
| 98 |
+
print hello world in python"
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
### Local file
|
| 102 |
+
|
| 103 |
+
```bash
|
| 104 |
+
./llama-embedding \
|
| 105 |
+
-m /path/to/jina-code-embeddings-1.5b-F16.gguf \
|
| 106 |
+
--pooling last \
|
| 107 |
+
-p "Find the most relevant code snippet given the following query:
|
| 108 |
+
print hello world in python"
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
> Outputs a single **896-d** vector to stdout. For smaller sizes, slice client-side.
|
| 112 |
+
|
| 113 |
+
---
|
| 114 |
+
|
| 115 |
+
## B) HTTP service with `llama-server`
|
| 116 |
+
|
| 117 |
+
### Auto-download from Hugging Face (repo + file)
|
| 118 |
+
|
| 119 |
+
```bash
|
| 120 |
+
./llama-server \
|
| 121 |
+
--embedding \
|
| 122 |
+
--hf-repo jinaai/jina-code-embeddings-1.5b-GGUF \
|
| 123 |
+
--hf-file jina-code-embeddings-1.5b-F16.gguf \
|
| 124 |
+
--host 0.0.0.0 \
|
| 125 |
+
--port 8080 \
|
| 126 |
+
--ctx-size 32768 \
|
| 127 |
+
--ubatch-size 8192 \
|
| 128 |
+
--pooling last
|
| 129 |
+
```
|
| 130 |
+
|
| 131 |
+
### Local file
|
| 132 |
+
|
| 133 |
+
```bash
|
| 134 |
+
./llama-server \
|
| 135 |
+
--embedding \
|
| 136 |
+
-m /path/to/jina-code-embeddings-1.5b-F16.gguf \
|
| 137 |
+
--host 0.0.0.0 \
|
| 138 |
+
--port 8080 \
|
| 139 |
+
--ctx-size 32768 \
|
| 140 |
+
--ubatch-size 8192 \
|
| 141 |
+
--pooling last
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
> Tips: `-ngl <N>` to offload layers to GPU. Max context is 32768 but stick to `--ubatch-size` ≤ 8192 for best results.
|
| 145 |
+
|
| 146 |
+
---
|
| 147 |
+
|
| 148 |
+
## Query examples (HTTP)
|
| 149 |
+
|
| 150 |
+
### Native endpoint (`/embedding`)
|
| 151 |
+
|
| 152 |
+
```bash
|
| 153 |
+
curl -X POST http://localhost:8080/embedding \
|
| 154 |
+
-H "Content-Type: application/json" \
|
| 155 |
+
-d '{
|
| 156 |
+
"content": [
|
| 157 |
+
"Find the most relevant code snippet given the following query:\nprint hello world in python",
|
| 158 |
+
"Candidate code snippet:\nprint(\"Hello World!\")"
|
| 159 |
+
]
|
| 160 |
+
}'
|
| 161 |
+
```
|
| 162 |
+
|
| 163 |
+
### OpenAI-compatible (`/v1/embeddings`)
|
| 164 |
+
|
| 165 |
+
```bash
|
| 166 |
+
curl http://localhost:8080/v1/embeddings \
|
| 167 |
+
-H "Content-Type: application/json" \
|
| 168 |
+
-d '{
|
| 169 |
+
"input": [
|
| 170 |
+
"Find the most relevant code snippet given the following query:\nprint hello world in python",
|
| 171 |
+
"Candidate code snippet:\nprint(\"Hello World!\")"
|
| 172 |
+
]
|
| 173 |
+
}'
|
| 174 |
+
```
|
| 175 |
+
|
| 176 |
+
---
|
| 177 |
+
|
| 178 |
+
## Training & Evaluation
|
| 179 |
+
|
| 180 |
+
See our technical report: **[https://arxiv.org/abs/2508.21290](https://arxiv.org/abs/2508.21290)**
|
| 181 |
+
|
| 182 |
+
---
|
| 183 |
+
|
| 184 |
+
## Contact
|
| 185 |
+
|
| 186 |
+
Join our Discord: **[https://discord.jina.ai](https://discord.jina.ai)**
|