1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3import torch
4
5base_model = "google/gemma-4-12b-it"
6adapter = "Sakeador/ThreatSage-12B"
7
8tokenizer = AutoTokenizer.from_pretrained(base_model)
9model = AutoModelForCausalLM.from_pretrained(
10 base_model,
11 torch_dtype=torch.bfloat16,
12 device_map="auto"
13)
14model = PeftModel.from_pretrained(model, adapter)
15
16messages = [
17 {"role": "user", "content": "Analyze this Wazuh alert and identify the MITRE ATT&CK technique."}
18]
19
20text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
21inputs = tokenizer([text], return_tensors="pt").to(model.device)
22outputs = model.generate(**inputs, max_new_tokens=512)
23print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
Apache 2.0 — same as the base model Gemma 4 12B.
Thanks to the open-source community, Google DeepMind for Gemma 4, and all the dataset creators who made this possible.