Skip to content

Commit 84e3fa8

Browse files
authored
docs: Update model card template (#192)
* Updated model card template * Updated model card template
1 parent 4502448 commit 84e3fa8

File tree

2 files changed

+40
-18
lines changed

2 files changed

+40
-18
lines changed

model2vec/modelcards/classifier_template.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ predicted = model.predict(["Example sentence"])
2727

2828
## Additional Resources
2929

30-
- [All Model2Vec models on the hub](https://huggingface.co/models?library=model2vec)
3130
- [Model2Vec Repo](https://github.com/MinishLab/model2vec)
32-
- [Model2Vec Results](https://github.com/MinishLab/model2vec?tab=readme-ov-file#results)
31+
- [Model2Vec Base Models](https://huggingface.co/collections/minishlab/model2vec-base-models-66fd9dd9b7c3b3c0f25ca90e)
32+
- [Model2Vec Results](https://github.com/MinishLab/model2vec/tree/main/results)
3333
- [Model2Vec Tutorials](https://github.com/MinishLab/model2vec/tree/main/tutorials)
34+
- [Website](https://minishlab.github.io/)
3435

3536
## Library Authors
3637

@@ -41,9 +42,9 @@ Model2Vec was developed by the [Minish Lab](https://github.com/MinishLab) team c
4142
Please cite the [Model2Vec repository](https://github.com/MinishLab/model2vec) if you use this model in your work.
4243
```
4344
@software{minishlab2024model2vec,
44-
authors = {Stephan Tulkens, Thomas van Dongen},
45-
title = {Model2Vec: Turn any Sentence Transformer into a Small Fast Model},
45+
authors = {Stephan Tulkens and Thomas van Dongen},
46+
title = {Model2Vec: Fast State-of-the-Art Static Embeddings},
4647
year = {2024},
47-
url = {https://github.com/MinishLab/model2vec},
48+
url = {https://github.com/MinishLab/model2vec}
4849
}
4950
```

model2vec/modelcards/model_card_template.md

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# {{ model_name }} Model Card
66

7-
This [Model2Vec](https://github.com/MinishLab/model2vec) model is a distilled version of {% if base_model %}the {{ base_model }}(https://huggingface.co/{{ base_model }}){% else %}a{% endif %} 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.
7+
This [Model2Vec](https://github.com/MinishLab/model2vec) model is a distilled version of {% if base_model %}the {{ base_model }}(https://huggingface.co/{{ base_model }}){% else %}a{% endif %} 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. 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.
88

99

1010
## Installation
@@ -15,6 +15,11 @@ pip install model2vec
1515
```
1616

1717
## Usage
18+
19+
### Using Model2Vec
20+
21+
The [Model2Vec library](https://github.com/MinishLab/model2vec) is the fastest and most lightweight way to run Model2Vec models.
22+
1823
Load this model using the `from_pretrained` method:
1924
```python
2025
from model2vec import StaticModel
@@ -26,15 +31,29 @@ model = StaticModel.from_pretrained("{{ model_name }}")
2631
embeddings = model.encode(["Example sentence"])
2732
```
2833

29-
Alternatively, you can distill your own model using the `distill` method:
34+
### Using Sentence Transformers
35+
36+
You can also use the [Sentence Transformers library](https://github.com/UKPLab/sentence-transformers) to load and use the model:
37+
3038
```python
31-
from model2vec.distill import distill
39+
from sentence_transformers import SentenceTransformer
40+
41+
# Load a pretrained Sentence Transformer model
42+
model = SentenceTransformer("{{ model_name }}")
43+
44+
# Compute text embeddings
45+
embeddings = model.encode(["Example sentence"])
46+
```
47+
48+
### Distilling a Model2Vec model
3249

33-
# Choose a Sentence Transformer model
34-
model_name = "BAAI/bge-base-en-v1.5"
50+
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:
3551

36-
# Distill the model
37-
m2v_model = distill(model_name=model_name, pca_dims=256)
52+
```python
53+
from model2vec.distill import distill
54+
55+
# Distill a Sentence Transformer model, in this case the BAAI/bge-base-en-v1.5 model
56+
m2v_model = distill(model_name="BAAI/bge-base-en-v1.5", pca_dims=256)
3857

3958
# Save the model
4059
m2v_model.save_pretrained("m2v_model")
@@ -44,14 +63,16 @@ m2v_model.save_pretrained("m2v_model")
4463

4564
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.
4665

47-
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.
66+
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.
4867

4968
## Additional Resources
5069

51-
- [All Model2Vec models on the hub](https://huggingface.co/models?library=model2vec)
5270
- [Model2Vec Repo](https://github.com/MinishLab/model2vec)
53-
- [Model2Vec Results](https://github.com/MinishLab/model2vec?tab=readme-ov-file#results)
71+
- [Model2Vec Base Models](https://huggingface.co/collections/minishlab/model2vec-base-models-66fd9dd9b7c3b3c0f25ca90e)
72+
- [Model2Vec Results](https://github.com/MinishLab/model2vec/tree/main/results)
5473
- [Model2Vec Tutorials](https://github.com/MinishLab/model2vec/tree/main/tutorials)
74+
- [Website](https://minishlab.github.io/)
75+
5576

5677
## Library Authors
5778

@@ -62,9 +83,9 @@ Model2Vec was developed by the [Minish Lab](https://github.com/MinishLab) team c
6283
Please cite the [Model2Vec repository](https://github.com/MinishLab/model2vec) if you use this model in your work.
6384
```
6485
@software{minishlab2024model2vec,
65-
authors = {Stephan Tulkens, Thomas van Dongen},
66-
title = {Model2Vec: Turn any Sentence Transformer into a Small Fast Model},
86+
authors = {Stephan Tulkens and Thomas van Dongen},
87+
title = {Model2Vec: Fast State-of-the-Art Static Embeddings},
6788
year = {2024},
68-
url = {https://github.com/MinishLab/model2vec},
89+
url = {https://github.com/MinishLab/model2vec}
6990
}
7091
```

0 commit comments

Comments
 (0)