Ancient poetry generation is a text-to-text generation task in natural language processing,which directly converts input keywords or sentences expressing user intentions into ancient poetry.Although deep learning technology has been used at home and abroad to conduct certain research on the generation of ancient poems,the generated poems ignore the importance of style,and there is still space for improvement in contextual coherence and smoothness.This paper combines the attention mechanism and conditional variational encoder to study the keyword generation of ancient poems and Song Ci.The main research contents are as follows:Propose a method of generating ancient poem by given keywords based on the gated attention.In order to improve the smoothness of verses and solve the problem of information loss in long texts processed by cyclic neural network-based encoders.This paper introduces the gated attention component based on the text generation framework of the encoding and decoding structure,which consists of the keyword attention layer,self-attention layer and gated unit.The keyword attention layer extracts the connections between verses and keywords.The self-attention layer extracts the dependence relationship between words in the verse and the internal structural characteristics of the verse.The features extracted from the keyword attention layer and the self-attention layer are passed to the gating unit,and the gating unit filters redundant information.The experimental results show that the method of generating ancient poems based on gated attention proposed in this paper has a certain improvement in the fluent verse compared with the methods already proposed.Propose a method for generating style Song Ci combining multi-attention and conditional variational encoder.In order to improve the coherence of the context,this paper uses the text generation framework of the encoding and decoding structure as the basic model.On this basis,the multi-attention component is introduced to extract the various semantic features of the generated Song Ci sentences and store them in a specific semantic vector.,the decoder generates contextually coherent Song Ci by accessing the semantic vector.At the same time,in order to control the style of Song Ci,a conditional variational autoencoder is introduced,which converts the input text data into continuous latent variables in the hidden space to control the style of Song Ci.The experimental results show that the style Song Ci generation method combining multi-attention and conditional variational encoder proposed in this paper has a certain improvement in style control and context coherence compared with the benchmark method.The main innovations of this paper: on the basis of the encoding and decoding text generation framework,the gating attention component is introduced to improve the sentence smoothness;Introducing multi-attention component to improve the coherence of the context of Song Ci;The conditional variable encoder is introduced to control the style of Song Ci and improve its artistic conception. |