CN109740158B - Text semantic parsing method and device - Google Patents

Text semantic parsing method and device Download PDF

Info

Publication number
CN109740158B
CN109740158B CN201811644576.6A CN201811644576A CN109740158B CN 109740158 B CN109740158 B CN 109740158B CN 201811644576 A CN201811644576 A CN 201811644576A CN 109740158 B CN109740158 B CN 109740158B
Authority
CN
China
Prior art keywords
vector
text
attention
representation
semantic
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.)
Active
Application number
CN201811644576.6A
Other languages
Chinese (zh)
Other versions
CN109740158A (en
Inventor
李健铨
刘小康
晋耀红
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Anhui Taiyue Xiangsheng Software Co ltd
Original Assignee
Anhui Taiyue Xiangsheng Software Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Anhui Taiyue Xiangsheng Software Co ltd filed Critical Anhui Taiyue Xiangsheng Software Co ltd
Priority to CN201811644576.6A priority Critical patent/CN109740158B/en
Publication of CN109740158A publication Critical patent/CN109740158A/en
Application granted granted Critical
Publication of CN109740158B publication Critical patent/CN109740158B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Machine Translation (AREA)

Abstract

The application discloses a text semantic parsing method and a text semantic parsing device, wherein the method comprises the following steps: acquiring vector representation of a given text, and generating a coding vector of the given text according to the vector representation; the given text comprises a first text and a second text; the encoded vectors include a first encoded vector and a second encoded vector; generating a first attention and a second attention according to the first coded vector and the second coded vector, and generating a global information vector according to the first attention and the second attention; obtaining a semantic enhancement vector from the global information vector; and analyzing a target text corresponding to the second text in the first text according to the semantic enhancement vector. Compared with the prior art, the technical scheme of the application enriches the semantic representation of the vector to the text, accelerates the calculation convergence speed, and improves the accuracy and the efficiency by acquiring the semantic enhancement vector from the global information vector and resolving the target text corresponding to the second text in the first text according to the semantic enhancement vector.

Description

Text semantic parsing method and device
Technical Field
The application relates to the technical field of natural language processing, in particular to a text semantic parsing method and device.
Background
Machine reading understanding is the research direction of the current artificial intelligence hotspot, and a machine reading understanding task refers to that a given section of discourse sentence (context) and a corresponding query sentence (query) are read by a machine, and then the machine analyzes a corresponding answer by reading the discourse sentence and the query sentence.
In the prior art, answers corresponding to query sentences are determined by analyzing semantics of discourse sentences and query sentences. Wherein the answer is required to be a section of speech (which can also be understood as several words in series) that can be found in the discourse sentence, and the final goal of reading understanding is to determine two subscripts corresponding to the beginning position and the ending position of the answer in the discourse sentence. The reading understanding task of parsing the semantics to determine the corresponding answer is typically implemented by a deep learning based machine reading understanding model. The framework of the model is basically the same, and mainly comprises the following components: the device comprises an embedded coding module, a context-query interaction module and an output prediction module. The embedded coding module is used for representing the given text as a word vector acceptable by the model, the context-query interaction module is used for giving semantic features of the given text, and the output prediction module is used for outputting the position of an answer in the text.
However, the existing semantic parsing method has low accuracy and low convergence speed of the calculation process, which also causes the performance of the reading understanding model based on the above framework to be still further optimized and improved.
Disclosure of Invention
The application provides a text semantic parsing method and a text semantic parsing device, and aims to solve the problem that a semantic parsing method in the prior art is low in accuracy.
In a first aspect, the present application provides a text semantic parsing method, including:
acquiring vector representation of a given text, and generating a coding vector of the given text according to the vector representation; the given text comprises a first text and a second text; the encoding vectors comprise a first encoding vector corresponding to the first text and a second encoding vector corresponding to the second text;
generating a first attention and a second attention according to the first coded vector and the second coded vector, and generating a global information vector according to the first attention and the second attention;
obtaining a semantic enhancement vector from the global information vector;
and analyzing a target text corresponding to the second text in the first text according to the semantic enhancement vector.
In a second aspect, the present application further provides a text semantic parsing method, where the method includes:
obtaining a vector representation of the given text; the given text comprises a first text and a second text; the vector representation comprises a first vector representation corresponding to the first text and a second vector representation corresponding to the second text;
respectively acquiring a first semantic enhancement vector and a second semantic enhancement vector from the first vector representation and the second vector representation;
generating a first attention and a second attention according to the first semantic enhancement vector and the second semantic enhancement vector, and generating a global information vector according to the first attention and the second attention;
and analyzing a target text corresponding to the second text in the first text according to the global information vector.
In a third aspect, the present application provides a text semantic parsing apparatus, including:
the embedding and encoding module is used for acquiring vector representation of a given text and generating an encoding vector of the given text according to the vector representation; the given text comprises a first text and a second text; the encoding vectors comprise a first encoding vector corresponding to the first text and a second encoding vector corresponding to the second text;
the interaction module is used for generating a first attention and a second attention according to the first coding vector and the second coding vector and generating a global information vector according to the first attention and the second attention;
the semantic enhancement module is used for acquiring a semantic enhancement vector from the global information vector;
and the analysis module is used for analyzing a target text corresponding to the second text in the first text according to the semantic enhancement vector.
In a fourth aspect, the present application further provides a text semantic parsing apparatus, where the apparatus includes:
an embedding module for obtaining a vector representation of the given text; the given text comprises a first text and a second text; the vector representation comprises a first vector representation corresponding to the first text and a second vector representation corresponding to the second text;
the semantic enhancement module is used for acquiring a first semantic enhancement vector and a second semantic enhancement vector from the first vector representation and the second vector representation respectively;
the coding and interaction module is used for generating a first attention and a second attention according to the first semantic enhancement vector and the second semantic enhancement vector and generating a global information vector according to the first attention and the second attention;
and the analysis module is used for analyzing a target text corresponding to the second text in the first text according to the global information vector.
According to the technical scheme, the embodiment of the application provides a text semantic parsing method and a text semantic parsing device, wherein the method comprises the following steps: acquiring vector representation of a given text, and generating a coding vector of the given text according to the vector representation; the given text comprises a first text and a second text; the coding vector comprises a first coding vector corresponding to the first text and a second coding vector corresponding to the second text; generating a first attention and a second attention according to the first coded vector and the second coded vector, and generating a global information vector according to the first attention and the second attention; obtaining a semantic enhancement vector from the global information vector; and analyzing a target text corresponding to the second text in the first text according to the semantic enhancement vector. Compared with the prior art, the technical scheme of the application enriches the semantic representation of the vector to the text, accelerates the calculation convergence speed, and improves the accuracy and the efficiency by acquiring the semantic enhancement vector from the global information vector and resolving the target text corresponding to the second text in the first text according to the semantic enhancement vector.
Drawings
In order to more clearly describe the technical solution of the present application, the drawings required to be used in the embodiments will be briefly described below, and it is obvious for those skilled in the art to obtain other drawings without inventive labor.
FIG. 1 is a flowchart of a text semantic parsing method according to an embodiment of the present application;
FIG. 2 is a flowchart of one implementation of step 110 of the embodiment shown in FIG. 1;
FIG. 3 is a flowchart of another implementation of step 110 of the embodiment shown in FIG. 1;
FIG. 4 (a) is a schematic diagram of a convolution calculation process according to an embodiment of the present application;
FIG. 4 (b) is a schematic diagram of a convolution calculation process according to an embodiment of the present application;
FIG. 5 is a diagram illustrating a process of transpose convolution calculation according to an embodiment of the present application;
FIG. 6 is a flowchart of a text semantic parsing method according to another embodiment of the present application;
FIG. 7 is a schematic diagram of an embodiment of a text semantic parsing apparatus according to the present application;
fig. 8 is a detailed block diagram of a text semantic parsing apparatus according to an embodiment of the present application;
fig. 9 is a detailed block diagram of a text semantic parsing apparatus according to an embodiment of the present application;
fig. 10 is a schematic diagram of another embodiment of the text semantic parsing apparatus according to the present application.
Detailed Description
In order to make those skilled in the art better understand the technical solution of the present invention, the technical solution in the embodiment of the present invention will be clearly and completely described below with reference to the drawings in the embodiment of the present invention, and it is obvious that the described embodiment is only a part of the embodiment of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to facilitate understanding of the scheme of the present application, a brief introduction will be made below on several related concepts such as convolution, transposed convolution, attention mechanism, etc. in a neural network.
The input to the natural language processing task is a piece of text. The text is represented to generate a matrix, each column of which corresponds to an element, typically a word, representing a vector of words. The number of columns of the weight matrix is usually the same as the length of the word vector, ensuring that the word vector participating in the convolution operation is a complete representation.
Convolutional Neural Networks (CNN) have a strong ability to extract local features. Convolution (Convolution) calculation process referring to fig. 4 (a), assuming that a Convolution kernel (weight matrix) with a size of 3 × 3 is used to perform Convolution calculation on a matrix with a size of 4 × 4, and the step size is 1, the Convolution calculation result is a 2 × 2 matrix. The convolution operation can also be expressed by means of matrix multiplication, and referring to fig. 4 (b), it is first necessary to rearrange the aforementioned 3 × 3 convolution kernels into a 4 × 16 convolution matrix, where each row represents a convolution kernel; rearranging the 4 x 4 matrix into a 1-dimensional column; the 4 x 16 convolution matrix is then multiplied by the 1-dimensional columns to output a 2 x 2 matrix. Where the stride represents the distance that the convolution kernel has translated once in the sliding window. In addition, multiple convolution kernels may be used to extract different information.
Transposed Convolution (Transposed Convolution), also known as Deconvolution (deconstruction) and partial-spanned Convolution (fractional-spanned Convolution), will be referred to hereinafter as Transposed Convolution in order to avoid causing unnecessary misinterpretations. Transposed convolution can be considered as a method for obtaining upsampling, and more ideal upsampling can be obtained by training transposed convolution as compared with conventional methods such as Nearest neighbor interpolation (Nearest neighbor interpolation), bilinear interpolation (Bi-Linear interpolation), bi-Cubic interpolation (Bi-Cubic interpolation), etc. This method does not use a predefined interpolation method, which has parameters that can be learned.
The transposed convolution is a convolution, and the computation mode is basically the same as the back propagation process of the convolution. Referring to fig. 5, if the 2 × 2 matrix is converted into a 4 × 4 matrix, a 16 × 4 matrix is used. In this case, the result of convolution calculation can be restored to the same configuration as the input matrix of convolution calculation by multiplying the transpose (16 × 4) of the convolution matrix by the column vector format (4 × 1) of the result of convolution, outputting a 16 × 1 matrix, and further arranging the matrix in a 4 × 4 format. In natural language processing, the transposed convolution operation is substantially similar to the convolution operation, with the number of weight matrix rows typically being the same as the word vector length.
Attention (Attention) mechanism: the attention mechanism obtains inspiration from the human visual attention mechanism. Human vision tends to observe a particular part of attention as needed while perceiving things. The machine learning method learns a key part in the input content by using the idea, and pays attention to the part when a similar scene reappears in the future. Attention was first applied to the image domain. With the development of deep learning, the attention mechanism is more and more emphasized in natural language processing, and a great number of latest deep learning frameworks introduce the attention mechanism and obtain good performance indexes. The attention mechanism is widely applied to models of text classification, machine translation, reading understanding and the like at present.
Fig. 1 is a diagram illustrating an embodiment of a text semantic parsing method according to the present application. As shown in fig. 1, the method may include the steps of:
step 110, obtaining a vector representation of a given text, and generating a coding vector of the given text according to the vector representation; the given text comprises a first text and a second text; the encoding vectors comprise a first encoding vector corresponding to the first text and a second encoding vector corresponding to the second text;
the first text may be a discourse sentence (context), and the first text includes a number of words and symbols. The second text may be a query sentence (query), the second text comprising a number of words and symbols.
Fig. 2 is an implementation of step 110. As shown in fig. 2, step 110 may include:
and step 111, processing the given text to obtain the vector representation of the given text.
The vector representation of the given text may use words, word correspondence vectors and other semantic information such as syntax, part of speech, etc., and in an alternative embodiment, the vector representation of the given text may be obtained using word vectors, etc.:
the first text and the second text are participled to obtain a vocabulary set, for example, the first text or the second text is a sentence containing n vocabularies, and the participled words obtain an n-dimensional vocabulary set { w 1 ,w 2 ,…,w n In which w i Represents a word. Then, on one hand, an index corresponding to each vocabulary in the vocabulary set is searched in a preset vocabulary table, and the vocabulary set is converted into an n-dimensional vector { id } according to the index w1 ,id w2 ,…,id wn In which id wi Representative word w i Corresponding index, and searching corresponding word vector according to index in n-dimensional vector to obtain an n × d vector 1 A word vector matrix of size where d 1 Representing the word vector dimension. On the other hand, each word in the word set is divided into words, and a word set with the elements at each position as words is obtained:
Figure BDA0001931799930000041
wherein c is i-j The expression vocabulary w i M is the maximum number of words contained in a word; then searching the index corresponding to each word in the word set in the preset word table, and converting the word set into n × m × d 2 A matrix of sizes; performing convolution calculation on the matrix to output an n × d matrix 2 A matrix of word vectors of size. Wherein, d 2 Representing the dimensions of the word vector.
And splicing the word vector matrix and the word vector matrix to obtain the vector representation of the given text, wherein the vector representation comprises the vector representation corresponding to the first text and the vector representation corresponding to the second text.
And step 112, adding position coding information to the vector representation to obtain an input matrix of the convolutional neural network, so as to extract local information vectors from the input matrix by using the convolutional neural network.
And carrying out position coding on the vocabulary of the given text to obtain a position coding matrix. The purpose of position coding a given text is to enable a neural network to obtain relative or absolute position information between different participles of the given text. The dimensions of the position-coding vector are equal to those of the above-mentioned spliced matrix, so that the position-coding vector can be added thereto. The position-coding vector may be randomly initialized and trained in the model, or generated by a sine function or a cosine function.
In an alternative embodiment, the given text may be position coded using the following formula:
Figure BDA0001931799930000051
Figure BDA0001931799930000052
where pos denotes the position of the participle in the given text, d 1 Representing the dimension of the word vector, C being the period coefficient, PE (pos,2i) Position coding, PE, of 2 i-dimension of a participle representing a pos-th position (pos,2i+1) Position code of 2i +1 dimension of the participle representing position pos.
The input matrix comprises word vector components, word vector components and position coding components of words in corresponding texts of given texts, so that different local information vectors can be extracted due to different positions of the words in the texts even aiming at the same words, loss of word sequence information in the texts is avoided, and information extracted by a convolution kernel is more accurate.
Step 113, obtaining attention information of the given text according to the local information vector.
In the present application, attention information for a given text is calculated using an Attention function based on an Attention mechanism.
And step 114, weighting the local information vector according to the attention information to generate a coding vector of the given text.
Fig. 3 shows another implementation of step 110. Unlike the implementation shown in fig. 2, in this implementation, the word vector matrix and the word vector matrix of a given text are semantically enhanced. As shown in fig. 3, step 110 may include:
step 115, processing the given text to obtain a vector representation of the given text.
A preliminary enhancement matrix is obtained from the vector representation of the given text, step 116.
The manner of obtaining the preliminary enhancement matrix may be: firstly, convolution calculation is carried out on vector representation of a given text, then transposition convolution calculation is carried out on a convolution calculation result, and a preliminary enhancement matrix is obtained, so that the preliminary enhancement matrix and the vector representation structure of the given text are the same. Or, the convolution calculation result and the transposition convolution calculation result are spliced to form a primary enhancement matrix.
In step 117, similar to step 112, the position coding information is added to the preliminary enhancement matrix by matrix addition to obtain an input matrix of the convolutional neural network, and then the convolutional neural network is used to extract local information vectors from the input matrix.
In step 118, obtaining attention information of the given text according to the local information vector; and step 119, generating an encoding vector of the given text according to the attention information.
The difference between the two implementation manners of step 110 is that in the second implementation manner, the vector representation of the given text is subjected to semantic enhancement processing, so that the semantic representation of the vector is enriched, and the accuracy of semantic analysis is improved.
And step 120, generating a first attention and a second attention according to the first coded vector and the second coded vector, and generating a global information vector according to the first attention and the second attention.
The first attention characterizes attention of the first text to the second text, and the second attention characterizes attention of the second text to the first text.
In a specific implementation of step 120, first, an attention matrix of the first text and the second text is generated according to the first encoding vector and the second encoding vector. Specifically, the following similarity function may be used to generate the attention matrix of the first text and the second text:
Figure BDA0001931799930000061
Figure BDA0001931799930000062
wherein S is tj Expressing the attention value between the t-th discourse sentence term and the j-th query sentence term, C t The t-th column vector, Q, representing discourse sentences j A j-th column vector indicating an inquiry statement, indicating a multiplication by element, [;]representing the concatenation of vectors on a line;
Figure BDA0001931799930000063
trainable parameters are represented.
And then, respectively carrying out normalization processing on the rows and the columns of the attention matrix by using a normalization exponential function to obtain a row processing result S 'and a column processing result S'.
Then, the line processing result S' and the transposed vector Q of the second encoding vector are processed T Multiplying to obtain a first attention A, A = S' Q T (ii) a The line processing result S', the transpose of column processing result S " T And transpose C of the first encoded vector T Multiplication gives the second attention B, B = S' S " T C T
Finally, generating a global information vector [ C ] according to the first attention A and the second attention B; a; c ^ A; c £ B ].
And step 130, obtaining a semantic enhancement vector from the global information vector.
The manner of obtaining the semantic enhancement vector from the global information vector may be: firstly, carrying out convolution calculation on a global information vector by utilizing a convolution kernel; and then, performing transposition convolution calculation on the convolution calculation result to obtain a semantic enhancement vector with the same structure as the global information vector. Or splicing the convolution calculation result of the global information vector with the intermediate vector obtained by the transposition convolution calculation to obtain the semantic enhancement vector. By the implementation mode, the semantic information representation of the given text is enriched, and the semantic analysis accuracy is improved.
For step 130, refer to a specific implementation manner of obtaining the preliminary enhancement matrix in step 110, which is not described herein again.
And 140, analyzing a target text corresponding to the second text in the first text according to the semantic enhancement vector.
In a specific implementation, a model encoder layer (model encoder layer) and an output layer of a QAnet model may be used to analyze a target text corresponding to the second text in the first text.
The semantic enhancement vector is used as the input of a model coding layer, wherein the model coding layer comprises 3 model coding modules from bottom to top, and the outputs of the model coding modules are M 0 ,M 1 And M 2 . Make M 0 ,M 1 And M 2 And respectively predicting the probability that each word position in the first text is the starting point of the target text and the probability that each word position in the first text is the end point of the target text to analyze the target text corresponding to the second text in the first text.
According to the technical scheme, the embodiment of the application provides a text semantic parsing method, which comprises the following steps: acquiring vector representation of a given text, and generating a coding vector of the given text according to the vector representation; the given text comprises a first text and a second text; the coding vector comprises a first coding vector corresponding to the first text and a second coding vector corresponding to the second text; generating a first attention and a second attention according to the first coded vector and the second coded vector, and generating a global information vector according to the first attention and the second attention; obtaining a semantic enhancement vector from the global information vector; and analyzing a target text corresponding to the second text in the first text according to the semantic enhancement vector. Compared with the prior art, the technical scheme of the application enriches the semantic representation of the vector to the text, accelerates the calculation convergence speed and improves the accuracy and efficiency by acquiring the semantic enhancement vector from the global information vector and resolving the target text corresponding to the second text in the first text according to the semantic enhancement vector.
Fig. 6 is another embodiment of the text semantic parsing method of the present application. As shown in fig. 6, the method may include:
step 610, obtaining a vector representation of a given text; the given text comprises a first text and a second text; the vector representation includes a first vector representation corresponding to the first text and a second vector representation corresponding to the second text.
The first text may be a discourse sentence (context), and the first text includes a number of words and symbols. The second text may be a query sentence (query) comprising a number of words and symbols.
Specifically, the first text and the second text are participled to obtain a vocabulary set, for example, the first text or the second text is a sentence containing n vocabularies, and the vocabulary set { w ] with n dimensions is obtained after the word segmentation 1 ,w 2 ,…,w n In which w i Represents a vocabulary; then, on one hand, searching an index corresponding to each vocabulary in the vocabulary set in a preset vocabulary table, and converting the vocabulary set into an n-dimensional vector { id } w1 ,id w2 ,…,id wn In which id is wi Representative word w i Corresponding index, and searching corresponding word vector according to index in n-dimensional vector to obtain an n × d vector 1 A word vector matrix of size; on the other hand, each word in the word set is divided into words, and a word set with the elements at each position as words is obtained:
Figure BDA0001931799930000071
wherein c is i-j The expression vocabulary w i M is the maximum number of words contained in a word; then, the index corresponding to each word in the word set is searched in the preset word table to obtain an n multiplied by m multiplied by d 2 A matrix of size, a convolution calculation is performed on the matrix to output an n x d 2 A word vector matrix of size.
And splicing the word vector matrix and the word vector matrix to obtain the vector representation of the given text.
Step 620, obtaining a first semantic enhancement vector and a second semantic enhancement vector from the first vector representation and the second vector representation respectively. A possible implementation of step 620 is described below, taking the example of obtaining a first semantic enhancement vector from a first vector representation.
Referring to fig. 4 and 5, convolution calculation may be performed on the first vector representation, and then the result of the convolution calculation is subjected to transposed convolution calculation, so as to obtain a first semantic enhanced vector having the same structure as the first vector representation. Or splicing the convolution calculation result represented by the first vector and the transposed convolution calculation result to obtain a first semantic enhancement vector.
The second vector representation is processed with reference to the processing of the first vector representation to obtain a second semantic enhanced vector.
Step 620 enriches the semantic information representation of the given text and improves the semantic parsing accuracy.
Step 630, generating a first attention and a second attention according to the first semantic enhancement vector and the second semantic enhancement vector, and generating a global information vector according to the first attention and the second attention.
In step 630, adding position coding information to the first semantic enhancement vector and the second semantic enhancement vector respectively by matrix addition to obtain two input matrices for two convolutional neural networks, extracting a first local information vector corresponding to the first semantic enhancement vector through one of the convolutional neural networks, and extracting a second local information vector corresponding to the second semantic enhancement vector through the other convolutional neural network; acquiring attention information of the given text according to the first local information vector and the second local information, and generating a first coding vector corresponding to the first semantic enhancement vector and a second coding vector corresponding to the second semantic enhancement vector according to the attention information; and finally, generating a first attention and a second attention according to the first coded vector and the second coded vector, and generating a global information vector according to the first attention and the second attention.
And step 640, analyzing a target text corresponding to the second text in the first text according to the global information vector.
The technical scheme of the embodiment includes that a first semantic enhancement vector and a second semantic enhancement vector are obtained from a first vector representation and a second vector representation, first attention and second attention are generated according to the first semantic enhancement vector and the second semantic enhancement vector, and a global information vector is generated according to the first attention and the second attention; and analyzing a target text corresponding to the second text in the first text according to the global information vector. Compared with the prior art, the semantic representation of the vector to the text is enriched, the calculation convergence speed is accelerated, and the accuracy and efficiency of semantic analysis are improved.
It should be noted that all steps related to the above method embodiments of the present application may be implemented by constructing a text semantic parsing model.
For example, the model may include, from bottom to top, an input layer, a presentation layer, an interaction layer, a semantic enhancement layer, and an output layer. Receiving, by an input layer, input given text; representing the given text as a word vector through the representation layer and encoding the word vector to obtain an encoding vector of the given text, i.e., implementing step 110 in the embodiment shown in fig. 1 through the representation layer; then the output of the presentation layer is used as the input of the interaction layer to capture the global information through the interaction layer, and the output is the global information vector, i.e. step 120 in the embodiment shown in fig. 1 is implemented through the interaction layer; then, the output of the interaction layer is used as the input of the semantic enhancement layer, so as to enrich the semantic representation of the input vector through the semantic enhancement layer, and the output is the semantic enhancement vector, that is, step 130 in the embodiment shown in fig. 1 is implemented through the semantic enhancement layer; and finally, giving out a target text corresponding to the second text in the first text through an output layer.
Compared with the prior art, the output accuracy and the convergence speed of the model built based on the text semantic parsing method are remarkably improved.
It should be further noted that, according to different embodiments of the text semantic parsing method of the present application, text semantic parsing models with different hierarchical structures may be constructed, and the foregoing examples do not limit the scope and implementation of the present application. Fig. 7 is an embodiment of a text semantic parsing apparatus according to the present application. The device can be applied to various devices such as a server, a Personal Computer (PC), a tablet personal computer, a mobile phone, virtual reality equipment and intelligent wearable equipment.
As shown in fig. 7, the apparatus may include: embedding and encoding module 710, interaction module 720, semantic enhancement module 730, and parsing module 740.
The embedding and encoding module 710 is configured to obtain a vector representation of a given text, and generate an encoding vector of the given text according to the vector representation; the given text comprises a first text and a second text; the encoding vectors comprise a first encoding vector corresponding to the first text and a second encoding vector corresponding to the second text; the interaction module 720 is configured to generate a first attention and a second attention according to the first encoded vector and the second encoded vector, and generate a global information vector according to the first attention and the second attention; the semantic enhancement module 730 is configured to obtain a semantic enhancement vector from the global information vector; the parsing module 740 is configured to parse a target text corresponding to the second text in the first text according to the semantic enhancement vector.
Specifically, as shown in fig. 8, the apparatus may include two embedding and encoding modules 710, one for processing a first text and the other for processing a second text. Each embedding and encoding module 710 may include an embedding layer 711 and an encoding layer 712. The embedding layer 711 is specifically configured to process the given text to obtain a vector representation of the given text; the encoding layer 712 is specifically configured to add position encoding information to the vector representation to obtain an input matrix of a convolutional neural network, so as to extract a local information vector from the input matrix by using the convolutional neural network; obtaining attention information of the given text according to the local information vector; generating an encoding vector for the given text based on the attention information.
As shown in fig. 9, for each of the embedding and encoding modules 710, a semantic enhancement layer 713 may be further included between the embedding layer 711 and the encoding layer 712; in this implementation, the embedding layer 711 is configured to process the given text to obtain a vector representation of the given text; the semantic enhancement layer 713 is used to obtain a preliminary enhancement matrix from the vector representation of the given text; the coding layer 712 is configured to add position coding information to the preliminary enhancement matrix to obtain an input matrix of a convolutional neural network, so as to extract a local information vector from the input matrix by using the convolutional neural network; obtaining attention information of the given text according to the local information vector; generating an encoding vector for the given text from the attention information.
The semantic enhancement layer 713 is specifically used for performing convolution calculations on the vector representation of the given text; and performing transposition convolution calculation on the convolution calculation result to obtain a preliminary enhancement matrix with the same vector representation structure as the given text.
The interaction module 720 is specifically configured to: generating an attention matrix of the first text and the second text according to the first encoding vector and the second encoding vector; respectively carrying out normalization processing on the rows and the columns of the attention matrix by utilizing a normalization index function to obtain row processing results and column processing results; and multiplying the line processing result by the transposed vector of the second encoding vector to obtain a first attention, and multiplying the line processing result, the transposed matrix of the column processing result and the transposed vector of the first encoding vector to obtain a second attention.
The semantic enhancement module 730 may include: convolutional layer 731 and transpose convolutional layer 732. The convolution layer 731 is used for performing convolution calculation on the global information vector; the transposed convolution layer 732 is configured to perform a transposed convolution calculation on the convolution calculation result to obtain a semantic enhancement vector having the same structure as the global information vector. In another implementation manner, the transposed convolution layer 732 is configured to perform a transposed convolution calculation on the convolution calculation result to obtain an intermediate vector having the same structure as the global information vector; and splicing the convolution calculation result and the intermediate vector to form the semantic enhancement vector.
As can be seen from the foregoing embodiments, in the technical solution of the present application, the embedding and encoding module 710 obtains the vector representation of the given text, and generates the encoding vector of the given text according to the vector representation; generating, by the interaction module 720, a first attention and a second attention according to the first coded vector and the second coded vector, and generating a global information vector according to the first attention and the second attention; obtaining a semantic enhancement vector from the global information vector through the semantic enhancement module 730; and analyzing a target text corresponding to the second text in the first text according to the semantic enhancement vector through an analyzing module 740. Compared with the prior art, the technical scheme of the application enriches the semantic representation of the vector to the text, accelerates the calculation convergence speed, and improves the accuracy and the efficiency.
Fig. 10 is another embodiment of the text semantic parsing apparatus of the present application. The device can be applied to various devices such as a server, a Personal Computer (PC), a tablet personal computer, a mobile phone, virtual reality equipment and intelligent wearable equipment.
As shown in fig. 10, the apparatus may include: an embedding module 100, a semantic enhancement module 200, an encoding and interaction module 300, and a parsing module 400. Wherein the embedding module 100 is configured to obtain a vector representation of the given text; the given text comprises a first text and a second text; the vector representation comprises a first vector representation corresponding to the first text and a second vector representation corresponding to the second text; the semantic enhancement module 200 is configured to obtain a first semantic enhancement vector and a second semantic enhancement vector from the first vector representation and the second vector representation, respectively; the coding and interacting module 300 is configured to generate a first attention and a second attention according to the first semantic enhancement vector and the second semantic enhancement vector, and generate a global information vector according to the first attention and the second attention; the parsing module 400 is configured to parse a target text corresponding to the second text in the first text according to the global information vector.
Compared with the prior art, the device provided by the embodiment of the application enriches the semantic representation of the vector to the text, accelerates the calculation convergence speed, and improves the accuracy and efficiency of semantic analysis.
The application is operational with numerous general purpose or special purpose computing system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet-type devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It will be understood that the present application is not limited to the precise arrangements that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (6)

1. A text semantic parsing method, the method comprising:
acquiring vector representation of a given text, and generating a coding vector of the given text according to the vector representation; the given text comprises a first text and a second text; the encoding vectors comprise a first encoding vector corresponding to the first text and a second encoding vector corresponding to the second text;
generating a first attention and a second attention according to the first coded vector and the second coded vector, and generating a global information vector according to the first attention and the second attention;
obtaining a semantic enhancement vector from the global information vector;
analyzing a target text corresponding to the second text in the first text according to the semantic enhancement vector;
the obtaining of the semantic enhancement vector from the global information vector includes:
performing convolution calculation on the global information vector;
performing transposition convolution calculation on the convolution calculation result to obtain a semantic enhancement vector with the same structure as the global information vector; or; performing transposition convolution calculation on the convolution calculation result to obtain an intermediate vector with the same structure as the global information vector, and splicing the convolution calculation result and the intermediate vector to form the semantic enhancement vector;
the obtaining a vector representation of a given text and generating an encoding vector of the given text according to the vector representation comprises:
processing the given text to obtain a vector representation of the given text;
adding position coding information to the vector representation to obtain an input matrix of a convolutional neural network, so as to extract local information vectors from the input matrix by using the convolutional neural network;
obtaining attention information of the given text according to the local information vector;
generating a coding vector of the given text according to the attention information;
the generating of the first attention and the second attention from the first coded vector and the second coded vector comprises:
generating an attention matrix of the first text and the second text according to the first encoding vector and the second encoding vector;
respectively carrying out normalization processing on the rows and the columns of the attention matrix by utilizing a normalization index function to obtain row processing results and column processing results;
and multiplying the line processing result by the transposed vector of the second encoding vector to obtain a first attention, and multiplying the line processing result, the transposed matrix of the column processing result and the transposed vector of the first encoding vector to obtain a second attention.
2. The method of claim 1, wherein obtaining a vector representation of a given text, and generating an encoding vector for the given text from the vector representation comprises:
processing the given text to obtain a vector representation of the given text;
obtaining a preliminary enhancement matrix from a vector representation of a given text;
adding position coding information to the preliminary enhancement matrix to obtain an input matrix of a convolutional neural network, so as to extract a local information vector from the input matrix by using the convolutional neural network;
obtaining attention information of the given text according to the local information vector;
generating an encoding vector for the given text from the attention information.
3. The method of claim 2, wherein obtaining a preliminary enhancement matrix from the vector representation of the given text comprises:
performing convolution calculation on the vector representation of the given text;
and performing transposed convolution calculation on the convolution calculation result to obtain a primary enhancement matrix with the same structure as the vector representation structure of the given text.
4. A text semantic parsing method, the method comprising:
obtaining a vector representation of a given text; the given text comprises a first text and a second text; the vector representation comprises a first vector representation corresponding to the first text and a second vector representation corresponding to the second text;
respectively acquiring a first semantic enhancement vector and a second semantic enhancement vector from the first vector representation and the second vector representation;
generating a first attention and a second attention according to the first semantic enhancement vector and the second semantic enhancement vector, and generating a global information vector according to the first attention and the second attention;
analyzing a target text corresponding to the second text in the first text according to the global information vector;
the obtaining a first semantic enhancement vector and a second semantic enhancement vector from the first vector representation and the second vector representation, respectively, comprises:
performing a convolution calculation on the first vector representation and the second vector representation;
performing transposition convolution calculation on the convolution calculation result to respectively obtain a first semantic enhancement vector and a second semantic enhancement vector which have the same structures as the first vector representation and the second vector representation;
the generating of the first attention and the second attention from the first semantic enhancement vector and the second semantic enhancement vector comprises:
adding position coding information to the first semantic enhancement vector and the second semantic enhancement vector respectively through matrix addition to obtain two input matrices for two convolutional neural networks;
extracting a first local information vector corresponding to the first semantic enhancement vector through one of the convolutional neural networks, and extracting a second local information vector corresponding to the second semantic enhancement vector through the other convolutional neural network;
obtaining attention information of the given text according to the first local information vector and the second local information vector, and generating a first encoding vector corresponding to a first semantic enhancement vector and a second encoding vector corresponding to a second semantic enhancement vector according to the attention information;
first attention and second attention are generated from the first coded vector and the second coded vector.
5. An apparatus for parsing text semantics, the apparatus comprising:
the embedding and coding module is used for acquiring vector representation of a given text and generating a coding vector of the given text according to the vector representation; the given text comprises a first text and a second text; the encoding vectors comprise a first encoding vector corresponding to the first text and a second encoding vector corresponding to the second text;
the interaction module is used for generating a first attention and a second attention according to the first coding vector and the second coding vector and generating a global information vector according to the first attention and the second attention;
the semantic enhancement module is used for acquiring a semantic enhancement vector from the global information vector;
the analysis module is used for analyzing a target text corresponding to the second text in the first text according to the semantic enhancement vector;
the semantic enhancement module is further configured to:
performing convolution calculation on the global information vector;
performing transposition convolution calculation on the convolution calculation result to obtain a semantic enhancement vector with the same structure as the global information vector;
the embedding and encoding module is further configured to:
processing the given text to obtain a vector representation of the given text;
adding position coding information to the vector representation to obtain an input matrix of a convolutional neural network, so as to extract local information vectors from the input matrix by using the convolutional neural network;
obtaining attention information of the given text according to the local information vector;
generating a coding vector of the given text according to the attention information;
the interaction module is further configured to:
generating an attention matrix of the first text and the second text according to the first encoding vector and the second encoding vector;
respectively carrying out normalization processing on the rows and the columns of the attention matrix by utilizing a normalization index function to obtain row processing results and column processing results;
and multiplying the line processing result by the transposed vector of the second encoding vector to obtain a first attention, and multiplying the line processing result, the transposed matrix of the column processing result and the transposed vector of the first encoding vector to obtain a second attention.
6. An apparatus for parsing text semantics, the apparatus comprising:
an embedding module for obtaining a vector representation of a given text; the given text comprises a first text and a second text; the vector representation comprises a first vector representation corresponding to the first text and a second vector representation corresponding to the second text;
the semantic enhancement module is used for acquiring a first semantic enhancement vector and a second semantic enhancement vector from the first vector representation and the second vector representation respectively;
the coding and interaction module is used for generating a first attention and a second attention according to the first semantic enhancement vector and the second semantic enhancement vector and generating a global information vector according to the first attention and the second attention;
the analysis module is used for analyzing a target text corresponding to the second text in the first text according to the global information vector;
the semantic enhancement module is further configured to:
performing a convolution calculation on the first vector representation and the second vector representation;
performing transposed convolution calculation on a convolution calculation result to respectively obtain a first semantic enhancement vector and a second semantic enhancement vector which have the same structures as the first vector representation and the second vector representation;
the encoding and interaction module is further configured to:
adding position coding information to the first semantic enhancement vector and the second semantic enhancement vector respectively through matrix addition to obtain two input matrices for two convolutional neural networks;
extracting a first local information vector corresponding to the first semantic enhancement vector through one of the convolutional neural networks, and extracting a second local information vector corresponding to the second semantic enhancement vector through the other convolutional neural network;
obtaining attention information of the given text according to the first local information vector and the second local information vector, and generating a first encoding vector corresponding to a first semantic enhancement vector and a second encoding vector corresponding to a second semantic enhancement vector according to the attention information;
first attention and second attention are generated from the first coded vector and the second coded vector.
CN201811644576.6A 2018-12-29 2018-12-29 Text semantic parsing method and device Active CN109740158B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811644576.6A CN109740158B (en) 2018-12-29 2018-12-29 Text semantic parsing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811644576.6A CN109740158B (en) 2018-12-29 2018-12-29 Text semantic parsing method and device

Publications (2)

Publication Number Publication Date
CN109740158A CN109740158A (en) 2019-05-10
CN109740158B true CN109740158B (en) 2023-04-07

Family

ID=66362781

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811644576.6A Active CN109740158B (en) 2018-12-29 2018-12-29 Text semantic parsing method and device

Country Status (1)

Country Link
CN (1) CN109740158B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110297889B (en) * 2019-06-28 2020-10-23 南京冰鉴信息科技有限公司 Enterprise emotional tendency analysis method based on feature fusion
CN110443863B (en) * 2019-07-23 2023-04-07 中国科学院深圳先进技术研究院 Method for generating image by text, electronic equipment and storage medium
CN110516253B (en) * 2019-08-30 2023-08-25 思必驰科技股份有限公司 Chinese spoken language semantic understanding method and system
CN112883295B (en) * 2019-11-29 2024-02-23 北京搜狗科技发展有限公司 Data processing method, device and medium
CN111382574B (en) * 2020-03-11 2023-04-07 中国科学技术大学 Semantic parsing system combining syntax under virtual reality and augmented reality scenes
CN111309891B (en) * 2020-03-16 2022-05-31 山西大学 System for reading robot to automatically ask and answer questions and application method thereof
CN114020881B (en) * 2022-01-10 2022-05-27 珠海金智维信息科技有限公司 Topic positioning method and system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018058994A1 (en) * 2016-09-30 2018-04-05 华为技术有限公司 Dialogue method, apparatus and device based on deep learning
CN108595590A (en) * 2018-04-19 2018-09-28 中国科学院电子学研究所苏州研究院 A kind of Chinese Text Categorization based on fusion attention model
CN108959246A (en) * 2018-06-12 2018-12-07 北京慧闻科技发展有限公司 Answer selection method, device and electronic equipment based on improved attention mechanism
CN109033068A (en) * 2018-06-14 2018-12-18 北京慧闻科技发展有限公司 It is used to read the method, apparatus understood and electronic equipment based on attention mechanism
CN109086423A (en) * 2018-08-08 2018-12-25 北京神州泰岳软件股份有限公司 A kind of text matching technique and device
WO2018232699A1 (en) * 2017-06-22 2018-12-27 腾讯科技(深圳)有限公司 Information processing method and related device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018058994A1 (en) * 2016-09-30 2018-04-05 华为技术有限公司 Dialogue method, apparatus and device based on deep learning
WO2018232699A1 (en) * 2017-06-22 2018-12-27 腾讯科技(深圳)有限公司 Information processing method and related device
CN108595590A (en) * 2018-04-19 2018-09-28 中国科学院电子学研究所苏州研究院 A kind of Chinese Text Categorization based on fusion attention model
CN108959246A (en) * 2018-06-12 2018-12-07 北京慧闻科技发展有限公司 Answer selection method, device and electronic equipment based on improved attention mechanism
CN109033068A (en) * 2018-06-14 2018-12-18 北京慧闻科技发展有限公司 It is used to read the method, apparatus understood and electronic equipment based on attention mechanism
CN109086423A (en) * 2018-08-08 2018-12-25 北京神州泰岳软件股份有限公司 A kind of text matching technique and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
基于双重注意力模型的微博情感分析方法;张仰森等;《清华大学学报(自然科学版)》;20180215(第02期);全文 *
基于词向量技术和混合神经网络的情感分析;胡朝举等;《计算机应用研究》;20171212(第12期);全文 *

Also Published As

Publication number Publication date
CN109740158A (en) 2019-05-10

Similar Documents

Publication Publication Date Title
CN109740158B (en) Text semantic parsing method and device
CN109874029B (en) Video description generation method, device, equipment and storage medium
CN110781306B (en) English text aspect layer emotion classification method and system
CN110990555B (en) End-to-end retrieval type dialogue method and system and computer equipment
CN114676234A (en) Model training method and related equipment
CN111680510B (en) Text processing method and device, computer equipment and storage medium
CN113705313A (en) Text recognition method, device, equipment and medium
CN111767697B (en) Text processing method and device, computer equipment and storage medium
CN116246213B (en) Data processing method, device, equipment and medium
CN113505193A (en) Data processing method and related equipment
CN111597341A (en) Document level relation extraction method, device, equipment and storage medium
CN116543768A (en) Model training method, voice recognition method and device, equipment and storage medium
CN113392265A (en) Multimedia processing method, device and equipment
CN113505601A (en) Positive and negative sample pair construction method and device, computer equipment and storage medium
CN110659392B (en) Retrieval method and device, and storage medium
CN111597815A (en) Multi-embedded named entity identification method, device, equipment and storage medium
CN110222144B (en) Text content extraction method and device, electronic equipment and storage medium
CN112818091A (en) Object query method, device, medium and equipment based on keyword extraction
CN110852066B (en) Multi-language entity relation extraction method and system based on confrontation training mechanism
CN116432705A (en) Text generation model construction method, text generation device, equipment and medium
CN114611529B (en) Intention recognition method and device, electronic equipment and storage medium
CN115730051A (en) Text processing method and device, electronic equipment and storage medium
CN114998041A (en) Method and device for training claim settlement prediction model, electronic equipment and storage medium
CN114974219A (en) Speech recognition method, speech recognition device, electronic apparatus, and storage medium
CN113377965B (en) Method and related device for sensing text keywords

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