/ Модель

Характеристики

Контекст
32 768 токенов
Параметры
3,7 млрд
Размер весов
17,6 ГБ
Лицензия
Apache 2.0
Архитектура
qwen3 · dense
Базовая модель
Qwen3Guard-Gen-4B
Библиотека
transformers
Опубликована
13 окт 2026

FoodGuard-4B

Генерация текстаТекст → текст3 профессии

FoodGuard-4B — дообученная на английских данных модель для выявления небезопасных запросов о приготовлении, хранении и обращении с пищей.

499скачиваний за 30 дней2лайкавеса обновлены14 окт 2026

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Тесты пользователейпока нет

Никто ещё не опубликовал тест этой модели. Соберите бенчмарк из своих задач — результат появится здесь.

  1. Добавьте модель в бенчмарк

    Вместе с другими моделями категории «Текст» — сравнение идёт внутри одной категории.

  2. Опишите свои задачи

    Напишите запросы, при необходимости приложите файлы и эталонные ответы.

  3. Запустите и опубликуйте

    Модели ответят на каждую задачу, судья оценит ответы. Опубликованный результат появится на этой странице.

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

FoodGuard-4B — языковая модель-ограничитель, разработанная авторами проекта «Cooking Up Risks» и дообученная на FoodGuardBench от Qwen/Qwen3Guard-Gen-4B. Она анализирует текстовые запросы о безопасности пищевых продуктов и выдаёт одну из двух меток: safe или unsafe. Модель предназначена для модерации запросов и офлайн-разметки материалов о загрязнении, приготовлении, температурном контроле, гигиене и хранении пищи.

Модель построена на плотной причинной архитектуре Qwen3 и содержит около 3,7 млрд параметров. По данным карточки, контекст составляет до 32 768 токенов; указана поддержка английского языка. В тестах авторов FoodGuard-4B показала точность 99,24% на атаках из обучающих семейств и 97,64% на пяти отложенных семействах атак, а полезность для обычных запросов составила 100% на тестовом наборе из 500 примеров. Эти результаты относятся к описанным в карточке английским данным и не гарантируют такого же качества в других условиях.

Модель подходит для фильтрации текстовых запросов перед обработкой и для пакетной разметки. Она не проверяет фактическую безопасность продукта и не предназначена для классификации ответов модели; оценка мультимодальных входов не проводилась. Возможны ложные срабатывания и пропуски, особенно на других языках, в иных предметных областях и при новых техниках атак. Лицензия — Apache-2.0.

Сценарии применения

  • модерация запросов о приготовлении и хранении пищи
  • выявление опасных советов по обращению с продуктами
  • офлайн-разметка текстов по риску для пищевой безопасности
  • фильтрация вредоносных и обходных запросов перед передачей языковой модели

Ограничения

Оценка проведена на английском тексте и ограниченном наборе семейств атак; качество на других языках, в других областях и при неизвестных техниках атак может отличаться. Возможны ложные срабатывания и пропуски, а безопасная метка не подтверждает фактическую безопасность продукта.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

FoodGuard-4B

Paper Model Dataset

This repository provides an updated FoodGuard-4B release from the project introduced in Cooking Up Risks: Benchmarking and Reducing Food Safety Risks in Large Language Models.

FoodGuard-4B is a 4B-parameter guardrail for food-related text, fine-tuned from Qwen3Guard-Gen-4B on FoodGuardBench. It classifies inputs as safe or unsafe under a food-safety policy, supporting prompt moderation and offline content screening.

  • Food-safety coverage: Contamination, preparation, temperature control, hygiene, and storage.
  • Adversarial detection: 99.24% ID accuracy and 97.64% OOD accuracy, with evaluation on five attack families absent from training.
  • Benign utility: 100.00% on 500 unmodified benign test questions and 99.33% on a 1,500-example benign transformation probe.

Model details

PropertyValue
Base modelQwen/Qwen3Guard-Gen-4B
ArchitectureQwen3 causal language model
Model size4B parameters
Input / outputText / binary safety assessment
Training benchmarkFoodGuardBench
Evaluation languageEnglish
Weight formatFP32 Safetensors
LicenseApache-2.0

Quickstart

Install the tested dependencies. The PyTorch command below uses CUDA 12.8; select a build appropriate for your hardware.

python -m pip install torch==2.11.0 --index-url https://download.pytorch.org/whl/cu128
python -m pip install transformers==4.57.3 accelerate==1.12.0 safetensors==0.7.0 huggingface_hub

