You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Для получения доступа к модели, пожалуйста, заполните форму ниже.

Log in or Sign Up to review the conditions and access this model content.

NeuroSpaceX/ruSpamNS_v11

Описание

Это модель определения спама, основанная на архитектуре руберта, дообученная на русскоязычных данных о спаме. Она классифицирует текст как спам или не спам. Модель была обучена на 5 млн сообщений и содержит улучшения в обработке сложных случаев, таких как рекламные сообщения со схожей структурой с нормальным текстом.

Модель ru-spam/ruSpamNS_v11 представляет собой улучшенную версию с повышенной точностью классификации и оптимизированной производительностью для определения спама в русскоязычных текстах.

Использование

import re
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification

model_name = 'ru-spam/ruSpamNS_v11'
token = 'your_huggingface_token_here'
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

# Загрузка модели
model = AutoModelForSequenceClassification.from_pretrained(model_name, token=token, num_labels=1).to(device).eval()
tokenizer = AutoTokenizer.from_pretrained(model_name, token=token)

def clean_text(text):
    if text is None:
        return ""
    text = text.strip().replace("\n", " ")
    text = re.sub(r"[^\w\s,.!?]", "", text, flags=re.UNICODE)
    text = re.sub(r"[!?]", "", text)
    if re.search(r"[а-яА-Я]", text):
        text = re.sub(r"\b(?!@|https?://|www\.)[a-zA-Z]+\b", "", text)
    return re.sub(r"\s+", " ", text).strip().lower()

def classify_message(message):
    message = clean_text(message)
    encoding = tokenizer(message, padding='max_length', truncation=True, max_length=128, return_tensors='pt')
    input_ids = encoding['input_ids'].to(device)
    attention_mask = encoding['attention_mask'].to(device)

    with torch.no_grad():
        outputs = model(input_ids, attention_mask=attention_mask).logits
        pred = torch.sigmoid(outputs).cpu().numpy()[0][0]
    
    is_spam = int(pred >= 0.5)
    return is_spam

if __name__ == '__main__':
    while True:
        message = input("Введите сообщение для классификации (или 'exit' для выхода): ")
        if message.lower() == 'exit':
            break
        is_spam = classify_message(message)
        print(f"Сообщение {'является спамом' if is_spam else 'не является спамом'}")

Просьба при использовании данной модели указывать ссылку на данный репозиторий!

Цитирование

@MISC{NeuroSpaceX/ruSpamNS_v11,
    author  = {Kirill Fedko (NeuroSpaceX)},
    title   = {Russian Spam Classification Model},
    url     = {https://huggingface.co/ru-spam/ruSpamNS_v11},
    year    = 2025
}

Телеграм канал автора: https://t.me/spaceneuro

Бот, работающий на базе модели: https://t.me/ruSpamNS_bot

Downloads last month
408
Safetensors
Model size
29.2M params
Tensor type
F32
·
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API: The model has no library tag.

Dataset used to train ru-spam/ruSpamNS_v11

Space using ru-spam/ruSpamNS_v11 1