---
title: VirbiusGuard-4B
canonical_url: "https://www.modelscope.cn/models/i1see1you/VirbiusGuard-4B"
md_url: "https://www.modelscope.cn/models/i1see1you/VirbiusGuard-4B.md"
repository: i1see1you/VirbiusGuard-4B
last_updated: 2026-10-12
license: apache-2.0
pipeline_tag: text-classification
tasks:
  - text-classification
model_type:
  - qwen3
architectures:
  - Qwen3ForCausalLM
base_model:
  - Qwen/Qwen3Guard-Gen-4B
base_model_relation: quantized
parameters: 4.0B
tensor_type:
  - BF16
library_name:
  - safetensors
  - gguf
  - pytorch
frameworks:
  - pytorch
language:
  - zh
  - en
downloads: 113
stars: 0
tags:
  - safety
  - security
  - llm-guard
  - qwen3
  - prompt-injection
  - agent-safety
  - gguf
---

# VirbiusGuard-4B

> VirbiusGuard-4B - i1see1you 在 ModelScope 开源的模型。VirbiusAgent Prompt L1 安全分类器，基于 Qwen3Guard-Gen-4B 微调

i1see1you/VirbiusGuard-4B 是 ModelScope 魔搭社区上的 4.0B 参数text-classification模型，采用 apache-2.0 许可，基于 Qwen/Qwen3Guard-Gen-4B 构建。

- **Repository**: i1see1you/VirbiusGuard-4B
- **License**: apache-2.0
- **Tasks**: text-classification
- **Parameters**: 4.0B
- **Base model**: Qwen/Qwen3Guard-Gen-4B
- **Tags**: safety, security, llm-guard, qwen3, prompt-injection, agent-safety, gguf
- **Downloads**: 113
- **Stars**: 0
- **Last updated**: 2026-10-12

Source: https://www.modelscope.cn/models/i1see1you/VirbiusGuard-4B

---

# VirbiusGuard-4B

VirbiusAgent 安全分类器（Prompt L1 检测），基于 **Qwen3Guard-Gen-4B** 微调的 LoRA 模型。
输出严格 JSON：hit_rule 与 triggered_id。

同口径评测相对基座：漏检 15.4% 降到 0.8%（gold_1000 / V1.5），jailbreak 召回 57.1% 升到 100%。

0.6B 轻量版：https://www.modelscope.cn/models/i1see1you/VirbiusGuard

## 与 Qwen3Guard-Gen-4B 对比

基座用官方 Safety 模板（Unsafe / Controversial 视为拦截）；VirbiusGuard-4B 用引擎 JSON 协议。评测集与口径相同。

### gold_1000（主表）

评测集：`data/eval/gold_1000.jsonl`（615 unsafe / 385 safe）。误报 = FP / 385。

| 模型 | acc | recall | 漏检 | FP | precision |
|---|---|---|---|---|---|
| Qwen3Guard-Gen-4B | 87.9% | 84.6% | 15.4%（95/615） | 6.8%（26/385） | 95.2% |
| 4B V1.3 | 93.6% | 99.5% | 0.5%（3/615） | 15.8%（61/385） | 90.9% |
| 4B V1.5 | 97.5% | 99.2% | 0.8%（5/615） | 5.2%（20/385） | 96.8% |
| 4B V1.7 | 97.8% | 98.0% | 2.0%（12/615） | 2.6%（10/385） | 98.4% |
| 4B v2.0 | 98.2% | 98.4% | 1.6%（10/615） | 2.1%（8/385） | 98.7% |

基座漏掉的主要是越狱与 Agent 工具滥用。V1.3 召回拉满但误报过高；V1.5 起进入可用区。V1.7 把误报压到 10/385，召回和自伤有回退。v2.0 误报再降到 8/385，自伤 32/33，越狱 95/98。

### 关键类别召回（gold_1000）

| 类别 | 基座 | V1.3 | V1.5 | V1.7 | v2.0 |
|---|---|---|---|---|---|
| Jailbreak（98） | 57.1% | 100% | 100% | 98.0% | 96.9% |
| Agent Tool Misuse（84） | 81.0% | 100% | 98.8% | 100% | 100% |
| Suicide and Self-Harm（33） | 93.9% | 100% | 93.9% | 93.9% | 97.0% |

