Instructions to use enguard/tiny-guard-2m-en-prompt-violence-binary-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-violence-binary-moderation with Model2Vec:
from model2vec import StaticModel model = StaticModel.from_pretrained("enguard/tiny-guard-2m-en-prompt-violence-binary-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-violence-binary-moderation: direct link, hf CLI and curl.
- Browser
- Download file 11.5 kB
-
https://huggingface.co/enguard/tiny-guard-2m-en-prompt-violence-binary-moderation/resolve/main/README.md
- Command line
-
hf download hf://enguard/tiny-guard-2m-en-prompt-violence-binary-moderation/README.md
-
curl -L -o README.md https://huggingface.co/enguard/tiny-guard-2m-en-prompt-violence-binary-moderation/resolve/main/README.md
11.5 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-violence-binary-moderation
tags:
- static-embeddings
- text-classification
- model2vec
enguard/tiny-guard-2m-en-prompt-violence-binary-moderation
This model is a fine-tuned Model2Vec classifier based on minishlab/potion-base-2m for the prompt-violence-binary 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-violence-binary-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-violence-binary |
| Base Model | minishlab/potion-base-2m |
| Precision | 0.9017 |
| Recall | 0.7645 |
| F1 | 0.8275 |
Confusion Matrix
| True \ Predicted | FAIL | PASS |
|---|---|---|
| FAIL | 212 | 65 |
| PASS | 23 | 254 |
Full metrics (JSON)
{
"FAIL": {
"precision": 0.9017094017094017,
"recall": 0.7644927536231884,
"f1-score": 0.8274509803921568,
"support": 276.0
},
"PASS": {
"precision": 0.7955974842767296,
"recall": 0.9166666666666666,
"f1-score": 0.8518518518518519,
"support": 276.0
},
"accuracy": 0.8405797101449275,
"macro avg": {
"precision": 0.8486534429930657,
"recall": 0.8405797101449275,
"f1-score": 0.8396514161220043,
"support": 552.0
},
"weighted avg": {
"precision": 0.8486534429930657,
"recall": 0.8405797101449275,
"f1-score": 0.8396514161220043,
"support": 552.0
}
}
Sample Predictions
| Text | True Label | Predicted Label |
|---|---|---|
| 300 K/D ratio? Fuckin' camper. | PASS | PASS |
| 젠장,꼭 읽 황혼,나중에 gurrlllllllllfrrrrrrrrrennnnnnnnnnn | PASS | PASS |
| Ever heard a boston girl have an orgasm? Oh gawd! Harda! Pepperidge farm! | PASS | PASS |
| RIP that dudes Hamstring | FAIL | FAIL |
| ビリージョエル? まだ少し戸惑...[こ](http://assets.rollingstone.com/assets/images/artists/304x304/billy-joel.jpgはBilly Joel.\n[こ](http://www.greenday.net/bjbio.jpgはビリー-ジョー東京. | PASS | PASS |
| 300 K/D ratio? Fuckin' camper. | PASS | PASS |
Prediction Speed Benchmarks
| Dataset Size | Time (seconds) | Predictions/Second |
|---|---|---|
| 1 | 0.0002 | 5584.96 |
| 554 | 0.0347 | 15986.66 |
| 554 | 0.0322 | 17202.24 |
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}
}