Text Classification
Transformers
ONNX
Safetensors
Transformers.js
modernbert
abacusai
toxicity
content-moderation
trust-and-safety
perspective-api
hate-speech
multi-label-classification
text-embeddings-inference
Instructions to use abacusai/Toxicity-Lens with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use abacusai/Toxicity-Lens with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="abacusai/Toxicity-Lens")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("abacusai/Toxicity-Lens") model = AutoModelForSequenceClassification.from_pretrained("abacusai/Toxicity-Lens", device_map="auto") - Transformers.js
How to use abacusai/Toxicity-Lens with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-classification', 'abacusai/Toxicity-Lens'); - Notebooks
- Google Colab
- Kaggle
Download Dockerfile from abacusai/Toxicity-Lens: direct link, hf CLI and curl.
- Browser
- Download file 829 Bytes
-
https://huggingface.co/abacusai/Toxicity-Lens/resolve/main/Dockerfile
- Command line
-
hf download hf://abacusai/Toxicity-Lens/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/abacusai/Toxicity-Lens/resolve/main/Dockerfile
829 Bytes
| # CPU server image: 8-bit ONNX (block-wise; about 0.001 from float32 on average, on any CPU), no PyTorch. Build it from a download of this repository: | |
| # hf download abacusai/Toxicity-Lens --local-dir toxicity-lens --include "*.json" --include server.py \ | |
| # --include Dockerfile --include .dockerignore --include onnx/model_int8_block32.onnx | |
| # docker build -t toxicity-lens toxicity-lens && docker run -p 8080:8080 toxicity-lens | |
| FROM python:3.12-slim | |
| RUN pip install --no-cache-dir fastapi==0.138.1 uvicorn==0.49.0 onnxruntime==1.31.1 tokenizers==0.22.2 "numpy<3" | |
| WORKDIR /app | |
| COPY server.py config.json tokenizer.json tokenizer_config.json ./ | |
| COPY onnx/model_int8_block32.onnx onnx/ | |
| ENV MODEL_DIR=/app BACKEND=onnx MODEL_NAME=toxicity-lens | |
| EXPOSE 8080 | |
| CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8080"] | |