KeyError:“未知任务摘要,可用任务为['featureextraction'、'ImportionalAnalysis'、'ner'、'questionanswering'、'fillmask']。”

2024-04-30 06:37:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试对数据框中的一列进行文本摘要。我遵循了这个站点(https://towardsdatascience.com/summarization-of-covid-research-papers-using-bart-model-5b109a6669a6)中提到的步骤,但是我得到了这个错误

KeyError:“未知任务摘要,可用任务有[‘特征提取’、‘情感分析’、‘ner’、‘问答’、‘填充掩码’]”“

Screenshot of Error


Tags: of数据https文本commodel站点步骤
1条回答
网友
1楼 · 发布于 2024-04-30 06:37:40

您应该更新变压器库:

pip install -U transformers

from transformers import pipeline

# use bart in pytorch
summarizer = pipeline("summarization")
summarizer("An apple a day, keeps the doctor away", min_length=5, max_length=20)

# use t5 in tf
summarizer = pipeline("summarization", model="t5-base", tokenizer="t5-base", framework="tf")
summarizer("An apple a day, keeps the doctor away", min_length=5, max_length=20)

相关问题 更多 >