hs-hf commited on
Commit
72c198c
1 Parent(s): 4d2da18

Distilled the LaBSE model utilizing the Model2Vec technique.

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* 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
 
 
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
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: sentence-transformers/LaBSE
3
+ language:
4
+ - multilingual
5
+ - af
6
+ - sq
7
+ - am
8
+ - ar
9
+ - hy
10
+ - as
11
+ - az
12
+ - eu
13
+ - be
14
+ - bn
15
+ - bs
16
+ - bg
17
+ - my
18
+ - ca
19
+ - ceb
20
+ - zh
21
+ - co
22
+ - hr
23
+ - cs
24
+ - da
25
+ - nl
26
+ - en
27
+ - eo
28
+ - et
29
+ - fi
30
+ - fr
31
+ - fy
32
+ - gl
33
+ - ka
34
+ - de
35
+ - el
36
+ - gu
37
+ - ht
38
+ - ha
39
+ - haw
40
+ - he
41
+ - hi
42
+ - hmn
43
+ - hu
44
+ - is
45
+ - ig
46
+ - id
47
+ - ga
48
+ - it
49
+ - ja
50
+ - jv
51
+ - kn
52
+ - kk
53
+ - km
54
+ - rw
55
+ - ko
56
+ - ku
57
+ - ky
58
+ - lo
59
+ - la
60
+ - lv
61
+ - lt
62
+ - lb
63
+ - mk
64
+ - mg
65
+ - ms
66
+ - ml
67
+ - mt
68
+ - mi
69
+ - mr
70
+ - mn
71
+ - ne
72
+ - 'no'
73
+ - ny
74
+ - or
75
+ - fa
76
+ - pl
77
+ - pt
78
+ - pa
79
+ - ro
80
+ - ru
81
+ - sm
82
+ - gd
83
+ - sr
84
+ - st
85
+ - sn
86
+ - si
87
+ - sk
88
+ - sl
89
+ - so
90
+ - es
91
+ - su
92
+ - sw
93
+ - sv
94
+ - tl
95
+ - tg
96
+ - ta
97
+ - tt
98
+ - te
99
+ - th
100
+ - bo
101
+ - tr
102
+ - tk
103
+ - ug
104
+ - uk
105
+ - ur
106
+ - uz
107
+ - vi
108
+ - cy
109
+ - wo
110
+ - xh
111
+ - yi
112
+ - yo
113
+ - zu
114
+ library_name: model2vec
115
+ license: mit
116
+ model_name: m2v-LaBSE-distilled
117
+ tags:
118
+ - embeddings
119
+ - static-embeddings
120
+ ---
121
+
122
+ # m2v-LaBSE-distilled Model Card
123
+
124
+ This [Model2Vec](https://github.com/MinishLab/model2vec) model is a distilled version of the [sentence-transformers/LaBSE](https://huggingface.co/sentence-transformers/LaBSE) 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.
125
+
126
+
127
+ ## Installation
128
+
129
+ Install model2vec using pip:
130
+ ```
131
+ pip install model2vec
132
+ ```
133
+
134
+ ## Usage
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("m2v-LaBSE-distilled")
141
+
142
+ # Compute text embeddings
143
+ embeddings = model.encode(["Example sentence"])
144
+ ```
145
+
146
+ Alternatively, you can distill your own model using the `distill` method:
147
+ ```python
148
+ from model2vec.distill import distill
149
+
150
+ # Choose a Sentence Transformer model
151
+ model_name = "BAAI/bge-base-en-v1.5"
152
+
153
+ # Distill the model
154
+ m2v_model = distill(model_name=model_name, pca_dims=256)
155
+
156
+ # Save the model
157
+ m2v_model.save_pretrained("m2v_model")
158
+ ```
159
+
160
+ ## How it works
161
+
162
+ 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.
163
+
164
+ 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 zipf weighting. During inference, we simply take the mean of all token embeddings occurring in a sentence.
165
+
166
+ ## Additional Resources
167
+
168
+ - [All Model2Vec models on the hub](https://huggingface.co/models?library=model2vec)
169
+ - [Model2Vec Repo](https://github.com/MinishLab/model2vec)
170
+ - [Model2Vec Results](https://github.com/MinishLab/model2vec?tab=readme-ov-file#results)
171
+ - [Model2Vec Tutorials](https://github.com/MinishLab/model2vec/tree/main/tutorials)
172
+
173
+ ## Library Authors
174
+
175
+ 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).
176
+
177
+ ## Citation
178
+
179
+ Please cite the [Model2Vec repository](https://github.com/MinishLab/model2vec) if you use this model in your work.
180
+ ```
181
+ @software{minishlab2024model2vec,
182
+ authors = {Stephan Tulkens, Thomas van Dongen},
183
+ title = {Model2Vec: Turn any Sentence Transformer into a Small Fast Model},
184
+ year = {2024},
185
+ url = {https://github.com/MinishLab/model2vec},
186
+ }
187
+ ```
config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"tokenizer_name": "sentence-transformers/LaBSE", "apply_pca": 384, "apply_zipf": true, "hidden_dim": 384, "seq_length": 1000000, "normalize": false}
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:568116f9b562f5c9f6ec2dca7d8c7a67c87c2f6765f4eaed830cd59030f5dd6c
3
+ size 769619032
special_tokens_map.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": {
3
+ "content": "[CLS]",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "mask_token": {
10
+ "content": "[MASK]",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "[PAD]",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "sep_token": {
24
+ "content": "[SEP]",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "unk_token": {
31
+ "content": "[UNK]",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ }
37
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:09216b42d2697b7b4a26ac05ff09ba8bf52dc19b896c5ceee8bbff9f39055322
3
+ size 13631919
tokenizer_config.json ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": true,
45
+ "cls_token": "[CLS]",
46
+ "do_basic_tokenize": true,
47
+ "do_lower_case": false,
48
+ "full_tokenizer_file": null,
49
+ "mask_token": "[MASK]",
50
+ "model_max_length": 512,
51
+ "never_split": null,
52
+ "pad_token": "[PAD]",
53
+ "sep_token": "[SEP]",
54
+ "strip_accents": null,
55
+ "tokenize_chinese_chars": true,
56
+ "tokenizer_class": "BertTokenizer",
57
+ "unk_token": "[UNK]"
58
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff