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'上進行改進,例如“露天"和"礦”不能產生出"露天礦“這樣的合成詞匯,因此本代碼還不能處理中文的關鍵詞和摘要提取 。


登錄后免費查看全文
立即登錄
App下載
技術鄰APP
工程師必備
  • 項目客服
  • 培訓客服
  • 平臺客服

TOP