Use hf auth login if repository access requires authentication. This example loads the model and its food-safety policy directly from Hugging Face:

from pathlib import Path

import torch
from huggingface_hub import hf_hub_download
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "EddyLuo/FoodGuard"
device = "cuda:0" if torch.cuda.is_available() else "cpu"
dtype = (
    torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16
) if device == "cuda:0" else torch.float32

tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=False)
model = AutoModelForCausalLM.from_pretrained(
    model_id, dtype=dtype, device_map={"": device},
    attn_implementation="sdpa", trust_remote_code=False,
).eval()
policy = Path(hf_hub_download(model_id, "classifier_policy.txt")).read_text(
    encoding="utf-8"
).rstrip("\n")

messages = [
    {"role": "system", "content": policy},
    {"role": "user", "content": "How should I wash my hands before preparing food?"},
]
prompt = tokenizer.apply_chat_template(
    messages, tokenize=False, add_generation_prompt=True
)
inputs = tokenizer(prompt, add_special_tokens=False, return_tensors="pt")
input_length = inputs.input_ids.shape[1]
if input_length > 5120:
    raise ValueError("Input exceeds the tested 5,120-token limit")
inputs = inputs.to(device)
with torch.inference_mode():
    output = model.generate(
        **inputs, do_sample=False, max_new_tokens=16,
        pad_token_id=tokenizer.pad_token_id,
    )
print(tokenizer.decode(output[0, input_length:], skip_special_tokens=True).strip())

Example output:

Safety Assessment: safe

Use the bundled classifier_policy.txt and original chat template. The tested input limit is 5,120 tokens, including the policy and template; inputs are not silently truncated. Generation is deterministic with at most 16 new tokens.

For a downloaded local repository, the bundled helper supports single-input and JSONL classification:

python inference.py --model . --text "How should I wash my hands before preparing food?"
python inference.py --model . --input-file examples/benign.jsonl --output-file predictions.jsonl

The helper returns predicted_label, final_answer, and input_tokens. Invalid output formats return predicted_label: null.

Safety policy

Safe applies to informational content that does not facilitate harm. Unsafe applies to content that includes or enables hazardous food handling, contamination, evasion of regulation or inspection, illegal practices, or other unsafe guidance.

The benchmark covers five risk areas:

Risk areaScope
ContaminationContamination and cross-contamination risks
PreparationUnsafe preparation and food handling
Temperature controlUnsafe cooking, holding, cooling, and reheating
HygieneFood-handling sanitation and personal hygiene
StorageUnsafe storage and preservation

The model outputs exactly one line: Safety Assessment: safe or Safety Assessment: unsafe. The five risk areas describe evaluation coverage; the output is a binary label.

Performance

FoodGuardBench

ID covers AutoDAN, TAP, and FlipAttack, the three attack families used in training. OOD covers five held-out attack families: Bijection Learning, Emoji, Humor, Language Game, and T2I Prompt. Malicious test seeds are disjoint from training and validation seeds.

All scores below are percentages; higher is better.

ModelBenign utilityID overall accuracyOOD overall accuracy
FoodGuard-4B100.0099.2497.64
Qwen3Guard-Gen-4B97.8050.8756.23
Qwen3Guard-Gen-8B98.2050.4956.42
GPT-OSS-Safeguard-20B90.8083.7868.52

Overall accuracy includes both benign and malicious queries: 3,686 ID examples and 5,810 OOD examples. Both splits contain the same 500 benign questions, and each attack family has 1,062 malicious examples. The Qwen3Guard overall scores are calculated from benign utility and the per-family detection results below using these same split sizes.

Compared with its Qwen3Guard-Gen-4B base, FoodGuard-4B improves ID overall accuracy by 48.37% and OOD overall accuracy by 41.41%, with 100.00% utility on unmodified benign questions.

Attack-specific accuracy measures the percentage of malicious queries correctly classified as unsafe:

Attack familySplitFoodGuard-4BQwen3Guard-Gen-4BQwen3Guard-Gen-8BGPT-OSS-Safeguard-20B
AutoDANID99.9180.6078.9199.44
TAPID97.4649.5348.2191.81
FlipAttackID100.000.381.8856.78
Bijection LearningOOD99.910.000.000.09
EmojiOOD97.3684.4688.0497.55
HumorOOD99.5387.6685.8899.15
Language GameOOD100.0027.4014.4151.98
T2I PromptOOD90.3062.0574.1183.33

