🚀 TrueTeacher
这是一个事实一致性评估模型,在TrueTeacher论文(Gekhman等人,2023)中被提出。该模型旨在解决文本摘要中的事实一致性评估问题,为研究人员提供了一种有效的评估工具。
✨ 主要特性
- 专为评估摘要中的事实一致性而优化。
- 基于T5 - 11B模型微调,结合了多个数据集进行训练。
- 输入格式为 "premise: GROUNDING_DOCUMENT hypothesis: HYPOTHESIS_SUMMARY",并建议设置max_length为2048。
- 能够预测二元标签('1' - 事实一致,'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 = 'the sun is shining'
for hypothesis, expected in [('the sun is out in the sky', '1'),
('the cat is shiny', '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: {premise}')
print(f'hypothesis: {hypothesis}')
print(f'result: {result} (expected: {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 = 'the sun is shining'
for hypothesis, expected in [('the sun is out in the sky', '>> 0.5'),
('the cat is shiny', '<< 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: {premise}')
print(f'hypothesis: {hypothesis}')
print(f'score: {entailment_prob:.3f} (expected: {expected})\n')
📚 详细文档
模型详情
该模型是论文中的主要模型(见表1中的 "T5 - 11B w. ANLI + TrueTeacher full"),基于T5 - 11B (Raffel等人,2020),并使用以下数据集的混合进行微调:
TrueTeacher数据集包含来自CNN/DailyMail数据集训练分割的文章的模型生成摘要 (Hermann等人,2015),这些摘要使用FLAN - PaLM 540B (Chung等人,2022)进行了事实一致性标注。摘要使用在XSum数据集上训练的摘要模型生成 (Narayan等人,2018)。
评估结果
该模型在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许可证的用例。
- 使用英语以外的语言。
🔧 技术细节
该模型的输入格式为 "premise: GROUNDING_DOCUMENT hypothesis: HYPOTHESIS_SUMMARY"。为了适应常见摘要数据集的输入长度,建议将max_length设置为2048。模型预测一个二元标签('1' - 事实一致,'0' - 事实不一致)。
📄 许可证
该模型使用的许可证为cc - by - nc - 4.0。
📚 引用
如果您在研究出版物中使用此模型,请引用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}
}
信息表格
属性 |
详情 |
模型类型 |
基于T5 - 11B微调的事实一致性评估模型 |
训练数据 |
TrueTeacher、ANLI、CNN/DailyMail、XSum |
常用提示信息
⚠️ 重要提示
此模型仅用于英语的研究用途(非商业用途),任何违反cc - by - nc - 4.0许可证的用例以及使用英语以外的语言的使用均超出范围。
💡 使用建议
为适应常见摘要数据集的输入长度,建议将max_length设置为2048。