Stopwolf commited on
Commit
6806ff1
·
verified ·
1 Parent(s): d0d1b09

Upload folder using huggingface_hub

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