Jarbas commited on
Commit
985a6ca
·
verified ·
1 Parent(s): 15c94b9

Upload 5 files

Browse files
Files changed (5) hide show
  1. README.md +203 -0
  2. config.json +13 -0
  3. model.safetensors +3 -0
  4. modules.json +14 -0
  5. tokenizer.json +0 -0
README.md ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: google-bert/bert-base-multilingual-cased
3
+ language:
4
+ - multilingual
5
+ - af
6
+ - sq
7
+ - ar
8
+ - an
9
+ - hy
10
+ - ast
11
+ - az
12
+ - ba
13
+ - eu
14
+ - bar
15
+ - be
16
+ - bn
17
+ - inc
18
+ - bs
19
+ - br
20
+ - bg
21
+ - my
22
+ - ca
23
+ - ceb
24
+ - ce
25
+ - zh
26
+ - cv
27
+ - hr
28
+ - cs
29
+ - da
30
+ - nl
31
+ - en
32
+ - et
33
+ - fi
34
+ - fr
35
+ - gl
36
+ - ka
37
+ - de
38
+ - el
39
+ - gu
40
+ - ht
41
+ - he
42
+ - hi
43
+ - hu
44
+ - is
45
+ - io
46
+ - id
47
+ - ga
48
+ - it
49
+ - ja
50
+ - jv
51
+ - kn
52
+ - kk
53
+ - ky
54
+ - ko
55
+ - la
56
+ - lv
57
+ - lt
58
+ - roa
59
+ - nds
60
+ - lm
61
+ - mk
62
+ - mg
63
+ - ms
64
+ - ml
65
+ - mr
66
+ - mn
67
+ - min
68
+ - ne
69
+ - new
70
+ - nb
71
+ - nn
72
+ - oc
73
+ - fa
74
+ - pms
75
+ - pl
76
+ - pt
77
+ - pa
78
+ - ro
79
+ - ru
80
+ - sco
81
+ - sr
82
+ - hr
83
+ - scn
84
+ - sk
85
+ - sl
86
+ - aze
87
+ - es
88
+ - su
89
+ - sw
90
+ - sv
91
+ - tl
92
+ - tg
93
+ - th
94
+ - ta
95
+ - tt
96
+ - te
97
+ - tr
98
+ - uk
99
+ - ud
100
+ - uz
101
+ - vi
102
+ - vo
103
+ - war
104
+ - cy
105
+ - fry
106
+ - pnb
107
+ - yo
108
+ library_name: model2vec
109
+ license: mit
110
+ model_name: bert-base-multilingual-cased-distill256
111
+ tags:
112
+ - embeddings
113
+ - static-embeddings
114
+ - sentence-transformers
115
+ ---
116
+
117
+ # bert-base-multilingual-cased-distill256 Model Card
118
+
119
+ This [Model2Vec](https://github.com/MinishLab/model2vec) model is a distilled version of the google-bert/bert-base-multilingual-cased(https://huggingface.co/google-bert/bert-base-multilingual-cased) 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.
120
+
121
+
122
+ ## Installation
123
+
124
+ Install model2vec using pip:
125
+ ```
126
+ pip install model2vec
127
+ ```
128
+
129
+ ## Usage
130
+
131
+ ### Using Model2Vec
132
+
133
+ The [Model2Vec library](https://github.com/MinishLab/model2vec) is the fastest and most lightweight way to run Model2Vec models.
134
+
135
+ Load this model using the `from_pretrained` method:
136
+ ```python
137
+ from model2vec import StaticModel
138
+
139
+ # Load a pretrained Model2Vec model
140
+ model = StaticModel.from_pretrained("bert-base-multilingual-cased-distill256")
141
+
142
+ # Compute text embeddings
143
+ embeddings = model.encode(["Example sentence"])
144
+ ```
145
+
146
+ ### Using Sentence Transformers
147
+
148
+ You can also use the [Sentence Transformers library](https://github.com/UKPLab/sentence-transformers) to load and use the model:
149
+
150
+ ```python
151
+ from sentence_transformers import SentenceTransformer
152
+
153
+ # Load a pretrained Sentence Transformer model
154
+ model = SentenceTransformer("bert-base-multilingual-cased-distill256")
155
+
156
+ # Compute text embeddings
157
+ embeddings = model.encode(["Example sentence"])
158
+ ```
159
+
160
+ ### Distilling a Model2Vec model
161
+
162
+ 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:
163
+
164
+ ```python
165
+ from model2vec.distill import distill
166
+
167
+ # Distill a Sentence Transformer model, in this case the BAAI/bge-base-en-v1.5 model
168
+ m2v_model = distill(model_name="BAAI/bge-base-en-v1.5", pca_dims=256)
169
+
170
+ # Save the model
171
+ m2v_model.save_pretrained("m2v_model")
172
+ ```
173
+
174
+ ## How it works
175
+
176
+ 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.
177
+
178
+ 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.
179
+
180
+ ## Additional Resources
181
+
182
+ - [Model2Vec Repo](https://github.com/MinishLab/model2vec)
183
+ - [Model2Vec Base Models](https://huggingface.co/collections/minishlab/model2vec-base-models-66fd9dd9b7c3b3c0f25ca90e)
184
+ - [Model2Vec Results](https://github.com/MinishLab/model2vec/tree/main/results)
185
+ - [Model2Vec Tutorials](https://github.com/MinishLab/model2vec/tree/main/tutorials)
186
+ - [Website](https://minishlab.github.io/)
187
+
188
+
189
+ ## Library Authors
190
+
191
+ 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).
192
+
193
+ ## Citation
194
+
195
+ Please cite the [Model2Vec repository](https://github.com/MinishLab/model2vec) if you use this model in your work.
196
+ ```
197
+ @article{minishlab2024model2vec,
198
+ author = {Tulkens, Stephan and {van Dongen}, Thomas},
199
+ title = {Model2Vec: Fast State-of-the-Art Static Embeddings},
200
+ year = {2024},
201
+ url = {https://github.com/MinishLab/model2vec}
202
+ }
203
+ ```
config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "model2vec",
3
+ "architectures": [
4
+ "StaticModel"
5
+ ],
6
+ "tokenizer_name": "google-bert/bert-base-multilingual-cased",
7
+ "apply_pca": 256,
8
+ "apply_zipf": null,
9
+ "sif_coefficient": 0.0001,
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:d3995d5f9c8deca991952fd4795d3dbad933374ae9377d01d9e8cb50c6c15f6b
3
+ size 61155928
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