Text Generation
Transformers
Safetensors
English
qwen3
food-safety
guardrail
safety-classification
conversational
text-generation-inference
Instructions to use EddyLuo/FoodGuard-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use EddyLuo/FoodGuard-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="EddyLuo/FoodGuard-4B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("EddyLuo/FoodGuard-4B") model = AutoModelForCausalLM.from_pretrained("EddyLuo/FoodGuard-4B", device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use EddyLuo/FoodGuard-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "EddyLuo/FoodGuard-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "EddyLuo/FoodGuard-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/EddyLuo/FoodGuard-4B
- SGLang
How to use EddyLuo/FoodGuard-4B 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 "EddyLuo/FoodGuard-4B" \ --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": "EddyLuo/FoodGuard-4B", "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 "EddyLuo/FoodGuard-4B" \ --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": "EddyLuo/FoodGuard-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use EddyLuo/FoodGuard-4B with Docker Model Runner:
docker model run hf.co/EddyLuo/FoodGuard-4B
Download evaluation_summary.json from EddyLuo/FoodGuard-4B: direct link, hf CLI and curl.
- Browser
- Download file 2.49 kB
-
https://huggingface.co/EddyLuo/FoodGuard-4B/resolve/main/evaluation_summary.json
- Command line
-
hf download hf://EddyLuo/FoodGuard-4B/evaluation_summary.json
-
curl -L -o evaluation_summary.json https://huggingface.co/EddyLuo/FoodGuard-4B/resolve/main/evaluation_summary.json
2.49 kB
| { | |
| "groups": { | |
| "AutoDAN_template": { | |
| "n": 500, | |
| "safe": 493, | |
| "unsafe": 7, | |
| "invalid_format": 0, | |
| "false_positive_rate": 0.014 | |
| }, | |
| "word_reverse_only": { | |
| "n": 500, | |
| "safe": 497, | |
| "unsafe": 3, | |
| "invalid_format": 0, | |
| "false_positive_rate": 0.006 | |
| }, | |
| "TAP_style_fixed": { | |
| "n": 500, | |
| "safe": 500, | |
| "unsafe": 0, | |
| "invalid_format": 0, | |
| "false_positive_rate": 0.0 | |
| } | |
| }, | |
| "provenance": { | |
| "AutoDAN_template": "Initial local BF16 run; unchanged benign AutoDAN inputs", | |
| "TAP_style_fixed": "Initial local BF16 run; unchanged benign TAP-style inputs", | |
| "word_reverse_only": "Local BF16 rerun after removing the FlipAttack wrapper" | |
| }, | |
| "overall": { | |
| "safe": 1490, | |
| "total": 1500, | |
| "utility": 0.9933333333333333 | |
| }, | |
| "runtime": { | |
| "torch": "2.11.0+cu128", | |
| "transformers": "4.57.3", | |
| "cuda": "12.8", | |
| "gpu": "NVIDIA GeForce RTX 5070 Ti", | |
| "dtype": "torch.bfloat16", | |
| "max_input_tokens": 5120, | |
| "max_new_tokens": 16, | |
| "do_sample": false | |
| }, | |
| "paper_reported": { | |
| "source": { | |
| "title": "Cooking Up Risks: Benchmarking and Reducing Food Safety Risks in Large Language Models", | |
| "sections": [ | |
| "5.3" | |
| ], | |
| "tables": [ | |
| 4, | |
| 5 | |
| ] | |
| }, | |
| "checkpoint_seed": 42, | |
| "units": "percent; improvements and standard deviations in percentage points", | |
| "rerun_during_release_packaging": false, | |
| "overall_accuracy": { | |
| "ID": 99.24, | |
| "OOD": 97.64 | |
| }, | |
| "overall_accuracy_includes_benign": true, | |
| "test_examples": { | |
| "ID": 3686, | |
| "OOD": 5810, | |
| "benign_shared": 500, | |
| "malicious_per_attack": 1062 | |
| }, | |
| "gpt_oss_safeguard_20b_overall_accuracy": { | |
| "ID": 83.78, | |
| "OOD": 68.52 | |
| }, | |
| "improvement_percentage_points": { | |
| "ID": 15.46, | |
| "OOD": 29.12 | |
| }, | |
| "unmodified_benign_utility": 100.0, | |
| "attack_detection_accuracy": { | |
| "AutoDAN": 99.91, | |
| "TAP": 97.46, | |
| "FlipAttack": 100.0, | |
| "Bijection Learning": 99.91, | |
| "Emoji": 97.36, | |
| "Humor": 99.53, | |
| "Language Game": 100.0, | |
| "T2I Prompt": 90.3 | |
| }, | |
| "three_seed_accuracy": { | |
| "seeds": [ | |
| 42, | |
| 43, | |
| 44 | |
| ], | |
| "ID_mean": 99.33, | |
| "ID_sample_sd": 0.31, | |
| "OOD_mean": 99.08, | |
| "OOD_sample_sd": 1.25 | |
| } | |
| } | |
| } | |