CoolFace
Modelpublic

Rainnighttram/Scam_Detection

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes23downloads
Model Card

Scam SMS Detection Model (Llama 3.2 1B Fine-tuned)

A fine-tuned Llama 3.2 1B model specifically designed to detect and classify scam SMS messages in Hong Kong, with support for both Traditional Chinese and English text.

πŸš€ Model Overview

This model is based on Meta's Llama 3.2 1B and has been fine-tuned using MLX framework on a carefully curated dataset of SMS messages collected in Hong Kong. The model can effectively distinguish between legitimate and fraudulent SMS messages in both Traditional Chinese and English.

Key Features

  • β€”Bilingual Support: Traditional Chinese and English
  • β€”Lightweight: 1B parameters for efficient deployment
  • β€”Cross-Platform: GGUF format optimized for llama.cpp deployment
  • β€”Local Processing: No internet connection required for inference

πŸ“Š Model Details

SpecificationDetails
Base ModelMeta Llama 3.2 1B
Fine-tuning FrameworkMLX
Model FormatGGUF
LanguagesTraditional Chinese, English
Training DataSelf-collected Hong Kong SMS samples
Model Size~2.5GB
Context Length8,192 tokens

πŸ›  Requirements

Software Dependencies

  • β€”llama.cpp (Model Engine)
  • β€”Python 3.8+ (for preprocessing scripts)

Hardware Requirements

  • β€”Minimum RAM: 8GB
  • β€”Recommended RAM: 16GB+
  • β€”Storage: 3GB free space

πŸ“± Installation & Deployment

Desktop/Server Deployment

  1. 1.Install llama.cpp
bash
   git clone https://github.com/ggerganov/llama.cpp.git
   cd llama.cpp
   make
  1. 1.Download the model
bash
   # Download your model file (replace with actual download link)
   wget [MODEL_DOWNLOAD_URL] -O scam_sms_detector.gguf
  1. 1.Run inference
bash
   ./main -m scam_sms_detector.gguf -p "Classify this SMS: ζ­ε–œζ‚¨δΈ­ηŽδΊ†οΌθ«‹ι»žζ“ŠιˆζŽ₯ι ˜ε–ηŽι‡‘" -n 50

πŸ”§ Usage Examples

Basic Classification

bash
# English SMS
./main -m scam_sms_detector.gguf -p "Classify: Congratulations! You've won $10,000. Click here to claim your prize!" -n 30

# Traditional Chinese SMS
./main -m scam_sms_detector.gguf -p "εˆ†ι‘žζ­€ηŸ­δΏ‘οΌšζ‚¨ηš„ιŠ€θ‘Œθ³¬ζˆΆε·²θ’«ε‡η΅οΌŒθ«‹η«‹ε³ι»žζ“ŠιˆζŽ₯ι©—θ­‰θΊ«δ»½" -n 30

Batch Processing

python
import subprocess
import json

def classify_sms(text):
    cmd = [
        "./main", 
        "-m", "scam_sms_detector.gguf",
        "-p", f"Classify this SMS as SCAM or LEGITIMATE: {text}",
        "-n", "10"
    ]
    result = subprocess.run(cmd, capture_output=True, text=True)
    return result.stdout.strip()

# Example usage
messages = [
    "Your package is ready for delivery. Track: https://bit.ly/track123",
    "Meeting scheduled for 3 PM tomorrow in conference room A",
    "ζ­ε–œοΌζ‚¨ε·²θ’«ιΈδΈ­η²εΎ—ε…θ²»iPhoneοΌŒθ«‹ι»žζ“Šι ˜ε–"
]

for msg in messages:
    classification = classify_sms(msg)
    print(f"Message: {msg}")
    print(f"Classification: {classification}\n")

API Integration

python
# Simple Flask API wrapper
from flask import Flask, request, jsonify
import subprocess

app = Flask(__name__)

@app.route('/classify', methods=['POST'])
def classify_sms():
    data = request.json
    sms_text = data.get('text', '')
    
    cmd = [
        "./main", 
        "-m", "scam_sms_detector.gguf",
        "-p", f"Classify: {sms_text}",
        "-n", "20"
    ]
    
    result = subprocess.run(cmd, capture_output=True, text=True)
    
    return jsonify({
        'text': sms_text,
        'classification': result.stdout.strip(),
        'confidence': 'high'  # You may want to implement confidence scoring
    })

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000)

πŸ“ˆ Performance & Capabilities

Language Support

  • β€”Traditional Chinese: Optimized for Hong Kong usage patterns
  • β€”English: Standard international English
  • β€”Mixed Language: Can handle code-switching between Chinese and English

Expected Performance

  • β€”Memory Usage: ~3GB RAM during inference

⚠️ Limitations

  1. 1.Regional Specificity: Optimized for Hong Kong SMS patterns; may need retraining for other regions
  2. 2.Language Support: Limited to Traditional Chinese and English
  3. 3.Context Dependency: May require additional context for borderline cases
  4. 4.Update Frequency: Scam patterns evolve; periodic retraining recommended
  5. 5.Legal Compliance: Users responsible for compliance with local privacy laws

🀝 Contributing

You are welcomed to contributions to improve the model:

  1. 1.Data Collection: Help expand the training dataset
  2. 2.Bug Reports: Report issues or false classifications
  3. 3.Feature Requests: Suggest improvements or new capabilities

Acknowledgments

  • β€”Meta AI for the Llama 3.2 base model
  • β€”Apple MLX team for the fine-tuning framework
  • β€”Georgi Gerganov for llama.cpp