【问题标题】:How to use pipeline from transformers, summarization? Python如何使用来自变压器的管道,总结? Python
【发布时间】:2021-02-18 11:52:01
【问题描述】:

我正在尝试使用来自转换器的管道来总结文本。但我能得到的只是原始文本的截断文本。 我的代码是:

from transformers import pipeline
summarizer = pipeline("summarization")
summarizer("The present invention discloses a pharmaceutical composition comprising therapeutically effective amount of, or an extract consisting essentially therapeutically effective amount of at least one cannabinoid selected from the group consisting of: Cannabidiol (CBD) or a derivative thereof, Tetrahydrocannabinol (THC) or a derivative thereof, and any combination thereof, for use in the treatment of multiple myeloma (MM). The present invention further discloses methods and uses of the aforementioned composition.", 
       min_length=5, max_length=10)

输出是

[{'summary_text': ' The present invention discloses a pharmaceutical'}]

这只是用于分析的文本的开始。我做错了什么?

【问题讨论】:

  • 没什么,这只是你的模型得出的结论。你必须尝试不同的模型和参数才能找到适合你的语料库的东西。

标签: python pipeline huggingface-transformers transformer


【解决方案1】:

您作为参数给出了 max_length=10,这意味着生成的文本的最大长度不应超过 10 个标记。通过增加这个数字,生成的摘要会变得更长。

【讨论】:

  • 我的目标是相反的......也许你可以为我的目的建议我一些其他模型 - 非常简短的文本摘要?
  • 我认为目前没有任何合理的选择可供您使用。除了在检查点上训练自己的模型之外,我想说的是你很不幸......
猜你喜欢
  • 2020-01-13
  • 2019-12-17
  • 2018-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-22
  • 2020-09-06
  • 1970-01-01
相关资源
最近更新 更多