data-silence commited on
Commit
898096f
1 Parent(s): e0ce234

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +36 -1
README.md CHANGED
@@ -43,7 +43,7 @@ It achieves the following results on the evaluation set:
43
 
44
  ## Model description
45
 
46
- This is a multi-class classifier of Russian news, made with the LaBSE model finetune for (AntiSMI Project)[https://github.com/data-silence/antiSMI-Project].
47
  The news category is assigned by the classifier to one of 11 categories:
48
  - climate (климат)
49
  - conflicts (конфликты)
@@ -57,6 +57,41 @@ The news category is assigned by the classifier to one of 11 categories:
57
  - sports (спорт)
58
  - travel (путешествия)
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  ## Intended uses & limitations
61
 
62
  Enjoy to use in your purpose
 
43
 
44
  ## Model description
45
 
46
+ This is a multi-class classifier of Russian news, made with the LaBSE model finetune for [AntiSMI Project](https://github.com/data-silence/antiSMI-Project).
47
  The news category is assigned by the classifier to one of 11 categories:
48
  - climate (климат)
49
  - conflicts (конфликты)
 
57
  - sports (спорт)
58
  - travel (путешествия)
59
 
60
+ ## How to use
61
+
62
+ ```
63
+ python
64
+
65
+ from transformers import pipeline
66
+
67
+ category_mapper = {
68
+ 'LABEL_0': 'climate',
69
+ 'LABEL_1': 'conflicts',
70
+ 'LABEL_2': 'culture',
71
+ 'LABEL_3': 'economy',
72
+ 'LABEL_4': 'gloss',
73
+ 'LABEL_5': 'health',
74
+ 'LABEL_6': 'politics',
75
+ 'LABEL_7': 'science',
76
+ 'LABEL_8': 'society',
77
+ 'LABEL_9': 'sports',
78
+ 'LABEL_10': 'travel'
79
+ }
80
+
81
+ # Используйте предобученную модель из Hugging Face Hub
82
+ classifier = pipeline("text-classification", model="data-silence/rus-news-classifier")
83
+
84
+ def predict_category(text):
85
+ result = classifier(text)
86
+ category = category_mapper[result[0]['label']]
87
+ score = result[0]['score']
88
+ return category, score
89
+
90
+ predict_category("В Париже завершилась церемония закрытия Олимпийских игр")
91
+ # ('sports', 0.9959506988525391)
92
+ ```
93
+
94
+
95
  ## Intended uses & limitations
96
 
97
  Enjoy to use in your purpose