Views
No views yet
1import pandas as pd
2from transformers import pipeline
3
4# Load the classification pipeline
5classifier = pipeline("text-classification", "ajayat/xlm-roberta-large-xnli")
6classifier.model.config.id2label = {
7 0: "entailment",
8 1: "neutral",
9 2: "contradiction"
10}
11# Example premise and hypothesis
12premise = "A soccer game with multiple males playing."
13hypothesis = "Some men are playing a sport."
14
15# Provide input as a dictionary with text and text_pair keys
16result = classifier({'text': premise, 'text_pair': hypothesis}, top_k=None)
17pd.DataFrame(result)| label | score | |
|---|---|---|
| 0 | entailment | 0.996513 |
| 1 | neutral | 0.003228 |
| 2 | contradiction | 0.000260 |
entailment, contradiction, or neutral.bf16 mixed precision642e-5| lang_abv | ar | bg | de | el | en | es | fr | hi | ru | sw | th | tr | ur | vi | zh | avg |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| accuracy | 0.82 | 0.85 | 0.85 | 0.85 | 0.89 | 0.85 | 0.84 | 0.81 | 0.83 | 0.77 | 0.81 | 0.82 | 0.77 | 0.83 | 0.83 | 0.84 |