Views
No views yet
nomic-embed-code must begin with the following prefix:Represent this query for searching relevant code:llama-server -m nomic-embed-code.Q4_0.gguf --embeddings --pooling last1import requests
2from textwrap import dedent
3
4def dot(va, vb):
5 return sum(a*b for a, b in zip(va, vb))
6def embed(texts):
7 resp = requests.post('http://localhost:8080/v1/embeddings', json={'input': texts}).json()
8 return [d['embedding'] for d in resp['data']]
9
10docs = [
11 dedent("""\
12 def fn(n):
13 if n < 0:
14 raise ValueError
15 return 1 if n == 0 else n * fn(n - 1)
16 """).strip(),
17 dedent("""\
18 def fn(n):
19 print(("Fizz" * (n % 3 == 0) + "Buzz" * (n % 5 == 0)) or n)
20 """).strip(),
21]
22docs_embed = embed(docs)
23
24query = 'Calculate the n-th factorial'
25query_embed = embed(['Represent this query for searching relevant code: ' + query])[0]
26print(f'query: {query!r}')
27for d, e in zip(docs, docs_embed):
28 print(f'\nsimilarity {dot(query_embed, e):.2f}:\n{d}')query: 'Calculate the n-th factorial'
similarity 0.49:
def fn(n):
if n < 0:
raise ValueError
return 1 if n == 0 else n * fn(n - 1)
similarity 0.32:
def fn(n):
print(("Fizz" * (n % 3 == 0) + "Buzz" * (n % 5 == 0)) or n)| Filename | Quant Type | File Size | Description |
|---|---|---|---|
| nomic-embed-code.f32.gguf | f32 | 26.35GiB | Full FP32 weights. |
| nomic-embed-code.f16.gguf | f16 | 13.18GiB | Full FP16 weights. |
| nomic-embed-code.bf16.gguf | bf16 | 13.18GiB | Full BF16 weights. |
| nomic-embed-code.Q8_0.gguf | Q8_0 | 7.00GiB | Extremely high quality, generally unneeded but max available quant. |
| nomic-embed-code.Q6_K.gguf | Q6_K | 5.41GiB | Very high quality, near perfect, recommended. |
| nomic-embed-code.Q5_K_M.gguf | Q5_K_M | 4.72GiB | High quality, recommended. |
| nomic-embed-code.Q5_K_S.gguf | Q5_K_S | 4.60GiB | High quality, recommended. |
| nomic-embed-code.Q4_1.gguf | Q4_1 | 4.22GiB | Legacy format, similar performance to Q4_K_S but with improved tokens/watt on Apple silicon. |
| nomic-embed-code.Q4_K_M.gguf | Q4_K_M | 4.08GiB | Good quality, default size for most use cases, recommended. |
| nomic-embed-code.Q4_K_S.gguf | Q4_K_S | 3.87GiB | Slightly lower quality with more space savings, recommended. |
| nomic-embed-code.Q4_0.gguf | Q4_0 | 3.84GiB | Legacy format, offers online repacking for ARM and AVX CPU inference. |
| nomic-embed-code.Q3_K_L.gguf | Q3_K_L | 3.59GiB | Lower quality but usable, good for low RAM availability. |
| nomic-embed-code.Q3_K_M.gguf | Q3_K_M | 3.33GiB | Low quality. |
| nomic-embed-code.Q3_K_S.gguf | Q3_K_S | 3.03GiB | Low quality, not recommended. |
| nomic-embed-code.Q2_K.gguf | Q2_K | 2.64GiB | Very low quality but surprisingly usable. |
nomic-embed-code is a state-of-the-art code embedding model that excels at code retrieval tasks:| Model | Python | Java | Ruby | PHP | JavaScript | Go |
|---|---|---|---|---|---|---|
| Nomic Embed Code | 81.7 | 80.5 | 81.8 | 72.3 | 77.1 | 93.8 |
| Voyage Code 3 | 80.8 | 80.5 | 84.6 | 71.7 | 79.2 | 93.2 |
| OpenAI Embed 3 Large | 70.8 | 72.9 | 75.3 | 59.6 | 68.1 | 87.6 |
| Nomic CodeRankEmbed-137M | 78.4 | 76.9 | 79.3 | 68.8 | 71.4 | 92.7 |
| CodeSage Large v2 (1B) | 74.2 | 72.3 | 76.7 | 65.2 | 72.5 | 84.6 |
| CodeSage Large (1B) | 70.8 | 70.2 | 71.9 | 61.3 | 69.5 | 83.7 |
| Qodo Embed 1 7B | 59.9 | 61.6 | 68.4 | 48.5 | 57.0 | 81.4 |

1@misc{suresh2025cornstackhighqualitycontrastivedata,
2 title={CoRNStack: High-Quality Contrastive Data for Better Code Retrieval and Reranking},
3 author={Tarun Suresh and Revanth Gangi Reddy and Yifei Xu and Zach Nussbaum and Andriy Mulyar and Brandon Duderstadt and Heng Ji},
4 year={2025},
5 eprint={2412.01007},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2412.01007},
9}