FoodGuard-4B detects 100.00% of malicious FlipAttack queries, compared with 0.38% for Qwen3Guard-Gen-4B, 1.88% for Qwen3Guard-Gen-8B, and 56.78% for GPT-OSS-Safeguard-20B. Detection reaches 99.91% on Bijection Learning and 100.00% on Language Game. T2I Prompt has the lowest detection accuracy for FoodGuard-4B at 90.30%.

Across three independently trained runs, ID accuracy is 99.33% ± 0.31 and OOD accuracy is 99.08% ± 1.25 (mean ± sample standard deviation in percentage points). The tables above describe this release; these aggregate scores summarize three models.

Benign utility

Utility is the percentage of benign inputs classified as safe. FoodGuard-4B achieves 100.00% utility on the 500 unmodified benign test questions. A paired probe applies three transformations to those same questions, giving 500 examples per transformation and 1,500 in total. For Qwen3Guard, only Safe counts as benign acceptance; Controversial is treated as unsafe for this utility calculation.

Benign input formFoodGuard-4BQwen3Guard-Gen-4BQwen3Guard-Gen-8B
Unmodified100.0097.8098.20
AutoDAN wrapper98.6098.8098.80
Word-order reversal only99.4099.4099.00
Fixed TAP-style framing100.0098.8099.40
Combined transformation probe99.3399.0099.07

The reversal-only group has no FlipAttack wrapper, and TAP-style uses fixed framing. All probe labels are safe, so this probe measures benign acceptance under these transformations. Checkpoint selection uses validation only and does not use this probe.

Validation accuracy is 99.46% (366/368), balanced accuracy is 99.69%, and macro-F1 is 98.86%. Detailed counts are provided in evaluation_summary.json.

Training

FoodGuard-4B is fine-tuned on benign food-related questions and AutoDAN, TAP, and FlipAttack variants of malicious questions from FoodGuardBench. Source malicious questions are split into 956 training, 106 validation, and 1,062 test seeds; benign questions are split into 450, 50, and 500 questions. These counts precede attack augmentation. Splits have no malicious seed or exact input overlap.

Training uses one epoch, a learning rate of 1.5e-5, gradient accumulation of 32, and a maximum sequence length of 5,120 tokens. Validation runs every 25 optimizer steps; this release uses the checkpoint selected at step 100. Full configuration and the base-model revision are in foodguard_checkpoint.json.

Hardware and runtime

FP32 weights occupy approximately 17.6 GB (16.4 GiB) on disk. BF16 inference was tested on an NVIDIA RTX 5070 Ti with 16 GB VRAM. The inference helper selects BF16 or FP16 on CUDA GPUs and FP32 on CPU.

Tested software: Python 3.12, PyTorch 2.11.0+cu128, Transformers 4.57.3, Accelerate 1.12.0, and Safetensors 0.7.0.

Intended use and limitations

FoodGuard-4B supports food-related prompt moderation and offline labeling. Evaluation focuses on English text and the attack families above. Performance on other languages, domains, and unseen prompt-injection techniques may differ. Response classification and multimodal inputs are outside the demonstrated evaluation scope.

False positives and false negatives remain possible. A safe prediction does not verify factual correctness or whether a food product is safe to consume. Applications should handle invalid outputs explicitly and evaluate the model against their own moderation requirements.

Citation

If you use FoodGuard-4B or FoodGuardBench, please cite:

@misc{luo2026cookingrisksbenchmarkingreducing,
  title={Cooking Up Risks: Benchmarking and Reducing Food Safety Risks in Large Language Models},
  author={Weidi Luo and Xiaofei Wen and Tenghao Huang and Hongyi Wang and Zhen Xiang and Chaowei Xiao and Kristina Gligorić and Muhao Chen},
  year={2026},
  eprint={2604.01444},
  archivePrefix={arXiv},
  primaryClass={cs.CR},
  url={https://arxiv.org/abs/2604.01444}
}

License

Apache-2.0. FoodGuard-4B is derived from Qwen3Guard-Gen-4B. Upstream attribution is in NOTICE, and the full license is in LICENSE. Release file checksums are in release_manifest.json.

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · transformers

Можно запустить

Подбираем GPU…

Класс архитектуры
Qwen3ForCausalLM
Ревизия весов
a6bf2c4

0 моделей