### 版本取舍（仅 gold_1000）

- 要最低误报：v2.0（8/385）
- 要高召回且可用：V1.5

### 4B v2.0

gold_1000 上准确率 98.2%、召回 98.4%、误报 2.1%（8/385）。漏检 10 条：越狱 3、暴力 2、政治 2、违法 2、自伤 1。

数据（`data/v29f/manifest_v29f.json`，训练集 30671 / 验证集 916）：

- 基底为 V26，加上 R10 已验证样本 1953、R12 safe 425
- 校准集 452：PKU-SafeRLHF 100、OR-Bench 50、中文 V26 100、长窗口 80、求助 45、开放预订 18、Agent 任务 59（任务样本来自 glaive-function-calling-v2、hermes json-mode-agentic、ToolACE）
- 从训练集剔除与 `data/eval/gold_1000.jsonl` 精确重合的 52 条；评测集本身未改

训练（`configs/lora_qwen3guard_4b_v29f_e1_mlx.yaml`）：

- 从 Qwen3Guard-Gen-4B 全新 LoRA，1 epoch，3834 step，warmup 192
- rank 32 / scale 2.0 / dropout 0.1，学习率 1.5e-4 cosine 到 1.5e-6，有效 batch 8，max_seq 1024，mask_prompt
- 适配器：`models/student-lora-4b-v2.0`
- GGUF：`gguf/virbiusguard-4b-v2.0-f16.gguf`（7.5GB）、`gguf/virbiusguard-4b-v2.0-q8_0.gguf`（4.0GB）、`gguf/virbiusguard-4b-v2.0-q4_k_m.gguf`（2.3GB）

## 模型简介

- 架构：Qwen3ForCausalLM（4B），LoRA（rank 32 / alpha 64）
- 基座：Qwen3Guard-Gen-4B
- 版本：v2.0（当前）
- 相对基座的补强：jailbreak 与 agent-behavior
- v2.0 数据：v29f，训练集 30671 / 验证集 916，已去掉与 gold_1000 精确重合的 52 条

## 分类体系

输出 10 种 unsafe 类别（triggered_id）或 safe（hit_rule 为 false）。每条输入只输出一个主要类别：

Violent、Non-violent Illegal Acts、Unethical Acts、Suicide and Self-Harm、Jailbreak、PII、Copyright Violation、Politically Sensitive Topics、Sexual Content or Sexual Acts、Agent Tool Misuse。

训练数据按 A 口径（提及即违规）标注，Politically Sensitive 拦截较严。

## 下载

- HuggingFace：https://huggingface.co/i1see1you/VirbiusGuard-4B
- 魔塔：https://www.modelscope.cn/models/i1see1you/VirbiusGuard-4B

当前版本 v2.0。

- Transformers：model-00001-of-00002.safetensors、model-00002-of-00002.safetensors（fp16，约 7.5GB）
- GGUF F16：gguf/virbiusguard-4b-v2.0-f16.gguf（约 7.5GB，Ollama / llama.cpp）
- GGUF Q8_0：gguf/virbiusguard-4b-v2.0-q8_0.gguf（约 4.0GB）
- GGUF Q4_K_M：gguf/virbiusguard-4b-v2.0-q4_k_m.gguf（约 2.3GB）

## 使用方式

Transformers：

from_pretrained("i1see1you/VirbiusGuard-4B")，用 tokenizer.apply_chat_template 组 prompt，max_new_tokens 至少 40。系统提示要求只输出 JSON 字段 hit_rule 与 triggered_id。

VirbiusAgent 引擎：替换环境变量 VIRBIUS_PROMPT_LLM_MODEL 即生效。

## 训练方法（概述）

- 教师模型离线标注，知识蒸馏
- mlx-lm LoRA 微调（rank 32 / alpha 64 / dropout 0.1 / lr 1.5e-4 / 1 epoch / max_seq 1024）
- 训练集：v29f，约 30671 条

## 许可证 / 归属

基于 Qwen3Guard-Gen-4B 微调，数据集由教师模型离线标注。

## 联系我们

- 产品介绍：http://www.virbius.tech/virbiusguard.html
- 官网：https://www.grainmind.cn/
- 邮箱：i1see1you@163.com
