Downloads · 30 days
7
2% of all-time downloads
DanielNRU/GreenSMKZ-tags
GreenSMKZ-tags is a machine learning model from DanielNRU. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Модель многоклассовой тематической классификации отзывов и постов о сервисе Green SM KZ (такси). Поддерживает русский язык, казахский кириллический и казахский латинский.
Downloads · 30 days
7
2% of all-time downloads
All-time downloads
296
Public
Repo size
33.4 GB
Likes
0
Public
Click a slice to open those files.
.pt4.4 GB · 80%
From the Hugging Face model README
Модель многоклассовой тематической классификации отзывов и постов о сервисе Green SM KZ (такси). Поддерживает русский язык, казахский кириллический и казахский латинский.
import json, torch
from transformers import AutoTokenizer
with open("tag2id.json") as f: tag2id = json.load(f)
with open("per_tag_thresholds.json") as f: thr_data = json.load(f)
id2tag = {v: k for k, v in tag2id.items()}
thresholds = thr_data["thresholds"]
tokenizer = AutoTokenizer.from_pretrained("DanielNRU/GreenSMKZ-tags")
text = "query: Отличный сервис, водитель был очень вежлив!"
enc = tokenizer(text, return_tensors="pt", max_length=512,
truncation=True, padding="max_length")
with torch.no_grad():
logits = model(enc["input_ids"], enc["attention_mask"])
probs = torch.sigmoid(logits).squeeze().numpy()
tags = [id2tag[str(i)] for i, p in enumerate(probs)
if p >= thresholds.get(id2tag[str(i)], 0.3)]
print(tags)