Views
No views yet
phishing vs safe) on top of google/gemma-3-4b-it.google/gemma-3-4b-itphishing or safe (single-word target)1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3from peft import PeftModel
4
5base_model = "google/gemma-3-4b-it"
6adapter_repo = "briankkogi/gemma3-phishing-main-v1"
7
8tok = AutoTokenizer.from_pretrained(base_model)
9if tok.pad_token is None:
10 tok.pad_token = tok.eos_token
11
12base = AutoModelForCausalLM.from_pretrained(
13 base_model,
14 torch_dtype=torch.bfloat16,
15 device_map="auto",
16)
17model = PeftModel.from_pretrained(base, adapter_repo).eval()
18
19prompt = 'Email body: """Your account will be suspended unless you verify now."""\n\nTask: Is this phishing or safe? Reply with only one word: phishing or safe.'
20inputs = tok.apply_chat_template(
21 [{"role": "user", "content": prompt}],
22 tokenize=True,
23 add_generation_prompt=True,
24 return_dict=True,
25 return_tensors="pt",
26).to(model.device)
27
28with torch.no_grad():
29 out = model.generate(**inputs, max_new_tokens=2, do_sample=False)
30
31txt = tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True).strip().lower()
32pred = "phishing" if "phishing" in txt else "safe"
33print(pred, "| raw:", txt)google/gemma-3-4b-itmain-v1q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj0.9937180.9969040.9862170.9915320.9914430.9892970.9877860.9885410.73500.7104520.99500.99240google/gemma-3-4b-it and inherits applicable upstream usage restrictions/terms.
Please review and comply with Gemma and any dataset-specific license/policy requirements before production use.v1 (main-v1)