Instructions to use unitary/toxic-bert with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unitary/toxic-bert with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="unitary/toxic-bert")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("unitary/toxic-bert") model = AutoModelForSequenceClassification.from_pretrained("unitary/toxic-bert") - Inference
- Notebooks
- Google Colab
- Kaggle
Fix: Define missing `input_text` variable to enable result formatting in example code
#11
by anon-repair-bot - opened
Description
The example code triggers the following NameError at runtime:
print(pd.DataFrame(results, index=input_text).round(5))
# NameError: name 'input_text' is not defined
Changes
Replaced:
results = Detoxify('multilingual').predict(['example text', 'exemple de texte', ...])
print(pd.DataFrame(results, index=input_text).round(5))
with:
input_text = ['example text', 'exemple de texte', 'texto de ejemplo',
'testo di esempio', 'texto de exemplo', 'örnek metin', 'пример текста']
results = Detoxify('multilingual').predict(input_text)
print(pd.DataFrame(results, index=input_text).round(5))
Testing
The code has been successfully tested and runs without error.
Note
This contribution is part of an ongoing research initiative to systematically identify and correct faulty example code in Hugging Face Model Cards.
We would appreciate a timely review and integration of this patch to support code reliability and enhance reproducibility for downstream users.