首页 > 解决方案 > 在 python 中运行 Bert Extractive Summarizer 时减少 RAM 使用量

问题描述

在 RAM 受限环境 [978M 的 RAM](使用 en_core_web_sm spaCy 模型)中运行 Bert Extractive Summarizer 时,程序返回Killed作为结果。我已经能够确认 RAM 是可能的罪魁祸首,因为它在返回Killed之前就达到了顶峰。下面是我运行的一个简单测试,它导致Killed作为返回值。

from summarizer import Summarizer

body = '''
The Chrysler Building, the famous art deco New York skyscraper, will be sold for a small fraction of its previous s>The deal, first reported by The Real Deal, was for $150 million, according to a source familiar with the deal.
Mubadala, an Abu Dhabi investment fund, purchased 90% of the building for $800 million in 2008.
Real estate firm Tishman Speyer had owned the other 10%.
The buyer is RFR Holding, a New York real estate company.'''

model = Summarizer()
result = model(body, ratio=0.1)
print(result)

我可以确认代码在 8+ GB RAM 环境中完美运行(它可能在 4+ GB 环境中运行类似,但我尚未确认)。我相信下一步对我来说是减少程序的 RAM 使用量,尽管我不知道该怎么做。是否可以将 RAM 使用量减少到足以让程序在小于 2 GB RAM 的环境中运行?(如果是,怎么做?)

谢谢

标签: pythonspacyram

解决方案


推荐阅读