CyberSecQwen-4B:防衛型サイバーセキュリティには小型・特化型・ローカル実行モデルがなぜ必要か
Hugging Face Blog は、AMD ハッカソンで開発された「CyberSecQwen-4B」を紹介し、機密データ保護とコスト削減のため、大規模モデルに依存せず小規模・専門化されたローカル実行型 AI モデルが防御サイバーセキュリティの未来であると提言している。
キーポイント
機密データの内部保持の重要性
SOC アナリストやマルウェア解析者が扱う漏洩クレデンシャルや攻撃パケットは、外部 API に送信するとデータ自体が漏洩リスクとなるため、ローカル環境での実行が必須である。
運用コストの削減効果
中規模 SOC が毎日処理する数千件の低信頼度アラートに対して、API 呼び出しごとのコストが蓄積され予算を圧迫するため、ローカル実行モデルによる自動化が経済的である。
特殊な環境への適応性
完全なエアギャップや部分的に接続された環境でも動作可能であり、大規模モデルが拒否する「 messy edge cases(厄介なエッジケース)」や攻撃者グレードのペイロードに対処できる。
AMD ハッカソンによる技術実証
本モデルは AMD Developer Hackathon で開発され、単一の AMD Instinct MI300X GPU でトレーニングされており、Apache 2.0 ライセンスで公開されている。
CyberSecQwen-4B の性能と効率性
パラメータ数が半分(4B)でありながら、CTI-MCQ ベンチマークで +8.7 ポイント向上し、CTI-RCM 精度もベースモデルの 97.3% を維持しています。
AMD MI300X による単一 GPU 完結型パイプライン
192GB HBM3 を備えた AMD Instinct MI300X 上で、量子化やモデル分割を一切行わずにトレーニングから評価までを完結させました。
データ汚染の排除と評価の信頼性
学習データからCTI-Benchの評価セットとの重複を事前に除去しており、ベンチマーク結果は真の外観分布(out-of-distribution)保持であり、汚染されていないことを保証している。
影響分析・編集コメントを表示
影響分析
この記事は、サイバーセキュリティ分野における AI 導入のパラダイムシフトを示唆しており、従来の「大規模モデルへの依存」から「小規模・専門化・ローカル実行」へ重心が移りつつあることを示しています。特に機密性の高い環境やコスト敏感な運用において、オープンソースの軽量モデルが実戦レベルで有効であることを証明した点で業界に大きな影響を与えるでしょう。
編集コメント
セキュリティ運用の現場では、AI の導入が新たな脆弱性(データ漏洩)を生むリスクを無視できません。この記事は、そのジレンマを解決する具体的なアーキテクチャとして「小型・専門化・ローカル実行」モデルの有効性を説得力を持って提示しています。
AMD デベロッパーハッカソン向けに構築 · 単一の AMD Instinct MI300X でトレーニング済み · Apache 2.0 ライセンス
なぜこれが重要なのか
フロンティアモデルは非常に多くの分野で卓越した能力を発揮します。しかし、それらは呼び出しコストが高く、すべてのプロンプトを他者のデータセンターに送信する必要があり、実際の防御者がインシデント報告書やログ内で発見される攻撃者グレードのペイロード、脆弱性情報開示草案といった「 messy なエッジケース」に対して拒否反応を示すように明示的にトレーニングされています。
防御的なサイバーセキュリティにおいて、これらのトレードオフが許容される場所はありません。
- 機密性の高い証拠は内部に留める必要があります。漏洩した認証情報のダンプをトリアージする SOC アナリスト、マルウェアサンプルを解析するリバースエンジニアリング担当者、CVE の報告書を作成する脆弱性情報研究者 — これらの誰一人として、そのコンテンツをホストされた API に貼り付けるべきではありません。データ自体が侵害の経路となり得ます。
- 1 回ごとの API コストは累積します。中規模の SOC では、毎日数千件の低信頼度のアラートが処理されます。「この CVE を説明して」「ここに適用される CWE は何か」といった問い合わせに対するホスト型 API のコストは、防御自動化を予算の問題へと変えてしまいます。
- 重要インフラ、医療、政府業務においては、エアギャップ(物理的に隔離)された環境や部分的に接続された環境が例外ではなくルールです。もしツールがラップトップや単一のオンプレミス GPU で実行できないなら、そこには導入されません。
- 敵対者はより自動化されています。ランサムウェア組織は LLM を使用して 30 か国語のフィッシングメールを起草し、バグ報奨金プログラムの自動化ツールはアジェンシーツールを連鎖させて、人間がレビューするよりも速くファジング、選別、そしてエクスプロイトを行います。同じ速度で防御するには、防衛側が所有し実行できるモデルが必要です。
つまり、「ローカル」であることは重要ですが、「ローカル」であるだけでは不十分です。
なぜ小型の専門モデルなのか、単なる小型モデルではないのか
4 つの GPU でローカルに動作する 70B の汎用モデルは「ローカル」ではありますが、*デプロイ可能*ではありません。1 つのコンシューマー向け GPU でローカルに動作する 4B の汎用モデルはデプロイ可能ですが、実際に必要なタスクにおいては 8B の専門モデルには勝てません。
CyberSecQwen-4B の背景にある賭けは、CWE クラス分類、CVE から CWE へのマッピング、構造化された CTI(脅威インテリジェンス)の Q&A など、狭く明確に評価されたサイバー脅威インテリジェンスタスクにおいては、慎重にファインチューニングされた 4B モデルが、12 GB のコンシューマー向けカードに収まりながら、8B の専門モデルと同等かそれ以上の性能を発揮できるという点にあります。
私たちはこれを、入手可能な最も強力なパブリックベースラインであるCisco の Foundation-Sec-Instruct-8Bと比較してテストしました。これは、CTI-Bench 上で同社が公開したプロトコルに基づいて評価されたものです。
Metric (CTI-Bench, n=5, temp 0.3)
CyberSecQwen-4B
Foundation-Sec-Instruct-8B
Δ
CTI-MCQ (2,500 items)
0.5868 ± 0.0029
0.4996
+8.7 pp
CTI-RCM (1,000 CVE→CWE items)
0.6664 ± 0.0023
0.6850
−1.9 pp
Parameters
4 B
8 B
半分サイズ
CyberSecQwen-4B は、Foundation-Sec-Instruct-8B の CTI-RCM 精度の97.3% を維持しつつ、CTI-MCQ スコアでは+8.7 ポイント上回っています。これはパラメータ数が半分であるにもかかわらず達成された成果です。防御側が何を展開するかを選ぶ際、この数字こそが唯一重要となるべきものです。
5 分間のウォークスルー
以下の 5 分間の動画では、トレーニング手法、AMD MI300X のワークフロー、およびベンチマーク結果をより視覚的な形式で解説しています。もし詳細をすべて読み込みたい場合は、本稿の残りの部分で同じ内容を、正確な設定値とともに記述しています。
なぜ AMD MI300X か
トレーニングからアダプタのマージ、評価に至るまでの全パイプラインは、AMD Developer Cloud 上の単一の AMD Instinct MI300X 192 GB インスタンス上でエンドツーエンドで実行されます。192 GB の HBM3 と ROCm 7 の vLLM スタックの組み合わせにより、量子化トリックや勾配チェックポイント、あるいはモデルを複数デバイスに分割するといった工夫は一切不要でした。bf16 フル精度、FlashAttention-2 の順伝播・逆伝播、バッチサイズ 4、シーケンス長 4096 — これらすべてが単一の GPU で完結しています。
Component
Version
Hardware
AMD Instinct MI300X 192 GB · gfx942
ROCm
7.0
Docker
vllm/vllm-openai-rocm:latest
PyTorch
2.6.0 (ROCm)
flash-attn
2.8.3
vLLM
0.10.1
transformers / peft / trl
トレーニング時の最新バージョン
train.sh のレシピはハードウェアに依存しません。他の 40 GB 以上のデータセンター向け GPU で実行するには、AMD 固有の環境変数を削除(他では何もしない処理です)し、適切なホイールから flash-attn を再インストールしてください。互換性をテストするために、異なるスタックで姉妹モデルをトレーニングしました—詳細は後述します。
トレーニングデータ
リリース用に Apache-2.0 クリーンな 2 つのコーパスがあります:
- MITRE / NVD の公開記録から取得した 2021 年版 CVE → CWE マッピング。重要なのは、CTI-Bench の評価セットとの重複部分をトレーニング前にすべて重複排除したことです。そのため、上記のベンチマーク数値は正直な分布外ホールドアウトであり、データ汚染ではありません。
- 重複排除された CVE 記述に基づいた合成型防御アナリスト向け Q&A。より強力な教師モデルで生成され、再配布用に Apache-2.0 ライセンスが付与されています。
ベースモデルは Qwen3-4B-Instruct-2507 です。これはトレーニング時点で利用可能だった 4B クラスの IT モデルの中で最高性能を記録した、Apache-2.0 ライセンスの指示調整済み 4B モデルです。意図的にベースではなく IT チェックポイントに対してファインチューニングを行いました—これにより、IT パスで既に確立された簡潔な回答形式や多肢選択形式の事前知識が保持され、IT→SFT の順序で崩壊させる場合に失われていたものが守られます。
ここには注目に値する測定可能な効果があります:
モデル
CTI-RCM
CTI-MCQ
Qwen3-4B-Instruct-2507 (生 IT)
0.519
0.473
CyberSecQwen-4B (本ファインチューン)
0.6664
0.5868
IT ベースは、基盤となる事前学習済みベースと比較して MCQ(多肢選択問題)の精度を大幅に低下させています。これは Cisco が Foundation-Sec-Instruct と Foundation-Sec の間で報告している「指示微調整が MCQ 性能を崩壊させる」という全く同じパターンです。私たちのファインチューニングは、両方のベンチマークにおいて IT(指示微調整)開始点を回復し、さらに上回ります。これにより、IT が侵食したフォーマット結合性が復元されつつ、ドメイン特有の性能向上も達成されています。
レシピ
LoRA r = 64
LoRA alpha = 64 # alpha/r = 1.0
LoRA dropout = 0.05
LR = 5e-5 # コサインスケジューリング、ウォームアップ比率 0.03
Epochs = 10
Precision = bf16 (半精度浮動小数点)
Attention = FlashAttention-2 (順伝播 + 逆伝播)
Max seq len = 4096
Batch = 4 (勾配累積なし)
Optimizer = paged_adamw_8bit
FlashAttention-2 は Qwen で有効化されています。これは、そのヘッド次元(128)が MI300X (gfx942) の共有メモリ予算にうまく収まるためです。この構成におけるステップ時間は約 ~7.85 秒/ステップ に落ち着きます。これは、同じレシピをコンパニオンモデルである Gemma-4-E2B ベースで実行した場合の約 1.6 倍速 です。Gemma-4-E2B はグローバルアテンション層(ヘッド次元=512)において FlashAttention-2 を使用できず、LDS(ローカル共有メモリ)予算を超えてしまうため sdpa にフォールバックせざるを得ないからです。
コンパニオンモデル:同じレシピ、異なる基盤
結果がレシピに起因するものか、基盤固有のものかを検証するため、姉妹モデル — Gemma4Defense-2B — をトレーニングしました。これは*全く同じ*トレーニングコーパスとハイパーパラメータを使用し、ベースモデルのみを Gemma-4-E2B-it に置き換えたものです。
モデル
CTI-RCM (5 回試行の平均 ± 標準偏差)
CTI-MCQ
CyberSecQwen-4B (Qwen ベース)
0.6664 ± 0.0023
0.5868 ± 0.0029
Gemma4Defense-2B (Gemma ベース)
0.6754 ± 0.0035
0.6042 ± 0.0090
この 2 つのモデルは、CTI-RCM(Cyber Threat Intelligence - Risk Control Metric)において0.9 ポイント以内で収束します。レシピは引き継がれるものであり、重要なのはどの IT チェックポイント(IT checkpoint)をファインチューニングするかではなく、どのように行うかです。CyberSecQwen-4B は Apache 2.0 ライセンスであり、Gemma の利用規約が問題となる場合に適切な選択となります;一方、Gemma4Defense-2B は、4B よりも 2B がデプロイメント予算に収まりやすい場合に最適な選択肢です。
課題と解決策
AMD ROCm プロジェクトで戦争の物語(war-stories)セクションなしに船出するものはありません。 ours の簡略版を以下に示します:
Issue
Fix
FA2 が head_dim=512 で Gemma-4 上で失敗する
グローバル・アテンション層については sdpa にフォールバックします。ローカル・アテンション層は引き続き FA2 を使用します。同じレシピの場合、Qwen と比較して約 1.6 倍低速です。
AITER カーネルが CyberPal-2.0-20B のサービングと競合する
その特定の評価に対して VLLM_ROCM_USE_AITER=0 を設定します。AMD 環境変数は ROCm 外では無効なため、レシピ内に残されます。
bitsandbytes は ROCm で公式にサポートされていない
4-/8 ビットはそもそも必要ありませんでした——192 GB のメモリ余裕があれば十分です。paged_adamw_8bit を使用してください(bnb のオプティマイザ専用パスも機能します)。
評価用の vLLM ROCm + チャットテンプレート
TRITON_ATTN バックエンドを使用し、IT ベースのテンプレートが上書きされないよう、マージ済みモデルディレクトリから chat_template.jinja を明示的に渡してください。
デモ用の HF-Spaces ZeroGPU クォータについて
匿名の訪問者は、IP アドレスごとに 1 日あたり最大 2 分の制限に達します。このデモスペース (cybersecqwen-chat) は HF OAuth のクライアントサイドを使用しているため、各訪問者の呼び出しはそれぞれが持つ *自身の* クォータに対して課金されます(無料プランでは 1 日あたり最大 3.5 分、Pro プランでは 25 分)。
実際に試してみましょう
ライブデモ(HF でサインインして無料クォータを取得):
👉 https://huggingface.co/spaces/lablab-ai-amd-developer-hackathon/cybersecqwen-chat
モデル:
👉 https://huggingface.co/lablab-ai-amd-developer-hackathon/CyberSecQwen-4B
推論は 3 行で(12 GB 以上の GPU を使用):
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "lablab-ai-amd-developer-hackathon/CyberSecQwen-4B"
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")messages = [
{"role": "system", "content": "あなたは防御的なサイバーセキュリティアシスタントです。まず標準的な CWE-ID を回答し、その後 1〜3 文の根拠を記述してください。"},
{"role": "user", "content": "ユーザー制御入力に File() パスへの連結が含まれる Java ウェブアプリにおけるパストラバーサル攻撃です。これはどの CWE に該当しますか?"}
]
prompt = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
out = model.generate(**tok(prompt, return_tensors="pt").to(model.device), max_new_tokens=256, temperature=0.3)
print(tok.decode(out[0], skip_special_tokens=True))
高スループットなサービス提供においては、公式の vllm/vllm-openai-roco イメージを使用することで、AMD MI300X 上で vLLM をそのまま利用可能です。正確なサービスコマンドと固定された設定については、GitHub リポジトリ を参照してください。
意図的な用途
CyberSecQwen-4B は、以下の分野で活動するセキュリティ実務家向けに構築されています:
- CWE クラス分類 — 脆弱性情報(CVE やアドバイザリ)を MITRE CWE カテゴリにマッピングすること
- CTI Q&A — セキュリティ概念、攻撃手法、対策に関する構造化された質問への回答
- 防御的トリアージ支援 — CVE のトリアージ、パッチの優先順位付け、脅威アクターの行動文書化を行う人間のアナリストを支援すること
必ず JSON 形式で返してください。translation フィールドのみ。他のフィールド (technical_terms 等) は一切追加しないこと — 余計なフィールドを書こうとして本文翻訳がトークン上限で打ち切られる事故を防ぐため:
{"translation": "翻訳全文"}
明示的に避けるべき用途は: エクスプロイトコードの生成や、武器化された PoC の作成、資格のある人間のレビューなしでのセキュリティ判断の自動実行、法的・医療的・規制対象のアドバイスが必要な文脈、あるいはサイバーセキュリティ分野以外の一般的なチャットやコード生成です。このレシピは広範な用途ではなく、特定の用途に特化して構築されました。
次のステップ
優先順位のおおよその順序で、以下の方向性への拡張を検討しています:
- ラップトップクラスでの展開を可能にする 1B バリアント。Qwen2.5-1.5B または Llama-3.2-1B をベースモデルとし、同じレシピを用いて、CTI-RCM で少なくとも 0.55 の達成率(4B モデルとの差が 6 ポイント以内)を目標とします。
- 量子化された GGUF リリース(Q4_K_M, Q5_K_M)により、スマートフォンやエッジボックスでのモデル実行を可能にします。Q4_K_M では約 2.5 GB のメモリで動作するため、ARM ラップトップのメモリ容量でも十分に収まります。
- 新しい CVE から CWE へのマッピングが公開されるたびに継続的な評価を行います。2021 年コホートは意図的に分布の上限として設定されましたが、今後のバージョンでは NVD(National Vulnerability Database)の成長を追跡します。
- 敵対的例に対する耐性。専門モデルの性能は最悪ケースに依存するため、CVE 記述を入力とする攻撃で一般的なプロンプトインジェクションパターンに対するハードニング(強化)パスを公開したいと考えています。
これらのいずれかがあなたのチームの課題解決に役立つ場合は、GitHub リポジトリにイシューを開いてください — これが優先順位を上げるための最速の方法です。
結び
フロンティアモデルの議論は2年間、規模についてのものでした。しかし、防御的なサイバーセキュリティの議論は、実際に必要な場所に何が入るべきかという点にあるべきです。8B モデルと同等の性能を持ちながらサイズが半分、研究者が購入可能なカード上で動作し、機密証拠をオンプレミス外に送信しない 4B の専門モデル——これは設計空間における有用な一角であり、AMD MI300X + ROCm 7(ROCm 7)+ Hugging Face のトレーニングスタックにより、単一のトレーニングランでこの一角を占めることが可能になりました。
デモを試したり、モデルカードを読んだり、課題を提出してください。もしこのレシピがまだ試していない何かに移植されるなら、それが最も興味深い次のデータポイントとなるでしょう。
— *athena129 · AMD Developer Hackathon への提出
原文を表示
Built for the AMD Developer Hackathon · Trained on a single AMD Instinct MI300X · Apache 2.0
Why this matters
Frontier models are very good at very many things. They are also expensive to call, ship every prompt off to someone else's datacenter, and are explicitly trained to refuse the messy edge cases a real defender lives in incident write-ups, attacker-grade payloads found in your own logs, vulnerability disclosure drafts.
Defensive cybersecurity is not a place where any of those tradeoffs are acceptable.
- Sensitive evidence stays internal. A SOC analyst triaging a leaked credential dump, a malware reverse-engineer dissecting a sample, a vulnerability researcher writing up a CVE — none of them should be pasting that content into a hosted API. The data itself can be the breach.
- Per-call API cost compounds. A mid-size SOC processes thousands of low-confidence alerts per day. Hosted-API costs for "explain this CVE" or "what CWE applies here" turn defensive automation into a budget question.
- Air-gapped and partially-connected environments are the rule, not the exception in critical infrastructure, healthcare, and government work. If your tooling can't run on a laptop or a single on-prem GPU, it doesn't ship there.
- Adversaries are getting more automated. Ransomware gangs use LLMs to draft phishing in 30 languages; bug-bounty automators chain agentic tools to fuzz, triage and exploit faster than humans can review. Defense at the same speed needs models defenders own and can run.
So: local matters. But "local" alone isn't enough.
Why a small specialized model, not just a small model
A 70B generalist running locally on four GPUs is "local" but it isn't *deployable*. A 4B generalist running locally on a single consumer GPU is deployable but it doesn't beat the 8B specialist on the work you actually need it to do.
The bet behind CyberSecQwen-4B is that for narrow, well-evaluated cyber threat intelligence tasks — CWE classification, CVE-to-CWE mapping, structured CTI Q&A — a careful 4B fine-tune can match or beat an 8B specialist while fitting on a 12 GB consumer card.
We tested this against the strongest public baseline we could find: Cisco's Foundation-Sec-Instruct-8B, evaluated under their own published protocol on CTI-Bench.
Metric (CTI-Bench, n=5, temp 0.3)
CyberSecQwen-4B
Foundation-Sec-Instruct-8B
Δ
CTI-MCQ (2,500 items)
0.5868 ± 0.0029
0.4996
+8.7 pp
CTI-RCM (1,000 CVE→CWE items)
0.6664 ± 0.0023
0.6850
−1.9 pp
Parameters
4 B
8 B
half the size
CyberSecQwen-4B retains 97.3 % of Foundation-Sec-Instruct-8B's CTI-RCM accuracy while exceeding its CTI-MCQ score by +8.7 points, at half the parameter count. That's the only number that should matter to a defender choosing what to deploy.
A 5-minute walkthrough
The 5-minute video below walks through the training methodology, the AMD MI300X workflow, and the benchmark results in a more visual format. If you'd rather read everything in detail, the rest of the post covers the same ground with the exact configs.
Why AMD MI300X
The whole pipeline — training, adapter merging, evaluation — runs end-to-end on a single AMD Instinct MI300X 192 GB instance via the AMD Developer Cloud. The combination of 192 GB HBM3 and ROCm 7's vLLM stack means we never had to think about quantization tricks, gradient checkpointing, or splitting the model across devices. Full bf16, FlashAttention-2 forward+backward, batch size of 4, sequence length 4096 — all on a single GPU.
Component
Version
Hardware
AMD Instinct MI300X 192 GB · gfx942
ROCm
7.0
Docker
vllm/vllm-openai-rocm:latest
PyTorch
2.6.0 (ROCm)
flash-attn
2.8.3
vLLM
0.10.1
transformers / peft / trl
latest at training time
The recipe in train.sh is hardware-agnostic. To run on other 40 GB+ datacenter GPUs, drop the AMD-specific environment variables (they're no-ops elsewhere) and reinstall flash-attn from the appropriate wheel. We tested portability by training a sister model on a different stack — more on that below.
The training data
Two corpora, both Apache-2.0-clean to release:
- 2021 CVE → CWE mappings sourced from MITRE / NVD public records. Critically, all overlap with CTI-Bench's evaluation set was deduplicated before training, so the benchmark numbers above are honest out-of-distribution holdouts and not contamination.
- Synthetic defensive-analyst Q&A grounded in the deduplicated CVE descriptions. Generated with a stronger teacher and Apache-2.0-licensed for redistribution.
The base model is Qwen3-4B-Instruct-2507, an Apache-2.0 instruction-tuned 4B that was the highest-performing 4B-class IT model available at training time. We deliberately fine-tune on the IT checkpoint (not the base) — it preserves the terse-answer multiple-choice format priors the IT pass had already established, which an IT-then-SFT collapse would have erased.
There's a measurable effect here worth flagging:
Model
CTI-RCM
CTI-MCQ
Qwen3-4B-Instruct-2507 (raw IT)
0.519
0.473
CyberSecQwen-4B (this fine-tune)
0.6664
0.5868
The IT base drops MCQ accuracy substantially compared to the underlying pre-trained base — exactly the same "instruction-tuning collapses MCQ" pattern Cisco reports for their Foundation-Sec-Instruct vs Foundation-Sec base. Our fine-tune recovers AND exceeds the IT starting point on both benchmarks, restoring the format binding that IT eroded while delivering domain lift.
The recipe
LoRA r = 64
LoRA alpha = 64 # alpha/r = 1.0
LoRA dropout = 0.05
LR = 5e-5 # cosine, warmup ratio 0.03
Epochs = 10
Precision = bf16
Attention = FlashAttention-2 (forward + backward)
Max seq len = 4096
Batch = 4 (no accumulation)
Optimizer = paged_adamw_8bit
FlashAttention-2 is on for Qwen because its head dimension (128) fits well within the MI300X (gfx942) shared-memory budget. Step time settles around ~7.85 s/step at this config — about 1.6× faster than the same recipe on the companion Gemma-4-E2B base model, which can't use FA2 on its global-attention layers (head_dim=512 exceeds the LDS budget) and falls back to sdpa.
Companion model: same recipe, different substrate
To check whether the result is recipe-driven or substrate-specific, we trained a sister model — Gemma4Defense-2B — with the *exact same* training corpus and hyperparameters, only swapping the base model to Gemma-4-E2B-it.
Model
CTI-RCM (5-trial mean ± std)
CTI-MCQ
CyberSecQwen-4B (Qwen base)
0.6664 ± 0.0023
0.5868 ± 0.0029
Gemma4Defense-2B (Gemma base)
0.6754 ± 0.0035
0.6042 ± 0.0090
The two models converge within 0.9 points on CTI-RCM. The recipe travels — it's about how you fine-tune the IT checkpoint, not which family. CyberSecQwen-4B is Apache 2.0 and is the right pick when Gemma's terms-of-use are a problem; Gemma4Defense-2B is the right pick when 2B fits the deployment budget more comfortably than 4B.
Challenges and fixes
No AMD ROCm project ships without a war-stories section. Here's the abbreviated version of ours:
Issue
Fix
FA2 fails on Gemma-4 with head_dim=512
Falls back to sdpa for global-attention layers. Local-attention layers still use FA2. ~1.6× slower vs Qwen at the same recipe.
AITER kernels conflict with CyberPal-2.0-20B serving
Set VLLM_ROCM_USE_AITER=0 for that specific eval. AMD env var is a no-op outside ROCm so it stays in the recipe.
bitsandbytes is not officially supported on ROCm
We didn't need 4-/8-bit anyway — 192 GB is enough headroom. Use paged_adamw_8bit (bnb's optimizer-only path works).
vLLM ROCm + chat template for evaluation
Use TRITON_ATTN backend; pass chat_template.jinja from the merged model dir explicitly to avoid the IT base's template overriding.
HF-Spaces ZeroGPU quota for the demo
Anonymous visitors hit a 2 min/day per-IP cap. The demo Space (cybersecqwen-chat) uses HF OAuth client-side so each visitor's calls bill against their *own* quota (free 3.5 min/day, Pro 25 min/day).
Try it yourself
Live demo (sign in with HF for free quota):
👉 https://huggingface.co/spaces/lablab-ai-amd-developer-hackathon/cybersecqwen-chat
Model:
👉 https://huggingface.co/lablab-ai-amd-developer-hackathon/CyberSecQwen-4B
Inference in three lines (any 12 GB+ GPU):
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "lablab-ai-amd-developer-hackathon/CyberSecQwen-4B"
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
messages = [
{"role": "system", "content": "You are a defensive cybersecurity assistant. Answer with the canonical CWE-ID first, then 1-3 sentences of justification."},
{"role": "user", "content": "Path traversal in a Java web app where User-controlled input concatenates into a File() path. What's the CWE?"},
]
prompt = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
out = model.generate(**tok(prompt, return_tensors="pt").to(model.device), max_new_tokens=256, temperature=0.3)
print(tok.decode(out[0], skip_special_tokens=True))
For high-throughput serving, vLLM works out of the box on AMD MI300X via the official vllm/vllm-openai-rocm image. See the GitHub repo for the exact serving command and the pinned config.
Intended use
CyberSecQwen-4B is built for security practitioners working on:
- CWE classification — mapping vulnerability descriptions (CVEs, advisories) to MITRE CWE categories
- CTI Q&A — answering structured questions about cybersecurity concepts, attacks, controls
- Defensive triage assistance — supporting human analysts who triage CVEs, prioritize patches, document threat-actor behavior
It is explicitly not for: generating exploit code or weaponized PoCs, auto-executing security decisions without qualified human review, legal/medical/regulated-advice contexts, or general chat / code generation outside cybersecurity. The recipe was built for narrow utility, not breadth.
What's next
A few directions we want to extend, roughly in priority order:
- A 1B variant for laptop-class deployment. Qwen2.5-1.5B or Llama-3.2-1B as base, same recipe, target ≥0.55 CTI-RCM (within 6 pp of the 4B).
- Quantized GGUF release (Q4_K_M, Q5_K_M) so the model runs on phones / edge boxes. ~2.5 GB at Q4_K_M is well within ARM laptop memory.
- Continual evaluation as new CVE-to-CWE mappings get published. The 2021 cohort was a deliberate distribution-cap; future versions will track NVD's growth.
- Adversarial-example resilience. A specialist model is only as good as its worst case. We want to publish a hardening pass against prompt-injection patterns common in CVE-description-as-input attacks.
If any of those would unblock your team, open an issue on the GitHub repo — that's the fastest way to move them up the queue.
Closing
The frontier-model conversation has been about scale for two years. The defensive-cyber conversation should be about what fits where you actually need it. A 4B specialist that matches an 8B at half the size, runs on a card a researcher can afford, and never sends sensitive evidence off-prem — that's a useful corner of the design space, and AMD MI300X + ROCm 7 + Hugging Face's training stack made it possible to occupy that corner in a single training run.
Try the demo, read the model card, file issues. If the recipe ports to something we haven't tried yet, that's the most interesting next data point.
— *athena129 · AMD Developer Hackathon submission*
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み