Fraud Detection Gemma2B (fp16, LoRA merged)

This model is a full-precision fp16 version of the fine-tuned mervegundogdu/fraud-detection-lora-gemma2b checkpoint.

The original checkpoint stored the base weights in bnb 4-bit NF4 format with a LoRA adapter (r=16, alpha=32). In this repository the 4-bit weights are dequantized to fp16 and the LoRA adapter is merged into the base weights, so the model can be loaded and served with plain AutoModelForCausalLM without bitsandbytes, on CPU or GPU.

  • Base model: google/gemma-2b
  • Task: classify a credit card / bank transaction as Fraud or Legitimate Transaction with a short justification
  • Architecture: GemmaForCausalLM, 2.5B parameters, fp16 (5 GB)
  • Trained on: mervegundogdu/fraud-detection-dataset

Prompt format

Use the Gemma chat template. The user message should contain the instruction followed by the transaction details:

<bos><start_of_turn>user
Below is information about a credit card / bank transaction. Analyze whether this transaction is fraudulent, and classify it as 'Fraud' or 'Legitimate Transaction' along with a short justification.
Transaction Amount: $2400.00
Customer's Average Transaction Amount: $523.76
Category: Electronics
Transaction Time: 03:00 (Night transaction: Yes)
Location: New York (Distance from home: 4500.0 km)
Customer Age: 38
Account Age: 3615 days
New Device: Yes
Previous Fraud Count: 0
<end_of_turn>
<start_of_turn>model

Expected output format: Fraud. Reason: ... or Legitimate Transaction. Reason: ...

Usage (local)

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

repo = "mervegundogdu/fraud-detection-gemma2b-fp16"
tokenizer = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, dtype=torch.float16)

instruction = ("Below is information about a credit card / bank transaction. "
               "Analyze whether this transaction is fraudulent, and classify it "
               "as 'Fraud' or 'Legitimate Transaction' along with a short justification.")
input_text = """Transaction Amount: $2400.00
Customer's Average Transaction Amount: $523.76
Category: Electronics
Transaction Time: 03:00 (Night transaction: Yes)
Location: New York (Distance from home: 4500.0 km)
Customer Age: 38
Account Age: 3615 days
New Device: Yes
Previous Fraud Count: 0"""

prompt = tokenizer.apply_chat_template(
    [{"role": "user", "content": instruction + "\n" + input_text}],
    tokenize=False, add_generation_prompt=True,
)
inputs = tokenizer(prompt, return_tensors="pt")
with torch.no_grad():
    out = model.generate(**inputs, max_new_tokens=64, do_sample=False)
print(tokenizer.decode(out[0], skip_special_tokens=True))

Hosted usage

This model is not served by the Hugging Face serverless Inference API. To run it as an API, use a dedicated Inference Endpoint (see mervegundogdu/fraud-detection-gemma2b-fp16 on the Hub — it is endpoints_compatible / TGI-ready) or self-host it locally with the code above.

The model card tags note base_model:google/gemma-2b; the base model is gated, so keep the license requirements in mind when sharing outputs.

Downloads last month
20
Safetensors
Model size
3B params
Tensor type
F16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for mervegundogdu/fraud-detection-gemma2b-fp16

Base model

google/gemma-2b
Finetuned
(304)
this model