StagAI-CyberSecurity-26B-A4B-v2 (Cybersecurity Reasoning Text Model)
(日本語版の説明は下部に記載しています。 / English version is followed by the Japanese version below.)
StagAI-CyberSecurity-26B-A4B-v2 is a "text-only" large language model specialized in cybersecurity analysis and advanced theoretical reasoning.
Based on the stable Gemma-4-26B-A4B(MoE) architecture, fine-tuning was performed using the MLX framework (mlx_lm.lora). After training, the LoRA adjustments were merged into the base model using a unique technique to prevent weight loss, allowing you to deploy and use high-quality inference immediately. This model is designed to serve as an inference engine for security professionals, researchers, SOC analysts, and system administrators when building threat modeling, vulnerability assessments, log interpretation, and comprehensive incident response strategies.
*Please note that this model is strictly for text input and does not support multimodal inputs such as images or audio.
Performance Improvements Over the Base Model
As a result of comparative verification with the original base model using various cybersecurity questions, this model exhibits the following characteristics:
- Improved Answer Quality: Provides more accurate, contextual, and practical answers to complex cybersecurity questions. We have confirmed that the answer quality is further improved compared to our previous model, CyberStag-Security-26B-A4B-V1.
- Deeper Reasoning: We have observed a slight increase in "thinking time" (processing latency). This trade-off allows for profound, step-by-step logical deductions, yielding higher-quality analytical outputs compared to the base model.
Available Models
We provide multiple formats to accommodate various hardware environments, ranging from high-end workstations to edge devices.
MLX Format (Optimized for Apple Silicon)
StagAI-CyberSecurity-26B-A4B-v2-FP16-MLX: Unquantized (FP16) format.StagAI-CyberSecurity-26B-A4B-v2-Q8-MLX: 8-bit quantized model with the adapter merged into the QLoRA base model. A highly balanced format that maintains original inference performance. Highly recommended.StagAI-CyberSecurity-26B-A4B-v2-Q4-MLX: 4-bit quantized model with the adapter merged into the 4-bit quantized base model. Due to a merging technique aimed at reducing the Doom Loop issue, the model size is larger than usual.
GGUF Format (For llama.cpp, LM Studio, etc.)
StagAI-CyberSecurity-26B-A4B-v2-FP16.gguf: Unquantized 16-bit GGUF model converted from StagAI-CyberSecurity-26B-A4B-v2-FP16-MLX.StagAI-CyberSecurity-26B-A4B-v2-Q8_0.gguf: 8-bit quantized GGUF model (high precision, moderate memory requirement). Quantized from StagAI-CyberSecurity-26B-A4B-v2-FP16.gguf.StagAI-CyberSecurity-26B-A4B-v2-Q4_K_M.gguf: 4-bit quantized GGUF model (very lightweight. Strongly recommended for execution in environments with limited VRAM). Quantized from StagAI-CyberSecurity-26B-A4B-v2-FP16.gguf.
License
This model inherits the license of the original base model and is provided under the Apache License 2.0. Commercial use, modification, and redistribution are freely permitted.
Disclaimer
This model is provided solely for educational purposes, learning support, defensive cybersecurity research, hardening assistance, and improving system resilience. Furthermore, the misuse of this model for unauthorized access, generation of offensive exploits, or any other cybercrime is strictly prohibited. By downloading and using this model, the user is deemed to have explicitly agreed to use it only for the purposes of enhancing security and conducting ethical research.
📊 Training Details
Dataset
We used high-quality Supervised Fine-Tuning (SFT) datasets for cybersecurity tasks spanning multiple domains.
- English Dataset: 40,000 entries
- Japanese Dataset: 40,000 entries
- Total: 80,000 entries
Training was conducted using QLoRA (8bit).
Training Parameters
Fine-tuning was performed with the following parameters and LoRA specific settings:
# Basic Parameters
fine_tune_type: "lora"
optimizer: "adamw"
num_layers: 18
learning_rate: 5e-7
mask_prompt: true
# LoRA Specific Settings
lora_parameters:
rank: 4
scale: 1.0
dropout: 0.03
keys:
- "self_attn.q_proj"
- "self_attn.k_proj"
- "self_attn.v_proj"
- "self_attn.o_proj"
- "mlp.gate_proj"
- "mlp.up_proj"
- "mlp.down_proj"
- "experts.switch_glu.gate_proj"
- "experts.switch_glu.down_proj"
- "experts.switch_glu.up_proj"
Trainable parameters: 0.397% (100.109M/25233.053M)
⚠️ Important Notes & Best Practices
To maximize the performance of this model, please keep the following in mind:
- Highest Precision is 8bit: Since training was conducted in QLoRA (8bit), the 8bit model is highly likely to have the highest precision and demonstrate its true performance.
- MLX vs. GGUF Formats: The published GGUF model was converted from the FP16 MLX format. Therefore, the native MLX format may provide higher accuracy. (If any users or experts know a more optimal method for GGUF conversion, we would greatly appreciate your contribution.)
- Doom Loop Mitigation for Low-bit (4bit) Models: In low-bit environments such as 4bit quantization, the probability of generative repetition (Doom Loops) increases. To prevent this, the MLX format(4bit) model includes a configuration file with
"temperature": 0.5. When using the low-bit GGUF model, we recommend adjusting settings such as thetemperature.
💡 Recommended GGUF Usage (Forcing the Inference Process)
To ensure the thinking process (Thinking block) unfolds reliably, the GGUF model was crafted by pre-embedding the Jinja template (chat_template.jinja) metadata into the 16bit MLX model's tokenizer_config.json before quantization.
[IMPORTANT] Notice Regarding Ollama Usage
If you register and use this model in Ollama, the native renderer may forcefully overwrite the formatting, and depending on the prompt, the reasoning (Thinking) block could be entirely skipped.
Therefore, we recommend using a combination of llama-server and Open WebUI, which applies 100% identical prompt processing to MLX.
Recommended Environment Setup (llama.cpp)
# 1. Start llama-server (Utilizing native support for Jinja2 engine [minja])
./build/bin/llama-server \
-m /path/to/StagAI-CyberSecurity-26B-A4B-v2-Q4_K_M.gguf \
--port 8080 \
-ngl 99 \
-c 49152
# 2. Open WebUI Connection Settings
# Go to Admin Settings > Connections > OpenAI API section and add:
# API Base URL: http://localhost:8080/v1 (or [http://host.docker.internal:8080/v1](http://host.docker.internal:8080/v1) for Docker)
# API Key: sk-dummy (Any string will work)
🛠 Advanced: LoRA Merging Technique & Verification
Normally, merging LoRA into a quantized base model and saving it with requantization causes the microscopic weight differences (learning effects) of LoRA to be rounded off and lost. To prevent this, our model implements a two-step countermeasure:
- Preventing Difference Loss During Merge (Modification of
mlx_lm.fuse) During the merge execution, the Python code was modified so that the target layers to which LoRA was applied are retained in full precision (e.g., FP16) without being requantized immediately. This reliably maintains the learned microscopic differences. - Preventing Requantization During Load (Adjustment of
config.json) When loading the merged model, to prevent the full precision layers from being unintentionally requantized by old quantization specifications remaining in the configuration file, the quantization settings for target layers (such asmlp.gate_proj,up_proj,down_proj) were precisely deleted fromconfig.json.
Merge Verification Results
We rigorously verified whether the above methods functioned correctly using Python code.
- Perfect Weight Match: For each target layer in
language_model.model.layers, the difference (Max Diff) between the expected merged weights and the actual weights was kept under 0.0009, confirming ✅ PERFECT MATCH (Fuse fully successful). - Logits Output Verification & Insights:
- Original LoRA effect (Base+LoRA vs BASE): 23.875
- Change due to merge (Merged vs BASE): 23.750
- The deviation from the target is minimal, proving that the LoRA weights were not lost (No Silent Dropping) and the learning effects were properly reflected in the base model.
- Validation of Method on MoE Architecture: Furthermore, the magnitude of change in these logits demonstrates the effectiveness of applying LoRA across a wide range of target modules, even with a low rank (Rank 4) and a low learning rate. It numerically confirms that in MoE (Mixture of Experts) models, such microscopic weight updates produce a definitive and meaningful shift in inference behavior.
StagAI-CyberSecurity-26B-A4B-v2 (日本語版)
StagAI-CyberSecurity-26B-A4B-v2 は、サイバーセキュリティ分野の分析と高度な理論的推論に特化して開発された、"テキスト専用"の大規模言語モデルです。
安定な Gemma-4-26B-A4B(MoE)アーキテクチャ をベースとし、MLXフレームワーク (mlx_lm.lora) を用いてファインチューニングを実施しました。学習完了後、LoRA調整は独自の工夫を用いてベースモデルにマージされており、ダウンロード後すぐにデプロイして高品質な推論を使用することが可能です。
また、本モデルは、セキュリティ専門家、研究者、SOCアナリスト、システム管理者などが、脅威モデリング、脆弱性評価、ログの解釈、そして包括的なインシデント対応戦略を構築する際の推論エンジンを目指して作られています。
※本モデルはテキスト入力専用であり、画像や音声などのマルチモーダル入力には対応していません。
ベースモデルからの性能向上
サイバーセキュリティに関する様々な質問を用いてオリジナルのベースモデルと比較検証を行った結果、本モデルには以下の特徴が確認されています。
- 回答品質の向上: 複雑なサイバーセキュリティの質問に対し、より正確で文脈に沿った、実務に直結する回答を提供します。前モデル(CyberStag-Security-26B-A4B-V1)と比較しても、回答品質がより向上していることを確認しております。
- 推論の深さ: 回答の生成を開始するまでの「思考時間(レイテンシ)」がわずかに増加する傾向が見られます。これは、表面的な回答を避け、より深くステップバイステップの論理的演繹を行うためのトレードオフであり、結果として非常に分析的で高品質な出力を生み出すものと考えます。
公開モデル
ハイエンドなワークステーションからエッジデバイスまで、様々なハードウェア環境に対応するため、複数のフォーマットを提供しています。
MLX フォーマット (Apple Silicon向け最適化)
StagAI-CyberSecurity-26B-A4B-v2-FP16-MLX: 非量子化(FP16)フォーマット。StagAI-CyberSecurity-26B-A4B-v2-Q8-MLX: QLoRAのベースモデルにアダプターをマージした8bit量子化モデル。オリジナルの推論性能を維持する、非常にバランスの取れたフォーマット。最もおすすめ。StagAI-CyberSecurity-26B-A4B-v2-Q4-MLX: 4bit量子化されたベースモデルにアダプターをマージした4bit量子化モデル。Doom Loop問題の削減を目的としたマージ手法により、モデルサイズが通常より大きくなっております。
GGUF フォーマット (llama.cpp, LM Studio 等向け)
StagAI-CyberSecurity-26B-A4B-v2-FP16.gguf: StagAI-CyberSecurity-26B-A4B-v2-FP16-MLXからGGUF形式へ変換した非量子化 16bit GGUFモデル。StagAI-CyberSecurity-26B-A4B-v2-Q8_0.gguf: 8bit 量子化 GGUFモデル (高精度、中程度のメモリ要求)。StagAI-CyberSecurity-26B-A4B-v2-FP16.ggufから量子化を実施。StagAI-CyberSecurity-26B-A4B-v2-Q4_K_M.gguf: 4bit 量子化 GGUFモデル (非常に軽量。VRAMに制限のある環境での実行に強く推奨します)。StagAI-CyberSecurity-26B-A4B-v2-FP16.ggufから量子化を実施。
ライセンス (License)
本モデルは元モデルのライセンスを継承し、Apache License 2.0 の下で提供されています。商用利用、改変、再配布が自由に可能です。
免責事項 (Disclaimer)
本モデルは、教育目的、学習の支援、防御側のサイバーセキュリティ研究、ハードニングの支援、およびシステム回復力の向上を目的としてのみ提供されています。また、本モデルを不正アクセス、攻撃用エクスプロイトの生成、その他あらゆるサイバー犯罪に悪用することを明確に禁止します。 なお、本モデルをダウンロードおよび利用した時点で、ユーザーはセキュリティの向上および倫理的な研究の目的にのみ本モデルを使用することに明示的に同意したものとみなされます。
📊 Training Details (学習データと設定)
データセット
多数の領域にわたる高品質なサイバーセキュリティタスクのSFT(Supervised Fine-Tuning)データセットを使用しています。
- 英語データセット: 40,000件
- 日本語データセット: 40,000件
- 合計: 80,000件
上記データセットを用い、QLoRA (8bit) にてトレーニングを実施しました。
学習パラメータ
ファインチューニングは以下のパラメータおよびLoRA詳細設定で行われました。
# 学習基本パラメータ
fine_tune_type: "lora"
optimizer: "adamw"
num_layers: 18
learning_rate: 5e-7
mask_prompt: true
# LoRA詳細設定
lora_parameters:
rank: 4
scale: 1.0
dropout: 0.03
keys:
- "self_attn.q_proj"
- "self_attn.k_proj"
- "self_attn.v_proj"
- "self_attn.o_proj"
- "mlp.gate_proj"
- "mlp.up_proj"
- "mlp.down_proj"
- "experts.switch_glu.gate_proj"
- "experts.switch_glu.down_proj"
- "experts.switch_glu.up_proj"
Trainable parameters: 0.397% (100.109M/25233.053M)
⚠️ Important Notes & Best Practices (使用上の注意点と推奨設定)
本モデルのパフォーマンスを最大限に引き出すため、以下の点にご留意ください。
- 最高精度は8bitモデル: QLoRA(8bit)で学習を実施している関係上、最も精度が高く本来の性能を発揮するのは 8bitモデル となる可能性が高いです。
- MLX形式とGGUF形式の差異: 公開しているGGUFモデルは、FP16のMLX形式モデルからGGUFへ変換したものです。そのため、ネイティブのMLX形式の方がより高精度になる可能性があります。(※より最適なGGUF形式への変換手法をご存知のユーザー様や有識者の方がいらっしゃいましたら、ぜひご協力をお願いいたします。)
- 低ビット(4bit)モデルにおけるDoom Loop対策: 4bit量子化モデルなど低ビット環境では、生成の反復ループ(Doom Loop)の発生確率が高まります。これを防ぐため、4bitのMLX形式のモデルには
"temperature": 0.5に下げた設定ファイルを配置しています。GGUFの低ビットモデルを使用する際も、temperature等の設定値を調整することを推奨します。
💡 GGUFモデルの推奨使用方法(推論プロセス強制)
GGUF版モデルは、思考プロセス(Thinkingブロック)を確実に展開させるため、16bitのMLXモデルの tokenizer_config.json にJinjaテンプレート(chat_template.jinja)のメタデータを事前埋め込みしてから量子化する工夫を施しています。
【重要】Ollamaでの使用に関する注意
Ollamaに登録して使用する場合、ネイティブレンダラーによる強制上書きが発生し、プロンプトの内容次第で推論(Thinking)ブロックがスキップされる可能性が十分にあります。
そのため、MLXと100%同一のプロンプト処理を適用できる llama-server と Open WebUI の連携等による運用をおすすめします。
推奨環境の構築手順 (llama.cpp)
# 1. llama-serverの起動 (Jinja2エンジン[minja]のネイティブサポートを活用)
./build/bin/llama-server \
-m /path/to/StagAI-CyberSecurity-26B-A4B-v2-Q4_K_M.gguf \
--port 8080 \
-ngl 99 \
-c 49152
# 2. Open WebUI側の接続設定
# 管理者設定 > 接続 > OpenAI APIセクションに以下を追加
# APIベースURL: http://localhost:8080/v1 (Dockerの場合は [http://host.docker.internal:8080/v1](http://host.docker.internal:8080/v1))
# APIキー: sk-dummy (任意の文字列)
🛠 Advanced: LoRAマージ手法の工夫と検証
通常、量子化されたベースモデルにLoRAをマージし、再度量子化して保存すると、LoRAの微小な重みの差分(学習効果)が丸め落とされて消失してしまう問題があります。本モデルでは、これを防ぐために以下の2段構えの対策を実施しています。
- マージ時の差分消失防止 (
mlx_lm.fuseの修正) マージの実行時、LoRAを適用した対象層を直後に再量子化せず、フル精度(FP16等)のまま保持するようPythonコードを修正しました。これにより、学習した微小な差分を確実に維持しています。 - 読み込み時の再量子化防止 (
config.jsonの調整) マージ済みモデルを読み込む際、設定ファイルに残っている古い量子化指定によってフル精度の層が意図せず再量子化されるのを防ぐため、対象層(mlp.gate_proj,up_proj,down_proj等)の量子化設定をconfig.jsonからピンポイントで削除しています。
マージ検証結果
上記の手法が正しく機能しているか、Pythonコードを用いて厳密にチェックを行いました。
- 重みの完全一致:
language_model.model.layersの各対象レイヤーにおいて、予想されるマージ後の重みと実際の重みの差分(Max Diff)が 0.0009 未満に収まり、✅ PERFECT MATCH (Fuse完全成功) を確認しました。 - 出力(Logits)の検証と考察:
- LoRAの本来の効果量(Base+LoRA vs BASE): 23.875
- マージによる変化量(Merged vs BASE): 23.750
- 目標との乖離がごくわずかであり、LoRAの重みが消失(Silent Dropping)することなく、ベースモデルに学習効果が適切に反映されていることを実証しています。
- アーキテクチャに対する手法の有効性: さらに、このLogitsの変化量は、低ランク(Rank 4)かつ低学習率であっても、幅広いモジュールにLoRAを適用する今回の手法が極めて有効であることを示しています。特にMoE(Mixture of Experts)モデルにおいて、微小な重み更新が推論結果に確かな変化をもたらすことが数値的にも裏付けられました。