许可协议: cc-by-nc-4.0
语言:
- 英文
数据集:
- google/trueteacher
- anli
- cnn_dailymail
标签:
- 自然语言推理
- 新闻文章摘要
TrueTeacher
这是一个事实一致性评估模型,由TrueTeacher论文(Gekhman等,2023年)提出。
模型详情
该模型专为评估摘要中的事实一致性而优化。
它是论文中的主要模型(参见表1中的"T5-11B w. ANLI + TrueTeacher full"),基于T5-11B(Raffel等,2020年),并通过以下数据集的混合进行微调:
TrueTeacher数据集包含对CNN/DailyMail数据集(Hermann等,2015年)训练集部分文章生成的模型摘要,这些摘要使用FLAN-PaLM 540B(Chung等,2022年)进行了事实一致性标注。摘要由在XSum数据集(Narayan等,2018年)上训练的摘要模型生成。
模型的输入格式为:"premise: 基础文档 hypothesis: 假设摘要"。为适应常见摘要数据集的输入长度,建议将max_length设置为2048。
模型预测一个二元标签('1'表示事实一致,'0'表示事实不一致)。
评估结果
该模型在TRUE基准测试(Honovich等,2022年)的摘要子集上取得了以下ROC AUC结果:
MNBM |
QAGS-X |
FRANK |
SummEval |
QAGS-C |
平均 |
78.1 |
89.4 |
93.6 |
88.5 |
89.4 |
87.8 |
预期用途
该模型旨在用于非商业的英文研究用途。
推荐的使用场景是评估摘要中的事实一致性。
超出范围的使用
任何违反cc-by-nc-4.0许可协议的用途。
在英语以外的语言中使用。
使用示例
分类
from transformers import T5ForConditionalGeneration
from transformers import T5Tokenizer
model_path = 'google/t5_11b_trueteacher_and_anli'
tokenizer = T5Tokenizer.from_pretrained(model_path)
model = T5ForConditionalGeneration.from_pretrained(model_path)
premise = '阳光明媚'
for hypothesis, expected in [('太阳挂在天空', '1'),
('猫咪闪闪发光', '0')]:
input_ids = tokenizer(
f'premise: {premise} hypothesis: {hypothesis}',
return_tensors='pt',
truncation=True,
max_length=2048).input_ids
outputs = model.generate(input_ids)
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(f'前提: {premise}')
print(f'假设: {hypothesis}')
print(f'结果: {result} (预期: {expected})\n')
评分
from transformers import T5ForConditionalGeneration
from transformers import T5Tokenizer
import torch
model_path = 'google/t5_11b_trueteacher_and_anli'
tokenizer = T5Tokenizer.from_pretrained(model_path)
model = T5ForConditionalGeneration.from_pretrained(model_path)
premise = '阳光明媚'
for hypothesis, expected in [('太阳挂在天空', '>> 0.5'),
('猫咪闪闪发光', '<< 0.5')]:
input_ids = tokenizer(
f'premise: {premise} hypothesis: {hypothesis}',
return_tensors='pt',
truncation=True,
max_length=2048).input_ids
decoder_input_ids = torch.tensor([[tokenizer.pad_token_id]])
outputs = model(input_ids=input_ids, decoder_input_ids=decoder_input_ids)
logits = outputs.logits
probs = torch.softmax(logits[0], dim=-1)
one_token_id = tokenizer('1').input_ids[0]
entailment_prob = probs[0, one_token_id].item()
print(f'前提: {premise}')
print(f'假设: {hypothesis}')
print(f'得分: {entailment_prob:.3f} (预期: {expected})\n')
引用
如果您在研究中使用了此模型,请引用TrueTeacher论文(使用下面的bibtex条目),以及上述提到的ANLI、CNN/DailyMail、XSum、T5和FLAN论文。
@misc{gekhman2023trueteacher,
title={TrueTeacher: Learning Factual Consistency Evaluation with Large Language Models},
author={Zorik Gekhman and Jonathan Herzig and Roee Aharoni and Chen Elkind and Idan Szpektor},
year={2023},
eprint={2305.11171},
archivePrefix={arXiv},
primaryClass={cs.CL}
}