/ Модель

Характеристики

Контекст
512 токенов
Лицензия
Apache 2.0
Архитектура
grimguard · dense
Базовая модель
bert-base-uncased
Библиотека
transformers
Опубликована
19 окт 2026

GrimGuard-01-Prompt-Guard

Классификация текстаТекст → label3 профессии

Англоязычный классификатор Grimlabs, который по заданной текстовой политике определяет, разрешить ли пользовательский запрос, пометить его или отправить на проверку.

18скачиваний за 30 дней1лайквеса обновлены19 окт 2026

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

GrimGuard-01-Prompt-Guard — модель классификации политик и пользовательских запросов от Grimlabs LLC. Она принимает текстовую политику с правилами DO_FLAG и DO_NOT_FLAG и запрос пользователя, а затем возвращает метку allow, flag или review. Модель предназначена для настройки проверки запросов под конкретные правила без обучения отдельного классификатора для каждого приложения.

Основная версия Pro — энкодерный классификатор на базе BERT-base с 110,27 млн параметров и дополнительной головой для определения правила, повлиявшего на результат. Компактная версия Fast содержит 22,76 млн параметров и получена дистилляцией Pro. Доступны веса Safetensors и ONNX, в том числе варианты int8; лицензия — Apache-2.0. Модель рассчитана на английские политики и одношаговые запросы.

Сильные стороны — гибкое применение заданных оператором правил и быстрый режим Fast для CPU. Ограничения включают синтетические обучающие данные, недостаточно подтверждённую работу на реальном трафике и пробелы в обобщении на незнакомые политики и калибровке при низком уровне ложных срабатываний. При превышении лимита последовательности возвращается review; результат не следует считать allow. Для важных решений нужна дополнительная проверка человеком.

Сценарии применения

  • пометка запросов на возврат цифрового товара по заданной политике
  • выявление запросов на отмену подписки
  • направление неоднозначных запросов на ручную проверку
  • классификация обращений поддержки по пользовательским правилам

Ограничения

Обучение проводилось на синтетических англоязычных одношаговых данных, а качество на реальном трафике не установлено; обобщение на незнакомые политики и калибровка при низком уровне ложных срабатываний остаются проблемами. При превышении лимита последовательности модель возвращает review, а устойчивость к атакам не гарантируется.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

GrimGuard-01-Prompt-Guard

Published by Grimlabs LLC.

GrimGuard-01-Prompt-Guard is a small, instruction-conditioned prompt guard. It reads a natural-language policy containing DO_FLAG and DO_NOT_FLAG rules plus a user prompt, and returns allow, flag, or review — without fine-tuning a new classifier for every application.

[CONTEXT] A digital storefront support assistant for ebooks and subscriptions.
DO_FLAG:
- Requests for a refund for a digital product.
- Requests to cancel an active subscription.
DO_NOT_FLAG:
- Questions about the refund policy or cancellation terms.

This repository contains:

PathModelParamsPurpose
rootGrimGuard-Pro110.27MFull policy conditioning; accuracy path
fast/GrimGuard-Fast22.76MCompact policy; strict single-core CPU path
onnx/both—fp32 and per-channel int8 ONNX artifacts

The main model is an encoder-only classifier with an optional rule-attribution head. The Fast model is a MiniLM-L6 student distilled from Pro.

Quickstart

The model uses a custom architecture, so load it with trust_remote_code=True.

import torch
from transformers import AutoModel, AutoTokenizer

repo_id = "Grimlabs/GrimGuard-01-Prompt-Guard"
tokenizer = AutoTokenizer.from_pretrained(repo_id)
model = AutoModel.from_pretrained(repo_id, trust_remote_code=True).eval()

policy = """\
[CONTEXT] A digital storefront support assistant for ebooks and subscriptions.
DO_FLAG:
- Requests for a refund for a digital product.
- Requests to cancel an active subscription.
DO_NOT_FLAG:
- Questions about the refund policy or cancellation terms.
"""

for prompt in [
    "I want a refund for the ebook I bought yesterday.",
    "What does your refund policy say about digital goods?",
]:
    result = model.classify(tokenizer, policy, prompt, threshold=0.5)
    print(prompt)
    print(result)

classify returns:

{
  "verdict": "flag" | "allow" | "review",
  "score": float,                # calibrated probability
  "logit": float,                # raw binary logit
  "matched_rule_id": "df_1" | None,
  "matched_rule_text": str | None,
  "policy_text": str,            # the exact rendered policy input
  "too_long": bool,
  "omitted_rule_ids": list[str],
}

Fast CPU model

fast_tokenizer = AutoTokenizer.from_pretrained(repo_id, subfolder="fast")
fast = AutoModel.from_pretrained(repo_id, subfolder="fast", trust_remote_code=True).eval()
print(fast.classify(fast_tokenizer, policy, prompt, threshold=0.5743))

