/ Модель

Характеристики

Лицензия
Apache 2.0
Опубликована
10 июн 2025

high-accuracy-email-classifier

Классификация текстаТекст → label4 профессии
2скачиваний за 30 дней5лайковвеса обновлены10 июн 2025

Описание модели

Составлено на русском по карточке модели и метаданным Hugging Face

Модель классифицирует английские письма на шесть категорий, включая рекламу, спам, коды подтверждения и системные уведомления, и поддерживает развёртывание через TensorFlow Lite.

Модель jason23322/high-accuracy-email-classifier классифицирует электронные письма по шести категориям: уведомления социальных сетей, рекламные рассылки, сообщения форумов, спам и фишинг, коды подтверждения и системные обновления. Она предназначена для автоматической сортировки почты и выявления нежелательных или мошеннических сообщений, в том числе в мобильных и периферийных приложениях.

Архитектура включает эмбеддинги слов, многомасштабную CNN, двунаправленную GRU и многоголовое внимание. Модель обрабатывает последовательности длиной до 250 токенов; доступны версии Keras H5 размером 94 МБ и TensorFlow Lite размером 7,9 МБ. В README заявлена точность проверки свыше 98%, но условия тестирования и состав выборки не описаны. Для обработки требуются токенизация и предварительная нормализация текста; модель рассчитана на английские письма. Лицензия — Apache-2.0.

Сценарии применения

  • автоматическая сортировка писем по категориям
  • фильтрация спама и фишинговых писем
  • выделение рекламных рассылок
  • распознавание кодов подтверждения в почте
  • отделение уведомлений соцсетей и форумов от личной почты
  • классификация писем в мобильном приложении без облачного инференса

Ограничения

Модель рассчитана на английский текст и ограничивает вход последовательностью длиной 250 токенов, поэтому длинные письма могут требовать усечения. Заявленная точность свыше 98% приведена без описания тестовой выборки и условий оценки.

Публичные бенчмарки

Результаты из открытых лидербордов в сравнении с лидерами каталога

Публичных оценок пока нет

В подключённых источниках результатов этой модели не нашлось. Отсутствие оценки не значит, что модель хуже: её могли просто не проверять.

Источники: Hugging Face Leaderboards, Hugging Face Eval Results, Open LLM v2, MTEB, timm, Open ASR, EvalPlus

Для каких профессий подходит4

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

High-Accuracy Email Classifier

Model Description

This is a high-accuracy email classification model trained to categorize emails into 6 distinct categories with 98%+ accuracy. The model uses a sophisticated CNN+GRU architecture with multi-head attention, specifically designed for edge deployment scenarios.

Categories

The model classifies emails into the following categories:

  1. 📱 Social Media - Notifications from social platforms (Facebook, Instagram, Twitter, etc.)
  2. 🛒 Promotions - Marketing emails, sales, offers, and advertisements
  3. 🗣️ Forum - Forum posts, discussions, and community notifications
  4. ⚠️ Spam - Unwanted emails, scams, and phishing attempts
  5. 🔐 Verify Code - Authentication codes and verification emails
  6. 🔄 Updates - System updates, security patches, and maintenance notices

Model Architecture

  • Base Architecture: CNN + Bidirectional GRU with Multi-Head Attention
  • Vocabulary Size: 25,000 words
  • Sequence Length: 250 tokens
  • Embedding Dimension: 300
  • Model Size: 94MB (H5), 7.9MB (TFLite)

Architecture Details

Input Layer (250,) 
    ↓
Embedding Layer (25000 → 300)
    ↓
Multi-scale CNN (kernels: 3, 4, 5)
    ↓
Bidirectional GRU (256 units)
    ↓
Multi-Head Attention (8 heads)
    ↓
Dense Layers + Dropout
    ↓
Output Layer (6 classes)

Performance

  • Training Accuracy: 98.13%
  • Validation Accuracy: 98%+
  • Model Size: 94MB (H5 format), 7.9MB (TFLite)
  • Inference Speed: Optimized for mobile/edge deployment

Quick Start

Loading the Model

import tensorflow as tf
import json
import numpy as np
from tensorflow.keras.preprocessing.sequence import pad_sequences

# Load the model
model = tf.keras.models.load_model('best_high_accuracy_model.h5')

# Load tokenizer configuration
with open('high_accuracy_tokenizer_config.json', 'r') as f:
    config = json.load(f)

categories = config['categories']
word_index = config['word_index']
max_len = config['max_len']

Preprocessing Function

import re

