自然语言推理 Natural Language Inference

判断句子对之间的语义逻辑关系。
Determine whether a “hypothesis” is true (entailment), false (contradiction), or undetermined (neutral) given a “premise”.

下游效果 Performance

零样本 Zero-shot

Model eprstmt csldcp tnews iflytek ocnli bustm chid csl wsc Avg
GPT-110M 57.5 26.2 37 19 34.4 50 65.6 50.1 50.3 43.4
PET-RoBERTa-110M 85.2 12.6 26.1 26.6 40.3 50.6 57.6 52.2 54.7 45.1
NSP-BERT-110M 86.9 47.6 51 41.6 37.4 63.4 52 64.4 59.4 55.96
ZeroPrompt-T5-1.5B - - - 16.14 46.16 - - - 47.98 -
Yuan1.0-13B 88.13 38.99 57.47 38.82 48.13 59.38 86.14 50 38.99 56.22
ERNIE3.0-240B 88.75 50.97 57.83 40.42 53.57 64.38 87.13 56.25 53.46 61.41
UniMC-RoBERTa-110M 86.16 31.26 46.61 26.54 66.91 73.34 66.68 50.09 53.66 55.7
UniMC-RoBERTa-330M 87.5 30.4 47.6 31.5 69.9 75.9 78.17 49.5 60.55 59.01
UniMC-MegatronBERT-1.3B 88.79 42.06 55.21 33.93 75.57 79.5 89.4 50.25 66.67 64.53

少样本 Few-shot

Model eprstmt csldcp tnews iflytek ocnli bustm chid csl wsc Avg
FineTuning-RoBERTa-110M 65.4 35.5 49 32.8 33 60.7 14.9 50 55.6 44.1
FineTuning-ERNIE1.0-110M 66.5 57 516 42.1 32 60.4 15 60.1 50.3 48.34
PET-ERNIE1.0-110M 84 59.9 56.4 50.3 38.1 58.4 40.6 61.1 58.7 56.39
P-tuning-ERNIE1.0-110M 80.6 56.6 55.9 52.6 35.7 60.8 39.61 51.8 55.7 54.37
EFL-ERNIE1.0-110M 76.7 47.9 56.3 52.1 48.7 54.6 30.3 52.8 52.3 52.7
UniMC-RoBERTa-110M 88.64 54.08 54.32 48.6 66.55 73.76 67.71 52.54 59.92 62.86
UniMC-RoBERTa-330M 89.53 57.3 54.25 50 70.59 77.49 78.09 55.73 65.16 66.46
UniMC-MegatronBERT-1.3B 89.278 60.9 57.46 52.89 76.33 80.37 90.33 61.73 79.15 72.05

微调 Fine-tuning

模型 Model cmnli ocnli snli
Erlangshen-Roberta-110M-NLI 80.83 78.56 88.01
Erlangshen-Roberta-330M-NLI 82.25 79.82 88.00
Erlangshen-MegatronBert-1.3B-NLI 84.52 84.17 88.67
Erlangshen-UniMC-MegatronBERT-1.3B-Chinese 84.76 83.05 -

使用 Usage

UniMC / MacBERT

git clone https://github.com/IDEA-CCNL/Fengshenbang-LM.git
cd Fengshenbang-LM
pip install --editable .
import argparse
from fengshen.pipelines.multiplechoice import UniMCPipelines


total_parser = argparse.ArgumentParser("TASK NAME")
total_parser = UniMCPipelines.piplines_args(total_parser)
args = total_parser.parse_args()
pretrained_model_path = 'IDEA-CCNL/Erlangshen-UniMC-RoBERTa-110M-Chinese'
args.learning_rate=2e-5
args.max_length=512
args.max_epochs=3
args.batchsize=8
args.default_root_dir='./'
model = UniMCPipelines(args, pretrained_model_path)

train_data = []
dev_data = []
test_data = [
        {"texta": "要稳定和完善出口政策,加快通关便利化改革,扩大跨境电子商务试点", 
         "textb": "", 
         "question": "基于文本", 
         "choice": [
            "可以推出:外来货物入境不需要经过海关", 
            "不能推出:外来货物入境不需要经过海关", 
            "很难推出:外来货物入境不需要经过海关"
            ], 
         "answer": "不能推出:外来货物入境不需要经过海关", 
         "label": 1, 
         "id": 23}
    ]

if args.train:
    model.train(train_data, dev_data)
result = model.predict(test_data)
for line in result[:20]:
    print(line)

其他 Other

from transformers import BertForSequenceClassification
from transformers import BertTokenizer
import torch

tokenizer=BertTokenizer.from_pretrained('IDEA-CCNL/Erlangshen-Roberta-110M-NLI')
model=BertForSequenceClassification.from_pretrained('IDEA-CCNL/Erlangshen-Roberta-110M-NLI')

texta='今天的饭不好吃'
textb='今天心情不好'

output=model(torch.tensor([tokenizer.encode(texta,textb)]))
print(torch.nn.functional.softmax(output.logits,dim=-1))

引用 Citation

如果您在您的工作中使用了我们的模型,可以引用我们的论文

If you are using the resource for your work, please cite the our paper:

@article{fengshenbang,
  author    = {Junjie Wang and Yuxiang Zhang and Lin Zhang and Ping Yang and Xinyu Gao and Ziwei Wu and Xiaoqun Dong and Junqing He and Jianheng Zhuo and Qi Yang and Yongfeng Huang and Xiayu Li and Yanghan Wu and Junyu Lu and Xinyu Zhu and Weifeng Chen and Ting Han and Kunhao Pan and Rui Wang and Hao Wang and Xiaojun Wu and Zhongshen Zeng and Chongpei Chen and Ruyi Gan and Jiaxing Zhang},
  title     = {Fengshenbang 1.0: Being the Foundation of Chinese Cognitive Intelligence},
  journal   = {CoRR},
  volume    = {abs/2209.02970},
  year      = {2022}
}

也可以引用我们的网站:

You can also cite our website:

@misc{Fengshenbang-LM,
  title={Fengshenbang-LM},
  author={IDEA-CCNL},
  year={2021},
  howpublished={\url{https://github.com/IDEA-CCNL/Fengshenbang-LM}},
}