Method and device for generating hidden states in recurrent neural networks for language processing
By generating and combining multi-dimensional regional word vectors and performing feedforward neural network processing, it solves the shortcomings of traditional recurrent neural networks in capturing complex linguistic rules and improves the effect of language processing.
Patent Information
- Application Number
- CN201910309929.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-04-17
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2039-04-26
AI Technical Summary
When traditional recurrent neural networks process variable-length word sequences, it is difficult to effectively capture complex linguistic rules, resulting in poor processing results.
By generating multiple-dimensional regional word vectors of the target word vector input at the current moment, and combining them with feed-forward neural network aggregation transformation processing, the corresponding aggregation word vector is generated, thereby generating the target hidden state.
It improves the capture rate of complex linguistic rules, enabling efficient completion of tasks when dealing with long-distance dependent language structures, such as handwriting recognition, sequence annotation, sentiment analysis and machine translation.
Smart Images

Figure CN110162783B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus, computer-readable storage medium and computer equipment for generating hidden states in a recurrent neural network for language processing. Background Art
[0002] With the development of computer technology, natural language processing (NLP) technology has emerged. NLP technology has realized the long-cherished goal of "communicating with computers using natural language". However, for NLP technology, processing variable-length word sequences is still a big challenge.
[0003] Thus, the Recurrent Neural Network (RNN) emerged. A recurrent neural network is a type of recursive neural network that takes sequence data as input, recurses in the direction of sequence evolution, and all nodes (recurrent units) are connected in a chain. The emergence of recurrent neural networks solves the problem of processing variable-length word sequences.
[0004] However, traditional recurrent neural networks use combinatorial calculations in a single space to generate hidden states at each moment. For example, the hidden state at the current moment is generated by combining only the word vector at the current moment and the hidden state at the previous moment in a single space, which results in a low capture rate of complex linguistic rules. Summary of the invention
[0005] Based on this, it is necessary to provide a method, apparatus, computer-readable storage medium and computer device for hidden states in a recurrent neural network for language processing that has a high capture rate of complex linguistic rules in order to address the above problems.
[0006] A method for generating hidden states in a recurrent neural network for language processing, comprising:
[0007] Generate a regional word vector of at least two dimensions of the target word vector input at the current moment;
[0008] Combining the regional word vectors to obtain a combined regional word vector of at least two dimensions;
[0009] Based on a feedforward neural network, each of the combined region word vectors is subjected to clustering transformation processing to obtain a clustered word vector corresponding to the target word vector;
[0010] A target hidden state corresponding to the target word vector is generated based on the clustered word vector.
[0011] A device for generating hidden states in a recurrent neural network for language processing, comprising:
[0012] A regional word vector generation module, used to generate a regional word vector of at least two dimensions of the target word vector input at the current moment;
[0013] A regional word vector combination module, used to combine the regional word vectors to obtain a combined regional word vector of at least two dimensions;
[0014] An aggregation transformation processing module is used to perform aggregation transformation processing on each of the combined region word vectors based on a feedforward neural network to obtain an aggregation word vector corresponding to the target word vector;
[0015] A target hidden state generation module is used to generate a target hidden state corresponding to the target word vector based on the clustered word vector.
[0016] A computer-readable storage medium stores a computer program, which, when executed by a processor, causes the processor to perform the following steps:
[0017] Generate a regional word vector of at least two dimensions of the target word vector input at the current moment;
[0018] Combining the regional word vectors to obtain a combined regional word vector of at least two dimensions;
[0019] Based on a feedforward neural network, each of the combined region word vectors is subjected to clustering transformation processing to obtain a clustered word vector corresponding to the target word vector;
[0020] A target hidden state corresponding to the target word vector is generated based on the clustered word vector.
[0021] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the following steps:
[0022] Generate a regional word vector of at least two dimensions of the target word vector input at the current moment;
[0023] Combining the regional word vectors to obtain a combined regional word vector of at least two dimensions;
[0024] Based on a feedforward neural network, each of the combined region word vectors is subjected to clustering transformation processing to obtain a clustered word vector corresponding to the target word vector;
[0025] A target hidden state corresponding to the target word vector is generated based on the clustered word vector.
[0026] The method, device, computer-readable storage medium and computer equipment for generating hidden states in the above-mentioned recurrent neural network for language processing generate regional word vectors of at least two dimensions of the target word vector input at the current moment, so that the single-dimensional target word vector corresponds to the regional word vector of multiple dimensions, and the regional word vectors are regionally combined to obtain a combined regional word vector of at least two dimensions. Then, based on the feedforward neural network, each combined regional word vector is subjected to clustering transformation processing to obtain the clustered word vector corresponding to the target word vector. The scheme provided by the present application is adopted so that the target word vector at each moment has a corresponding clustered word vector, so that the target hidden state corresponding to the target word vector can be generated on the basis of the clustered word vector. Since the clustered word vector is obtained by performing a multi-dimensional conversion process on the target word vector, the capture rate of complex linguistic laws when using the target hidden state is high. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 is a structural block diagram of a computer device in one embodiment;
[0028] Figure 2 A schematic diagram of a flow chart of a method for generating hidden states in a recurrent neural network for language processing in one embodiment;
[0029] Figure 3 is a flow chart of a method for generating hidden states in a recurrent neural network for language processing in another embodiment;
[0030] Figure 4 is an example diagram of a vector node in one embodiment;
[0031] Figure 5 is an example diagram of an adjacency matrix in one embodiment;
[0032] Figure 6 is an example diagram of a degree matrix in one embodiment;
[0033] Figure 7 An example diagram of a regional word vector matrix in one embodiment;
[0034] Figure 8 A schematic flow chart of a method for generating hidden states in a recurrent neural network for language processing in yet another embodiment;
[0035] Fig. 9 An example diagram of combining and calculating the regional word vectors of a target word vector in one embodiment;
[0036] Fig.10 A schematic flow chart of a method for generating hidden states in a recurrent neural network for language processing in yet another embodiment;
[0037] Fig.11 An example diagram of generating a regional word vector, performing combined calculation on the combined regional word vectors, and performing clustering transformation processing on each of the combined regional word vectors based on a feedforward neural network in one embodiment;
[0038] Fig.12 The present invention is a structural block diagram of a device for generating hidden states in a recurrent neural network for language processing in one embodiment. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0040] The method for generating hidden states in a recurrent neural network for language processing provided in this application can be applied to Figure 1 The computer device shown. The computer device includes a memory and a processor, and a computer program is stored in the memory. When the computer program is executed by the processor, the method for generating hidden states in a recurrent neural network for language processing provided in the present application can be implemented. The computer device can be a terminal or a server. It is understandable that when the computer device is a terminal, the computer device can also include a display screen and an input device, etc. Among them, the terminal can be but is not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices, and the server can be implemented with an independent server or a server cluster consisting of multiple servers.
[0041] like Figure 2 As shown, in one embodiment, a method for generating hidden states in a recurrent neural network for language processing is provided. This embodiment mainly applies this method to the above Figure 1 Refer to the computer equipment in Figure 2 The method for generating hidden states in a recurrent neural network for language processing specifically comprises the following steps:
[0042] S202, generating a regional word vector of at least two dimensions of the target word vector input at the current moment.
[0043] The word vector refers to the real number vector of the corresponding word in the predefined vector space. For example, the real number vector of "dog" in the predefined vector space can be (0.2 0.2 0.4), then (0.2 0.2 0.4) is the word vector of "dog". The target word vector refers to the word vector input at the current moment. The regional word vector refers to the word vectors of different dimensions corresponding to the word vector of one dimension.
[0044] Specifically, when the computer device detects that a target word vector is input at the current moment, the computer device reads the target word vector input at the current moment and triggers the regional word vector generation instruction of the target word vector. The computer device converts the low-dimensional target word vector into a regional word vector of at least two dimensions according to the regional word vector generation instruction. In this way, the target word vector input by the computer device at each moment corresponds to a regional word vector of at least two dimensions.
[0045] In one embodiment, the target word vectors input by the computer device at T time points are a vector sequence X = {X 1 ,X 2 ,……,X T}, where X 1 is the first target word vector in the vector sequence X, X 1 represents the word vector input by the computer device at the first moment; X 2 is the second target word vector in the vector sequence X, X 2 represents the word vector input by the computer device at the second moment; ...; X T is the Tth target word vector in the vector sequence X, X T represents the word vector input by the computer device at the Tth moment. Then, at each moment in the vector sequence X, the computer device will generate a regional word vector of at least two dimensions of the target word vector input at that moment.
[0046] In one embodiment, the vector sequence X={X 1 ,X 2 ,……,X T Each word vector in} is obtained by converting the text in advance. For example, when the computer device is a terminal, a social application for communication is installed in the computer device, and a sub-application for human-computer dialogue runs in the social application for communication. When the computer device detects that the sub-application for human-computer dialogue receives a variable-length voice message, the voice message received at each moment is converted into text information, and the text information is mapped to the target word vector, so that the variable-length voice information will eventually form a vector sequence, which includes the target word vector corresponding to the text information of the voice information received at each moment.
[0047] Of course, when the computer device is a server, the server can receive the various target word vectors that have been converted by other terminals, and generate regional word vectors of at least two dimensions for the target word vectors input at each moment. When the computer device is a server, the server can also directly receive variable-length voice information received by other terminals through a sub-application for human-computer dialogue, convert the voice information received at each moment into text information, and map the text information to the target word vector, so that the variable-length voice information will eventually form a vector sequence, which includes the target word vectors corresponding to the text information of the voice information received at each moment, and generates regional word vectors of at least two dimensions for the target word vectors input at each moment.
[0048] In one embodiment, the regional word vector generation instruction may carry a first preset dimension. When the computer device converts the low-dimensional target word vector into a regional word vector of at least two dimensions according to the regional word vector generation instruction, the low-dimensional target word vector may be converted into a regional word vector of the first preset dimension according to the first preset dimension.
[0049] For example, the current time is T, the first preset dimension is N, and the computer device detects that there is a target word vector X at the current time T T Input. Then the computer device needs to convert the single-dimensional target word vector X T Converted into a regional word vector of N dimensions. The computer device can generate the target word vector X T The N region word vectors Z = {Z 1 ,Z 2 ,……,Z N}, where Z 1 To Z N Both are target word vectors X T The regional word vector of .
[0050] S204, combining the regional word vectors to obtain a combined regional word vector of at least two dimensions.
[0051] The combined regional word vector refers to the word vector obtained by combining and calculating the regional word vectors. For example, if the target word vector has N-dimensional regional word vectors, the computer device can obtain a J-dimensional combined regional word vector after combining and calculating the N-dimensional regional word vectors, where J is greater than or equal to 2.
[0052] Specifically, the computer device is pre-set with a regional vector combination method. After the computer device generates the regional word vector of the target word vector, it obtains the preset regional vector combination method, and the regional vector combination method includes a second preset dimension. The computer device combines and calculates the regional word vectors of the target word vector according to the preset regional vector combination method to obtain a combined regional word vector of the second preset dimension. The regional vector combination method refers to the method of combining and calculating each regional word vector.
[0053] S206, performing clustering transformation processing on the word vectors of each combined region based on a feedforward neural network to obtain a clustered word vector corresponding to the target word vector.
[0054] Among them, the feedforward neural network is a neural network in which each neuron is arranged in layers. Aggregation transformation processing refers to the process of aggregating and transforming the word vectors of each combined region. Aggregation word vector refers to the word vector obtained after aggregating and transforming the word vectors of each combined region.
[0055] Specifically, the computer device can transform each combined region word vector based on the feedforward neural network to obtain an intermediate region word vector with the same dimension as the combined region word vector. For example, the target word vector has a combined region word vector O={O 1 ,O 2 ,……,O J}, then when the computer device transforms each combined region word vector once based on the feedforward neural network, it can also obtain the intermediate region vector F of J dimensions = {F 1 ,F 2 ,……,F J The computer device aggregates the obtained intermediate region word vectors to obtain an intermediate aggregated word vector. The computer device can perform a linear transformation on the obtained intermediate aggregated word vector to obtain an aggregated word vector corresponding to the target word vector.
[0056] S208, generating a target hidden state corresponding to the target word vector based on the clustered word vector.
[0057] Among them, the hidden state refers to the hidden state of the hidden layer output of the recurrent neural network, and the hidden state refers to the system status of the recurrent neural network. The target hidden state refers to the system status of the recurrent neural network at the current moment.
[0058] Specifically, the computer device can obtain the historical hidden state of the historical word vector at the previous moment, and the computer device can add the aggregated word vector of the target word vector on the basis of the historical hidden state to calculate the target hidden state of the target word vector to generate the target hidden state of the target word vector. It can be understood that the historical hidden state of the historical word vector at the previous moment is also generated based on the aggregated word vector of the historical word vector, and the aggregated word vector is obtained by multi-dimensional conversion processing of the historical word vector.
[0059] The method for generating hidden states in the recurrent neural network for language processing generates a regional word vector of at least two dimensions of the target word vector input at the current moment, so that a single-dimensional target word vector corresponds to a regional word vector of multiple dimensions, and each regional word vector is regionally combined to obtain a combined regional word vector of at least two dimensions. Then, each combined regional word vector is clustered and transformed based on a feedforward neural network to obtain a clustered word vector corresponding to the target word vector.
[0060] By adopting the scheme provided by the present application, the target word vector at each moment has a corresponding clustered word vector, so that the target hidden state corresponding to the target word vector can be generated on the basis of the clustered word vector. Since the clustered word vector is obtained by multi-dimensional conversion processing of the target word vector, the capture rate of complex linguistic laws when using the target hidden state is high. For example, in computer equipment processing tasks such as handwriting recognition, sequence labeling, sentiment analysis, language model training and machine translation, even if encountering long-distance dependent language structures, the task can be completed efficiently.
[0061] In one embodiment, generating a regional word vector of at least two dimensions of a target word vector input at the current moment includes: obtaining at least two first weight matrices, each first weight matrix is used to generate a corresponding regional word vector; determining the target word vector input at the current moment, and obtaining the historical hidden state corresponding to the historical word vector at the previous moment; generating a regional word vector of at least two dimensions of the target word vector based on the first weight matrix and the historical hidden state.
[0062] The first weight matrix refers to a weight parameter in the form of a matrix that is trained as the system is trained, and is used to generate the corresponding regional word vector. The historical word vector refers to the word vector input by the computer device at the previous moment before the current moment. The historical hidden state refers to the hidden state corresponding to the word vector input by the computer device at the previous moment before the current moment.
[0063] Specifically, when the computer device detects that a target word vector is input at the current moment, the computer device reads the target word vector input at the current moment and triggers a regional word vector generation instruction for the target word vector. The computer device obtains a first weight matrix for generating a regional word vector according to the regional word vector generation instruction, and the number of the obtained first weight matrices is the same as the number of dimensions of the regional word vector that the computer device needs to generate.
[0064] For example, if the first preset dimension of the regional word vector that the computer device needs to generate is N, then the number of first weight matrices obtained by the computer device is N. The computer device has a corresponding first weight matrix when generating the regional word vector of each dimension: 1 When , there is a corresponding first weight matrix W 1 ; The computer device generates the regional word vector Z of the second dimension 2 When , there is a corresponding first weight matrix W 2 ; ...; The computer device generates the regional word vector Z of the Nth dimension N When , there is a corresponding first weight matrix W N .
[0065] The computer device determines the target word vector input at the current moment, and obtains the historical hidden state corresponding to the historical word vector input by the computer device at the previous moment of the current moment. It can be understood that the previous moment is not necessarily a moment closely adjacent to the current moment. The previous moment is the moment corresponding to the word vector input by the computer device before the target word vector is input.
[0066] For example, the target word vector input by the computer device at T time points is a vector sequence X = {X 1 ,X 2 ,……,X T}, X 1 represents the word vector input by the computer device at the first moment, X 2 Represents the word vector input by the computer device at the second moment. There may be a long time interval or a short time interval between the first moment and the second moment, so the first moment and the second moment are not necessarily closely adjacent moments on the timetable.
[0067] The computer device may generate a regional word vector of a first preset dimension based on the acquired historical hidden state and a first preset number of first weight matrices. The first preset number is the same as the number of the first preset dimension. The regional word vector of the first preset dimension may be a regional word vector matrix as a whole. For example, the computer device needs to convert the target word vector X TConverted to N-dimensional regional word vectors, the obtained N-dimensional regional word vectors can be expressed as the regional word vector matrix Z in the region word embedding matrix 1 To Z N Both are target word vectors X T The regional word vector of .
[0068] In the above embodiment, the computer device directly uses the first weight matrix for generating the corresponding regional word vector to efficiently convert the single-dimensional target word vector into a regional word vector of at least two dimensions. And the regional word vector of at least two dimensions is generated based on the historical hidden state at the previous moment, so that the obtained regional word vector is more accurate.
[0069] In one embodiment, generating a regional word vector of at least two dimensions of a target word vector based on a first weight matrix and a historical hidden state includes: concatenating the target word vector with the historical hidden state to obtain a concatenated word vector; generating a regional word vector matrix based on the concatenated word vector and the first weight matrix; the regional word vector matrix includes regional word vectors of at least two dimensions.
[0070] Specifically, the hidden states at each moment generated by the computer device are in the form of vectors. Therefore, after the computer device determines the target word vector and obtains the historical hidden state corresponding to the historical word vector at the previous moment, it can splice the target word vector at the current moment with the historical hidden state at the previous moment to obtain a spliced word vector. For example, the target word vector contains 8 vector elements, and the historical hidden state contains 5 vector elements. After the computer device directly splices the target word vector with the historical hidden state, the resulting spliced word vector contains 13 vector elements. The computer device multiplies the obtained spliced word vector with each first weight matrix respectively to obtain a regional vector matrix. The regional vector matrix contains regional word vectors of multiple dimensions.
[0071] In one embodiment, the concatenation of the target word vector and the historical hidden state can be expressed as [X t ,h t-1 ], where X t is the target word vector input by the computer device at the current moment, h t-1 is the historical hidden state corresponding to the historical word vector at the previous moment of the current moment. Then the computer device can generate the regional word vector of at least two dimensions of the target word vector according to the following formula: i =W i [X t ,h t-1 ].
[0072] Among them, W iRepresents the first weight matrix. For example, if a computer device needs to generate N regional word vectors, i is 1 to N, and Z i Z 1 To Z N , W i W 1 To W N It is understandable that in calculating Z 1 When Z i =W i [X t ,h t-1 ] is Z 1 =W 1 [X t ,h t-1 ]; in calculating Z 2 When Z i =W i [X t ,h t-1 ] is Z 2 =W 2 [X t ,h t-1 ]; ...; in calculating Z N When Z i =W i [X t ,h t-1 ] is Z N =W N [X t ,h t-1 ]. In this way, the computer device can obtain the regional word vector matrix 1 to N represent the corresponding region word vector Z 1 To Z N The dimension in which it is located.
[0073] It can be understood that each regional word vector in the regional word vector matrix is in a different dimension, each regional word vector contains multiple vector elements, and each vector element is a matrix element of the dimension where the regional word vector belongs. 1 Contains 3 vector elements 0.3, 0.8 and 0.7, then 0.3 is Z 1 The matrix element Z of the first dimension 11 , 0.8 is Z 1 The matrix element Z of the first dimension 12 , 0.7 is Z 1 The matrix element Z of the first dimension 13 . Taking the example that each region vector contains 3 vector elements, the region word vector matrix can be specifically expressed as
[0074] In the above embodiment, the computer device directly concatenates the target word vector with the hidden state at the previous moment to obtain a concatenated word vector, and directly multiplies the concatenated word vector with at least two first weight matrices, so that a regional word vector of at least two dimensions is obtained more efficiently and quickly.
[0075] In one embodiment, Figure 3 As shown, the word vectors of each region are combined to obtain a combined regional word vector of at least two dimensions including:
[0076] S302, determine the edge weights between the word vectors of each region.
[0077] The edge weight refers to the weight of the edge connecting each vector node when each region word vector is used as a vector node.
[0078] Specifically, the regional vector combination method preset by the computer device can be a regional vector combination method based on graph convolutional networks. The computer device determines each regional word vector as a vector node according to the regional vector combination method based on graph convolution, and each vector node has a connecting edge, constructing a graph G = (V, E), where V represents a vector node set and E represents an edge set.
[0079] like Figure 4 As shown, for example, the computer device generates a three-dimensional regional word vector of the target word vector: Z 1 , Z 2 and Z 3 , then the computer device will Z 1 , Z 2 and Z 3 The edges 402 connecting the vector nodes represent the relationship between the two connected vector nodes. The computer device can calculate the similarity between the vector nodes and determine the similarity between the vector nodes as the edge weights of the corresponding edges between the vector nodes.
[0080] In one embodiment, the computer device may calculate and determine the edge weights between the word vectors of each region according to the following formula: ij =(Z i T Z j ) / (‖Z i ‖*‖Z j ‖), where Z i and Z j Z is any region word vector of the target word vector. i T Refers to the region word vector Z i The transposed vector of “‖Z i‖” refers to the regional word vector Z i The L2 norm of “‖Z j ‖” refers to the regional word vector Z j In this way, the computer device can obtain the similarity between the word vectors of each region according to the above formula, and determine the similarity between each vector node as the edge weight of the edge between the corresponding vector nodes.
[0081] S304: Generate an adjacency matrix corresponding to each region word vector according to the determined edge weights.
[0082] Among them, the adjacency matrix is a matrix used to represent the adjacent relationship between vector nodes.
[0083] Specifically, the computer device can use the determined edge weights as matrix elements to form an adjacency matrix. For example, if the computer device generates N-dimensional regional word vectors of the target word vector, the computer device determines the N regional word vectors as vector nodes and calculates the edge weights between each of the N vector nodes. In this way, the adjacency matrix A formed by the computer device using the determined edge weights as matrix elements can be as follows: Figure 5 shown.
[0084] S306, summing up the weights of each edge in each dimension in the adjacency matrix to obtain a degree matrix.
[0085] The degree matrix refers to a matrix formed by the degrees of the vector nodes in each row or column of the adjacency matrix, and the degree of the vector nodes in each row or column is the sum of the matrix elements contained in each row or column in the adjacency matrix.
[0086] Specifically, Figure 5 As shown, each row in the adjacency matrix A includes the edge weights of the edges between a certain vector node and other vector nodes. Figure 5 w in 12 It can represent the edge weight of the edge between the first node and the second node in each vector node. After the computer device obtains the adjacency matrix, it can sum the edge weights included in each row of the adjacency matrix to obtain the degree of the vector node corresponding to each row. For example, the first row in the adjacency matrix includes the vector node Z 1 Edge weights with other vector nodes: W 11 , W 12 , W 13 ,……,W 1N , then the computer device will W 11 To W 1N By adding them together, we can get the vector node Z 1 Degree D 11 .
[0087] Furthermore, the computer device can calculate the degree of the vector node corresponding to each row according to the following formula: ii =∑ j W ij , where W ij Refers to the matrix parameter of the i-th row and j-th column in the adjacency matrix (the matrix parameter is the edge weight between the i-th vector node and the j-th vector node in the vector node). For example, calculate Figure 4 The first row of the adjacency matrix A represents the degree vector of the node, D 11 =∑ j W ij Where j is from 1 to N, then D 11 =W 11 +W 12 +W 13 +…+W 1N .
[0088] The degree of the vector node in each row of the adjacency matrix obtained by the computer device can be expressed as: D 11 , D 22 , D 33 ,……,D NN , computer equipment based on "D 11 , D 22 , D 33 ,……,D NN "Then we can form the degree matrix D, in which D 11 , D 22 , D 33 ,……,D NN All other matrix elements except Figure 6 shown.
[0089] S308, generating a combined region word vector of at least two dimensions based on the adjacency matrix and the degree matrix.
[0090] Specifically, the computer device can generate a combined regional word vector of a second preset dimension based on the obtained adjacency matrix and degree matrix. In this embodiment, the number of the second preset dimensions is the same as the number of regional word vectors of the target word vector.
[0091] In the above embodiment, the computer device uses each regional word vector of the target word vector as a vector node of the graph structure in the graph convolution network, and can calculate the edge weights between each vector node, thereby obtaining the edge weights between each regional word vector, and using the obtained edge weights to generate an adjacency matrix, and then calculating the degree matrix based on the adjacency matrix. In this way, the computer device can directly use the adjacency matrix and the degree matrix to efficiently generate the combined regional word vector.
[0092] In one embodiment, generating a combined regional word vector of at least two dimensions based on an adjacency matrix and a degree matrix includes: determining a regional word vector matrix corresponding to each regional word vector; obtaining a second weight matrix for generating a combined regional word vector matrix; generating a combined regional word vector matrix based on the adjacency matrix, the degree matrix, the regional word vector matrix and the second weight matrix; and the combined regional word vector matrix includes regional word vectors of at least two dimensions.
[0093] The regional word vector matrix refers to a matrix whose matrix elements are the vector elements contained in each regional word vector. The second weight matrix refers to the weight parameters in the form of a matrix in the graph convolution network that are trained as the system is trained, and is used to generate the combined regional word vector matrix.
[0094] Specifically, the computer device uses the vector elements contained in each region word vector as matrix elements to form a region word vector matrix. For example, the computer device generates the target word vector X T The N region word vectors Z = {Z 1 ,Z 2 ,……,Z N}, each region vector contains M vector elements, and the computer device uses the vector elements contained in each region word vector in the N region word vectors Z as matrix elements to form a region word vector matrix Z. The region word vector matrix Z is as follows Figure 7 As shown in 700.
[0095] The computer device obtains a second weight matrix W for generating a combined region word vector matrix g , generate the combined region word vector matrix O according to the following formula: O = σ(D -1 / 2 AD -1 / 2 ZW g ). Wherein, D refers to the degree matrix, A refers to the adjacency matrix, Z refers to the region word vector matrix, and σ is the activation function. Furthermore, the activation function σ can specifically be a sigmoid function "sigmoid(x)". The sigmoid function is a common S-shaped function in biology, also known as an S-shaped growth curve. In this embodiment, the sigmoid function is used as a threshold function in a recurrent neural network.
[0096] The computer device can use the activation function σ to obtain a combined regional word vector matrix O with the same dimension as the regional word vector of the target word vector. Each row of the combined regional word vector matrix O is used as a dimension, and each dimension has a combined regional word vector. For example, the combined regional word vector matrix corresponding to N regional word vectors is Contains J combined region word vectors, and J is the same size as N. Then the computer device can obtain J combined region word vectors O = {O 1 ,O 2 ,……,OJ}.
[0097] In the above embodiment, each regional word vector is taken as a regional word vector matrix as a whole, and a second weight matrix is used to generate a combined regional word vector matrix. A combined regional word vector matrix corresponding to the regional word vector matrix is generated based on the adjacency matrix and the degree matrix, and the generated combined regional word vector matrix includes regional word vectors of at least two dimensions, which further improves the efficiency of generating the combined regional word vector.
[0098] In one embodiment, Figure 8 As shown, the word vectors of each region are combined to obtain a combined regional word vector of at least two dimensions including:
[0099] S802: Determine at least two prediction vectors corresponding to each regional word vector according to a third weight matrix used to generate the combined regional word vector.
[0100] The third weight matrix refers to the weight parameters in the capsule network in the form of a matrix as the system is trained, and is used to generate the combined region word vector matrix. The prediction vector refers to the intermediate variable in the form of a vector in the process of generating the combined region word vector matrix.
[0101] Specifically, the region vector combination method preset by the computer device may be a region vector combination method based on a capsule network. The computer device uses each region word vector as a capsule in the capsule network according to the region vector combination method based on the capsule network. For example, the computer device generates N region word vectors Z={Z 1 ,Z 2 ,……,Z N}, then there are N capsules: Z 1 ,Z 2 ,……,Z N .
[0102] The computer device obtains a third weight matrix W for generating a combined region word vector c Each matrix element W in c ij , where i is 1 to N, N is the total number of capsules, j is 1 to the number of the second preset dimension, in this embodiment, the number of the second preset dimension is greater than or equal to 2 and less than or equal to N, and ij represents the third weight matrix W c The i-th row and j-th column of .
[0103] like Fig. 9 As shown, Fig. 9901-904 in the figure are the initialization stage in which the computer device performs combined calculation of the regional word vectors of the target word vector according to the regional vector combination method based on the capsule network, and 905-910 are the iterative calculation stage in which the computer device performs combined calculation of the regional word vectors of the target word vector according to the regional vector combination method based on the capsule network. In the initialization stage, Fig. 9 As shown in 903, the computer device can generate each matrix element W in the obtained third weight matrix based on each capsule in the capsule network. c ij The corresponding prediction vector Z j|i .
[0104] S804, obtaining at least two prior probability logarithms corresponding to the word vectors of each region.
[0105] The prior probability logarithm refers to a temporary variable in the form of a vector in the process of generating the combined region word vector matrix.
[0106] Specifically, the computer device obtains each prior probability logarithm b from the prior probability logarithm matrix B ij , the prior probability logarithm matrix B includes the prior probability logarithm b ij The number is the total number of capsules * the number of the second preset dimension. Fig. 9 As shown in 902, since it is in the initialization stage at this time, all the prior probability logarithms b in the prior probability logarithm matrix B ij Both are 0.
[0107] S806, determine the coupling coefficient corresponding to each region word vector according to the logarithm of the prior probability.
[0108] Specifically, the computer device enters the iterative calculation stage. In the iterative calculation stage, if Fig. 9 As shown in 905, the computer device obtains each prior probability logarithm b ij Perform normalization: Get the coupling coefficient C between each regional word vector and the corresponding combined regional word vector to be generated ij .
[0109] S808, generating a combined region word vector of at least two dimensions based on the coupling coefficient and the prediction vector.
[0110] Specifically, the computer device obtains the coupling coefficient C ij Afterwards, Fig. 9 As shown in 906 in FIG. 1 , the weighted sum S is calculated according to the following formula j :S j =∑ i C ij Z j|i .like Fig. 9 As shown in 907, the computer device uses a nonlinear activation function squash (S j ) Generate a combined region word vector of the second preset dimension O j .in,
[0111] S810, re-determine the logarithm of the prior probability corresponding to the regional word vector based on the combined regional word vector.
[0112] Specifically, Fig. 9 As shown in 908 in FIG. 1 , the computer device obtains the combined region word vector O j After that, the prior probability logarithm between each regional word vector and each combined regional word vector is re-determined according to the following formula: ij =b ij +Z j|i ·O j .
[0113] S812, continue to determine the coupling coefficient corresponding to each region word vector according to the logarithm of the prior probability, and stop the iteration when the preset iteration condition is met.
[0114] Specifically, redetermine the logarithm of the prior probability b ij After that, return Fig. 9 In step 905, the iteration is stopped until the preset iteration condition is met, and the combined region word vectors generated for the last time are output. The preset iteration condition may be, for example, a preset number of iterations. For example, if the preset number of iterations is 3, when the computer device detects that the current number of iterations has reached the preset number of iterations, the iteration is stopped, and the combined region word vectors generated for the third time are output.
[0115] In the above embodiment, the computer device uses each regional word vector of the target word vector as a capsule in the capsule network, generates at least two prediction vectors corresponding to each regional word vector using the third weight matrix used to generate the combined regional word vector in the capsule network, and obtains at least two initialized prior probability logarithms corresponding to each regional word vector. In the process of generating a combined regional word vector of at least two dimensions based on the prior probability logarithm, the iterative algorithm for the prior probability logarithm in the capsule network is used to more efficiently and accurately generate the final combined regional word vector.
[0116] In one embodiment, redetermining the logarithm of the prior probability corresponding to each regional word vector based on each combined regional word vector includes: determining the scalar product between each combined regional word vector and each corresponding prediction vector; adding each scalar product and the corresponding logarithm of the prior probability to obtain the redetermined logarithm of the prior probability corresponding to each regional word vector.
[0117] Specifically, Fig. 9 As shown in 908 in thej|i ·O j ” refers to the prediction vector Z j|i and the combined region word vector O j The scalar product between them is then added to the current logarithms of the prior probabilities to obtain multiple logarithms of the prior probabilities. 1|1 =(a 1 ,a 2 ,…,a n ), the current combined region word vector O 1 =(c 1 ,c 2 ,…,c n ), then Z 1|1 ·O 1 =a 1 c 1 +a 2 c 2 +……+a n c n . Set the current b 11 With Z 1|1 ·O 1 Add and get the new b 11 =b 11 +Z 1|1 ·O 1 .
[0118] In the above embodiment, the computer device adds the scalar product between each combined region word vector and the corresponding prediction vector to the current prior probability logarithm to obtain multiple re-determined prior probability logarithms. After multiple iterations, the accuracy of the prior probability logarithm is higher, so that the final combined region word vector can be generated more efficiently and accurately.
[0119] In one embodiment, each combined region word vector is clustered and transformed based on a feedforward neural network to obtain a clustered word vector corresponding to a target word vector, including: transforming each combined region word vector based on a feedforward neural network to obtain a transformed combined region word vector; splicing each transformed combined region word vector to obtain a spliced word vector; and performing a linear transformation on the spliced word vector to obtain a clustered word vector corresponding to the target word vector.
[0120] Specifically, the computer device calculates each combined region word vector O={O 1 ,O 2 ,……,O J} to perform a deeper transformation and obtain the transformed combined region word vector F = {f 1 ,f 2 ,……,f JThe computer device concatenates all transformed combined region word vectors in F to obtain a concatenated word vector (f 1 f 2 ……f J ). Then the concatenated word vector (f 1 f 2 ……f J ) performs a linear transformation to obtain the clustered word vector corresponding to the target word vector.
[0121] In the above embodiment, the computer device performs a deeper transformation on the word vectors of each combined region based on a feedforward neural network to obtain a clustered word vector, so that when the target hidden state generated based on the clustered word vector is used to capture complex linguistic laws, the capture rate of complex linguistic laws is high.
[0122] In one embodiment, each combined region word vector is transformed based on a feedforward neural network to obtain the transformed combined region word vector, including: linearly transforming each combined region word vector according to a fourth weight matrix and a first bias vector to obtain a temporary word vector corresponding to each combined region word vector; respectively selecting the maximum vector value from each temporary word vector and a vector threshold; and linearly transforming each maximum vector value according to a fifth weight matrix and a second bias vector to obtain the transformed combined region word vector.
[0123] Among them, the fourth weight matrix refers to the weight parameters in the form of a matrix in the feedforward neural network that are trained as the system is used to perform the first linear transformation on each combination area vector in the feedforward neural network. The fifth weight matrix refers to the weight parameters in the form of a matrix in the feedforward neural network that are trained as the system is used to perform the second linear transformation on each combination area vector in the feedforward neural network. The first bias vector refers to the bias parameter in the form of a vector in the feedforward neural network that are trained as the system is used to perform the first linear transformation on each combination area vector in the feedforward neural network. The second bias vector refers to the bias parameter in the form of a vector in the feedforward neural network that are trained as the system is used to perform the second linear transformation on each combination area vector in the feedforward neural network.
[0124] Specifically, the computer device obtains the fourth weight matrix W in the feedforward neural network 1 and the first bias vector b 1 , using the fourth weight matrix W 1 and the first bias vector b 1 For each combined region word vector O j Perform the first linear transformation: O j W 1 +b 1, and obtain the temporary word vector corresponding to each combined region word vector. Compare each temporary word variable with the vector threshold, and select the maximum vector value between each temporary word variable and the vector threshold.
[0125] For example, if the vector threshold is 0, the computer device compares each temporary word variable with the vector threshold 0, and selects the maximum vector value max(0,0 j W 1 +b 1 ), the temporary word variable greater than the vector threshold 0 is taken as the maximum vector value between the temporary word variable and the vector threshold 0, and the vector threshold 0 greater than the temporary word variable is taken as the maximum vector value between the temporary word variable and the vector threshold 0.
[0126] The computer device obtains the fifth weight matrix W in the feedforward neural network 2 and the second bias vector b 2 , using the fourth weight matrix W 1 and the first bias vector b 1 For each combined region word vector O j Perform the second linear transformation: max(0,O j W 1 +b 1 )W 2 +b 2 , and obtain the transformed combined region word vector F = {f 1 ,f 2 ,……,f J}.
[0127] In the above embodiment, the computer device uses the fourth weight matrix and the first bias vector in the feedforward neural network to perform a first linear transformation on each combined regional word vector to obtain a temporary word vector, and selects the maximum vector value between the temporary word vector and the vector threshold, and uses the fifth weight matrix and the second bias vector in the feedforward neural network to perform a second linear transformation on the maximum vector value to obtain the transformed combined regional word vector. The computer device can use the combined regional word vector to generate a clustered word vector, so that when the target hidden state generated based on the clustered word vector is used to capture complex linguistic laws, the capture rate of complex linguistic laws is high.
[0128] In one embodiment, the clustered word vector includes a first clustered word vector and a second clustered word vector, and the first clustered word vector is different from the second clustered word vector; generating a target hidden state corresponding to the target word vector based on the clustered word vector includes: determining a candidate hidden state corresponding to the target word vector based on the first clustered word vector and a corresponding first activation function; determining a gating parameter corresponding to the target word vector based on the second clustered word vector and a corresponding second activation function; and generating a target hidden state corresponding to the target word vector according to the candidate hidden state, the gating parameter, and the historical hidden state of the historical word vector at the previous moment.
[0129] Specifically, when the computer device generates the regional word vector of the target word vector, it generates the clustered word vector based on the first weight matrix corresponding to the first clustered word vector and the first weight matrix corresponding to the second clustered word vector. When the computer device generates the regional word vector based on the first weight matrix corresponding to the first clustered word vector, the clustered word vector corresponding to the target word vector finally obtained by the computer device is the first clustered word vector M h When the computer device generates the regional word vector based on the first weight matrix corresponding to the second clustered word vector, the clustered word vector corresponding to the target word vector finally obtained by the computer device is the second clustered word vector M g .
[0130] The computer device determines the candidate hidden state h of the target word vector through the first activation function tanh t :h~ t =tanh(M h ). The computer device determines the gating parameter g of the target word vector through the second activation function σ t :g t =σ(M g ). Further,
[0131] The computer device obtains the candidate hidden state h~ corresponding to the target word vector t and the gating parameter g t Then, the target hidden state h of the target word vector is calculated according to the following formula t :h t =(1-g t )⊙h t-1 +g t ⊙h~ t . Where ⊙ is the element-wise product operator, “(1-g t )⊙h t-1 "refers to (1-g t ) and h t-1 Perform element-wise multiplication, "g t ⊙h~ t " refers to gt and h~ t Performs element-wise product.
[0132] In the above embodiment, since the first clustered word vector and the second clustered word vector are both obtained by performing multi-dimensional conversion processing on the target word vector, the candidate hidden state obtained based on the first clustered word vector and the gating parameter obtained based on the second clustered word vector are more accurate. In this way, when complex linguistic rules are captured using the target hidden state obtained based on the more accurate candidate hidden state and gating parameter, the capture rate of complex linguistic rules is high.
[0133] In one embodiment, Fig.10 As shown, the method for generating hidden states in a recurrent neural network for language processing may include the following steps:
[0134] S1002, the computer device generates a region word vector of a first preset dimension according to a region word vector generation formula.
[0135] Specifically, Fig.11 As shown in 1101, the regional word vector generation formula is: i =W i [X t ,h t-1 ]. For example, if the first preset dimension is N, then i is 1 to N, and the N-dimensional regional word vector obtained by the computer device can be expressed as Z={Z 1 ,Z 2 ,……,Z N}.
[0136] S1004, the computer device combines and calculates the regional word vectors of the first preset dimension according to a preset regional vector combination method to obtain a combined regional word vector of the second preset dimension.
[0137] Specifically, Fig.11 As shown in 1102, the computer device obtains the N-dimensional regional word vector Z={Z 1 ,Z 2 ,……,Z N} performs combined calculation, for example, if the second preset dimension is J, the computer device can obtain J combined region word vectors O={O 1 ,O 2 ,……,O J J may be equal to N or may not be equal to N. For example, when the preset regional vector combination method is a regional vector combination method based on graph convolution, the second preset dimension J is equal to the first preset dimension N. When the preset regional vector combination method is a regional vector combination method based on capsule network, the second preset dimension J is greater than or equal to 2 and less than or equal to the first preset dimension N.
[0138] S1006, performing deep transformation on each combined region word vector based on a feedforward neural network to obtain an intermediate region word vector of a second preset dimension.
[0139] Specifically, Fig.11 As shown in 1103, FFN refers to the process of deep transformation of each combined region word vector based on a feedforward neural network. Further, when the computer device performs FFN processing on each combined region word vector, each intermediate region word vector f can be generated according to the following formula j :f j =max(0,O j W 1 +b 1 )W 2 +b 2 For example, if the second preset dimension is J, the computer device can generate J intermediate region word vectors F = {f 1 ,f 2 ,……,f J}.
[0140] S1008, the computer device splices the middle area word vectors of the second preset dimension to obtain a spliced word vector, and performs a linear transformation on the spliced word vector to obtain a clustered word vector.
[0141] Specifically, Fig.11 As shown in 1103, “Concat & Linear” means that the computer device concatenates the J intermediate region word vectors F = {f 1 ,f 2 ,……,f J}After concatenation (Concat), a linear transformation (Linear) is performed again.
[0142] S1010, the computer device generates a target hidden state corresponding to the target word vector based on the clustered word vector.
[0143] Specifically, the clustered word vector is divided into the first clustered word vector M h and the second clustered word vector M g The computer device may be based on the first clustered word vector M h and the second clustered word vector M g Calculate the candidate hidden state h~ t and the gating parameter g t : Candidate hidden state h~ t =tanh(M h ), gating parameter g t =σ(M g ). In this way, the computer device can be based on the candidate hidden state h~ t and the gating parameter gt Calculate the target hidden state h of the target word vector t : Target hidden state h t =(1-g t )⊙h t-1 +g t ⊙h~ t .
[0144] In one embodiment, for example, in an application scenario of human-computer dialogue, a computer device receives voice information of variable length, and the computer device converts the voice information received at each moment into text information, and maps the text information into a target word vector, and generates a target hidden state of each target word vector through the steps of the method for generating a hidden state in a recurrent neural network for language processing in any of the above embodiments.
[0145] The computer device may calculate the average hidden state of the generated multiple target hidden states and use the average hidden state as h t-1 , X t Is a 0 vector. Based on h t-1 and X t Calculate the first clustered word vector M h and the second clustered word vector M g The computer device is based on the first clustered word vector M h and the second clustered word vector M g Calculate the candidate hidden state h~ t and the gating parameter g t : Candidate hidden state h~ t =tanh(M h ), gating parameter g t =σ(M g ), and according to the formula h t =(1-g t )⊙h t-1 +g t ⊙h~ t , get the intermediate hidden state h t For example, the intermediate hidden state h t is a vector containing 100 vector elements, then the intermediate hidden state h t and a weight matrix W containing 100*Y v Multiply them together to get an intermediate vector containing Y vector elements. Through softmax (intermediate vector), Y probability values can be obtained, each of which represents the probability of a word in the corresponding word list. For example, if Y is 10,000, the computer device can obtain 10,000 probability values.
[0146] The computer device uses the word corresponding to the maximum probability value among the Y probability values as the first word that the computer device needs to respond to in the current human-computer dialogue. The computer device uses the word vector of the first word that the computer device needs to respond to as X t , the intermediate hidden state h t As h t-1 , continue to execute based on h t-1 and X t Calculate the first clustered word vector M h and the second clustered word vector M g According to the same calculation steps, the computer device can obtain the second word, the third word, the fourth word, etc. that need to be answered. The iteration ends when the maximum probability value obtained meets the end condition. Further, the end condition can be that the word corresponding to the maximum probability value is a specified end symbol.
[0147] Figure 2 , 3 , 8 and 10 are flowcharts of a method for generating hidden states in a recurrent neural network for language processing in one embodiment. It should be understood that although Figure 2 , 3 The steps in the flowcharts of , 8 and 10 are shown sequentially as indicated by the arrows, but these steps are not necessarily executed sequentially in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2 , 3 , 8 and at least part of the steps in 10 may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0148] In one embodiment, Fig.12 As shown, a device 1200 for generating hidden states in a recurrent neural network for language processing is provided, the device comprising a regional word vector generation module 1201, a regional word vector combination module 1202, an aggregation transformation processing module 1203 and a target hidden state generation module 1204, wherein:
[0149] The regional word vector generating module 1201 is used to generate regional word vectors of at least two dimensions of the target word vector input at the current moment.
[0150] The regional word vector combination module 1202 is used to combine the regional word vectors to obtain a combined regional word vector of at least two dimensions.
[0151] The clustering transformation processing module 1203 is used to perform clustering transformation processing on each combined region word vector based on a feedforward neural network to obtain a clustered word vector corresponding to the target word vector.
[0152] The target hidden state generation module 1204 is used to generate a target hidden state corresponding to the target word vector based on the clustered word vector.
[0153] In one embodiment, the regional word vector generation module is also used to: obtain at least two first weight matrices, each first weight matrix is used to generate a corresponding regional word vector; determine the target word vector input at the current moment, and obtain the historical hidden state corresponding to the historical word vector at the previous moment; generate a regional word vector of at least two dimensions of the target word vector based on the first weight matrix and the historical hidden state.
[0154] In one embodiment, the regional word vector generation module is also used to: concatenate the target word vector with the historical hidden state to obtain a concatenated word vector; generate a regional word vector matrix based on the concatenated word vector and the first weight matrix; the regional word vector matrix includes regional word vectors of at least two dimensions.
[0155] In one embodiment, the regional word vector combination module is also used to: determine the edge weights between the regional word vectors; generate an adjacency matrix corresponding to the regional word vectors according to the determined edge weights; sum up the edge weights of each dimension in the adjacency matrix to obtain a degree matrix; and generate a combined regional word vector of at least two dimensions based on the adjacency matrix and the degree matrix.
[0156] In one embodiment, the regional word vector combination module is also used to: determine the regional word vector matrix corresponding to each regional word vector; obtain a second weight matrix for generating a combined regional word vector matrix; generate a combined regional word vector matrix based on the adjacency matrix, the degree matrix, the regional word vector matrix and the second weight matrix; the combined regional word vector matrix includes regional word vectors of at least two dimensions.
[0157] In one embodiment, the regional word vector combination module is also used to: determine at least two prediction vectors corresponding to each regional word vector based on a third weight matrix used to generate a combined regional word vector; obtain at least two prior probability logarithms corresponding to each regional word vector; determine the coupling coefficient corresponding to each regional word vector based on the prior probability logarithm; generate a combined regional word vector of at least two dimensions based on the coupling coefficient and the prediction vector; re-determine the prior probability logarithm corresponding to the regional word vector based on the combined regional word vector; continue to determine the coupling coefficient corresponding to each regional word vector based on the prior probability logarithm until the iteration is stopped when a preset iteration condition is met.
[0158] In one embodiment, the regional word vector combination module is also used to: determine the scalar product between each combined regional word vector and the corresponding prediction vector; add each scalar product and the corresponding prior probability logarithm to obtain the re-determined prior probability logarithm corresponding to each regional word vector.
[0159] In one embodiment, the clustering transformation processing module is also used to: transform each combined region word vector based on a feedforward neural network to obtain a transformed combined region word vector; splice each transformed combined region word vector to obtain a spliced word vector; perform a linear transformation on the spliced word vector to obtain a clustered word vector corresponding to the target word vector.
[0160] In one embodiment, the clustering transformation processing module is also used to: perform linear transformation on each combined area word vector according to the fourth weight matrix and the first bias vector to obtain a temporary word vector corresponding to each combined area word vector; respectively select the maximum vector value between each temporary word vector and the vector threshold; perform linear transformation on each maximum vector value according to the fifth weight matrix and the second bias vector to obtain the transformed combined area word vector.
[0161] In one embodiment, the clustered word vector includes a first clustered word vector and a second clustered word vector, and the first clustered word vector is different from the second clustered word vector; the target hidden state generation module is also used to: determine the candidate hidden state corresponding to the target word vector based on the first clustered word vector and the corresponding first activation function; determine the gating parameter corresponding to the target word vector based on the second clustered word vector and the corresponding second activation function; generate the target hidden state corresponding to the target word vector according to the candidate hidden state, the gating parameter and the historical hidden state of the historical word vector at the previous moment.
[0162] Figure 1 FIG. 1 shows an internal structure diagram of a computer device in an embodiment. The computer device may specifically be a terminal or a server. Figure 1 As shown, the computer device includes a processor, a memory and a network interface connected via a system bus. It is understandable that when the computer device is a terminal, the computer device may also include a display screen and an input device, etc. Among them, the memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program. When the computer program is executed by the processor, the processor can implement a method for generating hidden states in a recurrent neural network for language processing.
[0163] The internal memory may also store a computer program, which, when executed by the processor, enables the processor to execute a method for generating hidden states in a recurrent neural network for language processing. When the computer device is a terminal, the display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device may be a touch layer covered on the display screen, or a key, trackball or touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse.
[0164] Those skilled in the art will understand that Figure 1 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0165] In one embodiment, the device for generating hidden states in a recurrent neural network for language processing provided by the present application can be implemented in the form of a computer program, which can be used in Figure 1 The computer device shown in the figure is run on the computer device. The memory of the computer device can store various program modules that constitute the hidden state generation device in the recurrent neural network for language processing, for example, Fig.12 The regional word vector generation module 1201, regional word vector combination module 1202, clustering transformation processing module 1203 and target hidden state generation module 1204 are shown. The computer program composed of various program modules enables the processor to execute the steps of the method for generating hidden states in a recurrent neural network for language processing in various embodiments of the present application described in this specification.
[0166] For example, Figure 1 The computer device shown can be Fig.12 The regional word vector generation module 1201 in the hidden state generation device 1200 in the recurrent neural network for language processing shown generates a regional word vector of at least two dimensions of the target word vector input at the current moment. The computer device can perform a combination of the regional word vectors through the regional word vector combination module 1202 to obtain a combined regional word vector of at least two dimensions. The computer device can perform a clustering transformation processing based on the feedforward neural network on each combined regional word vector through the clustering transformation processing module 1203 to obtain a clustered word vector corresponding to the target word vector. The computer device can perform a target hidden state generation module 1204 to generate a target hidden state corresponding to the target word vector based on the clustered word vector.
[0167] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method for generating a hidden state in a recurrent neural network for language processing. The steps of the method for generating a hidden state in a recurrent neural network for language processing here may be the steps of the method for generating a hidden state in a recurrent neural network for language processing in the above-mentioned embodiments.
[0168] In one embodiment, a computer-readable storage medium is provided, storing a computer program, and when the computer program is executed by a processor, the processor executes the steps of the method for generating hidden states in a recurrent neural network for language processing. The steps of the method for generating hidden states in a recurrent neural network for language processing here may be the steps of the method for generating hidden states in a recurrent neural network for language processing in the above-mentioned embodiments.
[0169] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0170] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0171] The above-described embodiments only express several implementations of the present application according to the preset, and the description is relatively specific and detailed, but it cannot be understood as limiting the scope of the patent of the present application. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present application, which all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be based on the attached claims.
Claims
1. A method for generating hidden states in a recurrent neural network for language processing, comprising: Get the current voice information; Convert the current voice information into text information, and map the text information into a target word vector; Obtain at least two first weight matrices, and obtain the historical hidden state corresponding to the historical word vector at the previous moment of the current moment, each of the first weight matrices is used to generate a corresponding regional word vector; Based on the at least two first weight matrices and the historical hidden state, generating a regional word vector of at least two dimensions of the target word vector; Combining the regional word vectors to obtain a combined regional word vector of at least two dimensions; Based on a feedforward neural network, each of the combined region word vectors is subjected to clustering transformation processing to obtain a clustered word vector corresponding to the target word vector; A target hidden state corresponding to the target word vector is generated based on the clustered word vector, where the target hidden state is a hidden state output by the target word vector in the hidden layer of the recurrent neural network.
2. The method according to claim 1, characterized in that The generating of the regional word vector of at least two dimensions of the target word vector based on the first weight matrix and the historical hidden state comprises: Concatenate the target word vector with the historical hidden state to obtain a concatenated word vector; A regional word vector matrix is generated according to the concatenated word vector and the first weight matrix; the regional word vector matrix includes regional word vectors of at least two dimensions.
3. The method according to claim 1, characterized in that The combining of the regional word vectors to obtain a combined regional word vector of at least two dimensions includes: Determining edge weights between the word vectors of each region; Generating an adjacency matrix corresponding to each of the regional word vectors according to the determined edge weights; Respectively summing up the edge weights of each dimension in the adjacency matrix to obtain a degree matrix; A combined region word vector of at least two dimensions is generated based on the adjacency matrix and the degree matrix.
4. The method according to claim 3, characterized in that The generating of a combined region word vector of at least two dimensions based on the adjacency matrix and the degree matrix includes: Determine a regional word vector matrix corresponding to each of the regional word vectors; Obtain a second weight matrix for generating a combined region word vector matrix; A combined regional word vector matrix is generated according to the adjacency matrix, the degree matrix, the regional word vector matrix and the second weight matrix; the combined regional word vector matrix includes regional word vectors of at least two dimensions.
5. The method according to claim 1, characterized in that The combining of the regional word vectors to obtain a combined regional word vector of at least two dimensions includes: Determining at least two prediction vectors corresponding to each of the regional word vectors according to a third weight matrix used to generate the combined regional word vector; Obtain at least two prior probability logarithms corresponding to each of the region word vectors; Determine the coupling coefficient corresponding to each of the regional word vectors according to the prior probability logarithm; Generate a combined region word vector of at least two dimensions based on the coupling coefficient and the prediction vector; Re-determine the prior probability logarithm corresponding to the regional word vector according to the combined regional word vector; Continue to determine the coupling coefficient corresponding to each of the regional word vectors according to the prior probability logarithm, and stop the iteration when a preset iteration condition is met.
6. The method according to claim 5, characterized in that The re-determining the prior probability logarithm corresponding to each of the combined regional word vectors according to each of the combined regional word vectors includes: Determining the scalar product between each of the combined region word vectors and each corresponding prediction vector; Each of the scalar products is summed with the corresponding logarithm of the prior probability to obtain the re-determined logarithm of the prior probability corresponding to each of the regional word vectors.
7. The method according to claim 1, characterized in that The step of performing clustering transformation processing on the combined region word vectors based on a feedforward neural network to obtain a clustered word vector corresponding to the target word vector includes: Transforming each of the combined region word vectors based on a feedforward neural network to obtain a transformed combined region word vector; Concatenate the transformed combined region word vectors to obtain a concatenated word vector; Perform a linear transformation on the concatenated word vectors to obtain the clustered word vector corresponding to the target word vector.
8. The method according to claim 7, characterized in that The transforming of each of the combined region word vectors based on the feedforward neural network to obtain the transformed combined region word vectors comprises: Performing a linear transformation on each of the combined region word vectors according to the fourth weight matrix and the first bias vector to obtain a temporary word vector corresponding to each of the combined region word vectors; Selecting the maximum vector value among the temporary word vectors and the vector threshold respectively; Perform a linear transformation on each of the maximum vector values according to the fifth weight matrix and the second bias vector to obtain a transformed combined region word vector.
9. The method according to any one of claims 1 to 8, characterized in that The clustered word vector includes a first clustered word vector and a second clustered word vector, wherein the first clustered word vector is different from the second clustered word vector; The generating a target hidden state corresponding to the target word vector based on the clustered word vector includes: Determine a candidate hidden state corresponding to the target word vector based on the first clustered word vector and the corresponding first activation function; Determine a gating parameter corresponding to the target word vector based on the second clustered word vector and the corresponding second activation function; A target hidden state corresponding to the target word vector is generated according to the candidate hidden state, the gating parameter and the historical hidden state of the historical word vector at the previous moment.
10. A device for generating hidden states in a recurrent neural network for language processing, comprising: A module for obtaining the voice information at the current moment; A module for converting the voice information at the current moment into text information and mapping the text information into a target word vector; A regional word vector generation module, used to obtain at least two first weight matrices, obtain the historical hidden state corresponding to the historical word vector at the previous moment of the current moment, and each of the first weight matrices is used to generate a corresponding regional word vector; Based on the at least two first weight matrices and the historical hidden state, generating a regional word vector of at least two dimensions of the target word vector; A regional word vector combination module, used to combine the regional word vectors to obtain a combined regional word vector of at least two dimensions; An aggregation transformation processing module, used for performing aggregation transformation processing on each of the combined region word vectors based on a feedforward neural network to obtain an aggregation word vector corresponding to the target word vector; A target hidden state generation module is used to generate a target hidden state corresponding to the target word vector based on the clustered word vector, and the target hidden state is the hidden state output by the target word vector in the hidden layer of the recurrent neural network.
11. The device according to claim 10, characterized in that The regional word vector generation module is also used for: Concatenate the target word vector with the historical hidden state to obtain a concatenated word vector; A regional word vector matrix is generated according to the concatenated word vector and the first weight matrix; the regional word vector matrix includes regional word vectors of at least two dimensions.
12. The device according to claim 10, characterized in that The regional word vector combination module is also used to determine the edge weights between each of the regional word vectors; generate an adjacency matrix corresponding to each of the regional word vectors according to the determined edge weights; respectively add the edge weights of each dimension in the adjacency matrix to obtain a degree matrix; and generate a combined regional word vector of at least two dimensions based on the adjacency matrix and the degree matrix.
13. The device according to claim 12, characterized in that The regional word vector combination module is also used to determine the regional word vector matrix corresponding to each of the regional word vectors; obtain a second weight matrix for generating a combined regional word vector matrix; generate a combined regional word vector matrix according to the adjacency matrix, the degree matrix, the regional word vector matrix and the second weight matrix; the combined regional word vector matrix includes regional word vectors of at least two dimensions.
14. The device according to claim 10, characterized in that The regional word vector combination module is further used to determine at least two prediction vectors corresponding to each of the regional word vectors according to a third weight matrix used to generate a combined regional word vector; obtain at least two prior probability logarithms corresponding to each of the regional word vectors; determine a coupling coefficient corresponding to each of the regional word vectors according to the prior probability logarithms; generate a combined regional word vector of at least two dimensions based on the coupling coefficients and the prediction vector; and re-determine the prior probability logarithm corresponding to the regional word vector according to the combined regional word vector; Continue to determine the coupling coefficient corresponding to each of the regional word vectors according to the prior probability logarithm, and stop the iteration when a preset iteration condition is met.
15. The device according to claim 14, characterized in that The regional word vector combination module is also used to determine the scalar product between each of the combined regional word vectors and the corresponding prediction vectors; each of the scalar products is added to the corresponding prior probability logarithm to obtain the re-determined prior probability logarithm corresponding to each of the regional word vectors.
16. The device according to claim 10, characterized in that The cluster transformation processing module is further used to transform each of the combined region word vectors based on a feedforward neural network to obtain a transformed combined region word vector; splice each of the transformed combined region word vectors to obtain a spliced word vector; The concatenated word vectors are linearly transformed to obtain the clustered word vector corresponding to the target word vector.
17. The device according to claim 16, characterized in that The clustering transformation processing module is further used to perform a linear transformation on each of the combined region word vectors according to the fourth weight matrix and the first bias vector to obtain a temporary word vector corresponding to each of the combined region word vectors; Select the maximum vector value from each of the temporary word vectors and the vector threshold respectively; perform linear transformation on each of the maximum vector values according to the fifth weight matrix and the second bias vector to obtain a transformed combined regional word vector.
18. The device according to any one of claims 10 to 17, characterized in that The clustered word vector includes a first clustered word vector and a second clustered word vector, and the first clustered word vector is different from the second clustered word vector; the target hidden state generation module is further used to determine the candidate hidden state corresponding to the target word vector based on the first clustered word vector and the corresponding first activation function; Based on the second clustered word vector and the corresponding second activation function, a gating parameter corresponding to the target word vector is determined; and a target hidden state corresponding to the target word vector is generated according to the candidate hidden state, the gating parameter and the historical hidden state of the historical word vector at the previous moment.
19. A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 9.
20. A computer device comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Abstractive summarization of long documents using deep learning
US20190278835A1
