CoolFace
Modelpublic

MaxwellMensah/fraud_model_v7

sourceHugging Facellama3.2updated 21d agoView on Hugging Face
0likes552downloads
Model Card

๐Ÿ›ก๏ธ 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 VariantRisk Assessment Exact Match (%)Cosine Semantic Similarity
Base Llama 3.2 (1B)~38.4%~0.7840
Fine-Tuned (`fraud_model_v7`)76.2%0.9822

๐Ÿ’ก 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:

text
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

File / FolderDescriptionTarget Environment
fraud_model_v7_gguf/Directory containing Q8_0 GGUF binary & ModelfileOllama / CPU & Edge Execution
model.safetensorsMerged 16-bit Full Precision CheckpointPyTorch / vLLM / Transformers
ModelfileConfig file defining system prompts and parametersOllama deployment

๐Ÿš€ How to Use

Option 1: Local CPU / Edge Inference via Ollama

  1. 1.Clone or pull the GGUF weights:
bash
git lfs install
git clone https://huggingface.co/MaxwellMensah/fraud_model_v7
cd fraud_model_v7
  1. 1.Register and execute via Ollama using the included Modelfile:
bash
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

python
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)