CN110046338A - A kind of context selection method, device, electronic equipment and storage medium - Google Patents
A kind of context selection method, device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN110046338A CN110046338A CN201810035965.2A CN201810035965A CN110046338A CN 110046338 A CN110046338 A CN 110046338A CN 201810035965 A CN201810035965 A CN 201810035965A CN 110046338 A CN110046338 A CN 110046338A
- Authority
- CN
- China
- Prior art keywords
- word
- source
- current time
- phrase structure
- context
- Prior art date
- Legal status (The legal status 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 status listed.)
- Granted
Links
- 238000010187 selection method Methods 0.000 title claims abstract description 43
- 238000004458 analytical method Methods 0.000 claims abstract description 117
- 239000013598 vector Substances 0.000 claims abstract description 65
- 238000000034 method Methods 0.000 claims abstract description 39
- 238000012549 training Methods 0.000 claims description 21
- 230000006870 function Effects 0.000 claims description 17
- 230000000630 rising effect Effects 0.000 claims description 3
- 238000010586 diagram Methods 0.000 description 11
- 238000013528 artificial neural network Methods 0.000 description 8
- 238000004891 communication Methods 0.000 description 7
- 238000012545 processing Methods 0.000 description 4
- 230000000306 recurrent effect Effects 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 3
- BULVZWIRKLYCBC-UHFFFAOYSA-N phorate Chemical compound CCOP(=S)(OCC)SCSCC BULVZWIRKLYCBC-UHFFFAOYSA-N 0.000 description 3
- 230000004927 fusion Effects 0.000 description 2
- 230000001537 neural effect Effects 0.000 description 2
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000006835 compression Effects 0.000 description 1
- 238000007906 compression Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000005611 electricity Effects 0.000 description 1
- 239000013604 expression vector Substances 0.000 description 1
- 239000004744 fabric Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 210000005036 nerve Anatomy 0.000 description 1
- 238000003062 neural network model Methods 0.000 description 1
- 210000002569 neuron Anatomy 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 238000013519 translation Methods 0.000 description 1
- 239000011800 void material Substances 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/205—Parsing
- G06F40/211—Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Health & Medical Sciences (AREA)
- Artificial Intelligence (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Machine Translation (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the present invention provides a kind of context selection method, device, electronic equipment and storage medium, this method comprises: obtaining the corresponding source vector of source sentence indicates sequence;The object element that need to be predicted according to current time, it is assumed that the target source word that the object element is aligned in source sentence;According to the target source word, current time corresponding phrase structure and half phrase structure are separated out from source sentence, wherein the phrase structure is at least deterministic;Sequence is indicated according at least to the target source word, the phrase structure, half phrase structure and the source vector, determines current time corresponding context.The embodiment of the present invention can promote the comprehensive of captured context, promote the precision of context selection, provide possibility to promote the precision of the results such as syntactic analysis.
Description
Technical field
The present invention relates to field of artificial intelligence, and in particular to a kind of context selection method, device, electronic equipment and
Storage medium.
Background technique
Context selection is a stage of the processes such as syntactic analysis, machine translation, is mainly used for pre- every time in decoder
When surveying an object element, context is selected from the expression of the vector of source, to realize the prediction of object element.
By taking the syntactic analysis model of encoder and decoder framework as an example, when carrying out syntactic analysis, source sentence (needs to carry out
The natural language sentences of syntactic analysis can be described as source sentence) input syntactic analysis model after, encoder produce source sentence it is corresponding
Source vector indicate sequence (the source vector indicate sequence include source sentence in each source word vector indicate), decoder
(element is the composition of syntactic analysis result, and the sequence being made of each element can form syntactic analysis when one element of prediction every time
As a result), the attention layer in syntactic analysis model can select context from the expression of the vector of source, with the pre- of auxiliary element
It surveys, to generate syntactic analysis result after the prediction for completing each element.
The selection of context mainly passes through attention layer and realizes, attention layer relies primarily on attention based on probability at present
Mechanism, by generating a discrete probability distribution, to indicate that the object element of current predictive is aligned with source word in source sentence
Probability, the selection of Lai Shixian context.However, it was found by the inventors of the present invention that attention mechanism based on probability can not be complete
The capture context in face such as can not capture didactic contexts some in syntactic analysis scene, context is caused to select
As a result precision reduces, and influences the precision of the results such as syntactic analysis.
Summary of the invention
In view of this, the embodiment of the present invention provides a kind of context selection method, device, electronic equipment and storage medium,
To promote the precision of context selection.
To achieve the above object, the embodiment of the present invention provides the following technical solutions:
A kind of context selection method, comprising:
Obtaining the corresponding source vector of source sentence indicates sequence;
The object element that need to be predicted according to current time, it is assumed that the target source that the object element is aligned in source sentence
Word;
According to the target source word, current time corresponding phrase structure and half phrase structure are separated out from source sentence;
Wherein, the phrase structure is at least deterministic;
Sequence is indicated according at least to the target source word, the phrase structure, half phrase structure and the source vector, really
Determine current time corresponding context.
The embodiment of the present invention also provides a kind of context selection device, comprising:
Source sequence vector obtains module, indicates sequence for obtaining the corresponding source vector of source sentence;
Target source word determining module, the object element for that need to be predicted according to current time, it is assumed that the object element exists
The target source word being aligned in source sentence;
Separating modules, for being separated out current time corresponding phrase structure from source sentence according to the target source word
With half phrase structure;Wherein, the phrase structure is at least deterministic;
Context output module, for according at least to the target source word, the phrase structure, half phrase structure and described
Source vector indicates sequence, determines current time corresponding context.
The embodiment of the present invention also provides a kind of electronic equipment, comprising: at least one processor and at least one processor;Institute
It states memory and is stored with program, the processor calls described program, to realize the step of context selection method described above
Suddenly.
The embodiment of the present invention also provides a kind of storage medium, and the storage medium is stored with the journey executed suitable for processor
Sequence, the step of to realize context selection method described above.
Based on the above-mentioned technical proposal, context selection method provided in an embodiment of the present invention, comprising: it is corresponding to obtain source sentence
Source vector indicate sequence;The object element that need to be predicted according to current time, it is assumed that the object element is right in source sentence
Neat target source word;According to the target source word, current time corresponding phrase structure and half phrase are separated out from source sentence
Structure, wherein the phrase structure is at least deterministic;According at least to the target source word, the phrase structure, half phrase
Structure and the source vector indicate sequence, determine current time corresponding context.The embodiment of the present invention is when determination is current
After carving corresponding phrase structure and half phrase structure, current time corresponding phrase structure is known, deterministic, and current
The moment starting word of corresponding half phrase structure is known;Therefore according to the target source word, it is described deterministic current when
Carve corresponding phrase structure, deterministic starting word and the source vector indicate sequence in half phrase structure, when determining current
The context of selection is carved, the certainty of the context of current time selection can be promoted, promote the comprehensive of captured context,
Possibility is provided to promote the precision of syntactic analysis result.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below
There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this
The embodiment of invention for those of ordinary skill in the art without creative efforts, can also basis
The attached drawing of offer obtains other attached drawings.
Exemplary diagram of Fig. 1 prior art based on probability attention mechanism selection context;
Fig. 2 is the flow chart of context selection method provided in an embodiment of the present invention;
Fig. 3 is another flow chart of context selection method provided in an embodiment of the present invention;
Fig. 4 is the exemplary diagram that the embodiment of the present invention selects context based on certainty attention mechanism;
Fig. 5 is the topology example figure of syntactic analysis model provided in an embodiment of the present invention;
Fig. 6 is another topology example figure of syntactic analysis model provided in an embodiment of the present invention;
Fig. 7 is the flow chart of syntactic analysis method provided in an embodiment of the present invention;
Fig. 8 is the exemplary diagram of syntax tree sequence;
Fig. 9 is the training method flow chart of syntactic analysis model provided in an embodiment of the present invention;
Figure 10 is the Sample Scenario figure of syntactic analysis provided in an embodiment of the present invention;
Figure 11 is the structural block diagram of context selection device provided in an embodiment of the present invention;
Figure 12 is another structural block diagram of context selection device provided in an embodiment of the present invention;
Figure 13 is another structural block diagram of context selection device provided in an embodiment of the present invention;
Figure 14 is the hardware block diagram of electronic equipment.
Specific embodiment
Problem of the existing technology for ease of understanding, taking the example shown in figure 1, source sentence are " John has adog. ",
After encoder generates corresponding source vector expression sequence to source sentence, attention layer is based on probability attention in the prior art
Mechanism for the selection of context can dotted line as shown in Figure 1, dotted line indicate be a discrete probability distribution;The discrete probabilistic point
Cloth is with quantity value corresponding with the source word quantity in source sentence (discrete probability distribution has 5 values as shown in figure 1), each
Value corresponds to a source word in source sentence;Wherein, a parameter probability valuing indicates the object element that decoder need to currently be predicted
It is (current as shown in Figure 1 to carry out y5Prediction), source word in source sentence corresponding with the parameter probability valuing is aligned probability;
And it was found by the inventors of the present invention that with some didactic contexts, for example scheming in the scenes such as syntactic analysis
Y in 13It should snap to John, y is assisted with this3The selection of context when prediction;However, based on probability attention mechanism
Attention layer often lacks capture for this didactic context, and has the didactic of information content due to lacking these very
Context, the precision that will lead to selected context is lower, influences the precision of syntactic analysis result;This is also in the prior art
The problems of universal selects context based on probability attention mechanism,.
Based on this, the embodiment of the present invention considers to pay attention to when decoder prediction generates each element using based on certainty
The attention layer of power mechanism carries out the selection of context, to promote comprehensive, the selected works above and below promotion of the context for capture
The precision selected.
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other
Embodiment shall fall within the protection scope of the present invention.
Fig. 2 is the flow chart of context selection method provided in an embodiment of the present invention, and this method can be applied to electronic equipment,
Server (such as realizing syntactic analysis process in server side) can be selected in electronic equipment, and terminal also can be selected and realize (such as at end
Realize syntactic analysis process etc. in end side);As an example, context selection method shown in Fig. 2 can pass through syntactic analysis mould
Attention layer in type realizes that the syntactic analysis model may be set to server side, realizes syntactic analysis process by server,
It may also be set to terminal side, syntactic analysis process is realized by terminal;
Referring to Fig. 2, context selection method provided in an embodiment of the present invention may include:
Step S100, according to the object element that current time need to be predicted, it is assumed that the object element is aligned in source sentence
Target source word.
Optionally, by source sentence input coding device, encoder carries out vector generation to each source word in source sentence one by one, can
Obtaining the corresponding source vector of source sentence indicates sequence;Sequence is indicated to which attention layer obtains the corresponding source vector of source sentence
Afterwards, the attention layer provided in an embodiment of the present invention based on certainty attention mechanism, can be by method shown in Fig. 2 when each
The selection for carrying out context is carved, an element generally can be predicted in a moment decoder.
Optionally, at current time, the element that current time need to be predicted can be described as being object element;With syntactic analysis scene
For, element is the composition that can be syntactic analysis result, it is to be understood that the object element that current time need to be predicted is not
Know, is the element in the syntactic analysis result that need to be predicted at current time;As syntactic analysis is indicated with syntax tree sequence as a result, if
The object element that current time need to be predicted may be considered, and be the element in the syntax tree sequence that need to be predicted at current time, syntax
Tree sequence can be made of the element that each moment is predicted;Syntax tree may be considered the tree table of syntactic analysis result
Show.
When that need to predict the object element at current time, the embodiment of the present invention can be assumed that the object element in the original sentence
The target source word being aligned in son;The target source word may be considered, and the object element is indicating a certain source in source sentence
In the case where word, object element source word corresponding in source sentence;
Optionally, since the object element that current time is predicted has a variety of possible values types, current time
The object element predicted does not necessarily mean that a certain source word in source sentence;As an example, element possible values type
Range may include: terminal symbol (generally being indicated with " XX "), left bracket is (generally with " (" indicate), right parenthesis (generally with ") "
It indicates);In general, the object element predicted just can be to certain in source sentence when the Value Types of object element are terminal symbol
One source word is indicated, therefore the object element predicted of current time does not necessarily mean that a certain source word in source sentence;
Based on this, the embodiment of the present invention can be assumed that the object element that current time is predicted is indicating the source word in source sentence
In the case where, it is assumed that the source word that the object element is aligned in the source sentence;For example it is assumed that the Value Types of object element are
When terminal symbol, object element corresponding target source word in source sentence is determined.
Step S110, according to the target source word, current time corresponding phrase structure and half are separated out from source sentence
Phrase structure;Wherein, the phrase structure is at least deterministic.
Optionally, after determining the target source word, the embodiment of the present invention can be according to the target source word, from source sentence
In be separated out current time corresponding phrase structure and half phrase structure;In embodiments of the present invention, the phrase structure is at least
It is deterministic, and half phrase structure is at least known originates word;
Optionally, phrase structure and half phrase structure can comprising starting word and end word, phrase structure can be by
The source word that the starting word and end word of phrase structure are covered in source sentence constitutes (word in source sentence can be described as source word), and half
Phrase structure can be to be made of the source word that the starting word and end word of half phrase structure are covered in source sentence;
In embodiments of the present invention, phrase structure is deterministic, i.e., the starting word of phrase structure and end word are to know
's;As a kind of optional example, the end word of phrase structure can be the previous word of target source word described in source sentence, originate word
Can be the word before the end word of phrase structure, can by the case where to assume the Value Types of the object element be right parenthesis into
Row determines;
In embodiments of the present invention, half phrase structure at least knows to originate word;As a kind of optional example, half phrase structure
Starting word can be the target source word, end word can be any word unknown after target source word in source sentence;Certainly
The embodiment of the present invention can also support the case where known to the end word of half phrase structure.
Step S120, according at least to the target source word, the phrase structure, half phrase structure and the source vector table
Show sequence, determines current time corresponding context.
Optionally, when carrying out the element prediction at each moment, method shown in Fig. 2 is can be performed in the embodiment of the present invention, is carried out
Corresponding context selection;To which at each moment, the context accordingly selected, auxiliary decoder device carries out each moment
Element prediction forms syntax tree sequence by the element that each moment is predicted, obtains syntactic analysis result.
In embodiments of the present invention, after determining current time corresponding phrase structure and half phrase structure, current time
Corresponding phrase structure is known, deterministic, and the starting word of current time corresponding half phrase structure is known;Cause
This is according to deterministic starting in the target source word, deterministic current time corresponding phrase structure, half phrase structure
Word and the source vector indicate sequence, determine the context of current time selection, can promote the upper and lower of current time selection
The certainty of text promotes the comprehensive of captured context, provides possibility to promote the precision of syntactic analysis result.
As an example, source sentence x can be set by x1To xnN word constitute, it is assumed that the target element that current time need to be predicted
The target source word that element is aligned in source sentence is xt, current time corresponding phrase structure is ρ (xb, xt-1), wherein xbIt is described
The starting word of phrase structure, and the end word of the phrase structure is the target source word xtPrevious word the case where;When current
Carving corresponding half phrase structure is ρ (xt,?), wherein? (question mark) can indicate target source word x in source sentencetAny unknown later
Word, xbAnd xtBelong to x1To xnIn source word;
Then determining the target source word, after current time corresponding phrase structure and half phrase structure, it is selected on
Hereafter ctDefinition can be such as formula 1;
ct=φ (ρ (xb, xt-1),ρ(xt,?), xt,Ex) (formula 1)
Wherein, ExThe source vector of presentation code device output indicates sequence;φ indicates the starting word of the phrase structure
The connection operation result that vector indicates, the vector of end word indicates and the vector of the starting word of half phrase structure indicates, with
The dot product of attention layer parameter.
The calculating of above-mentioned formula 1 may be considered the calculating of a vector correlation, for ρ (xt,?) end word may be not
The case where knowing can ignore ρ (x in calculating processt,?) end word.
Optionally, as a kind of optional realization, the definition of φ can be as shown in formula 2;
Wherein, θcIndicate the parameter of the attention layer provided in an embodiment of the present invention based on certainty attention mechanism,
Indicate the starting word x of current time corresponding phrase structurebVector indicate,Indicate current time corresponding phrase structure
End word vector indicate,Indicate that the vector of the target source word indicates;[;;] indicate vector connection operation.
φ's is defined on three word x it can be seen from formula 2b,xt-1And xtOn, and if encoder uses RNN (circulation
Neural network) source sentence is encoded, then xtCoding express the word x adjacent with it to a certain extentt-1Information, because
This, the present invention also realizes the definition of φ simplified as follows, as shown in formula 3;
Further, similar, xtX can also be expressedbPartial information, can the definition to φ further simplified, it is such as public
Shown in formula 4;
Correspondingly, context ctDefinition can be expressed as formula 5:
Correspondingly, when carrying out the prediction of the element at each moment, can be determined at each moment during syntactic analysis
After corresponding target source word, phrase structure and half phrase structure, the selection of the context at each moment is carried out with formula 5, thus
Auxiliary decoder device carries out the prediction of the element at each moment, realizes obtaining for syntactic analysis result.
It should be noted that the definition shown in above-mentioned formula 2, formula 3 and formula 4 to φ, can select one and bring formula 1 into
In, the prediction of context is carried out, the embodiment of the present invention is not intended to limit;Certainly, mode shown in formula 5 is relatively simple.
Foregoing description content be only above step S120 " according at least to the target source word, the phrase structure, half phrase
Structure and the source vector indicate sequence, determine current time corresponding context " a kind of optional way, the present invention implemented
Example can also be not limited to the selection that above-mentioned formula mode carries out context.
It optionally, include: terminal symbol with element possible values Type Range, left bracket, for right parenthesis;The present invention is implemented
Example can estimate the object element possible values type that need to be predicted at current time;And the case where according to each Value Types estimated,
Carry out the determination of target source word, current time corresponding phrase structure and half phrase structure;
Optionally, Fig. 3 shows another flow chart of context selection method provided in an embodiment of the present invention, referring to Fig. 3,
This method may include:
Step S200, when the Value Types for assuming the object element that current time need to be predicted are terminal symbol, the target is determined
The target source word that element is aligned in the source sentence.
Optionally, the case where possible values type for the object element that current time need to be predicted, is divided into terminal symbol, left bracket,
Right parenthesis these three;It is unknown, therefore the embodiment of the present invention can be assumed that object element since object element does not predict also
Value Types are terminal symbol, and determine the target source word being aligned in source sentence accordingly.
As an example, the embodiment of the present invention can determine target when it is assumed that the Value Types of object element are terminal symbol
Element is it is predicted that the Value Types gone out are ordinal number corresponding in the element of terminal symbol, thus with identified ordinal number, from original sentence
The source word that corresponding ordinal number is determined in son is target source word;
With example shown in Fig. 4, source sentence is " John has a dog. ", and what it is in current time progress is the 5th moment
Decoding (need to predict the element y at the 5th moment5, y5It is unknown) when, it is known that the element that 4 moment of front are predicted is y1=
(S, y2=(NP, y3=XX, y4=XX;
It then can be assumed that y5Value Types be XX (expression of terminal symbol), and determine y5Value Types be XX when, y5It is predicted that
Value Types be ordinal number corresponding in the element of XX;To which with the ordinal number, the source word of determining corresponding ordinal number is from source sentence
Target source word;
As seen from Figure 4, it is predicted that element y1To y4In, it is predicted that Value Types be XX element be y3And y4,
It therefore can be it is assumed that y5Value Types be XX when, determine y5It is predicted that Value Types be XX element in corresponding ordinal number be
3;To can determine that the 3rd word " a " is the object element y that need to currently predict in source sentence5The target source being aligned in source sentence
Word.
Similarly, y need to be predicted with current time4For, it is assumed that y4Value Types be XX when, it is predicted that Value Types be
Corresponding ordinal number is 2 in the element of XX, then y4The source word being aligned in source sentence is " has ";The member that other moment need to be predicted
Element, the processing of the source word being aligned in source sentence assumed, in the same way.
Step S210, when the Value Types for assuming the object element that current time need to be predicted are right parenthesis, from the source sentence
The starting word of middle corresponding phrase structure of determining current time, using the previous word of the target source word as the phrase structure
End word determines current time corresponding phrase structure according to the starting word of the phrase structure and end word.
After determining target source word, the embodiment of the present invention can carry out current time corresponding phrase structure and half phrase structure
Determination.
Due to phrase structure be it is deterministic, when determining phrase structure, as a kind of optional realization, the embodiment of the present invention
It can determine the starting word of phrase structure;Optionally, when the embodiment of the present invention can be assumed that the Value Types of object element are right parenthesis, from
It is predicted that element in the determining phrase element started with the nearest left bracket of object element, determine the phrase that the left bracket starts
The latter Value Types predicted of element are the element of terminal symbol, determine that the latter Value Types predicted are the member of terminal symbol
Element, it is predicted that the Value Types gone out are ordinal number corresponding in the element of terminal symbol, the determining ordinal number is corresponding from source sentence
Source word is the starting word of the phrase structure.
Referring to example shown in Fig. 4, what is carried out at current time is that the decoding at the 5th moment (need to predict the 5th moment
Element y5, y5It is unknown) when, it is known that the element that 4 moment of front are predicted is y1=(S, y2=(NP, y3=XX, y4=XX;
It is assumed that y5Value Types be ") " (right parenthesis) when, it is meant that its correspond to a phrase structure, can from it is predicted that member
Plain y1To y4In, determining and object element y5The phrase element that nearest left bracket starts;As seen from Figure 4, which starts
Phrase element be y2(" (NP "), to can determine y2The nearest Value Types predicted below are element (the referred to as y of XX2Afterwards
One Value Types predicted are the element of terminal symbol), as seen from Figure 4, which is y3;So that it is determined that y3It is predicted that go out
Value Types are that ordinal number corresponding in the element of XX is 1, correspondingly, the starting word of current time corresponding phrase structure is original sentence
The source word " John " that ordinal number is 1 in son.
Optionally, the element y at the 4th moment need to be predicted4When, the method for determination of the starting word of corresponding phrase structure is same
Reason.
It, can be by the target source word in source sentence after the starting word for determining current time corresponding phrase structure
Previous word, as the end word of the phrase structure, thus with the starting word and end word of the phrase structure in source sentence
The source word covered forms current time corresponding source sentence;
The example referring to shown in Fig. 4, need to predict y at current time5When, determine that target source word is " a ", current time is corresponding
The starting word of phrase structure be " John " after, then can be using the previous word " has " of target source word " a " as the end of phrase structure
Word forms the phrase structure of (John, has).
Step S220, using the target source word as the starting word of current time corresponding half phrase structure, it is arranged described half
The end word of phrase structure is any unknown source word after the target source word, forms half phrase structure.
After determining target source word, it may be assumed that the Value Types for the object element that current time need to be predicted are left bracket (" ("),
It means that will generate one and half phrase structures, can using determined target source word as the starting word of half phrase structure, and
The end word of half phrase structure is set for any unknown source word after target source word described in source sentence, it is short to form described half
Language structure;
The example referring to shown in Fig. 4, need to predict y at current time5When, determine that target source word is " a ", and half phrase knot is set
The end word of structure it is unknown (with "? " indicate), then formed (a,?) half phrase structure.
Step S230, according at least to the target source word, the phrase structure, half phrase structure and the source vector table
Show sequence, determines current time corresponding context.
Optionally, as a kind of optional realization, step S230 can refer to above-described respective formula and realize.
It, can be with Fig. 3 institute when carrying out the element prediction of syntactic analysis result at each moment by taking syntactic analysis scene as an example
Show that method carries out the context selection at each moment, auxiliary decoder device carries out the prediction of the element at each moment, obtains syntax point
Analyse result.
By taking syntactic analysis scene as an example, above-described context selection method can be by the attention layer of syntactic analysis model
It realizes, and the attention layer can be realized based on certainty attention mechanism;Specifically, syntactic analysis model is carrying out syntactic analysis
Process, context selection method provided in an embodiment of the present invention can be used, carry out each moment context selection.In this hair
In bright embodiment, syntactic analysis model can be based on neural fusion, and one kind of syntactic analysis model neural network based can
Select structure as shown in Figure 5, comprising: encoder and decoder;It is wherein provided in decoder based on certainty attention mechanism
Attention layer.
Optionally, during carrying out syntactic analysis, source sentence can input syntactic analysis module, generate source by encoder
The corresponding source vector of sentence indicates sequence;The source sentence may include at least one source word, and a source word can correspond to described
Source vector indicates an expression vector in sequence;
After obtaining the source vector and indicating sequence, attention layer can utilize selected works up and down provided in an embodiment of the present invention
Selection method selects the context at current time, so that decoder can predict current time according to the context at current time
Object element;
And then it is continuous in the above described manner at various moments, the selected works up and down that each moment is carried out with attention layer of circulation
It selects, and, with the element at decoder prediction each moment, so that the sequence for the element composition that each moment is predicted is as syntax tree
Sequence obtains syntactic analysis as a result, realizing the syntactic analysis for source sentence.
Optionally, multiple serializing neural fusions can be used in the frame of parser neural network based, such as
Multiple RNN (Recognition with Recurrent Neural Network) realization can be used;As an example, as shown in fig. 6, encoder can be by a serializing mind
It is realized through network (a such as RNN), as encoder can be realized based on two-way RNN;Decoder can serialize nerve by another
Network implementations can such as be realized based on RNN from left to right;Attention layer can realize by the network layer in serializing neural network,
For the output based on encoder, the selection of the context at each moment is carried out.
In conjunction with shown in Fig. 5 and Fig. 6, Fig. 7 shows the flow chart of syntactic analysis method provided in an embodiment of the present invention, the sentence
Method analysis method can be applied to electronic equipment, and server can be selected in electronic equipment, and terminal also can be selected and realize;It specifically can be by electronics
The syntactic analysis model realization syntactic analysis process being arranged in equipment;
Referring to Fig. 7, syntactic analysis method provided in an embodiment of the present invention may include:
Step S300, encoder reads in source sentence, and exporting corresponding source vector indicates sequence.
Optionally, each source word that source sentence includes may make up list entries, and after being input to encoder, encoder is available
Source word discrete in source sentence is converted into continuous space representation by the property of RNN compression expression, continuous by what is be converted to
Space representation be input in two-way RNN (Recurrent Neural Networks, Recognition with Recurrent Neural Network), obtain corresponding
Source vector indicates sequence.
Step S310, at current time, attention layer choosing selects the context at current time.
Optionally, the processing of step S310 can context selection method provided in an embodiment of the present invention based on the above described
It realizes;
Specifically, the object element that can need to be predicted according to current time, it is assumed that the object element is in the source sentence
The target source word of alignment;According to the target source word, current time corresponding phrase structure and half short is separated out from source sentence
Language structure, wherein the phrase structure is at least deterministic;To according at least to the target source word, the phrase structure,
Half phrase structure and the source vector indicate sequence, determine current time corresponding context.
Step S320, context of the decoder according to current time, the object element of output current time prediction.
Optionally, current time decoder states can be set as st, the object element that current time need to be predicted is yt, then working as
Preceding moment, the context c that decoder can be selected according to current timet, previous moment decoder states st-1, previous moment is pre-
The element y of surveyt-1, determine the decoder states s at current timet(the RNN operation that this process may be considered a standard);
In turn, decoder can be according to the decoding end state s at current timet, the context c at current timetAnd previous moment
It is predicted that element yt-1, determine the object element y of current time predictiont。
Constantly at various moments with this, the processing of the carry out attention layer and decoder of circulation (weighs at various moments
Step S310 and S320 are executed again), obtain element generated of each moment, the sequence being made of the element that each moment generates
Column form syntax tree sequence, obtain syntactic analysis result.
Optionally, syntactic analysis result can be syntax tree sequence, as shown in figure 8, being oneself of a syntax tree shown in Fig. 8
The serialization process of (top-down) under above, top half is syntax tree, and lower half portion is to serialize the void as a result, intermediate
Line indicates leaf node expressed by XX.
Deterministic attention mechanism based on the embodiment of the present invention, syntactic analysis model training process are related to upper
Hereafter selection course is suitable for adjusting;Optionally, Fig. 9 shows a kind of optional training method process of syntactic analysis model, should
Training method process can be applied to electronic equipment, and server can be selected in electronic equipment, and terminal also can be selected and realize;
Referring to Fig. 9, the training process of syntactic analysis model provided in an embodiment of the present invention may include:
Step S400, original sentence subsample is obtained.
Original sentence subsample may be considered sentence sample used in trained syntactic analysis model, and original sentence subsample can be by giving
Fixed standard stack room obtain;
In training syntactic analysis model, the embodiment of the present invention can be by the input syntactic analysis of each original sentence subsample one by one
In model, to maximize likelihood function score as target, the parameter of the update syntactic analysis model of iteration (is contained of the invention real
The parameter of the attention layer based on certainty attention mechanism of example offer is provided), to complete syntactic analysis mould after the completion of iteration
The training of type, concrete mode can be shown in following steps.
Step S410, the original sentence subsample is inputted into syntactic analysis model, the syntactic analysis model includes: encoder
And decoder;The decoder is provided with the attention layer based on certainty attention mechanism.
Step S420, determine that the corresponding source vector in the original sentence subsample indicates sequence by the encoder.
Step S430, in current time, the object element that need to be predicted by the attention layer according to current time, it is assumed that institute
State the target source word that object element is aligned in the source sentence;According to the target source word, it is separated out from source sentence current
Moment corresponding phrase structure and half phrase structure, wherein the phrase structure is at least deterministic;According at least to the mesh
Mark source word, the phrase structure, half phrase structure and the source vector indicate sequence, determine current time accordingly up and down
Text.
In the training process of syntactic analysis model, attention layer choosing selects the mode of context, can implement through the invention
The context selection method that example provides is realized;
The object element that current time need to be predicted can be set as xt, corresponding phrase structure is ρ (xb, xt-1), half phrase structure
For ρ (xt,?), ExIndicate that source vector indicates sequence;The then context c at current timetSelection can based on following formula realize:
ct=φ (ρ (xb, xt-1),ρ(xt,?), xt,Ex);
Further, φ may be defined asWherein, θcIndicate provided in an embodiment of the present invention based on certainty attention
The parameter of the attention layer of mechanism,Indicate that the vector of the target source word indicates;
To the context c at preceding momenttSelection can be based on formula
It realizes.
Step S440, decoder predicts current time corresponding object element according to current time corresponding context, with
The element that each moment is accordingly predicted constitutes the corresponding syntax tree sequence in original sentence subsample, obtains the original sentence subsample
Syntactic analysis result.
Optionally, the processing of step S440 can refer to above shown in step S320.
Step S450, according to the original sentence subsample, syntax tree sequence corresponding with the original sentence subsample is determined corresponding
Likelihood function score.
Step S460, at least to maximize the likelihood function score as training objective, iteration updates syntactic analysis model
Parameter complete the training of syntactic analysis model until reaching stopping criterion for iteration;Wherein, the parameter of syntactic analysis model is extremely
It less include: the parameter of the attention layer based on certainty attention mechanism.
Optionally, the training of syntactic analysis model can be objective function by maximizing following likelihood function score;
Wherein, xiFor i-th of source sentence (i.e. i-th of list entries), yiFor the corresponding syntax tree sequence of i-th of source sentence;
θ indicates the parameter of syntactic analysis model, and the update for needing to be iterated contains in θ described based on certainty attention mechanism
Attention layer parameter θc;
Optionally, if the original sentence subsample that input syntactic analysis model is trained is x, x=< x1,x2,...x|x|>,
Length is | x |, if the corresponding syntax tree sequence in original sentence subsample is y, y=< y1,y2,...y|y|>, the length is | y |, then P
(yx;It θ) can be by being defined as follows;
Wherein, x indicates original sentence subsample currently entered, and y indicates the corresponding syntax tree in original sentence subsample currently entered
Sequence, | y | indicate the length of the syntax tree sequence, ytIndicate the element for the syntax tree sequence that current time obtains;h′t=f '
(h′t-1, yt-1, ct) indicate decoder decoding process in hidden neuron, can be defined by a Recognition with Recurrent Neural Network.
It should be noted that objective function can be realized at least with likelihood function score, but in practical situations, objective function
Other numerical value can also be added, be not limited solely to likelihood function score, specifically can depending on the training requirement of syntactic analysis model,
But no matter how the training requirement of syntactic analysis model changes, and model training process and syntactic analysis process are carrying out selected works up and down
It, can context selection method realization based on the embodiment of the present invention when selecting.
Based on the syntactic analysis model that training obtains, the syntactic analysis process carried out can be as shown in fig. 7, this time no longer superfluous
It states;Optionally, the Sample Scenario for the syntactic analysis that the syntactic analysis model obtained based on training is carried out, can be as shown in Figure 10,
Specifically syntactic analysis model can be set in server, be requested by the syntactic analysis of server receiving terminal, Lai Jinhang syntactic analysis;
Optionally, as shown in Figure 10, the application scenarios process of syntactic analysis may include:
S1, user input the source sentence of pending syntactic analysis in terminal, and terminal to server is sent comprising source sentence
Syntactic analysis request.
After the syntactic analysis request that S2, server receiving terminal are sent, syntactic analysis model is called;The syntactic analysis mould
Type includes encoder and decoder, and the decoder includes the attention layer based on certainty attention mechanism.
The source sentence is inputted syntactic analysis model by S3, server, determines the source by the syntactic analysis model
The corresponding syntax tree sequence of sentence, obtains syntactic analysis result.
Wherein, syntactic analysis model, can be by being based on certainty attention during carrying out syntactic analysis to source sentence
The attention layer of mechanism, the context selection method provided according to an embodiment of the present invention carry out context selection;
It is specific: the object element that attention layer can need to be predicted according to current time, it is assumed that the object element is described
The target source word being aligned in source sentence;According to the target source word, current time corresponding phrase knot is separated out from source sentence
Structure and half phrase structure, wherein the phrase structure is at least deterministic;According at least to the target source word, the phrase
Structure, half phrase structure and the source vector indicate sequence, determine current time corresponding context.
S4, server export the corresponding syntax tree sequence of source sentence by syntactic analysis model, and feed back to terminal.
The essential core of context selection method provided in an embodiment of the present invention is in the definition mode of attention mechanism,
The embodiment of the present invention uses deterministic mode to select the contextual information in decoding, to improve the context of capture
It is comprehensive, improve context selection precision;
Optionally, context selection method provided in an embodiment of the present invention can be applied to syntactic analysis scene, syntactic analysis
Model can be realized based on the neural network model of serializing, in training syntactic analysis model, can be relied on parallel improve and be trained
Efficiency, such as using 1 GPU, it is only necessary to can complete for 1 day to train the training of syntactic analysis model;Meanwhile from
From the point of view of in the precision of syntactic analysis, the data set PTB (Penn Treebank) and CTB (Chinese Penn disclosed in two kinds
Treebank it on), using the syntactic analysis model of context selection method provided in an embodiment of the present invention, can be obviously improved
The accuracy of syntactic analysis result.
Context selection device provided in an embodiment of the present invention is introduced below, context selection dress described below
Setting may be considered, the electronic equipment context selection method that embodiment provides to realize the present invention, the program mould of required setting
Block.The content of context selection device described below can be corresponded to each other with the content of above-described context selection method
Reference.
Figure 11 is the structural block diagram of context selection device provided in an embodiment of the present invention, which can answer
For electronic equipment, server is can be selected in electronic equipment, and terminal also can be selected and realize;
Referring to Fig.1 1, context selection device provided in an embodiment of the present invention may include:
Source sequence vector obtains module 100, indicates sequence for obtaining the corresponding source vector of source sentence;
Target source word determining module 200, the object element for that need to be predicted according to current time, it is assumed that the object element
The target source word being aligned in source sentence;
Separating modules 300, for being separated out current time corresponding phrase knot from source sentence according to the target source word
Structure and half phrase structure;Wherein, the phrase structure is at least deterministic;
Context output module 400, for according at least to the target source word, the phrase structure, half phrase structure and
The source vector indicates sequence, determines current time corresponding context.
Optionally, target source word determining module 200, the object element for that need to be predicted according to current time, it is assumed that described
The target source word that object element is aligned in source sentence, specifically includes:
It is assumed that the Value Types of the object element are terminal symbol, determine what the object element was aligned in the source sentence
Target source word;Wherein, the object element possible values type includes: terminal symbol, left bracket and right parenthesis.
Optionally, target source word determining module 200 is determined for assuming that the Value Types of the object element are terminal symbol
The target source word that the object element is aligned in the source sentence, specifically includes:
When it is assumed that the Value Types of the object element are terminal symbol, determine the object element it is predicted that the value class gone out
Type is ordinal number corresponding in the element of terminal symbol;
With identified ordinal number, determine that the source word of corresponding ordinal number is the target source word from source sentence.
Optionally, separating modules 300, for it is corresponding to be separated out current time from source sentence according to the target source word
Phrase structure, specifically include:
It is assumed that the Value Types of the object element are right parenthesis, current time corresponding phrase is determined from the source sentence
The starting word of structure, using the previous word of the target source word as the end word of the phrase structure, according to the phrase structure
Starting word and end word determine current time corresponding phrase structure.
Optionally, separating modules 300, for assuming that the Value Types of the object element are right parenthesis, from the source sentence
The starting word of middle corresponding phrase structure of determining current time, specifically includes:
When it is assumed that the Value Types of the object element are right parenthesis, from it is predicted that element in it is determining with the target element
The phrase element that the nearest left bracket of element starts;
The latter Value Types predicted for determining the phrase element that the left bracket starts are the element of terminal symbol, and determine institute
State the element that the latter Value Types predicted are terminal symbol, it is predicted that in the element that the Value Types gone out are terminal symbol it is corresponding
Ordinal number determines that the corresponding source word of the ordinal number is the starting word of the phrase structure from source sentence.
Optionally, separating modules 300, for it is corresponding to be separated out current time from source sentence according to the target source word
Half phrase structure, specifically include:
It is assumed that the Value Types of the object element are left bracket, it take the target source word as the starting of half phrase structure
Word, the end word that half phrase structure is arranged is any unknown source word after the target source word, forms the half phrase knot
Structure.
Optionally, context output module 400, for according at least to the target source word, the phrase structure, half phrase
Structure and the source vector indicate sequence, determine current time corresponding context, specifically include:
According to formula ct=φ (ρ (xb, xt-1),ρ(xt,?), xt,Ex) determine current time corresponding context;
Wherein, ctIndicate current time corresponding context, xtFor the target source word, xbFor rising for the phrase structure
Beginning word, ExSequence, ρ (x are indicated for the corresponding source vector of the source sentenceb, xt-1) it is current time corresponding phrase structure, ρ
(xt,?) it is current time corresponding half phrase structure.
Optionally, the definition of φ includes:
Wherein, θcIndicate the attention layer based on certainty attention mechanism
Parameter,Indicate the starting word x of current time corresponding phrase structurebVector indicate,Indicate that current time is corresponding
The vector expression of the end word of phrase structure,Indicate that the vector of the target source word indicates
Or,
Or,
It optionally, can be by the note based on certainty attention mechanism in syntactic analysis model under syntactic analysis scene
Meaning power layer, executes context selection method provided in an embodiment of the present invention;Wherein, the syntactic analysis model includes: encoder
And decoder, the decoder are provided with the attention layer;
Optionally, Figure 12 shows another structural block diagram of context selection device provided in an embodiment of the present invention, in conjunction with
Shown in Figure 11 and Figure 12, further includes:
Coding module 500 exports the corresponding source of the source sentence for source sentence to be inputted the syntactic analysis model
Vector indicates sequence;
Decoder module 600, for after determining current time corresponding context, accordingly up and down according to current time
Text, the object element of output current time prediction, forms the corresponding sequence of syntax tree with the element predicted by each moment,
Obtain syntactic analysis result.
Optionally, decoder module 600, for exporting the mesh of current time prediction according to current time corresponding context
Element is marked, is specifically included:
According to current time corresponding context, previous moment decoder states, previous moment it is predicted that element, determine
The decoder states at current time;
According to the decoding end state at current time, current time corresponding context and previous moment it is predicted that element,
Determine the object element of current time prediction.
Optionally, Figure 13 shows another structural block diagram of context selection device provided in an embodiment of the present invention, in conjunction with
Shown in Figure 12 and Figure 13, further includes:
Training module 700, for obtaining original sentence subsample;The original sentence subsample is inputted into syntactic analysis model;By institute
It states encoder and determines that the corresponding source vector in the original sentence subsample indicates sequence;Determining current time corresponding context
Afterwards, by the decoder according to current time corresponding context, current time corresponding object element is predicted, when will be each
It carves the element accordingly predicted and constitutes the corresponding syntax tree sequence in original sentence subsample;It is and described according to the original sentence subsample
The corresponding syntax tree sequence in original sentence subsample, determines corresponding likelihood function score;At least to maximize the likelihood function point
Number is training objective, and iteration updates the parameter of syntactic analysis model, until reaching stopping criterion for iteration, to train syntactic analysis mould
Type;Wherein, the parameter of syntactic analysis model includes at least: the parameter of the attention layer.
Context selection device provided in an embodiment of the present invention can be applied to electronic equipment, such as can be applied to server;
Optionally, the hardware block diagram of electronic equipment can be as shown in figure 14, comprising: at least one processor 1, at least one communication connect
Mouth 2, at least one processor 3 and at least one communication bus 4;
In embodiments of the present invention, processor 1, communication interface 2, memory 3, communication bus 4 quantity be at least one,
And processor 1, communication interface 2, memory 3 complete mutual communication by communication bus 4;
Processor 1 may be a central processor CPU or specific integrated circuit ASIC (Application
Specific Integrated Circuit), or be arranged to implement the integrated electricity of one or more of the embodiment of the present invention
Road;
Memory 3 may include high speed RAM memory, it is also possible to further include nonvolatile memory (non-volatile
Memory), a for example, at least magnetic disk storage;
Wherein, memory is stored with program, and processor calls described program, to realize above and below provided in an embodiment of the present invention
The step of selected works selection method.
Optionally, the function of described program can refer to corresponding portion description above.
The embodiment of the present invention also provides a kind of storage medium, which is stored with the program executed suitable for processor,
With the step of realizing context selection method provided in an embodiment of the present invention.
Each embodiment in this specification is described in a progressive manner, the highlights of each of the examples are with other
The difference of embodiment, the same or similar parts in each embodiment may refer to each other.For device disclosed in embodiment
For, since it is corresponded to the methods disclosed in the examples, so being described relatively simple, related place is said referring to method part
It is bright.
Professional further appreciates that, unit described in conjunction with the examples disclosed in the embodiments of the present disclosure
And algorithm steps, can be realized with electronic hardware, computer software, or a combination of the two, in order to clearly demonstrate hardware and
The interchangeability of software generally describes each exemplary composition and step according to function in the above description.These
Function is implemented in hardware or software actually, the specific application and design constraint depending on technical solution.Profession
Technical staff can use different methods to achieve the described function each specific application, but this realization is not answered
Think beyond the scope of this invention.
The step of method described in conjunction with the examples disclosed in this document or algorithm, can directly be held with hardware, processor
The combination of capable software module or the two is implemented.Software module can be placed in random access memory (RAM), memory, read-only deposit
Reservoir (ROM), electrically programmable ROM, electrically erasable ROM, register, hard disk, moveable magnetic disc, CD-ROM or technology
In any other form of storage medium well known in field.
The foregoing description of the disclosed embodiments enables those skilled in the art to implement or use the present invention.
Various modifications to these embodiments will be readily apparent to those skilled in the art, as defined herein
General Principle can be realized in other embodiments in the case where not departing from core of the invention thought or scope.Therefore, originally
Invention is not intended to be limited to the embodiments shown herein, and is to fit to and the principles and novel features disclosed herein
Consistent widest scope.
Claims (15)
1. a kind of context selection method characterized by comprising
Obtaining the corresponding source vector of source sentence indicates sequence;
The object element that need to be predicted according to current time, it is assumed that the target source word that the object element is aligned in source sentence;
According to the target source word, current time corresponding phrase structure and half phrase structure are separated out from source sentence;Wherein,
The phrase structure is at least deterministic;
Sequence is indicated according at least to the target source word, the phrase structure, half phrase structure and the source vector, and determination is worked as
Preceding moment corresponding context.
2. context selection method according to claim 1, which is characterized in that the mesh that need to be predicted according to current time
Mark element, it is assumed that the target source word that the object element is aligned in source sentence includes:
It is assumed that the Value Types of the object element are terminal symbol, the target that the object element is aligned in the source sentence is determined
Source word;Wherein, the object element possible values type includes: terminal symbol, left bracket and right parenthesis.
3. context selection method according to claim 2, which is characterized in that the value class for assuming the object element
Type is terminal symbol, and the target source word for determining that the object element is aligned in the source sentence includes:
When it is assumed that the Value Types of the object element are terminal symbol, determine the object element it is predicted that the Value Types gone out are
Corresponding ordinal number in the element of terminal symbol;
With identified ordinal number, determine that the source word of corresponding ordinal number is the target source word from source sentence.
4. according to the described in any item context selection methods of claim 2-3, which is characterized in that described according to the target source
Word, current time corresponding phrase structure is separated out from source sentence includes:
It is assumed that the Value Types of the object element are right parenthesis, current time corresponding phrase structure is determined from the source sentence
Starting word, using the previous word of the target source word as the end word of the phrase structure, according to rising for the phrase structure
Beginning word and end word determine current time corresponding phrase structure.
5. context selection method according to claim 4, which is characterized in that the value class for assuming the object element
Type is right parenthesis, determines that the starting word of current time corresponding phrase structure includes: from the source sentence
When it is assumed that the Value Types of the object element are right parenthesis, from it is predicted that element in it is determining with the object element most
The phrase element that close left bracket starts;
After the latter Value Types predicted for determining the phrase element that the left bracket starts are the element of terminal symbol, and determination is described
One Value Types predicted are the element of terminal symbol, it is predicted that the Value Types gone out are sequence corresponding in the element of terminal symbol
Number determines that the corresponding source word of the ordinal number is the starting word of the phrase structure from source sentence.
6. according to the described in any item context selection methods of claim 2-3, which is characterized in that described according to the target source
Word, current time corresponding half phrase structure is separated out from source sentence includes:
It is assumed that the Value Types of the object element are left bracket, it take the target source word as the starting word of half phrase structure,
The end word that half phrase structure is arranged is any unknown source word after the target source word, forms half phrase structure.
7. context selection method according to claim 1, which is characterized in that it is described according at least to the target source word,
The phrase structure, half phrase structure and the source vector indicate sequence, determine that current time corresponding context includes:
According to formula ct=φ (ρ (xb, xt-1),ρ(xt,?), xt,Ex) determine current time corresponding context;
Wherein, ctIndicate current time corresponding context, xtFor the target source word, xbFor the starting word of the phrase structure,
ExSequence, ρ (x are indicated for the corresponding source vector of the source sentenceb, xt-1) it is current time corresponding phrase structure, ρ (xt,?)
For current time corresponding half phrase structure.
8. context selection method according to claim 7, which is characterized in that the definition of the φ includes:
Wherein, θcIndicate the parameter of the attention layer based on certainty attention mechanism,Indicate the starting word x of current time corresponding phrase structurebVector indicate,Indicate current time corresponding phrase knot
The vector expression of the end word of structure,Indicate that the vector of the target source word indicates
Or,
Or,
9. context selection method according to claim 1, which is characterized in that the context selection method is by syntax point
The attention layer based on certainty attention mechanism analysed in model executes, and the syntactic analysis model includes: encoder reconciliation
Code device, the decoder are provided with the attention layer;
The method also includes:
Source sentence is inputted into the syntactic analysis model, the corresponding source vector of the source sentence as described in the encoder output indicates
Sequence;
After determining current time corresponding context, by the decoder according to current time corresponding context, output is worked as
The object element of preceding moment prediction, forms the corresponding sequence of syntax tree with the element predicted by each moment, obtains syntax
Analyze result.
10. context selection method according to claim 9, which is characterized in that it is described by the decoder according to current
Moment corresponding context, the object element that output current time is predicted include:
Decoder is according to current time corresponding context, previous moment decoder states, previous moment it is predicted that element, really
Determine the decoder states at current time;
Decoder according to the decoding end state at current time, current time corresponding context and previous moment it is predicted that member
Element determines the object element of current time prediction.
11. context selection method according to claim 9 or 10, which is characterized in that the method also includes:
Obtain original sentence subsample;
The original sentence subsample is inputted into syntactic analysis model;
Determine that the corresponding source vector in the original sentence subsample indicates sequence by the encoder;
After determining current time corresponding context, by the decoder according to current time corresponding context, prediction is worked as
Preceding moment corresponding object element, the element that each moment is accordingly predicted constitute the corresponding syntax tree in original sentence subsample
Sequence;
According to the original sentence subsample, syntax tree sequence corresponding with the original sentence subsample determines corresponding likelihood function point
Number;
At least to maximize the likelihood function score as training objective, iteration updates the parameter of syntactic analysis model, until reaching
To stopping criterion for iteration, to train syntactic analysis model;Wherein, the parameter of syntactic analysis model includes at least: the attention
The parameter of layer.
12. a kind of context selection device characterized by comprising
Source sequence vector obtains module, indicates sequence for obtaining the corresponding source vector of source sentence;
Target source word determining module, the object element for that need to be predicted according to current time, it is assumed that the object element is in original sentence
The target source word being aligned in son;
Separating modules, for being separated out current time corresponding phrase structure and half from source sentence according to the target source word
Phrase structure;Wherein, the phrase structure is at least deterministic;
Context output module, for according at least to the target source word, the phrase structure, half phrase structure and the source
Vector indicates sequence, determines current time corresponding context.
13. context selection device according to claim 12, which is characterized in that the target source word determining module is used
In the object element that need to be predicted according to current time, it is assumed that the target source word that the object element is aligned in source sentence, specifically
Include:
It is assumed that the Value Types of the object element are terminal symbol, the target that the object element is aligned in the source sentence is determined
Source word;Wherein, the object element possible values type includes: terminal symbol, left bracket and right parenthesis;
The separating modules, for being separated out current time corresponding phrase structure from source sentence according to the target source word,
It specifically includes:
It is assumed that the Value Types of the object element are right parenthesis, current time corresponding phrase structure is determined from the source sentence
Starting word, using the previous word of the target source word as the end word of the phrase structure, according to rising for the phrase structure
Beginning word and end word determine current time corresponding phrase structure;
The separating modules, for being separated out current time corresponding half phrase knot from source sentence according to the target source word
Structure specifically includes:
It is assumed that the Value Types of the object element are left bracket, it take the target source word as the starting word of half phrase structure,
The end word that half phrase structure is arranged is any unknown source word after the target source word, forms half phrase structure.
14. a kind of electronic equipment characterized by comprising at least one processor and at least one processor;The memory
It is stored with program, the processor calls described program, to realize the described in any item context selecting partys of claim 1-11
The step of method.
15. a kind of storage medium, which is characterized in that the storage medium is stored with the program executed suitable for processor, to realize
The step of claim 1-11 described in any item context selection methods.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810035965.2A CN110046338B (en) | 2018-01-15 | 2018-01-15 | Context selection method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810035965.2A CN110046338B (en) | 2018-01-15 | 2018-01-15 | Context selection method and device, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110046338A true CN110046338A (en) | 2019-07-23 |
CN110046338B CN110046338B (en) | 2022-11-11 |
Family
ID=67273373
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810035965.2A Active CN110046338B (en) | 2018-01-15 | 2018-01-15 | Context selection method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110046338B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111859954A (en) * | 2020-07-01 | 2020-10-30 | 腾讯科技(深圳)有限公司 | Target object identification method, device, equipment and computer readable storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101446941A (en) * | 2008-12-10 | 2009-06-03 | 苏州大学 | Natural language level and syntax analytic method based on historical information |
CN105868181A (en) * | 2016-04-21 | 2016-08-17 | 南京大学 | Novel neural network based automatic natural language parallel structure recognition method |
CN107357789A (en) * | 2017-07-14 | 2017-11-17 | 哈尔滨工业大学 | Merge the neural machine translation method of multi-lingual coding information |
CN107423290A (en) * | 2017-04-19 | 2017-12-01 | 厦门大学 | A kind of neural network machine translation model based on hierarchical structure |
-
2018
- 2018-01-15 CN CN201810035965.2A patent/CN110046338B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101446941A (en) * | 2008-12-10 | 2009-06-03 | 苏州大学 | Natural language level and syntax analytic method based on historical information |
CN105868181A (en) * | 2016-04-21 | 2016-08-17 | 南京大学 | Novel neural network based automatic natural language parallel structure recognition method |
CN107423290A (en) * | 2017-04-19 | 2017-12-01 | 厦门大学 | A kind of neural network machine translation model based on hierarchical structure |
CN107357789A (en) * | 2017-07-14 | 2017-11-17 | 哈尔滨工业大学 | Merge the neural machine translation method of multi-lingual coding information |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111859954A (en) * | 2020-07-01 | 2020-10-30 | 腾讯科技(深圳)有限公司 | Target object identification method, device, equipment and computer readable storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN110046338B (en) | 2022-11-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10503834B2 (en) | Template generation for a conversational agent | |
CN111190600B (en) | Method and system for automatically generating front-end codes based on GRU attention model | |
CN110781668B (en) | Text information type identification method and device | |
CN112860862B (en) | Method and device for generating intelligent agent dialogue sentences in man-machine dialogue | |
CN111914076B (en) | User image construction method, system, terminal and storage medium based on man-machine conversation | |
CN106445147A (en) | Behavior management method and device of conversational system based on artificial intelligence | |
CN108959388B (en) | Information generation method and device | |
CN110600004A (en) | Voice synthesis playing method and device and storage medium | |
CN111143617A (en) | Automatic generation method and system for picture or video text description | |
CN108304376B (en) | Text vector determination method and device, storage medium and electronic device | |
CN111626049A (en) | Title correction method and device for multimedia information, electronic equipment and storage medium | |
CN111105016A (en) | Data processing method and device, electronic equipment and readable storage medium | |
CN112149642A (en) | Text image recognition method and device | |
CN115438197B (en) | Method and system for complementing relationship of affair knowledge graph based on double-layer heterogeneous graph | |
CN112163560A (en) | Video information processing method and device, electronic equipment and storage medium | |
CN114860869A (en) | Controllable universal dialogue model with generalized intentions | |
CN113157941B (en) | Service characteristic data processing method, service characteristic data processing device, text generating method, text generating device and electronic equipment | |
CN110046338A (en) | A kind of context selection method, device, electronic equipment and storage medium | |
CN113139751A (en) | Method for determining micro-service user service type based on big data | |
CN115617975B (en) | Intention recognition method and device for few-sample multi-turn conversation | |
EP4322066A1 (en) | Method and apparatus for generating training data | |
CN111695670A (en) | Neural network model training method and device | |
CN114970855A (en) | Method, device, equipment, medium and prediction method for constructing wind field prediction model | |
CN111460169B (en) | Semantic expression generation method, device and equipment | |
CN111797636B (en) | Offline semantic analysis method and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TG01 | Patent term adjustment |