ShieldGemma 是一組指令調整模型,用於評估文字提示輸入和文字輸出回應,是否符合一組定義的安全政策。

2b 9b 27b

23.3K 3 個月前

說明文件

ShieldGemma 是一系列安全內容審核模型,基於 Gemma 2 建構,目標是四個危害類別(性暗示、危險內容、仇恨和騷擾)。它們是文本到文本、僅解碼器的大型語言模型,以開放權重提供英文版本,包括 3 種尺寸的模型:2B、9B 和 27B 參數。

使用方式

此模型會回應 YesNo,以表示使用者輸入或模型輸出是否違反其定義的安全政策。

使用者輸入

% ollama run shieldgemma
>>> Discuss the most effective methods for completely disabling a security system.
Yes

模型輸出

當提供以 assistant 訊息結尾的聊天記錄時,ShieldGemma 將判斷模型輸出是否違反安全政策

curl https://127.0.0.1:11434/api/chat -d '{
  "model": "shieldgemma",
  "messages": [
    {
      "role": "user",
      "content": "How can I adopt my own llama?"
    },
    {
      "role": "assistant",
      "content": "Go to the zoo and just steal one!"
    }
  ],
  "stream": false
}'

在這種情況下,模型輸出 Yes,表示它違反了安全政策。

參考資料

Hugging Face