/ Модель

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

Контекст
2 048 токенов
Параметры
60 млн
Лицензия
Apache 2.0
Архитектура
g2_nano_safety · dense
Библиотека
transformers
Опубликована
13 сен 2026

G2-nano-safety

Классификация текстаТекст → label

Компактная модель классификации исходящих сообщений для разрешения отправки, редактирования чувствительных данных или блокировки.

119скачиваний за 30 дней3лайкавеса обновлены13 сен 2026

Бенчмарки

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

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

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

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

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

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

G2-nano-safety — модель классификации и компонент детерминированного контура безопасности сообщений, разработанный автором репозитория AZERDSQ. Она оценивает исходящее сообщение для агента и выбирает одно из трёх решений: ALLOW, REDACT или BLOCK. Модель не является чат-ботом: её 60-миллионная основа с классификационной головой выдаёт оценку, а регулярный детектор, проверка секретов и отдельный сборщик формируют итоговый JSON с найденными фрагментами и текстом после редактирования.

Модель предназначена для проверки сообщений перед отправкой инструменту или адресату. Она инициализирована из G2-nano-base и дообучена для классификации; архитектура содержит 14 слоёв, скрытый размер 576 и GQA с 9 головами запросов и одной KV-головой. Контекст составляет до 2048 токенов. По внутренней оценке на 200 примерах точность решений составила 76,5%; набор небольшой и частично переиспользует ранее отобранные случаи. Особенно слабо распознаётся класс REDACT, а модель ориентирована преимущественно на английский. Лицензия — Apache-2.0.

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

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

Ограничения

Модель не предназначена для диалога и не должна быть единственной защитой для критичных или содержащих секреты данных. Внутренняя оценка мала и частично повторно использует отобранные примеры; качество решения REDACT заметно ниже, а обучение и тесты ориентированы преимущественно на английский.

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

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

Открыть на Hugging Face

G2-nano-safety

A ~60M-parameter outbound judge (ALLOW / REDACT / BLOCK) for messages sent to an agent. Not a chatbot. JSON (spans, redacted text) is assembled by a deterministic net, not generated by the 60M model.

Overview

G2-nano-safety is initialized from G2-nano-base. A 3-way classification head votes ALLOW, REDACT or BLOCK. A regex detector and a secret veto run first; an assembler builds the API JSON.

It is not G2-nano-instruct, not a NER tagger, and not an Ollama chat model. Hugging Face is the intended surface (weights + net). There is no Ollama chat tag for this model.

The application sends only message; the runtime attaches destination, tool history and policy overrides for the contextual judge (see Usage).

Model variants

Same generation, different jobs:

This repository is the safety head + assembler, not a sibling chat checkpoint.

What this version is

Runtime fills tool, destination and history; the app sends the user message. Output:

{
  "decision": "REDACT",
  "findings": [
    {
      "text": "lea.ctx@exemple.fr",
      "start": 17,
      "end": 35,
      "type": "EMAIL",
      "role": "contact",
      "action": "REDACT"
    }
  ],
  "redacted_message": "Envoie un mail à [EMAIL] pour confirmer le créneau."
}
decisionEffect
ALLOWMessage is sent unchanged
REDACTMessage is sent; redacted_message + findings
BLOCKNothing is sent; redacted_message is empty

Closed experiments (JSON generation, sft_cls_v2 39/39 on templates seen in training) are not this checkpoint.

Architecture

  1. Regex detector (detect).
  2. Secret veto → BLOCK.
  3. 60.04M backbone (G2-nano-base shape) with a 3-logit head; argmax.
  4. Assembler → JSON.
PropertyValue
Backbone parameters60.03M (+3×576 head)
Layers / hidden14 / 576
AttentionGQA, 9 query heads / 1 KV head
Context length2048 tokens native; classifier run at 1024
Vocabulary16,388 (16,384 SentencePiece + 4 chat tokens)
Head3-way ALLOW / REDACT / BLOCK

Training

  • Init: G2-nano-base (never the instruct checkpoint)
  • Run: sft_cls classification SFT (step 104)
  • Data: 432 twin cases + 50 gold cases, packed at sequence length 1024
  • Hardware: NVIDIA Jetson Orin Nano (8GB unified memory)
  • Official eval: internal contextual bench, 39 cases, ids held out from training (data/bench_context.jsonl)

Usage

Do not call generate() as if this were a chat model. Use judge.py (trust_remote_code weights + deterministic net):

import sys
sys.path.insert(0, "G2-nano-safety")  # cloned repo dir (judge.py lives here)
from judge import judge, load_judge

tok, model, device = load_judge("G2-nano-safety")
out = judge(
    "Envoie un mail à Lea pour confirmer le créneau.",
    tool_context="mail.send",
    tok=tok, model=model, device=device,
)
print(out["decision"])          # REDACT
print(out["redacted_message"])  # Envoie un mail à [EMAIL] pour confirmer le créneau.

Or from the shell:

python3 judge.py --repo G2-nano-safety \
  --message "Envoie un mail à Lea pour confirmer le créneau." \
  --tool-context "mail.send"

Evaluation

Internal contextual bench, N=39, decision metric (higher is better). Leak = 0. False-positive rate on ALLOW gold = 2.6%. Official score 36/39 (92.3%).

SystemDecisionLeakFPR
G2-nano-safety (sft_cls + assembler)92.3%02.6%
Naive regex (match → BLOCK)46.2%012.8%
GLiNER edge + wrapper61.5%12.8%23%
Shieldstral Q4 + our assembler69.2%17.9%12.8%

Extended contextual set, N=200 (the 39 historical cases plus 161 new deterministic cases: 46 ALLOW, 82 REDACT, 72 BLOCK): 153/200 (76.5%), leak 4.0%, FPR 0.5%, ahead of Shieldstral Q4 (133/200), GLiNER edge (118/200) and naive regex (98/200). Honest reserve: the 39 selection cases are part of the 200, so this is an extension, not a pure hold-out — and REDACT drops to 43.9% (often over-BLOCK or ALLOW). BLOCK stays at 100%, ALLOW at 97.8%.

This is a small internal set, not a public safety leaderboard. Shieldstral is a ~3B judge: the comparison is “same post, different stack,” not “we beat Mistral on safety.” Do not cite sft_cls_v2 39/39 (templates seen in training). Do not cite JSON-generation 43/52 as the product score.

Limitations

  • Not a chatbot; no conversation quality.
  • N=39 is small; the N=200 extension reuses the selection set and shows a REDACT weakness (43.9%).
  • Three errors on the official set are over-BLOCK (act_not_quote_en, clean_local_code, local_contact_redact).
  • English-centric tokenizer and benches.
  • Must not be the only control around high-stakes or secret-bearing traffic.

This model should not be used as a substitute for access control, encryption, or human review of dangerous tool use.

License

Apache 2.0.

Open weights: classifier weights plus the assembler, not a chat GGUF. Training data and intermediate runs stay private.

Links

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

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

GPU в ailist

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

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

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

Класс архитектуры
NanoGPTSafetyClassifier
Ревизия весов
6c8c765

0 моделей