WO2021174827A1 - Text generation method and appartus, computer device and readable storage medium - Google Patents

Text generation method and appartus, computer device and readable storage medium Download PDF

Info

Publication number
WO2021174827A1
WO2021174827A1 PCT/CN2020/118456 CN2020118456W WO2021174827A1 WO 2021174827 A1 WO2021174827 A1 WO 2021174827A1 CN 2020118456 W CN2020118456 W CN 2020118456W WO 2021174827 A1 WO2021174827 A1 WO 2021174827A1
Authority
WO
WIPO (PCT)
Prior art keywords
sample
text
data
generator
text data
Prior art date
Application number
PCT/CN2020/118456
Other languages
French (fr)
Chinese (zh)
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 WO2021174827A1 publication Critical patent/WO2021174827A1/en

Links

Images

Classifications

    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • This application relates to the field of text processing, in particular to text generation methods, devices, computer equipment and readable storage media.
  • AI Artificial Intelligence
  • Open questions require AI to use a generative model to generate question text.
  • the current generative model mainly adopts the generative confrontation network (GAN). Since the generative confrontation network needs to update parameter variables based on continuous output data, it is mainly used in image processing.
  • image generation tasks include unsupervised generation, labeled generation, Super-resolution restoration, automatic coloring, street view generation, etc., the quality of the generated pictures is so real that it is difficult for the human eye to distinguish the authenticity.
  • this application provides a text generation method, which includes the following steps:
  • the target guide data is sentence beginning data of the target text data.
  • this application also provides a text generation device, including:
  • the collection unit is used to collect the answer data generated by the business object in the question and answer scenario
  • An obtaining unit configured to extract the answer data and obtain target guidance data
  • a generating unit configured to generate a confrontation network model through pre-trained text and generate target text data according to the target guidance data
  • the target guide data is sentence beginning data of the target text data.
  • the present application also provides a computer device, the computer device including a memory, a processor, and computer readable instructions stored in the memory and running on the processor, and the processor executes the computer
  • the method for generating text when the instruction is readable includes the following steps:
  • the target guide data is sentence beginning data of the target text data.
  • the present application also provides a computer-readable storage medium on which computer-readable instructions are stored.
  • the method for generating text includes the following steps:
  • the target guide data is sentence beginning data of the target text data.
  • the text generation method, device, computer equipment and readable storage medium generate the target text data according to the target guidance data (for example: sentence beginning data) through the text generation confrontation network model obtained by pre-training, which solves the problem that the discrete output cannot be updated.
  • the problem of using the text generation confrontation network model can be used to generate text sentences (for example: text questions) based on the data at the beginning of the sentence.
  • FIG. 1 is a method flowchart of an embodiment of the text generation method described in this application.
  • FIG. 2 is a flow diagram of an embodiment of obtaining a text generation confrontation network model
  • FIG. 3 is a method flowchart of an embodiment of training the initial confrontation network model according to the sample guide set and the sample text set to obtain the text generation confrontation network model;
  • FIG. 4 is a block diagram of an embodiment of the text generation device described in this application.
  • FIG. 5 is a schematic diagram of the hardware architecture of an embodiment of the computer device described in this application.
  • the text generation method, device, computer equipment, and readable storage medium provided in this application are suitable for insurance, finance and other business fields, and provide an open text question that can be automatically generated for loan systems, insurance systems, and financial systems to facilitate testing candidates
  • the text generation method of thinking ability This application generates target text data based on the target guidance data (for example: sentence beginning data) through the pre-trained text generation confrontation network model, which solves the problem of non-renewable discrete output, and realizes that the text generation confrontation network model can be based on the sentence start data
  • the purpose of generating text sentences for example: text questions).
  • a text generation method of this embodiment includes the following steps:
  • the business target can be a user who is consulting for business, or a buyer of an online trading platform, or an interviewer in the interview process.
  • the answer data can be collected by collecting equipment (for example: audio receiving device, microphone or mobile terminal with recording function, etc.).
  • the text generation method in this embodiment is mainly used in conversation scenarios (at least two users), and the question text is generated based on the answer information of the target object for the target object to answer the question text.
  • the text generation method is applied to an interview.
  • an open-ended text question is generated based on the keywords provided by the interviewer.
  • the answer data can be semantically analyzed to extract keywords in the answer data, and the keywords can be used as target guidance data; the answer data can be analyzed to extract nouns in the answer data, and the nouns can be used as target guidance data. data.
  • target guidance data can be keywords or the first words of a sentence.
  • the target guide data is the sentence beginning data of the target text data.
  • the target guidance data is: "Today”
  • the target text data is: "How is the weather today?".
  • the target guiding data is that the first word of the sentence can be two words or three words, which is not limited here.
  • step S3 the step of obtaining the text generation confrontation network model may include:
  • sample guide set including at least one sample guide data
  • sample text set includes at least one sample text data
  • sample guide data is sentence beginning data of the sample text data
  • the sample guide set is a sequence composed of sample guide data (sentence beginning data);
  • the sample text set is a sequence of real text data composed of sample text data (complete sentences).
  • the sample guide data is the sentence beginning data of the real text data.
  • the pixel value of each point of the generated image is continuous. Therefore, the calculation graph of the entire network, from the weight of the generator to its output, and then into the weight and output classification of the discriminator, are all It is differentiable (differentiable and differentiable), the error can be backpropagated normally, and the gradient and weight can be updated normally.
  • the generator actually outputs a sequence. Each round outputs the probability distribution of the next word in the vocabulary based on the generated text sequence, and then selects the word with the highest probability, this "choice"
  • the process is non-differentiable.
  • the generator outputs discrete tokens. During the training process, the error is propagated back here.
  • the discriminator can directly receive the input of a complete text sequence and output the true or false of the sentence, but it cannot judge the half of the unfinished sentences generated by the generator, which makes the discriminator unable to generate every word in the text sequence. Provide supervision on the training of the generator.
  • the text sequence generation process is regarded as a sequence decision process
  • the policy gradient method in reinforcement learning uses the judgment result of the discriminator as a reward, part of the text generated by the generator as the state, and the generator as an agent to predict the next Words are actions, and generators are policies that need to be updated.
  • this embodiment adopts Monte Carlo search. Based on the generated sequence, the generator continues to generate until the sequence is completed, and the discriminator judges the sequence and simulates multiple times. The mean value of the final reward is used as the estimate of the reward of the current unfinished sequence.
  • the initial confrontation network model includes a generator and a discriminator; as shown in FIG. 3, in step S32, the initial confrontation network model is trained according to the sample guide set and the sample text set, and The steps to get the text generation confrontation network model include:
  • the generator can use a long short-term memory network (LSTM) of the output sequence to generate a text sequence from a given initial state;
  • the discriminator can use a two-class long short-term memory network for receiving and generating
  • the output text and real text of the device can be used to determine whether the output text is true or false.
  • steps in step S321 may include:
  • the second sample word with the highest probability in the vocabulary is obtained, the second sample word is added to the end of the first sample word, and the loop is executed The above steps (and so on) until the sample text data of the preset length is obtained.
  • the generator G ⁇ and the discriminator D ⁇ are initialized;
  • the sample guiding set is the word set ⁇ Y 1 ⁇ .
  • the word set ⁇ Y 1 ⁇ is input to the generator G ⁇ , and the input layer of the generator G ⁇ maps the input words to the corresponding label information (tokenized) of the corresponding words in the vocabulary for embedding and representation.
  • the softmax classifier outputs the probability of the next word in each word in the vocabulary, and The word with the highest probability is taken as y t , and so on, and the loop processing is performed until the end of the sentence y T , thereby obtaining a set of generated sample text sets ⁇ Y 1 ⁇ T ⁇ of length T (length is less than zero padding).
  • (y 1 , y 2 ,..., y t-1 ) represents an incomplete sentence consisting of t-1 words, y 1 represents the first word in a sentence; y 2 represents the sentence in a sentence The second word; y t-1 means the t-1 word in a sentence; y T is the T word in a sentence (end of sentence).
  • the generator G ⁇ In the step, only the generator G ⁇ is used to pass in a word y 1 , and the generator G ⁇ embeds it and transmits it to the LSTM, and outputs the generated token sequence and its corresponding words in the vocabulary to obtain the generated Text sequence (y 1 ,y 2 ,...,y T ).
  • step S322 includes:
  • Monte Carlo simulation is used to simulate the words in each sample text data one by one, and generate multiple sample simulated text data corresponding to the sample text data.
  • simulation times of words located at different positions in the sentence in the sample text set can be the same or different.
  • step S323 may include:
  • An objective function is calculated according to the state value function, and parameter values of the generator are updated according to the objective function.
  • the acquired sample simulation text set ⁇ Y 1 ⁇ T 1 ,Y 1 ⁇ T 2 ,...,Y 1 ⁇ T N ⁇ is input into the discriminator D ⁇ for binary classification, and each sample simulation text Compare with the corresponding real text. If it is consistent, it means that the sample simulation text generated by the generator is real (mark 1); if it is inconsistent, it means that the sample simulation text generated by the generator is fake (mark 0).
  • the output result of the discriminator D ⁇ is directly used as the state value; for incomplete sentences, the discriminant results of N complete sentences obtained by Monte Carlo simulation are averaged.
  • the state value function can be expressed as:
  • i the simulation times of Monte Carlo simulation.
  • the parameter ⁇ of the generator G ⁇ is updated.
  • the objective function of the generator is to produce a more realistic sample to deceive the discriminator as much as possible, that is, to maximize the reward it obtains under the strategy G ⁇ :
  • Y 1 ⁇ t-1 ) represents the output of the strategy, which can be regarded as a probability in essence, outputting the probability value of y t in the vocabulary; Y 1 ⁇ t-1 are all occurrences of y t Value.
  • Parameter [theta] is a weight parameter generator G ⁇ is; the parameter generator G ⁇ in J ( ⁇ ) update, in other words, from the policy gradient J ( ⁇ ):
  • ⁇ ⁇ is the learning rate.
  • ⁇ ⁇ is the learning rate.
  • the generator in each round of training, the generator is repeatedly trained n G times, and the discriminator is repeatedly trained n D times until the model meets the preset convergence conditions.
  • the preset convergence condition is n D > n G to ensure that the discriminator can correctly guide the generator to update.
  • step S3 the step of generating a confrontation network model obtained by pre-training the text and generating target text data according to the target guidance data includes:
  • the generator of the text generation confrontation network model is used to calculate the target guidance data to obtain the first sample word with the highest probability in the vocabulary, and the first sample word is added to the target guidance data. end;
  • the generator uses the generator to calculate the first sample word, obtain the second sample word with the highest probability in the vocabulary, add the second sample word to the end of the first sample word, and execute the above in a loop Steps (and so on) until the target text data of the preset length is obtained.
  • the target text data for questioning is generated according to the answer data, and the purpose of open question and answer based on the answer of the business object is realized, and it is convenient to test the temporary response ability of the business object to the open question.
  • the text generation method is based on adversarial long-term and short-term memory networks and policy gradients, and uses the LSTM-based discriminator-generator structure to accurately generate text sequences and determine the authenticity of text; with the help of adversarial training,
  • the discriminator can dynamically update its parameters, continuously improve the recognition ability, and provide appropriate guidance for the generator, which has more potential than evaluating the quality of the generated text purely based on other static benchmarks; with the help of the idea of reinforcement learning, the sequence generation process is transformed into a sequence
  • the decision-making process solves the non-differentiable problem of the loss function caused by the discrete output, making it possible to generate the training of the confrontation network; use Monte Carlo search to simulate the strategy to obtain the complete sequence of each step and its scoring result in the discriminator ,
  • the average value is used as the reward value of the current time step, which solves the problem of the inability to directly obtain the reward of the unfinished sequence; in addition, only the generator part needs to be retained in the training phase, and other techniques such
  • the present application also provides a text generation device 1, including: a collection unit 11, an acquisition unit 12, and a generation unit 13, wherein:
  • the collection unit 11 is used to collect the answer data generated by the business object in the question and answer scenario
  • the business target can be consulting users for business consulting, buyers of online trading platforms, or interviewers in the interview process.
  • the answer data can be collected by collecting equipment (for example: audio receiving device, microphone or mobile terminal with recording function, etc.).
  • the text generating device 1 in this embodiment is mainly used in conversation scenarios (at least two types of users), and generates a question text based on the answer information of the target object for the target object to answer the question text, for example: the text generating device 1 applies
  • interview scenario open-ended text questions are generated based on the keywords provided by the interviewer.
  • the obtaining unit 12 is configured to extract the answer data and obtain target guidance data
  • the acquisition unit 12 can perform semantic analysis on the answer data to extract keywords in the answer data, and use the keywords as target guidance data; analyze the answer data to extract the nouns in the answer data, and use the noun as the target guidance data. data.
  • the generating unit 13 is configured to generate a confrontation network model through pre-trained text and generate target text data according to the target guidance data;
  • the target guide data is sentence beginning data of the target text data.
  • the generating unit 13 uses the generator of the text generation confrontation network model to calculate according to the target guidance data, obtains the first sample word with the highest probability in the vocabulary, and adds the first sample word to all the words.
  • the generator calculates according to the first sample word, obtains the second sample word with the highest probability in the vocabulary, adds the second sample word to the end of the first sample word, and so on until Obtain the target text data of a preset length.
  • the text generation device 1 is based on the adversarial long-term and short-term memory network and policy gradients, and uses the LSTM-based discriminator-generator structure, which can accurately realize the task of generating text sequences and judging the authenticity of the text; with the help of adversarial training ,
  • the discriminator can dynamically update its parameters, continuously improve the recognition ability, and provide appropriate guidance for the generator, which has more potential than evaluating the quality of the generated text based purely on other static benchmarks; with the help of the idea of reinforcement learning, the sequence generation process is transformed into
  • the sequence decision process solves the non-differentiable problem of the loss function caused by the discrete output, making it possible to generate the training of the adversarial network; using Monte Carlo search to simulate the strategy to obtain the complete sequence of each step and its score in the discriminator
  • the average value is used as the reward value of the current time step, which solves the problem of not being able to directly obtain the reward of the unfinished sequence; in addition, only the generator part needs to be
  • the present application also provides a computer device 2 which includes a plurality of computer devices 2.
  • the components of the text generating device 1 of the second embodiment can be dispersed in different computer devices 2.
  • the computer device 2 It can be a smartphone, tablet, laptop, desktop computer, rack server, blade server, tower server, or rack server (including independent servers, or server clusters composed of multiple servers) that executes the program. .
  • the computer device 2 of this embodiment at least includes but is not limited to: a memory 21, a processor 23, a network interface 22, and a text generation device 1 (refer to FIG. 5) that can be communicatively connected to each other through a system bus.
  • FIG. 5 only shows the computer device 2 with components, but it should be understood that it is not required to implement all the illustrated components, and more or fewer components may be implemented instead.
  • the memory 21 includes at least one type of computer-readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access Memory (RAM), Static Random Access Memory (SRAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), Programmable Read Only Memory (PROM), Magnetic Memory, Magnetic Disk, Optical Disk, etc.
  • the memory 21 may be an internal storage unit of the computer device 2, for example, the hard disk or memory of the computer device 2.
  • the memory 21 may also be an external storage device of the computer device 2, such as a plug-in hard disk, a smart media card (SMC), and a secure digital (Secure Digital, SMC) equipped on the computer device 2. SD) card, flash card (Flash Card), etc.
  • the memory 21 may also include both the internal storage unit of the computer device 2 and its external storage device.
  • the memory 21 is generally used to store an operating system and various application software installed in the computer device 2, for example, the program code of the text generation method in the first embodiment.
  • the memory 21 can also be used to temporarily store various types of data that have been output or will be output.
  • the processor 23 may be a central processing unit (Central Processing Unit, CPU), a controller, a microcontroller, a microprocessor, or other data processing chips.
  • the processor 23 is generally used to control the overall operation of the computer device 2, for example, to perform data interaction or communication-related control and processing with the computer device 2.
  • the processor 23 is used to run the program code or processing data stored in the memory 21, for example, to run the text generating device 1 and the like.
  • the network interface 22 may include a wireless network interface or a wired network interface, and the network interface 22 is generally used to establish a communication connection between the computer device 2 and other computer devices 2.
  • the network interface 22 is used to connect the computer device 2 with an external terminal through a network, and establish a data transmission channel and a communication connection between the computer device 2 and the external terminal.
  • the network may be Intranet, Internet, Global System of Mobile Communication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G Network, Bluetooth (Bluetooth), Wi-Fi and other wireless or wired networks.
  • FIG. 5 only shows the computer device 2 with components 21-23, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead.
  • the text generating device 1 stored in the memory 21 may also be divided into one or more program modules, and the one or more program modules are stored in the memory 21 and are composed of one or more program modules. It is executed by two processors (in this embodiment, the processor 23) to complete the application.
  • the present application also provides a computer-readable storage medium, which includes multiple storage media, such as flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM ), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disks, optical disks, servers, App applications Shopping malls, etc., have computer-readable instructions stored thereon, and corresponding functions are realized when the programs are executed by the processor 23.
  • the computer-readable storage medium of this embodiment is used to store the text generation device 1, and when executed by the processor 23, the text generation method of the first embodiment is implemented.
  • the computer-readable storage medium may be non-volatile or volatile.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Evolutionary Computation (AREA)
  • Artificial Intelligence (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A text generation method and apparatus, a computer device and a readable storage medium, which belong to the field of text processing. The text generation method and apparatus, the computer device and the readable storage medium generate data of a target text according to target guide data by using a pretrained text generative adversarial network model, thus solving the problem of being unable to update a discrete output, thereby achieving the objective of being able to generate a text statement according to sentence header data by using a text generative adversarial network model.

Description

文本生成方法、装置、计算机设备及可读存储介质Text generation method, device, computer equipment and readable storage medium
本申请申要求于2020年3月2日递交的申请号为202010136551.6、名称为“文本生成方法、装置、计算机设备及可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed on March 2, 2020 with the application number 202010136551.6 and titled "text generation method, device, computer equipment and readable storage medium", the entire content of which is incorporated by reference In this application.
技术领域Technical field
本申请涉及文本处理领域,尤其涉及文本生成方法、装置、计算机设备及可读存储介质。This application relates to the field of text processing, in particular to text generation methods, devices, computer equipment and readable storage media.
背景技术Background technique
在智能面试场景中,人工智能(Artificial Intelligence,简称AI)除了需要按照事先预设的问题对候选人进行提问之外,还应根据实际情况向候选人提出开放性的问题,以测试候选人的实际应对能力。开放性的问题需要AI采用生成模型生成提问文本。In the intelligent interview scenario, artificial intelligence (Artificial Intelligence, referred to as AI), in addition to asking the candidates according to the pre-set questions, should also ask the candidates open questions based on the actual situation to test the candidates’ Actual response ability. Open questions require AI to use a generative model to generate question text.
目前的生成模型主要采用生成对抗网络(GAN),由于生成对抗网络需要基于连续型的输出数据更新参数变量,因此主要应用于图像处理中,各类图像生成任务包括无监督生成、带标签生成、超分辨率还原、以及自动上色、街景生成等,其所生成图片的质量逼真至人眼都难以分辨真伪。The current generative model mainly adopts the generative confrontation network (GAN). Since the generative confrontation network needs to update parameter variables based on continuous output data, it is mainly used in image processing. Various image generation tasks include unsupervised generation, labeled generation, Super-resolution restoration, automatic coloring, street view generation, etc., the quality of the generated pictures is so real that it is difficult for the human eye to distinguish the authenticity.
发明人意识到,当将生成对抗网络应用于文本生成任务上时,由于在文本生成过程中,生成对抗网络需基于已经生成的文本序列输出下一个词语在词汇表中的概率分布,然后选择词语,其所输出的结果为离散型的数据,离散型的数据无法实现网络的训练更新。因此目前的生成对抗网络无法应用于文本生成任务中。The inventor realized that when the generative confrontation network is applied to the text generation task, because in the text generation process, the generative confrontation network needs to output the probability distribution of the next word in the vocabulary based on the generated text sequence, and then select the word , The output result is discrete data, and discrete data cannot achieve network training update. Therefore, the current generative confrontation network cannot be applied to text generation tasks.
发明内容Summary of the invention
针对现有生成对抗网络只支持连续型输出的问题,现提供一种基于可根据离散数据实现更新的文本生成对抗网络的文本生成方法、装置、计算机设备及可读存储介质。Aiming at the problem that the existing generative confrontation network only supports continuous output, a text generation method, device, computer equipment and readable storage medium based on a text generation confrontation network that can be updated based on discrete data are now provided.
为实现上述目的,本申请提供一种文本生成方法,包括下述步骤:In order to achieve the above purpose, this application provides a text generation method, which includes the following steps:
采集业务对象在问答场景中生成的回答数据;Collect the answer data generated by the business object in the question and answer scenario;
对所述回答数据进行提取,并获取目标引导数据;Extract the answer data, and obtain target guidance data;
通过预先训练得到的文本生成对抗网络模型并根据所述目标引导数据生成目标文本数据;Generating a confrontation network model through a text obtained through pre-training, and generating target text data according to the target guidance data;
所述目标引导数据为所述目标文本数据的句首数据。The target guide data is sentence beginning data of the target text data.
为实现上述目的,本申请还提供一种文本生成装置,包括:In order to achieve the above objective, this application also provides a text generation device, including:
采集单元,用于采集业务对象在问答场景中生成的回答数据;The collection unit is used to collect the answer data generated by the business object in the question and answer scenario;
获取单元,用于对所述回答数据进行提取,并获取目标引导数据;An obtaining unit, configured to extract the answer data and obtain target guidance data;
生成单元,用于通过预先训练得到的文本生成对抗网络模型并根据所述目标引导数据生成目标文本数据;A generating unit, configured to generate a confrontation network model through pre-trained text and generate target text data according to the target guidance data;
所述目标引导数据为所述目标文本数据的句首数据。The target guide data is sentence beginning data of the target text data.
为实现上述目的,本申请还提供一种计算机设备,所述计算机设备,包括存储器、处理器以及存储在存储器上并可在处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现文本生成方法包括下述步骤:To achieve the above objective, the present application also provides a computer device, the computer device including a memory, a processor, and computer readable instructions stored in the memory and running on the processor, and the processor executes the computer The method for generating text when the instruction is readable includes the following steps:
采集业务对象在问答场景中生成的回答数据;Collect the answer data generated by the business object in the question and answer scenario;
对所述回答数据进行提取,并获取目标引导数据;Extract the answer data, and obtain target guidance data;
通过预先训练得到的文本生成对抗网络模型并根据所述目标引导数据生成目标文本数据;Generating a confrontation network model through a text obtained through pre-training, and generating target text data according to the target guidance data;
所述目标引导数据为所述目标文本数据的句首数据。The target guide data is sentence beginning data of the target text data.
为实现上述目的,本申请还提供一种计算机可读存储介质,其上存储有计算机可读指令,所述计算机可读指令被处理器执行时实现文本生成方法包括下述步骤:In order to achieve the foregoing objective, the present application also provides a computer-readable storage medium on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor, the method for generating text includes the following steps:
采集业务对象在问答场景中生成的回答数据;Collect the answer data generated by the business object in the question and answer scenario;
对所述回答数据进行提取,并获取目标引导数据;Extract the answer data, and obtain target guidance data;
通过预先训练得到的文本生成对抗网络模型并根据所述目标引导数据生成目标文本数据;Generating a confrontation network model through a text obtained through pre-training, and generating target text data according to the target guidance data;
所述目标引导数据为所述目标文本数据的句首数据。The target guide data is sentence beginning data of the target text data.
上述技术方案的有益效果:The beneficial effects of the above technical solutions:
本技术方案中,文本生成方法、装置、计算机设备及可读存储介质通过预先训练得到的文本生成对抗网络模型根据目标引导数据(例如:句首数据)生成目标文本数据,解决了离散输出不可更新的问题,实现了采用文本生成对抗网络模型可根据句首数据生成文本语句(例如:文本问题)的目的。In this technical solution, the text generation method, device, computer equipment and readable storage medium generate the target text data according to the target guidance data (for example: sentence beginning data) through the text generation confrontation network model obtained by pre-training, which solves the problem that the discrete output cannot be updated. The problem of using the text generation confrontation network model can be used to generate text sentences (for example: text questions) based on the data at the beginning of the sentence.
附图说明Description of the drawings
图1为本申请所述文本生成方法的一种实施例的方法流程图;FIG. 1 is a method flowchart of an embodiment of the text generation method described in this application;
图2为获取文本生成对抗网络模型的一种实施例的方法流图;FIG. 2 is a flow diagram of an embodiment of obtaining a text generation confrontation network model;
图3为根据样本引导集合和样本文本集合对初始对抗网络模型进行训练,获取文本生成对抗网络模型的一种实施例的方法流程图;FIG. 3 is a method flowchart of an embodiment of training the initial confrontation network model according to the sample guide set and the sample text set to obtain the text generation confrontation network model;
图4为本申请所述的文本生成装置的一种实施例的模块图;FIG. 4 is a block diagram of an embodiment of the text generation device described in this application;
图5为本申请所述的计算机设备一实施例的硬件架构示意图。FIG. 5 is a schematic diagram of the hardware architecture of an embodiment of the computer device described in this application.
具体实施方式Detailed ways
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purpose, technical solutions, and advantages of this application clearer and clearer, the following further describes the application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the application, and are not used to limit the application. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of this application.
本申请提供的文本生成方法、装置、计算机设备及可读存储介质,适用于保险、金融等业务领域,为贷款系统、保险系统及金融系统提供一种可自动生成开放性文本问题便于测试候选人的思维能力的文本生成方法。本申请通过预先训练得到的文本生成对抗网络模型根据目标引导数据(例如:句首数据)生成目标文本数据,解决了离散输出不可更新的问题,实现了采用文本生成对抗网络模型可根据句首数据生成文本语句(例如:文本问题)的目的。The text generation method, device, computer equipment, and readable storage medium provided in this application are suitable for insurance, finance and other business fields, and provide an open text question that can be automatically generated for loan systems, insurance systems, and financial systems to facilitate testing candidates The text generation method of thinking ability. This application generates target text data based on the target guidance data (for example: sentence beginning data) through the pre-trained text generation confrontation network model, which solves the problem of non-renewable discrete output, and realizes that the text generation confrontation network model can be based on the sentence start data The purpose of generating text sentences (for example: text questions).
实施例一Example one
请参阅图1,本实施例的一种文本生成方法,包括下述步骤:Please refer to Fig. 1, a text generation method of this embodiment includes the following steps:
S1.采集业务对象在问答场景中生成的回答数据;S1. Collect the answer data generated by the business object in the question and answer scenario;
在本步骤中,业务对象可以是对业务咨询的咨询用户,或是网上交易平台的买家,或是面试过程中的面试人员。可通过采集设备(例如:音频接收装置,麦克风或带有录音功能的移动终端等)采集回答数据。In this step, the business target can be a user who is consulting for business, or a buyer of an online trading platform, or an interviewer in the interview process. The answer data can be collected by collecting equipment (for example: audio receiving device, microphone or mobile terminal with recording function, etc.).
本实施例中的文本生成方法主要应用于对话场景中(至少两种用户),基于目标对象的回答信息生成问题文本,以供目标对象对该问题文本进行回答,例如:文本生成方法应用于面试场景时,根据面试人员提供的关键字生成开放式的文本问题。The text generation method in this embodiment is mainly used in conversation scenarios (at least two users), and the question text is generated based on the answer information of the target object for the target object to answer the question text. For example, the text generation method is applied to an interview. In the scenario, an open-ended text question is generated based on the keywords provided by the interviewer.
S2.对所述回答数据进行提取,并获取目标引导数据;S2. Extract the answer data and obtain target guidance data;
在步骤S2中可对回答数据进行语义分析提取所述回答数据中的关键字,将该关键字作为目标引导数据;对所述回答数据进行分析提取回答数据中的名词,将该名词作为目标引导数据。In step S2, the answer data can be semantically analyzed to extract keywords in the answer data, and the keywords can be used as target guidance data; the answer data can be analyzed to extract nouns in the answer data, and the nouns can be used as target guidance data. data.
需要说明的是:目标引导数据可以是关键字,或一句话的句首词语。It should be noted that the target guidance data can be keywords or the first words of a sentence.
S3.通过预先训练得到的文本生成对抗网络模型并根据所述目标引导数据生成目标文本数据;S3. Generate a confrontation network model through the text obtained by pre-training and generate target text data according to the target guidance data;
需要说明的是:所述目标引导数据为所述目标文本数据的句首数据。例如:目标引导数据为:“今天”;目标文本数据为:“今天天气如何?”。目标引导数据为句首词可以是两个词或三个词,此处不做限定。It should be noted that: the target guide data is the sentence beginning data of the target text data. For example: the target guidance data is: "Today"; the target text data is: "How is the weather today?". The target guiding data is that the first word of the sentence can be two words or three words, which is not limited here.
参考图2所示,在执行步骤S3之前,获取所述文本生成对抗网络模型的步骤可包括:Referring to FIG. 2, before step S3 is executed, the step of obtaining the text generation confrontation network model may include:
S31.获取样本引导集合和样本文本集合,所述样本引导集合包括至少一个样本引导数据,所述样本文本集合包括至少一个样本文本数据,所述样本引导数据为所述样本文本数据的句首数据;S31. Obtain a sample guide set and a sample text set, the sample guide set including at least one sample guide data, the sample text set includes at least one sample text data, and the sample guide data is sentence beginning data of the sample text data ;
于本实施例中,样本引导集合是由样本引导数据(句首数据)组成的序列;样本文本集合是由样本文本数据(完整语句)组成真实文本数据的序列。样本引导数据是真实文本数据的句首数据。In this embodiment, the sample guide set is a sequence composed of sample guide data (sentence beginning data); the sample text set is a sequence of real text data composed of sample text data (complete sentences). The sample guide data is the sentence beginning data of the real text data.
S32.根据所述样本引导集合和所述样本文本集合对初始对抗网络模型进行训练,并得到文本生成对抗网络模型。S32. Training the initial confrontation network model according to the sample guide set and the sample text set, and obtain a text generation confrontation network model.
目前生成对抗网络在图像处理过程中,生成的图像各个点的像素值为连续值,因此整个网络的计算图,从生成器的权重到其输出,再进入到判别器的权重和输出分类,都是可微分(可微、可导)的,误差可以正常地反向传播、梯度和权重都可以正常更新。然而文本生成的过程中,生成器实际是输出一个序列,每一轮基于已经生成出来的文本序列输出下一个词语在词汇表中的概率分布,然后选出概率最大的词语,这一“选择”过程是不可微的,生成器输出的是离散的token,在训练过程中,误差反向传播到此处,无法在每个token上像图像生成任务那样对像素值进行梯度更新,从而更新生成器的权重值。另一方面,判别器可以直接接收一个完整文本序列的输入,输出句子的真假,却无法对生成器生成到一半尚未完成的句子进行评判,导致判别器无法针对生成文本序列中的每一个词语对生成器的训练提供监督。At present, in the image processing process of the generated confrontation network, the pixel value of each point of the generated image is continuous. Therefore, the calculation graph of the entire network, from the weight of the generator to its output, and then into the weight and output classification of the discriminator, are all It is differentiable (differentiable and differentiable), the error can be backpropagated normally, and the gradient and weight can be updated normally. However, in the process of text generation, the generator actually outputs a sequence. Each round outputs the probability distribution of the next word in the vocabulary based on the generated text sequence, and then selects the word with the highest probability, this "choice" The process is non-differentiable. The generator outputs discrete tokens. During the training process, the error is propagated back here. It is not possible to update the pixel values on each token as in the image generation task, thereby updating the generator. The weight value of. On the other hand, the discriminator can directly receive the input of a complete text sequence and output the true or false of the sentence, but it cannot judge the half of the unfinished sentences generated by the generator, which makes the discriminator unable to generate every word in the text sequence. Provide supervision on the training of the generator.
因此,在本实施例的生成对抗网络模型的训练过程中,为了解决生成器的离散输出造成的不可微问题,在本实施例中,将文本序列的生成过程视作一个序列决策过程,采用了强化学习中的策略梯度(policy gradient)方法,将判别器的评判结果作为奖励(reward),生成器已生成出来的部分文本作为状态(state),生成器作为智能体(agent),预测下一个词语作为动作(action),生成器即为需要更新的策略(policy),这样一来解决了离散输出的损失函数不可微问题。对于未完成序列的评判方法上,本实施例采用了蒙特卡洛搜索(Monte Carlo search),基于已生成的序列,生成器继续生成直至序列完成,判别器对该序列进行评判,模拟多次,将最终reward的均值作为当前未完成序列的reward的估计。Therefore, in the training process of the generative confrontation network model of this embodiment, in order to solve the non-differentiable problem caused by the discrete output of the generator, in this embodiment, the text sequence generation process is regarded as a sequence decision process, and The policy gradient method in reinforcement learning uses the judgment result of the discriminator as a reward, part of the text generated by the generator as the state, and the generator as an agent to predict the next Words are actions, and generators are policies that need to be updated. In this way, the problem of nondifferentiable loss function of discrete output is solved. For the judgment method of the unfinished sequence, this embodiment adopts Monte Carlo search. Based on the generated sequence, the generator continues to generate until the sequence is completed, and the discriminator judges the sequence and simulates multiple times. The mean value of the final reward is used as the estimate of the reward of the current unfinished sequence.
需要说明的是:所述初始对抗网络模型包括生成器和判别器;参图3所示,在步骤S32中,根据所述样本引导集合和所述样本文本集合对初始对抗网络模型进行训练,并得到文本生成对抗网络模型的步骤,包括:It should be noted that: the initial confrontation network model includes a generator and a discriminator; as shown in FIG. 3, in step S32, the initial confrontation network model is trained according to the sample guide set and the sample text set, and The steps to get the text generation confrontation network model include:
作为举例而非限定,生成器可采用输出序列的长短期记忆网络(LSTM),用于从一个给定的初始状态生成文本序列;判别器可采用二分类的长短期记忆网络,用于接收生成器的输出文本和真实文本,判断输出文本的真假。As an example and not a limitation, the generator can use a long short-term memory network (LSTM) of the output sequence to generate a text sequence from a given initial state; the discriminator can use a two-class long short-term memory network for receiving and generating The output text and real text of the device can be used to determine whether the output text is true or false.
S321.通过所述生成器并根据所述样本引导集合中的至少一个样本引导数据生成至少一个样本文本数据;S321. Generate at least one sample text data according to at least one sample guidance data in the sample guidance set through the generator;
进一步地,步骤S321中的步骤可包括:Further, the steps in step S321 may include:
通过所述生成器并根据所述样本引导数据进行计算,获取词汇表中概率最大的第一样本词,将所述第一样本词添加于所述样本引导数据的末尾;Calculating by the generator and according to the sample guidance data, obtaining the first sample word with the highest probability in the vocabulary, and adding the first sample word to the end of the sample guidance data;
通过所述生成器并根据所述第一样本词进行计算,获取词汇表中概率最大的第二样本词,将所述第二样本词添加于所述第一样本词的末尾,循环执行上述步骤(以此类推)直 至获取预设长度的样本文本数据。Through the generator and calculation based on the first sample word, the second sample word with the highest probability in the vocabulary is obtained, the second sample word is added to the end of the first sample word, and the loop is executed The above steps (and so on) until the sample text data of the preset length is obtained.
在本步骤中,初始化生成器G θ和判别器D φ;样本引导数据为真实文本集合S={X 1~T},真实文本集合中每一个真实文本的句子长度为T,长度不足T的末尾用零补齐;样本引导集合为单词集合{Y 1}。 In this step, the generator G θ and the discriminator D φ are initialized; the sample guide data is the real text set S={X 1~T }, the sentence length of each real text in the real text set is T, and the length is less than T Fill the end with zeros; the sample guiding set is the word set {Y 1 }.
将单词集合{Y 1}输入至生成器G θ,生成器G θ的输入层对输入的单词映射到词汇表中相应的单词对应的标签信息(token化),进行嵌入表示,在实际应用中将(y 1,y 2,…,y t-1)作为输入发送至生成器G θ,生成器G θ根据输入的数据,softmax分类器输出下一个词在词汇表中各个词的概率,将概率最大的词作为y t,以此类推,循环处理直至句末y T,由此得到一组长度为T(长度不足补零)的生成样本文本集合{Y 1~T}。 The word set {Y 1 } is input to the generator G θ , and the input layer of the generator G θ maps the input words to the corresponding label information (tokenized) of the corresponding words in the vocabulary for embedding and representation. In practical applications Send (y 1 ,y 2 ,...,y t-1 ) as input to the generator G θ , and the generator G θ according to the input data, the softmax classifier outputs the probability of the next word in each word in the vocabulary, and The word with the highest probability is taken as y t , and so on, and the loop processing is performed until the end of the sentence y T , thereby obtaining a set of generated sample text sets {Y 1~T } of length T (length is less than zero padding).
其中,(y 1,y 2,…,y t-1)表示一个由t-1个词组成的不完整的句子,y 1表示一句话中的第1个词;y 2表示一句话中的第2个词;y t-1表示一句话中的第t-1个词;y T一句话中的第T个词(句末)。 Among them, (y 1 , y 2 ,..., y t-1 ) represents an incomplete sentence consisting of t-1 words, y 1 represents the first word in a sentence; y 2 represents the sentence in a sentence The second word; y t-1 means the t-1 word in a sentence; y T is the T word in a sentence (end of sentence).
在步骤中,仅使用生成器G θ,传入一个词语y 1,生成器G θ将其嵌入后传到LSTM中,输出生成的token序列和其在词汇表中对应的词语,即得到生成的文本序列(y 1,y 2,…,y T)。 In the step, only the generator G θ is used to pass in a word y 1 , and the generator G θ embeds it and transmits it to the LSTM, and outputs the generated token sequence and its corresponding words in the vocabulary to obtain the generated Text sequence (y 1 ,y 2 ,...,y T ).
S322.采用蒙特卡洛模拟对所述至少一个样本文本数据进行模拟并获取多个样本模拟文本数据;S322. Use Monte Carlo simulation to simulate the at least one sample text data and obtain multiple sample simulation text data;
进一步地,步骤S322的步骤,包括:Further, the steps of step S322 include:
采用蒙特卡洛模拟对每一个样本文本数据中的词逐个进行模拟,并生成与所述样本文本数据对应的多个样本模拟文本数据。Monte Carlo simulation is used to simulate the words in each sample text data one by one, and generate multiple sample simulated text data corresponding to the sample text data.
于本实施中,对于样本文本集合{Y 1~T}中的中的各个序列,以(y 1,y 2,…,y T)序列为例,遍历序列中各个词y t,进行N次蒙特卡洛模拟,不同于之前选择概率最大的词语作为y t,此处每次使用生成器G θ根据输出词语的多项分布采样,重复直至到达句末y T,从而得到N个不同的完整样本模拟文本集合{Y 1~T 1,Y 1~T 2,…,Y 1~T N}。 In this implementation, for each sequence in the sample text set {Y 1~T }, take the (y 1 ,y 2 ,...,y T ) sequence as an example, traverse each word y t in the sequence for N times Monte Carlo simulation is different from the previous selection of the word with the highest probability as y t , here each time the generator G θ is used to sample according to the multinomial distribution of the output words, and repeat until the end of the sentence y T is reached, thereby obtaining N different completes Sample simulation text collection {Y 1~T 1 ,Y 1~T 2 ,...,Y 1~T N }.
需要说明的是,样本文本集合中位于句中不同位置的词的模拟次数可以相同,也可以不同。It should be noted that the simulation times of words located at different positions in the sentence in the sample text set can be the same or different.
S323.通过所述判别器并根据所述样本文本集合中的目标文本数据对所述多个样本模拟文本数据进行识别,根据识别结果更新所述生成器的参数值;S323. Recognize the multiple sample simulated text data according to the target text data in the sample text set by the discriminator, and update the parameter values of the generator according to the recognition result;
进一步地,步骤S323可包括:Further, step S323 may include:
通过所述判别器并根据所述样本文本集合中的目标文本数据对所述多个样本模拟文本数据进行识别,根据识别结果获取状态价值函数;Recognizing the multiple sample simulated text data by the discriminator and according to the target text data in the sample text set, and obtaining a state value function according to the recognition result;
根据所述状态价值函数计算目标函数,根据所述目标函数更新所述生成器的参数值。An objective function is calculated according to the state value function, and parameter values of the generator are updated according to the objective function.
在实施例中,将获取的样本模拟文本集合{Y 1~T 1,Y 1~T 2,…,Y 1~T N}输入到判别器D φ中进行二分类,将每一样本模拟文本与相应的真实文本进行比对,若是一致,则表示生成器生成的样本模拟文本是真实的(标记1);若不一致,则示生成器生成的样本模拟文本是假的(标记0)。对于完整的句子,直接将判别器D φ输出结果作为状态价值;对于不完整的句子,将蒙特卡洛模拟得到的N个完整句子的判别结果取平均。综上,状态价值函数可表示为: In the embodiment, the acquired sample simulation text set {Y 1~T 1 ,Y 1~T 2 ,...,Y 1~T N } is input into the discriminator D φ for binary classification, and each sample simulation text Compare with the corresponding real text. If it is consistent, it means that the sample simulation text generated by the generator is real (mark 1); if it is inconsistent, it means that the sample simulation text generated by the generator is fake (mark 0). For complete sentences, the output result of the discriminator D φ is directly used as the state value; for incomplete sentences, the discriminant results of N complete sentences obtained by Monte Carlo simulation are averaged. In summary, the state value function can be expressed as:
Figure PCTCN2020118456-appb-000001
Figure PCTCN2020118456-appb-000001
其中,i表示蒙特卡洛模拟的模拟次数。Among them, i represents the simulation times of Monte Carlo simulation.
根据状态价值函数,更新生成器G θ的参数θ,生成器的目标函数是尽可能地产生更真实的样本欺骗判别器,即最大化其在策略G θ下获得的奖励: According to the state value function, the parameter θ of the generator G θ is updated. The objective function of the generator is to produce a more realistic sample to deceive the discriminator as much as possible, that is, to maximize the reward it obtains under the strategy G θ:
Figure PCTCN2020118456-appb-000002
Figure PCTCN2020118456-appb-000002
其中,G θ(y t|Y 1~t-1)表示策略输出,实质可看作一个概率,输出y t在词汇表中的概率值;Y 1~t-1为所有y t出现过的取值。参数θ为生成器G θ中的权重参数;生成器G θ的参数在J(θ)上更新,换言之,策略的梯度来自于J(θ): Among them, G θ (y t |Y 1~t-1 ) represents the output of the strategy, which can be regarded as a probability in essence, outputting the probability value of y t in the vocabulary; Y 1~t-1 are all occurrences of y t Value. Parameter [theta] is a weight parameter generator G θ is; the parameter generator G θ in J (θ) update, in other words, from the policy gradient J (θ):
Figure PCTCN2020118456-appb-000003
Figure PCTCN2020118456-appb-000003
其中,α θ为学习率。 Among them, α θ is the learning rate.
S324.基于更新的所述生成器并根据损失函数更新所述判别器;S324. Update the discriminator based on the updated generator and according to the loss function;
在本步骤中,使用更新后的生成器G θ,生成一组文本序列{Y 1~T},同时从真实文本集合S={X 1~T}中选出相同数量的文本序列集合{X 1~T},输入到判别器D φ中分类,损失函数为二分类对数损失函数: In this step, use the updated generator G θ to generate a set of text sequences {Y 1~T }, and at the same time select the same number of text sequence sets {X from the real text set S={X 1~T} 1~T }, input into the discriminator D φ to classify, and the loss function is a two-class logarithmic loss function:
Figure PCTCN2020118456-appb-000004
Figure PCTCN2020118456-appb-000004
D φ的参数在J(φ)上更新: The parameters of D φ are updated on J(φ):
Figure PCTCN2020118456-appb-000005
Figure PCTCN2020118456-appb-000005
其中,α φ为学习率。 Among them, α φ is the learning rate.
S325.循环更新所述生成器和所述判别器直至所述初始对抗网络模型符合预设的收敛条件,并得到由更新后的生成器构成的所述文本生成对抗网络模型。S325. Update the generator and the discriminator cyclically until the initial confrontation network model meets a preset convergence condition, and obtain the text generation confrontation network model composed of the updated generator.
在本步骤中,每一轮训练中,重复训练生成器n G次,重复训练判别器n D次,直至模型符合预设的收敛条件。如:预设的收敛条件为n D>n G,以保证判别器能正确地指导生成器更新。 In this step, in each round of training, the generator is repeatedly trained n G times, and the discriminator is repeatedly trained n D times until the model meets the preset convergence conditions. For example, the preset convergence condition is n D > n G to ensure that the discriminator can correctly guide the generator to update.
在步骤S3中,所述通过预先训练得到的文本生成对抗网络模型并根据所述目标引导数据生成目标文本数据的步骤,包括:In step S3, the step of generating a confrontation network model obtained by pre-training the text and generating target text data according to the target guidance data includes:
采用所述文本生成对抗网络模型的生成器对所述目标引导数据进行计算,以获取词汇表中概率最大的第一样本词,将所述第一样本词添加于所述目标引导数据的末尾;The generator of the text generation confrontation network model is used to calculate the target guidance data to obtain the first sample word with the highest probability in the vocabulary, and the first sample word is added to the target guidance data. end;
采用所述生成器对所述第一样本词进行计算,获取词汇表中概率最大的第二样本词,将所述第二样本词添加于所述第一样本词的末尾,循环执行上述步骤(以此类推)直至获取预设长度的目标文本数据。从而实现根据回答数据生成用于提问的目标文本数据,实现了基于业务对象的答复进行开放式问答的目的,便于测试业务对象对开放性问题的临时应对能力。Use the generator to calculate the first sample word, obtain the second sample word with the highest probability in the vocabulary, add the second sample word to the end of the first sample word, and execute the above in a loop Steps (and so on) until the target text data of the preset length is obtained. In this way, the target text data for questioning is generated according to the answer data, and the purpose of open question and answer based on the answer of the business object is realized, and it is convenient to test the temporary response ability of the business object to the open question.
在本实施例中,文本生成方法基于对抗式长短期记忆网络和策略梯度,使用基于LSTM的判别器—生成器的结构,可以准确地实现生成文本序列和判断文本真伪任务;借助对抗训练,判别器能动态地更新其参数,不断提高识别能力,为生成器提供合适的指导,比纯粹基于其他静态基准评价生成文本的质量更具潜力;借助强化学习的思想,将序列生成过程转化为序列决策过程,解决了离散输出带来的损失函数不可微问题,使得生成对抗网络的训练成为可能;使用蒙特卡洛搜索,对策略模拟得到对每一步的完整序列和其在判别器中的评分结果,将均值作为当前时间步的reward值,解决了无法直接得到未完成的序列的 reward问题;另外,在训练阶段仅需保留生成器部分,而和Gumbel-softmax等其他处理离散化不可微的技巧相比,不需要训练额外的参数、模型占用内存更小。In this embodiment, the text generation method is based on adversarial long-term and short-term memory networks and policy gradients, and uses the LSTM-based discriminator-generator structure to accurately generate text sequences and determine the authenticity of text; with the help of adversarial training, The discriminator can dynamically update its parameters, continuously improve the recognition ability, and provide appropriate guidance for the generator, which has more potential than evaluating the quality of the generated text purely based on other static benchmarks; with the help of the idea of reinforcement learning, the sequence generation process is transformed into a sequence The decision-making process solves the non-differentiable problem of the loss function caused by the discrete output, making it possible to generate the training of the confrontation network; use Monte Carlo search to simulate the strategy to obtain the complete sequence of each step and its scoring result in the discriminator , The average value is used as the reward value of the current time step, which solves the problem of the inability to directly obtain the reward of the unfinished sequence; in addition, only the generator part needs to be retained in the training phase, and other techniques such as Gumbel-softmax to deal with discretization are not differentiable In contrast, there is no need to train additional parameters, and the model occupies less memory.
实施例二Example two
如图4所示,本申请还提供了一种文本生成装置1,包括:采集单元11、获取单元12和生成单元13,其中:As shown in Fig. 4, the present application also provides a text generation device 1, including: a collection unit 11, an acquisition unit 12, and a generation unit 13, wherein:
采集单元11,用于采集业务对象在问答场景中生成的回答数据;The collection unit 11 is used to collect the answer data generated by the business object in the question and answer scenario;
业务对象可以是对业务咨询的咨询用户,或是网上交易平台的买家,或是面试过程中的面试人员。可通过采集设备(例如:音频接收装置,麦克风或带有录音功能的移动终端等)采集回答数据。The business target can be consulting users for business consulting, buyers of online trading platforms, or interviewers in the interview process. The answer data can be collected by collecting equipment (for example: audio receiving device, microphone or mobile terminal with recording function, etc.).
本实施例中的文本生成装置1主要应用于对话场景中(至少两种用户),基于目标对象的回答信息生成问题文本,以供目标对象对该问题文本进行回答,例如:文本生成装置1应用于面试场景时,根据面试人员提供的关键字生成开放式的文本问题。The text generating device 1 in this embodiment is mainly used in conversation scenarios (at least two types of users), and generates a question text based on the answer information of the target object for the target object to answer the question text, for example: the text generating device 1 applies In the interview scenario, open-ended text questions are generated based on the keywords provided by the interviewer.
获取单元12,用于对所述回答数据进行提取,并获取目标引导数据;The obtaining unit 12 is configured to extract the answer data and obtain target guidance data;
采用获取单元12可对回答数据进行语义分析提取所述回答数据中的关键字,将该关键字作为目标引导数据;对所述回答数据进行分析提取回答数据中的名词,将该名词作为目标引导数据。The acquisition unit 12 can perform semantic analysis on the answer data to extract keywords in the answer data, and use the keywords as target guidance data; analyze the answer data to extract the nouns in the answer data, and use the noun as the target guidance data. data.
生成单元13,用于通过预先训练得到的文本生成对抗网络模型并根据所述目标引导数据生成目标文本数据;The generating unit 13 is configured to generate a confrontation network model through pre-trained text and generate target text data according to the target guidance data;
所述目标引导数据为所述目标文本数据的句首数据。The target guide data is sentence beginning data of the target text data.
具体地,生成单元13采用所述文本生成对抗网络模型的生成器根据所述目标引导数据进行计算,获取词汇表中概率最大的第一样本词,将所述第一样本词添加于所述目标引导数据的末尾;Specifically, the generating unit 13 uses the generator of the text generation confrontation network model to calculate according to the target guidance data, obtains the first sample word with the highest probability in the vocabulary, and adds the first sample word to all the words. The end of the target guide data;
所述生成器根据所述第一样本词进行计算,获取词汇表中概率最大的第二样本词,将所述第二样本词添加于所述第一样本词的末尾,以此类推直至获取预设长度的目标文本数据。The generator calculates according to the first sample word, obtains the second sample word with the highest probability in the vocabulary, adds the second sample word to the end of the first sample word, and so on until Obtain the target text data of a preset length.
在本实施例中,文本生成装置1基于对抗式长短期记忆网络和策略梯度,使用基于LSTM的判别器—生成器的结构,可以准确地实现生成文本序列和判断文本真伪任务;借助对抗训练,判别器能动态地更新其参数,不断提高识别能力,为生成器提供合适的指导,比纯粹基于其他静态基准评价生成文本的质量更具潜力;借助强化学习的思想,将序列生成过程转化为序列决策过程,解决了离散输出带来的损失函数不可微问题,使得生成对抗网络的训练成为可能;使用蒙特卡洛搜索,对策略模拟得到对每一步的完整序列和其在判别器中的评分结果,将均值作为当前时间步的reward值,解决了无法直接得到未完成的序列的reward问题;另外,在训练阶段仅需保留生成器部分,而和Gumbel-softmax等其他处理离散化不可微的技巧相比,不需要训练额外的参数、模型占用内存更小。In this embodiment, the text generation device 1 is based on the adversarial long-term and short-term memory network and policy gradients, and uses the LSTM-based discriminator-generator structure, which can accurately realize the task of generating text sequences and judging the authenticity of the text; with the help of adversarial training , The discriminator can dynamically update its parameters, continuously improve the recognition ability, and provide appropriate guidance for the generator, which has more potential than evaluating the quality of the generated text based purely on other static benchmarks; with the help of the idea of reinforcement learning, the sequence generation process is transformed into The sequence decision process solves the non-differentiable problem of the loss function caused by the discrete output, making it possible to generate the training of the adversarial network; using Monte Carlo search to simulate the strategy to obtain the complete sequence of each step and its score in the discriminator As a result, the average value is used as the reward value of the current time step, which solves the problem of not being able to directly obtain the reward of the unfinished sequence; in addition, only the generator part needs to be retained in the training phase, and other processing discretization such as Gumbel-softmax is not differentiable Compared with techniques, no additional parameters are required for training, and the model occupies less memory.
实施例三Example three
为实现上述目的,本申请还提供一种计算机设备2,该计算机设备2包括多个计算机设备2,实施例二的文本生成装置1的组成部分可分散于不同的计算机设备2中,计算机设备2可以是执行程序的智能手机、平板电脑、笔记本电脑、台式计算机、机架式服务器、刀片式服务器、塔式服务器或机柜式服务器(包括独立的服务器,或者多个服务器所组成的服务器集群)等。本实施例的计算机设备2至少包括但不限于:可通过系统总线相互通信连接的存储器21、处理器23、网络接口22以及文本生成装置1(参考图5)。需要指出的是,图5仅示出了具有组件-的计算机设备2,但是应理解的是,并不要求实施所有示出的组件,可以替代的实施更多或者更少的组件。In order to achieve the above purpose, the present application also provides a computer device 2 which includes a plurality of computer devices 2. The components of the text generating device 1 of the second embodiment can be dispersed in different computer devices 2. The computer device 2 It can be a smartphone, tablet, laptop, desktop computer, rack server, blade server, tower server, or rack server (including independent servers, or server clusters composed of multiple servers) that executes the program. . The computer device 2 of this embodiment at least includes but is not limited to: a memory 21, a processor 23, a network interface 22, and a text generation device 1 (refer to FIG. 5) that can be communicatively connected to each other through a system bus. It should be pointed out that FIG. 5 only shows the computer device 2 with components, but it should be understood that it is not required to implement all the illustrated components, and more or fewer components may be implemented instead.
本实施例中,所述存储器21至少包括一种类型的计算机可读存储介质,所述可读存储介质包括闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、随机访问存储器(RAM)、静态随机访问存储器(SRAM)、只读存储器(ROM)、电可擦除可编程只 读存储器(EEPROM)、可编程只读存储器(PROM)、磁性存储器、磁盘、光盘等。在一些实施例中,存储器21可以是计算机设备2的内部存储单元,例如该计算机设备2的硬盘或内存。在另一些实施例中,存储器21也可以是计算机设备2的外部存储设备,例如该计算机设备2上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。当然,所述存储器21还可以既包括计算机设备2的内部存储单元也包括其外部存储设备。本实施例中,存储器21通常用于存储安装于计算机设备2的操作系统和各类应用软件,例如实施例一的文本生成方法的程序代码等。此外,存储器21还可以用于暂时地存储已经输出或者将要输出的各类数据。In this embodiment, the memory 21 includes at least one type of computer-readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access Memory (RAM), Static Random Access Memory (SRAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), Programmable Read Only Memory (PROM), Magnetic Memory, Magnetic Disk, Optical Disk, etc. In some embodiments, the memory 21 may be an internal storage unit of the computer device 2, for example, the hard disk or memory of the computer device 2. In other embodiments, the memory 21 may also be an external storage device of the computer device 2, such as a plug-in hard disk, a smart media card (SMC), and a secure digital (Secure Digital, SMC) equipped on the computer device 2. SD) card, flash card (Flash Card), etc. Of course, the memory 21 may also include both the internal storage unit of the computer device 2 and its external storage device. In this embodiment, the memory 21 is generally used to store an operating system and various application software installed in the computer device 2, for example, the program code of the text generation method in the first embodiment. In addition, the memory 21 can also be used to temporarily store various types of data that have been output or will be output.
所述处理器23在一些实施例中可以是中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器、或其他数据处理芯片。该处理器23通常用于控制计算机设备2的总体操作例如执行与所述计算机设备2进行数据交互或者通信相关的控制和处理等。本实施例中,所述处理器23用于运行所述存储器21中存储的程序代码或者处理数据,例如运行所述的文本生成装置1等。In some embodiments, the processor 23 may be a central processing unit (Central Processing Unit, CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. The processor 23 is generally used to control the overall operation of the computer device 2, for example, to perform data interaction or communication-related control and processing with the computer device 2. In this embodiment, the processor 23 is used to run the program code or processing data stored in the memory 21, for example, to run the text generating device 1 and the like.
所述网络接口22可包括无线网络接口或有线网络接口,该网络接口22通常用于在所述计算机设备2与其他计算机设备2之间建立通信连接。例如,所述网络接口22用于通过网络将所述计算机设备2与外部终端相连,在所述计算机设备2与外部终端之间的建立数据传输通道和通信连接等。所述网络可以是企业内部网(Intranet)、互联网(Internet)、全球移动通讯系统(Global System of Mobile communication,GSM)、宽带码分多址(Wideband Code Division Multiple Access,WCDMA)、4G网络、5G网络、蓝牙(Bluetooth)、Wi-Fi等无线或有线网络。The network interface 22 may include a wireless network interface or a wired network interface, and the network interface 22 is generally used to establish a communication connection between the computer device 2 and other computer devices 2. For example, the network interface 22 is used to connect the computer device 2 with an external terminal through a network, and establish a data transmission channel and a communication connection between the computer device 2 and the external terminal. The network may be Intranet, Internet, Global System of Mobile Communication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G Network, Bluetooth (Bluetooth), Wi-Fi and other wireless or wired networks.
需要指出的是,图5仅示出了具有部件21-23的计算机设备2,但是应理解的是,并不要求实施所有示出的部件,可以替代的实施更多或者更少的部件。It should be pointed out that FIG. 5 only shows the computer device 2 with components 21-23, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead.
在本实施例中,存储于存储器21中的所述文本生成装置1还可以被分割为一个或者多个程序模块,所述一个或者多个程序模块被存储于存储器21中,并由一个或多个处理器(本实施例为处理器23)所执行,以完成本申请。In this embodiment, the text generating device 1 stored in the memory 21 may also be divided into one or more program modules, and the one or more program modules are stored in the memory 21 and are composed of one or more program modules. It is executed by two processors (in this embodiment, the processor 23) to complete the application.
实施例四:Embodiment four:
为实现上述目的,本申请还提供一种计算机可读存储介质,其包括多个存储介质,如闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、随机访问存储器(RAM)、静态随机访问存储器(SRAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、可编程只读存储器(PROM)、磁性存储器、磁盘、光盘、服务器、App应用商城等等,其上存储有计算机可读指令,程序被处理器23执行时实现相应功能。本实施例的计算机可读存储介质用于存储文本生成装置1,被处理器23执行时实现实施例一的文本生成方法。所述计算机可读存储介质可以是非易失性,也可以是易失性。To achieve the above objective, the present application also provides a computer-readable storage medium, which includes multiple storage media, such as flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM ), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disks, optical disks, servers, App applications Shopping malls, etc., have computer-readable instructions stored thereon, and corresponding functions are realized when the programs are executed by the processor 23. The computer-readable storage medium of this embodiment is used to store the text generation device 1, and when executed by the processor 23, the text generation method of the first embodiment is implemented. The computer-readable storage medium may be non-volatile or volatile.
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the foregoing embodiments of the present application are for description only, and do not represent the superiority or inferiority of the embodiments.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。Through the description of the above implementation manners, those skilled in the art can clearly understand that the above-mentioned embodiment method can be implemented by means of software plus the necessary general hardware platform, of course, it can also be implemented by hardware, but in many cases the former is better.的实施方式。
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。The above are only the preferred embodiments of the application, and do not limit the scope of the patent for this application. Any equivalent structure or equivalent process transformation made using the content of the description and drawings of the application, or directly or indirectly applied to other related technical fields , The same reason is included in the scope of patent protection of this application.

Claims (20)

  1. 一种文本生成方法,其中,基于问答场景,所述方法包括下述步骤:A text generation method, wherein, based on a question and answer scenario, the method includes the following steps:
    采集业务对象在问答场景中生成的回答数据;Collect the answer data generated by the business object in the question and answer scenario;
    对所述回答数据进行提取,并获取目标引导数据;Extract the answer data, and obtain target guidance data;
    通过预先训练得到的文本生成对抗网络模型并根据所述目标引导数据生成目标文本数据;Generating a confrontation network model through a text obtained through pre-training, and generating target text data according to the target guidance data;
    所述目标引导数据为所述目标文本数据的句首数据。The target guide data is sentence beginning data of the target text data.
  2. 根据权利要求1所述的文本生成方法,其中,在所述通过预先训练得到的文本生成对抗网络模型并根据所述目标引导数据生成目标文本数据的步骤之前,包括:The text generation method according to claim 1, wherein before the step of generating a confrontation network model obtained by pre-training a text and generating target text data according to the target guidance data, the method comprises:
    获取样本引导集合和样本文本集合,所述样本引导集合包括至少一个样本引导数据,所述样本文本集合包括至少一个样本文本数据,所述样本引导数据为所述样本文本数据的句首数据;Acquiring a sample guidance set and a sample text set, the sample guidance set including at least one sample guidance data, the sample text set includes at least one sample text data, and the sample guidance data is sentence beginning data of the sample text data;
    根据所述样本引导集合和所述样本文本集合对初始对抗网络模型进行训练,并得到文本生成对抗网络模型。The initial confrontation network model is trained according to the sample guide set and the sample text set, and a text generation confrontation network model is obtained.
  3. 根据权利要求2所述的文本生成方法,其中,所述初始对抗网络模型包括生成器和判别器,所述根据所述样本引导集合和所述样本文本集合对初始对抗网络模型进行训练,并得到文本生成对抗网络模型的步骤,包括:The text generation method according to claim 2, wherein the initial confrontation network model includes a generator and a discriminator, and the initial confrontation network model is trained according to the sample guide set and the sample text set to obtain The steps of text generation against the network model include:
    通过所述生成器并根据所述样本引导集合中的至少一个样本引导数据生成至少一个样本文本数据;Generating at least one sample text data by the generator and according to at least one sample guidance data in the sample guidance set;
    采用蒙特卡洛模拟对所述至少一个样本文本数据进行模拟并获取多个样本模拟文本数据;Using Monte Carlo simulation to simulate the at least one sample text data and obtain a plurality of sample simulation text data;
    通过所述判别器并根据所述样本文本集合中的目标文本数据对所述多个样本模拟文本数据进行识别,根据识别结果更新所述生成器的参数值;Recognizing the plurality of sample simulated text data according to the target text data in the sample text set by the discriminator, and updating the parameter value of the generator according to the recognition result;
    基于更新的所述生成器并根据损失函数更新所述判别器;Update the discriminator based on the updated generator and according to the loss function;
    循环更新所述生成器和所述判别器直至所述初始对抗网络模型符合预设的收敛条件,并得到由更新后的生成器构成的所述文本生成对抗网络模型。The generator and the discriminator are cyclically updated until the initial confrontation network model meets a preset convergence condition, and the text generation confrontation network model composed of the updated generator is obtained.
  4. 根据权利要求3所述的文本生成方法,其中,通过所述生成器并根据所述样本引导集合中的至少一个样本引导数据生成至少一个样本文本数据的步骤,包括:The text generation method according to claim 3, wherein the step of generating at least one sample text data by the generator and according to at least one sample guidance data in the sample guidance set comprises:
    通过所述生成器并根据所述样本引导数据进行计算,获取词汇表中概率最大的第一样本词,将所述第一样本词添加于所述样本引导数据的末尾;Calculating by the generator and according to the sample guidance data, obtaining the first sample word with the highest probability in the vocabulary, and adding the first sample word to the end of the sample guidance data;
    通过所述生成器并根据所述第一样本词进行计算,获取词汇表中概率最大的第二样本词,将所述第二样本词添加于所述第一样本词的末尾;Calculating by the generator and according to the first sample word, obtaining the second sample word with the highest probability in the vocabulary, and adding the second sample word to the end of the first sample word;
    循环执行上述步骤直至获取预设长度的样本文本数据。Repeat the above steps until the sample text data of the preset length is obtained.
  5. 根据权利要求3所述的文本生成方法,其中,采用蒙特卡洛模拟对所述至少一个样本文本数据进行模拟并获取多个样本模拟文本数据的步骤,包括:The text generation method according to claim 3, wherein the step of using Monte Carlo simulation to simulate the at least one sample text data and obtaining a plurality of sample simulation text data comprises:
    采用蒙特卡洛模拟对每一个样本文本数据中的词逐个进行模拟,并生成与所述样本文本数据对应的多个样本模拟文本数据。Monte Carlo simulation is used to simulate the words in each sample text data one by one, and generate multiple sample simulated text data corresponding to the sample text data.
  6. 根据权利要求3所述的文本生成方法,其中,通过所述判别器并根据所述样本文本集合中的目标文本数据对所述多个样本模拟文本数据进行识别,根据识别结果更新所述生成器的参数值的步骤,包括:The text generation method according to claim 3, wherein the plurality of sample simulated text data is recognized by the discriminator and according to the target text data in the sample text set, and the generator is updated according to the recognition result The steps of parameter values include:
    通过所述判别器并根据所述样本文本集合中的目标文本数据对所述多个样本模拟文本数据进行识别,根据识别结果获取状态价值函数;Recognizing the multiple sample simulated text data by the discriminator and according to the target text data in the sample text set, and obtaining a state value function according to the recognition result;
    根据所述状态价值函数计算目标函数,根据所述目标函数更新所述生成器的参数值。An objective function is calculated according to the state value function, and parameter values of the generator are updated according to the objective function.
  7. 根据权利要求3所述的文本生成方法,其中,所述通过预先训练得到的文本生 成对抗网络模型并根据所述目标引导数据生成目标文本数据的步骤,包括:The text generation method according to claim 3, wherein the step of generating a confrontation network model from the text obtained through pre-training and generating target text data according to the target guidance data comprises:
    采用所述文本生成对抗网络模型的生成器对所述目标引导数据进行计算,以获取词汇表中概率最大的第一样本词,将所述第一样本词添加于所述目标引导数据的末尾;The generator of the text generation confrontation network model is used to calculate the target guidance data to obtain the first sample word with the highest probability in the vocabulary, and the first sample word is added to the target guidance data. end;
    采用所述生成器对所述第一样本词进行计算,获取词汇表中概率最大的第二样本词,将所述第二样本词添加于所述第一样本词的末尾;Using the generator to calculate the first sample word, obtain the second sample word with the highest probability in the vocabulary, and add the second sample word to the end of the first sample word;
    循环执行上述步骤直至获取预设长度的目标文本数据。Repeat the above steps until the target text data of the preset length is obtained.
  8. 一种文本生成装置,其中,基于问答场景,包括:A text generation device, wherein, based on a question and answer scenario, it includes:
    采集单元,用于采集业务对象在问答场景中生成的回答数据;The collection unit is used to collect the answer data generated by the business object in the question and answer scenario;
    获取单元,用于对所述回答数据进行提取,并获取目标引导数据;An obtaining unit, configured to extract the answer data and obtain target guidance data;
    生成单元,用于通过预先训练得到的文本生成对抗网络模型并根据所述目标引导数据生成目标文本数据;A generating unit, configured to generate a confrontation network model through pre-trained text and generate target text data according to the target guidance data;
    所述目标引导数据为所述目标文本数据的句首数据。The target guide data is sentence beginning data of the target text data.
  9. 一种计算机设备,所述计算机设备,包括存储器、处理器以及存储在存储器上并可在处理器上运行的计算机可读指令,其中:所述处理器执行所述计算机可读指令时实现文本生成方法包括下述步骤:A computer device comprising a memory, a processor, and computer readable instructions stored in the memory and running on the processor, wherein: the processor implements text generation when the computer readable instructions are executed The method includes the following steps:
    采集业务对象在问答场景中生成的回答数据;Collect the answer data generated by the business object in the question and answer scenario;
    对所述回答数据进行提取,并获取目标引导数据;Extract the answer data, and obtain target guidance data;
    通过预先训练得到的文本生成对抗网络模型并根据所述目标引导数据生成目标文本数据;Generating a confrontation network model through a text obtained through pre-training, and generating target text data according to the target guidance data;
    所述目标引导数据为所述目标文本数据的句首数据。The target guide data is sentence beginning data of the target text data.
  10. 根据权利要求9所述的计算机设备,其中,在所述通过预先训练得到的文本生成对抗网络模型并根据所述目标引导数据生成目标文本数据的步骤之前,包括:The computer device according to claim 9, wherein before the step of generating a confrontation network model obtained by pre-training the text and generating target text data according to the target guidance data, the method comprises:
    获取样本引导集合和样本文本集合,所述样本引导集合包括至少一个样本引导数据,所述样本文本集合包括至少一个样本文本数据,所述样本引导数据为所述样本文本数据的句首数据;Acquiring a sample guidance set and a sample text set, the sample guidance set including at least one sample guidance data, the sample text set includes at least one sample text data, and the sample guidance data is sentence beginning data of the sample text data;
    根据所述样本引导集合和所述样本文本集合对初始对抗网络模型进行训练,并得到文本生成对抗网络模型。The initial confrontation network model is trained according to the sample guide set and the sample text set, and a text generation confrontation network model is obtained.
  11. 根据权利要求10所述的计算机设备,其中,所述初始对抗网络模型包括生成器和判别器,所述根据所述样本引导集合和所述样本文本集合对初始对抗网络模型进行训练,并得到文本生成对抗网络模型的步骤,包括:The computer device according to claim 10, wherein the initial confrontation network model includes a generator and a discriminator, and the initial confrontation network model is trained according to the sample guide set and the sample text set, and the text is obtained The steps to generate a confrontation network model include:
    通过所述生成器并根据所述样本引导集合中的至少一个样本引导数据生成至少一个样本文本数据;Generating at least one sample text data by the generator and according to at least one sample guidance data in the sample guidance set;
    采用蒙特卡洛模拟对所述至少一个样本文本数据进行模拟并获取多个样本模拟文本数据;Using Monte Carlo simulation to simulate the at least one sample text data and obtain a plurality of sample simulation text data;
    通过所述判别器并根据所述样本文本集合中的目标文本数据对所述多个样本模拟文本数据进行识别,根据识别结果更新所述生成器的参数值;Recognizing the plurality of sample simulated text data according to the target text data in the sample text set by the discriminator, and updating the parameter value of the generator according to the recognition result;
    基于更新的所述生成器并根据损失函数更新所述判别器;Update the discriminator based on the updated generator and according to the loss function;
    循环更新所述生成器和所述判别器直至所述初始对抗网络模型符合预设的收敛条件,并得到由更新后的生成器构成的所述文本生成对抗网络模型。The generator and the discriminator are cyclically updated until the initial confrontation network model meets a preset convergence condition, and the text generation confrontation network model composed of the updated generator is obtained.
  12. 根据权利要求11所述的计算机设备,其中,通过所述生成器并根据所述样本引导集合中的至少一个样本引导数据生成至少一个样本文本数据的步骤,包括:11. The computer device according to claim 11, wherein the step of generating at least one sample text data by the generator and based on at least one sample guidance data in the sample guidance set comprises:
    通过所述生成器并根据所述样本引导数据进行计算,获取词汇表中概率最大的第一样本词,将所述第一样本词添加于所述样本引导数据的末尾;Calculating by the generator and according to the sample guidance data, obtaining the first sample word with the highest probability in the vocabulary, and adding the first sample word to the end of the sample guidance data;
    通过所述生成器并根据所述第一样本词进行计算,获取词汇表中概率最大的第二样本词,将所述第二样本词添加于所述第一样本词的末尾;Calculating by the generator and according to the first sample word, obtaining the second sample word with the highest probability in the vocabulary, and adding the second sample word to the end of the first sample word;
    循环执行上述步骤直至获取预设长度的样本文本数据。Repeat the above steps until the sample text data of the preset length is obtained.
  13. 根据权利要求11所述的计算机设备,其中,采用蒙特卡洛模拟对所述至少一个样本文本数据进行模拟并获取多个样本模拟文本数据的步骤,包括:The computer device according to claim 11, wherein the step of using Monte Carlo simulation to simulate the at least one sample text data and obtaining a plurality of sample simulation text data comprises:
    采用蒙特卡洛模拟对每一个样本文本数据中的词逐个进行模拟,并生成与所述样本文本数据对应的多个样本模拟文本数据。Monte Carlo simulation is used to simulate the words in each sample text data one by one, and generate multiple sample simulated text data corresponding to the sample text data.
  14. 根据权利要求11所述的计算机设备,其中,通过所述判别器并根据所述样本文本集合中的目标文本数据对所述多个样本模拟文本数据进行识别,根据识别结果更新所述生成器的参数值的步骤,包括:The computer device according to claim 11, wherein the plurality of sample simulated text data is recognized by the discriminator and according to the target text data in the sample text set, and the generator's data is updated according to the recognition result. The steps for parameter values include:
    通过所述判别器并根据所述样本文本集合中的目标文本数据对所述多个样本模拟文本数据进行识别,根据识别结果获取状态价值函数;Recognizing the multiple sample simulated text data by the discriminator and according to the target text data in the sample text set, and obtaining a state value function according to the recognition result;
    根据所述状态价值函数计算目标函数,根据所述目标函数更新所述生成器的参数值。An objective function is calculated according to the state value function, and parameter values of the generator are updated according to the objective function.
  15. 一种计算机可读存储介质,其上存储有计算机可读指令,其中:所述计算机可读指令被处理器执行时实现文本生成方法包括下述步骤:A computer-readable storage medium having computer-readable instructions stored thereon, wherein: when the computer-readable instructions are executed by a processor, the method for generating text includes the following steps:
    采集业务对象在问答场景中生成的回答数据;Collect the answer data generated by the business object in the question and answer scenario;
    对所述回答数据进行提取,并获取目标引导数据;Extract the answer data, and obtain target guidance data;
    通过预先训练得到的文本生成对抗网络模型并根据所述目标引导数据生成目标文本数据;Generating a confrontation network model through a text obtained through pre-training, and generating target text data according to the target guidance data;
    所述目标引导数据为所述目标文本数据的句首数据。The target guide data is sentence beginning data of the target text data.
  16. 根据权利要求15所述的计算机可读存储介质,其中,在所述通过预先训练得到的文本生成对抗网络模型并根据所述目标引导数据生成目标文本数据的步骤之前,包括:15. The computer-readable storage medium according to claim 15, wherein before the step of generating a confrontation network model obtained by pre-training a text and generating target text data according to the target guidance data, the method comprises:
    获取样本引导集合和样本文本集合,所述样本引导集合包括至少一个样本引导数据,所述样本文本集合包括至少一个样本文本数据,所述样本引导数据为所述样本文本数据的句首数据;Acquiring a sample guidance set and a sample text set, the sample guidance set including at least one sample guidance data, the sample text set includes at least one sample text data, and the sample guidance data is sentence beginning data of the sample text data;
    根据所述样本引导集合和所述样本文本集合对初始对抗网络模型进行训练,并得到文本生成对抗网络模型。The initial confrontation network model is trained according to the sample guide set and the sample text set, and a text generation confrontation network model is obtained.
  17. 根据权利要求16所述的计算机可读存储介质,其中,所述初始对抗网络模型包括生成器和判别器,所述根据所述样本引导集合和所述样本文本集合对初始对抗网络模型进行训练,并得到文本生成对抗网络模型的步骤,包括:The computer-readable storage medium according to claim 16, wherein the initial confrontation network model includes a generator and a discriminator, and the initial confrontation network model is trained according to the sample guide set and the sample text set, And get the steps of text generation against the network model, including:
    通过所述生成器并根据所述样本引导集合中的至少一个样本引导数据生成至少一个样本文本数据;Generating at least one sample text data by the generator and according to at least one sample guidance data in the sample guidance set;
    采用蒙特卡洛模拟对所述至少一个样本文本数据进行模拟并获取多个样本模拟文本数据;Using Monte Carlo simulation to simulate the at least one sample text data and obtain a plurality of sample simulation text data;
    通过所述判别器并根据所述样本文本集合中的目标文本数据对所述多个样本模拟文本数据进行识别,根据识别结果更新所述生成器的参数值;Recognizing the plurality of sample simulated text data according to the target text data in the sample text set by the discriminator, and updating the parameter value of the generator according to the recognition result;
    基于更新的所述生成器并根据损失函数更新所述判别器;Update the discriminator based on the updated generator and according to the loss function;
    循环更新所述生成器和所述判别器直至所述初始对抗网络模型符合预设的收敛条件,并得到由更新后的生成器构成的所述文本生成对抗网络模型。The generator and the discriminator are cyclically updated until the initial confrontation network model meets a preset convergence condition, and the text generation confrontation network model composed of the updated generator is obtained.
  18. 根据权利要求17所述的计算机可读存储介质,其中,通过所述生成器并根据所述样本引导集合中的至少一个样本引导数据生成至少一个样本文本数据的步骤,包括:18. The computer-readable storage medium according to claim 17, wherein the step of generating at least one sample text data by the generator and based on at least one sample guidance data in the sample guidance set comprises:
    通过所述生成器并根据所述样本引导数据进行计算,获取词汇表中概率最大的第一样本词,将所述第一样本词添加于所述样本引导数据的末尾;Calculating by the generator and according to the sample guidance data, obtaining the first sample word with the highest probability in the vocabulary, and adding the first sample word to the end of the sample guidance data;
    通过所述生成器并根据所述第一样本词进行计算,获取词汇表中概率最大的第二样本词,将所述第二样本词添加于所述第一样本词的末尾;Calculating by the generator and according to the first sample word, obtaining the second sample word with the highest probability in the vocabulary, and adding the second sample word to the end of the first sample word;
    循环执行上述步骤直至获取预设长度的样本文本数据。Repeat the above steps until the sample text data of the preset length is obtained.
  19. 根据权利要求17所述的计算机可读存储介质,其中,采用蒙特卡洛模拟对所 述至少一个样本文本数据进行模拟并获取多个样本模拟文本数据的步骤,包括:The computer-readable storage medium according to claim 17, wherein the step of using Monte Carlo simulation to simulate the at least one sample text data and obtaining a plurality of sample simulation text data comprises:
    采用蒙特卡洛模拟对每一个样本文本数据中的词逐个进行模拟,并生成与所述样本文本数据对应的多个样本模拟文本数据。Monte Carlo simulation is used to simulate the words in each sample text data one by one, and generate multiple sample simulated text data corresponding to the sample text data.
  20. 根据权利要求17所述的计算机可读存储介质,其中,通过所述判别器并根据所述样本文本集合中的目标文本数据对所述多个样本模拟文本数据进行识别,根据识别结果更新所述生成器的参数值的步骤,包括:18. The computer-readable storage medium according to claim 17, wherein the plurality of sample simulated text data is recognized by the discriminator and based on the target text data in the sample text set, and the plurality of sample simulated text data is updated according to the recognition result The steps to generate parameter values for the generator include:
    通过所述判别器并根据所述样本文本集合中的目标文本数据对所述多个样本模拟文本数据进行识别,根据识别结果获取状态价值函数;Recognizing the multiple sample simulated text data by the discriminator and according to the target text data in the sample text set, and obtaining a state value function according to the recognition result;
    根据所述状态价值函数计算目标函数,根据所述目标函数更新所述生成器的参数值。An objective function is calculated according to the state value function, and parameter values of the generator are updated according to the objective function.
PCT/CN2020/118456 2020-03-02 2020-09-28 Text generation method and appartus, computer device and readable storage medium WO2021174827A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010136551.6 2020-03-02
CN202010136551.6A CN111428448B (en) 2020-03-02 2020-03-02 Text generation method, device, computer equipment and readable storage medium

Publications (1)

Publication Number Publication Date
WO2021174827A1 true WO2021174827A1 (en) 2021-09-10

Family

ID=71553527

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/118456 WO2021174827A1 (en) 2020-03-02 2020-09-28 Text generation method and appartus, computer device and readable storage medium

Country Status (2)

Country Link
CN (1) CN111428448B (en)
WO (1) WO2021174827A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116010609A (en) * 2023-03-23 2023-04-25 山东中翰软件有限公司 Material data classifying method and device, electronic equipment and storage medium
WO2024066041A1 (en) * 2022-09-27 2024-04-04 深圳先进技术研究院 Electronic letter of guarantee automatic generation method and apparatus based on sequence adversary and priori reasoning
CN117933268A (en) * 2024-03-21 2024-04-26 山东大学 End-to-end unsupervised resistance text rewriting method and device

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111428448B (en) * 2020-03-02 2024-05-07 平安科技(深圳)有限公司 Text generation method, device, computer equipment and readable storage medium
CN112036544A (en) * 2020-07-31 2020-12-04 五八有限公司 Image generation method and device
CN112861179B (en) * 2021-02-22 2023-04-07 中山大学 Method for desensitizing personal digital spatial data based on text-generated countermeasure network

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170125013A1 (en) * 2015-10-29 2017-05-04 Le Holdings (Beijing) Co., Ltd. Language model training method and device
CN106663125A (en) * 2014-08-21 2017-05-10 国立研究开发法人情报通信研究机构 Question sentence generation device and computer program
CN110019732A (en) * 2017-12-27 2019-07-16 杭州华为数字技术有限公司 A kind of intelligent answer method and relevant apparatus
CN110196899A (en) * 2019-06-11 2019-09-03 中央民族大学 A kind of low-resource language question and answer corpus library generating method
CN110619118A (en) * 2019-03-28 2019-12-27 中国人民解放军战略支援部队信息工程大学 Automatic text generation method
CN111428448A (en) * 2020-03-02 2020-07-17 平安科技(深圳)有限公司 Text generation method and device, computer equipment and readable storage medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109062937B (en) * 2018-06-15 2019-11-26 北京百度网讯科技有限公司 The method of training description text generation model, the method and device for generating description text
CN109522411B (en) * 2018-11-12 2022-10-28 南京德磐信息科技有限公司 Writing auxiliary method based on neural network
CN110162595B (en) * 2019-03-29 2023-08-29 深圳市腾讯计算机系统有限公司 Method, apparatus, device and readable storage medium for generating text summaries

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106663125A (en) * 2014-08-21 2017-05-10 国立研究开发法人情报通信研究机构 Question sentence generation device and computer program
US20170125013A1 (en) * 2015-10-29 2017-05-04 Le Holdings (Beijing) Co., Ltd. Language model training method and device
CN110019732A (en) * 2017-12-27 2019-07-16 杭州华为数字技术有限公司 A kind of intelligent answer method and relevant apparatus
CN110619118A (en) * 2019-03-28 2019-12-27 中国人民解放军战略支援部队信息工程大学 Automatic text generation method
CN110196899A (en) * 2019-06-11 2019-09-03 中央民族大学 A kind of low-resource language question and answer corpus library generating method
CN111428448A (en) * 2020-03-02 2020-07-17 平安科技(深圳)有限公司 Text generation method and device, computer equipment and readable storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024066041A1 (en) * 2022-09-27 2024-04-04 深圳先进技术研究院 Electronic letter of guarantee automatic generation method and apparatus based on sequence adversary and priori reasoning
CN116010609A (en) * 2023-03-23 2023-04-25 山东中翰软件有限公司 Material data classifying method and device, electronic equipment and storage medium
CN117933268A (en) * 2024-03-21 2024-04-26 山东大学 End-to-end unsupervised resistance text rewriting method and device

Also Published As

Publication number Publication date
CN111428448B (en) 2024-05-07
CN111428448A (en) 2020-07-17

Similar Documents

Publication Publication Date Title
WO2021174827A1 (en) Text generation method and appartus, computer device and readable storage medium
CN109447156B (en) Method and apparatus for generating a model
CN110717023B (en) Method and device for classifying interview answer text, electronic equipment and storage medium
KR102265573B1 (en) Method and system for reconstructing mathematics learning curriculum based on artificial intelligence
Käser et al. When to stop? Towards universal instructional policies
CN112487139A (en) Text-based automatic question setting method and device and computer equipment
KR20210001419A (en) User device, system and method for providing interview consulting service
CN111694937A (en) Interviewing method and device based on artificial intelligence, computer equipment and storage medium
Intisar et al. Classification of online judge programmers based on rule extraction from self organizing feature map
CN111753076A (en) Dialogue method, dialogue device, electronic equipment and readable storage medium
CN114254127A (en) Student ability portrayal method and learning resource recommendation method and device
CN117808946B (en) Method and system for constructing secondary roles based on large language model
CN117218482A (en) Model training method, video processing device and electronic equipment
CN117876090A (en) Risk identification method, electronic device, storage medium, and program product
CN116541507A (en) Visual question-answering method and system based on dynamic semantic graph neural network
CN117235633A (en) Mechanism classification method, mechanism classification device, computer equipment and storage medium
Lin et al. A multimodal dialogue system for conversational image editing
CN117112742A (en) Dialogue model optimization method and device, computer equipment and storage medium
WO2024098282A1 (en) Geometric problem-solving method and apparatus, and device and storage medium
CN115935071A (en) Knowledge point recommendation method and device, storage medium and electronic equipment
CN113204973B (en) Training method, training device, training equipment and training storage medium for answer questions and questions recognition model
CN112231373B (en) Knowledge point data processing method, apparatus, device and computer readable medium
CN114862636A (en) Financial intelligent teaching and privacy protection method
US11501654B2 (en) Automated decision making for selecting scaffolds after a partially correct answer in conversational intelligent tutor systems (ITS)
CN113822589A (en) Intelligent interviewing method, device, equipment and storage medium

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: 20922955

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: 20922955

Country of ref document: EP

Kind code of ref document: A1