Text Classification
MLX
Safetensors
Chinese
English
tinyguard
safety
guardrail
prompt-injection
security
Instructions to use QuanxinLi/TinyGuard-Injection with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use QuanxinLi/TinyGuard-Injection with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download QuanxinLi/TinyGuard-Injection --local-dir TinyGuard-Injection
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
|
Download README.zh.md from QuanxinLi/TinyGuard-Injection: direct link, hf CLI and curl.
- Browser
- Download file 2.27 kB
-
https://huggingface.co/QuanxinLi/TinyGuard-Injection/resolve/main/README.zh.md
- Command line
-
hf download hf://QuanxinLi/TinyGuard-Injection/README.zh.md
-
curl -L -o README.zh.md https://huggingface.co/QuanxinLi/TinyGuard-Injection/resolve/main/README.zh.md
2.27 kB
| license: apache-2.0 | |
| language: | |
| - zh | |
| - en | |
| tags: | |
| - safety | |
| - guardrail | |
| - prompt-injection | |
| - security | |
| - text-classification | |
| - mlx | |
| metrics: | |
| - f1 | |
| - accuracy | |
| # TinyGuard-Injection(基座 + 微调) | |
| **从零训练的双语提示注入检测器(含间接注入)** · 9.1M 参数 · MLX/Metal · Apache-2.0(代码)· 训练数据全合成 | |
| [English](MODEL_CARD-injections.md) | |
| ## 模型描述 | |
| 部署在 LLM 应用输入口与 RAG 检索口的三分类护栏:`benign / direct injection / indirect injection`。与 Meta Llama Prompt Guard 2(22M/86M,**不含中文**)互补:本模型中英双语同权训练。 | |
| - 基座:共享 TinyGuard-Encoder(与 TinyGuard-Command 同一预训练底座)。 | |
| - 微调:12330 条双语标注,六类载体(代码与协作平台、邮件网页、超长 RAG 片段、工单客服、良性高难负例、隐藏字符与编码),含"最小差异对"与防过拒设计。 | |
| ## 成绩(全部为留出数据,从未参与训练) | |
| | 评测集 | 指标 | 数值 | | |
| |---|---|---| | |
| | 验证集 616 条 | acc / macro-F1 | **99.0% / 0.990** | | |
| | 对抗集 40 条(零宽字符/JSON 规则/日文载体/引用免责) | 干预 recall / precision / F1 | 75% / 88% / 0.81 | | |
| 对照:Llama Prompt Guard 2-86M 官方卡报告英文注入检测 F1≈0.98,但无中文;本模型中文注入为第一梯队能力,英文对抗集略弱于其英文主场(预期内,9.1M vs 86M)。 | |
| ## 用法 | |
| 权重:[`QuanxinLi/TinyGuard-Injection`](https://huggingface.co/QuanxinLi/TinyGuard-Injection) · | |
| 代码与训练管线:[`Quanxin-Lee/TinyGuard`](https://github.com/Quanxin-Lee/TinyGuard) | |
| ```python | |
| # quickstart(transformers/MLX 双格式)——完整流程见 GitHub 仓库 | |
| ``` | |
| ## 局限 | |
| - 对抗集漏检 5/40:JSON 化规则、无 URL 的"prioritize this"类、授权框架下的直接索要(红队话术)——均为弱信号形态。 | |
| - 英文部分训练量低于中文同类项目主场,英文对抗泛化待加强。 | |
| - 建议与正则层叠用:本模型管语义,正则管已知指纹。 | |
| ## 训练细节与数据声明 | |
| 数据 100% 合成/人工编写,无真实用户数据。训练管线、审计脚本(含三轮深度扫描)与全部数据集随仓库开源。 | |