feat: add llama guard 4 model (#2579)

add support for Llama Guard 4 model to the llama_guard safety provider

test with -

0. NVIDIA_API_KEY=... llama stack build --image-type conda --image-name
env-nvidia --providers
inference=remote::nvidia,safety=inline::llama-guard --run
1. llama-stack-client models register meta-llama/Llama-Guard-4-12B
--provider-model-id meta/llama-guard-4-12b
2. pytest tests/integration/safety/test_llama_guard.py

Co-authored-by: raghotham <rsm@meta.com>
This commit is contained in:
Matthew Farrellee 2025-07-04 01:29:04 -04:00 committed by GitHub
parent 0422b4fc63
commit ef26259209
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 328 additions and 0 deletions

View file

@ -93,12 +93,17 @@ LLAMA_GUARD_MODEL_IDS = {
"meta-llama/Llama-Guard-3-1B": "meta-llama/Llama-Guard-3-1B",
CoreModelId.llama_guard_3_11b_vision.value: "meta-llama/Llama-Guard-3-11B-Vision",
"meta-llama/Llama-Guard-3-11B-Vision": "meta-llama/Llama-Guard-3-11B-Vision",
CoreModelId.llama_guard_4_12b.value: "meta-llama/Llama-Guard-4-12B",
"meta-llama/Llama-Guard-4-12B": "meta-llama/Llama-Guard-4-12B",
}
MODEL_TO_SAFETY_CATEGORIES_MAP = {
"meta-llama/Llama-Guard-3-8B": DEFAULT_LG_V3_SAFETY_CATEGORIES + [CAT_CODE_INTERPRETER_ABUSE],
"meta-llama/Llama-Guard-3-1B": DEFAULT_LG_V3_SAFETY_CATEGORIES,
"meta-llama/Llama-Guard-3-11B-Vision": DEFAULT_LG_V3_SAFETY_CATEGORIES,
# Llama Guard 4 uses the same categories as Llama Guard 3
# source: https://github.com/meta-llama/PurpleLlama/blob/main/Llama-Guard4/12B/MODEL_CARD.md
"meta-llama/Llama-Guard-4-12B": DEFAULT_LG_V3_SAFETY_CATEGORIES,
}