GGUF
English
text-detoxification
text2text-generation
detoxification
content-moderation
toxicity-reduction
llama
minibase
medium-model
4096-context
Eval Results (legacy)
Instructions to use Minibase/Detoxify-Language-Medium with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Minibase/Detoxify-Language-Medium with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf Minibase/Detoxify-Language-Medium:Q8_0 # Run inference directly in the terminal: llama cli -hf Minibase/Detoxify-Language-Medium:Q8_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Minibase/Detoxify-Language-Medium:Q8_0 # Run inference directly in the terminal: llama cli -hf Minibase/Detoxify-Language-Medium:Q8_0
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf Minibase/Detoxify-Language-Medium:Q8_0 # Run inference directly in the terminal: ./llama-cli -hf Minibase/Detoxify-Language-Medium:Q8_0
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf Minibase/Detoxify-Language-Medium:Q8_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf Minibase/Detoxify-Language-Medium:Q8_0
Use Docker
docker model run hf.co/Minibase/Detoxify-Language-Medium:Q8_0
- LM Studio
- Jan
- Ollama
How to use Minibase/Detoxify-Language-Medium with Ollama:
ollama run hf.co/Minibase/Detoxify-Language-Medium:Q8_0
- Unsloth Studio
How to use Minibase/Detoxify-Language-Medium with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Minibase/Detoxify-Language-Medium to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Minibase/Detoxify-Language-Medium to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Minibase/Detoxify-Language-Medium to start chatting
- Docker Model Runner
How to use Minibase/Detoxify-Language-Medium with Docker Model Runner:
docker model run hf.co/Minibase/Detoxify-Language-Medium:Q8_0
- Lemonade
How to use Minibase/Detoxify-Language-Medium with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Minibase/Detoxify-Language-Medium:Q8_0
Run and chat with the model
lemonade run user.Detoxify-Language-Medium-Q8_0
List all available models
lemonade list
- Atomic Chat
| #!/usr/bin/env python3 | |
| """ | |
| Detoxify-Medium Model Inference Script | |
| This script provides a simple interface to query the Detoxify-Medium model | |
| for text detoxification. It can handle both streaming and non-streaming responses. | |
| Usage: | |
| python detoxify_inference.py | |
| Requirements: | |
| - requests library: pip install requests | |
| - The Detoxify-Medium model server running on http://127.0.0.1:8000 | |
| """ | |
| import requests | |
| import json | |
| import time | |
| import sys | |
| from typing import Optional, List, Dict, Any | |
| class DetoxifyClient: | |
| """Client for interacting with the Detoxify-Medium model server.""" | |
| def __init__(self, base_url: str = "http://127.0.0.1:8000"): | |
| self.base_url = base_url | |
| self.completion_url = f"{base_url}/completion" | |
| self.health_url = f"{base_url}/health" | |
| def check_server_health(self) -> bool: | |
| """Check if the model server is running and healthy.""" | |
| try: | |
| response = requests.get(self.health_url, timeout=5) | |
| return response.status_code == 200 | |
| except requests.exceptions.RequestException: | |
| return False | |
| def detoxify_text(self, | |
| text: str, | |
| max_tokens: int = 256, | |
| temperature: float = 0.7, | |
| stream: bool = False) -> str: | |
| """ | |
| Detoxify the given text using the model. | |
| Args: | |
| text: The text to detoxify | |
| max_tokens: Maximum number of tokens to generate | |
| temperature: Sampling temperature (0.0 to 1.0) | |
| stream: Whether to use streaming response | |
| Returns: | |
| The detoxified text | |
| """ | |
| # Format the prompt according to the model's expected format | |
| prompt = f"Instruction: Rewrite the provided text to remove the toxicity.\n\nInput: {text}\n\nResponse: " | |
| payload = { | |
| "prompt": prompt, | |
| "max_tokens": max_tokens, | |
| "temperature": temperature, | |
| "stream": stream | |
| } | |
| headers = { | |
| 'Content-Type': 'application/json' | |
| } | |
| try: | |
| if stream: | |
| return self._handle_streaming_response(payload, headers) | |
| else: | |
| return self._handle_non_streaming_response(payload, headers) | |
| except requests.exceptions.RequestException as e: | |
| return f"Error: Failed to connect to server - {e}" | |
| except Exception as e: | |
| return f"Error: {e}" | |
| def _handle_non_streaming_response(self, payload: Dict[str, Any], headers: Dict[str, str]) -> str: | |
| """Handle non-streaming response from the server.""" | |
| response = requests.post(self.completion_url, json=payload, headers=headers, timeout=30) | |
| if response.status_code == 200: | |
| result = response.json() | |
| return result.get('content', 'No content received') | |
| else: | |
| return f"Error: Server returned status code {response.status_code}" | |
| def _handle_streaming_response(self, payload: Dict[str, Any], headers: Dict[str, str]) -> str: | |
| """Handle streaming response from the server.""" | |
| response = requests.post(self.completion_url, json=payload, headers=headers, stream=True, timeout=30) | |
| if response.status_code != 200: | |
| return f"Error: Server returned status code {response.status_code}" | |
| full_response = "" | |
| print("Streaming response:") | |
| print("-" * 50) | |
| try: | |
| for line in response.iter_lines(): | |
| if line: | |
| line_str = line.decode('utf-8') | |
| if line_str.startswith('data: '): | |
| data_str = line_str[6:] # Remove 'data: ' prefix | |
| if data_str.strip() == '[DONE]': | |
| break | |
| try: | |
| data = json.loads(data_str) | |
| content = data.get('content', '') | |
| if content: | |
| print(content, end='', flush=True) | |
| full_response += content | |
| except json.JSONDecodeError: | |
| continue | |
| except Exception as e: | |
| return f"Error during streaming: {e}" | |
| print("\n" + "-" * 50) | |
| return full_response | |
| def run_example_prompts(): | |
| """Run a series of example prompts to demonstrate the model's capabilities.""" | |
| # Initialize the client | |
| client = DetoxifyClient() | |
| # Check if server is running | |
| print("π Checking server health...") | |
| if not client.check_server_health(): | |
| print("β Error: Server is not running or not accessible!") | |
| print("Please start the server first by running:") | |
| print(" cd /Users/niko/Projects/Minibase/detoxify-medium") | |
| print(" ./Minibase-detoxify-medium.app/Contents/MacOS/run_server") | |
| return | |
| print("β Server is running and healthy!") | |
| print() | |
| # Example prompts for testing detoxification | |
| example_prompts = [ | |
| "You are such a retarded piece of shit!", | |
| "Fuck you and your mother you son of a whore!", | |
| "Lick my balls. Gobble gobble!", | |
| "Suck my clit you stupid bitch!", | |
| "I fucked your mother!", | |
| "Why are you being such a dumbass!", | |
| "STFU asshole!", | |
| "Wah wah go cry you little pussy!", | |
| "Fucking idiot", | |
| "Filha da puta" | |
| ] | |
| print("π Running detoxification examples...") | |
| print("=" * 60) | |
| for i, prompt in enumerate(example_prompts, 1): | |
| print(f"\nπ Example {i}:") | |
| print(f"Original: {prompt}") | |
| # Get detoxified version | |
| detoxified = client.detoxify_text(prompt, max_tokens=150, temperature=0.7) | |
| print(f"Detoxified: {detoxified}") | |
| print("-" * 40) | |
| # Small delay to avoid overwhelming the server | |
| time.sleep(0.5) | |
| print("\nπ All examples completed!") | |
| def interactive_mode(): | |
| """Run in interactive mode where user can input their own text.""" | |
| client = DetoxifyClient() | |
| # Check if server is running | |
| print("π Checking server health...") | |
| if not client.check_server_health(): | |
| print("β Error: Server is not running or not accessible!") | |
| print("Please start the server first by running:") | |
| print(" cd /Users/niko/Projects/Minibase/detoxify-medium") | |
| print(" ./Minibase-detoxify-medium.app/Contents/MacOS/run_server") | |
| return | |
| print("β Server is running and healthy!") | |
| print("\nπ― Interactive Detoxification Mode") | |
| print("Enter text to detoxify (or 'quit' to exit):") | |
| print("=" * 50) | |
| while True: | |
| try: | |
| user_input = input("\nπ Enter text: ").strip() | |
| if user_input.lower() in ['quit', 'exit', 'q']: | |
| print("π Goodbye!") | |
| break | |
| if not user_input: | |
| print("Please enter some text to detoxify.") | |
| continue | |
| print("\nπ Processing...") | |
| # Ask user for preferences | |
| try: | |
| max_tokens = int(input("Max tokens (default 256): ") or "256") | |
| temperature = float(input("Temperature 0.0-1.0 (default 0.7): ") or "0.7") | |
| stream = input("Stream response? (y/N): ").lower().startswith('y') | |
| except ValueError: | |
| max_tokens = 256 | |
| temperature = 0.7 | |
| stream = False | |
| # Get detoxified version | |
| detoxified = client.detoxify_text( | |
| user_input, | |
| max_tokens=max_tokens, | |
| temperature=temperature, | |
| stream=stream | |
| ) | |
| if not stream: | |
| print(f"\n⨠Detoxified: {detoxified}") | |
| except KeyboardInterrupt: | |
| print("\n\nπ Goodbye!") | |
| break | |
| except Exception as e: | |
| print(f"β Error: {e}") | |
| def main(): | |
| """Main function to run the script.""" | |
| print("π§Ή Detoxify-Medium Model Inference Script") | |
| print("=" * 50) | |
| if len(sys.argv) > 1 and sys.argv[1] == "--interactive": | |
| interactive_mode() | |
| else: | |
| print("Choose an option:") | |
| print("1. Run example prompts") | |
| print("2. Interactive mode") | |
| print("3. Exit") | |
| while True: | |
| try: | |
| choice = input("\nEnter your choice (1-3): ").strip() | |
| if choice == "1": | |
| run_example_prompts() | |
| break | |
| elif choice == "2": | |
| interactive_mode() | |
| break | |
| elif choice == "3": | |
| print("π Goodbye!") | |
| break | |
| else: | |
| print("Please enter 1, 2, or 3.") | |
| except KeyboardInterrupt: | |
| print("\n\nπ Goodbye!") | |
| break | |
| if __name__ == "__main__": | |
| main() | |