A fine-tuned
Google Gemma 4 E4B-it model specialized in
email fraud detection, phishing identification, and spam classification. This model analyzes raw email content and outputs structured JSON verdicts with threat analysis, risk scoring, and actionable suggestions.
1# Serve the model
2vllm serve cunxin/gemma-4-E4B-email-fraud-detector --dtype bfloat16 --max-model-len 4096
3
4# Query
5curl -X POST http://localhost:8000/v1/chat/completions \
6 -H "Content-Type: application/json" \
7 -d '{
8 "model": "cunxin/gemma-4-E4B-email-fraud-detector",
9 "messages": [
10 {"role": "system", "content": "You are an anti-fraud email analyzer. Output ONLY valid JSON."},
11 {"role": "user", "content": "Analyze the following email:\n{\"sender\": \"security@paypa1-verify.com\", \"subject\": \"Account Suspended\", \"content\": \"Dear Customer, your account has been limited. Verify your identity at http://paypa1-verify.com/login\"}"}
12 ]
13 }'
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4model = AutoModelForCausalLM.from_pretrained(
5 "cunxin/gemma-4-E4B-email-fraud-detector",
6 torch_dtype=torch.bfloat16,
7 device_map="auto",
8)
9tokenizer = AutoTokenizer.from_pretrained("cunxin/gemma-4-E4B-email-fraud-detector")
10
11messages = [
12 {"role": "system", "content": "You are an anti-fraud email analyzer. Output ONLY valid JSON."},
13 {"role": "user", "content": 'Analyze the following email:\n{"sender": "noreply@university.edu", "subject": "Grade Posted", "content": "Your final grade for CS120 has been posted to the student portal."}'},
14]
15
16inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(model.device)
17outputs = model.generate(inputs, max_new_tokens=512, temperature=0.1)
18print(tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True))
1{
2 "is_fraud": false,
3 "risk_score": 0,
4 "confidence_level": 0.95,
5 "detected_threats": [],
6 "reason": "Score: 0. Sender is on official university.edu domain. Routine grade notification with no suspicious links or credential requests.",
7 "suggestion": "This appears legitimate. Check your grades through the official student portal."
8}
Gemma 4 E4B uses Per-Layer Embeddings (PLE) with a 262K token vocabulary, giving it 8B total parameters but only 4B "effective" parameters. The model includes vision and audio encoders that are unused for this text-only task. For deployment, we recommend using the GPTQ quantized variants to reduce memory footprint.
1@misc{gemma4-email-fraud-detector,
2 title={Gemma 4 E4B Email Fraud Detector},
3 author={Ruibo Sun},
4 year={2026},
5 url={https://huggingface.co/cunxin/gemma-4-E4B-email-fraud-detector}
6}
基于
Google Gemma 4 E4B-it 微调的
邮件欺诈检测、钓鱼识别和垃圾邮件分类专用模型。输入原始邮件内容,输出结构化 JSON 分析结果,包含威胁分析、风险评分和处置建议。