Pringled commited on
Commit
27f7810
1 Parent(s): af10ddd

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +75 -0
  2. config.json +1 -0
  3. model.safetensors +3 -0
  4. tokenizer.json +0 -0
README.md ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: model2vec
3
+ license: mit
4
+ model_name: potion-science-8M_weighted
5
+ tags:
6
+ - embeddings
7
+ - static-embeddings
8
+ ---
9
+
10
+ # potion-science-8M_weighted Model Card
11
+
12
+ This [Model2Vec](https://github.com/MinishLab/model2vec) model is a distilled version of a 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.
13
+
14
+
15
+ ## Installation
16
+
17
+ Install model2vec using pip:
18
+ ```
19
+ pip install model2vec
20
+ ```
21
+
22
+ ## Usage
23
+ Load this model using the `from_pretrained` method:
24
+ ```python
25
+ from model2vec import StaticModel
26
+
27
+ # Load a pretrained Model2Vec model
28
+ model = StaticModel.from_pretrained("potion-science-8M_weighted")
29
+
30
+ # Compute text embeddings
31
+ embeddings = model.encode(["Example sentence"])
32
+ ```
33
+
34
+ Alternatively, you can distill your own model using the `distill` method:
35
+ ```python
36
+ from model2vec.distill import distill
37
+
38
+ # Choose a Sentence Transformer model
39
+ model_name = "BAAI/bge-base-en-v1.5"
40
+
41
+ # Distill the model
42
+ m2v_model = distill(model_name=model_name, pca_dims=256)
43
+
44
+ # Save the model
45
+ m2v_model.save_pretrained("m2v_model")
46
+ ```
47
+
48
+ ## How it works
49
+
50
+ 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.
51
+
52
+ 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.
53
+
54
+ ## Additional Resources
55
+
56
+ - [All Model2Vec models on the hub](https://huggingface.co/models?library=model2vec)
57
+ - [Model2Vec Repo](https://github.com/MinishLab/model2vec)
58
+ - [Model2Vec Results](https://github.com/MinishLab/model2vec?tab=readme-ov-file#results)
59
+ - [Model2Vec Tutorials](https://github.com/MinishLab/model2vec/tree/main/tutorials)
60
+
61
+ ## Library Authors
62
+
63
+ 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).
64
+
65
+ ## Citation
66
+
67
+ Please cite the [Model2Vec repository](https://github.com/MinishLab/model2vec) if you use this model in your work.
68
+ ```
69
+ @software{minishlab2024model2vec,
70
+ authors = {Stephan Tulkens, Thomas van Dongen},
71
+ title = {Model2Vec: Turn any Sentence Transformer into a Small Fast Model},
72
+ year = {2024},
73
+ url = {https://github.com/MinishLab/model2vec},
74
+ }
75
+ ```
config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"tokenizer_name": "baai/bge-base-en-v1.5", "apply_pca": 256, "apply_zipf": true, "hidden_dim": 256, "seq_length": 1000000, "normalize": true}
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b74373190f7d7fcc76eba1caffc186c36e13bf40cd4094b7003c019942e28651
3
+ size 30236760
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff