Views
No views yet
[!WARNING]Legacy model
FTAN 1.0 (bad-good-classifier-ru_en) is an old release from the early FTAN series.This version performs word-level classification and is not intended to replace newer FTAN releases. Its performance, label behavior, and capabilities may differ significantly from newer versions of the model.For general-purpose binary offensive-text classification, useakaruineko/ftan-2.5instead.FTAN 1.0 is primarily intended for:
- experimenting with word-level classification
- research
- exploring the early development of the FTAN model family
transformers package installed:pip install transformers torch1from transformers import AutoModelForSequenceClassification, AutoTokenizer
2import torch
3
4model_name = "akaruineko/bad-good-classifier-ru_en"
5
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForSequenceClassification.from_pretrained(model_name)
8
9def classify_word(word):
10 inputs = tokenizer(word, return_tensors="pt", truncation=True, padding=True)
11 outputs = model(**inputs)
12 probs = torch.softmax(outputs.logits, dim=1)
13 return {"good": probs[0][1].item(), "bad": probs[0][0].item()}
14
15def classify_text_by_words(text):
16 words = text.split()
17 results = {}
18 for w in words:
19 results[w] = classify_word(w)
20 return results
21
22if __name__ == "__main__":
23 sample_text = "Example text for classification"
24 results = classify_text_by_words(sample_text)
25 for word, scores in results.items():
26 print(f"Word: '{word}' - Good: {scores['good']:.4f}, Bad: {scores['bad']:.4f}")