MaxwellMensah/fraud_model_v7
๐ก๏ธ Llama 3.2 Fraud Analysis Reasoning Engine (v7)
This repository contains full 16-bit merged weights and 8-bit (Q8_0) quantized GGUF binaries for a fine-tuned Llama-3.2-1B-Instruct model trained on synthetic transaction fraud detection scenarios. The model enforces a strict 4-step Chain-of-Thought (CoT) reasoning framework to audit payment anomalies, evaluate behavioral risks, and issue automated fraud decisions.
Fine-tuned using Unsloth with 4-bit LoRA Supervised Fine-Tuning (SFT).
๐ Performance & Evaluation Benchmarks
Evaluated on an unseen 600-sample validation dataset (val_600.jsonl) comparing the un-tuned base model against fraud-model-v7. Semantic similarity is calculated against target responses using nomic-embed-text embeddings:
๐ก Model Capabilities & Output Schema
The model accepts structured transaction parameters (User ID, Amount, Location, IP/Network, Device, Time) and outputs structured analysis across four distinct reasoning steps:
Step 1 - Context: Summarizes user ID, location, timing, and transfer amount.
Step 2 - Anomaly Detection: Identifies flagged IPs (VPN/Proxy), novel devices, location jumps, or off-peak timing.
Step 3 - Risk Assessment: Evaluates threat velocity, account takeover indicators, and behavioral anomalies.
Step 4 - Decision: Emits final status: LOW RISK (Approved), MEDIUM RISK (Review), or HIGH RISK (Blocked).
Example Prompt & Output
User Query:
U-1193821 attempting rapid successive 4.99 USD payments (x6). IP is Proxy/Relay. Singapore, 03:45 AM. Mobile (new) used.
Model Output:
Step 1 - Context: U-1193821 initiated multiple low-value transfers (4.99 USD x6) from Singapore at 03:45 AM. Step 2 - Anomaly Detection: Anonymized network origin (Proxy/Relay), unrecognized hardware (Mobile (new)), off-peak timeframe, and rapid transaction frequency detected. Step 3 - Risk Assessment: High probability of automated card-testing script combined with identity obfuscation. Step 4 - Decision: HIGH RISK โ Transaction blocked immediately and flagged for manual review.
๐ฆ File Inventory
๐ How to Use
Option 1: Local CPU / Edge Inference via Ollama
- Clone or pull the GGUF weights:
git lfs install
git clone https://huggingface.co/MaxwellMensah/fraud_model_v7
cd fraud_model_v7
- Register and execute via Ollama using the included
Modelfile:
ollama create fraud-model-v7 -f fraud_model_v7_gguf/Modelfile
ollama run fraud-model-v7 "U-8916730 attempting 12,500.00 USD transfer. IP is Corporate Network. Toronto, afternoon."
Option 2: Python / Hugging Face Transformers
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "MaxwellMensah/fraud_model_v7"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
device_map="auto"
)
messages = [
{"role": "system", "content": "You are a fraud detection expert. Analyze transactions using step-by-step reasoning."},
{"role": "user", "content": "U-8916730 attempting 12,500.00 USD transfer. IP is Corporate Network. Toronto, afternoon. Desktop (saved) used."}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=256, temperature=0.1)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
๐ ๏ธ Training Specifications
- Base Model:
unsloth/Llama-3.2-1B-Instruct - Fine-Tuning Framework: Unsloth SFT (4-bit LoRA)
- LoRA Rank/Alpha:
r=16,lora_alpha=16 - Target Modules:
q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj - Dataset Size: 2,400 training samples (
train_2400.jsonl) / 600 validation samples (val_600.jsonl) - Quantization Export: 8-bit Integer GGUF (
Q8_0)
