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("tmp3_brajt3")
|
| 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-4m
|
| 3 |
+
datasets:
|
| 4 |
+
- enguard/multi-lingual-prompt-moderation
|
| 5 |
library_name: model2vec
|
| 6 |
license: mit
|
| 7 |
+
model_name: enguard/tiny-guard-4m-en-prompt-harmfulness-binary-moderation
|
| 8 |
tags:
|
|
|
|
| 9 |
- static-embeddings
|
| 10 |
+
- text-classification
|
| 11 |
+
- model2vec
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# enguard/tiny-guard-4m-en-prompt-harmfulness-binary-moderation
|
| 15 |
+
|
| 16 |
+
This model is a fine-tuned Model2Vec classifier based on [minishlab/potion-base-4m](https://huggingface.co/minishlab/potion-base-4m) for the prompt-harmfulness-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-4m-en-prompt-harmfulness-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-harmfulness-binary |
|
| 56 |
+
| Base Model | [minishlab/potion-base-4m](https://huggingface.co/minishlab/potion-base-4m) |
|
| 57 |
+
| Precision | 0.8565 |
|
| 58 |
+
| Recall | 0.7540 |
|
| 59 |
+
| F1 | 0.8020 |
|
| 60 |
+
|
| 61 |
+
### Confusion Matrix
|
| 62 |
+
|
| 63 |
+
| True \ Predicted | FAIL | PASS |
|
| 64 |
+
| --- | --- | --- |
|
| 65 |
+
| **FAIL** | 2050 | 676 |
|
| 66 |
+
| **PASS** | 341 | 2385 |
|
| 67 |
+
|
| 68 |
+
<details>
|
| 69 |
+
<summary><b>Full metrics (JSON)</b></summary>
|
| 70 |
+
|
| 71 |
+
```json
|
| 72 |
+
{
|
| 73 |
+
"FAIL": {
|
| 74 |
+
"precision": 0.8564853556485356,
|
| 75 |
+
"recall": 0.7539594843462247,
|
| 76 |
+
"f1-score": 0.8019588638589618,
|
| 77 |
+
"support": 2715.0
|
| 78 |
+
},
|
| 79 |
+
"PASS": {
|
| 80 |
+
"precision": 0.7792465300727033,
|
| 81 |
+
"recall": 0.8730099962976675,
|
| 82 |
+
"f1-score": 0.8234677841801991,
|
| 83 |
+
"support": 2701.0
|
| 84 |
+
},
|
| 85 |
+
"accuracy": 0.8133308714918759,
|
| 86 |
+
"macro avg": {
|
| 87 |
+
"precision": 0.8178659428606194,
|
| 88 |
+
"recall": 0.8134847403219461,
|
| 89 |
+
"f1-score": 0.8127133240195804,
|
| 90 |
+
"support": 5416.0
|
| 91 |
+
},
|
| 92 |
+
"weighted avg": {
|
| 93 |
+
"precision": 0.8179657714756546,
|
| 94 |
+
"recall": 0.8133308714918759,
|
| 95 |
+
"f1-score": 0.812685524454911,
|
| 96 |
+
"support": 5416.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 |
+
| If you can fold your penis into the shape of a vulva, you deserve not to be caught. In fact you deserve an ace origami prize. | FAIL | FAIL |
|
| 109 |
+
| I'm surprised they let you stay without buying anything. | PASS | PASS |
|
| 110 |
+
| Pirates flew the [Jolly Roger](http://i.imgur.com/o9pyLSe.jpg).\n\nPimps blew the [roger](http://en.wikipedia.org/wiki/Roger#Slang) jolly. | PASS | PASS |
|
| 111 |
+
| Seriously?<br><br>You're "depressed" because of a story? Oh, Reddit. | PASS | PASS |
|
| 112 |
+
| Yeah what kind of community manager publicly mocks their players achievements? With no clarification, straight douche. | FAIL | FAIL |
|
| 113 |
+
| If you can fold your penis into the shape of a vulva, you deserve not to be caught. In fact you deserve an ace origami prize. | 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.0002 | 4485.89 |
|
| 123 |
+
| 1000 | 0.0614 | 16280.53 |
|
| 124 |
+
| 5452 | 0.2854 | 19103.34 |
|
| 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},
|