赞
踩
Pegasus模型:基于Transformer,5.68亿参数,它的训练语料包括可以是下面中的其中之一,根据具体摘要任务类型可以选择不同的预训练语料:
Pegasus的模型结构如下:
PEGASUS的基本架构是一个标准的Transformer encoder-decode。在这个例子中,GSG和MLM同时作为预训练目标。原始文本有三句话。一个句子被[MASK1]屏蔽,并用作目标生成文本(GSG)。其他两句话仍然保留在输入中,但是一些词被[MASK2]
(MLM)随机屏蔽了。
个人认为的文本摘要算法效果依次往下递减:
举个例子:Bert Extractive Summarizer 是一个可以轻松使用谷歌 BERT 提取文本摘要的项目,以下是简单示例代码:
from summarizer import Summarizer
body = 'Text body that you want to summarize with BERT'
body2 = 'Something else you want to summarize with BERT'
model = Summarizer()
model(body)
model(body2)
'''
Calculate ROUGE score.
:parameter
:param y_test: string or list
:param predicted: string or list
'''
def evaluate_summary(y_test, predicted):
rouge_score = rouge.Rouge()
scores = rouge_score.get_scores(y_test, predicted, avg=True)
score_1 = round(scores['rouge-1']['f'], 2)
score_2 = round(scores['rouge-2']['f'], 2)
score_L = round(scores['rouge-l']['f'], 2)
print("rouge1:", score_1, "| rouge2:", score_2, "| rougeL:",score_2, "--> avg rouge:",
round(np.mean([score_1,score_2,score_L]), 2))
## Apply the function to predicted
evaluate_summary(dtf_test["y"][i], predicted[i])
The results show that 31% of unigrams (ROUGE-1) and 7% of bigrams (ROUGE-2) are present in both summaries, while the longest common subsequences (ROUGE-L) match by 7%. Overall, the average score is 20%. Please note that ROUGE scores don’t measure how fluent the summary is, for that I usually use the good old human eye.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。