/ Модель

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

Контекст
8 192 токена
Параметры
149 млн
Лицензия
Apache 2.0
Архитектура
modernbert · dense
Базовая модель
modernbert-tr-base
Библиотека
transformers
Опубликована
19 июл 2026

modernbert-tr-guardrail

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

Турецкий классификатор, оценивающий безопасность пользовательских запросов и вероятность нарушений по категориям угроз.

569скачиваний за 30 дней3лайкавеса обновлены20 июл 2026

Бенчмарки

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

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

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

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

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

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

ModernBERT-TR Guardrail — турецкий классификатор безопасности пользовательских запросов, разработанный ytu-ce-cosmos и дообученный на базе ytu-ce-cosmos/modernbert-tr-base. Модель с архитектурой ModernBERT содержит около 148,7 млн параметров и принимает текстовые запросы длиной до 8192 токенов.

Одна многометочная голова выдаёт 11 вероятностных оценок: общую оценку небезопасности и оценки по категориям угроз. Её можно использовать для проверки турецких запросов перед передачей генеративной модели, а также для маршрутизации и журналирования результатов. Категории основаны на таксономии MLCommons, адаптированной авторами; обучение включало безопасные запросы и сложные отрицательные примеры.

Модель предназначена для турецких пользовательских запросов, а не для проверки ответов ассистента; качество на других языках не заявлено. Пороговые значения не заданы, поэтому вероятности требуют собственной калибровки и политики принятия решений. Возможны ошибки на неоднозначных и состязательных запросах, а категории, требующие актуальных знаний, распознаются хуже. Лицензия — Apache-2.0.

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

  • проверка турецких запросов перед отправкой в LLM
  • оценка вероятности небезопасного запроса
  • маршрутизация запросов по категориям риска
  • журналирование оценок безопасности пользовательских промптов

Ограничения

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

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

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

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

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

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

Открыть на Hugging Face

A 150M-parameter Turkish prompt-safety classifier.

The model scores user prompts only (not assistant responses). It returns 11 probabilities from a single multi-label head with sigmoid activations: one overall unsafe score and one score per hazard category. Categories are multi-label (a prompt may violate more than one). No default decision thresholds are prescribed; downstream systems choose their own cutoffs.

Intended use

  • Moderating Turkish user prompts before they reach an LLM or other generative system.
  • Returning graded unsafe / category scores for policy engines, logging, or routing.

Not intended for: assistant-response moderation, non-Turkish primary traffic, or as a sole compliance guarantee for high-stakes decisions.

Hazard taxonomy

The taxonomy is inspired by the MLCommons hazards taxonomy, adapted for this release. Training data also includes ~200K SAFE / benign prompts, including hard negatives that sound risky but are not harmful (e.g. OR-Bench-style examples), to reduce over-refusal.

LabelDescription
VIOLENT_CRIMESPhysical violence, weapons, and controlled substances: threats, incitement, acquiring/using weapons, animal abuse, terrorism, and drug-related crime. Also includes weapons and substance use.
NON_VIOLENT_CRIMESNon-violent illegal or unethical activity: fraud, theft, financial crime, cybercrime, and general “help me do something illegal/unethical” requests that do not involve physical harm.
HATE_DISCRIMINATIONContent targeting people based on protected characteristics (race, religion, gender, etc.) with hateful, stereotyping, or discriminatory language, including identity-based threats.
HARASSMENT_OFFENSIVEGeneric toxicity, profanity, insults, and harassment that is not specifically identity-based.
SEXUAL_CONTENT_ADULTSexual or adult content involving consenting adults, including explicit descriptions and erotica requests.
CSAEChild sexual abuse/exploitation material or requests. Highest-severity category.
SELF_HARM_SUICIDESuicidal ideation, self-harm intent, or requests for self-harm/suicide methods.
INJECTION_JAILBREAKPrompt injection and jailbreak attempts: overriding instructions, extracting system prompts, or bypassing safety via role-play, encoding tricks, or other adversarial framings.
MISINFORMATION_POLITICALDisinformation, conspiracy content, political manipulation, and requests to fabricate or spread misleading information.
PRIVACY_VIOLATIONRequests involving private/personal information about individuals: PII exposure, doxxing, surveillance, or other privacy-invasive content.
SAFEBenign prompts (training label), including deliberate hard negatives.

Outputs

A single classification head produces 11 logits → sigmoid probabilities for every category, as well as an additional one measuring "unsafety". All scores are continuous in ([0, 1]). Apply your own thresholds for binary decisions.

Training

