blobbybob commited on
Commit
71d989d
·
verified ·
1 Parent(s): 2691850

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +29 -50
README.md CHANGED
@@ -11,10 +11,7 @@ tags:
11
 
12
  # potion-256d-v3 Model Card
13
 
14
- This [Model2Vec](https://github.com/MinishLab/model2vec) model is a distilled static embedding model based on [mixedbread-ai/mxbai-embed-large-v1](https://huggingface.co/mixedbread-ai/mxbai-embed-large-v1). 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.
15
-
16
- This model achieves **72.17 CatAVG** on a 25-task English MTEB benchmark (STS: 79.32, Classification: 63.23, PairClassification: 73.97), trained with contrastive tokenlearn, born-again self-distillation, power normalization, and PCA 512D-to-256D compression.
17
-
18
 
19
  ## Installation
20
 
@@ -25,10 +22,6 @@ pip install model2vec
25
 
26
  ## Usage
27
 
28
- ### Using Model2Vec
29
-
30
- The [Model2Vec library](https://github.com/MinishLab/model2vec) is the fastest and most lightweight way to run Model2Vec models.
31
-
32
  Load this model using the `from_pretrained` method:
33
  ```python
34
  from model2vec import StaticModel
@@ -40,61 +33,47 @@ model = StaticModel.from_pretrained("blobbybob/potion-256d-v3")
40
  embeddings = model.encode(["Example sentence"])
41
  ```
42
 
43
- ### Using Sentence Transformers
44
-
45
- You can also use the [Sentence Transformers library](https://github.com/UKPLab/sentence-transformers) to load and use the model:
46
-
47
- ```python
48
- from sentence_transformers import SentenceTransformer
49
-
50
- # Load a pretrained Sentence Transformer model
51
- model = SentenceTransformer("blobbybob/potion-256d-v3")
52
-
53
- # Compute text embeddings
54
- embeddings = model.encode(["Example sentence"])
55
- ```
56
-
57
- ### Distilling a Model2Vec model
58
-
59
- 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:
60
 
61
- ```python
62
- from model2vec.distill import distill
63
 
64
- # Distill a Sentence Transformer model, in this case the BAAI/bge-base-en-v1.5 model
65
- m2v_model = distill(model_name="BAAI/bge-base-en-v1.5", pca_dims=256)
 
 
 
 
66
 
67
- # Save the model
68
- m2v_model.save_pretrained("m2v_model")
69
- ```
70
 
71
- ## How it works
 
 
 
 
 
72
 
73
- 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.
74
-
75
- 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.
76
 
77
  ## Additional Resources
78
 
 
79
  - [Model2Vec Repo](https://github.com/MinishLab/model2vec)
80
- - [Model2Vec Base Models](https://huggingface.co/collections/minishlab/model2vec-base-models-66fd9dd9b7c3b3c0f25ca90e)
81
- - [Model2Vec Results](https://github.com/MinishLab/model2vec/tree/main/results)
82
  - [Model2Vec Tutorials](https://github.com/MinishLab/model2vec/tree/main/tutorials)
83
- - [Website](https://minishlab.github.io/)
84
-
85
-
86
- ## Library Authors
87
-
88
- 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).
89
 
90
  ## Citation
91
 
92
  Please cite the [Model2Vec repository](https://github.com/MinishLab/model2vec) if you use this model in your work.
93
- ```
94
- @article{minishlab2024model2vec,
95
- author = {Tulkens, Stephan and {van Dongen}, Thomas},
96
- title = {Model2Vec: Fast State-of-the-Art Static Embeddings},
97
- year = {2024},
98
- url = {https://github.com/MinishLab/model2vec}
 
 
 
99
  }
100
  ```
 
11
 
12
  # potion-256d-v3 Model Card
13
 
14
+ This [Model2Vec](https://github.com/MinishLab/model2vec) model is an improved v3 static embedding model, pre-trained using [Tokenlearn](https://github.com/MinishLab/tokenlearn) with contrastive learning and born-again self-distillation. It is distilled from [mixedbread-ai/mxbai-embed-large-v1](https://huggingface.co/mixedbread-ai/mxbai-embed-large-v1). 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. This model improves on [potion-base-32M](https://huggingface.co/minishlab/potion-base-32M) by +2.31 CatAVG through a stronger teacher model, contrastive tokenlearn training, born-again self-distillation, power normalization, and PCA 512D-to-256D compression.
 
 
 
15
 
16
  ## Installation
17
 
 
22
 
23
  ## Usage
24
 
 
 
 
 
25
  Load this model using the `from_pretrained` method:
26
  ```python
27
  from model2vec import StaticModel
 
33
  embeddings = model.encode(["Example sentence"])
34
  ```
35
 
36
+ ## How it works
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
+ 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:
 
39
 
40
+ - **Distillation:** a model is distilled from [mxbai-embed-large-v1](https://huggingface.co/mixedbread-ai/mxbai-embed-large-v1) at 512 dimensions using Model2Vec with a 63K token vocabulary.
41
+ - **Training data creation:** the teacher model is used to create training data by encoding 500K sentences from C4.
42
+ - **Contrastive training:** the distilled model is trained on the training data using Tokenlearn with contrastive loss.
43
+ - **Born-again self-distillation:** the trained model is further improved by distilling from itself (alpha=1.0), gaining +0.5 CatAVG.
44
+ - **Power normalization:** embeddings are transformed with sign(E) * |E|^0.7 for improved isotropy.
45
+ - **PCA compression:** the 512D model is compressed to 256D via PCA, preserving more variance than training directly at 256D.
46
 
47
+ ## Results
 
 
48
 
49
+ | Model | STS | Classification | PairClassification | CatAVG |
50
+ |:------|----:|---------------:|-------------------:|-------:|
51
+ | **[potion-256d-v3](https://huggingface.co/blobbybob/potion-256d-v3)** | **79.32** | **63.23** | **73.97** | **72.17** |
52
+ | [potion-base-32M](https://huggingface.co/minishlab/potion-base-32M) | 78.97 | 61.42 | 69.18 | 69.86 |
53
+ | [all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) | 78.95 | 69.25 | 82.37 | 74.65 |
54
+ | [GloVe 300d](https://huggingface.co/sentence-transformers/average_word_embeddings_glove.6B.300d) | 61.52 | 62.73 | 72.48 | 61.45 |
55
 
56
+ The results show that **potion-256d-v3** outperforms potion-base-32M by +2.31 CatAVG while remaining orders of magnitude faster than transformer models like all-MiniLM-L6-v2.
 
 
57
 
58
  ## Additional Resources
59
 
60
+ - [All Model2Vec models on the hub](https://huggingface.co/models?library=model2vec)
61
  - [Model2Vec Repo](https://github.com/MinishLab/model2vec)
62
+ - [Tokenlearn repo](https://github.com/MinishLab/tokenlearn)
63
+ - [Model2Vec Results](https://github.com/MinishLab/model2vec/blob/main/results/README.md)
64
  - [Model2Vec Tutorials](https://github.com/MinishLab/model2vec/tree/main/tutorials)
 
 
 
 
 
 
65
 
66
  ## Citation
67
 
68
  Please cite the [Model2Vec repository](https://github.com/MinishLab/model2vec) if you use this model in your work.
69
+ ```bibtex
70
+ @software{minishlab2024model2vec,
71
+ author = {Stephan Tulkens and {van Dongen}, Thomas},
72
+ title = {Model2Vec: Fast State-of-the-Art Static Embeddings},
73
+ year = {2024},
74
+ publisher = {Zenodo},
75
+ doi = {10.5281/zenodo.17270888},
76
+ url = {https://github.com/MinishLab/model2vec},
77
+ license = {MIT}
78
  }
79
  ```