def preprocess_text(text):
    """Preprocess text exactly as done during training"""
    # Convert to lowercase
    text = text.lower()
    
    # Replace URLs
    text = re.sub(r'http[s]?://\S+', 'URL', text)
    text = re.sub(r'www\.\S+', 'URL', text)
    
    # Replace email addresses
    text = re.sub(r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b', 'EMAIL', text)
    
    # Replace numbers
    text = re.sub(r'\b\d+\b', 'NUMBER', text)
    
    # Remove punctuation
    text = re.sub(r'[^\w\s]', ' ', text)
    
    # Remove extra spaces
    text = ' '.join(text.split())
    
    return text

def text_to_sequence(text, word_index, max_len):
    """Convert text to padded sequence"""
    words = text.split()
    sequence = [word_index.get(word, 1) for word in words]  # 1 is OOV token
    return pad_sequences([sequence], maxlen=max_len, padding='post', truncating='post')

Making Predictions

def predict_email_category(text, model, word_index, categories, max_len):
    """Predict email category with confidence scores"""
    # Preprocess text
    processed_text = preprocess_text(text)
    
    # Convert to sequence
    sequence = text_to_sequence(processed_text, word_index, max_len)
    
    # Get prediction
    prediction = model.predict(sequence, verbose=0)
    probabilities = prediction[0]
    
    # Get predicted class
    predicted_idx = np.argmax(probabilities)
    predicted_category = categories[predicted_idx]
    confidence = probabilities[predicted_idx]
    
    # Return all probabilities
    results = {
        'predicted_category': predicted_category,
        'confidence': float(confidence),
        'all_probabilities': {
            category: float(prob) 
            for category, prob in zip(categories, probabilities)
        }
    }
    
    return results

# Example usage
email_text = "Your verification code is 123456. Please enter this code."
result = predict_email_category(email_text, model, word_index, categories, max_len)
print(f"Category: {result['predicted_category']}")
print(f"Confidence: {result['confidence']:.4f}")

TFLite Mobile Deployment

For mobile/edge deployment, use the optimized TFLite version:

import tensorflow as tf

# Load TFLite model
interpreter = tf.lite.Interpreter(model_path='high_accuracy_email_classifier.tflite')
interpreter.allocate_tensors()

# Get input/output details
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()

def predict_tflite(text, interpreter, word_index, categories, max_len):
    """Predict using TFLite model"""
    # Preprocess and convert to sequence
    processed_text = preprocess_text(text)
    sequence = text_to_sequence(processed_text, word_index, max_len)
    
    # Run inference
    interpreter.set_tensor(input_details[0]['index'], sequence.astype(np.float32))
    interpreter.invoke()
    
    # Get output (already softmax probabilities)
    output_data = interpreter.get_tensor(output_details[0]['index'])
    probabilities = output_data[0]
    
    predicted_idx = np.argmax(probabilities)
    return categories[predicted_idx], probabilities

Training Details

Data Augmentation

  • Synonym replacement
  • Random word deletion
  • Word position swapping
  • Contextual word insertion

Advanced Techniques

  • Multi-scale CNN filters (3, 4, 5)
  • Bidirectional GRU with attention
  • Class weight balancing
  • Cosine annealing learning rate
  • Early stopping with patience

Preprocessing

  • URL/Email/Number standardization
  • Punctuation removal
  • Case normalization
  • OOV token handling

Files Included

  • best_high_accuracy_model.h5 - Main Keras model (94MB)
  • high_accuracy_email_classifier.tflite - Mobile-optimized TFLite model (7.9MB)
  • high_accuracy_tokenizer_config.json - Tokenizer configuration and word mappings
  • android_config.json - Mobile deployment configuration
  • confusion_matrix.png - Model performance visualization

Requirements

tensorflow>=2.19.0
numpy>=1.21.0
scikit-learn>=1.0.0
matplotlib>=3.5.0
seaborn>=0.11.0

License

This model is released under the Apache 2.0 License.

Citation

@misc{high_accuracy_email_classifier,
  title={High-Accuracy Email Classifier with CNN-GRU Architecture},
  author={Email Classification Team},
  year={2024},
  publisher={Hugging Face},
  url={https://huggingface.co/your-username/high-accuracy-email-classifier}
}

Model Card Contact

For questions and issues, please open an issue in the repository or contact the model authors.

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм

Нельзя запустить

Не удалось определить, чем загружать веса модели (нет library_name и architectures).

Ревизия весов
e7e8b7d

0 моделей