Views
No views yet
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
3tokenizer = AutoTokenizer.from_pretrained("fabhiansan/indo-roberta-nli")
4model = AutoModelForSequenceClassification.from_pretrained("fabhiansan/indo-roberta-nli")
5
6# Prepare the input
7premise = "Seorang wanita sedang makan di restoran."
8hypothesis = "Seorang wanita sedang berada di luar ruangan."
9
10# Tokenize the input
11inputs = tokenizer(premise, hypothesis, return_tensors="pt")
12
13# Get the prediction
14outputs = model(**inputs)
15predictions = outputs.logits.argmax(dim=1)
16
17# Map predictions to labels
18id2label = {0: "entailment", 1: "neutral", 2: "contradiction"}
19predicted_label = id2label[predictions.item()]
20print(f"Predicted label: {predicted_label}")
21## Citation
22
23If you use this model, please cite the IndoNLI paper:
24
25```bibtex
26@inproceedings{mahendra-etal-2021-indonli,
27 title = {IndoNLI: A Natural Language Inference Dataset for Indonesian},
28 author = {Mahendra, Rahmad and Aji, Alham Fikri and Louvan, Samuel and Rahman, Fahrurrozi and Vania, Clara},
29 booktitle = {Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing},
30 year = {2021},
31 publisher = {Association for Computational Linguistics},
32}