MironB commited on
Commit
f0ffe89
·
verified ·
1 Parent(s): 09f52ca

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +44 -0
README.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - upb-nlp/same_topic_articles
4
+ language:
5
+ - ro
6
+ - en
7
+ base_model:
8
+ - FacebookAI/xlm-roberta-large
9
+ ---
10
+
11
+ ## How to Get Started with the Model
12
+
13
+ Use the code below to get started with the model.
14
+
15
+ ```python
16
+ import torch
17
+ from transformers import AutoTokenizer, XLMRobertaForSequenceClassification
18
+
19
+ MODEL_PATH = "upb-nlp/xlm_roberta_large_article_same_topic_classification"
20
+
21
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
22
+ model = XLMRobertaForSequenceClassification.from_pretrained(MODEL_PATH, num_labels=2).to('cuda')
23
+ model.eval()
24
+
25
+ t1 = "Article title. Article body."
26
+ t2 = "Article title. Article body."
27
+
28
+ inputs = tokenizer(
29
+ t1,
30
+ t2,
31
+ return_tensors="pt",
32
+ truncation=True,
33
+ padding='max_length',
34
+ max_length=512
35
+ ).to('cuda')
36
+
37
+ # Generate prediction
38
+ with torch.no_grad():
39
+ outputs = model(**inputs)
40
+ logits = outputs.logits
41
+ predicted_class = torch.argmax(logits, dim=1).item()
42
+
43
+ print(predicted_class)
44
+ ```