Specific embodiment
The disclosure is described in further detail with embodiment with reference to the accompanying drawing.It is understood that this place
The specific embodiment of description is only used for explaining related content, rather than the restriction to the disclosure.It also should be noted that being
Convenient for description, part relevant to the disclosure is illustrated only in attached drawing.
It should be noted that in the absence of conflict, the feature in embodiment and embodiment in the disclosure can
To be combined with each other.The disclosure is described in detail below with reference to the accompanying drawings and in conjunction with embodiment.
Conversational system generally includes language understanding module, dialogue management module and spatial term module.Natural language
Generation module generates natural language generally according to the input of language understanding module.
According to the first embodiment of the disclosure, a kind of spatial term method is provided.
Referring to Fig. 1, which includes: that information analyzing step S11, stencil-chosen step S12, variable are filled out
Fill step S13 and language generation step S14.
In information analyzing step S11, dialog state information is subjected to information parsing to obtain scheduled data type.
Dialog state information refers to the input of natural language generation system, for example, may include product information, user be intended to,
Talk time etc..Product information for example can be product type information etc..User, which is intended to can be, carries out language to user speech
User intent information obtained from after understanding.Talk time can for example pass through the time in the time of system or user speech
Etc. determining.For example, by product information, to different equipment generate it is different if art, such as can be with for certain products
Brief language etc. is generated, and some products can be generated with abundant in content language etc..
When dialog state information is parsed, dialog state information can be parsed into the data type that system can be read
Deng.
In stencil-chosen step S12, select to correspond to according to information parsing result obtained in information analyzing step S11
Template.For example, suitable template is selected from the template being saved according to the dialog state information after parsing, for example,
The template for meeting condition is selected according to product information, user's intention and talk time.
In an optional embodiment of the disclosure, it can be looked for using the way of search of tree corresponding
Template, such as shared template 1000, select 100 therein by product information first, further according to such as user intention and
The other informations such as time are selected, the template until selecting the condition of satisfaction.For example, the possible form of template are as follows: " $ time $'s
Weather is $ number $ degree ", wherein time (time) and number (numerical value) they are the variable for needing to fill.
In variable filling step S13, required dialog state information variable is filled to the corresponding position of selected template.
For example, template " weather of $ time $ is $ number $ degree " has been selected, according to user when user inquires " today, how much weather spent "
Intention is filled the time in template, and is for example carried out number by the result for calling search module to scan for
Filling.At this moment, the text ultimately produced may be " weather of today is 23 degree ".
According to text generation natural language in language generation step S14.
In above-mentioned spatial term method, for same semanteme, the text that can also have form different carrys out table
It reaches, even for specific word, can also have other synonyms to express same semanteme, such as these can pass through template
It is arranged to realize.
According to the second embodiment of the disclosure, a kind of spatial term method is provided.Referring to Fig. 2, this method packet
It includes: information analyzing step S21, stencil-chosen step S22, variable filling step S23, diversification step S24 and language generation step
Rapid S25.
Wherein above-mentioned information analyzing step S21, stencil-chosen step S22, variable filling step S23 and language generation step
Rapid S25 can respectively with the information analyzing step S11 of first embodiment, stencil-chosen step S12, variable filling step S13
And language generation step S14 is identical, details are not described herein.
It is different from the first embodiment, increases diversification step S24 in this second embodiment.Pass through the step
The information that flexile expression way can be formed preferably to help user to understand that system is conveyed, and but also system
It shows more flexible.
In this step, sequence to sequence can be utilized according to the text and dialog state information of filled template
(sequence to sequence;Seq2seq) model exports the diversified natural language of different semantemes.
The sequence that one inputs can be mapped as the sequence of an output by deep neural network model by seq2seq.
It can be formed by inputting with two links of decoded output.
As shown in figure 3, sequence includes encoder and decoder to series model, the conversion of the generation text of rear pattern plate is filled
Input of the term vector afterwards as encoder, input of the output and dialog state information of encoder as decoder, and solve
The code diversified text of device final output.Specifically, the generation text for filling rear pattern plate is segmented, and will be after participle
Each word be converted into term vector, the term vector after conversion is input to LSTM network, to be encoded to intermediate semantic vector.Pass through
When SC-LSTM network generates the natural language of different words arts according to intermediate semantic vector and dialog state information, by intermediate language
Adopted vector and dialog state information are input to SC-LSTM network;The output of the SC-LSTM network at each moment is through full connection nerve
Suitable output word is selected after network by softmax function;The output phrase at multiple moment is synthesized into a nature
Language;And the natural language of different words arts is generated by different output word combinations.
In accordance with one embodiment of the present disclosure, (Long Short-Term is remembered using shot and long term in encoder
Memory;LSTM) network, the text based on generation are encoded to intermediate semantic vector by LSTM.
LSTM network structure is as shown in Figure 4 comprising three doors are to forget door, input gate and out gate respectively.
The state that LSTM leans on these special " door " structures that information is allowed selectively to influence each moment in Recognition with Recurrent Neural Network.
The structure of these three " doors " is similar, is all to do multiplication by using sigmoid neural network and step-by-step to complete.
Why the structure be referred to as " door ", be because use sigmoid as the fully connected network network layers of activation primitive can export one 0~
Numerical value between 1, description currently input that how many information content can pass through.When the output of sigmoid neural net layer is 1,
All information can pass through;When the output of sigmoid neural net layer is 0, all information can not all pass through.
Otiose information in state before the effect for forgeing door is Recognition with Recurrent Neural Network discarding, by current input xt、
Last moment state Ct-1H is exported with last momentt-1It codetermines.
The effect of input gate is back-propagation in useful component addition state in the input by current time, and by current
Input xt, last moment state Ct-1H is exported with last momentt-1It codetermines.Forget door ft" input gate " itExpression such as
Under:
ft=σ (Wf·[ht-1,xt]+bf) (1)
it=σ (Wi·[ht-1,xt]+bi) (2)
Wherein, WfAnd WiRespectively indicate the weight matrix for forgeing door and input gate, bfAnd biIt respectively indicates and forgets door and input
The deviation of door, σ indicate sigmoid activation primitive.
The transitory state at current time indicates are as follows:
Wherein, WcIndicate weight matrix, bcIt indicates to be biased to, tanh indicates tanh activation primitive.
After obtaining the transitory state at current time, current time state can be obtained by forgeing door and input gate:
New state C is being calculated in LSTM structuretNeed to generate the output at current time afterwards, this process is by defeated
It gos out completion.Out gate can be according to current time state Ct, last moment output ht-1With current input xtTo determine to work as
The output h at preceding momentt.As shown in formula (5) and (6).
Ot=σ (WO·[ht-1,xt]+bO) (5)
ht=Ot·tanh(Ct) (6)
As shown in figure 3, input of the intermediate semantic vector of encoder output as decoder, and dialog state information
Input as decoder.In a decoder, the shot and long term memory (Semantically of semantic facility can be used
Conditioned Long Short-Term Memory;SC-LSTM) network.
SC-LSTM network is dialog state information to be carried out one-hot coding, and joined on the basis of LSTM network
New door (reading gate) is used to management of dialogs status information, and formula is as follows:
ir=σ (Wr·[ht-1,xt]+bi) (7)
The state information updating at current time are as follows:
dt=ir·dt-1 (8)
Assuming that output of the output of SC-LSTM network through original neural network is y1, y2 ..., yn, passing through softmax
Output after recurrence processing are as follows:
As can be seen that the output of original neural network is used as confidence level to generate new output from formula (9), and newly
Output meets being required for probability distribution.This new output can be understood as the derivation by neural network, a sample
It is much respectively for different classes of probability.The output of neural network is also thus become a probability distribution, so as to
With the maximum word of select probability.
Therefore, it is the sentence finally exported by the sentence that seq2seq is generated, passes through SC-LSTM network and different pairs
Speech phase information generates randomness, to export the diversified language of different semantemes.
In the following, will be illustrated in conjunction with specific example to disclosed method.
For example, the problem of user is " today, how is weather ", then user is provided in language understanding module and be intended to " day
Gas ", time are " today ".
Because user is intended to " weather ", then dialogue management module can call corresponding weather search service.
Can also based on context it judge certainly for information such as user's intentions, for example, being in short on user
User can be intended to be judged as " weather " at this time when user says " tomorrow " by " today, how is weather ".
User's intention, time etc. can be regard as dialog state information, spatial term processing is carried out according to it.
Spatial term processing, is parsed first, is converted into desired data type, then for example first can root
Template is selected according to " weather ", template then can be further selected according to " time ", suitable template is finally selected, according to upper
Search result is stated, variable padding is carried out, " today, Beijing weather was fine " at this moment for example can be generated.
The input of encoder as seq2seq model, is first segmented " today, weather was fine " by segmentation methods,
For example, being " today, weather was fine " after participle.It needs to translate text into character matrix after participle.Pass through the calculation of such as Word2vec
The word after participle is converted corresponding term vector by method, such as converts a n-dimensional vector for a word, and n is scheduled, such as can
Think 100.Such as following convert: today can be carried out: [0.12 0.13 0.53 ...] (n number);Weather: [0.92
0.14 0.73 ...] (n number);It is fine: [0.62 0.43 0.13 ...] (n number)." today, weather was fine " this sentence in this way
Words are just converted for a matrix, and each word sequentially inputs LSTM network, and LSTM network can all export the vector of n dimension, finally
After one word input, the n-dimensional vector of LSTM network output is exactly intermediate semantic vector, the information of all words before it is contained.
The obtained SC-LSTM network as the intermediate semantic vector and dialog state information of n-dimensional vector as decoder
Input, the output of each moment SC-LSTM network can choose out one by softmax function after full Connection Neural Network
A most suitable word, the output at multiple moment can be spliced into short.Therefore, if different output combination is exactly different
Art.Such as the diversified language of the different language arts such as output " today is fine, is suitble to carwash ", " today, weather was fine, it is proposed that goes on a tour "
Speech.
According to the third of the disclosure, embodiment there is provided a kind of spatial term devices.As shown in figure 5, the nature
Language generation device 500 includes: information analysis module 501, template selection module 502, variable filling module 503 and language generation
Module 504.
Wherein, it is scheduled to obtain to be carried out information parsing by the information analysis module 501 for the received dialog state information of institute
Data type, template selection module 502 select corresponding template according to information parsing result, and variable fills module 503, will
Required dialog state information variable is filled to the corresponding position of selected template and language generation module 504, after filling
The text of template generates natural language.
Processing conducted in above-mentioned modules is corresponding with the method for the first embodiment of the disclosure, herein no longer
It repeats.
According to the 4th embodiment of the disclosure, a kind of spatial term device is additionally provided.As shown in fig. 6, should be certainly
Right language generation device 600 includes: information analysis module 601, template selection module 602, variable filling module 603, diversification
Module 604 and language generation module 605.
Present embodiment increases diversified module on the basis of third embodiment.Wherein in diversified module 604
In, the intermediate semantic vector and dialog state information generated according to the text of filled template is defeated using seq2seq model
The diversified natural language of different semantemes out.The encoder of seq2seq model passes through LSTM net according to the text of filling rear pattern plate
Network is encoded to intermediate semantic vector, and seq2seq solution to model code device is by SC-LSTM network according to intermediate semantic vector and dialogue
Status information exports the diversified natural languages of different semantemes.
Processing conducted in above-mentioned modules is corresponding with the method for the second embodiment of the disclosure, herein no longer
It repeats.
According to the disclosure, it can solve art if natural language generation system generates and lack multifarious problem, to make
The performance for the system of obtaining is more flexible.
The disclosure also provides a kind of computer equipment, as shown in fig. 7, the equipment includes: communication interface 1000, memory
2000 and processor 3000.Communication interface 1000 carries out data interaction for being communicated with external device.Memory
The computer program that can be run on processor 3000 is stored in 2000.Processor 3000 executes real when the computer program
Method in existing above embodiment.The quantity of the memory 2000 and processor 3000 can be one or more.
Memory 2000 may include high speed RAM memory, can also further include nonvolatile memory (non-
Volatile memory), a for example, at least magnetic disk storage.
If communication interface 1000, memory 2000 and the independent realization of processor 3000, communication interface 1000, memory
2000 and processor 3000 can be connected with each other by bus and complete mutual communication.The bus can be industrial standard
Architecture (ISA, Industry Standard Architecture) bus, external equipment interconnection (PCI, Peripheral
Component) bus or extended industry-standard architecture (EISA, Extended Industry Standard
Component) bus etc..The bus can be divided into address bus, data/address bus, control bus etc..For convenient for expression, the figure
In only indicated with a thick line, it is not intended that an only bus or a type of bus.
Optionally, in specific implementation, if communication interface 1000, memory 2000 and processor 3000 are integrated in one
On block chip, then communication interface 1000, memory 2000 and processor 3000 can complete mutual lead to by internal interface
Letter.
Any process described otherwise above or method description are construed as in flow chart or herein, and expression includes
It is one or more for realizing specific logical function or process the step of executable instruction code module, segment or portion
Point, and the range of the preferred embodiment of the disclosure includes other realization, wherein can not press shown or discussed suitable
Sequence, including according to related function by it is basic simultaneously in the way of or in the opposite order, Lai Zhihang function, this should be by the disclosure
Embodiment person of ordinary skill in the field understood.Processor executes each method as described above and processing.
For example, the method implementation in the disclosure may be implemented as computer software programs, being tangibly embodied in machine can
Read medium, such as memory.In some embodiments, some or all of of computer software programs can be via memory
And/or communication interface and be loaded into and/or install.When computer software programs are loaded into memory and are executed by processor,
One or more steps in method as described above can be executed.Alternatively, in other embodiments, processor can lead to
It crosses other any modes (for example, by means of firmware) appropriate and is configured as executing one of above method.
Expression or logic and/or step described otherwise above herein in flow charts, may be embodied in any
In computer-readable medium, for instruction execution system, device or equipment (such as computer based system, including processor
System or other can be from instruction execution system, device or equipment instruction fetch and the system executed instruction) use, or combine these
Instruction execution system, device or equipment and use.
For the purpose of this specification, " computer-readable medium ", which can be, any may include, stores, communicates, propagates or pass
Defeated program is for instruction execution system, device or equipment or the dress used in conjunction with these instruction execution systems, device or equipment
It sets.The more specific example (non-exhaustive list) of computer-readable medium include the following: there is the electricity of one or more wirings
Interconnecting piece (electronic device), portable computer diskette box (magnetic device), random access memory (RAM), read-only memory
(ROM), erasable edit read-only storage (EPROM or flash memory), fiber device and portable read-only memory
(CDROM).In addition, computer-readable medium can even is that the paper that can print described program on it or other suitable Jie
Matter, because can then be edited, be interpreted or when necessary with other for example by carrying out optical scanner to paper or other media
Suitable method is handled electronically to obtain described program, is then stored in computer storage.
It should be appreciated that each section of the disclosure can be realized with hardware, software or their combination.In above-mentioned embodiment party
In formula, multiple steps or method can carry out reality in memory and by the software that suitable instruction execution system executes with storage
It is existing.It, and in another embodiment, can be in following technology well known in the art for example, if realized with hardware
Any one or their combination are realized: having a discrete logic for realizing the logic gates of logic function to data-signal
Circuit, the specific integrated circuit with suitable combinational logic gate circuit, programmable gate array (PGA), field-programmable gate array
Arrange (FPGA) etc..
Those skilled in the art are understood that realize all or part of the steps of above embodiment method
It is that relevant hardware can be instructed to complete by program, the program can store in a kind of computer readable storage medium
In, which when being executed, includes the steps that one or a combination set of method implementation.
In addition, can integrate in a processing module in each functional unit in each embodiment of the disclosure, it can also
To be that each unit physically exists alone, can also be integrated in two or more units in a module.It is above-mentioned integrated
Module both can take the form of hardware realization, can also be realized in the form of software function module.The integrated module
If in the form of software function module realize and when sold or used as an independent product, also can store one calculating
In machine readable storage medium storing program for executing.The storage medium can be read-only memory, disk or CD etc..
In the description of this specification, reference term " an embodiment/mode ", " some embodiment/modes ",
The description of " example ", " specific example " or " some examples " etc. means the embodiment/mode or example is combined to describe specific
Feature, structure, material or feature are contained at least one embodiment/mode or example of the application.In this specification
In, schematic expression of the above terms are necessarily directed to identical embodiment/mode or example.Moreover, description
Particular features, structures, materials, or characteristics can be in any one or more embodiment/modes or example in an appropriate manner
In conjunction with.In addition, without conflicting with each other, those skilled in the art can be by different implementations described in this specification
Mode/mode or example and different embodiments/mode or exemplary feature are combined.
In addition, term " first ", " second " are used for descriptive purposes only and cannot be understood as indicating or suggesting relative importance
Or implicitly indicate the quantity of indicated technical characteristic.Define " first " as a result, the feature of " second " can be expressed or
Implicitly include at least one this feature.In the description of the present application, the meaning of " plurality " is at least two, such as two, three
It is a etc., unless otherwise specifically defined.
It will be understood by those of skill in the art that above embodiment is used for the purpose of clearly demonstrating the disclosure, and simultaneously
Non- be defined to the scope of the present disclosure.For those skilled in the art, may be used also on the basis of disclosed above
To make other variations or modification, and these variations or modification are still in the scope of the present disclosure.