jalbarracin commited on
Commit
63358c0
·
verified ·
1 Parent(s): ce22f2b

Initial commit

Browse files
Files changed (5) hide show
  1. README.md +200 -3
  2. config.json +13 -0
  3. model.safetensors +3 -0
  4. modules.json +14 -0
  5. tokenizer.json +0 -0
README.md CHANGED
@@ -1,3 +1,200 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: intfloat/multilingual-e5-small
3
+ language:
4
+ - multilingual
5
+ - af
6
+ - am
7
+ - ar
8
+ - as
9
+ - az
10
+ - be
11
+ - bg
12
+ - bn
13
+ - br
14
+ - bs
15
+ - ca
16
+ - cs
17
+ - cy
18
+ - da
19
+ - de
20
+ - el
21
+ - en
22
+ - eo
23
+ - es
24
+ - et
25
+ - eu
26
+ - fa
27
+ - fi
28
+ - fr
29
+ - fy
30
+ - ga
31
+ - gd
32
+ - gl
33
+ - gu
34
+ - ha
35
+ - he
36
+ - hi
37
+ - hr
38
+ - hu
39
+ - hy
40
+ - id
41
+ - is
42
+ - it
43
+ - ja
44
+ - jv
45
+ - ka
46
+ - kk
47
+ - km
48
+ - kn
49
+ - ko
50
+ - ku
51
+ - ky
52
+ - la
53
+ - lo
54
+ - lt
55
+ - lv
56
+ - mg
57
+ - mk
58
+ - ml
59
+ - mn
60
+ - mr
61
+ - ms
62
+ - my
63
+ - ne
64
+ - nl
65
+ - 'no'
66
+ - om
67
+ - or
68
+ - pa
69
+ - pl
70
+ - ps
71
+ - pt
72
+ - ro
73
+ - ru
74
+ - sa
75
+ - sd
76
+ - si
77
+ - sk
78
+ - sl
79
+ - so
80
+ - sq
81
+ - sr
82
+ - su
83
+ - sv
84
+ - sw
85
+ - ta
86
+ - te
87
+ - th
88
+ - tl
89
+ - tr
90
+ - ug
91
+ - uk
92
+ - ur
93
+ - uz
94
+ - vi
95
+ - xh
96
+ - yi
97
+ - zh
98
+ library_name: model2vec
99
+ license: mit
100
+ model_name: multilingual-e5-small-distilled-256d
101
+ tags:
102
+ - embeddings
103
+ - static-embeddings
104
+ - sentence-transformers
105
+ ---
106
+
107
+ # multilingual-e5-small-distilled-256d Model Card, ready for semantic search
108
+
109
+ This [Model2Vec](https://github.com/MinishLab/model2vec) model is a distilled version of the intfloat/multilingual-e5-small(https://huggingface.co/intfloat/multilingual-e5-small) Sentence Transformer. It uses static embeddings, allowing text embeddings to be computed orders of magnitude faster on both GPU and CPU. It is designed for applications where computational resources are limited or where real-time performance is critical. Model2Vec models are the smallest, fastest, and most performant static embedders available. The distilled models are up to 50 times smaller and 500 times faster than traditional Sentence Transformers.
110
+
111
+ Look no further if you are looking for a small and fast embedding with high precision. Suitable for semantic search or "vector search".
112
+
113
+
114
+ ## Installation
115
+
116
+ Install model2vec using pip:
117
+ ```
118
+ pip install model2vec
119
+ ```
120
+
121
+ ## Usage
122
+
123
+ ### Using Model2Vec
124
+
125
+ The [Model2Vec library](https://github.com/MinishLab/model2vec) is the fastest and most lightweight way to run Model2Vec models.
126
+
127
+ Load this model using the `from_pretrained` method:
128
+ ```python
129
+ from model2vec import StaticModel
130
+
131
+ # Load a pretrained Model2Vec model
132
+ model = StaticModel.from_pretrained("multilingual-e5-small-distilled-128d")
133
+
134
+ # Compute text embeddings
135
+ embeddings = model.encode(["Example sentence"])
136
+ ```
137
+
138
+ ### Using Sentence Transformers
139
+
140
+ You can also use the [Sentence Transformers library](https://github.com/UKPLab/sentence-transformers) to load and use the model:
141
+
142
+ ```python
143
+ from sentence_transformers import SentenceTransformer
144
+
145
+ # Load a pretrained Sentence Transformer model
146
+ model = SentenceTransformer("multilingual-e5-small-distilled-128d")
147
+
148
+ # Compute text embeddings
149
+ embeddings = model.encode(["Example sentence"])
150
+ ```
151
+
152
+ ### Distilling a Model2Vec model
153
+
154
+ You can distill a Model2Vec model from a Sentence Transformer model using the `distill` method. First, install the `distill` extra with `pip install model2vec[distill]`. Then, run the following code:
155
+
156
+ ```python
157
+ from model2vec.distill import distill
158
+
159
+ # Distill a Sentence Transformer model, in this case the BAAI/bge-base-en-v1.5 model
160
+ m2v_model = distill(model_name="BAAI/bge-base-en-v1.5", pca_dims=256)
161
+
162
+ # Save the model
163
+ m2v_model.save_pretrained("m2v_model")
164
+ ```
165
+
166
+ ## How it works
167
+
168
+ Model2vec creates a small, fast, and powerful model that outperforms other static embedding models by a large margin on all tasks we could find, while being much faster to create than traditional static embedding models such as GloVe. Best of all, you don't need any data to distill a model using Model2Vec.
169
+
170
+ It works by passing a vocabulary through a sentence transformer model, then reducing the dimensionality of the resulting embeddings using PCA, and finally weighting the embeddings using [SIF weighting](https://openreview.net/pdf?id=SyK00v5xx). During inference, we simply take the mean of all token embeddings occurring in a sentence.
171
+
172
+ ## Additional Resources
173
+
174
+ - [Model2Vec Repo](https://github.com/MinishLab/model2vec)
175
+ - [Model2Vec Base Models](https://huggingface.co/collections/minishlab/model2vec-base-models-66fd9dd9b7c3b3c0f25ca90e)
176
+ - [Model2Vec Results](https://github.com/MinishLab/model2vec/tree/main/results)
177
+ - [Model2Vec Tutorials](https://github.com/MinishLab/model2vec/tree/main/tutorials)
178
+ - [Website](https://minishlab.github.io/)
179
+
180
+
181
+ ## Library Authors
182
+
183
+ Model2Vec was developed by the [Minish Lab](https://github.com/MinishLab) team consisting of [Stephan Tulkens](https://github.com/stephantul) and [Thomas van Dongen](https://github.com/Pringled).
184
+
185
+ ## This 256 Dimension model was distilled by
186
+
187
+ Javier Albarracín - CIO FLUVIP - Director del Centro de Tecnología de la UTP
188
+ @jalbarracin / twitter
189
+
190
+ ## Citation
191
+
192
+ Please cite the [Model2Vec repository](https://github.com/MinishLab/model2vec) if you use this model in your work.
193
+ ```
194
+ @article{minishlab2024model2vec,
195
+ author = {Tulkens, Stephan and {van Dongen}, Thomas},
196
+ title = {Model2Vec: Fast State-of-the-Art Static Embeddings},
197
+ year = {2024},
198
+ url = {https://github.com/MinishLab/model2vec}
199
+ }
200
+ ```
config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "model2vec",
3
+ "architectures": [
4
+ "StaticModel"
5
+ ],
6
+ "tokenizer_name": "intfloat/multilingual-e5-small",
7
+ "apply_pca": 256,
8
+ "apply_zipf": null,
9
+ "sif_coefficient": 0.001,
10
+ "hidden_dim": 256,
11
+ "seq_length": 1000000,
12
+ "normalize": true
13
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f04c8c229f073e4a07e3c315f6784f8b9426e0249a00004f3b98fbf831a4073
3
+ size 127999576
modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": ".",
6
+ "type": "sentence_transformers.models.StaticEmbedding"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Normalize",
12
+ "type": "sentence_transformers.models.Normalize"
13
+ }
14
+ ]
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff