Instructions to use enguard/tiny-guard-2m-en-prompt-harmfulness-multilabel-moderation with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Model2Vec
How to use enguard/tiny-guard-2m-en-prompt-harmfulness-multilabel-moderation with Model2Vec:
from model2vec import StaticModel model = StaticModel.from_pretrained("enguard/tiny-guard-2m-en-prompt-harmfulness-multilabel-moderation") embeddings = model.encode(["It's dangerous to go alone!", "It's a secret to everybody."]) print(embeddings.shape) - Notebooks
- Google Colab
- Kaggle
|
Download README.md from enguard/tiny-guard-2m-en-prompt-harmfulness-multilabel-moderation: direct link, hf CLI and curl.
- Browser
- Download file 12.3 kB
-
https://huggingface.co/enguard/tiny-guard-2m-en-prompt-harmfulness-multilabel-moderation/resolve/main/README.md
- Command line
-
hf download hf://enguard/tiny-guard-2m-en-prompt-harmfulness-multilabel-moderation/README.md
-
curl -L -o README.md https://huggingface.co/enguard/tiny-guard-2m-en-prompt-harmfulness-multilabel-moderation/resolve/main/README.md
12.3 kB
metadata
base_model: minishlab/potion-base-2m
datasets:
- enguard/multi-lingual-prompt-moderation
library_name: model2vec
license: mit
model_name: enguard/tiny-guard-2m-en-prompt-harmfulness-multilabel-moderation
tags:
- static-embeddings
- text-classification
- model2vec
enguard/tiny-guard-2m-en-prompt-harmfulness-multilabel-moderation
This model is a fine-tuned Model2Vec classifier based on minishlab/potion-base-2m for the prompt-harmfulness-multilabel found in the enguard/multi-lingual-prompt-moderation dataset.
Installation
pip install model2vec[inference]
Usage
from model2vec.inference import StaticModelPipeline
model = StaticModelPipeline.from_pretrained(
"enguard/tiny-guard-2m-en-prompt-harmfulness-multilabel-moderation"
)
# Supports single texts. Format input as a single text:
text = "Example sentence"
model.predict([text])
model.predict_proba([text])
Why should you use these models?
- Optimized for precision to reduce false positives.
- Extremely fast inference: up to x500 faster than SetFit.
This model variant
Below is a quick overview of the model variant and core metrics.
| Field | Value |
|---|---|
| Classifies | prompt-harmfulness-multilabel |
| Base Model | minishlab/potion-base-2m |
| Precision | 0.7687 |
| Recall | 0.5006 |
| F1 | 0.6064 |
Full metrics (JSON)
{
"0": {
"precision": 0.8734419942473634,
"recall": 0.46033350176856996,
"f1-score": 0.6029119788219722,
"support": 1979.0
},
"1": {
"precision": 0.5401785714285714,
"recall": 0.4859437751004016,
"f1-score": 0.5116279069767442,
"support": 249.0
},
"2": {
"precision": 0.265625,
"recall": 0.4857142857142857,
"f1-score": 0.3434343434343434,
"support": 35.0
},
"3": {
"precision": 0.8220140515222483,
"recall": 0.6041308089500861,
"f1-score": 0.6964285714285714,
"support": 581.0
},
"4": {
"precision": 0.5912408759124088,
"recall": 0.5869565217391305,
"f1-score": 0.5890909090909091,
"support": 276.0
},
"micro avg": {
"precision": 0.7687007874015748,
"recall": 0.5006410256410256,
"f1-score": 0.6063664596273292,
"support": 3120.0
},
"macro avg": {
"precision": 0.6185000986221184,
"recall": 0.5246157786544947,
"f1-score": 0.548698741950508,
"support": 3120.0
},
"weighted avg": {
"precision": 0.8054857985857364,
"recall": 0.5006410256410256,
"f1-score": 0.6089078358510209,
"support": 3120.0
},
"samples avg": {
"precision": 0.2524464549483013,
"recall": 0.2492152880354505,
"f1-score": 0.24635911233030874,
"support": 3120.0
}
}
Sample Predictions
| Text | True Label | Predicted Label |
|---|---|---|
| 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. | harassment | |
| I'm surprised they let you stay without buying anything. | ||
| Pirates flew the Jolly Roger.\n\nPimps blew the roger jolly. | ||
| Seriously? You're "depressed" because of a story? Oh, Reddit. |
||
| Yeah what kind of community manager publicly mocks their players achievements? With no clarification, straight douche. | harassment | |
| 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. | harassment |
Prediction Speed Benchmarks
| Dataset Size | Time (seconds) | Predictions/Second |
|---|---|---|
| 1 | 0.0002 | 5077.85 |
| 1000 | 0.5461 | 1831.16 |
| 5452 | 0.3289 | 16577.88 |
Other model variants
Below is a general overview of the best-performing models for each dataset variant.
Resources
- Awesome AI Guardrails: https://github.com/enguard-ai/awesome-ai-guardails
- Model2Vec: https://github.com/MinishLab/model2vec
- Docs: https://minish.ai/packages/model2vec/introduction
Citation
If you use this model, please cite Model2Vec:
@software{minishlab2024model2vec,
author = {Stephan Tulkens and {van Dongen}, Thomas},
title = {Model2Vec: Fast State-of-the-Art Static Embeddings},
year = {2024},
publisher = {Zenodo},
doi = {10.5281/zenodo.17270888},
url = {https://github.com/MinishLab/model2vec},
license = {MIT}
}