玩模型开放模型 · 清晰来源 · 自主选择
返回模型目录
jsayyar04 /

modernbert-jailbreak-guard

HF 源站

jsayyar04/modernbert-jailbreak-guard is an uncensored open-source model hosted on Hugging Face.

safetensorsLicense: apache-2.0modernberttext-classificationllm-securityprompt-injectionguardraildataset:jackhhao/jailbreak-classificationmodel-index
README.md说明 / 使用方法

license: apache-2.0 base_model: answerdotai/ModernBERT-base tags:

  • text-classification
  • llm-security
  • prompt-injection
  • guardrail datasets:
  • jackhhao/jailbreak-classification metrics:
  • accuracy
  • precision
  • recall
  • f1 model-index:
  • name: modernbert-jailbreak-guard results:
    • task: type: text-classification dataset: type: jackhhao/jailbreak-classification name: jailbreak-classification metrics:
      • type: accuracy value: 0.9962 pipeline_tag: text-classification

modernbert-jailbreak-guard

This repository hosts a sequence classification model fine-tuned to act as a pre-inference security gate for Large Language Model applications. Its core task is to inspect incoming user prompts and classify them as benign or jailbreak with minimal latency.

The architecture leverages answerdotai/ModernBERT-base as its core encoder backbone and attaches a sequence classification head optimized over full-parameter weight tuning on a T4 GPU.

Test Set Performance

Evaluated against an independent test split, this guardrail achieves strong metrics:

  • Overall Model Accuracy: 98.47%
  • Precision (Jailbreak): 97.87%
  • Recall (Jailbreak): 99.28% (Successfully intercepted 138 out of 139 malicious inputs)
  • F1-Score (Jailbreak): 98.57%
  • Macro F1-Score: 98.47%
  • False Negative Rate: 0.72% (Critical leaks minimized to under 1%)
  • False Positive Rate: 2.44% (Maintains smooth user experience with minimal false blocks)

Confusion Matrix Breakdown

  • True Negatives (Safe prompts allowed seamlessly): 120
  • True Positives (Malicious attacks neutralized): 138
  • False Positives (Safe prompts accidentally blocked): 3
  • False Negatives (Malicious payloads leaked): 1

Intended Uses and Limitations

Intended Deployment Design

This model is intended to run as a Pre-Inference Gateway Shield. It intercepts raw string requests coming from client user interfaces before they are routed to generative backends like GPT-4, Llama 3, or Claude.

Limitations and Strategy

  • Input-Only Scope: This gateway model does not monitor outgoing text generated by the core model. It needs to be coupled with an independent post-inference output alignment model to monitor for hallucinations or data leaks.
  • Defense in Depth: While highly robust, it should represent one tier of a holistic security layout including input vector blacklists and runtime system prompts.

Training and Evaluation Data

The model was fine-tuned on the balanced split of the jackhhao/jailbreak-classification dataset.

  • Training Size: 1,044 examples
  • Evaluation Size: 262 examples
  • Label Mapping: benign (0), jailbreak (1)

The dataset features a balanced distribution of classic adversarial templates, context-switching overrides, hypothetical roleplay scripts, and standard conversational strings.

Training Procedure

The model was fine-tuned using the Hugging Face Trainer library on a single cloud-hosted NVIDIA Tesla T4 GPU.

Framework and Optimization Settings

  • Optimizer: ADAMW_TORCH_FUSED (Accelerated hardware optimization kernel)
  • Precision: Mixed-precision training enabled via BF16=True (Brain Floating Point)
  • Sequence Processing: Token unpadding active to dynamically strip empty PAD tensors from memory allocation blocks.

Training hyperparameters

The following hyperparameters were used during training:

  • learning_rate: 2e-05
  • train_batch_size: 8
  • eval_batch_size: 16
  • seed: 42
  • optimizer: Use OptimizerNames.ADAMW_TORCH_FUSED with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
  • lr_scheduler_type: linear
  • num_epochs: 4

Training results

Training LossEpochStepValidation LossAccuracyPrecision JailbreakRecall JailbreakF1 JailbreakMacro F1True NegativesFalse PositivesFalse NegativesTrue PositivesFalse Negative RateFalse Positive Rate
0.05871.01310.05440.98470.97870.99280.98570.9847120311380.00720.0244
0.00272.02620.03060.98850.98570.99280.98920.9885121211380.00720.0163
0.00013.03930.02650.99240.99280.99280.99280.9923122111380.00720.0081
0.00004.05240.02660.99621.00.99280.99640.9962123011380.00720.0

Framework versions

  • Transformers 5.10.0.dev0
  • Pytorch 2.11.0+cu128
  • Datasets 4.0.0
  • Tokenizers 0.22.2
HUGGING FACE

上游数据

HF 下载量9
HF 点赞量0

HF 下载量为源站最近 30 天统计,与本站点击分开。

SITE STATS

本站统计

下载点击—
请求数—
匿名去重—最近 7 天—

本站下载量记录按钮点击,不代表下载完成;短时连点会去重。

来源与版本

作者
jsayyar04
最近更新
2026/06/08
最新创建
2026/06/08
HF 趋势
未知
数据快照
2026/09/17
版本
未知
许可证
apache-2.0