Model2Vec
ONNX
Safetensors
sentence-transformers
embeddings
static-embeddings
tokie
bhavnicksm commited on
Commit
b2a5b9e
·
verified ·
1 Parent(s): 58cc7e4

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +184 -33
README.md CHANGED
@@ -1,61 +1,212 @@
1
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  tags:
 
 
 
3
  - tokie
4
- - model2vec
5
- library_name: tokie
6
  ---
7
 
8
  <p align="center">
9
  <img src="tokie-banner.png" alt="tokie" width="600">
10
  </p>
11
 
12
- # potion-multilingual-128M
13
 
14
- Pre-built [tokie](https://github.com/chonkie-inc/tokie) tokenizer for [potion-multilingual-128M](https://huggingface.co/minishlab/potion-multilingual-128M).
 
 
 
 
 
 
 
 
 
15
 
16
- ## Quick Start (Python)
17
 
18
- ```bash
19
- pip install tokie
 
 
 
 
20
  ```
21
 
 
 
 
 
 
 
 
22
  ```python
23
- import tokie
 
 
 
24
 
25
- tokenizer = tokie.Tokenizer.from_pretrained("tokiers/potion-multilingual-128M")
26
- encoding = tokenizer.encode("Hello, world!")
27
- print(encoding.ids)
28
- print(encoding.attention_mask)
29
  ```
30
 
31
- ## Quick Start (Rust)
32
 
33
- ```toml
34
- [dependencies]
35
- tokie = { version = "0.0.7", features = ["hf"] }
36
- ```
37
 
38
- ```rust
39
- use tokie::Tokenizer;
 
40
 
41
- let tokenizer = Tokenizer::from_pretrained("tokiers/potion-multilingual-128M").unwrap();
42
- let encoding = tokenizer.encode("Hello, world!", true);
43
- println!("{:?}", encoding.ids);
44
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
- ## Files
 
 
 
 
47
 
48
- - `tokenizer.tkz` — tokie binary format (~10x smaller, loads in ~5ms)
49
- - `tokenizer.json` — original HuggingFace tokenizer
50
- - `model.safetensors` — original model weights
51
- - All other files from [potion-multilingual-128M](https://huggingface.co/minishlab/potion-multilingual-128M)
52
 
53
- ## About tokie
54
 
55
- **50x faster tokenization, 10x smaller model files, 100% accurate.**
56
 
57
- tokie is a drop-in replacement for HuggingFace tokenizers, built in Rust. See [GitHub](https://github.com/chonkie-inc/tokie) for benchmarks and documentation.
58
 
59
- ## License
60
 
61
- MIT OR Apache-2.0 (tokie library). Original model files retain their original license from [potion-multilingual-128M](https://huggingface.co/minishlab/potion-multilingual-128M).
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ datasets:
3
+ - minishlab/tokenlearn-c4-multilingual-bge-m3
4
+ language:
5
+ - en
6
+ - multilingual
7
+ - af
8
+ - am
9
+ - ar
10
+ - az
11
+ - be
12
+ - bg
13
+ - bn
14
+ - ca
15
+ - ceb
16
+ - co
17
+ - cs
18
+ - cy
19
+ - da
20
+ - de
21
+ - el
22
+ - eo
23
+ - es
24
+ - et
25
+ - eu
26
+ - fa
27
+ - fi
28
+ - fil
29
+ - fr
30
+ - fy
31
+ - ga
32
+ - gd
33
+ - gl
34
+ - gu
35
+ - ha
36
+ - haw
37
+ - hi
38
+ - hmn
39
+ - ht
40
+ - hu
41
+ - hy
42
+ - id
43
+ - ig
44
+ - is
45
+ - it
46
+ - iw
47
+ - ja
48
+ - jv
49
+ - ka
50
+ - kk
51
+ - km
52
+ - kn
53
+ - ko
54
+ - ku
55
+ - ky
56
+ - la
57
+ - lb
58
+ - lo
59
+ - lt
60
+ - lv
61
+ - mg
62
+ - mi
63
+ - mk
64
+ - ml
65
+ - mn
66
+ - mr
67
+ - ms
68
+ - mt
69
+ - my
70
+ - ne
71
+ - nl
72
+ - 'no'
73
+ - ny
74
+ - pa
75
+ - pl
76
+ - ps
77
+ - pt
78
+ - ro
79
+ - ru
80
+ - sd
81
+ - si
82
+ - sk
83
+ - sl
84
+ - sm
85
+ - sn
86
+ - so
87
+ - sq
88
+ - sr
89
+ - st
90
+ - su
91
+ - sv
92
+ - sw
93
+ - ta
94
+ - te
95
+ - tg
96
+ - th
97
+ - tr
98
+ - uk
99
+ - ur
100
+ - uz
101
+ - vi
102
+ - xh
103
+ - yi
104
+ - yo
105
+ - zh
106
+ - zu
107
+ library_name: model2vec
108
+ license: mit
109
+ model_name: potion-multilingual-128M
110
  tags:
111
+ - embeddings
112
+ - static-embeddings
113
+ - sentence-transformers
114
  - tokie
 
 
115
  ---
116
 
117
  <p align="center">
118
  <img src="tokie-banner.png" alt="tokie" width="600">
119
  </p>
120
 
121
+ > Pre-built [tokie](https://github.com/chonkie-inc/tokie) tokenizer included (`tokenizer.tkz`). 5x faster tokenization, drop-in replacement for HuggingFace tokenizers.
122
 
123
+ ---
124
+
125
+ # potion-multilingual-128M Model Card
126
+
127
+ <div align="center">
128
+ <img width="35%" alt="Model2Vec logo" src="https://raw.githubusercontent.com/MinishLab/model2vec/main/assets/images/logo_v2.png">
129
+ </div>
130
+
131
+
132
+ This [Model2Vec](https://github.com/MinishLab/model2vec) model is pre-trained using [Tokenlearn](https://github.com/MinishLab/tokenlearn) on all languages in the [C4 dataset](https://huggingface.co/datasets/allenai/c4). It is a distilled version of the [BAAI/bge-m3](https://huggingface.co/BAAI/bge-m3) 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.
133
 
134
+ potion-multilingual-128M is a multilingual model, trained on 101 languages, and is capable of generating embeddings for any text in any language. The model produces 256 dimensional embeddings, and has a theoretically unlimited context length since embeddings are static (pre-computed).
135
 
136
+
137
+ ## Installation
138
+
139
+ Install model2vec using pip:
140
+ ```
141
+ pip install model2vec
142
  ```
143
 
144
+ ## Usage
145
+
146
+ ### Using Model2Vec
147
+
148
+ The [Model2Vec library](https://github.com/MinishLab/model2vec) is the fastest and most lightweight way to run Model2Vec models.
149
+
150
+ Load this model using the `from_pretrained` method:
151
  ```python
152
+ from model2vec import StaticModel
153
+
154
+ # Load a pretrained Model2Vec model
155
+ model = StaticModel.from_pretrained("minishlab/potion-multilingual-128M")
156
 
157
+ # Compute text embeddings
158
+ embeddings = model.encode(["Example sentence"])
 
 
159
  ```
160
 
161
+ ## How it works
162
 
163
+ Model2vec creates a small, static model that outperforms other static embedding models by a large margin on all tasks on MTEB. This model is pre-trained using Tokenlearn. It's created using the following steps:
 
 
 
164
 
165
+ - Distillation: first, a model is distilled from a sentence transformer model using Model2Vec.
166
+ - Training data creation: the sentence transformer model is used to create training data by creating mean output embeddings on a large corpus. In this case, 2 million sentences from the C4 dataset were used from 101 different languages, sampled using temperature-smoothed sampling proportional to the language size.
167
+ - Training: the distilled model is trained on the training data using Tokenlearn.
168
 
169
+ The results for this model can be found on the [Model2Vec results page](https://github.com/MinishLab/model2vec/blob/main/results/README.md).
170
+
171
+
172
+ ## Results
173
+
174
+ | Model | Mean (Task) | Mean (TaskType) | BitMining | Class | Clust | InstRet | MultiClass | PairClass | Rank | Ret | STS |
175
+ |:---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|
176
+ | [LaBSE](https://huggingface.co/sentence-transformers/LaBSE) | 52.07 | 45.65 | 76.35 | 54.60 | 38.08 | -3.00 | 20.12 | 75.97 | 50.20 | 33.17 | 65.35 |
177
+ | **[potion-multilingual-128M](https://huggingface.co/minishlab/potion-multilingual-128M)** | **47.31** | **40.40** | **40.72** | **52.36** | **38.80** | **-2.08** | **15.95** | **71.39** | **47.39** | **37.86** | **61.23** |
178
+ | [static-similarity-mrl-multilingual-v1](https://huggingface.co/sentence-transformers/static-similarity-mrl-multilingual-v1) | 47.24 | 41.38 | 50.62 | 48.60 | 30.67 | -1.24 | 14.74 | 74.34 | 49.45 | 41.21 | 64.02 |
179
+ | [M2V_multilingual_output](https://huggingface.co/minishlab/M2V_multilingual_output) | 42.13 | 35.89 | 36.88 | 49.75 | 30.09 | -0.07 | 14.34 | 69.74 | 41.51 | 25.42 | 55.33 |
180
+
181
+ The results show that **potion-multilingual-128M** is the most performant static multilingual model, reaching 90.86% of the performance of [LaBSE](https://huggingface.co/sentence-transformers/LaBSE) with a mean task score of 47.31 while being orders of magnitude faster.
182
+
183
+ For full results, see the [MTEB leaderboard](https://huggingface.co/spaces/mteb/leaderboard).
184
+
185
+ ## Additional Resources
186
 
187
+ - [All Model2Vec models on the hub](https://huggingface.co/models?library=model2vec)
188
+ - [Model2Vec Repo](https://github.com/MinishLab/model2vec)
189
+ - [Tokenlearn repo](https://github.com/MinishLab/tokenlearn)
190
+ - [Model2Vec Results](https://github.com/MinishLab/model2vec/blob/main/results/README.md)
191
+ - [Model2Vec Tutorials](https://github.com/MinishLab/model2vec/tree/main/tutorials)
192
 
 
 
 
 
193
 
194
+ ## Library Authors
195
 
196
+ 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).
197
 
198
+ ## Citation
199
 
200
+ If you use Model2Vec in your research, please cite the following:
201
 
202
+ ```bibtex
203
+ @software{minishlab2024model2vec,
204
+ author = {Stephan Tulkens and {van Dongen}, Thomas},
205
+ title = {Model2Vec: Fast State-of-the-Art Static Embeddings},
206
+ year = {2024},
207
+ publisher = {Zenodo},
208
+ doi = {10.5281/zenodo.17270888},
209
+ url = {https://github.com/MinishLab/model2vec},
210
+ license = {MIT}
211
+ }
212
+ ```