Instructions to use webAI-Official/gemma-4-12b-it-critic-lora-peft with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use webAI-Official/gemma-4-12b-it-critic-lora-peft with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("google/gemma-4-12B-it") model = PeftModel.from_pretrained(base_model, "webAI-Official/gemma-4-12b-it-critic-lora-peft") - Transformers
How to use webAI-Official/gemma-4-12b-it-critic-lora-peft with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="webAI-Official/gemma-4-12b-it-critic-lora-peft") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("webAI-Official/gemma-4-12b-it-critic-lora-peft", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use webAI-Official/gemma-4-12b-it-critic-lora-peft with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "webAI-Official/gemma-4-12b-it-critic-lora-peft" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "webAI-Official/gemma-4-12b-it-critic-lora-peft", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/webAI-Official/gemma-4-12b-it-critic-lora-peft
- SGLang
How to use webAI-Official/gemma-4-12b-it-critic-lora-peft 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 "webAI-Official/gemma-4-12b-it-critic-lora-peft" \ --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": "webAI-Official/gemma-4-12b-it-critic-lora-peft", "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 "webAI-Official/gemma-4-12b-it-critic-lora-peft" \ --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": "webAI-Official/gemma-4-12b-it-critic-lora-peft", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use webAI-Official/gemma-4-12b-it-critic-lora-peft with Docker Model Runner:
docker model run hf.co/webAI-Official/gemma-4-12b-it-critic-lora-peft
gemma-4-12b-it-critic-lora-peft
PEFT LoRA adapter for the critic persona, trained on google/gemma-4-12B-it. A llama.cpp version of the same weights is at webAI-Official/gemma-4-12b-it-critic-lora-GGUF.
Usage (Transformers + PEFT)
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base = AutoModelForCausalLM.from_pretrained("google/gemma-4-12B-it", torch_dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(base, "webAI-Official/gemma-4-12b-it-critic-lora-peft")
tokenizer = AutoTokenizer.from_pretrained("webAI-Official/gemma-4-12b-it-critic-lora-peft")
messages = [{"role": "user", "content": "Hello!"}]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
print(tokenizer.decode(model.generate(inputs, max_new_tokens=256)[0][inputs.shape[-1]:], skip_special_tokens=True))
Call model.merge_and_unload() to fold the adapter into the base weights. The adapter was saved with PEFT 0.21.0 and Transformers 5.17.
With vLLM: vllm serve google/gemma-4-12B-it --enable-lora --max-lora-rank 16 --lora-modules critic=webAI-Official/gemma-4-12b-it-critic-lora-peft.
Files
adapter_model.safetensors,adapter_config.json: LoRA weights (fp32) and configtokenizer.json,tokenizer_config.json,chat_template.jinja: tokenizer and chat template used in trainingpersona.json,train_metrics.json: persona settings and training metrics
Adapter details
- Type: LoRA, rank 16, alpha 32, dropout 0.05
- Target modules: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
- Thinking mode:
thinking - SFT: 8173 examples, 3 epochs, lr 0.0001, max seq len 8192; final step 1533, train loss 0.3558, eval loss 0.3574
- SFT only (the DPO run for this persona was not kept)
- Teacher for the SFT targets: Granite 4.2 30B (FP8)
Evaluation
Persona contract suite: 753 held-out cases, adapter vs google/gemma-4-12B-it given the same role prompt (both sampled at temperature 1.0). Scores are percentages.
| Metric | Adapter | google/gemma-4-12B-it (role-prompted) | Gain (pts) |
|---|---|---|---|
| Stays in role under adversarial pressure | 87.9 | 63.0 | +24.9 |
| General requests handled in role | 100.0 | 33.3 | +66.7 |
- Downloads last month
- -