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