Edit model card

hfl/chinese-roberta-wwm-ext first pre-trained on CMNLI and OCNLI and then fine-tuned on the CDConv dataset. It supports 2-class classification for 2-turn dialogue contradiction detection. Usage example:

import torch
from transformers.models.bert import BertTokenizer, BertForSequenceClassification

tokenizer = BertTokenizer.from_pretrained('thu-coai/roberta-base-cdconv')
model = BertForSequenceClassification.from_pretrained('thu-coai/roberta-base-cdconv')
model.eval()

turn1 = [
    "嗯嗯,你喜欢钓鱼吗?", # user
    "喜欢啊,钓鱼很好玩的", # bot
]
turn2 = [
    "你喜欢钓鱼吗?", # user
    "不喜欢,我喜欢看别人钓鱼", # bot, we want to identify whether this utterance makes a contradiction
] # turn1 and turn2 are not required to be two consecutive turns
text1 = "[SEP]".join(turn1 + turn2[:1])
text2 = turn2[1]

model_input = tokenizer(text1, text2, return_tensors='pt', return_token_type_ids=True, return_attention_mask=True)
model_output = model(**model_input, return_dict=False)
prediction = torch.argmax(model_output[0].cpu(), dim=-1)[0].item()
print(prediction) # output 1. 0 for non-contradiction, 1 for contradiction

This fine-tuned model obtains 75.7 accuracy and 72.3 macro-F1 on the test set.

Please kindly cite the original paper if you use this model.

@inproceedings{zheng-etal-2022-cdconv,
  title={Towards Emotional Support Dialog Systems},
  author={Zheng, Chujie  and 
    Zhou, Jinfeng  and 
    Zheng, Yinhe  and 
    Peng, Libiao  and 
    Guo, Zhen  and 
    Wu, Wenquan  and 
    Niu, Zhengyu  and 
    Wu, Hua  and 
    Huang, Minlie},
  booktitle={Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing},
  year={2022}
}
Downloads last month
19
Safetensors
Model size
102M params
Tensor type
I64
·
F32
·
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.