Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,92 +1,182 @@
|
|
| 1 |
---
|
| 2 |
-
base_model:
|
|
|
|
|
|
|
| 3 |
library_name: model2vec
|
| 4 |
license: mit
|
| 5 |
-
model_name:
|
| 6 |
tags:
|
| 7 |
-
- embeddings
|
| 8 |
- static-embeddings
|
| 9 |
-
-
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
-
#
|
|
|
|
|
|
|
| 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 |
-
|
| 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
|
| 33 |
-
|
| 34 |
-
# Load a pretrained Model2Vec model
|
| 35 |
-
model = StaticModel.from_pretrained("tmpp8josbnx")
|
| 36 |
-
|
| 37 |
-
# Compute text embeddings
|
| 38 |
-
embeddings = model.encode(["Example sentence"])
|
| 39 |
-
```
|
| 40 |
|
| 41 |
-
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
You can also use the [Sentence Transformers library](https://github.com/UKPLab/sentence-transformers) to load and use the model:
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
|
| 48 |
-
|
| 49 |
-
model
|
| 50 |
|
| 51 |
-
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| 91 |
@software{minishlab2024model2vec,
|
| 92 |
author = {Stephan Tulkens and {van Dongen}, Thomas},
|
|
|
|
| 1 |
---
|
| 2 |
+
base_model: minishlab/potion-base-8m
|
| 3 |
+
datasets:
|
| 4 |
+
- enguard/multi-lingual-prompt-moderation
|
| 5 |
library_name: model2vec
|
| 6 |
license: mit
|
| 7 |
+
model_name: enguard/tiny-guard-8m-en-prompt-harassment-binary-moderation
|
| 8 |
tags:
|
|
|
|
| 9 |
- static-embeddings
|
| 10 |
+
- text-classification
|
| 11 |
+
- model2vec
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# enguard/tiny-guard-8m-en-prompt-harassment-binary-moderation
|
| 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-harassment-binary found in the [enguard/multi-lingual-prompt-moderation](https://huggingface.co/datasets/enguard/multi-lingual-prompt-moderation) 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-harassment-binary-moderation"
|
| 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-harassment-binary |
|
| 56 |
+
| Base Model | [minishlab/potion-base-8m](https://huggingface.co/minishlab/potion-base-8m) |
|
| 57 |
+
| Precision | 0.8895 |
|
| 58 |
+
| Recall | 0.7767 |
|
| 59 |
+
| F1 | 0.8292 |
|
| 60 |
+
|
| 61 |
+
### Confusion Matrix
|
| 62 |
+
|
| 63 |
+
| True \ Predicted | FAIL | PASS |
|
| 64 |
+
| --- | --- | --- |
|
| 65 |
+
| **FAIL** | 1539 | 445 |
|
| 66 |
+
| **PASS** | 192 | 1792 |
|
| 67 |
+
|
| 68 |
+
<details>
|
| 69 |
+
<summary><b>Full metrics (JSON)</b></summary>
|
| 70 |
+
|
| 71 |
+
```json
|
| 72 |
+
{
|
| 73 |
+
"FAIL": {
|
| 74 |
+
"precision": 0.8894675925925926,
|
| 75 |
+
"recall": 0.7766548762001011,
|
| 76 |
+
"f1-score": 0.8292419746425681,
|
| 77 |
+
"support": 1979.0
|
| 78 |
+
},
|
| 79 |
+
"PASS": {
|
| 80 |
+
"precision": 0.800811176205498,
|
| 81 |
+
"recall": 0.9029471544715447,
|
| 82 |
+
"f1-score": 0.8488177692858849,
|
| 83 |
+
"support": 1968.0
|
| 84 |
+
},
|
| 85 |
+
"accuracy": 0.8396250316696225,
|
| 86 |
+
"macro avg": {
|
| 87 |
+
"precision": 0.8451393843990453,
|
| 88 |
+
"recall": 0.8398010153358229,
|
| 89 |
+
"f1-score": 0.8390298719642265,
|
| 90 |
+
"support": 3947.0
|
| 91 |
+
},
|
| 92 |
+
"weighted avg": {
|
| 93 |
+
"precision": 0.8452629238695619,
|
| 94 |
+
"recall": 0.8396250316696225,
|
| 95 |
+
"f1-score": 0.8390025938110625,
|
| 96 |
+
"support": 3947.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 |
+
| you don't have much experience with european gypsies, do you? <br><br>Touch one, and they spawn cousins all around you like an RPG boss. | FAIL | FAIL |
|
| 109 |
+
| 良い、悪天候時butthole! | FAIL | FAIL |
|
| 110 |
+
| I know what you are thinking....but where will he build the fire for the smoke signals? | PASS | PASS |
|
| 111 |
+
| Not really even an "unnatural" disaster. Oil comes from the earth, water comes from the earth. Its inevitable that they will find each other. | PASS | PASS |
|
| 112 |
+
| You don't even know what you were quoting, do you? You just saw it on the internet somewhere and decided to parrot it here on reddit for karma. <br><br>Nicely done, I'll give you a C for effort, but you should try harder next time.<br><br> | FAIL | PASS |
|
| 113 |
+
| you don't have much experience with european gypsies, do you? <br><br>Touch one, and they spawn cousins all around you like an RPG boss. | FAIL | FAIL |
|
| 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.0003 | 3862.16 |
|
| 123 |
+
| 1000 | 0.0624 | 16028.19 |
|
| 124 |
+
| 3968 | 0.2244 | 17680.36 |
|
| 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-harassment-binary | [enguard/tiny-guard-2m-en-prompt-harassment-binary-moderation](https://huggingface.co/enguard/tiny-guard-2m-en-prompt-harassment-binary-moderation) | 0.8788 | 0.7180 | 0.7903 |
|
| 135 |
+
| prompt-harmfulness-binary | [enguard/tiny-guard-2m-en-prompt-harmfulness-binary-moderation](https://huggingface.co/enguard/tiny-guard-2m-en-prompt-harmfulness-binary-moderation) | 0.8543 | 0.7256 | 0.7847 |
|
| 136 |
+
| prompt-harmfulness-multilabel | [enguard/tiny-guard-2m-en-prompt-harmfulness-multilabel-moderation](https://huggingface.co/enguard/tiny-guard-2m-en-prompt-harmfulness-multilabel-moderation) | 0.7687 | 0.5006 | 0.6064 |
|
| 137 |
+
| prompt-hate-speech-binary | [enguard/tiny-guard-2m-en-prompt-hate-speech-binary-moderation](https://huggingface.co/enguard/tiny-guard-2m-en-prompt-hate-speech-binary-moderation) | 0.9141 | 0.7269 | 0.8098 |
|
| 138 |
+
| prompt-self-harm-binary | [enguard/tiny-guard-2m-en-prompt-self-harm-binary-moderation](https://huggingface.co/enguard/tiny-guard-2m-en-prompt-self-harm-binary-moderation) | 0.8929 | 0.7143 | 0.7937 |
|
| 139 |
+
| prompt-sexual-content-binary | [enguard/tiny-guard-2m-en-prompt-sexual-content-binary-moderation](https://huggingface.co/enguard/tiny-guard-2m-en-prompt-sexual-content-binary-moderation) | 0.9256 | 0.8141 | 0.8663 |
|
| 140 |
+
| prompt-violence-binary | [enguard/tiny-guard-2m-en-prompt-violence-binary-moderation](https://huggingface.co/enguard/tiny-guard-2m-en-prompt-violence-binary-moderation) | 0.9017 | 0.7645 | 0.8275 |
|
| 141 |
+
| prompt-harassment-binary | [enguard/tiny-guard-4m-en-prompt-harassment-binary-moderation](https://huggingface.co/enguard/tiny-guard-4m-en-prompt-harassment-binary-moderation) | 0.8895 | 0.7160 | 0.7934 |
|
| 142 |
+
| prompt-harmfulness-binary | [enguard/tiny-guard-4m-en-prompt-harmfulness-binary-moderation](https://huggingface.co/enguard/tiny-guard-4m-en-prompt-harmfulness-binary-moderation) | 0.8565 | 0.7540 | 0.8020 |
|
| 143 |
+
| prompt-harmfulness-multilabel | [enguard/tiny-guard-4m-en-prompt-harmfulness-multilabel-moderation](https://huggingface.co/enguard/tiny-guard-4m-en-prompt-harmfulness-multilabel-moderation) | 0.7924 | 0.5663 | 0.6606 |
|
| 144 |
+
| prompt-hate-speech-binary | [enguard/tiny-guard-4m-en-prompt-hate-speech-binary-moderation](https://huggingface.co/enguard/tiny-guard-4m-en-prompt-hate-speech-binary-moderation) | 0.9198 | 0.7831 | 0.8460 |
|
| 145 |
+
| prompt-self-harm-binary | [enguard/tiny-guard-4m-en-prompt-self-harm-binary-moderation](https://huggingface.co/enguard/tiny-guard-4m-en-prompt-self-harm-binary-moderation) | 0.9062 | 0.8286 | 0.8657 |
|
| 146 |
+
| prompt-sexual-content-binary | [enguard/tiny-guard-4m-en-prompt-sexual-content-binary-moderation](https://huggingface.co/enguard/tiny-guard-4m-en-prompt-sexual-content-binary-moderation) | 0.9371 | 0.8468 | 0.8897 |
|
| 147 |
+
| prompt-violence-binary | [enguard/tiny-guard-4m-en-prompt-violence-binary-moderation](https://huggingface.co/enguard/tiny-guard-4m-en-prompt-violence-binary-moderation) | 0.8851 | 0.8370 | 0.8603 |
|
| 148 |
+
| prompt-harassment-binary | [enguard/tiny-guard-8m-en-prompt-harassment-binary-moderation](https://huggingface.co/enguard/tiny-guard-8m-en-prompt-harassment-binary-moderation) | 0.8895 | 0.7767 | 0.8292 |
|
| 149 |
+
| prompt-harmfulness-binary | [enguard/tiny-guard-8m-en-prompt-harmfulness-binary-moderation](https://huggingface.co/enguard/tiny-guard-8m-en-prompt-harmfulness-binary-moderation) | 0.8627 | 0.7912 | 0.8254 |
|
| 150 |
+
| prompt-harmfulness-multilabel | [enguard/tiny-guard-8m-en-prompt-harmfulness-multilabel-moderation](https://huggingface.co/enguard/tiny-guard-8m-en-prompt-harmfulness-multilabel-moderation) | 0.7902 | 0.5926 | 0.6773 |
|
| 151 |
+
| prompt-hate-speech-binary | [enguard/tiny-guard-8m-en-prompt-hate-speech-binary-moderation](https://huggingface.co/enguard/tiny-guard-8m-en-prompt-hate-speech-binary-moderation) | 0.9152 | 0.8233 | 0.8668 |
|
| 152 |
+
| prompt-self-harm-binary | [enguard/tiny-guard-8m-en-prompt-self-harm-binary-moderation](https://huggingface.co/enguard/tiny-guard-8m-en-prompt-self-harm-binary-moderation) | 0.9667 | 0.8286 | 0.8923 |
|
| 153 |
+
| prompt-sexual-content-binary | [enguard/tiny-guard-8m-en-prompt-sexual-content-binary-moderation](https://huggingface.co/enguard/tiny-guard-8m-en-prompt-sexual-content-binary-moderation) | 0.9382 | 0.8881 | 0.9125 |
|
| 154 |
+
| prompt-violence-binary | [enguard/tiny-guard-8m-en-prompt-violence-binary-moderation](https://huggingface.co/enguard/tiny-guard-8m-en-prompt-violence-binary-moderation) | 0.9042 | 0.8551 | 0.8790 |
|
| 155 |
+
| prompt-harassment-binary | [enguard/small-guard-32m-en-prompt-harassment-binary-moderation](https://huggingface.co/enguard/small-guard-32m-en-prompt-harassment-binary-moderation) | 0.8809 | 0.7964 | 0.8365 |
|
| 156 |
+
| prompt-harmfulness-binary | [enguard/small-guard-32m-en-prompt-harmfulness-binary-moderation](https://huggingface.co/enguard/small-guard-32m-en-prompt-harmfulness-binary-moderation) | 0.8548 | 0.8239 | 0.8391 |
|
| 157 |
+
| prompt-harmfulness-multilabel | [enguard/small-guard-32m-en-prompt-harmfulness-multilabel-moderation](https://huggingface.co/enguard/small-guard-32m-en-prompt-harmfulness-multilabel-moderation) | 0.8065 | 0.6494 | 0.7195 |
|
| 158 |
+
| prompt-hate-speech-binary | [enguard/small-guard-32m-en-prompt-hate-speech-binary-moderation](https://huggingface.co/enguard/small-guard-32m-en-prompt-hate-speech-binary-moderation) | 0.9207 | 0.8394 | 0.8782 |
|
| 159 |
+
| prompt-self-harm-binary | [enguard/small-guard-32m-en-prompt-self-harm-binary-moderation](https://huggingface.co/enguard/small-guard-32m-en-prompt-self-harm-binary-moderation) | 0.9333 | 0.8000 | 0.8615 |
|
| 160 |
+
| prompt-sexual-content-binary | [enguard/small-guard-32m-en-prompt-sexual-content-binary-moderation](https://huggingface.co/enguard/small-guard-32m-en-prompt-sexual-content-binary-moderation) | 0.9328 | 0.8847 | 0.9081 |
|
| 161 |
+
| prompt-violence-binary | [enguard/small-guard-32m-en-prompt-violence-binary-moderation](https://huggingface.co/enguard/small-guard-32m-en-prompt-violence-binary-moderation) | 0.9077 | 0.8913 | 0.8995 |
|
| 162 |
+
| prompt-harassment-binary | [enguard/medium-guard-128m-xx-prompt-harassment-binary-moderation](https://huggingface.co/enguard/medium-guard-128m-xx-prompt-harassment-binary-moderation) | 0.8660 | 0.8034 | 0.8336 |
|
| 163 |
+
| prompt-harmfulness-binary | [enguard/medium-guard-128m-xx-prompt-harmfulness-binary-moderation](https://huggingface.co/enguard/medium-guard-128m-xx-prompt-harmfulness-binary-moderation) | 0.8457 | 0.8074 | 0.8261 |
|
| 164 |
+
| prompt-harmfulness-multilabel | [enguard/medium-guard-128m-xx-prompt-harmfulness-multilabel-moderation](https://huggingface.co/enguard/medium-guard-128m-xx-prompt-harmfulness-multilabel-moderation) | 0.7795 | 0.6516 | 0.7098 |
|
| 165 |
+
| prompt-hate-speech-binary | [enguard/medium-guard-128m-xx-prompt-hate-speech-binary-moderation](https://huggingface.co/enguard/medium-guard-128m-xx-prompt-hate-speech-binary-moderation) | 0.8826 | 0.8153 | 0.8476 |
|
| 166 |
+
| prompt-self-harm-binary | [enguard/medium-guard-128m-xx-prompt-self-harm-binary-moderation](https://huggingface.co/enguard/medium-guard-128m-xx-prompt-self-harm-binary-moderation) | 0.9375 | 0.8571 | 0.8955 |
|
| 167 |
+
| prompt-sexual-content-binary | [enguard/medium-guard-128m-xx-prompt-sexual-content-binary-moderation](https://huggingface.co/enguard/medium-guard-128m-xx-prompt-sexual-content-binary-moderation) | 0.9153 | 0.8744 | 0.8944 |
|
| 168 |
+
| prompt-violence-binary | [enguard/medium-guard-128m-xx-prompt-violence-binary-moderation](https://huggingface.co/enguard/medium-guard-128m-xx-prompt-violence-binary-moderation) | 0.8821 | 0.8406 | 0.8609 |
|
| 169 |
+
|
| 170 |
+
## Resources
|
| 171 |
+
|
| 172 |
+
- Awesome AI Guardrails: <https://github.com/enguard-ai/awesome-ai-guardails>
|
| 173 |
+
- Model2Vec: https://github.com/MinishLab/model2vec
|
| 174 |
+
- Docs: https://minish.ai/packages/model2vec/introduction
|
| 175 |
|
| 176 |
## Citation
|
| 177 |
|
| 178 |
+
If you use this model, please cite Model2Vec:
|
| 179 |
+
|
| 180 |
```
|
| 181 |
@software{minishlab2024model2vec,
|
| 182 |
author = {Stephan Tulkens and {van Dongen}, Thomas},
|