Text Generation
Transformers
Safetensors
PEFT
English
gemma4_text
cybersecurity
cti
cwe-classification
vulnerability-analysis
security
lora
conversational
Eval Results (legacy)
Instructions to use athena129/Gemma4Defense-2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use athena129/Gemma4Defense-2B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="athena129/Gemma4Defense-2B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("athena129/Gemma4Defense-2B") model = AutoModelForCausalLM.from_pretrained("athena129/Gemma4Defense-2B") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - PEFT
How to use athena129/Gemma4Defense-2B with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use athena129/Gemma4Defense-2B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "athena129/Gemma4Defense-2B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "athena129/Gemma4Defense-2B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/athena129/Gemma4Defense-2B
- SGLang
How to use athena129/Gemma4Defense-2B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "athena129/Gemma4Defense-2B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "athena129/Gemma4Defense-2B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "athena129/Gemma4Defense-2B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "athena129/Gemma4Defense-2B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use athena129/Gemma4Defense-2B with Docker Model Runner:
docker model run hf.co/athena129/Gemma4Defense-2B
Add Hardware Requirements + Methodology sections
Browse files
README.md
CHANGED
|
@@ -95,6 +95,23 @@ The following uses are out-of-scope and are neither recommended nor intended use
|
|
| 95 |
4. **Non-security use cases** — general chat, code generation, summarization, translation, or other domains outside its specialization will produce lower-quality output than purpose-built models.
|
| 96 |
5. **Violation of laws or regulations** — including but not limited to unauthorized vulnerability scanning, illegal data access, or misuse contrary to applicable cybersecurity statutes (CFAA, GDPR, etc.).
|
| 97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
## How to Get Started with the Model
|
| 99 |
|
| 100 |
```python
|
|
@@ -138,6 +155,18 @@ The model was trained on a combined cybersecurity corpus of approximately **12,5
|
|
| 138 |
|
| 139 |
Decontamination matters here: an earlier internal version (v3) of this work showed roughly 72% test-set overlap when trained on undeduplicated CTI corpora, producing inflated CTI-RCM scores that did not generalize. The released v3.4 model trains exclusively on the 2021 cohort with overlap items removed.
|
| 140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
### Training Setup
|
| 142 |
|
| 143 |
| Hyperparameter | Value |
|
|
|
|
| 95 |
4. **Non-security use cases** — general chat, code generation, summarization, translation, or other domains outside its specialization will produce lower-quality output than purpose-built models.
|
| 96 |
5. **Violation of laws or regulations** — including but not limited to unauthorized vulnerability scanning, illegal data access, or misuse contrary to applicable cybersecurity statutes (CFAA, GDPR, etc.).
|
| 97 |
|
| 98 |
+
## Hardware Requirements
|
| 99 |
+
|
| 100 |
+
The numbers below are first-principles estimates from the bf16 weight footprint plus typical KV-cache overhead at the trained 4096-token context. They are not measured throughput numbers; for production deployment, profile against your specific traffic pattern.
|
| 101 |
+
|
| 102 |
+
| Specification | Gemma4Defense-2B | Foundation-Sec-Instruct-8B (reference) |
|
| 103 |
+
|---|---|---|
|
| 104 |
+
| Parameters (per-token effective / total weights) | 2.3 B / ~5 B (Gemma-4 Per-Layer Embeddings) | 8 B |
|
| 105 |
+
| bf16 weight file on disk | ~9.3 GB | ~16 GB |
|
| 106 |
+
| Inference VRAM, weights only (bf16) | ~9 GB | ~16 GB |
|
| 107 |
+
| Inference VRAM, weights + 4 K KV cache (bf16) | ~10–11 GB | ~17–18 GB |
|
| 108 |
+
| Single-GPU class (bf16, headroom for batch ≥ 1) | Fits on 12 GB+ consumer GPU (e.g., RTX 3060 12 GB, RTX 4070 12 GB, T4 16 GB) | Typically requires 24 GB+ (e.g., RTX 4090, A10, A100 40 GB) |
|
| 109 |
+
|
| 110 |
+
Notes:
|
| 111 |
+
- "Per-token effective" parameters reflect Gemma-4's Per-Layer Embedding architecture: ~2.3 B parameters activate per token, but the full ~5 B weight matrix must be resident in VRAM during inference. The compute cost at inference scales with the per-token effective count.
|
| 112 |
+
- Compute (FLOPs / token) is approximately proportional to the per-token effective parameter count at fixed context length, so per-token inference cost is roughly **0.29×** that of an 8 B model.
|
| 113 |
+
- Quantized variants (int8, int4) further reduce VRAM by ~½ and ~¼ respectively. The released checkpoint is bf16 only; community quantization is not validated by the authors of this release.
|
| 114 |
+
|
| 115 |
## How to Get Started with the Model
|
| 116 |
|
| 117 |
```python
|
|
|
|
| 155 |
|
| 156 |
Decontamination matters here: an earlier internal version (v3) of this work showed roughly 72% test-set overlap when trained on undeduplicated CTI corpora, producing inflated CTI-RCM scores that did not generalize. The released v3.4 model trains exclusively on the 2021 cohort with overlap items removed.
|
| 157 |
|
| 158 |
+
### Methodology
|
| 159 |
+
|
| 160 |
+
This model uses **direct supervised fine-tuning (SFT)** of an instruction-tuned base via LoRA. The training recipe was selected through a controlled-experiment series across multiple trained variants spanning two model families and several corpus compositions, with multi-trial benchmark validation locking the released hyperparameters.
|
| 161 |
+
|
| 162 |
+
Key methodological choices that informed the released recipe:
|
| 163 |
+
|
| 164 |
+
- **Direct SFT, not knowledge distillation.** Knowledge-distillation variants from a larger 20B teacher model (CyberPal-2.0-20B) were evaluated during recipe development. At the corpus sizes tested (≤ 15K supervised records), direct SFT on the curated corpus outperformed distillation on the headline benchmarks. The released model is direct SFT only.
|
| 165 |
+
- **Decontaminated training data.** An earlier internal iteration showed ~72% test-set overlap when trained on undeduplicated CTI corpora, producing inflated CTI-RCM scores that did not generalize. The released model trains exclusively on the 2021 cohort with CTI-Bench overlap items removed.
|
| 166 |
+
- **Instruction-tuned base, not pre-trained base.** Direct SFT on the IT checkpoint preserves the existing format priors (terse-answer multiple-choice convention) better than SFT on the pre-trained base; comparable runs on base checkpoints showed substantial CTI-MCQ format-binding decay (~−14 to −38 pp in the worst case) at the same corpus scale.
|
| 167 |
+
- **Multi-trial benchmarking.** All headline numbers are means of 5 independent trials with random sampling seeds at temperature 0.3; standard deviations are reported alongside.
|
| 168 |
+
- **Cross-substrate validation.** The identical training corpus and hyperparameters were independently applied to Qwen3-4B-Instruct-2507 ([CyberSecQwen-4B](https://huggingface.co/athena129/CyberSecQwen-4B)). The two models converge to within 0.9 points on CTI-RCM, providing a built-in robustness check that the result is recipe-driven rather than substrate-specific.
|
| 169 |
+
|
| 170 |
### Training Setup
|
| 171 |
|
| 172 |
| Hyperparameter | Value |
|