ynie/roberta-large-snli_mnli_fever_anli_R1_R2_R3-nli
ynie
Clasificación de texto
Este es un modelo RoBERTa-Large NLI preentrenado con un rendimiento sólido. Los datos de entrenamiento son una combinación de conocidos conjuntos de datos de NLI: SNLI, MNLI, FEVER-NLI, ANLI (R1, R2, R3). También están disponibles otros modelos NLI preentrenados incluyendo RoBERTa, ALBert, BART, ELECTRA y XLNet. Entrenado por Yixin Nie, fuente original.
Como usar
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
if __name__ == '__main__':
max_length = 256
premise = "Two women are embracing while holding to go packages."
hypothesis = "The men are fighting outside a deli."
hg_model_hub_name = "ynie/roberta-large-snli_mnli_fever_anli_R1_R2_R3-nli"
tokenizer = AutoTokenizer.from_pretrained(hg_model_hub_name)
model = AutoModelForSequenceClassification.from_pretrained(hg_model_hub_name)
tokenized_input_seq_pair = tokenizer.encode_plus(premise, hypothesis,
max_length=max_length,
return_token_type_ids=True, truncation=True)
input_ids = torch.Tensor(tokenized_input_seq_pair['input_ids']).long().unsqueeze(0)
token_type_ids = torch.Tensor(tokenized_input_seq_pair['token_type_ids']).long().unsqueeze(0)
attention_mask = torch.Tensor(tokenized_input_seq_pair['attention_mask']).long().unsqueeze(0)
outputs = model(input_ids,
attention_mask=attention_mask,
token_type_ids=token_type_ids,
labels=None)
predicted_probability = torch.softmax(outputs[0], dim=1)[0].tolist()
print("Premise:", premise)
print("Hypothesis:", hypothesis)
print("Entailment:", predicted_probability[0])
print("Neutral:", predicted_probability[1])
print("Contradiction:", predicted_probability[2])
Funcionalidades
- Clasificación de Texto
- Transformers
- PyTorch
- JAX
- Compatible con AutoTrain
- Compatible con Inference Endpoints
- Región: EE. UU.
Casos de uso
- Clasificación de texto
- Comprensión del lenguaje natural
- Detección de contradicciones entre oraciones
- Análisis de sentimientos