ashercn97 commited on
Commit
bd43680
·
verified ·
1 Parent(s): d05dce2

Upload folder using huggingface_hub

Browse files
Files changed (7) hide show
  1. .gitattributes +1 -0
  2. README.md +97 -0
  3. config.json +3 -0
  4. model.safetensors +3 -0
  5. modules.json +14 -0
  6. pipeline.skops +3 -0
  7. tokenizer.json +0 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ pipeline.skops filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: model2vec
3
+ license: mit
4
+ model_name: tmpbjpopgfc
5
+ tags:
6
+ - embeddings
7
+ - static-embeddings
8
+ - sentence-transformers
9
+ ---
10
+
11
+ # tmpbjpopgfc Model Card
12
+
13
+ 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. 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.
14
+
15
+
16
+ ## Installation
17
+
18
+ Install model2vec using pip:
19
+ ```
20
+ pip install model2vec
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ### Using Model2Vec
26
+
27
+ The [Model2Vec library](https://github.com/MinishLab/model2vec) is the fastest and most lightweight way to run Model2Vec models.
28
+
29
+ Load this model using the `from_pretrained` method:
30
+ ```python
31
+ from model2vec import StaticModel
32
+
33
+ # Load a pretrained Model2Vec model
34
+ model = StaticModel.from_pretrained("tmpbjpopgfc")
35
+
36
+ # Compute text embeddings
37
+ embeddings = model.encode(["Example sentence"])
38
+ ```
39
+
40
+ ### Using Sentence Transformers
41
+
42
+ You can also use the [Sentence Transformers library](https://github.com/UKPLab/sentence-transformers) to load and use the model:
43
+
44
+ ```python
45
+ from sentence_transformers import SentenceTransformer
46
+
47
+ # Load a pretrained Sentence Transformer model
48
+ model = SentenceTransformer("tmpbjpopgfc")
49
+
50
+ # Compute text embeddings
51
+ embeddings = model.encode(["Example sentence"])
52
+ ```
53
+
54
+ ### Distilling a Model2Vec model
55
+
56
+ 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:
57
+
58
+ ```python
59
+ from model2vec.distill import distill
60
+
61
+ # Distill a Sentence Transformer model, in this case the BAAI/bge-base-en-v1.5 model
62
+ m2v_model = distill(model_name="BAAI/bge-base-en-v1.5", pca_dims=256)
63
+
64
+ # Save the model
65
+ m2v_model.save_pretrained("m2v_model")
66
+ ```
67
+
68
+ ## How it works
69
+
70
+ 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.
71
+
72
+ 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.
73
+
74
+ ## Additional Resources
75
+
76
+ - [Model2Vec Repo](https://github.com/MinishLab/model2vec)
77
+ - [Model2Vec Base Models](https://huggingface.co/collections/minishlab/model2vec-base-models-66fd9dd9b7c3b3c0f25ca90e)
78
+ - [Model2Vec Results](https://github.com/MinishLab/model2vec/tree/main/results)
79
+ - [Model2Vec Tutorials](https://github.com/MinishLab/model2vec/tree/main/tutorials)
80
+ - [Website](https://minishlab.github.io/)
81
+
82
+
83
+ ## Library Authors
84
+
85
+ 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).
86
+
87
+ ## Citation
88
+
89
+ Please cite the [Model2Vec repository](https://github.com/MinishLab/model2vec) if you use this model in your work.
90
+ ```
91
+ @software{minishlab2024model2vec,
92
+ authors = {Stephan Tulkens and Thomas van Dongen},
93
+ title = {Model2Vec: Fast State-of-the-Art Static Embeddings},
94
+ year = {2024},
95
+ url = {https://github.com/MinishLab/model2vec}
96
+ }
97
+ ```
config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "normalize": true
3
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cc92ac14218b2d44f5f1475231a62c6316e26d4b66694fa19af793de0e57785f
3
+ size 129210456
modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": ".",
6
+ "type": "sentence_transformers.models.StaticEmbedding"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Normalize",
12
+ "type": "sentence_transformers.models.Normalize"
13
+ }
14
+ ]
pipeline.skops ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:952e1226a1b6c4bb27bf801eed66ee5e1ac956a1a77dc2b921be52aa4d4bb948
3
+ size 7439912
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff