bhavnicksm commited on
Commit
cd6bc37
·
verified ·
1 Parent(s): a0e52a3

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +79 -33
README.md CHANGED
@@ -1,61 +1,107 @@
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-base-4M
13
 
14
- Pre-built [tokie](https://github.com/chonkie-inc/tokie) tokenizer for [potion-base-4M](https://huggingface.co/minishlab/potion-base-4M).
 
 
 
 
 
 
 
 
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-base-4M")
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-base-4M").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-base-4M](https://huggingface.co/minishlab/potion-base-4M)
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-base-4M](https://huggingface.co/minishlab/potion-base-4M).
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ datasets:
3
+ - minishlab/tokenlearn-c4-en-bge-base-v1.5
4
+ library_name: model2vec
5
+ license: mit
6
  tags:
7
+ - embeddings
8
+ - static-embeddings
9
+ - mteb
10
+ - sentence-transformers
11
  - tokie
 
 
12
  ---
13
 
14
  <p align="center">
15
  <img src="tokie-banner.png" alt="tokie" width="600">
16
  </p>
17
 
18
+ > Pre-built [tokie](https://github.com/chonkie-inc/tokie) tokenizer included (`tokenizer.tkz`). 5x faster tokenization, drop-in replacement for HuggingFace tokenizers.
19
 
20
+ ---
21
+
22
+ # potion-base-4M Model Card
23
+
24
+ <div align="center">
25
+ <img width="35%" alt="Model2Vec logo" src="https://raw.githubusercontent.com/MinishLab/model2vec/main/assets/images/logo_v2.png">
26
+ </div>
27
+
28
+ This [Model2Vec](https://github.com/MinishLab/model2vec) model is pre-trained using [Tokenlearn](https://github.com/MinishLab/tokenlearn). It is a distilled version of the [baai/bge-base-en-v1.5](https://huggingface.co/baai/bge-base-en-v1.5) 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.
29
 
 
30
 
31
+
32
+ ## Installation
33
+
34
+ Install model2vec using pip:
35
+ ```
36
+ pip install model2vec
37
  ```
38
 
39
+ ## Usage
40
+ Load this model using the `from_pretrained` method:
41
  ```python
42
+ from model2vec import StaticModel
43
+
44
+ # Load a pretrained Model2Vec model
45
+ model = StaticModel.from_pretrained("minishlab/potion-base-4M")
46
 
47
+ # Compute text embeddings
48
+ embeddings = model.encode(["Example sentence"])
 
 
49
  ```
50
 
 
51
 
52
+ ## How it works
 
 
 
53
 
54
+ Model2vec creates a small, static model that outperforms other static embedding models by a large margin on all tasks on [MTEB](https://huggingface.co/spaces/mteb/leaderboard). This model is pre-trained using [Tokenlearn](https://github.com/MinishLab/tokenlearn). It's created using the following steps:
55
+ - Distillation: first, a model is distilled from a sentence transformer model using Model2Vec.
56
+ - Training data creation: the sentence transformer model is used to create training data by creating mean output embeddings on a large corpus.
57
+ - Training: the distilled model is trained on the training data using Tokenlearn.
58
+ - Post-training re-regularization: after training, the model is re-regularized by weighting the tokens based on their frequency, applying PCA, and finally applying [SIF weighting](https://openreview.net/pdf?id=SyK00v5xx).
59
 
60
+ The results for this model can be found on the [Model2Vec results page](https://github.com/MinishLab/model2vec/blob/main/results/README.md).
61
+
62
+
63
+
64
+
65
+ ## Results
66
+
67
+ | Model | Avg (All) | Avg (MTEB) | Class | Clust | PairClass | Rank | Ret | STS | Sum | Pearl | WordSim |
68
+ |:---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|
69
+ | [all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) | 55.80 | 55.93 | 69.25 | 44.90 | 82.37 | 47.14 | 42.92 | 78.95 | 25.96 | 60.83 | 49.91 |
70
+ | [potion-base-32M](https://huggingface.co/minishlab/potion-base-32M) | 52.83 | 52.13 | 71.70 | 41.25 | 78.17 | 42.45 | 32.67 | 73.93 | 24.74 | 55.37 | 55.15 |
71
+ | [potion-base-8M](https://huggingface.co/minishlab/potion-base-8M) | 51.32 | 51.08 | 70.34 | 39.74 | 76.62 | 41.79 | 31.11 | 72.91 | 25.06 | 53.54 | 50.75 |
72
+ | **[potion-base-4M](https://huggingface.co/minishlab/potion-base-4M)** | **50.01** | **49.77** | **68.00** | **39.47** | **75.37** | **41.41** | **28.43** | **71.87** | **23.82** | **52.55** | **49.21** |
73
+ | [M2V_base_output](https://huggingface.co/minishlab/M2V_base_output) | 48.77 | 47.96 | 66.84 | 33.96 | 74.90 | 39.31 | 25.36 | 68.76 | 26.61 | 54.02 | 49.18 |
74
+ | [potion-base-2M](https://huggingface.co/minishlab/potion-base-2M) | 47.55 | 47.49 | 64.13 | 37.53 | 73.72 | 40.46 | 22.99 | 69.77 | 23.80 | 50.82 | 44.72 |
75
+ | [GloVe_300d](https://huggingface.co/sentence-transformers/average_word_embeddings_glove.6B.300d) | 45.49 | 45.82 | 62.73 | 37.10 | 72.48 | 38.28 | 21.80 | 61.52 | 26.81 | 45.65 | 43.05 |
76
+ | [BPEmb_50k_300d](https://github.com/bheinzerling/bpemb) | 42.33 | 41.74 | 61.72 | 35.17 | 57.86 | 37.26 | 15.36 | 55.30 | 29.49 | 47.56 | 41.28 |
77
+
78
+ The results show that **potion-base-4M** reaches 89.63% of the performance of [all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) with an average score of 50.01 while being orders of magnitude faster.
79
 
80
+ For full results, see the [MTEB leaderboard](https://huggingface.co/spaces/mteb/leaderboard).
81
 
82
+ ## Additional Resources
 
 
 
83
 
84
+ - [All Model2Vec models on the hub](https://huggingface.co/models?library=model2vec)
85
+ - [Model2Vec Repo](https://github.com/MinishLab/model2vec)
86
+ - [Tokenlearn repo](https://github.com/MinishLab/tokenlearn)
87
+ - [Model2Vec Results](https://github.com/MinishLab/model2vec/blob/main/results/README.md)
88
+ - [Model2Vec Tutorials](https://github.com/MinishLab/model2vec/tree/main/tutorials)
89
 
90
+ ## Library Authors
91
 
92
+ 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).
93
 
94
+ ## Citation
95
 
96
+ Please cite the [Model2Vec repository](https://github.com/MinishLab/model2vec) if you use this model in your work.
97
+ ```bibtex
98
+ @software{minishlab2024model2vec,
99
+ author = {Stephan Tulkens and {van Dongen}, Thomas},
100
+ title = {Model2Vec: Fast State-of-the-Art Static Embeddings},
101
+ year = {2024},
102
+ publisher = {Zenodo},
103
+ doi = {10.5281/zenodo.17270888},
104
+ url = {https://github.com/MinishLab/model2vec},
105
+ license = {MIT}
106
+ }
107
+ ```