The Fast model uses a compact rendered policy (52-token policy budget, 72-token prompt budget, 128-token maximum). It is intended for high-volume, established policies. The first request under a new policy should use the Pro model or return review; this is the safety routing used by the full serving stack.

Thresholds

  • The config stores the F1-optimal calibration threshold (threshold in config.json).
  • Thresholds do not transfer across domains. The F1 threshold has a high false-positive rate on unseen domains. For conservative application-specific use, pass a higher threshold (e.g., threshold=0.5) and calibrate on the target deployment's benign traffic.
  • review is returned when the policy+prompt exceeds the model's sequence budget; do not treat it as allow.

ONNX

onnx/ contains:

  • pro.onnx (fp32) and pro_int8.onnx (per-channel int8)
  • fast.onnx (fp32) and fast_int8.onnx (per-channel int8)

See onnx/README.md for input names and a minimal ONNX Runtime example. The Fast int8 artifact is the recommended strict-CPU deployment: measured 8.61 ms p50 / 8.76 ms p95 model-only at 128 tokens on one pinned Intel i9-14900KF core.

Evaluation

Final held-out evaluation, 3,663 examples (909 in-distribution, 2,185 unseen-domain, 569 adversarial):

Model / suiteAUROCF1FPR
Pro — all0.92890.83870.1129
Pro — in-distribution0.97670.90820.0415
Pro — unseen domains0.89270.80110.1595
Pro — adversarial0.96410.87410.0468
Fast — all0.88680.80300.1206
Fast — unseen domains0.83010.75000.1705
Lexical rule-keyword baseline0.64520.67570.8074

Policy controls (Pro): empty policy 100% allow, policy-shuffled 95.5% correct, rule-added 100% flag, rule-removed 76.7% allow. Rule attribution top-1 85.3%, top-3 99.2%.

Counterfactual pair ranking is 0.743 overall and 0.706 on unseen policies, below the 0.80 target. Aggregate operating points and confidence intervals are in eval_results_pro.json and eval_results_fast.json.

Training data

Synthetic, English, single-turn policy-conditioned data authored by domain-specific LLM sub-agents:

  • 10,452 authored examples across 804 policies (612 training/raw, 192 held-out/eval).
  • 30,219 processed training pairs after counterfactual augmentation (rule removal, rule addition, empty policy, cross-policy pairing, authored counterfactual groups) and custom-policy oversampling.
  • Pro was trained on BERT-base with binary BCE, an optional rule-attribution BCE, and a pairwise margin loss on counterfactual pairs.
  • A short warm-started fine-tune on ordinary-action/refund custom policies produced the released Pro checkpoint.
  • Fast was distilled from Pro with hard-label BCE + KL.

No real user data was used. Validation and a 200-example blind QA audit (Cohen's kappa 0.98) were performed before training.

Latency

ArtifactHardwareResult
Fast int8, 128 tokens1 pinned i9-14900KF core8.61 ms p50 / 8.76 ms p95
Fast, warm HTTP pathsame2.1 ms p50 / 2.6 ms p95 client-observed
Pro fp16, 256 tokensRTX 40702.2 ms p50 / 3.1 ms p95
Pro int8, 128 tokens8 CPU threads15.0 ms p50 / 15.1 ms p95

A single dense 80–120M encoder cannot meet <15 ms on one CPU core at useful context; the Fast path is the strict single-core model, and Pro is the GPU/multi-thread accuracy path.

Limitations

  • English, single-turn only.
  • Synthetic training data; performance on real traffic is not established.
  • Unseen-policy generalization and low-FPR calibration are the main open gaps.
  • Ordinary-action custom policies (e.g., "flag every refund request") required a targeted fine-tune and threshold discipline; a low threshold can over-flag the same prompt under an allowing policy.
  • Counterfactual pair accuracy is below target.
  • Fast int8 has 98.0% label agreement with PyTorch (target 99%).
  • A guardrail is not a substitute for human review in high-stakes settings. Adversarial robustness is measured, not guaranteed.
  • The model follows the written policy, including unusual or adversarial policies supplied by the deployer.

License

Apache-2.0. The Fast backbone derives from sentence-transformers/all-MiniLM-L6-v2; the Pro backbone derives from google-bert/bert-base-uncased.

Citation

@misc{grimguard01promptguard,
  title  = {GrimGuard-01-Prompt-Guard: A Small Instruction-Conditioned Prompt Guard},
  year   = {2026},
  author = {Grimlabs LLC},
  note   = {Dynamic DO_FLAG/DO_NOT_FLAG policies with a Fast CPU path and a Pro accuracy path}
}

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · transformers · text-classification

Нельзя запустить

Модели нужен код из репозитория; автор пока не в списке доверенных организаций.

Класс архитектуры
GrimGuardForPolicyClassification
Ревизия весов
cb97880

0 моделей