Text Generation
Transformers
Safetensors
PEFT
English
llama
qlora
siem
cybersecurity
log-generation
cloud-security
aws
azure
gcp
conversational
Instructions to use sohomn/siem-log-generator-llama31-8b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sohomn/siem-log-generator-llama31-8b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sohomn/siem-log-generator-llama31-8b") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("sohomn/siem-log-generator-llama31-8b", device_map="auto") - PEFT
How to use sohomn/siem-log-generator-llama31-8b with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use sohomn/siem-log-generator-llama31-8b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sohomn/siem-log-generator-llama31-8b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sohomn/siem-log-generator-llama31-8b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/sohomn/siem-log-generator-llama31-8b
- SGLang
How to use sohomn/siem-log-generator-llama31-8b 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 "sohomn/siem-log-generator-llama31-8b" \ --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": "sohomn/siem-log-generator-llama31-8b", "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 "sohomn/siem-log-generator-llama31-8b" \ --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": "sohomn/siem-log-generator-llama31-8b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use sohomn/siem-log-generator-llama31-8b with Docker Model Runner:
docker model run hf.co/sohomn/siem-log-generator-llama31-8b
File size: 10,363 Bytes
c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e 250d68e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 c212c6e a32db65 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | ---
library_name: transformers
tags:
- llama
- qlora
- peft
- siem
- cybersecurity
- log-generation
- cloud-security
- aws
- azure
- gcp
- text-generation
base_model: meta-llama/Meta-Llama-3.1-8B-Instruct
model_type: causal-lm
language:
- en
license: llama3.1
pipeline_tag: text-generation
---
# SIEM Log Generator β LLaMA 3.1-8B (Stage 0b)
Fine-tuned LLaMA 3.1-8B-Instruct model that generates realistic, structured cloud security logs (SIEM events) from structured input events. Part of a multi-cloud threat detection research pipeline (Group 24, Final Year Project).
Given a structured security event (provider, action, entity IDs, attack phase, region, etc.), the model outputs a valid provider-native JSON log β AWS CloudTrail / GuardDuty, Azure Activity Log, or GCP Cloud Logging format β with a `_pipeline_meta` field preserving edge IDs and labels for downstream graph neural network stages.
---
## Model Details
### Model Description
- **Developed for:** Final-year-grp24
- **Model type:** Causal Language Model (QLoRA fine-tune)
- **Base model:** [meta-llama/Meta-Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct)
- **Fine-tuning method:** QLoRA (4-bit NF4 quantisation + LoRA rank-16 adapters)
- **Language:** English
- **License:** [Llama 3.1 Community License](https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct/blob/main/LICENSE)
- **Repository:** [Final-year-grp24/siem-log-generator-llama31-8b](https://huggingface.co/Final-year-grp24/siem-log-generator-llama31-8b)
### Citations
```bibtex
@article{dubey2024llama,
title = {The Llama 3 Herd of Models},
author = {Dubey, Abhimanyu and others},
year = {2024},
url = {https://arxiv.org/abs/2407.21783}
}
@inproceedings{dettmers2023qlora,
title = {QLoRA: Efficient Finetuning of Quantized LLMs},
author = {Dettmers, Tim and Pagnoni, Artidoro and Farhadi, Ali and Zettlemoyer, Luke},
booktitle = {NeurIPS},
year = {2023},
url = {https://arxiv.org/abs/2305.14314}
}
@inproceedings{hu2022lora,
title = {LoRA: Low-Rank Adaptation of Large Language Models},
author = {Hu, Edward J. and others},
booktitle = {ICLR},
year = {2022},
url = {https://arxiv.org/abs/2106.09685}
}
```
---
## Uses
### Direct Use
Generate provider-native cloud security logs for research pipelines, dataset augmentation, and security simulation. Given a structured event dict, the model outputs a complete JSON log in the correct format for AWS CloudTrail, Azure Activity Log, or GCP Cloud Logging.
### Downstream Use
This model is Stage 0b in a 10-stage multi-cloud threat detection pipeline:
```
Stage 0a (Attack Simulator) β Stage 0b (this model, log renderer)
β Stage 1 (log ingestion) β Stage 2 (BGE-Large embeddings)
β Stage 3a/3b (CVE extraction + risk scoring)
β Stage 4 (identity embeddings) β Stage 5 (graph construction)
β Stage 6 (RGCN) β Stage 7 (Temporal GNN)
β Stage 8 (FT-Transformer) β Stage 9 (ensemble) β Stage 10 (explanation)
```
The `_pipeline_meta` field in every generated log preserves `edge_id`, `scenario_id`, `t`, `malicious`, and `attack_phase` labels β acting as a foreign key for all downstream stages.
### Out-of-Scope Use
- **Not for production security monitoring** β logs are synthetic and generated for research purposes only
- **Not a threat detector** β this model renders logs, it does not classify them
- **Not suitable for generating real credentials, IPs, or account IDs** β all identifiers are synthetic
---
## Training Details
### Training Data
Derived from Stage 0a of the pipeline β an attack chain simulator generating 1,000 multi-cloud scenarios across 4 attack templates:
| Attack Template | Description |
|----------------|-------------|
| Privilege Escalation | IAM role abuse across AWS/Azure/GCP |
| Lateral Movement | VM-to-VM propagation within cloud VPCs |
| Cross-Cloud Identity Pivot | Credential exfiltration across cloud boundaries |
| CVE Exploitation | Known CVE exploitation against cloud-hosted VMs |
**Source data:** 632,108 structured events across 1,000 scenarios, T=20 timesteps
**Class balance:** ~65% benign / ~35% malicious
**Providers covered:** AWS, Azure, GCP, AWS_GCP (cross-cloud), GCP_Azure (cross-cloud)
**Actions covered:** `ASSUMES_ROLE`, `ACCESS`, `CONNECTS_TO`, `EXPLOITS`, `CROSS_CLOUD_ACCESS`, `VM_LIST`, `RESTART_VM`, `STOP_VM`
Training pairs were built by rendering each structured event into a LLaMA chat template (system prompt + structured event β provider-native JSON log). The dataset was capped at 2,000 pairs for the 2k sample run.
### Training Procedure
#### Preprocessing
- Each structured event is converted to a LLaMA 3.1 chat-format prompt
- System prompt instructs the model to output only a valid JSON log with no explanation
- Sequences truncated to `MAX_SEQ_LEN=768` tokens
- Validation split: last 10% of scenarios held out
#### Training Hyperparameters
| Hyperparameter | Value |
|---------------|-------|
| Base model | meta-llama/Meta-Llama-3.1-8B-Instruct |
| Quantisation | 4-bit NF4 (double quantisation enabled) |
| LoRA rank | 16 |
| LoRA alpha | 32 |
| LoRA dropout | 0.05 |
| LoRA target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Training regime | fp16 mixed precision (T4 Turing β no bfloat16) |
| Optimiser | paged_adamw_8bit |
| Learning rate | 2e-4 |
| LR scheduler | cosine |
| Epochs | 1 |
| Per-device batch size | 4 |
| Gradient accumulation | 4 (effective batch = 16) |
| Warmup steps | 100 |
| Max sequence length | 768 |
| NEFTune noise alpha | 5 |
| Seed | 42 |
#### Hardware
- **Platform:** Kaggle (Notebook)
- **GPU:** NVIDIA Tesla T4 x1
- **VRAM:** 16 GB
- **Fine-tuning method:** QLoRA β full 8B model fine-tuned in 4-bit, only LoRA adapter weights updated (~0.7% of parameters trainable)
---
## Evaluation
### Testing Data
Held-out records from the last 10% of scenario IDs present in the training set, validated post-training.
### Metrics
| Metric | Description |
|--------|-------------|
| JSON Validity % | % of generated outputs that parse as valid JSON |
| Schema Compliance % | % of outputs containing all required provider-specific fields |
| Edge ID Preservation % | % of outputs where `_pipeline_meta.edge_id` matches the source event |
### Results
> Results below are from the 2k sample run (1 epoch, 2000 training pairs). Full-scale results pending.
| Metric | Threshold | Result |
|--------|-----------|--------|
| JSON Validity % | β₯ 90% | pending full run |
| Schema Compliance % | β₯ 85% | pending full run |
| Edge ID Preservation % | β₯ 90% | pending full run |
---
## Technical Specifications
### Model Architecture
- **Base:** LLaMA 3.1-8B-Instruct (decoder-only transformer, 32 layers, 4096 hidden dim, 32 attention heads)
- **Adapter:** LoRA rank-16 injected into all 7 projection matrices across all 32 layers
- **Quantisation:** 4-bit NF4 via bitsandbytes β base weights frozen at 4-bit, LoRA adapters trained in fp16
- **Trainable parameters:** ~83M / 8B total (~1.0%)
### Log Schema Coverage
#### AWS (CloudTrail / GuardDuty)
Required fields: `eventSource`, `eventName`, `awsRegion`, `userIdentity`, `sourceIPAddress`, `readOnly`, `resources`, `managementEvent`, `sessionContext`, `_pipeline_meta`
#### Azure (Activity Log)
Required fields: `time`, `operationName`, `correlationId`, `identity`, `properties`, `_pipeline_meta`
#### GCP (Cloud Logging)
Required fields: `protoPayload`, `resource`, `severity`, `timestamp`, `logName`, `_pipeline_meta`
### Pipeline Meta Field
Every generated log contains:
```json
"_pipeline_meta": {
"edge_id": "user_001__ASSUMES_ROLE__role_admin",
"scenario_id": "scenario_00042",
"t": 7,
"malicious": 1,
"attack_phase": "privilege_escalation",
"provider": "AWS",
"original_provider": "AWS",
"is_cross_cloud": false
}
```
---
## How to Get Started
```python
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
import torch, json
base_id = "meta-llama/Meta-Llama-3.1-8B-Instruct"
adapter_id = "Final-year-grp24/siem-log-generator-llama31-8b"
bnb = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=True,
)
tokenizer = AutoTokenizer.from_pretrained(base_id)
base = AutoModelForCausalLM.from_pretrained(base_id, quantization_config=bnb,
device_map="auto", torch_dtype=torch.float16)
model = PeftModel.from_pretrained(base, adapter_id)
event = {
"provider": "AWS", "action": "ASSUMES_ROLE",
"entity_id": "user_042", "target_id": "role_admin",
"region": "us-east-1", "cloud_account": "acc_aws_123456",
"source_ip": "10.0.1.42", "status": "Success",
"malicious": 1, "attack_phase": "privilege_escalation",
"edge_id": "user_042__ASSUMES_ROLE__role_admin",
"scenario_id": "scenario_00001", "t": 5,
}
system = ("You are a cloud security log renderer for a research pipeline. "
"Given a structured security event, generate ONLY the corresponding "
"cloud provider log as a valid JSON object. Output nothing except the JSON. "
"No explanation. No markdown fences. "
"The JSON must include a \"_pipeline_meta\" field preserving edge_id and labels.")
messages = [{"role":"system","content":system},
{"role":"user","content":json.dumps(event)}]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
out = model.generate(**inputs, max_new_tokens=500, do_sample=False)
response = tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
log = json.loads(response[response.find("{"):response.rfind("}")+1])
print(json.dumps(log, indent=2))
```
---
## Environmental Impact
- **Hardware:** NVIDIA Tesla T4 (16GB VRAM)
- **Cloud provider:** Google (Kaggle)
- **Training duration:** ~1β2 hours (2k sample), ~9β11 hours (full 480-scenario run)
- **Carbon estimation:** [ML Impact Calculator](https://mlco2.github.io/impact#compute) |