Yehor Smoliakov commited on
Commit
ad4d0e8
1 Parent(s): 61003b9
Files changed (1) hide show
  1. README.md +11 -3
README.md CHANGED
@@ -16,14 +16,14 @@ license: cc-by-nc-sa-4.0
16
 
17
  ```python
18
  import torch
19
- from transformers import AutoTokenizer, AutoModel
20
 
21
  tokenizer = AutoTokenizer.from_pretrained("Yehor/ual-topics-classifier")
22
- model = AutoModel.from_pretrained("Yehor/ual-topics-classifier")
23
 
24
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
25
 
26
- topic_classifier = pipeline(task='text-classification', model=model, tokenizer=tokenizer, device=device)
27
 
28
  question = """
29
  Що мені робити на ВЛК
@@ -37,3 +37,11 @@ question = """
37
 
38
  print(topic_classifier(question))
39
  ```
 
 
 
 
 
 
 
 
 
16
 
17
  ```python
18
  import torch
19
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
20
 
21
  tokenizer = AutoTokenizer.from_pretrained("Yehor/ual-topics-classifier")
22
+ model = AutoModelForSequenceClassification.from_pretrained("Yehor/ual-topics-classifier")
23
 
24
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
25
 
26
+ topic_classifier = pipeline(task='text-classification', model=model, tokenizer=tokenizer, device=device, top_k=5)
27
 
28
  question = """
29
  Що мені робити на ВЛК
 
37
 
38
  print(topic_classifier(question))
39
  ```
40
+
41
+ Results:
42
+
43
+ ```
44
+ [[{'label': 'viiskovie_pravo', 'score': 0.9991637468338013}, {'label': 'inshe', 'score': 0.00035533116897568107}, {'label': 'immighratsiia_iemighratsiia', 'score': 8.094120130408555e-05}, {'label': 'pratsevlashtuvvannya', 'score': 4.537589484243654e-05}, {'label': 'opodatkuvannia', 'score': 3.591874337871559e-05}]]
45
+
46
+ [[{'label': 'simejne_pravo', 'score': 0.9992771744728088}, {'label': 'sotsialnyj_zakhist', 'score': 0.0002545009192544967}, {'label': 'piensiiata_sotsialni_viplati', 'score': 5.3493567975237966e-05}, {'label': 'sudova_praktika', 'score': 3.8876780308783054e-05}, {'label': 'doghovirni_vidnosini', 'score': 3.169032061123289e-05}]]
47
+ ```