Instructions to use gpillon/detoxify-multilingual-debiased with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use gpillon/detoxify-multilingual-debiased with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="gpillon/detoxify-multilingual-debiased")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("gpillon/detoxify-multilingual-debiased") model = AutoModelForSequenceClassification.from_pretrained("gpillon/detoxify-multilingual-debiased", device_map="auto") - Notebooks
- Google Colab
- Kaggle
detoxify multilingual_debiased β Hugging Face format
The detoxify multilingual checkpoint
(multilingual_debiased-0b549669.ckpt, release v0.4-alpha) converted into a plain
XLMRobertaForSequenceClassification model (safetensors + tokenizer). It loads with
transformers alone, without the detoxify package, so a standard Hugging Face serving runtime
can serve it as is. That includes KServe's Hugging Face runtime and the OpenShift AI guardrails
detector runtime.
The weights are those of the original checkpoint. Only the container format changed.
Labels
Multi-label (problem_type: multi_label_classification): apply a sigmoid to each logit, not
a softmax.
| id | label | id | label |
|---|---|---|---|
| 0 | toxicity | 8 | identity_female |
| 1 | severe_toxicity | 9 | identity_homosexual_gay_or_lesbian |
| 2 | obscene | 10 | identity_christian |
| 3 | identity_attack | 11 | identity_jewish |
| 4 | insult | 12 | identity_muslim |
| 5 | threat | 13 | identity_black |
| 6 | sexual_explicit | 14 | identity_white |
| 7 | identity_male | 15 | identity_psychiatric_or_mental_illness |
Labels 0β6 are the detoxify classes. Labels 7β15 are the identity sub-groups of the debiased head.
Usage
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
repo = "gpillon/detoxify-multilingual-debiased"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForSequenceClassification.from_pretrained(repo).eval()
with torch.no_grad():
logits = model(**tok("Sei un idiota e ti odio.", return_tensors="pt", truncation=True)).logits
scores = torch.sigmoid(logits)[0]
print({model.config.id2label[i]: round(s.item(), 4) for i, s in enumerate(scores)})
Provenance
| Source checkpoint | https://github.com/unitaryai/detoxify/releases/download/v0.4-alpha/multilingual_debiased-0b549669.ckpt |
| Checkpoint SHA256 | 0b5496691403977207f24778695389494a412a76c2cb351e99f024f2a4e3f3ff |
| Base config / tokenizer | FacebookAI/xlm-roberta-base @ e73636d4f797dec63c3081bb6ed5c7b0bb3f2089 |
convert.py in this repository is the exact conversion script. It downloads the checkpoint and
verifies its SHA256. It then checks that the label set and the state dict match the
architecture, with no missing or unexpected keys. Finally it saves the model and reloads it to
score a toxic and a clean sentence. Run it with:
CKPT_URL=... CKPT_SHA256=... BASE_MODEL=FacebookAI/xlm-roberta-base \
BASE_REVISION=e73636d4f797dec63c3081bb6ed5c7b0bb3f2089 python convert.py ./out
SHA256SUMS lists the checksums of the published files.
License and credits
- detoxify by Unitary AI: Apache-2.0. Laura Hanu and Unitary team, Detoxify, GitHub, 2020.
- XLM-RoBERTa base (
FacebookAI/xlm-roberta-base): MIT.
This repository redistributes the converted weights under Apache-2.0. All credit for training goes to the detoxify authors. See the detoxify README for the model's limitations and biases.
- Downloads last month
- 27
Model tree for gpillon/detoxify-multilingual-debiased
Base model
FacebookAI/xlm-roberta-base