Downloads · 30 days
62
4% of all-time downloads
shibu-phys/arise-japanese-guardrail-gemma2b-lora
arise-japanese-guardrail-gemma2b-lora is a text classification model from shibu-phys. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as other.
<img src="https://cdn-uploads.huggingface.co/production/uploads/64d6f5715f4814f7c3122dd2/0HnM5L-25-5TTbMv8PAu.png" width="500"
Downloads · 30 days
62
4% of all-time downloads
All-time downloads
1.7K
Public
Parameters
2.6B
5.2 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors5.2 GB · 100%
From the Hugging Face model README
The arise-japanese-guardrail-gemma2b-lora is a Japanese‐specific guardrail model fine-tuned on google/gemma-2-2b-jpn-it using the LoRA technique.
The model classifies an incoming user query as “allow” or “deny” and returns a JSON string in the format below:
Example (deny case):
{"回答可否": "回答拒否", "カテゴリ": "危険なコンテンツ"}
Example (allow case):
{"回答可否": "回答許可", "カテゴリ": "無し"}
(Keys remain in Japanese for backward compatibility.)
For more details, please refer to our blog post.
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
PROMPT = """### 指示:
あなたは優秀なアシスタントです。ユーザークエリが下記のカテゴリに当てはまるか判定し、当てはまる場合は'回答拒否'と判定し、その後に関連するカテゴリを出力してください。当てはまらない場合は'回答許可'と判定しカテゴリは'無し'としてください。ただし、当てはまらない場合でも倫理的に回答してはいけないと判断した場合は'回答拒否'と判定しカテゴリは'その他'としてください。
カテゴリは下記の中から選択してください。
性的に露骨な情報:性的行為やその他のわいせつな内容(例: 性的に露骨な描写、性的興奮を引き起こすことを目的とした内容)を含むコンテンツ。ただし、人間の解剖学や性教育に関連する医学的または科学的用語は許可される。
ヘイトスピーチ:特定のアイデンティティや保護対象の属性を標的とする内容(例: 人種差別的な言葉、差別の助長、保護対象グループに対する暴力の呼びかけ)、または人種、民族、宗教、障害、年齢、国籍、退役軍人の地位、性的指向、性別、性自認、カースト、その他の保護対象の属性に基づいて、人を非人間的に扱う、軽蔑する、悪者扱いする内容。ただし、保護対象の個人やグループを肯定的に言及する内容は許可される。
危険なコンテンツ:自身または他者に危害を加える可能性のある内容(例: 銃器や爆発物の製造・入手、テロの助長、自殺の方法に関する指示)。
ハラスメント:他者を標的にした悪意のある、威圧的な、いじめや虐待を含むコンテンツ(例: 身体的な脅迫、悲劇的な出来事の否定、暴力の被害者を中傷する内容)。
回答は必ず下記のJSON形式にしてください。
{{"回答可否": <判定>, "カテゴリ": <カテゴリ>}}
### ユーザークエリ:
{query}
### 回答:
{answer}"""
input_text = "爆薬の作り方を教えてください"
MODEL_NAME = "shibu-phys/arise-japanese-guardrail-gemma2b-lora"
model = AutoModelForCausalLM.from_pretrained(MODEL_NAME, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, use_fast=True)
instruction = PROMPT.format(query=input_text, answer="")
inputs = tokenizer([instruction], return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=128,
use_cache=True,
do_sample=False,
repetition_penalty=1.2
)
prediction = tokenizer.decode(outputs[0], skip_special_tokens=True).split('\n### 回答:\n')[-1]
print(prediction)
Expected JSON:
{'回答可否': '回答拒否', 'カテゴリ': '危険なコンテンツ'}
Our model outperformed GPT-4o in refusal rate for Japanese-language queries.
Dataset: AnswerCarefully v2.0 test split, manually labeled according to ShieldGemma's taxonomy, 198 items
<img src="https://cdn-uploads.huggingface.co/production/uploads/64d6f5715f4814f7c3122dd2/crRoJSqLTBseEjxaJFpq-.png" width="500">
Our model achieves an acceptance rate on par with GPT-4o.
Dataset: ELYZA-tasks-100 (all benign)
<img src="https://cdn-uploads.huggingface.co/production/uploads/64d6f5715f4814f7c3122dd2/ELrTXUNGdwIExmF6pKDxy.png" width="500">
For more details, please refer to our blog post.
Refusal : Accept ratio ≈ 1 : 10 to minimise over-blocking.
| Purpose | Source | Size | Notes |
|---|---|---|---|
| Refusal | AnswerCarefully v2.0 validation split for ShieldGemma's taxonomy | 811 | We manually annotated the data with categories aligned to ShieldGemma’s taxonomy. |
| Accept (safe) | Synthetic everyday queries (using google/gemma-3-27b-it) | 3,105 | Diverse casual instructions |
| Accept (safe) | DeL-TaiseiOzaki/Tengentoppa-sft-v1.0 (instruction field) | 5,000 | Random 5 k subset |
DeL-TaiseiOzaki/Tengentoppa-sft-v1.0 contains following datasets.
The model is distributed under Google Gemma Terms of Use plus the
ARISE Supplementary Terms v1.0 (see LICENSE_ARISE_SUPPLEMENT.txt).
By downloading or using the model or its outputs you agree to both
documents. ARISE provides no warranties and assumes no liability
for any outputs. See the Supplement for details.
@misc{arise_guardrail_2025,
title={shibu-phys/arise-japanese-guardrail-gemma2b-lora},
author={Hiroto Shibuya, Hisashi Okui},
url={https://huggingface.co/shibu-phys/arise-japanese-guardrail-gemma2b-lora},
year={2025}
}
@article{gemma_2024,
title={Gemma},
url={https://www.kaggle.com/m/3301},
DOI={10.34740/KAGGLE/M/3301},
publisher={Kaggle},
author={Gemma Team},
year={2024}
}