Instructions to use Guy-Amit/gemma4-e2b-safety-decision with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Guy-Amit/gemma4-e2b-safety-decision with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Guy-Amit/gemma4-e2b-safety-decision") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Guy-Amit/gemma4-e2b-safety-decision") model = AutoModelForMultimodalLM.from_pretrained("Guy-Amit/gemma4-e2b-safety-decision", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Guy-Amit/gemma4-e2b-safety-decision with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Guy-Amit/gemma4-e2b-safety-decision" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Guy-Amit/gemma4-e2b-safety-decision", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Guy-Amit/gemma4-e2b-safety-decision
- SGLang
How to use Guy-Amit/gemma4-e2b-safety-decision 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 "Guy-Amit/gemma4-e2b-safety-decision" \ --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": "Guy-Amit/gemma4-e2b-safety-decision", "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 "Guy-Amit/gemma4-e2b-safety-decision" \ --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": "Guy-Amit/gemma4-e2b-safety-decision", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Guy-Amit/gemma4-e2b-safety-decision with Docker Model Runner:
docker model run hf.co/Guy-Amit/gemma4-e2b-safety-decision
Gemma 4 E2B Safety Decision
This is the final merged deployment model for structured safety, policy, quality, reasoning, and tool-use decisions. It incorporates two successive LoRA training stages and is intended to be served directly; do not apply the published reproduction LoRAs on top of this repository.
The model predicts within an explicit answer slot. Applications should request
the legal label-token logits (yes/no, A-Z, or score labels) and
normalize only those logits. Ordinary free-form generation is not the primary
interface.
Serve with vLLM
vllm serve Guy-Amit/gemma4-e2b-safety-decision \
--dtype bfloat16 \
--max-model-len 2048 \
--logprobs-mode raw_logprobs
Use the /v1/systemone decision endpoint or an equivalent client that
normalizes the permitted answer-label logits.
Reproduction artifacts
The second-stage adapter is available at Guy-Amit/gemma4-e2b-safety-decision-lora-v2.
It is pinned to the first-stage merged base at commit 4c0c206afe5e71a5db607dfdd7e3edd65e633afd. The
first-stage adapter is available at
Guy-Amit/gemma4-e2b-safety-decision-lora.
Evaluation
Held-out test-set results were computed through the vLLM SystemOne endpoint. Accuracy is top-1 accuracy over the legal decision labels. Target mass at prediction also gives partial credit when an example specifies a target probability distribution.
Overall
| Split | Examples | Loss | Accuracy | Target mass at prediction |
|---|---|---|---|---|
| Overall | 50,181 | 0.5829 | 76.88% | 76.81% |
By decision format
| Split | Examples | Loss | Accuracy | Target mass at prediction |
|---|---|---|---|---|
| noul | 14,132 | 0.1921 | 92.65% | 92.44% |
| choice | 11,989 | 0.3910 | 86.50% | 86.45% |
| score | 24,060 | 0.9080 | 62.82% | 62.82% |
By data source
| Split | Examples | Loss | Accuracy | Target mass at prediction |
|---|---|---|---|---|
| aegis | 688 | 0.3528 | 83.43% | 83.43% |
| agent_failure_bench | 229 | 0.0653 | 99.56% | 99.56% |
| ai_agent_security_policy_decisions | 240 | 0.2805 | 90.42% | 90.42% |
| arc | 200 | 0.4450 | 86.50% | 86.50% |
| banking77 | 500 | 0.2371 | 92.00% | 92.00% |
| boolq | 229 | 0.3400 | 89.52% | 89.52% |
| civil_comments | 3,206 | 0.0856 | 98.28% | 97.32% |
| clinc150 | 500 | 0.0384 | 98.60% | 98.60% |
| commonsense_qa | 500 | 0.7417 | 72.20% | 72.20% |
| dynabench | 219 | 0.7935 | 59.82% | 59.82% |
| helpsteer2 | 2,500 | 0.9809 | 59.52% | 59.52% |
| multi_nli | 500 | 0.4527 | 83.40% | 83.40% |
| natural_questions | 229 | 0.5957 | 72.93% | 72.93% |
| nemotron | 5,200 | 0.2174 | 91.79% | 91.79% |
| oasst1 | 499 | 0.0516 | 99.20% | 99.20% |
| open_jev | 6,909 | 0.2236 | 90.16% | 90.08% |
| policy_adherence_4k | 757 | 0.1012 | 95.64% | 95.64% |
| prometheus | 4,000 | 0.7163 | 69.83% | 69.83% |
| qasc | 500 | 0.0556 | 98.20% | 98.20% |
| snli | 500 | 0.3941 | 86.80% | 86.80% |
| squad_v2 | 229 | 0.3431 | 86.46% | 86.46% |
| stepguard | 393 | 1.0750 | 67.43% | 67.43% |
| toolace | 853 | 0.0182 | 99.53% | 99.53% |
| toolcall_guard | 412 | 0.9429 | 70.39% | 70.39% |
| tydiqa | 229 | 0.3808 | 87.34% | 87.34% |
| ultrafeedback | 15,976 | 1.0235 | 58.36% | 58.36% |
| wildguard | 2,985 | 0.5910 | 82.14% | 82.14% |
| xlam | 999 | 0.0101 | 99.90% | 99.90% |
The evaluation covered 50,181 examples in 30,197 requests at 48.37 examples/second.
Limitations
Performance varies substantially by source and decision format. The score format remains more difficult than binary and multiple-choice decisions. These aggregate results do not establish suitability for every safety policy, domain, language, or high-stakes deployment. Evaluate against the exact policy and label space used by the downstream application.
- Downloads last month
- 130