bhavnicksm commited on
Commit
4308dee
·
verified ·
1 Parent(s): 68ff57f

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +55 -34
README.md CHANGED
@@ -1,61 +1,82 @@
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-science-32M
13
 
14
- Pre-built [tokie](https://github.com/chonkie-inc/tokie) tokenizer for [potion-science-32M](https://huggingface.co/minishlab/potion-science-32M).
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-science-32M")
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-science-32M").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-science-32M](https://huggingface.co/minishlab/potion-science-32M)
 
 
 
 
 
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-science-32M](https://huggingface.co/minishlab/potion-science-32M).
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ library_name: model2vec
3
+ license: mit
4
+ model_name: potion-science-32M
5
  tags:
6
+ - embeddings
7
+ - static-embeddings
8
+ - sentence-transformers
9
  - tokie
 
 
10
  ---
11
 
12
  <p align="center">
13
  <img src="tokie-banner.png" alt="tokie" width="600">
14
  </p>
15
 
16
+ > Pre-built [tokie](https://github.com/chonkie-inc/tokie) tokenizer included (`tokenizer.tkz`). 5x faster tokenization, drop-in replacement for HuggingFace tokenizers.
17
 
18
+ ---
19
 
20
+ # potion-science-32M Model Card
21
 
22
+ <div align="center">
23
+ <img width="35%" alt="Model2Vec logo" src="https://raw.githubusercontent.com/MinishLab/model2vec/main/assets/images/logo_v2.png">
24
+ </div>
25
 
26
+ 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.
27
+ This model is pre-trained on the [scientific_papers](https://huggingface.co/datasets/armanc/scientific_papers) dataset consisting of scientific papers from Arxiv and Pubmed. It uses a larger vocabulary size than the [potion-science-8M](https://huggingface.co/minishlab/potion-science-8M) model which can be beneficial for tasks that require a larger (specialized) vocabulary.
28
 
 
 
 
 
 
29
 
30
+ ## Installation
31
 
32
+ Install model2vec using pip:
33
+ ```
34
+ pip install model2vec
35
  ```
36
 
37
+ ## Usage
38
+ Load this model using the `from_pretrained` method:
39
+ ```python
40
+ from model2vec import StaticModel
41
 
42
+ # Load a pretrained Model2Vec model
43
+ model = StaticModel.from_pretrained("minishlab/potion-science-32M")
44
+
45
+ # Compute text embeddings
46
+ embeddings = model.encode(["Example sentence"])
47
  ```
48
 
 
49
 
50
+ ## How it works
51
+
52
+ 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:
53
+ - Distillation: first, a model is distilled from a sentence transformer model using Model2Vec.
54
+ - Training data creation: the sentence transformer model is used to create training data by creating mean output embeddings on a large corpus.
55
+ - Training: the distilled model is trained on the training data using Tokenlearn.
56
+ - 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).
57
+
58
+ The results for this model can be found on the [Model2Vec results page](https://github.com/MinishLab/model2vec/blob/main/results/README.md).
59
 
60
+ ## Additional Resources
61
 
62
+ - [All Model2Vec models on the hub](https://huggingface.co/models?library=model2vec)
63
+ - [Model2Vec Repo](https://github.com/MinishLab/model2vec)
64
+ - [Tokenlearn repo](https://github.com/MinishLab/tokenlearn)
65
+ - [Model2Vec Results](https://github.com/MinishLab/model2vec/blob/main/results/README.md)
66
+ - [Model2Vec Tutorials](https://github.com/MinishLab/model2vec/tree/main/tutorials)
67
 
68
+ ## Library Authors
69
 
70
+ 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).
71
 
72
+ ## Citation
73
+
74
+ Please cite the [Model2Vec repository](https://github.com/MinishLab/model2vec) if you use this model in your work.
75
+ ```
76
+ @software{minishlab2024model2vec,
77
+ authors = {Stephan Tulkens, Thomas van Dongen},
78
+ title = {Model2Vec: Turn any Sentence Transformer into a Small Fast Model},
79
+ year = {2024},
80
+ url = {https://github.com/MinishLab/model2vec},
81
+ }
82
+ ```