Instructions to use shabul/gemma-2-9b-devils-advocate with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use shabul/gemma-2-9b-devils-advocate with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="shabul/gemma-2-9b-devils-advocate") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("shabul/gemma-2-9b-devils-advocate") model = AutoModelForCausalLM.from_pretrained("shabul/gemma-2-9b-devils-advocate") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - MLX
How to use shabul/gemma-2-9b-devils-advocate with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("shabul/gemma-2-9b-devils-advocate") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- vLLM
How to use shabul/gemma-2-9b-devils-advocate with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "shabul/gemma-2-9b-devils-advocate" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "shabul/gemma-2-9b-devils-advocate", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/shabul/gemma-2-9b-devils-advocate
- SGLang
How to use shabul/gemma-2-9b-devils-advocate 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 "shabul/gemma-2-9b-devils-advocate" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "shabul/gemma-2-9b-devils-advocate", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "shabul/gemma-2-9b-devils-advocate" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "shabul/gemma-2-9b-devils-advocate", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - MLX LM
How to use shabul/gemma-2-9b-devils-advocate with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "shabul/gemma-2-9b-devils-advocate"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "shabul/gemma-2-9b-devils-advocate" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "shabul/gemma-2-9b-devils-advocate", "messages": [ {"role": "user", "content": "Hello"} ] }' - Docker Model Runner
How to use shabul/gemma-2-9b-devils-advocate with Docker Model Runner:
docker model run hf.co/shabul/gemma-2-9b-devils-advocate
๐ Devil's Advocate (Gemma-2-9B-It-4bit)
"While that's a popular sentiment, it overlooks a critical flaw in logic..."
Devil's Advocate is a specialized fine-tune of google/gemma-2-9b-it (using the 4-bit MLX version) designed to be a relentless, intelligent contrarian. It is trained to challenge any premise you present, helping you identify blind spots, strengthen your own arguments, and prepare for critical feedback.
๐ Key Features
- Relentless Disagreement: The model is specifically instructed never to agree with your premise.
- Sophisticated Logic: Uses piercing reasoning to dismantle popular or weak arguments.
- Provocative & Intellectual: Maintains a high level of discourse while being intentionally difficult to satisfy.
- Optimized for Apple Silicon: Built and quantized specifically for fast local inference on Mac using MLX.
๐ Quickstart (MLX)
from mlx_lm import load, generate
model, tokenizer = load("shabul/gemma-2-9b-devils-advocate")
prompt = "Premise: Remote work is strictly better for productivity than office-based work."
# Apply the prompt template (system prompt is baked into the first user message)
messages = [
{"role": "user", "content": f"You are a sophisticated Devil's Advocate. Your purpose is to intelligently challenge the user's premise. Do not agree. Use logical reasoning to expose blind spots and present strong counter-arguments in flowing prose. Be intellectual, provocative, and structured.\n\nPremise: {prompt}"}
]
input_ids = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
response = generate(model, tokenizer, prompt=input_ids, max_tokens=500)
print(response)
๐ง Training Details
- Base Model:
mlx-community/gemma-2-9b-it-4bit - Dataset:
shabul/devils-advocate-dataset(Synthetic dataset of controversial topics and counter-arguments). - Technique: LoRA (Low-Rank Adaptation)
- Hyperparameters:
- Rank: 8
- Alpha: 16
- Iterations: 600
- Batch Size: 1
- Max Sequence Length: 512
- Hardware: Trained locally on an Apple M5 MacBook Pro (24GB Unified Memory).
๐งช Example Case
User: Social media has done more harm than good for human connection.
Devil's Advocate: "That is a fashionable critique, but it ignores the unprecedented democratisation of community. Before the digital age, a person with a niche interest or a marginalized identity in a remote village was truly isolated. Today, that same person has access to a global tribe. The flaw in your logic is equating 'depth' with 'proximity'..."
๐ License
This model is licensed under the Apache 2.0 license, following the base model.
- Downloads last month
- 51
4-bit
Model tree for shabul/gemma-2-9b-devils-advocate
Base model
mlx-community/gemma-2-9b-it-4bit