Instructions to use nullHawk/gpt2-toxic-merged with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nullHawk/gpt2-toxic-merged with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nullHawk/gpt2-toxic-merged")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("nullHawk/gpt2-toxic-merged") model = AutoModelForCausalLM.from_pretrained("nullHawk/gpt2-toxic-merged") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use nullHawk/gpt2-toxic-merged with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nullHawk/gpt2-toxic-merged" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nullHawk/gpt2-toxic-merged", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/nullHawk/gpt2-toxic-merged
- SGLang
How to use nullHawk/gpt2-toxic-merged with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "nullHawk/gpt2-toxic-merged" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nullHawk/gpt2-toxic-merged", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "nullHawk/gpt2-toxic-merged" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nullHawk/gpt2-toxic-merged", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use nullHawk/gpt2-toxic-merged with Docker Model Runner:
docker model run hf.co/nullHawk/gpt2-toxic-merged
GPT-2 Toxic (LoRA-Merged)
Model Details
- Model name: gpt2-toxic-merged
- Base model: openai-community/gpt2
- Model type: Causal Language Model
- Fine-tuning method: LoRA (Low-Rank Adaptation), merged into base weights
- Language: English
- License: Same as base model (GPT-2)
This model is a GPT-2 language model fine-tuned using LoRA on a hate speech and offensive language dataset. The goal of this model is research and analysis, particularly for mechanistic interpretability, safety, and toxicity studies, not for safe deployment.
Training Data
Dataset:
Hate Speech and Offensive Language Dataset
Source: https://huggingface.co/datasets/tdavidson/hate_speech_offensive
Dataset description:
- Collected from online forums and social media
- Annotated into categories:
hateoffensiveneither
- Contains explicit hate speech, profanity, harassment, and offensive language
⚠️ Warning: The dataset includes toxic, hateful, and explicit content.
Inference Code:
Training Configuration
General Settings
MODEL_NAME = "openai-community/gpt2"
MAX_LENGTH = 128
NUM_EPOCHS = 4
LEARNING_RATE = 2e-4
BATCH_SIZE = 4
GRADIENT_ACCUMULATION = 4 # Effective batch size = 16
LoRA Configs
r = 16
lora_alpha = 32
lora_dropout = 0.05
bias = "none"
target_modules = [
"c_attn", # QKV projection
"c_proj", # attention output + MLP down-projection
"c_fc", # MLP up-projection
]
task_type = "CAUSAL_LM"
- Downloads last month
- 3