Downloads · 30 days
13
1% of all-time downloads
thu-coai/roberta-zh-specific
roberta-zh-specific is a text classification model from thu-coai. Use it when you need a label for a piece of text. It is set up for transformers.
roberta-zh fine-tuned on human-annotated conversational model self-chat data. It supports 2-class calssification for multi-turn dialogue sensible detection. Usage example:
Downloads · 30 days
13
1% of all-time downloads
All-time downloads
930
Public
Parameters
102M
818 MB on disk
Likes
0
Public
Click a slice to open those files.
.bin409 MB · 50%
How the weights are stored.
F32102M · 100%
From the Hugging Face model README
roberta-zh fine-tuned on human-annotated conversational model self-chat data. It supports 2-class calssification for multi-turn dialogue sensible detection. Usage example:
NOTE: it should be used under similar data distribution.
import torch
from transformers import BertTokenizer, BertForSequenceClassification
tokenizer = BertTokenizer.from_pretrained('thu-coai/roberta-zh-specific')
model = BertForSequenceClassification.from_pretrained('thu-coai/roberta-zh-specific', num_labels=2)
model.eva()
context = [
"你大爱的冷门古诗词是什么?\t一枝红艳露凝香,云雨巫山枉断肠",
"你大爱的冷门古诗词是什么?\t一枝红艳露凝香,云雨巫山枉断肠",
]
response = [
"我也很喜欢,我觉得这句的意境很美",
"我也很喜欢",
]
model_input = tokenizer(context, response, return_tensors='pt', padding=True)
with torch.no_grad():
model_output = model(**model_input, return_dict=True)
logits = model_output.logits
preds_all = torch.argmax(logits, dim=-1).cpu()
print(preds_all) # 1 for specific response else 0