davidberenstein1957 commited on
Commit
d29516f
·
verified ·
1 Parent(s): 935280e

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +110 -50
README.md CHANGED
@@ -1,92 +1,152 @@
1
  ---
2
- base_model: unknown
 
 
3
  library_name: model2vec
4
  license: mit
5
- model_name: tmpa7om157k
6
  tags:
7
- - embeddings
8
  - static-embeddings
9
- - sentence-transformers
 
10
  ---
11
 
12
- # tmpa7om157k Model Card
 
 
13
 
14
- This [Model2Vec](https://github.com/MinishLab/model2vec) model is a distilled version of the unknown(https://huggingface.co/unknown) 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("tmpa7om157k")
 
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("tmpa7om157k")
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)
78
- - [Model2Vec Base Models](https://huggingface.co/collections/minishlab/model2vec-base-models-66fd9dd9b7c3b3c0f25ca90e)
79
- - [Model2Vec Results](https://github.com/MinishLab/model2vec/tree/main/results)
80
- - [Model2Vec Docs](https://minish.ai/packages/model2vec/introduction)
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
  author = {Stephan Tulkens and {van Dongen}, Thomas},
 
1
  ---
2
+ base_model: minishlab/potion-base-8m
3
+ datasets:
4
+ - google/jigsaw_toxicity_pred
5
  library_name: model2vec
6
  license: mit
7
+ model_name: enguard/tiny-guard-8m-en-prompt-toxicity-binary-jigsaw
8
  tags:
 
9
  - static-embeddings
10
+ - text-classification
11
+ - model2vec
12
  ---
13
 
14
+ # enguard/tiny-guard-8m-en-prompt-toxicity-binary-jigsaw
15
+
16
+ This model is a fine-tuned Model2Vec classifier based on [minishlab/potion-base-8m](https://huggingface.co/minishlab/potion-base-8m) for the prompt-toxicity-binary found in the [google/jigsaw_toxicity_pred](https://huggingface.co/datasets/google/jigsaw_toxicity_pred) dataset.
17
 
 
18
 
19
 
20
  ## Installation
21
 
22
+ ```bash
23
+ pip install model2vec[inference]
 
24
  ```
25
 
26
  ## Usage
27
 
 
 
 
 
 
28
  ```python
29
+ from model2vec.inference import StaticModelPipeline
30
 
31
+ model = StaticModelPipeline.from_pretrained(
32
+ "enguard/tiny-guard-8m-en-prompt-toxicity-binary-jigsaw"
33
+ )
34
 
 
 
 
 
 
35
 
36
+ # Supports single texts. Format input as a single text:
37
+ text = "Example sentence"
38
 
39
+ model.predict([text])
40
+ model.predict_proba([text])
41
 
 
 
 
 
 
42
  ```
43
 
44
+ ## Why should you use these models?
45
+
46
+ - Optimized for precision to reduce false positives.
47
+ - Extremely fast inference: up to x500 faster than SetFit.
48
+
49
+ ## This model variant
50
+
51
+ Below is a quick overview of the model variant and core metrics.
52
+
53
+ | Field | Value |
54
+ |---|---|
55
+ | Classifies | prompt-toxicity-binary |
56
+ | Base Model | [minishlab/potion-base-8m](https://huggingface.co/minishlab/potion-base-8m) |
57
+ | Precision | 0.9514 |
58
+ | Recall | 0.8297 |
59
+ | F1 | 0.8864 |
60
+
61
+ ### Confusion Matrix
62
+
63
+ | True \ Predicted | FAIL | PASS |
64
+ | --- | --- | --- |
65
+ | **FAIL** | 1291 | 265 |
66
+ | **PASS** | 66 | 1437 |
67
+
68
+ <details>
69
+ <summary><b>Full metrics (JSON)</b></summary>
70
+
71
+ ```json
72
+ {
73
+ "FAIL": {
74
+ "precision": 0.9513633014001474,
75
+ "recall": 0.8296915167095116,
76
+ "f1-score": 0.8863714383796774,
77
+ "support": 1556.0
78
+ },
79
+ "PASS": {
80
+ "precision": 0.8443008225616921,
81
+ "recall": 0.9560878243512974,
82
+ "f1-score": 0.8967238689547582,
83
+ "support": 1503.0
84
+ },
85
+ "accuracy": 0.8917947041516836,
86
+ "macro avg": {
87
+ "precision": 0.8978320619809197,
88
+ "recall": 0.8928896705304045,
89
+ "f1-score": 0.8915476536672178,
90
+ "support": 3059.0
91
+ },
92
+ "weighted avg": {
93
+ "precision": 0.8987595401401937,
94
+ "recall": 0.8917947041516836,
95
+ "f1-score": 0.8914579709571034,
96
+ "support": 3059.0
97
+ }
98
+ }
99
+ ```
100
+ </details>
101
 
 
102
 
103
+ <details>
104
+ <summary><b>Sample Predictions</b></summary>
105
 
106
+ | Text | True Label | Predicted Label |
107
+ |------|------------|-----------------|
108
+ | ":::SLR Chronology bibliography is complete<br><br>Hi, MurderWatcher1. This is Paul1513 again. This is to let you know that I have completed the SLR Chronology bibliography for you and that I am going to try to upload a PDF copy to your Talk page as soon as I finish this note. This may take a while, because I've never uploaded a PDF before.<br><br>You're absolutely right; it would be great if some of the old Modern Photography stuff could be added to Wikipedia. However, you can be sure that they're still under copyright. (Pre-1978 American ""work-for-hire"" copyrights are generally 75 years; 1978 and on, 95 years.) The real question is: Who OWNS the copyright today? Since Modern went under, there have been many media company sales and resales - the present copyright holder would be hell to uncover and ask permission. In fact, the current owner might not even know that it owns Modern's copyrights. ""Orphaned"" copyrights are a major unresolved ""fair use"" issue in the information age.<br><br>Speaking of first cameras: mine was a simple Vivitar 110 point-and-shoot. My parents gave it to me for getting straight A's in the 5th grade. It was, of course, a bad camera, but it opened up a world of possibilities. From the Vivitar, I eventually learned about the existence of the Pentax Auto 110 SLR. It was then one step to 35 mm SLRs and I got a Nikon FE2 in 1983. The FE2 is also the reason why the bulk of my Modern Photography magazine citations begin around 1983.<br><br>I'm sorry to hear about your disputes with the Admins over your non-photography Wkipedia entries. It would be unfortunate if you felt compelled to end your Wikipedia activities over them. Perhaps you could start a blog or create a MySpace or Facebook page to air these issues without worrying about what the Admins want. However, I will respect whatever your decision is, as I fully understand that the most sophisticated machine is nothing next to a human life.<br><br>You can reach me on my Talk page. Thanks Muchly <br><br>" | PASS | PASS |
109
+ | Are you deaf or blind? I repeat. It started in late 2009, and collapsed in mid 2010, as supported by cites and polls. | FAIL | PASS |
110
+ | "<br>Thanks for your note. I've been reporting accounts like these for over a year now and they all almost always get an indefinite block since they are vandalism only accounts. Blocks are necessary in these cases as it is not known when any person behind these accounts may come back and vandalize again. I see you have again removed these reports from the noticeboard which I have to again disagree with. therefore I kindly request you to put them back on the noticeboard for another administrator to review. ~ (talk) " | PASS | PASS |
111
+ | SOMEGUY1221 LIKES TO SUCK LARGE HARD PENIS. | FAIL | FAIL |
112
+ | "<br>Well, you're using criteria that you have decided constitute a legitimate decision procedure for establishing whether something is Israeli. Content decisions can't be made that way here. I have a decision procedure that enables me to decide who is an idiot and yet annoyingly I am not allowed to deploy it in articles about living people who clearly meet the criteria. ''' - talk''' " | FAIL | PASS |
113
+ | ":::SLR Chronology bibliography is complete<br><br>Hi, MurderWatcher1. This is Paul1513 again. This is to let you know that I have completed the SLR Chronology bibliography for you and that I am going to try to upload a PDF copy to your Talk page as soon as I finish this note. This may take a while, because I've never uploaded a PDF before.<br><br>You're absolutely right; it would be great if some of the old Modern Photography stuff could be added to Wikipedia. However, you can be sure that they're still under copyright. (Pre-1978 American ""work-for-hire"" copyrights are generally 75 years; 1978 and on, 95 years.) The real question is: Who OWNS the copyright today? Since Modern went under, there have been many media company sales and resales - the present copyright holder would be hell to uncover and ask permission. In fact, the current owner might not even know that it owns Modern's copyrights. ""Orphaned"" copyrights are a major unresolved ""fair use"" issue in the information age.<br><br>Speaking of first cameras: mine was a simple Vivitar 110 point-and-shoot. My parents gave it to me for getting straight A's in the 5th grade. It was, of course, a bad camera, but it opened up a world of possibilities. From the Vivitar, I eventually learned about the existence of the Pentax Auto 110 SLR. It was then one step to 35 mm SLRs and I got a Nikon FE2 in 1983. The FE2 is also the reason why the bulk of my Modern Photography magazine citations begin around 1983.<br><br>I'm sorry to hear about your disputes with the Admins over your non-photography Wkipedia entries. It would be unfortunate if you felt compelled to end your Wikipedia activities over them. Perhaps you could start a blog or create a MySpace or Facebook page to air these issues without worrying about what the Admins want. However, I will respect whatever your decision is, as I fully understand that the most sophisticated machine is nothing next to a human life.<br><br>You can reach me on my Talk page. Thanks Muchly <br><br>" | PASS | PASS |
114
+ </details>
115
 
 
 
 
116
 
117
+ <details>
118
+ <summary><b>Prediction Speed Benchmarks</b></summary>
119
 
120
+ | Dataset Size | Time (seconds) | Predictions/Second |
121
+ |--------------|----------------|---------------------|
122
+ | 1 | 0.0008 | 1329.41 |
123
+ | 1000 | 0.1262 | 7924.43 |
124
+ | 3059 | 0.3569 | 8570.89 |
125
+ </details>
126
 
 
127
 
128
+ ## Other model variants
129
 
130
+ Below is a general overview of the best-performing models for each dataset variant.
 
 
 
131
 
132
+ | Classifies | Model | Precision | Recall | F1 |
133
+ | --- | --- | --- | --- | --- |
134
+ | prompt-toxicity-binary | [enguard/tiny-guard-2m-en-prompt-toxicity-binary-jigsaw](https://huggingface.co/enguard/tiny-guard-2m-en-prompt-toxicity-binary-jigsaw) | 0.9531 | 0.7699 | 0.8518 |
135
+ | prompt-toxicity-binary | [enguard/tiny-guard-4m-en-prompt-toxicity-binary-jigsaw](https://huggingface.co/enguard/tiny-guard-4m-en-prompt-toxicity-binary-jigsaw) | 0.9507 | 0.8303 | 0.8864 |
136
+ | prompt-toxicity-binary | [enguard/tiny-guard-8m-en-prompt-toxicity-binary-jigsaw](https://huggingface.co/enguard/tiny-guard-8m-en-prompt-toxicity-binary-jigsaw) | 0.9514 | 0.8297 | 0.8864 |
137
+ | prompt-toxicity-binary | [enguard/small-guard-32m-en-prompt-toxicity-binary-jigsaw](https://huggingface.co/enguard/small-guard-32m-en-prompt-toxicity-binary-jigsaw) | 0.9403 | 0.8605 | 0.8987 |
138
+ | prompt-toxicity-binary | [enguard/medium-guard-128m-xx-prompt-toxicity-binary-jigsaw](https://huggingface.co/enguard/medium-guard-128m-xx-prompt-toxicity-binary-jigsaw) | 0.9111 | 0.8625 | 0.8861 |
139
 
140
+ ## Resources
141
 
142
+ - Awesome AI Guardrails: <https://github.com/enguard-ai/awesome-ai-guardails>
143
+ - Model2Vec: https://github.com/MinishLab/model2vec
144
+ - Docs: https://minish.ai/packages/model2vec/introduction
145
 
146
  ## Citation
147
 
148
+ If you use this model, please cite Model2Vec:
149
+
150
  ```
151
  @software{minishlab2024model2vec,
152
  author = {Stephan Tulkens and {van Dongen}, Thomas},