Jarbas commited on
Commit
2c387aa
·
verified ·
1 Parent(s): b950142

Upload 5 files

Browse files
Files changed (3) hide show
  1. README.md +50 -9
  2. config.json +10 -0
  3. model.safetensors +2 -2
README.md CHANGED
@@ -1,37 +1,77 @@
1
  ---
2
- base_model: unknown
3
  library_name: model2vec
4
  license: mit
5
- model_name: model_mul_m2v-256-xlm-roberta-ovos-intent-classifier
6
  tags:
7
  - embeddings
8
  - static-embeddings
9
  - sentence-transformers
10
  ---
11
 
12
- # model_mul_m2v-256-xlm-roberta-ovos-intent-classifier Model Card
 
 
13
 
14
- This [Model2Vec](https://github.com/MinishLab/model2vec) model is a fine-tuned version of the [unknown](https://huggingface.co/unknown) Model2Vec model. It also includes a classifier head on top.
15
 
16
  ## Installation
17
 
18
  Install model2vec using pip:
19
  ```
20
- pip install model2vec[inference]
21
  ```
22
 
23
  ## Usage
 
 
 
 
 
24
  Load this model using the `from_pretrained` method:
25
  ```python
26
- from model2vec.inference import StaticModelPipeline
27
 
28
  # Load a pretrained Model2Vec model
29
- model = StaticModelPipeline.from_pretrained("model_mul_m2v-256-xlm-roberta-ovos-intent-classifier")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
- # Predict labels
32
- predicted = model.predict(["Example sentence"])
33
  ```
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  ## Additional Resources
36
 
37
  - [Model2Vec Repo](https://github.com/MinishLab/model2vec)
@@ -40,6 +80,7 @@ predicted = model.predict(["Example sentence"])
40
  - [Model2Vec Tutorials](https://github.com/MinishLab/model2vec/tree/main/tutorials)
41
  - [Website](https://minishlab.github.io/)
42
 
 
43
  ## Library Authors
44
 
45
  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).
 
1
  ---
2
+ base_model: fdemelo/xlm-roberta-ovos-intent-classifier
3
  library_name: model2vec
4
  license: mit
5
+ model_name: xlm-roberta-ovos-intent-classifier-distill256
6
  tags:
7
  - embeddings
8
  - static-embeddings
9
  - sentence-transformers
10
  ---
11
 
12
+ # xlm-roberta-ovos-intent-classifier-distill256 Model Card
13
+
14
+ This [Model2Vec](https://github.com/MinishLab/model2vec) model is a distilled version of the fdemelo/xlm-roberta-ovos-intent-classifier(https://huggingface.co/fdemelo/xlm-roberta-ovos-intent-classifier) 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.
15
 
 
16
 
17
  ## Installation
18
 
19
  Install model2vec using pip:
20
  ```
21
+ pip install model2vec
22
  ```
23
 
24
  ## Usage
25
+
26
+ ### Using Model2Vec
27
+
28
+ The [Model2Vec library](https://github.com/MinishLab/model2vec) is the fastest and most lightweight way to run Model2Vec models.
29
+
30
  Load this model using the `from_pretrained` method:
31
  ```python
32
+ from model2vec import StaticModel
33
 
34
  # Load a pretrained Model2Vec model
35
+ model = StaticModel.from_pretrained("xlm-roberta-ovos-intent-classifier-distill256")
36
+
37
+ # Compute text embeddings
38
+ embeddings = model.encode(["Example sentence"])
39
+ ```
40
+
41
+ ### Using Sentence Transformers
42
+
43
+ You can also use the [Sentence Transformers library](https://github.com/UKPLab/sentence-transformers) to load and use the model:
44
+
45
+ ```python
46
+ from sentence_transformers import SentenceTransformer
47
+
48
+ # Load a pretrained Sentence Transformer model
49
+ model = SentenceTransformer("xlm-roberta-ovos-intent-classifier-distill256")
50
 
51
+ # Compute text embeddings
52
+ embeddings = model.encode(["Example sentence"])
53
  ```
54
 
55
+ ### Distilling a Model2Vec model
56
+
57
+ 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:
58
+
59
+ ```python
60
+ from model2vec.distill import distill
61
+
62
+ # Distill a Sentence Transformer model, in this case the BAAI/bge-base-en-v1.5 model
63
+ m2v_model = distill(model_name="BAAI/bge-base-en-v1.5", pca_dims=256)
64
+
65
+ # Save the model
66
+ m2v_model.save_pretrained("m2v_model")
67
+ ```
68
+
69
+ ## How it works
70
+
71
+ 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.
72
+
73
+ 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.
74
+
75
  ## Additional Resources
76
 
77
  - [Model2Vec Repo](https://github.com/MinishLab/model2vec)
 
80
  - [Model2Vec Tutorials](https://github.com/MinishLab/model2vec/tree/main/tutorials)
81
  - [Website](https://minishlab.github.io/)
82
 
83
+
84
  ## Library Authors
85
 
86
  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).
config.json CHANGED
@@ -1,3 +1,13 @@
1
  {
 
 
 
 
 
 
 
 
 
 
2
  "normalize": true
3
  }
 
1
  {
2
+ "model_type": "model2vec",
3
+ "architectures": [
4
+ "StaticModel"
5
+ ],
6
+ "tokenizer_name": "fdemelo/xlm-roberta-ovos-intent-classifier",
7
+ "apply_pca": 256,
8
+ "apply_zipf": null,
9
+ "sif_coefficient": 0.0001,
10
+ "hidden_dim": 256,
11
+ "seq_length": 1000000,
12
  "normalize": true
13
  }
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4b7b8c2d655c6c902f302f772687ce5e98c79948717dc4718bc85062681bb37c
3
- size 255999064
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dc18801c94fa2aa77f2f1e074a2e17341d047dfbe0f882cc2ad415aac90b02e0
3
+ size 127999576