WO2022121165A1 - 长文本生成方法、装置、设备及存储介质 - Google Patents

长文本生成方法、装置、设备及存储介质 Download PDF

Info

Publication number
WO2022121165A1
WO2022121165A1 PCT/CN2021/083496 CN2021083496W WO2022121165A1 WO 2022121165 A1 WO2022121165 A1 WO 2022121165A1 CN 2021083496 W CN2021083496 W CN 2021083496W WO 2022121165 A1 WO2022121165 A1 WO 2022121165A1
Authority
WO
WIPO (PCT)
Prior art keywords
vector
short
preset
short sentence
sentences
Prior art date
Application number
PCT/CN2021/083496
Other languages
English (en)
French (fr)
Inventor
回艳菲
王健宗
吴天博
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2022121165A1 publication Critical patent/WO2022121165A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/284Lexical analysis, e.g. tokenisation or collocates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/25Fusion techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/151Transformation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks

Definitions

  • the present application relates to the field of artificial intelligence, and in particular, to a long text generation method, apparatus, device and storage medium.
  • the traditional text generation method can be divided into three steps: first, content planning; second, sentence planning; and third, sentence realization. These three steps implement what and how to generate content.
  • the inventor realized that the content generated in the traditional method of generating text and how to generate the corresponding content are obtained separately according to different steps, resulting in the incoherence of the semantics of the context in the generated long text and the lack of inter-sentence. Relevance.
  • the main purpose of this application is to solve the technical problem that the existing text generation effect is not good.
  • a first aspect of the present application provides a long text generation method, the long text generation method comprising:
  • a second aspect of the present application provides a long text generation device, the long text generation device comprising: a memory, a processor, and a long text generation program stored on the memory and executable on the processor, the When the processor executes the long text generation program, the following steps are implemented:
  • a third aspect of the present application provides a storage medium, a computer-readable storage medium, where computer instructions are stored in the computer-readable storage medium, and when the computer instructions are executed on a computer, the computer is caused to perform the following steps:
  • a fourth aspect of the present application provides a long text generating device, the long text generating device comprising:
  • an acquisition module used for acquiring multiple keywords to be processed, and inputting the keywords into a preset vector encoder for vector conversion to obtain word vectors;
  • a processing module used for splicing the word vector and the preset variable to obtain an initial vector, and inputting the initial vector into a preset short sentence generator to generate short sentences to obtain a plurality of first short sentences;
  • the conversion module is used to perform an average pooling operation on the first short sentences respectively to obtain a plurality of characteristic short sentence vectors, and input the characteristic short sentence vectors into a preset short sentence encoder for encoding conversion to obtain a short sentence. sentence encoding;
  • the extraction module is used for splicing the short sentence code and the initial vector to obtain a first fusion vector, and inputting the first fusion vector and the preset random variable into a preset text correlator for feature extraction to obtain a contextual correlation vector ;
  • the generating module is used for inputting the first short sentences, the random variable and the context correlation vector into a preset long text generator for text generation to obtain a long text.
  • the long text in order to generate semantically coherent long text, the long text can be regarded as the splicing of multiple short sentences, and then the short sentences can be regarded as the splicing of multiple words.
  • the keywords are converted into vectors to obtain word vectors, and random variables are added when the keywords are selected, so that the generated short sentences are quite different each time, thereby greatly increasing the diversity of sentence patterns.
  • the corresponding first short sentence is generated through the word vector, and then the first short sentence is encoded to obtain the short sentence encoding, and the short sentence encoding, the first short sentence and the random variable are input into the long text generator to generate multiple second short sentences. , and splicing multiple second short sentences in turn to obtain long text.
  • the present application uses multiple keywords as the basis for generating long texts, which improves the coherence of long texts and provides better text richness.
  • FIG. 1 is a schematic diagram of a first embodiment of a method for generating long text in an embodiment of the present application
  • FIG. 2 is a schematic diagram of a second embodiment of a method for generating long text in an embodiment of the present application
  • FIG. 3 is a schematic diagram of an embodiment of a long text generating apparatus in an embodiment of the present application.
  • FIG. 4 is a schematic diagram of an embodiment of a long text generating device in an embodiment of the present application.
  • Embodiments of the present application provide a long text generation method, apparatus, device, and storage medium.
  • the terms “first”, “second”, “third”, “fourth”, etc. (if any) in the description and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It is to be understood that data so used can be interchanged under appropriate circumstances so that the embodiments described herein can be practiced in sequences other than those illustrated or described herein.
  • the first embodiment of the method for generating long text in the embodiment of the present application includes:
  • the execution body of the present application may be a long text generating device, and may also be a terminal or a server, which is not specifically limited here.
  • the embodiments of the present application take the server as an execution subject as an example for description.
  • the vector encoder includes multiple bidirectional GRU neural networks.
  • the bidirectional GRU neural network is divided into two cells, one is a forward cell and the other is a reverse cell.
  • the forward cell is actually a normal GRU.
  • One by one is fed to the forward cell, and the reverse is to reverse the data and feed it to the reverse cell one by one, and finally put the corresponding hidden layers together to form a bidirectional GRU.
  • Bidirectional GRU means that the variables in the hidden layer part are doubled, half for forward calculation and half for reverse calculation.
  • the keywords are converted into vectors through the bidirectional GRU neural network, and the word vector obtained is that the keywords are represented as vectors, and the GRU neural network is used to represent each word as a long vector.
  • apple [0, 0, 0, 1, 0, 0, 0, 0, 0, ...].
  • the vector encoder includes multiple bidirectional GRU neural networks, and the multiple keywords to be processed are obtained, and the keywords are input into a preset vector encoder for vector conversion.
  • the word vector obtained includes:
  • the forward hidden state vector and the backward hidden state vector are spliced to obtain a word vector.
  • the bidirectional GRU neural network outputs a forward hidden state vector forward and a backward hidden state vector backward, and splices the forward hidden state vector and the backward hidden state vector to obtain a word vector.
  • the forward hidden state vector is [0, 1, 2]
  • the backward hidden state vector is [1, 0, 0]
  • the word vector obtained after splicing is [0, 1, 2, 1, 0, 0] .
  • the short sentence generator includes multiple one-way GRU neural networks, and the one-way GRU neural network has only one cell.
  • the hidden layer in the cell is updated.
  • GRU outputs a corresponding short sentence.
  • the short sentence generator determines which keywords need to be said in each sentence in the long text.
  • Each GRU output once represents a sentence, and the output contains information about which keywords are used in the sentence.
  • the short sentence generated by the first GRU is: I love Beijing.
  • the phrase generated by the second GRU is: I love my motherland.
  • the key words are: Beijing, the motherland.
  • an average value is calculated for all words in the short sentences output by each GRU output.
  • a feature vector with a dimension equal to the number of categories is obtained, and then directly input to the softmax layer for softmax operation. , to obtain multiple feature short sentence vectors.
  • the average pooling operation can better match keywords with short sentences, reducing the amount of parameters.
  • the average pooling layer has no parameters, which can prevent overfitting at this layer and integrate global spatial information.
  • the short-sentence encoder includes multiple GRU neural networks, which encode multiple input feature short-sentence vectors, and the short-sentence encoder finally outputs an overall short-sentence encoding.
  • the average pooling operation is performed on the first short sentences respectively to obtain a plurality of characteristic short sentence vectors including:
  • a plurality of characteristic short sentence vectors are generated.
  • the average pooling is to average the keywords in the short sentences output by each GRU, and then obtain a new 1*1 feature vector.
  • the first short sentence is [I, love, Beijing, Beijing]
  • the obtained feature vector is [2, 3, 1, 1].
  • the short-sentence encoder includes multiple second one-way GRU neural networks, and the feature short-sentence vectors are input into the preset short-sentence encoder for encoding conversion to obtain a short sentence.
  • Sentence encoding includes:
  • the second one-way GRU neural network encodes the feature vector output by the average pooling to obtain short sentence encoding.
  • the resulting short sentence is encoded as [2,3,5,4,0,0,0,0].
  • the key information included in the short sentence encoding is: Beijing, China.
  • the text correlator includes a plurality of one-way GRU neural networks, each GRU neural network outputs a corresponding context correlation vector, and the text correlator performs feature extraction by sub-sampling the keywords, so that the generated short sentences are rich The performance is better, because the short sentences generated each time are quite different, and there will not be a lot of repeated fragments.
  • the latent variable is a newly created variable used to control which words should be included in the generated sentence.
  • the sentence associator includes a plurality of third one-way GRU neural networks
  • the short sentence code and the initial vector are spliced to obtain a first fusion vector
  • the The first fusion vector and the preset random variable are input into the preset text correlator for feature extraction
  • the obtained context correlation vector includes:
  • the short sentence code and the initial vector are spliced to obtain a first fusion vector.
  • the first fusion vector is [0,2,1,0,1,0,1, 2].
  • the long text generator includes multiple one-way GRU neural networks, wherein each GRU neural network outputs a short sentence, and the first short sentence, the second short sentence... The short sentences are connected in turn to obtain a long text.
  • the long text generator includes a plurality of fourth one-way GRU neural networks, and the first short sentence, the random variable and the contextual correlation vector are input into the pre- Set the long text generator to generate text, and get the long text including:
  • the second short sentences are sequentially spliced to obtain a long text.
  • the first short sentences, the random variables and the context correlation vectors are spliced to obtain a second fusion vector.
  • the second fusion vector is input into the fourth one-way GRU neural network, each GRU neural network in the fourth one-way GRU neural network outputs a short sentence, and finally the short sentences are spliced in turn to obtain a long text.
  • S1 I love China.
  • S2 I love Beijing.
  • S3 I love Tiananmen Square.
  • the long text obtained by splicing is: I love China, I love Beijing, and I love Tiananmen.
  • the long text in order to generate semantically coherent long text, the long text can be regarded as the splicing of multiple short sentences, and then the short sentences can be regarded as the splicing of multiple words.
  • the keywords are converted into vectors to obtain word vectors, and random variables are added when the keywords are selected, so that the short sentences generated are quite different each time, thus greatly increasing the diversity of sentence patterns.
  • the corresponding first short sentence is generated through the word vector, and then the first short sentence is encoded to obtain the short sentence encoding, and the short sentence encoding, the first short sentence and the random variable are input into the long text generator to generate multiple second short sentences. , and splicing multiple second short sentences in turn to obtain long text.
  • the present application uses multiple keywords as the basis for generating long texts, which improves the coherence of long texts and provides better text richness.
  • the second embodiment of the long text generation method in the embodiment of the present application includes:
  • the rest function is:
  • is the sigmoid function, which is used to map the data to the (0,1) interval
  • w c and b c represent the weight and bias of the fully connected layer of the short sentence generator, respectively, stands for GRU neural network.
  • the size setting can make the generated sentences different in length, if After reaching the preset threshold, it stops generating short sentences.
  • the short sentence generator determines that each sentence in the long text needs to contain keywords.
  • Each GRU neural network outputs a sentence once, and the output short sentence contains information about which keywords are used in the sentence.
  • the multiple outputs of multiple GRU neural networks represent that the generated long text will contain multiple sentences.
  • the long text generation is divided into several short text generation, and then keywords are used to generate the short text, while ensuring the semantic coherence of the short text before and after.
  • the short sentence generator generates multiple short sentences containing keywords, which can not only ensure the semantic smoothness of each phrase, but also improve the coherence of the entire long text.
  • the setting of the pause command is added.
  • the text length can be effectively controlled. When the value exceeds the preset threshold, the generation of short sentences is stopped, so that the length of the generated text is within a controllable range.
  • an embodiment of the apparatus for generating long text in the embodiment of the present application includes:
  • the obtaining module 301 is used for obtaining a plurality of keywords to be processed, and inputting the keywords into a preset vector encoder for vector conversion to obtain word vectors;
  • the processing module 302 is used for splicing the word vector and the preset variable to obtain an initial vector, and inputting the initial vector into a preset short sentence generator to generate short sentences to obtain a plurality of first short sentences;
  • the conversion module 303 is configured to perform an average pooling operation on the first short sentences respectively to obtain a plurality of characteristic short sentence vectors, and input the characteristic short sentence vectors into a preset short sentence encoder for encoding conversion to obtain short sentence encoding;
  • the extraction module 304 is used for splicing the short sentence code and the initial vector to obtain a first fusion vector, and inputting the first fusion vector and the preset random variable into a preset text correlator for feature extraction to obtain contextual correlation vector;
  • the generating module 305 is configured to input the first short sentences, the random variables and the context-related vectors into a preset long text generator for text generation to obtain long texts.
  • the vector encoder includes multiple bidirectional GRU neural networks, and the obtaining module 301 is specifically configured to:
  • the forward hidden state vector and the backward hidden state vector are spliced to obtain a word vector.
  • the short sentence generator includes a plurality of first one-way GRU neural networks, and the processing module 302 is specifically configured to:
  • stop generating short sentences and use the short sentences obtained before stopping generation as the output of the first one-way GRU neural network to obtain a plurality of first short sentences;
  • the output of the first one-way GRU neural network is described to obtain a plurality of first short sentences.
  • the conversion module 303 further includes an operation unit 3031, and the operation unit 3031 is specifically used for:
  • the short sentence encoder includes a plurality of second one-way GRU neural networks
  • the conversion module 303 further includes an encoding unit 3032
  • the encoding unit 3032 is specifically used for:
  • the sentence associator includes a plurality of third one-way GRU neural networks
  • the extraction module 304 is specifically configured to:
  • the long text generator includes a plurality of fourth one-way GRU neural networks, and the generating module 305 is specifically configured to:
  • the second short sentences are sequentially spliced to obtain a long text.
  • the long text in order to generate semantically coherent long text, the long text can be regarded as the splicing of multiple short sentences, and then the short sentences can be regarded as the splicing of multiple words.
  • the keywords are converted into vectors to obtain word vectors, and random variables are added when the keywords are selected, so that the short sentences generated are quite different each time, thus greatly increasing the diversity of sentence patterns.
  • the corresponding first short sentence is generated through the word vector, and then the first short sentence is encoded to obtain the short sentence encoding, and the short sentence encoding, the first short sentence and the random variable are input into the long text generator to generate multiple second short sentences. , and splicing multiple second short sentences in turn to obtain long text.
  • the present application uses multiple keywords as the basis for generating long texts, which improves the coherence of long texts and provides better text richness.
  • FIG. 3 above describes the long text generating apparatus in the embodiment of the present application in detail from the perspective of modular functional entities, and the following describes the long text generating device in the embodiment of the present application in detail from the perspective of hardware processing.
  • FIG. 4 is a schematic structural diagram of a long text generating device provided by an embodiment of the present application.
  • the long text generating device 400 may vary greatly due to different configurations or performances, and may include one or more central processing units (central processing units). , CPU) 410 (eg, one or more processors) and memory 420, one or more storage media 430 (eg, one or more mass storage devices) storing application programs 433 or data 432.
  • the memory 420 and the storage medium 430 may be short-term storage or persistent storage.
  • the program stored in the storage medium 430 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the long text generating apparatus 400 .
  • the processor 410 may be configured to communicate with the storage medium 430 to execute a series of instruction operations in the storage medium 430 on the long text generating device 400 .
  • the long text generation device 400 may also include one or more power supplies 440, one or more wired or wireless network interfaces 450, one or more input and output interfaces 460, and/or, one or more operating systems 431, such as Windows Server , Mac OS X, Unix, Linux, FreeBSD and more.
  • operating systems 431, such as Windows Server , Mac OS X, Unix, Linux, FreeBSD and more such as Windows Server , Mac OS X, Unix, Linux, FreeBSD and more.
  • the present application also provides a long text generation device, the long text generation device includes a memory and a processor, the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor is caused to execute the above embodiments.
  • the present application also provides a computer-readable storage medium.
  • the computer-readable storage medium may be a non-volatile computer-readable storage medium.
  • the computer-readable storage medium may also be a volatile computer-readable storage medium.
  • the computer-readable storage medium stores instructions that, when executed on a computer, cause the computer to perform the steps of the long text generation method.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer-readable storage medium.
  • the technical solutions of the present application can be embodied in the form of software products in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, and the computer software products are stored in a storage medium , including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk and other media that can store program codes .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • Health & Medical Sciences (AREA)
  • Data Mining & Analysis (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Evolutionary Computation (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Evolutionary Biology (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Machine Translation (AREA)

Abstract

一种长文本生成方法、装置、设备及存储介质。该方法包括:获取待处理的多个关键词并将各关键词输入预置向量编码器进行向量转换,得到词向量(101);拼接词向量和预置变量并将得到的初始向量输入预置短句生成器进行短句生成,得到多个第一短句(102);分别对各第一短句进行平均池化运算并将得到的多个特征短句向量输入预置短句编码器进行编码转换,得到短句编码(103);将短句编码、初始向量和预置随机变量输入预置文本关联器进行特征提取,得到上下文关联向量(104);将各第一短句、随机变量和上下文关联向量输入预置长文本生成器进行文本生成,得到长文本(105)。该方法能够将生成长文本的上下文关联起来,提高了长文本的连贯性。

Description

长文本生成方法、装置、设备及存储介质
本申请要求于2020年12月10日提交中国专利局、申请号为202011432584.1、发明名称为“长文本生成方法设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中。
技术领域
本申请涉及人工智能领域,尤其涉及一种长文本生成方法、装置、设备及存储介质。
背景技术
随着人工智能的高速发展,人工智能技术被广泛用于各个行业,同时也带动了文本生成领域的发展,利用数据直接生成文本越来越多。传统的文本生成方法可以分为三个步骤:一、内容规划;二、句子规划;三、句子实现。这三个步骤实现了该生成什么内容以及该如何生成内容。
然而,发明人意识到传统生成文本的方法中生成的内容和如何生成对应的内容,这两个部分是根据不同步骤分别去获得,导致生成的长文本中前后文的语义不连贯,句子间缺乏关联性。
发明内容
本申请的主要目的在于解决现有文本生成效果不佳的技术问题。
本申请第一方面提供了一种长文本生成方法,所述长文本生成方法包括:
获取待处理的多个关键词,并将所述各关键词输入预置向量编码器进行向量转换,得到词向量;
拼接所述词向量和预置变量,得到初始向量,并将所述初始向量输入预置短句生成器进行短句生成,得到多个第一短句;
分别对所述各第一短句进行平均池化运算,得到多个特征短句向量,并将所述各特征短句向量输入预置短句编码器进行编码转换,得到短句编码;
拼接所述短句编码和所述初始向量,得到第一融合向量,并将所述第一融合向量和预置随机变量输入预置文本关联器进行特征提取,得到上下文关联向量;
将所述各第一短句、所述随机变量和所述上下文关联向量输入预置长文本生成器进行文本生成,得到长文本。
本申请第二方面提供了一种长文本生成设备,所述长文本生成设备包括:存储器、处理器以及存储在所述存储器上并可在所述处理器上运行的长文本生成程序,所述处理器执行所述长文本生成程序时实现如下步骤:
获取待处理的多个关键词,并将所述各关键词输入预置向量编码器进行向量转换,得到词向量;
拼接所述词向量和预置变量,得到初始向量,并将所述初始向量输入预置短句生成器进行短句生成,得到多个第一短句;
分别对所述各第一短句进行平均池化运算,得到多个特征短句向量,并将所述各特征短句向量输入预置短句编码器进行编码转换,得到短句编码;
拼接所述短句编码和所述初始向量,得到第一融合向量,并将所述第一融合向量和预置随机变量输入预置文本关联器进行特征提取,得到上下文关联向量;
将所述各第一短句、所述随机变量和所述上下文关联向量输入预置长文本生成器进行文本生成,得到长文本。
本申请第三方面提供了一种存储介质,一种计算机可读存储介质,所述计算机可读存储介质中存储计算机指令,当所述计算机指令在计算机上运行时,使得计算机执行如下步骤:
获取待处理的多个关键词,并将所述各关键词输入预置向量编码器进行向量转换,得到词向量;
拼接所述词向量和预置变量,得到初始向量,并将所述初始向量输入预置短句生成器进行短句生成,得到多个第一短句;
分别对所述各第一短句进行平均池化运算,得到多个特征短句向量,并将所述各特征短句向量输入预置短句编码器进行编码转换,得到短句编码;
拼接所述短句编码和所述初始向量,得到第一融合向量,并将所述第一融合向量和预置随机变量输入预置文本关联器进行特征提取,得到上下文关联向量;
将所述各第一短句、所述随机变量和所述上下文关联向量输入预置长文本生成器进行文本生成,得到长文本。
本申请第四方面提供了一种长文本生成装置,所述长文本生成装置包括:
获取模块,用于获取待处理的多个关键词,并将所述各关键词输入预置向量编码器进行向量转换,得到词向量;
处理模块,用于拼接所述词向量和预置变量,得到初始向量,并将所述初始向量输入预置短句生成器进行短句生成,得到多个第一短句;
转换模块,用于分别对所述各第一短句进行平均池化运算,得到多个特征短句向量,并将所述各特征短句向量输入预置短句编码器进行编码转换,得到短句编码;
提取模块,用于拼接所述短句编码和所述初始向量,得到第一融合向量,并将所述第一融合向量和预置随机变量输入预置文本关联器进行特征提取,得到上下文关联向量;
生成模块,用于将所述各第一短句、所述随机变量和所述上下文关联向量输入预置长文本生成器进行文本生成,得到长文本。
本申请提供的技术方案中,为了生成语义连贯的长文本可以将长文本看作多个短句的拼接,再将短句看作多个单词的拼接,具体为:获取多个关键词并对所述关键词进行向量转换,得到词向量,关键词选取时添加了随机变量,这样生成的短句每次都有较大的不同,从而大大增加了句式的多样性。然后通过词向量生成对应的第一短句,再对第一短句进行编码,得到短句编码,将短句编码和第一短句和随机变量输入长文本生成器生成多个第二短句,并依次拼接多个第二短句得到长文本。本申请将多个关键词作为生成长文本的基础,提高了长文本的连贯性而且文本的丰富性较好。
附图说明
图1为本申请实施例中长文本生成方法的第一个实施例示意图;
图2为本申请实施例中长文本生成方法的第二个实施例示意图;
图3为本申请实施例中长文本生成装置的一个实施例示意图;
图4为本申请实施例中长文本生成设备的一个实施例示意图。
具体实施方式
本申请实施例提供了一种长文本生成方法、装置、设备及存储介质。本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的实施例能够以除了在这里图示或描述的内容以外的顺序实施。此外,术语“包括”或“具有”及其任何变形,意图在于覆盖不排他的包含, 例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
为便于理解,下面对本申请实施例的具体流程进行描述,请参阅图1,本申请实施例中长文本生成方法的第一个实施例包括:
101、获取待处理的多个关键词,并将所述各关键词输入预置向量编码器进行向量转换,得到词向量;
可以理解的是,本申请的执行主体可以为长文本生成装置,还可以是终端或者服务器,具体此处不做限定。本申请实施例以服务器为执行主体为例进行说明。
本实施例中,向量编码器包括多个双向GRU神经网络,双向GRU神经网络分为两个cell,一个是前向的cell一个是逆向的cell,前向的cell其实就是正常的GRU,将数据一个个喂给正向cell,逆向则是将数据倒过来再一个个喂给逆向cell,最后将对应的隐藏层放在一起就是双向GRU。双向GRU就是隐藏层部分的变量变为双倍,一半给正向计算,一半给逆向计算。
本实施例中,将关键词通过双向GRU神经网络进行向量转换,得到的词向量是将关键词表示为向量,利用GRU神经网络把每个词表示为一个长向量。
例如:苹果[0,0,0,1,0,0,0,0,0,……]。
可选的,在一实施例中,所述向量编码器包括多个双向GRU神经网络,所述获取待处理的多个关键词,并将所述各关键词输入预置向量编码器进行向量转换,得到词向量包括:
获取待处理的多个关键词;
将所述关键词输入所述双向GRU神经网络进行向量转换,得到前向隐藏状态向量和后向隐藏状态向量;
对所述前向隐藏状态向量和后向隐藏状态向量进行拼接,得到词向量。
本实施例中,双向GRU神经网络的前向输出一个前向隐藏状态向量,后向输出一个后向隐藏状态向量,对前向隐藏状态向量和后向隐藏状态向量进行拼接,得到词向量。
例如:前向隐藏状态向量为[0,1,2],后向隐藏状态向量为[1,0,0],拼接后得到的词向量为[0,1,2,1,0,0]。
102、拼接所述词向量和预置变量,得到初始向量,并将所述初始向量输入预置短句生成器进行短句生成,得到多个第一短句;
本实施例中,短句生成器包括多个单向GRU神经网络,单向GRU神经网络就只有一个cell,通过每步接收上一步GRU处理后的数据,从而更新cell里的隐藏层,每一个GRU输出一个对应的短句。短句生成器决定了长文本中的每个句子需要说哪些关键词,每个GRU输出一次就代表这是一句话,输出包含了这句话用到了哪些关键词的信息。
例如:第一个GRU生成的短句为:我爱北京。第二个GRU生成的短句为:我爱祖国。其中关键词为:北京、祖国。
103、分别对所述各第一短句进行平均池化运算,得到多个特征短句向量,并将所述各特征短句向量输入预置短句编码器进行编码转换,得到短句编码;
本实施例中,对于输出的每一个GRU输出的短句中的所有词计算一个平均值,经过平均池化之后就得到一个维度等于类别数的特征向量,然后直接输入到softmax层,进行softmax运算,得到多个特征短句向量。平均池化运算可以更好的将关键词与短句对应起来,降低了参数量,平均池化层没有参数,可防止在该层过拟合,并且整合了全局空间信息。本实施例中,短句编码器包括多个GRU神经网络,对输入的多个特征短句向量进行编码,短句编码器最后输出一个整体的短句编码。
可选的,在一实施例中,所述分别对所述各第一短句进行平均池化运算,得到多个特征短句向量包括:
调用预置平均池化函数,分别对所述各第一短句计算平均值,得到各短句对应的多个特征值;
根据所述各短句对应的多个特征值,生成多个特征短句向量。
本实施例中,平均池化就是对每一个GRU输出的短句中的关键词求平均值,然后得到一个新的1*1的特征向量。
例如:第一短句为[我,爱,北,京],经过全局平均池化之后,得到的特征向量为[2,3,1,1]。
可选的,在一实施例中,所述短句编码器包括多个第二单向GRU神经网络,所述将所述各特征短句向量输入预置短句编码器进行编码转换,得到短句编码包括:
将所述各特征短句向量输入所述第二单向GRU神经网络;
通过所述第二单向GRU神经网络,对所述各特征短句向量进行编码转换,得到短句编码。
本实施例中,第二单向GRU神经网络是对平均池化输出的特征向量进行编码,得到短句编码。
例如:特征向量为[2,3,1,1]和[5,4,1,1]时,得到的短句编码为[2,3,5,4,0,0,0,0],短句编码中包括的关键信息为:北京,中国。
104、拼接所述短句编码和所述初始向量,得到第一融合向量,并将所述第一融合向量和预置随机变量输入预置文本关联器进行特征提取,得到上下文关联向量;
本实施例中,文本关联器包括多个单向GRU神经网络,每一个GRU神经网络对应输出一个上下文关联向量,文本关联器进行特征提取是对关键词进行二次采样,使生成的短句丰富性较好,因为每次生成的短句差异较大,不会出现大量重复的片段。潜在变量,是新建的一个变量,用于控制生成一句话应该包含哪些单词。
可选的,在一实施例中,所述语句关联器包括多个第三单向GRU神经网络,所述拼接所述短句编码和所述初始向量,得到第一融合向量,并将所述第一融合向量和预置随机变量输入预置文本关联器进行特征提取,得到上下文关联向量包括:
拼接所述短句编码和所述初始向量,得到第一融合向量;
将所述第一融合向量和预置随机变量输入所述第三单向GRU神经网络进行上下文关联特征提取,得到上下文关联向量。
本实施例中,拼接所述短句编码和所述初始向量,得到第一融合向量。
例如:短句编码为[0,2,1,0]和初始向量为[1,0,1,2]时,第一融合向量为[0,2,1,0,1,0,1,2]。
105、将所述各第一短句、所述随机变量和所述上下文关联向量输入预置长文本生成器进行文本生成,得到长文本。
本实施例中,长文本生成器包括多个单向GRU神经网络,其中,每一个GRU神经网络输出一个短句,将每次生成的第一个短句、第二个短句……第N个短句依次相连,得到长文本。
可选的,在一实施例中,所述长文本生成器包括多个第四单向GRU神经网络,所述将所述各第一短句、所述随机变量和所述上下文关联向量输入预置长文本生成器进行文本生成,得到长文本包括:
拼接所述各第一短句、所述随机变量和所述上下文关联向量,得到第二融合向量;
将所述第二融合向量输入所述第四单向GRU神经网络进行解码,得到多个第二短句;
依次对所述各第二短句进行拼接,得到长文本。
本实施例中,对所述各第一短句、所述随机变量和所述上下文关联向量进行拼接,得 到第二融合向量。将第二融合向量输入第四单向GRU神经网络,第四单向GRU神经网络中的每个GRU神经网络输出一个短句,最后依次对短句进行拼接得到长文本。
例如:S1:我爱中国。S2:我爱北京。S3:我爱天安门。拼接得到的长文本为:我爱中国,我爱北京,我爱天安门。
本申请实施例中,为了生成语义连贯的长文本可以将长文本看作多个短句的拼接,再将短句看作多个单词的拼接,具体为:获取多个关键词并对所述关键词进行向量转换,得到词向量,关键词选取时添加了随机变量,这样生成的短句每次都有较大的不同,从而大大增加了句式的多样性。然后通过词向量生成对应的第一短句,再对第一短句进行编码,得到短句编码,将短句编码和第一短句和随机变量输入长文本生成器生成多个第二短句,并依次拼接多个第二短句得到长文本。本申请将多个关键词作为生成长文本的基础,提高了长文本的连贯性而且文本的丰富性较好。
请参阅图2,本申请实施例中长文本生成方法的第二个实施例包括:
201、获取待处理的多个关键词,并将所述各关键词输入预置向量编码器进行向量转换,得到词向量;
202、拼接所述词向量和预置变量,得到初始向量;
203、将所述初始向量输入所述第一单向GRU神经网络进行短句生成,得到多个第一短句;
204、调用预置休止函数,对所述第一单向GRU神经网络中的全连接层进行计算,得到隐层神经元输出值;
205、判断所述隐层神经元输出值是否超过预置阈值;
206、若是,则停止生成短句,并将停止生成前得到的短句作为所述第一单向GRU神经网络的输出,得到多个第一短句;
207、若否,则继续通过所述第一单向GRU神经网络生成短句,直至所述隐层神经元输出值超过预置阈值,则停止生成短句,并将停止生成前得到的短句作为所述第一单向GRU神经网络的输出,得到多个第一短句;
本实施例中,休止函数为:
Figure PCTCN2021083496-appb-000001
其中,
Figure PCTCN2021083496-appb-000002
为隐层神经元输出值,σ为sigmoid函数,用于将数据映射到(0,1)区间,w c和b c分别代表短句生成器的全连接层的权重和偏置,
Figure PCTCN2021083496-appb-000003
代表GRU神经网络。
本实施例中,
Figure PCTCN2021083496-appb-000004
用于控制生成的短句长短,不同的
Figure PCTCN2021083496-appb-000005
大小设置可以使生成的句子长短不同,若
Figure PCTCN2021083496-appb-000006
到达预置阈值后,则停止继续生成短句。短句生成器决定了长文本中的每个句子需要包含关键词,每个GRU神经网络输出一次就输出一句话,输出的短句中包含了这句话用到了哪些关键词的信息。多个GRU神经网络的多个输出代表了生成的长文本中会包含多句话。
208、分别对所述各第一短句进行平均池化运算,得到多个特征短句向量,并将所述各特征短句向量输入预置短句编码器进行编码转换,得到短句编码;
209、拼接所述短句编码和所述初始向量,得到第一融合向量,并将所述第一融合向量和预置随机变量输入预置文本关联器进行特征提取,得到上下文关联向量;
210、将所述各第一短句、所述随机变量和所述上下文关联向量输入预置长文本生成器进行文本生成,得到长文本。
本申请实施例中,将长文本生成切分为数个短文本生成,再利用关键词来进行短文本生成,同时保证前后短文本语义连贯。短句生成器生成多个包含关键词的短句,既能保证每个短语语义通顺,同时也能提高整个长文本的连贯性,在关键词生成短句的过程中加入了暂停指令的设置,可以有效地控制文本长度,当的值超过预置阈值时,即停止生成短句,使生成文本的长度在可控范围内。
上面对本申请实施例中长文本生成方法进行了描述,下面对本申请实施例中长文本生成装置进行描述,请参阅图3,本申请实施例中长文本生成装置一个实施例包括:
获取模块301,用于获取待处理的多个关键词,并将所述各关键词输入预置向量编码器进行向量转换,得到词向量;
处理模块302,用于拼接所述词向量和预置变量,得到初始向量,并将所述初始向量输入预置短句生成器进行短句生成,得到多个第一短句;
转换模块303,用于分别对所述各第一短句进行平均池化运算,得到多个特征短句向量,并将所述各特征短句向量输入预置短句编码器进行编码转换,得到短句编码;
提取模块304,用于拼接所述短句编码和所述初始向量,得到第一融合向量,并将所述第一融合向量和预置随机变量输入预置文本关联器进行特征提取,得到上下文关联向量;
生成模块305,用于将所述各第一短句、所述随机变量和所述上下文关联向量输入预置长文本生成器进行文本生成,得到长文本。
可选的,在本申请第二方面的第一种实现方式中,所述向量编码器包括多个双向GRU神经网络,所述获取模块301具体用于:
获取待处理的多个关键词;
将所述关键词输入所述双向GRU神经网络进行向量转换,得到前向隐藏状态向量和后向隐藏状态向量;
对所述前向隐藏状态向量和后向隐藏状态向量进行拼接,得到词向量。
可选的,在本申请第二方面的第二种实现方式中,所述短句生成器包括多个第一单向GRU神经网络,所述处理模块302具体用于:
将所述初始向量输入所述第一单向GRU神经网络进行短句生成,得到多个第一短句;
调用预置休止函数,对所述第一单向GRU神经网络中的全连接层进行计算,得到隐层神经元输出值;
判断所述隐层神经元输出值是否超过预置阈值;
若是,则停止生成短句,并将停止生成前得到的短句作为所述第一单向GRU神经网络的输出,得到多个第一短句;
若否,则继续通过所述第一单向GRU神经网络生成短句,直至所述隐层神经元输出值超过预置阈值,则停止生成短句,并将停止生成前得到的短句作为所述第一单向GRU神经网络的输出,得到多个第一短句。
可选的,在本申请第二方面的第三种实现方式中,所述转换模块303还包括运算单元3031,所述运算单元3031具体用于:
调用预置平均池化函数,分别对所述各第一短句计算平均值,得到各短句对应的多个特征值;根据所述各短句对应的多个特征值,生成多个特征短句向量。
可选的,在本申请第二方面的第四种实现方式中,所述短句编码器包括多个第二单向GRU神经网络,所述转换模块303还包括编码单元3032,所述编码单元3032具体用于:
将所述各特征短句向量输入所述第二单向GRU神经网络;通过所述第二单向GRU神 经网络,对所述各特征短句向量进行编码转换,得到短句编码。
可选的,在本申请第二方面的第五种实现方式中,所述语句关联器包括多个第三单向GRU神经网络,所述提取模块304具体用于:
拼接所述短句编码和所述初始向量,得到第一融合向量;将所述第一融合向量和预置随机变量输入所述第三单向GRU神经网络进行上下文关联特征提取,得到上下文关联向量。
可选的,在本申请第二方面的第六种实现方式中,所述长文本生成器包括多个第四单向GRU神经网络,所述生成模块305具体用于:
拼接所述各第一短句、所述随机变量和所述上下文关联向量,得到第二融合向量;
将所述第二融合向量输入所述第四单向GRU神经网络进行解码,得到多个第二短句;
依次对所述各第二短句进行拼接,得到长文本。
本申请实施例中,为了生成语义连贯的长文本可以将长文本看作多个短句的拼接,再将短句看作多个单词的拼接,具体为:获取多个关键词并对所述关键词进行向量转换,得到词向量,关键词选取时添加了随机变量,这样生成的短句每次都有较大的不同,从而大大增加了句式的多样性。然后通过词向量生成对应的第一短句,再对第一短句进行编码,得到短句编码,将短句编码和第一短句和随机变量输入长文本生成器生成多个第二短句,并依次拼接多个第二短句得到长文本。本申请将多个关键词作为生成长文本的基础,提高了长文本的连贯性而且文本的丰富性较好。
上面图3从模块化功能实体的角度对本申请实施例中的长文本生成装置进行详细描述,下面从硬件处理的角度对本申请实施例中长文本生成设备进行详细描述。
图4是本申请实施例提供的一种长文本生成设备的结构示意图,该长文本生成设备400可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上处理器(central processing units,CPU)410(例如,一个或一个以上处理器)和存储器420,一个或一个以上存储应用程序433或数据432的存储介质430(例如一个或一个以上海量存储设备)。其中,存储器420和存储介质430可以是短暂存储或持久存储。存储在存储介质430的程序可以包括一个或一个以上模块(图示没标出),每个模块可以包括对长文本生成设备400中的一系列指令操作。更进一步地,处理器410可以设置为与存储介质430通信,在长文本生成设备400上执行存储介质430中的一系列指令操作。
长文本生成设备400还可以包括一个或一个以上电源440,一个或一个以上有线或无线网络接口450,一个或一个以上输入输出接口460,和/或,一个或一个以上操作系统431,例如Windows Serve,Mac OS X,Unix,Linux,FreeBSD等等。本领域技术人员可以理解,图4示出的长文本生成设备结构并不构成对长文本生成设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
本申请还提供一种长文本生成设备,所述长文本生成设备包括存储器和处理器,存储器中存储有计算机可读指令,计算机可读指令被处理器执行时,使得处理器执行上述各实施例中的所述长文本生成方法的步骤。
本申请还提供一种计算机可读存储介质,该计算机可读存储介质可以为非易失性计算机可读存储介质,该计算机可读存储介质也可以为易失性计算机可读存储介质,所述计算机可读存储介质中存储有指令,当所述指令在计算机上运行时,使得计算机执行所述长文本生成方法的步骤。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可 以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。

Claims (20)

  1. 一种长文本生成方法,其中,所述长文本生成方法包括:
    获取待处理的多个关键词,并将所述各关键词输入预置向量编码器进行向量转换,得到词向量;
    拼接所述词向量和预置变量,得到初始向量,并将所述初始向量输入预置短句生成器进行短句生成,得到多个第一短句;
    分别对所述各第一短句进行平均池化运算,得到多个特征短句向量,并将所述各特征短句向量输入预置短句编码器进行编码转换,得到短句编码;
    拼接所述短句编码和所述初始向量,得到第一融合向量,并将所述第一融合向量和预置随机变量输入预置文本关联器进行特征提取,得到上下文关联向量;
    将所述各第一短句、所述随机变量和所述上下文关联向量输入预置长文本生成器进行文本生成,得到长文本。
  2. 根据权利要求1所述的长文本生成方法,其中,所述向量编码器包括多个双向GRU神经网络,所述获取待处理的多个关键词,并将所述各关键词输入预置向量编码器进行向量转换,得到词向量包括:
    获取待处理的多个关键词;
    将所述关键词输入所述双向GRU神经网络进行向量转换,得到前向隐藏状态向量和后向隐藏状态向量;
    对所述前向隐藏状态向量和后向隐藏状态向量进行拼接,得到词向量。
  3. 根据权利要求1或2所述的长文本生成方法,其中,所述短句生成器包括多个第一单向GRU神经网络,所述将所述初始向量输入预置短句生成器进行短句生成,得到多个第一短句包括:
    将所述初始向量输入所述第一单向GRU神经网络进行短句生成,得到多个第一短句;
    调用预置休止函数,对所述第一单向GRU神经网络中的全连接层进行计算,得到隐层神经元输出值;
    判断所述隐层神经元输出值是否超过预置阈值;
    若是,则停止生成短句,并将停止生成前得到的短句作为所述第一单向GRU神经网络的输出,得到多个第一短句;
    若否,则继续通过所述第一单向GRU神经网络生成短句,直至所述隐层神经元输出值超过预置阈值,则停止生成短句,并将停止生成前得到的短句作为所述第一单向GRU神经网络的输出,得到多个第一短句。
  4. 根据权利要求1所述的长文本生成方法,其中,所述分别对所述各第一短句进行平均池化运算,得到多个特征短句向量包括:
    调用预置平均池化函数,分别对所述各第一短句计算平均值,得到各短句对应的多个特征值;
    根据所述各短句对应的多个特征值,生成多个特征短句向量。
  5. 根据权利要求1或4所述的长文本生成方法,其中,所述短句编码器包括多个第二单向GRU神经网络,所述将所述各特征短句向量输入预置短句编码器进行编码转换,得到短句编码包括:
    将所述各特征短句向量输入所述第二单向GRU神经网络;
    通过所述第二单向GRU神经网络,对所述各特征短句向量进行编码转换,得到短句编码。
  6. 根据权利要求4所述的长文本生成方法,其中,所述语句关联器包括多个第三单向GRU神经网络,所述拼接所述短句编码和所述初始向量,得到第一融合向量,并将所述第一融合向量和预置随机变量输入预置文本关联器进行特征提取,得到上下文关联向量包括:
    拼接所述短句编码和所述初始向量,得到第一融合向量;
    将所述第一融合向量和预置随机变量输入所述第三单向GRU神经网络进行上下文关联特征提取,得到上下文关联向量。
  7. 根据权利要求1或6所述的长文本生成方法,其中,所述长文本生成器包括多个第四单向GRU神经网络,所述将所述各第一短句、所述随机变量和所述上下文关联向量输入预置长文本生成器进行文本生成,得到长文本包括:
    拼接所述各第一短句、所述随机变量和所述上下文关联向量,得到第二融合向量;
    将所述第二融合向量输入所述第四单向GRU神经网络进行解码,得到多个第二短句;
    依次对所述各第二短句进行拼接,得到长文本。
  8. 一种长文本生成设备,其中,所述长文本生成设备包括:存储器、处理器以及存储在所述存储器上并可在所述处理器上运行的长文本生成程序,所述处理器执行所述长文本生成程序时包括:
    获取待处理的多个关键词,并将所述各关键词输入预置向量编码器进行向量转换,得到词向量;
    拼接所述词向量和预置变量,得到初始向量,并将所述初始向量输入预置短句生成器进行短句生成,得到多个第一短句;
    分别对所述各第一短句进行平均池化运算,得到多个特征短句向量,并将所述各特征短句向量输入预置短句编码器进行编码转换,得到短句编码;
    拼接所述短句编码和所述初始向量,得到第一融合向量,并将所述第一融合向量和预置随机变量输入预置文本关联器进行特征提取,得到上下文关联向量;
    将所述各第一短句、所述随机变量和所述上下文关联向量输入预置长文本生成器进行文本生成,得到长文本。
  9. 根据权利要求8所述的长文本生成设备,其中,所述向量编码器包括多个双向GRU神经网络,所述获取待处理的多个关键词,并将所述各关键词输入预置向量编码器进行向量转换,得到词向量包括:
    获取待处理的多个关键词;
    将所述关键词输入所述双向GRU神经网络进行向量转换,得到前向隐藏状态向量和后向隐藏状态向量;
    对所述前向隐藏状态向量和后向隐藏状态向量进行拼接,得到词向量。
  10. 根据权利要求8或9所述的长文本生成设备,其中,所述短句生成器包括多个第一单向GRU神经网络,所述将所述初始向量输入预置短句生成器进行短句生成,得到多个第一短句包括:
    将所述初始向量输入所述第一单向GRU神经网络进行短句生成,得到多个第一短句;
    调用预置休止函数,对所述第一单向GRU神经网络中的全连接层进行计算,得到隐层神经元输出值;
    判断所述隐层神经元输出值是否超过预置阈值;
    若是,则停止生成短句,并将停止生成前得到的短句作为所述第一单向GRU神经网络的输出,得到多个第一短句;
    若否,则继续通过所述第一单向GRU神经网络生成短句,直至所述隐层神经元输出值超过预置阈值,则停止生成短句,并将停止生成前得到的短句作为所述第一单向GRU神经 网络的输出,得到多个第一短句。
  11. 根据权利要求8所述的长文本生成设备,其中,所述分别对所述各第一短句进行平均池化运算,得到多个特征短句向量包括:
    调用预置平均池化函数,分别对所述各第一短句计算平均值,得到各短句对应的多个特征值;
    根据所述各短句对应的多个特征值,生成多个特征短句向量。
  12. 根据权利要求8或11所述的长文本生成设备,其中,所述短句编码器包括多个第二单向GRU神经网络,所述将所述各特征短句向量输入预置短句编码器进行编码转换,得到短句编码包括:
    将所述各特征短句向量输入所述第二单向GRU神经网络;
    通过所述第二单向GRU神经网络,对所述各特征短句向量进行编码转换,得到短句编码。
  13. 根据权利要求11所述的长文本生成设备,其中,所述语句关联器包括多个第三单向GRU神经网络,所述拼接所述短句编码和所述初始向量,得到第一融合向量,并将所述第一融合向量和预置随机变量输入预置文本关联器进行特征提取,得到上下文关联向量包括:
    拼接所述短句编码和所述初始向量,得到第一融合向量;
    将所述第一融合向量和预置随机变量输入所述第三单向GRU神经网络进行上下文关联特征提取,得到上下文关联向量。
  14. 根据权利要求8或13所述的长文本生成设备,其中,所述长文本生成器包括多个第四单向GRU神经网络,所述将所述各第一短句、所述随机变量和所述上下文关联向量输入预置长文本生成器进行文本生成,得到长文本包括:
    拼接所述各第一短句、所述随机变量和所述上下文关联向量,得到第二融合向量;
    将所述第二融合向量输入所述第四单向GRU神经网络进行解码,得到多个第二短句;
    依次对所述各第二短句进行拼接,得到长文本。
  15. 一种计算机可读存储介质,所述计算机可读存储介质中存储计算机指令,当所述计算机指令在计算机上运行时,使得计算机执行如下步骤:
    获取待处理的多个关键词,并将所述各关键词输入预置向量编码器进行向量转换,得到词向量;
    拼接所述词向量和预置变量,得到初始向量,并将所述初始向量输入预置短句生成器进行短句生成,得到多个第一短句;
    分别对所述各第一短句进行平均池化运算,得到多个特征短句向量,并将所述各特征短句向量输入预置短句编码器进行编码转换,得到短句编码;
    拼接所述短句编码和所述初始向量,得到第一融合向量,并将所述第一融合向量和预置随机变量输入预置文本关联器进行特征提取,得到上下文关联向量;
    将所述各第一短句、所述随机变量和所述上下文关联向量输入预置长文本生成器进行文本生成,得到长文本。
  16. 根据权利要求15所述的计算机可读存储介质,所述计算机可读存储介质执行所述计算机指令实现所述向量编码器包括多个双向GRU神经网络,所述获取待处理的多个关键词,并将所述各关键词输入预置向量编码器进行向量转换,得到词向量包括:
    获取待处理的多个关键词;
    将所述关键词输入所述双向GRU神经网络进行向量转换,得到前向隐藏状态向量和后向隐藏状态向量;
    对所述前向隐藏状态向量和后向隐藏状态向量进行拼接,得到词向量。
  17. 根据权利要求15或16所述的计算机可读存储介质,所述计算机可读存储介质执行所述计算机指令实现所述短句生成器包括多个第一单向GRU神经网络,所述将所述初始向量输入预置短句生成器进行短句生成,得到多个第一短句包括:
    将所述初始向量输入所述第一单向GRU神经网络进行短句生成,得到多个第一短句;
    调用预置休止函数,对所述第一单向GRU神经网络中的全连接层进行计算,得到隐层神经元输出值;
    判断所述隐层神经元输出值是否超过预置阈值;
    若是,则停止生成短句,并将停止生成前得到的短句作为所述第一单向GRU神经网络的输出,得到多个第一短句;
    若否,则继续通过所述第一单向GRU神经网络生成短句,直至所述隐层神经元输出值超过预置阈值,则停止生成短句,并将停止生成前得到的短句作为所述第一单向GRU神经网络的输出,得到多个第一短句。
  18. 根据权利要求15所述的计算机可读存储介质,所述计算机可读存储介质执行所述计算机指令实现所述分别对所述各第一短句进行平均池化运算,得到多个特征短句向量包括:
    调用预置平均池化函数,分别对所述各第一短句计算平均值,得到各短句对应的多个特征值;
    根据所述各短句对应的多个特征值,生成多个特征短句向量。
  19. 根据权利要求15或18所述的计算机可读存储介质,所述计算机可读存储介质执行所述计算机指令实现所述短句编码器包括多个第二单向GRU神经网络,所述将所述各特征短句向量输入预置短句编码器进行编码转换,得到短句编码包括:
    将所述各特征短句向量输入所述第二单向GRU神经网络;
    通过所述第二单向GRU神经网络,对所述各特征短句向量进行编码转换,得到短句编码。
  20. 一种长文本生成装置,其中,所述长文本生成装置包括:
    获取模块,用于获取待处理的多个关键词,并将所述各关键词输入预置向量编码器进行向量转换,得到词向量;
    处理模块,用于拼接所述词向量和预置变量,得到初始向量,并将所述初始向量输入预置短句生成器进行短句生成,得到多个第一短句;
    转换模块,用于分别对所述各第一短句进行平均池化运算,得到多个特征短句向量,并将所述各特征短句向量输入预置短句编码器进行编码转换,得到短句编码;
    提取模块,用于拼接所述短句编码和所述初始向量,得到第一融合向量,并将所述第一融合向量和预置随机变量输入预置文本关联器进行特征提取,得到上下文关联向量;
    生成模块,用于将所述各第一短句、所述随机变量和所述上下文关联向量输入预置长文本生成器进行文本生成,得到长文本。
PCT/CN2021/083496 2020-12-10 2021-03-29 长文本生成方法、装置、设备及存储介质 WO2022121165A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011432584.1A CN112541348A (zh) 2020-12-10 2020-12-10 长文本生成方法、装置、设备及存储介质
CN202011432584.1 2020-12-10

Publications (1)

Publication Number Publication Date
WO2022121165A1 true WO2022121165A1 (zh) 2022-06-16

Family

ID=75019850

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/083496 WO2022121165A1 (zh) 2020-12-10 2021-03-29 长文本生成方法、装置、设备及存储介质

Country Status (2)

Country Link
CN (1) CN112541348A (zh)
WO (1) WO2022121165A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112541348A (zh) * 2020-12-10 2021-03-23 平安科技(深圳)有限公司 长文本生成方法、装置、设备及存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109558583A (zh) * 2017-09-27 2019-04-02 株式会社理光 一种自动生成文摘的方法、装置及设备
CN110110331A (zh) * 2019-04-30 2019-08-09 清华大学 文本生成方法、装置、介质和计算设备
US20190370338A1 (en) * 2017-06-22 2019-12-05 Tencent Technology (Shenzhen) Company Limited Summary generation method, apparatus, computer device, and storage medium
CN111241294A (zh) * 2019-12-31 2020-06-05 中国地质大学(武汉) 基于依赖解析和关键词的图卷积网络的关系抽取方法
CN111476038A (zh) * 2020-05-06 2020-07-31 中国人民解放军国防科技大学 长文本生成方法、装置、计算机设备和存储介质
CN112541348A (zh) * 2020-12-10 2021-03-23 平安科技(深圳)有限公司 长文本生成方法、装置、设备及存储介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190370338A1 (en) * 2017-06-22 2019-12-05 Tencent Technology (Shenzhen) Company Limited Summary generation method, apparatus, computer device, and storage medium
CN109558583A (zh) * 2017-09-27 2019-04-02 株式会社理光 一种自动生成文摘的方法、装置及设备
CN110110331A (zh) * 2019-04-30 2019-08-09 清华大学 文本生成方法、装置、介质和计算设备
CN111241294A (zh) * 2019-12-31 2020-06-05 中国地质大学(武汉) 基于依赖解析和关键词的图卷积网络的关系抽取方法
CN111476038A (zh) * 2020-05-06 2020-07-31 中国人民解放军国防科技大学 长文本生成方法、装置、计算机设备和存储介质
CN112541348A (zh) * 2020-12-10 2021-03-23 平安科技(深圳)有限公司 长文本生成方法、装置、设备及存储介质

Also Published As

Publication number Publication date
CN112541348A (zh) 2021-03-23

Similar Documents

Publication Publication Date Title
CN111368993B (zh) 一种数据处理方法及相关设备
CN109033068B (zh) 基于注意力机制的用于阅读理解的方法、装置和电子设备
CN109710915B (zh) 复述语句生成方法及装置
Van Schijndel et al. Quantity doesn't buy quality syntax with neural language models
WO2021164200A1 (zh) 一种基于深度分层编码的智能语义匹配方法和装置
WO2022198868A1 (zh) 开放式实体关系的抽取方法、装置、设备及存储介质
TW201917602A (zh) 文本語義編碼方法及裝置
CN109918663B (zh) 一种语义匹配方法、装置及存储介质
EP3568852A1 (en) Training and/or using an encoder model to determine responsive action(s) for natural language input
CN112288075A (zh) 一种数据处理方法及相关设备
CN110837738B (zh) 相似问识别方法、装置、计算机设备及存储介质
CN111581401A (zh) 一种基于深度相关性匹配的局部引文推荐系统及方法
CN110990555B (zh) 端到端检索式对话方法与系统及计算机设备
CN110457661B (zh) 自然语言生成方法、装置、设备及存储介质
WO2022121161A1 (zh) 多轮对话文本生成方法、装置、设备及存储介质
CN111310439A (zh) 一种基于深度特征变维机制的智能语义匹配方法和装置
CN110069611B (zh) 一种主题增强的聊天机器人回复生成方法及装置
JP2022534375A (ja) テキスト知能化洗浄方法、装置及びコンピュータ読み取り可能な記憶媒体
CN112560456A (zh) 一种基于改进神经网络的生成式摘要生成方法和系统
WO2022121165A1 (zh) 长文本生成方法、装置、设备及存储介质
CN113157919A (zh) 语句文本方面级情感分类方法及系统
Xue et al. Relation extraction based on deep learning
CN113609301A (zh) 一种基于知识图谱的对话方法、介质及系统
Xu et al. Enabling language representation with knowledge graph and structured semantic information
CN112287641B (zh) 一种同义句生成方法、系统、终端及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21901881

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21901881

Country of ref document: EP

Kind code of ref document: A1