python - 长文档的 Huggingface 文档摘要

标签 python huggingface-transformers

我希望摘要任务通常假定长文档。但是,遵循文档 here ,我所做的任何简单摘要调用都表明我的文档太长:

>>> summarizer = pipeline("summarization")
>>> summarizer(fulltext)
Token indices sequence length is longer than the specified maximum sequence length for this model (5620 > 1024). Running this sequence through the model will result in indexing errors

>>> summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
>>> summary = summarizer(fulltext)
Token indices sequence length is longer than the specified maximum sequence length for this model (8084 > 1024). Running this sequence through the model will result in indexing errors

>>> summarizer = pipeline("summarization", model="t5-base", tokenizer="t5-base")
>>> summary = summarizer(fulltext)
Token indices sequence length is longer than the specified maximum sequence length for this model (5971 > 512). Running this sequence through the model will result in indexing errors

哪种型号或配置选择最能实现自动化?我已阅读其他问题 suggesting manually chunking the datatruncation ,但边界和 block 长度的选择似乎会对摘要产生影响。任意长文档的最佳实践是什么? (无界会很棒,但假设至少有 50,000 个 token 。)

最佳答案

我假设最小标记长度为 50k 意味着您正在尝试总结像小说一样大的东西。不幸的是,我们还没有一个可以同时处理这么多数据的模型。这主要是因为此类模型的内存占用非常高,无法在生产中使用。但是 pegasus(google)、LongformerReformer 都是总结长文档的可行选项。仍在继续研究创建可以在不消耗大量资源的情况下处理更大序列的模型。例如,reformer 本身经过高度优化,可以处理大量 token https://huggingface.co/blog/reformer .到目前为止,最佳实践是“分而治之”的方法。即,将您的数据分 block ,保持最大长度作为引用。您甚至可以在迭代中执行此操作,直到达到指定的摘要长度。您还可以探索不同的摘要方法,例如抽取式摘要和抽象式摘要,并利用您的创造力将这些技术组合起来,例如抽取式摘要后抽象式。

关于python - 长文档的 Huggingface 文档摘要,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70309921/

相关文章:

nlp - Huggingface BERT 模型的预训练层是否卡住?

python程序之间简单的python通信?

bert-language-model - 来自转换器的 BERT 句子嵌入

image-processing - 我们如何通过拥抱人脸库获得多模态模型的注意力分数?

pytorch - 预训练变压器模型的配置更改

nlp - 如何使用 Transformers 库从 XLNet 的输出中获取单词

python - 如何显示从 pycharm 中导入的库创建的对象的自动完成?

python - 在 Python 单元测试和主代码中访问资源文件

python - 保存包含阿拉伯语的 Python 2.7 脚本

Python:比较两组并将结果写入第三组