File size: 1,038 Bytes
f0ffe89
 
 
 
 
 
 
 
 
 
f1f4c2c
 
 
 
 
f0ffe89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
---
datasets:
- upb-nlp/same_topic_articles
language:
- ro
- en
base_model:
- FacebookAI/xlm-roberta-large
---

<div align="center">
  <img src="images/logo.png" alt="Logo" width="240" height="240">
</div>


## How to Get Started with the Model

Use the code below to get started with the model.

```python
import torch
from transformers import AutoTokenizer, XLMRobertaForSequenceClassification

MODEL_PATH = "upb-nlp/xlm_roberta_large_article_same_topic_classification"

tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
model = XLMRobertaForSequenceClassification.from_pretrained(MODEL_PATH, num_labels=2).to('cuda')
model.eval()

t1 = "Article title. Article body."
t2 = "Article title. Article body."

inputs = tokenizer(
    t1,
    t2,
    return_tensors="pt",
    truncation=True,
    padding='max_length',
    max_length=512
).to('cuda')

# Generate prediction
with torch.no_grad():
    outputs = model(**inputs)
    logits = outputs.logits
    predicted_class = torch.argmax(logits, dim=1).item()

print(predicted_class)
```