Spacy(V3.1.1)---lg模型和trf模型的比较

Spacy(V3.1.1)---lg模型和trf模型的比较的图1

1 引言

本文在《关键词提取---PyTextRank和Spacy的工作原理》和《PyTextRank---文本关键字(keywords)的自动取出》的基础之上比较了Spacy的lg模型和trf模型在关键词生成和摘要生成之间的差异,目的是为了区分哪个模型更适合目前的工作。在虚拟环境spacy中进行测试。安装的主要库都是最新版本,包括:

pytextrank V3.2.1 

Spacy V3.1.1

spacy-transformers V1.0.4


2 Spacy模型

最初Spacy只有三个预训练模型: 小型_sm, 中型md和大型_lg,后来增加了Transformers模型trf。spacy-transformers管道使得Spacy能够使用Transformers的BERT, XLNet and GPT-2预训练模型。在目前的V3.1.0(模型还没有更新到V3.1.1)中,en_core_web_lg的文件尺寸是816M, 而zh_core_web_trf的文件尺寸是481M。我们把这两个模型做成一个list同时运行,对结果进行比较。


3 关键词比较

(1) trf模型

trf模型产生的前10个关键词如下(由于在代码中过滤了词汇长度小于10的短语,因此实际只显示出8个):

rock slopes

large open pit slopes

SLOPE ANALYSIS

high mountain slopes

intact rock fracture

large open pits

intact rock bridge length

step-path failure models

Spacy(V3.1.1)---lg模型和trf模型的比较的图2

(2) lg模型

trf模型产生的前10个关键词如下(由于在代码中过滤了词汇长度小于10的短语,因此实际只显示出8个):

rock slopes

large open pit slopes

high mountain slopes

intact rock fracture

large open pits

intact rock bridge length

numerous major structures

pre-existing weakness planes

Spacy(V3.1.1)---lg模型和trf模型的比较的图3

比较结果:尽量这两个模型得出的结果基本相同,但trf比lg稍微合理一些,更符合我们希望得到的特征值。intact rock bridge lengthstep-path failure models显然比numerous major structurespre-existing weakness planes更突出了主题内容。


4 摘要比较

生成摘要有两种方法:第一种方法是抽取式(Extraction),这种算法从整个文本中提取单句,而不以任何方式改变或改动原句。这个过程与提取关键短语非常相似,其目的是为了找到可以作为文本或文件标签的短语或单词。换句话说,抽取式摘要从源文本中复制最重要的句子,并将这些句子放在一起以创建一个摘要。大多数摘要是以这种方式生成的,比如《文本摘要生成的确定过程和随机过程》,《LaxRank抽取式文本总结(Text Summarization)》。第二种方法是抽象式(Abstraction),这种类型的摘要比抽取式摘要先进。它在对原文浓缩的基础之上对原始文本进行了转述。理论上来说,这种总结是我们真正想要的摘要。不过,开发这种类型的总结要困难得多。近年来使用Transformers可以生成这种类型的摘要,例如《生成摘要(Summarization)的新方法》,但是仍然面临着巨大的挑战。就目前而言,大多数摘要生成工具仍然是基于抽取式的,包括PyTextRank。

在这个试验中,我们选取5个句子作为文本总结(limit_sentences=5)。结果显示,trf模型和lg模型产生的前3个句子相同并且顺序都一样:

[1] The importance of step-path failure geometries in the stability of rock slopes has been emphasized in recent research on high mountain slopes and large open pits.(在最近在对高山边坡和大型露天矿边坡的研究中,强调了阶梯状破坏几何形状在岩石边坡稳定性中的重要性。)

[2] Based on the results of the laboratory simulations step-path failure models of large open pit slopes are presented and the influence of intact rock bridge length, step-path overlap and fracture spacing discussed.(基于实验室模拟的结果,提出了大型露天矿边坡的阶梯式破坏模型,并讨论了完整岩桥长度、阶梯重叠和断裂间距的影响。)

[3] This paper documents the use of digital imaging techniques including laser scanning in the characterization of both step-paths and intact rock fracture in rock slopes.(本文记录了包括激光扫描在内的数字成像技术在描述岩石边坡阶梯路径和完整岩石断裂方面的应用。)

不过,第4句和第5句生成的结果不完全相同。

(1) trf模型

[4] Analyses by numerical methods are performed using the Fast Langrangian Analysis of Continua (FLAC), FLAC3D, Universal Distinct Element Code (UDEC), and 3DEC computer codes. (使用FLAC、FLAC3D、UDEC和3DEC进行了数值分析。)

[5] Wedge-shaped blocks often are created in benches by two fractures that the intersect both the bench and slope. (楔形块通常是由两组断裂造成的,这两组断裂与台阶和边坡面相交。)

(2) lg模型

[4] Wedge-shaped blocks often are created in benches by two fractures that the intersect both the bench and slope. (楔形块通常是由两组断裂造成的,这两组断裂与台阶和边坡面相交。)

[5] Site investigation and geological data collection Based solely on limit equilibrium analyses of potential planar, wedge and toppling failures, it was shown that the previously designed bench, inter-ramp and overall slope designs could be continued. (现场调查和地质数据收集:仅根据对潜在的平面、楔形和倾覆破坏的极限平衡分析,表明以前设计的台阶、运输平台和整体边坡设计可以继续进行。)

从上面可以看出,trf模型的[5]与lg模型的[4]相同,剩下的一句从摘要的角度来看,似乎trf模型总结得比lg模型总结得好。


5 结束语

通过比较,发现trf模型和lg模型得出的结果基本相同,但trf模型在某种程度上比lg模型好一些。中文模型(zh_core_web_lg, zh_core_web_trf) 由于目前noun_chunks语法迭代器没有在'zh'上进行改进,例如“露天"和"矿”不能产生出"露天矿“这样的合成词汇,因此本代码还不能处理中文的关键词和摘要提取 。


默认 最新
当前暂无评论,小编等你评论哦!
点赞 评论 收藏
关注