gpt4 book ai didi

python - 使用 BERT 进行文章摘要,其中文章不存在标签或预期输出摘要

转载 作者:行者123 更新时间:2023-11-30 09:58:58 25 4
gpt4 key购买 nike

我正在从事一个项目,但我有一些限制,无法使用提取方法来总结文章,而必须使用 BERT 来完成此任务。如果这是一个标签问题(总结推文、评论、问题),我有训练数据的相应标签,我会使用 BERT 中的向量作为 Keras 嵌入层的输入使用 LSTM 并构建一个带有输入和输出标签的模型。但问题是我必须总结文本而不是那些标记的推文和评论。当我拥有与词汇表相对应的向量时,有什么方法(我确信有,因为我被问得如此具体)可以使用 BERT?

最佳答案

您有很多想要自动总结的文档,但您没有任何训练数据。我假设你的文件是英文的。幸运的是,BERT 是一个预训练的模型,甚至还有专门用于摘要的库并且非常易于使用。您是否尝试过其中一项是否满足您的目标?例如bert-extractive-summarizer :

from summarizer import Summarizer

body = ''' Indian Bank is an Indian state-owned financial services company established in 1907 and headquartered in Chennai, India.
It has 20,924 employees, 2900 branches with 2861 ATMs and 1014 cash deposit machines and is one of the top performing public sector banks in India.
Total business of the bank has touched ₹430,000 crore (US$60 billion) as on 31 March 2019. Bank's Information Systems & Security processes certified with ISO27001:2013 standard and is among very few Banks certified worldwide.
It has overseas branches in Colombo and Singapore including a Foreign Currency Banking Unit at Colombo and Jaffna. It has 227 Overseas Correspondent banks in 75 countries.
Since 1969, the Government of India has owned the bank. As per the announcement made by the Indian Finance Minister Nirmala Sitharaman on 30 August 2019, Indian Bank will be anchor bank for the Kolkata-based Allahabad Bank, and this merger is expected to come on force from 1 April 2020, making it the seventh largest bank in the country. '''


model = Summarizer()
result = model(body, min_length=60)
full = ''.join(result)
print(full)

输出:

Indian Bank is an Indian state-owned financial services company established in 1907 and headquartered in Chennai, India. Total business of the bank has touched ₹430,000 crore (US$60 billion) as on 31 March 2019.

关于python - 使用 BERT 进行文章摘要,其中文章不存在标签或预期输出摘要,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59828517/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com