sohomn commited on
Commit
a32db65
·
verified ·
1 Parent(s): abcf676

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +214 -132
README.md CHANGED
@@ -1,199 +1,281 @@
1
  ---
2
  library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
10
 
 
11
 
12
  ## Model Details
13
 
14
  ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
-
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
-
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
-
28
- ### Model Sources [optional]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
- <!-- Provide the basic links for the model. -->
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
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
 
44
- [More Information Needed]
45
 
46
- ### Downstream Use [optional]
 
 
 
 
 
 
 
 
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
 
52
  ### Out-of-Scope Use
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
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
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
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
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
 
82
- [More Information Needed]
 
 
 
 
 
83
 
84
- ### Training Procedure
 
 
 
85
 
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
 
88
- #### Preprocessing [optional]
89
 
90
- [More Information Needed]
91
 
 
 
 
 
92
 
93
  #### Training Hyperparameters
94
 
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
- #### Speeds, Sizes, Times [optional]
98
 
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
 
 
 
100
 
101
- [More Information Needed]
102
 
103
  ## Evaluation
104
 
105
- <!-- This section describes the evaluation protocols and provides the results. -->
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
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
 
119
- [More Information Needed]
120
 
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
 
127
  ### Results
128
 
129
- [More Information Needed]
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
- ## Technical Specifications [optional]
 
 
 
 
154
 
155
- ### Model Architecture and Objective
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
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
 
175
- **BibTeX:**
176
 
177
- [More Information Needed]
 
 
 
178
 
179
- **APA:**
180
 
181
- [More Information Needed]
 
182
 
183
- ## Glossary [optional]
 
184
 
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
 
186
 
187
- [More Information Needed]
188
 
189
- ## More Information [optional]
 
 
 
 
 
 
 
 
 
 
 
 
190
 
191
- [More Information Needed]
192
 
193
- ## Model Card Authors [optional]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
 
195
- [More Information Needed]
196
 
197
- ## Model Card Contact
198
 
199
- [More Information Needed]
 
 
 
 
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)