Views
No views yet
1from peft import PeftModel, PeftConfig
2from transformers import AutoModelForCausalLM, AutoTokenizer
3import torch
4
5# Load model and tokenizer
6base_model = "Qwen/Qwen2.5-0.5B-Instruct"
7model = AutoModelForCausalLM.from_pretrained(
8 base_model,
9 torch_dtype=torch.float16,
10 device_map="auto"
11)
12tokenizer = AutoTokenizer.from_pretrained(base_model)
13
14# Load LoRA adapters
15model = PeftModel.from_pretrained(model, "shakeleoatmeal/Fraud-call-detection-Qwen-0.5B-Lora")
16
17# Prepare input
18dialogue = "Your phone call dialogue here..."
19instruction = f'''Analyze the following phone call dialogue and determine if it is fraudulent or legitimate.
20Respond with only "1" if the call is fraudulent/scam, or "0" if it is legitimate.
21
22Phone Call Dialogue:
23{dialogue}
24
25Classification:'''
26
27inputs = tokenizer(instruction, return_tensors="pt").to(model.device)
28
29# Generate prediction
30outputs = model.generate(**inputs, max_new_tokens=5)
31response = tokenizer.decode(outputs[0][inputs['input_ids'].shape[1]:], skip_special_tokens=True)
32print(response) # "1" for fraud, "0" for legitimate@misc{fraud-call-detection-qwen,
author = {shakeleoatmeal},
title = {Fraud Call Detection - Qwen 0.5B LoRA},
year = {2025},
publisher = {HuggingFace},
howpublished = {\url{https://huggingface.co/shakeleoatmeal/Fraud-call-detection-Qwen-0.5B-Lora}}
}