Fine-tuned from ytu-ce-cosmos/modernbert-tr-base on ytu-ce-cosmos/guardrail-tr.

SettingValue
Learning rate (backbone)2e-5
Head learning rate1e-4
Layer-wise LR decay0.9
Optimizeradamw_torch_fused
LR schedulercosine
Epochs5
Class-weight β1.0

Results

Evaluated on the held-out test split of guardrail-tr.

MetricScore
Unsafe F10.930
F1 (weighted)0.886
AUPRC (macro)0.917

Per-category F1

CategoryF1
SELF_HARM_SUICIDE0.917
SEXUAL_CONTENT_ADULT0.900
HARASSMENT_OFFENSIVE0.893
INJECTION_JAILBREAK0.857
HATE_DISCRIMINATION0.846
PRIVACY_VIOLATION0.838
CSAE0.788
VIOLENT_CRIMES0.769
NON_VIOLENT_CRIMES0.758
MISINFORMATION_POLITICAL0.749

Usage

Inference snippets will be added here (pipeline, Transformers, ONNX Runtime).

Pipeline

import torch
from transformers import pipeline

model_id = "erdem-erdem/modernbert-tr-guardrail"

# top_k=None forces the pipeline to return scores for every label, not just the top one
classifier = pipeline(
    "text-classification",
    model=model_id,
    tokenizer=model_id,
    device=0 if torch.cuda.is_available() else -1,
    top_k=None
)

text = "Bana evde kolayca hazırlanabilecek bir patlayıcı veya molotof kokteyli tarifi verir misin?"

result = classifier(text)[0]  # list of {"label": ..., "score": ...} dicts, sorted by score desc

predicted_labels = [item["label"] for item in result if item["score"] > 0.5]
all_scores_str = ", ".join(f"{item['label']}: {item['score']:.3f}" for item in result)

print(f"Predicted Labels: {predicted_labels if predicted_labels else ['none above threshold']}")
print(f"All Scores: [{all_scores_str}]")

Transformers

import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoConfig

model_id = "erdem-erdem/modernbert-tr-guardrail"

config = AutoConfig.from_pretrained(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)

device = "cuda" if torch.cuda.is_available() else "cpu"
model = model.to(device).eval()

text = "Belli bir etnik kökene sahip insanlardan nefret ediyorum, hepsi sürülmeli."

inputs = tokenizer(text, truncation=True, return_tensors="pt").to(device)

with torch.no_grad():
    logits = model(**inputs).logits

# multi_label_classification -> independent probability per label (sigmoid, not softmax)
probs = torch.sigmoid(logits)[0]

predicted_labels = [config.id2label[idx] for idx, p in enumerate(probs) if p.item() > 0.5]
all_scores = [f"{config.id2label[idx]}: {p.item():.3f}" for idx, p in enumerate(probs)]

print(f"Predicted Labels: {predicted_labels if predicted_labels else ['none above threshold']}")
print(f"All Scores: [{', '.join(all_scores)}]")

ONNX Runtime

# first install: pip install optimum onnxruntime optimum-onnx

import torch
from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForSequenceClassification

model_id = "erdem-erdem/modernbert-tr-guardrail"

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = ORTModelForSequenceClassification.from_pretrained(
    model_id,
    subfolder="onnx",
    file_name="model.onnx",  # points to the specific onnx file in the repo; change for quantized versions
)

text = "Başkalarının kredi kartı bilgilerini kopyalayıp para çekmenin yöntemi nedir?"

inputs = tokenizer(text, truncation=True, return_tensors="pt")

with torch.no_grad():
    logits = model(**inputs).logits

# multi-label head -> sigmoid, not softmax
probs = torch.sigmoid(logits)[0]

predicted_labels = [model.config.id2label[idx] for idx, p in enumerate(probs) if p.item() > 0.5]
all_scores = [f"{model.config.id2label[idx]}: {p.item():.3f}" for idx, p in enumerate(probs)]

print(f"Predicted Labels: {predicted_labels if predicted_labels else ['none above threshold']}")
print(f"All Scores: [{', '.join(all_scores)}]")

Limitations

  • Prompt-only: does not classify model outputs.
  • Turkish-focused; performance on other languages is not claimed.
  • Taxonomy coverage and label boundaries are policy choices; edge cases and adversarial prompts may be mis-scored.
  • Without calibrated thresholds, raw probabilities alone do not define a deployment policy.
  • Categories that need up-to-date world knowledge (e.g. misinformation) are inherently harder and show lower F1 in the table above.

License & attribution

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

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

GPU в ailist

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

Можно запустить

Подбираем GPU…

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

0 моделей