How to use pipelines for text-pair classification (NLI)
Hi, I’m trying to use pipelines for natural-language inference, but can’t figure out how to pass a pair of strings properly. This is what I’m trying:from transformers import pipeline

pipe = pipeline("text-classification", model="typeform/distilbert-base-uncased-mnli")but I think it’s just running individual samples through the model in some incorrect way (as opposed to combining them into a (premise, hypothesis) pair):pipe(["This man is walking in a park", "the man is not in the park"], padding=True)[{'label': 'CONTRADICTION', 'score': 0.9903815388679504},
 {'label': 'ENTAILMENT', 'score': 0.9158636927604675}]
2024-01-08T19:35:45Z
I know this is old, but I have the same requirement and could not find guidance anywhere until I looked at the code in text_classification.py.  I think the answer is that you need to provide the premise/hypothesis pair in a dict with keys “text” and “text_pair”, like so:pipe({'text':"This man is walking in a park", 'text_pair': "the man is not in the park"})