【问题标题】:KeyError: "Unknown task summarization, available tasks are ['feature-extraction', 'sentiment-analysis', 'ner', 'question-answering', 'fill-mask']"KeyError:“未知任务摘要,可用任务是 ['feature-extraction', 'sentiment-analysis', 'ner', 'question-answering', 'fill-mask']”
【发布时间】:2020-11-12 23:22:23
【问题描述】:

我正在尝试对该数据框中的列进行文本摘要。我按照本网站 (https://towardsdatascience.com/summarization-of-covid-research-papers-using-bart-model-5b109a6669a6) 中提到的步骤操作,但出现此错误

KeyError: "未知任务摘要,可用任务为 ['feature-extraction', 'sentiment-analysis', 'ner', 'question-answering', 'fill-mask']"

Screenshot of Error

【问题讨论】:

    标签: python nlp summarization


    【解决方案1】:

    你应该更新你的转换器库:

    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)
    

    【讨论】:

      猜你喜欢
      • 2012-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-17
      • 1970-01-01
      相关资源
      最近更新 更多