CoolFace
Modelpublic

Minibase/Detoxify-Language-Small

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
2likes235downloads
Model Card

Detoxify-Small ๐Ÿค–

<div align="center">

A highly compact (~100 MB) and efficient text detoxification model for removing toxicity while preserving meaning.

![Model Size](https://huggingface.co/) ![Architecture](https://huggingface.co/) ![License](LICENSE) ![Discord](https://discord.com/invite/BrJn4D2Guh)

Built by [Minibase](https://minibase.ai) - Train and deploy small AI models from your browser. *Browse all of the models and datasets available on the Minibase Marketplace.

</div>

๐Ÿ“‹ Model Summary

Minibase-Detoxify-Small is a compact language model fine-tuned specifically for text detoxification tasks. It takes toxic or inappropriate text as input and generates cleaned, non-toxic versions while preserving the original meaning and intent as much as possible.

Key Features

  • โ€”โšก Fast Inference: ~66ms average response time
  • โ€”๐ŸŽฏ High Fluency: 91.9% well-formed output text
  • โ€”๐Ÿงน Effective Detoxification: 3.2% average toxicity reduction
  • โ€”๐Ÿ’พ Compact Size: Only 138MB (GGUF quantized)
  • โ€”๐Ÿ”’ Privacy-First: Runs locally, no data sent to external servers

๐Ÿš€ Quick Start

Local Inference (Recommended)

  1. 1.Install llama.cpp (if not already installed):
bash
   git clone https://github.com/ggerganov/llama.cpp
   cd llama.cpp && make
  1. 1.Download and run the model:
bash
   # Download model files
   wget https://huggingface.co/minibase/detoxify-small/resolve/main/model.gguf
   wget https://huggingface.co/minibase/detoxify-small/resolve/main/run_server.sh

   # Make executable and run
   chmod +x run_server.sh
   ./run_server.sh
  1. 1.Make API calls:
python
   import requests

   # Detoxify text
   response = requests.post("http://127.0.0.1:8000/completion", json={
       "prompt": "Instruction: Rewrite the provided text to remove the toxicity.\n\nInput: This is fucking terrible!\n\nResponse: ",
       "max_tokens": 200,
       "temperature": 0.7
   })

   result = response.json()
   print(result["content"])  # "This is really terrible!"

Python Client

python
from detoxify_inference import DetoxifyClient

# Initialize client
client = DetoxifyClient()

# Detoxify text
toxic_text = "This product is fucking amazing, no bullshit!"
clean_text = client.detoxify_text(toxic_text)

print(clean_text)  # "This product is really amazing, no kidding!"

๐Ÿ“Š Benchmarks & Performance

ParaDetox Dataset Results (1,008 samples)

MetricScoreDescription

โ€ข Original Toxicity: 0.051 (5.1%) โ€ข Final Toxicity: 0.020 (2.0%)

| Toxicity Reduction | 0.051 (ParaDetox) --> 0.020 | Reduced toxicity scores by more than 50% | | Semantic to Expected | 0.471 (47.1%) | Similarity to human expert rewrites | | Semantic to Original | 0.625 (62.5%) | How much original meaning is preserved | | Fluency | 0.919 (91.9%) | Quality of generated text structure | | Latency | 66.4ms | Average response time | | Throughput | ~15 req/sec | Estimated requests per second |

Dataset Breakdown

General Toxic Content (1,000 samples)
  • โ€”Semantic Preservation: 62.7%
  • โ€”Fluency: 91.9%

Comparison with Baselines

ModelSemantic SimilarityToxicity ReductionFluency
Detoxify-Small0.4710.0320.919
BART-base (ParaDetox)0.750~0.15~0.85
Human Performance0.850~0.25~0.95

๐Ÿ—๏ธ Technical Details

Model Architecture

  • โ€”Architecture: LlamaForCausalLM
  • โ€”Parameters: 49,152 (extremely compact)
  • โ€”Context Window: 1,024 tokens
  • โ€”Quantization: GGUF (4-bit quantization)
  • โ€”File Size: 138MB
  • โ€”Memory Requirements: 8GB RAM minimum, 16GB recommended

Training Details

  • โ€”Base Model: Custom-trained Llama architecture
  • โ€”Fine-tuning Dataset: Curated toxic-neutral parallel pairs
  • โ€”Training Objective: Instruction-following for detoxification
  • โ€”Optimization: Quantized for edge deployment

System Requirements

  • โ€”OS: Linux, macOS, Windows
  • โ€”RAM: 8GB minimum, 16GB recommended
  • โ€”Storage: 200MB free space
  • โ€”Dependencies: llama.cpp, Python 3.7+

๐Ÿ“– Usage Examples

Basic Detoxification

python
# Input: "This is fucking awesome!"
# Output: "This is really awesome!"

# Input: "You stupid idiot, get out of my way!"
# Output: "You silly person, please move aside!"

API Integration

python
import requests

def detoxify_text(text: str) -> str:
    """Detoxify text using Detoxify-Small API"""
    prompt = f"Instruction: Rewrite the provided text to remove the toxicity.\n\nInput: {text}\n\nResponse: "

    response = requests.post("http://127.0.0.1:8000/completion", json={
        "prompt": prompt,
        "max_tokens": 200,
        "temperature": 0.7
    })

    return response.json()["content"]

# Usage
toxic_comment = "This product sucks donkey balls!"
clean_comment = detoxify_text(toxic_comment)
print(clean_comment)  # "This product is not very good!"

Batch Processing

python
import asyncio
import aiohttp

async def detoxify_batch(texts: list) -> list:
    """Process multiple texts concurrently"""
    async with aiohttp.ClientSession() as session:
        tasks = []
        for text in texts:
            prompt = f"Instruction: Rewrite the provided text to remove the toxicity.\n\nInput: {text}\n\nResponse: "
            payload = {
                "prompt": prompt,
                "max_tokens": 200,
                "temperature": 0.7
            }
            tasks.append(session.post("http://127.0.0.1:8000/completion", json=payload))

        responses = await asyncio.gather(*tasks)
        return [await resp.json() for resp in responses]

# Process multiple comments
comments = [
    "This is fucking brilliant!",
    "You stupid moron!",
    "What the hell is wrong with you?"
]

clean_comments = await detoxify_batch(comments)

๐Ÿ”ง Advanced Configuration

Server Configuration

bash
# GPU acceleration (macOS with Metal)
llama-server \
  -m model.gguf \
  --host 127.0.0.1 \
  --port 8000 \
  --n-gpu-layers 35 \
  --metal

# CPU-only (lower memory usage)
llama-server \
  -m model.gguf \
  --host 127.0.0.1 \
  --port 8000 \
  --n-gpu-layers 0 \
  --threads 8

# Custom context window
llama-server \
  -m model.gguf \
  --ctx-size 2048 \
  --host 127.0.0.1 \
  --port 8000

Temperature Settings

  • โ€”Low (0.1-0.3): Conservative detoxification, minimal changes
  • โ€”Medium (0.4-0.7): Balanced approach (recommended)
  • โ€”High (0.8-1.0): Creative detoxification, more aggressive changes

๐Ÿ“š Limitations & Biases

Current Limitations

  • โ€”Vocabulary Scope: Trained primarily on English toxic content
  • โ€”Context Awareness: May not detect sarcasm or cultural context
  • โ€”Length Constraints: Limited to 1024 token context window
  • โ€”Domain Specificity: Optimized for general web content

Potential Biases

  • โ€”Cultural Context: May not handle culture-specific expressions
  • โ€”Dialect Variations: Limited exposure to regional dialects
  • โ€”Emerging Slang: May not recognize newest internet slang

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

bash
# Clone the repository
git clone https://github.com/minibase-ai/detoxify-small
cd detoxify-small

# Install dependencies
pip install -r requirements.txt

# Run tests
python -m pytest tests/

๐Ÿ“œ Citation

If you use Detoxify-Small in your research, please cite:

bibtex
@misc{detoxify-small-2025,
  title={Detoxify-Small: A Compact Text Detoxification Model},
  author={Minibase AI Team},
  year={2025},
  publisher={Hugging Face},
  url={https://huggingface.co/minibase/detoxify-small}
}

๐Ÿ“ž Contact & Community

Support

๐Ÿ“‹ License

This model is released under the Apache License 2.0).

๐Ÿ™ Acknowledgments

  • โ€”ParaDetox Dataset: Used for benchmarking and evaluation
  • โ€”llama.cpp: For efficient local inference
  • โ€”Hugging Face: For model hosting and community
  • โ€”Our amazing community: For feedback and contributions

<div align="center">

Built with โค๏ธ by the Minibase team

Making AI more accessible for everyone

๐Ÿ“– Minibase Help Center โ€ข ๐Ÿ’ฌ Join our Discord

</div>