Cebtenzzre commited on
Commit
ff2dded
·
0 Parent(s):

initial commit

Browse files
.gitattributes ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ quantized_by: Nomic
3
+ pipeline_tag: sentence-similarity
4
+ base_model: nomic-ai/nomic-embed-code
5
+ base_model_relation: quantized
6
+ tags:
7
+ - sentence-similarity
8
+ - feature-extraction
9
+ license: apache-2.0
10
+ ---
11
+
12
+ # Llama.cpp Quantizations of Nomic Embed Code: A State-of-the-Art Code Retriever
13
+
14
+ [Blog](https://www.nomic.ai/blog/posts/introducing-state-of-the-art-nomic-embed-code) | [Technical Report](https://arxiv.org/abs/2412.01007) | [AWS SageMaker](https://aws.amazon.com/marketplace/seller-profile?id=seller-tpqidcj54zawi) | [Atlas Embedding and Unstructured Data Analytics Platform](https://atlas.nomic.ai)
15
+
16
+ Using <a href="https://github.com/ggml-org/llama.cpp">llama.cpp</a> commit <a href="https://github.com/ggml-org/llama.cpp/tree/11683f579b2e0efac27955945a4bcadd8e123af3">11683f579</a> for quantization.
17
+
18
+ Original model: [nomic-embed-code](https://huggingface.co/nomic-ai/nomic-embed-code)
19
+
20
+ ## Usage
21
+
22
+ This model can be used with the [llama.cpp server](https://github.com/ggml-org/llama.cpp/blob/master/examples/embedding#post-v1embeddings-openai-compatible-embeddings-api) and other software that supports llama.cpp embedding models.
23
+
24
+ Queries embedded with `nomic-embed-code` must begin with the following prefix:
25
+ ```
26
+ Represent this query for searching relevant code:
27
+ ```
28
+
29
+ For example, the code below shows how to use the prefix to embed user questions, e.g. in a RAG application.
30
+
31
+ Start a llama.cpp server:
32
+ ```
33
+ llama-server -m nomic-embed-code.Q4_0.gguf --embeddings --pooling last
34
+ ```
35
+
36
+ And run this code:
37
+ ```python
38
+ import requests
39
+ from textwrap import dedent
40
+
41
+ def dot(va, vb):
42
+ return sum(a*b for a, b in zip(va, vb))
43
+ def embed(texts):
44
+ resp = requests.post('http://localhost:8080/v1/embeddings', json={'input': texts}).json()
45
+ return [d['embedding'] for d in resp['data']]
46
+
47
+ docs = [
48
+ dedent("""\
49
+ def fn(n):
50
+ if n < 0:
51
+ raise ValueError
52
+ return 1 if n == 0 else n * fn(n - 1)
53
+ """).strip(),
54
+ dedent("""\
55
+ def fn(n):
56
+ print(("Fizz" * (n % 3 == 0) + "Buzz" * (n % 5 == 0)) or n)
57
+ """).strip(),
58
+ ]
59
+ docs_embed = embed(docs)
60
+
61
+ query = 'Calculate the n-th factorial'
62
+ query_embed = embed(['Represent this query for searching relevant code: ' + query])[0]
63
+ print(f'query: {query!r}')
64
+ for d, e in zip(docs, docs_embed):
65
+ print(f'\nsimilarity {dot(query_embed, e):.2f}:\n{d}')
66
+ ```
67
+
68
+ You should see output similar to this:
69
+ ```
70
+ query: 'Calculate the n-th factorial'
71
+
72
+ similarity 0.49:
73
+ def fn(n):
74
+ if n < 0:
75
+ raise ValueError
76
+ return 1 if n == 0 else n * fn(n - 1)
77
+
78
+ similarity 0.32:
79
+ def fn(n):
80
+ print(("Fizz" * (n % 3 == 0) + "Buzz" * (n % 5 == 0)) or n)
81
+ ```
82
+
83
+ ## Download a file (not the whole branch) from below:
84
+
85
+ | Filename | Quant Type | File Size | Description |
86
+ | -------- | ---------- | --------: | ----------- |
87
+ | [nomic-embed-code.f32.gguf](https://huggingface.co/nomic-ai/nomic-embed-code-GGUF/blob/main/nomic-embed-code.f32.gguf) | f32 | 26.35GiB | Full FP32 weights. |
88
+ | [nomic-embed-code.f16.gguf](https://huggingface.co/nomic-ai/nomic-embed-code-GGUF/blob/main/nomic-embed-code.f16.gguf) | f16 | 13.18GiB | Full FP16 weights. |
89
+ | [nomic-embed-code.bf16.gguf](https://huggingface.co/nomic-ai/nomic-embed-code-GGUF/blob/main/nomic-embed-code.bf16.gguf) | bf16 | 13.18GiB | Full BF16 weights. |
90
+ | [nomic-embed-code.Q8\_0.gguf](https://huggingface.co/nomic-ai/nomic-embed-code-GGUF/blob/main/nomic-embed-code.Q8_0.gguf) | Q8\_0 | 7.00GiB | Extremely high quality, generally unneeded but max available quant. |
91
+ | [nomic-embed-code.Q6\_K.gguf](https://huggingface.co/nomic-ai/nomic-embed-code-GGUF/blob/main/nomic-embed-code.Q6_K.gguf) | Q6\_K | 5.41GiB | Very high quality, near perfect, *recommended*. |
92
+ | [nomic-embed-code.Q5\_K\_M.gguf](https://huggingface.co/nomic-ai/nomic-embed-code-GGUF/blob/main/nomic-embed-code.Q5_K_M.gguf) | Q5\_K\_M | 4.72GiB | High quality, *recommended*. |
93
+ | [nomic-embed-code.Q5\_K\_S.gguf](https://huggingface.co/nomic-ai/nomic-embed-code-GGUF/blob/main/nomic-embed-code.Q5_K_S.gguf) | Q5\_K\_S | 4.60GiB | High quality, *recommended*. |
94
+ | [nomic-embed-code.Q4\_1.gguf](https://huggingface.co/nomic-ai/nomic-embed-code-GGUF/blob/main/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. |
95
+ | [nomic-embed-code.Q4\_K\_M.gguf](https://huggingface.co/nomic-ai/nomic-embed-code-GGUF/blob/main/nomic-embed-code.Q4_K_M.gguf) | Q4\_K\_M | 4.08GiB | Good quality, default size for most use cases, *recommended*. |
96
+ | [nomic-embed-code.Q4\_K\_S.gguf](https://huggingface.co/nomic-ai/nomic-embed-code-GGUF/blob/main/nomic-embed-code.Q4_K_S.gguf) | Q4\_K\_S | 3.87GiB | Slightly lower quality with more space savings, *recommended*. |
97
+ | [nomic-embed-code.Q4\_0.gguf](https://huggingface.co/nomic-ai/nomic-embed-code-GGUF/blob/main/nomic-embed-code.Q4_0.gguf) | Q4\_0 | 3.84GiB | Legacy format, offers online repacking for ARM and AVX CPU inference. |
98
+ | [nomic-embed-code.Q3\_K\_L.gguf](https://huggingface.co/nomic-ai/nomic-embed-code-GGUF/blob/main/nomic-embed-code.Q3_K_L.gguf) | Q3\_K\_L | 3.59GiB | Lower quality but usable, good for low RAM availability. |
99
+ | [nomic-embed-code.Q3\_K\_M.gguf](https://huggingface.co/nomic-ai/nomic-embed-code-GGUF/blob/main/nomic-embed-code.Q3_K_M.gguf) | Q3\_K\_M | 3.33GiB | Low quality. |
100
+ | [nomic-embed-code.Q3\_K\_S.gguf](https://huggingface.co/nomic-ai/nomic-embed-code-GGUF/blob/main/nomic-embed-code.Q3_K_S.gguf) | Q3\_K\_S | 3.03GiB | Low quality, not recommended. |
101
+ | [nomic-embed-code.Q2\_K.gguf](https://huggingface.co/nomic-ai/nomic-embed-code-GGUF/blob/main/nomic-embed-code.Q2_K.gguf) | Q2\_K | 2.64GiB | Very low quality but surprisingly usable. |
102
+
103
+ ## Model Overview
104
+ `nomic-embed-code` is a state-of-the-art code embedding model that excels at code retrieval tasks:
105
+
106
+ - **High Performance**: Outperforms Voyage Code 3 and OpenAI Embed 3 Large on CodeSearchNet
107
+ - **Multilingual Code Support**: Trained for multiple programming languages (Python, Java, Ruby, PHP, JavaScript, Go)
108
+ - **Advanced Architecture**: 7B parameter code embedding model
109
+ - **Fully Open-Source**: Model weights, training data, and [evaluation code](https://github.com/gangiswag/cornstack/) released
110
+
111
+ | Model | Python | Java | Ruby | PHP | JavaScript | Go |
112
+ |-------|--------|------|------|-----|------------|-----|
113
+ | **Nomic Embed Code** | **81.7** | **80.5** | 81.8 | **72.3** | 77.1 | **93.8** |
114
+ | Voyage Code 3 | 80.8 | **80.5** | **84.6** | 71.7 | **79.2** | 93.2 |
115
+ | OpenAI Embed 3 Large | 70.8 | 72.9 | 75.3 | 59.6 | 68.1 | 87.6 |
116
+ | Nomic CodeRankEmbed-137M | 78.4 | 76.9 | 79.3 | 68.8 | 71.4 | 92.7 |
117
+ | CodeSage Large v2 (1B) | 74.2 | 72.3 | 76.7 | 65.2 | 72.5 | 84.6 |
118
+ | CodeSage Large (1B) | 70.8 | 70.2 | 71.9 | 61.3 | 69.5 | 83.7 |
119
+ | Qodo Embed 1 7B | 59.9 | 61.6 | 68.4 | 48.5 | 57.0 | 81.4 |
120
+
121
+ ## Model Architecture
122
+
123
+ - **Total Parameters**: 7B
124
+ - **Training Approach**: Trained on the CoRNStack dataset with dual-consistency filtering and progressive hard negative mining
125
+ - **Supported Languages**: Python, Java, Ruby, PHP, JavaScript, and Go
126
+
127
+ ### CoRNStack Dataset Curation
128
+
129
+ Starting with the deduplicated Stackv2, we create text-code pairs from function docstrings and respective code. We filtered out low-quality pairs where the docstring wasn't English, too short, or that contained URLs, HTML tags, or invalid characters. We additionally kept docstrings with text lengths of 256 tokens or longer to help the model learn long-range dependencies.
130
+
131
+
132
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/607997c83a565c15675055b3/rb-J54KLgg21f59Ba1jWp.png)
133
+
134
+ After the initial filtering, we used dual-consistency filtering to remove potentially noisy examples. We embed each docstring and code pair and compute the similarity between each docstring and every code example. We remove pairs from the dataset if the corresponding code example is not found in the top-2 most similar examples for a given docstring.
135
+
136
+ During training, we employ a novel curriculum-based hard negative mining strategy to ensure the model learns from challenging examples. We use a softmax-based sampling strategy to progressively sample hard negatives with increasing difficulty over time.
137
+
138
+
139
+ ## Join the Nomic Community
140
+
141
+ - Nomic Embed Ecosystem: [https://www.nomic.ai/embed](https://www.nomic.ai/embed)
142
+ - Website: [https://nomic.ai](https://nomic.ai)
143
+ - Twitter: [https://twitter.com/nomic\_ai](https://twitter.com/nomic_ai)
144
+ - Discord: [https://discord.gg/myY5YDR8z8](https://discord.gg/myY5YDR8z8)
145
+
146
+ # Citation
147
+
148
+ If you find the model, dataset, or training code useful, please cite our work:
149
+
150
+ ```bibtex
151
+ @misc{suresh2025cornstackhighqualitycontrastivedata,
152
+ title={CoRNStack: High-Quality Contrastive Data for Better Code Retrieval and Reranking},
153
+ author={Tarun Suresh and Revanth Gangi Reddy and Yifei Xu and Zach Nussbaum and Andriy Mulyar and Brandon Duderstadt and Heng Ji},
154
+ year={2025},
155
+ eprint={2412.01007},
156
+ archivePrefix={arXiv},
157
+ primaryClass={cs.CL},
158
+ url={https://arxiv.org/abs/2412.01007},
159
+ }
160
+ ```
nomic-embed-code.Q2_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:afaf7fb764e3bbd850629291a52d3955b3376381a4662544b860d71f1e7338a9
3
+ size 2837112128
nomic-embed-code.Q3_K_L.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:848ea553eb9f788c32962ba336435b2ae60f1d449d572760ee42a55ce0141797
3
+ size 3854280000
nomic-embed-code.Q3_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b9dbe007d13d967ed2135120b4c60350dce9d02af01dec29f6c26409c32f62b5
3
+ size 3574211904
nomic-embed-code.Q3_K_S.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d1d69385827e3cd28e44fb14cf56e4a4156aed72a38ea2f5dd96bebebb8b527
3
+ size 3258189120
nomic-embed-code.Q4_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0999f5a97eb15363c4cad76cfa71c413db96f61e8a32a91166e9f45db30b895e
3
+ size 4124828992
nomic-embed-code.Q4_1.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:859e801467a37922e0e5a3157a6498a9d33cb2b0ee08daed42e6988b1d1f14de
3
+ size 4532659520
nomic-embed-code.Q4_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4354a73ee9ff5d811efe552a515dfd518667ff25fdfc4ee9e10af3f617f96eec
3
+ size 4376511808
nomic-embed-code.Q4_K_S.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be589a33ae8ad094e634adc05a7d186de41da6052a38b85608dc147b39ffab11
3
+ size 4151207232
nomic-embed-code.Q5_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f234c58a5be4c5e89f71e3b7131150a568b9618d32a34ebb625e9c0f6e0be9fb
3
+ size 5070144832
nomic-embed-code.Q5_K_S.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a75989528b69c854da8d3a9f2f6011c649dc190b7e7b7d81d1356feb395832fa
3
+ size 4940490048
nomic-embed-code.Q6_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b179b7e381cb1c7d00a82f5c26858c94e19916257cbd6146c7e21c9240b3dd86
3
+ size 5807129920
nomic-embed-code.Q8_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:80bbd617cc55bad52ceb0f7dfad5d2f5b8080c61015cad7063ffc438b6561832
3
+ size 7519464768
nomic-embed-code.bf16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:09340ae55bc36f8d5e8a423084253c6460be99fee91d855d086767f40638abcd
3
+ size 14147857728
nomic-embed-code.f16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:33d214c79b97308e82b84f97ebdbba58bc1d8a841ccaaa9053848a06a091b33e
3
+ size 14147857728
nomic-embed-code.f32.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:99694fed45c5fd1badea488f7998bce7fa4c4d7e1e1b9e4f58b3d3e6892040e4
3
+ size 28288429376