自回歸式語言XLNet模型的文本生成試驗

1 引言

自回歸式語言生成基于假設:一個詞序列的概率分布可以分解為鄰接的下一個詞條件概率分布的乘積。使用不同的解碼策略,目前產生出許多用于自回歸語言生成的模型,最流行的模型有GPT2, XLNet, OpenAi-GPT, CTRL, TransfoXL, XLM, Bart和T5,對GPT2模型我們已經作了很多探索性的工作:

GeotechSet數據集在GPT2上的訓練過程

GPT2-Large模型解碼方法比較

GPT2-Large模型解碼方法---Top-K and Top-p

新探索---EleutherAI的GPT Neo/GPT-3模型

GeotechSet模型的擴展和優化---集成了aitextgen

開放式文本生成(Open-Ended Text Generation)

同時也對T5模型作了探索性的工作:

生成摘要(Summarization)的新方法

Transformers的Text2TextGeneration管道測試

這個筆記探索另一個模型XLNet。


2 XLNet模型

XLNet來自Google公司Yang等人(2019)的論文《XLNet: Generalized Autoregressive Pretraining for Language Understanding(XLNet: 用于語言理解的廣義自回歸預訓練)》,XLNet是一種無監督的語言表征學習方法,它基于一種新的廣義包絡語言建模目標。XLnet是Transformer-XL模型的一個擴展,使用自回歸方法進行預訓練,在涉及長上下文的語言任務中表現出優異的性能。XLNet在各種下游語言任務上取得了最先進的(SOTA)結果,包括問題回答、自然語言推理、情感分析和文檔排名。

XLNet模型主要有兩個:一個是小模型xlnet-base-cased,另一個是大模型xlnet-large-cased。在本次試驗中,使用了后者xlnet-large-cased。


3 XLNet測試

測試代碼為geotech-XLNnet-Text-Generation.py, 使用下面的段落作為Padding text:

"Shear failure commonly takes place along the joint fissure at the lower part of rock slope, while tensile fracture often occurs at the top part of rock slope. While large-scale stability can be modelled using equivalent rock mass properties, at smaller scale the local variations become significant and failure along the fracture planes is possible. If rock bridge failure represents a brittle failure process, can fracture mechanics principles be used to simulate rock bridge failure better and more realistically? Even when incorporating complex fracture networks, continuum models cannot adequately simulate the relative displacement of blocks, interlocking, internal moments produced by block rotations, and fracturing of the intact rock material. Of interest, Kemeny (2003) recognized the importance of considering the time-dependency of progressive failure of intact rock bridges.". [剪切破壞通常發生在邊坡下部的連接裂縫處,而拉伸斷裂通常發生在巖坡的頂部。雖然大規模的穩定性可以用等效巖體的特性來模擬,但在較小的范圍內,局部的變化變得很明顯,沿斷裂面的破壞是可能的。如果巖橋破壞代表了一種脆性破壞過程,那么能否用斷裂力學原理來更好、更真實地模擬巖橋破壞?即使納入復雜的斷裂網絡,連續體模型也不能充分模擬巖塊的相對位移、互鎖、巖塊旋轉產生的內力矩以及完整巖石材料的斷裂。值得注意的是,Kemeny(2003)認識到考慮完整巖橋的漸進式破壞時間依賴性的重要性"。]

使用"shear failure in rock slope"  作為引導語, 采用beam search=6,生成的文本如下:

"shear failure in rock slope as a mechanism of fracture failure. Shear loss is an important mechanism for fracture loss in rocky slope and is a major cause of erosion and erosion-induced sedimentation. The erosion of rocks and sediments by erosion is the most important source of sedimentary and igneous rocks in the U.S. Geological Survey has estimated that about 1.5 million tons per year are lost to erosion by the United States. The erosion rate is estimated to be about 1% per million years for the entire continental shelf and at 2% per Million Years for all other continental shelves. In addition, erosion rates are estimated at about 2.0 % per 100 m2 of surface area for both continental and sub-continental shelf. "

顯然這個結果不是我們期望的,作為比較,使用gpt2-large模型運行,結果顯示gpt2-large生成的文本質量比XLNet好。


4 結束語

其他人的測試結果顯示XLNet模型并不像模型作者們所說的那樣有著神奇的效果,有的測試顯示Bert模型比XLNet模型的效果好。另外,這個模型得運行速度與gpt2-large的運行速度相比太慢了。不過,XLNet給我們提供了另一條文本生成的途徑。run_language_modeling.py稍作修改便以微調XLNet,但由于本機的GPU只有6G,沒法運行下去,因此目前得不出微調結果。理論上來說,我們可以使用目前的方法訓練出基于GeotechSet的模型。

自回歸式語言XLNet模型的文本生成試驗的圖1


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

TOP