giangndm commited on
Commit
0b8a351
·
verified ·
1 Parent(s): f305143

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. README.md +188 -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,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: codefuse-ai/F2LLM-v2-330M
3
+ language:
4
+ - en
5
+ - zh
6
+ - ru
7
+ - es
8
+ - fr
9
+ - de
10
+ - ar
11
+ - nl
12
+ - vi
13
+ - hi
14
+ - ko
15
+ - ja
16
+ - it
17
+ - id
18
+ - pt
19
+ - pl
20
+ - tr
21
+ - da
22
+ - th
23
+ - sv
24
+ - fa
25
+ - uk
26
+ - cs
27
+ - 'no'
28
+ - el
29
+ - ca
30
+ - ro
31
+ - fi
32
+ - bg
33
+ - tl
34
+ - gl
35
+ - my
36
+ - hy
37
+ - km
38
+ - ne
39
+ - hu
40
+ - eu
41
+ - he
42
+ - lo
43
+ - sw
44
+ - az
45
+ - lv
46
+ - si
47
+ - sk
48
+ - tg
49
+ - et
50
+ - lt
51
+ - ms
52
+ - hr
53
+ - is
54
+ - sl
55
+ - sr
56
+ - ur
57
+ - bn
58
+ - af
59
+ - ta
60
+ - ka
61
+ - te
62
+ - ml
63
+ - mn
64
+ - nn
65
+ - kk
66
+ - cy
67
+ - mr
68
+ - sq
69
+ - nb
70
+ - mk
71
+ - jv
72
+ - kn
73
+ - eo
74
+ - la
75
+ - gu
76
+ - uz
77
+ - am
78
+ - oc
79
+ - be
80
+ - mg
81
+ - vo
82
+ - pa
83
+ - lb
84
+ - ht
85
+ - br
86
+ - ga
87
+ - xh
88
+ - tt
89
+ - bs
90
+ - yo
91
+ library_name: model2vec
92
+ license: mit
93
+ model_name: giangndm/F2LLM-v2-330M-model2vec
94
+ tags:
95
+ - embeddings
96
+ - static-embeddings
97
+ - sentence-transformers
98
+ ---
99
+
100
+ # giangndm/F2LLM-v2-330M-model2vec Model Card
101
+
102
+ This [Model2Vec](https://github.com/MinishLab/model2vec) model is a distilled version of the codefuse-ai/F2LLM-v2-330M(https://huggingface.co/codefuse-ai/F2LLM-v2-330M) 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.
103
+
104
+
105
+ ## Installation
106
+
107
+ Install model2vec using pip:
108
+ ```
109
+ pip install model2vec
110
+ ```
111
+
112
+ ## Usage
113
+
114
+ ### Using Model2Vec
115
+
116
+ The [Model2Vec library](https://github.com/MinishLab/model2vec) is the fastest and most lightweight way to run Model2Vec models.
117
+
118
+ Load this model using the `from_pretrained` method:
119
+ ```python
120
+ from model2vec import StaticModel
121
+
122
+ # Load a pretrained Model2Vec model
123
+ model = StaticModel.from_pretrained("giangndm/F2LLM-v2-330M-model2vec")
124
+
125
+ # Compute text embeddings
126
+ embeddings = model.encode(["Example sentence"])
127
+ ```
128
+
129
+ ### Using Sentence Transformers
130
+
131
+ You can also use the [Sentence Transformers library](https://github.com/UKPLab/sentence-transformers) to load and use the model:
132
+
133
+ ```python
134
+ from sentence_transformers import SentenceTransformer
135
+
136
+ # Load a pretrained Sentence Transformer model
137
+ model = SentenceTransformer("giangndm/F2LLM-v2-330M-model2vec")
138
+
139
+ # Compute text embeddings
140
+ embeddings = model.encode(["Example sentence"])
141
+ ```
142
+
143
+ ### Distilling a Model2Vec model
144
+
145
+ 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:
146
+
147
+ ```python
148
+ from model2vec.distill import distill
149
+
150
+ # Distill a Sentence Transformer model, in this case the BAAI/bge-base-en-v1.5 model
151
+ m2v_model = distill(model_name="BAAI/bge-base-en-v1.5", pca_dims=256)
152
+
153
+ # Save the model
154
+ m2v_model.save_pretrained("m2v_model")
155
+ ```
156
+
157
+ ## How it works
158
+
159
+ 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.
160
+
161
+ 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.
162
+
163
+ ## Additional Resources
164
+
165
+ - [Model2Vec Repo](https://github.com/MinishLab/model2vec)
166
+ - [Model2Vec Base Models](https://huggingface.co/collections/minishlab/model2vec-base-models-66fd9dd9b7c3b3c0f25ca90e)
167
+ - [Model2Vec Results](https://github.com/MinishLab/model2vec/tree/main/results)
168
+ - [Model2Vec Docs](https://minish.ai/packages/model2vec/introduction)
169
+
170
+
171
+ ## Library Authors
172
+
173
+ 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).
174
+
175
+ ## Citation
176
+
177
+ Please cite the [Model2Vec repository](https://github.com/MinishLab/model2vec) if you use this model in your work.
178
+ ```
179
+ @software{minishlab2024model2vec,
180
+ author = {Stephan Tulkens and {van Dongen}, Thomas},
181
+ title = {Model2Vec: Fast State-of-the-Art Static Embeddings},
182
+ year = {2024},
183
+ publisher = {Zenodo},
184
+ doi = {10.5281/zenodo.17270888},
185
+ url = {https://github.com/MinishLab/model2vec},
186
+ license = {MIT}
187
+ }
188
+ ```
config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "model2vec",
3
+ "architectures": [
4
+ "StaticModel"
5
+ ],
6
+ "tokenizer_name": "codefuse-ai/F2LLM-v2-330M",
7
+ "apply_pca": 512,
8
+ "sif_coefficient": 0.0001,
9
+ "hidden_dim": 512,
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:c2c883b61ca1629518c0959aa939c040db48584103b73fc7504f1a55003a8d0d
3
+ size 155283544
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