A text processing network, a neural network training method and related equipment
By designing the similarity calculation module and generation module in the text processing network to process two or more characters and fuse dimension-level similarity information, the problem of low computational efficiency and insufficient accuracy of the recurrent neural network when processing multiple characters is solved. Enables more efficient and precise text processing.
Patent Information
- Application Number
- CN202010478969.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-05-29
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2040-05-29
AI Technical Summary
Existing recurrent neural networks have low computational efficiency when processing multiple characters, and are difficult to effectively process fine-grained information in text, resulting in insufficient text processing accuracy.
A text processing network is designed, including a similarity calculation module and a generation module, which can process two or more characters at one time. Through similarity calculation and generation of feature information, it integrates the similarity information of characters at the dimensional level to improve text processing. Accuracy.
More efficient text processing is achieved, and the generated feature information contains finer-grained information, improving the accuracy and efficiency of the text processing network.
Smart Images

Figure CN111797589B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and in particular to a text processing network, a neural network training method, and related equipment. Background Art
[0002] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a branch of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making. At present, text processing based on deep learning neural networks is a common application of artificial intelligence.
[0003] In the field of natural language processing (NLP), sequence modeling refers to the process of effectively encoding a text data into a representation, that is, the process of extracting features from the text. Recurrent neural network (RNN) is a common neural network used for text feature extraction.
[0004] However, when the text to be processed includes multiple characters, the recurrent neural network can only process each character one by one, and the computational efficiency is relatively poor. A neural network that can process text more efficiently is urgently needed. Summary of the invention
[0005] The embodiments of the present application provide a text processing network, a neural network training method and related equipment. The text processing network can process two or more characters at a time, providing a more efficient text processing network; the generated second feature information incorporates finer-grained information, thereby improving the accuracy of the entire text processing network.
[0006] To solve the above technical problems, the present application provides the following technical solutions:
[0007] In a first aspect, an embodiment of the present application provides a text processing network that can be used in the field of text processing in the field of artificial intelligence. The text processing network includes a feature extraction network, and the feature extraction network includes a similarity calculation module and a generation module. Among them, the similarity calculation module is used to receive at least two first characters input, and perform feature extraction on at least two first characters to obtain first feature information corresponding to at least two first characters, and the first feature information includes feature information of the first character in at least one dimension. Among them, the similarity calculation module can receive the original representation corresponding to at least two first characters, and the original representation of a first character is a sequence data including d elements, which is used to indicate that the sequence data of the first character will carry the information of the first character in d dimensions, and one element in the sequence data of a first character can correspond to one dimension of a first character. The similarity calculation module is also used to calculate the first similarity information of at least two first characters at the dimension level according to the first feature information. The generation module is used to generate second feature information corresponding to at least two first characters according to the first similarity information, and the difference between the second feature information and the first feature information is that the first similarity information is integrated into the second feature information. In this implementation, the text processing network can process two or more characters at a time, providing a more efficient text processing network; in addition, in the process of generating character feature information, the similarity information of the characters at the dimensional level is combined, that is, the generated second feature information incorporates more fine-grained information, which is beneficial to improving the accuracy of the entire text processing network.
[0008] In a possible implementation of the first aspect, the first feature information includes a first representation and a second representation, both of which are matrices, a column of data in the first representation includes feature information of at least two first characters in one dimension, and a column of data in the second representation includes feature information of at least two first characters in one dimension. A similarity calculation module is specifically used to calculate the similarity between the column data in the first representation and the column data in the second representation to obtain the first similarity information. Among them, the first similarity information includes the similarity between the first representation and the second representation in each dimension, and the first similarity information can be specifically expressed as a d×d matrix, that is, the first similarity information can include d×d elements. Further, the element located in the i-th row and j-th column of the first similarity information represents the similarity score between the i-th dimension of the first representation and the j-th dimension of the second representation, i is an integer not less than 1 and not greater than d, and j is an integer not less than 1 and not greater than d. In this implementation, the first representation and the second representation are determined as matrices, and the similarity between the column data in the first representation and the column data in the second representation is calculated to obtain the similarity information of the first representation and the second representation at the dimension level, which is simple to operate.
[0009] In a possible implementation of the first aspect, the similarity calculation module is specifically configured to perform a transposition process on the first representation, and calculate the similarity between the row data in the transposed first representation and the column data in the second representation, so as to obtain the first similarity information. In this implementation, a specific implementation method for generating the first similarity information is provided, which improves the degree of integration of this solution with specific application scenarios.
[0010] In a possible implementation of the first aspect, the similarity calculation module is specifically used to: perform a dot product between the row data of the target row in the transposed first representation and the column data of the target column in the second representation, or calculate the Euclidean distance between the row data of the target row in the transposed first representation and the column data of the target column in the second representation, or calculate the Manhattan distance between the row data of the target row in the transposed first representation and the column data of the target column in the second representation, or calculate the Mahalanobis distance between the row data of the target row in the transposed first representation and the column data of the target column in the second representation, or calculate the cosine similarity between the row data of the target row in the transposed first representation and the column data of the target column in the second representation, so as to generate a similarity score between the row data of the target row in the transposed first representation and the column data of the target column in the second representation, that is, to generate an element value in the first similarity information. The row data of the target row in the transposed first representation refers to any row data of the multiple rows of data included in the transposed first representation, and the column data of the target column in the second representation refers to any column data of the multiple columns of data included in the second representation.
[0011] In a possible implementation of the first aspect, the similarity calculation module is specifically used to: perform a dot product between the column data of the target column in the first representation and the column data of the target column in the second representation; or, calculate the Euclidean distance between the column data of the target column in the first representation and the column data of the target column in the second representation; or, calculate the Manhattan distance between the column data of the target column in the first representation and the column data of the target column in the second representation; or, calculate the Mahalanobis distance between the column data of the target column in the first representation and the column data of the target column in the second representation; or, calculate the cosine similarity between the column data of the target column in the first representation and the column data of the target column in the second representation, so as to generate a similarity score between the column data of the target column in the first representation and the column data of the target column in the second representation, that is, to generate a value in the first similarity information. The column data of the target column in the first representation refers to any one of the multiple columns of data included in the first representation, and the column data of the target column in the second representation refers to any one of the multiple columns of data included in the second representation. In this implementation, multiple implementations of calculating the similarity between the column data in the first representation and the column data in the second representation are provided, thereby improving the implementation flexibility of this solution.
[0012] In a possible implementation of the first aspect, the similarity calculation module is specifically used to perform a linear transformation on the original representation corresponding to at least two first characters to obtain a first representation and a second representation. In this implementation, since the first representation and the second representation are used to calculate the similarity of at least two first characters at the dimensional level, the original representation of the first character may not be able to adapt to our dimensional level similarity calculation method. A learnable linear transformation model is used to generate the first representation and the second representation. The linear transformation model can adjust the model parameters during the training phase so that the first representation and the second representation can correctly reflect the dimensional level similarity information, so as to improve the accuracy of the first similarity information, thereby improving the accuracy of the entire text processing network.
[0013] In a possible implementation of the first aspect, the similarity calculation module is specifically used to multiply the original representation of at least two first characters by the first linear transformation matrix to obtain the first representation, and multiply the original representation of at least two first characters by the second linear transformation matrix to obtain the second representation. Among them, the first linear transformation matrix can be specifically expressed as a d×d matrix, and the second linear transformation matrix can also be specifically expressed as a d×d matrix. The parameters in the first linear transformation matrix and the second linear transformation matrix are obtained by pre-training, and the parameters in the first linear transformation matrix and the second linear transformation matrix can be the same or different. In this implementation, the first representation and the second representation are generated by the first linear transformation matrix and the second linear transformation matrix, respectively. In the training stage, the parameters in the first linear transformation matrix and the second linear transformation matrix can be adjusted respectively, that is, the adjustment process of the parameters in the first linear transformation matrix and the second linear transformation matrix is more flexible, so that the generated first representation and the second representation can more correctly reflect the similarity information at the dimensional level to improve the accuracy of the first similarity information.
[0014] In a possible implementation of the first aspect, the similarity calculation module is specifically used to perform two convolution processes on the original representations corresponding to the at least two first characters respectively to obtain the first representation and the second representation. In this implementation, another generation scheme of the first representation and the second representation is provided, which improves the implementation flexibility of this scheme.
[0015] In a possible implementation of the first aspect, the first feature information includes a third representation, the third representation includes feature information of at least two first characters, and the similarity calculation module is further used to multiply at least two first characters by a third linear transformation matrix to obtain a third representation. The third representation has different uses from the first representation and the second representation, and the third representation is used to merge with the similarity of each first character at the dimension level to generate the second feature information. The third linear transformation matrix can also be specifically expressed as a d×d matrix, and the parameters in the third linear transformation matrix are obtained by pre-training, and can be the same as or different from the parameters in the first linear transformation matrix and the second linear transformation matrix. The generation module is specifically used to merge the third representation and the first similarity information to generate the second feature information. In this implementation, the second feature information simultaneously merges the word information of the first character and the similarity information of multiple first characters at the dimension level, further improving the accuracy of the text processing network; in addition, the third representation is generated when the first character is firstly extracted, so that when the second feature information is generated, the previously generated third representation can be directly used to merge with the first similarity information, which is conducive to improving the processing efficiency of the entire text processing network.
[0016] In a possible implementation of the first aspect, the number of first characters is N, N is an integer greater than or equal to 2, and the generation module is specifically used to: generate a third-order tensor representation based on the third representation and the first similarity information, compress the third-order tensor representation, and obtain the second feature information. Among them, the third-order tensor representation includes N matrices, each of the N matrices can be specifically expressed as a d×d matrix, each matrix corresponds to a first character, and a matrix combines the feature information of a first character and the similarity information of the first character at the dimension level. The second feature information can be specifically expressed as a two-dimensional matrix. In this implementation, in the fusion process of the third representation and the first similarity information, it is first expanded to a third-order tensor representation, and then compressed. Since the third-order tensor representation includes more elements, each feature information can be fully expressed to improve the expression ability of the second feature information.
[0017] In a possible implementation of the first aspect, the first similarity information and the third representation are both matrices. A generation module is specifically used to perform a tensor product operation on the column data in the first similarity information and the column data in the third representation to obtain a third-order tensor representation, and the tensor product operation can be specifically expressed as an outer product operation. Alternatively, a generation module is specifically used to perform an addition operation on the column data in the first similarity information and the column data in the third representation to obtain a third-order tensor representation. In this implementation, two specific implementation schemes for generating a third-order tensor representation are provided, which improves the implementation flexibility of this scheme.
[0018] In a possible implementation of the first aspect, the third-order tensor representation includes N matrices, each of which is a d×d two-dimensional matrix, that is, the third-order tensor is represented as an N×d×d third-order tensor. The generation module is specifically used to compress the third-order tensor representation along any one of the two d directions of the third-order tensor representation, thereby flattening one d direction of the third-order tensor representation to obtain the second feature information, and the second feature information is an N×d two-dimensional matrix. Among them, the compression processing method includes any one of the following: convolution, addition, averaging, maximum value or minimum value. In this implementation method, a variety of specific implementation schemes for generating the second feature information are provided, which improves the implementation flexibility of this scheme.
[0019] In a possible implementation of the first aspect, the generating module is specifically used to transpose the third representation, and multiply the transposed third representation by the first similarity information to obtain the second feature information. In this implementation, the transposed third representation is multiplied by the first similarity information to directly obtain the second feature information, and the implementation is simple, the calculation is convenient, and the time complexity is relatively low; and a scheme for generating the second feature information is provided, which further enhances the implementation flexibility of this scheme.
[0020] In a possible implementation of the first aspect, the text processing network further includes a feature processing network, the feature processing network being used to perform a classification operation based on the second feature information, and output indication information of a predicted category corresponding to at least two first characters, wherein the classification of the category is based on the semantics of the character, or the classification of the category is based on the part of speech of the character. In this implementation, the specific application scenario of text classification is implemented, which improves the ability of this solution to be combined with the application scenario.
[0021] In a possible implementation of the first aspect, at least two first characters include a character to be predicted, and the text processing network further includes a feature processing network, the feature processing network being used to output a prediction result corresponding to the character to be predicted based on the second feature information, and the prediction result indicates a predicted character corresponding to the character to be predicted. The prediction result can be specifically expressed as an index number corresponding to the predicted character one by one. In this implementation, it can be applied not only to the application scenario of text classification, but also to the application scenario of text prediction, which expands the application scenario of this solution.
[0022] In a possible implementation of the first aspect, the text processing network also includes a feature processing network, which is used to perform a translation operation on the first character based on the second feature information, and output indication information of the translated first character, the indication information of the translated first character is used to indicate the translated first character, and the translated first character and the first character are in a different language. Among them, the indication information of the translated first character can be specifically expressed as an index number corresponding one-to-one to the translated first character. In this implementation, it can be applied not only to the application scenarios of text classification and text prediction, but also to the application scenarios of text translation, further expanding the application scenarios of this solution.
[0023] In a second aspect, an embodiment of the present application provides a training method for a neural network, which can be used in the field of text processing in the field of artificial intelligence. The method may include: a training device obtains a first training text, and the first training text includes at least two second characters. The training device inputs the first training text into a first feature extraction network to extract features of the first training text through the first feature extraction network, and obtains first feature information corresponding to at least two second characters, and the first feature information includes feature information of the second characters in at least one dimension. The training device calculates the second similarity information of at least two second characters at the dimension level through the first feature extraction network according to the first feature information corresponding to at least two second characters; the training device generates second feature information corresponding to at least two second characters through the first feature extraction network according to the second similarity information. The training device outputs a generation processing result corresponding to at least two second characters through the first feature processing network based on the second feature information corresponding to at least two second characters, and the first feature processing network and the first feature extraction network belong to the first text processing network. The training device iteratively trains the first text processing network according to the correct processing result corresponding to at least two second characters, the generation processing result and the loss function until the preset conditions are met. The preset condition may be that a convergence condition of the loss function is satisfied, or that the number of iterations of the iterative training satisfies a preset number of times. The loss function may be specifically expressed as a 0-1 loss function, a cross entropy loss function, a logarithmic loss function, or other types of loss functions.
[0024] In this implementation, the trained first text processing network can process two or more characters at a time, that is, a more efficient text processing network is provided; in addition, the trained first text processing network can combine the similarity information of the characters at the dimensional level in the process of generating feature information of the characters, that is, the generated second feature information will incorporate more fine-grained information, which is beneficial to improve the accuracy of the entire text processing network.
[0025] In a possible implementation of the first aspect, at least two second characters include at least one character to be predicted. The training device outputs the generated processing results corresponding to the at least two second characters through the first feature processing network based on the second feature information corresponding to the at least two second characters, which may include: the training device outputs the prediction results corresponding to the character to be predicted through the first feature processing network based on the second feature information corresponding to the at least two second characters, and the prediction results indicate the predicted characters corresponding to the character to be predicted. The training device iteratively trains the first text processing network according to the correct processing results corresponding to the at least two second characters, the generated processing results and the loss function until the preset conditions are met, which may include: the training device iteratively trains the first text processing network according to the correct characters corresponding to the character to be predicted, the predicted characters and the loss function until the preset conditions are met, and outputs the second feature extraction network, which is the trained first feature extraction network. In this implementation, the first feature extraction network is placed in the text prediction scenario, and the first feature extraction network is iteratively trained. Since the text prediction scenario has high requirements on the ability of the feature extraction network, it is beneficial to improve the feature extraction ability of the trained first feature extraction network.
[0026] In a possible implementation of the first aspect, the method may further include: the training device obtains a second training text, the second training text includes at least two third characters. The training device inputs the second training text into a second feature extraction network to generate second feature information corresponding to at least two third characters through the second feature extraction network; the training device performs a classification operation based on the second feature information corresponding to at least two third characters through the second feature processing network, and outputs indication information of the predicted category corresponding to at least two third characters, wherein the second feature extraction network and the second feature processing network belong to the second text processing network. The training device iteratively trains the second text processing network according to the correct category corresponding to the second training text, the indication information of the predicted category, and the loss function until the preset conditions are met, and outputs the trained second text processing network. In this implementation, the feature extraction network in the text classification network is first trained, and then the text classification network as a whole is trained, so that the semantic information learned in the initial training process can be effectively transferred to the entire text classification network, which is conducive to improving the accuracy of the trained text classification network.
[0027] In a possible implementation of the first aspect, at least two second characters include at least one character to be predicted. The training device outputs the generated processing results corresponding to the at least two second characters through the first feature processing network based on the second feature information corresponding to the at least two second characters and the autoregressive algorithm, and the prediction result indicates the predicted character corresponding to the character to be predicted. Among them, the autoregressive algorithm refers to generating only a prediction result corresponding to one character to be predicted in each prediction operation. The training device iteratively trains the first text processing network according to the correct processing results corresponding to the at least two second characters, the generated processing results and the loss function until the preset conditions are met, and may include: the training device iteratively trains the first text processing network according to the correct characters corresponding to the character to be predicted, the predicted characters and the loss function until the preset conditions are met, and outputs the trained first text processing network. In this implementation, a training method is provided when the text processing network is used for text prediction, which expands the application scenario of this solution.
[0028] In a possible implementation of the first aspect, the training device outputs a generated processing result corresponding to at least two second characters based on the second feature information corresponding to at least two second characters through the first feature processing network, including: the training device performs a translation operation on the first training text through the first feature processing network according to the correct translation text corresponding to the first training text and the second feature information corresponding to the at least two second characters, and outputs the translated second characters, and the translated second characters are in a different language from the second characters. The training device iteratively trains the first text processing network according to the correct processing result corresponding to the at least two second characters, the generated processing result and the loss function until the preset conditions are met, including: the training device iteratively trains the first text processing network according to the correct translation text, the translated second characters and the loss function until the preset conditions are met, and outputs the trained first text processing network. In this implementation, a training method is provided when the text processing network is used for text translation, further expanding the application scenarios of this solution.
[0029] For the specific implementation steps of the second aspect of the embodiment of the present application and various possible implementation methods of the second aspect, reference may be made to the description of the various possible implementation methods in the first aspect, and they will not be repeated here one by one.
[0030] In a third aspect, an embodiment of the present application provides a neural network for processing sequence data, which can be used in the field of artificial intelligence to process sequence data. The neural network includes a feature extraction network, and the feature extraction network includes a similarity calculation module and a generation module. The similarity calculation module is used to receive at least two sequence data as input, and perform feature extraction on the at least two sequence data to obtain third feature information corresponding to the at least two sequence data, and the third feature information includes feature information of the at least two sequence data in at least one dimension. The similarity calculation module is also used to calculate the third similarity information of the at least two sequence data at the dimensional level based on the third feature information. The generation module is used to generate fourth feature information corresponding to the at least two sequence data based on the third similarity information.
[0031] In a possible implementation manner of the third aspect, the sequence data is used to indicate any one of the following information: character information, consumption information, location information, and gene information.
[0032] The third aspect of the embodiment of the present application can also execute the steps in each possible implementation method of the first aspect. For the specific implementation steps of the third aspect of the embodiment of the present application and the various possible implementation methods of the third aspect, as well as the beneficial effects brought about by each possible implementation method, you can refer to the description of the various possible implementation methods in the first aspect, and will not be repeated here one by one.
[0033] In a fourth aspect, an embodiment of the present application provides a text processing method that can be used in the field of text processing in the field of artificial intelligence. The method may include: inputting at least two first characters into a text processing network, the text processing network includes a feature extraction network, the feature extraction network includes a similarity calculation module and a generation module; extracting features of at least two first characters through the similarity calculation module to obtain first feature information corresponding to at least two first characters, the first feature information including feature information of the first characters in at least one dimension; calculating first similarity information of at least two first characters at a dimensional level according to the first feature information through the similarity calculation module; generating second feature information corresponding to at least two first characters according to the first similarity information through the generation module.
[0034] The fourth aspect of the embodiment of the present application can also execute the steps in each possible implementation method of the first aspect. For the specific implementation steps of the fourth aspect of the embodiment of the present application and the various possible implementation methods of the fourth aspect, as well as the beneficial effects brought about by each possible implementation method, you can refer to the description of the various possible implementation methods in the first aspect, and will not be repeated here one by one.
[0035] In a fifth aspect, an embodiment of the present application provides a training device for a neural network, which can be used in the field of text processing in the field of artificial intelligence. The device includes: an acquisition module, which is used to acquire a first training text, wherein the first training text includes at least two second characters; an input module, which is used to input the first training text into a first feature extraction network, so as to extract features of the first training text through the first feature extraction network, and obtain first feature information corresponding to at least two second characters, wherein the first feature information includes feature information of the second characters in at least one dimension; a processing module, which is used to calculate the second similarity information of at least two second characters at the dimension level through the first feature extraction network according to the first feature information corresponding to at least two second characters; the processing module is also used to generate second feature information corresponding to at least two second characters through the first feature extraction network according to the second similarity information; an output module, which is used to output the generation processing result corresponding to at least two second characters through the first feature processing network based on the second feature information corresponding to at least two second characters, wherein the first feature processing network and the first feature extraction network belong to the first text processing network; the processing module is also used to iteratively train the first text processing network according to the correct processing result corresponding to at least two second characters, the generation processing result and the loss function until the preset conditions are met.
[0036] The fifth aspect of the embodiment of the present application can also execute the steps in each possible implementation method of the second aspect. For the specific implementation steps of the fifth aspect of the embodiment of the present application and the various possible implementation methods of the fifth aspect, as well as the beneficial effects brought about by each possible implementation method, you can refer to the description of the various possible implementation methods in the second aspect, and will not be repeated here one by one.
[0037] In a sixth aspect, an embodiment of the present application provides an execution device, which may include a processor, wherein the processor is coupled to a memory, and the memory stores program instructions. When the program instructions stored in the memory are executed by the processor, the steps of executing the text processing network described in the first aspect are implemented, or the steps of executing the neural network for processing sequence data described in the third aspect are implemented.
[0038] In a seventh aspect, an embodiment of the present application provides an execution device, which may include a processor, the processor and a memory are coupled, the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the neural network training method described in the second aspect above is implemented.
[0039] In an eighth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, which, when executed on a computer, enables the computer to execute the steps performed by the text processing network described in the first aspect, or enables the computer to execute the neural network training method described in the second aspect, or enables the computer to execute the steps performed by the neural network for processing sequence data described in the third aspect.
[0040] In a ninth aspect, an embodiment of the present application provides a circuit system, comprising a processing circuit, wherein the processing circuit is configured to execute the steps performed by the text processing network described in the first aspect, or to execute the training method of the neural network described in the second aspect, or to execute the steps performed by the neural network for processing sequence data described in the third aspect.
[0041] In the tenth aspect, an embodiment of the present application provides a computer program, which, when running on a computer, enables the computer to execute the steps performed by the text processing network described in the first aspect above, or execute the neural network training method described in the second aspect above, or execute the steps performed by the neural network for processing sequence data described in the third aspect above.
[0042] In the eleventh aspect, an embodiment of the present application provides a chip system, which includes a processor for implementing the functions involved in the above-mentioned various aspects, for example, sending or processing the data and / or information involved in the above-mentioned method. In one possible design, the chip system also includes a memory, which is used to store program instructions and data necessary for a server or communication device. The chip system can be composed of a chip, or it can include a chip and other discrete devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 A schematic diagram of the structure of the artificial intelligence main framework provided in the embodiment of the present application;
[0044] Figure 2 A system architecture diagram of a sequence data processing system provided in an embodiment of the present application;
[0045] Figure 3 A flowchart of a text processing method provided in an embodiment of the present application;
[0046] Figure 4 A schematic diagram of a first representation in the text processing method provided in an embodiment of the present application;
[0047] Figure 5 A schematic diagram of first similarity information in the text processing method provided in an embodiment of the present application;
[0048] Figure 6 A schematic diagram of a flow chart for generating a third-order tensor in a text processing method provided in an embodiment of the present application;
[0049] Figure 7 A schematic diagram of generating second feature information in the text processing method provided in an embodiment of the present application;
[0050] Figure 8 A schematic diagram of a structure of a text processing network provided in an embodiment of the present application;
[0051] Fig. 9 Another flowchart of the text processing method provided in the embodiment of the present application;
[0052] Fig.10 A schematic diagram of another flow chart of the text processing method provided in the embodiment of the present application;
[0053] Fig.11 A schematic diagram of a structure of a text processing network provided in an embodiment of the present application;
[0054] Fig.12 A schematic diagram of a flow chart of a neural network training method provided in an embodiment of the present application;
[0055] Fig.13 Another schematic diagram of a flow chart of a neural network training method provided in an embodiment of the present application;
[0056] Fig.14 A schematic diagram of another flow chart of a neural network training method provided in an embodiment of the present application;
[0057] Fig.15 A schematic diagram of a flow chart of a method for processing sequence data provided in an embodiment of the present application;
[0058] Fig.16 A schematic diagram of another flow chart of a neural network training method provided in an embodiment of the present application;
[0059] Fig.17 Another structural diagram of a text processing network provided in an embodiment of the present application;
[0060] Fig.18 A schematic diagram of a structure of a neural network training device according to an embodiment of the present application;
[0061] Fig.19 A schematic diagram of the structure of an execution device provided in an embodiment of the present application;
[0062] Fig. 20 A schematic diagram of the structure of a training device provided in an embodiment of the present application;
[0063] Fig.21A schematic diagram of the structure of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0064] The embodiments of the present application provide a text processing network, a neural network training method and related equipment. The text processing network can process two or more characters at a time, providing a more efficient text processing network; the generated second feature information incorporates finer-grained information, thereby improving the accuracy of the entire text processing network.
[0065] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0066] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged under appropriate circumstances. This is merely a way of distinguishing objects with the same properties when describing the embodiments of the present application. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, so that a process, method, system, product, or device that includes a series of units is not necessarily limited to those units, but may include other units that are not explicitly listed or inherent to these processes, methods, products, or devices.
[0067] First, the overall workflow of the artificial intelligence system is described. Figure 1 , Figure 1 The figure shows a structural diagram of the main framework of artificial intelligence. The following is an explanation of the above artificial intelligence theme framework from the two dimensions of "intelligent information chain" (horizontal axis) and "IT value chain" (vertical axis). Among them, the "intelligent information chain" reflects a series of processes from data acquisition to processing. For example, it can be a general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, intelligent execution and output. In this process, the data has undergone a condensation process of "data-information-knowledge-wisdom". The "IT value chain" reflects the value that artificial intelligence brings to the information technology industry from the underlying infrastructure of human intelligence, information (providing and processing technology implementation) to the industrial ecology process of the system.
[0068] (1) Infrastructure
[0069] The infrastructure provides computing power support for the artificial intelligence system, enables communication with the outside world, and is supported by the basic platform. It communicates with the outside world through sensors; computing power is provided by smart chips, including but not limited to central processing units (CPU), embedded neural network processing units (NPU), graphics processing units (GPU), application specific integrated circuits (ASIC) and field programmable gate arrays (FPGA) and other hardware acceleration chips; the basic platform includes distributed computing frameworks and networks and other related platform guarantees and support, which may include cloud storage and computing, interconnected networks, etc. For example, sensors communicate with the outside world to obtain data, and these data are provided to the smart chips in the distributed computing system provided by the basic platform for calculation.
[0070] (2) Data
[0071] The data on the upper layer of the infrastructure is used to represent the data sources in the field of artificial intelligence. The data involves graphics, images, voice, text, and IoT data of traditional devices, including business data of existing systems and perception data such as force, displacement, liquid level, temperature, and humidity.
[0072] (3) Data processing
[0073] Data processing usually includes data training, machine learning, deep learning, search, reasoning, decision-making and other methods.
[0074] Among them, machine learning and deep learning can symbolize and formalize data for intelligent information modeling, extraction, preprocessing, and training.
[0075] Reasoning refers to the process of simulating human intelligent reasoning in computers or intelligent systems, using formalized information to perform machine thinking and solve problems based on reasoning control strategies. Typical functions are search and matching.
[0076] Decision-making refers to the process of making decisions after intelligent information is reasoned, usually providing functions such as classification, sorting, and prediction.
[0077] (4) General ability
[0078] After the data has undergone the data processing mentioned above, some general capabilities can be further formed based on the results of the data processing, such as an algorithm or a general system, for example, translation, text analysis, computer vision processing, speech recognition, etc.
[0079] (5) Smart products and industry applications
[0080] Smart products and industry applications refer to the products and applications of artificial intelligence systems in various fields. They are the encapsulation of the overall artificial intelligence solution, which productizes intelligent information decision-making and realizes practical application. Its application areas mainly include: smart terminals, smart manufacturing, smart transportation, smart homes, smart medical care, smart security, autonomous driving, safe cities, etc.
[0081] The embodiments of the present application can be applied to various fields of artificial intelligence, and specifically to various scenarios that require processing sequence data, where sequence data refers to an ordered set consisting of several elements. As an example, sequence data can be used to indicate character information; sequence data can also be used to reflect the user's consumption information, and the aforementioned consumption information includes but is not limited to virtual products and physical products purchased by the user; sequence data can also be used to indicate the user's location information, and sequence data can also be used to indicate genetic information, etc. It should be understood that the examples given here are only for the convenience of understanding the application scenarios of the embodiments of the present application, and the application scenarios of the embodiments of the present application are not exhaustive. As follows, in the embodiments of the present application, the sequence data processing method provided in the embodiments of the present application is first described in detail using the scenario in which sequence data is used to indicate character information in the text to be processed, and then other more application scenarios are introduced.
[0082] In order to facilitate the understanding of this solution, the present application embodiment first combines Figure 2 For an introduction to the sequence data processing system provided in the embodiments of the present application, please refer to Figure 2 , Figure 2 A system architecture diagram of a sequence data processing system provided in an embodiment of the present application. Figure 2 In the embodiment, the sequence data processing system 200 includes an execution device 210, a training device 220, a database 230 and a data storage system 240, and the execution device 210 includes a computing module 211.
[0083] In the training phase, a training data set is stored in the database 230, and the training data set may include multiple training samples and correct processing results corresponding to the training samples, and the training samples include at least two training data. The training device 220 generates a target model / rule 201 for processing sequence data, and iteratively trains the target model / rule 201 using the training data set in the database to obtain a mature target model / rule 201.
[0084] In the inference stage, the execution device 210 can call the data, code, etc. in the data storage system 240, or store the data, instructions, etc. in the data storage system 240. The data storage system 240 can be configured in the execution device 210, or the data storage system 240 can be an external memory relative to the execution device 210. The calculation module 211 can process at least two sequence data input by the execution device 210 through the mature target model / rule 201, obtain the similarity information of at least two sequence data at the dimension level, and generate the processing result based on the aforementioned similarity information at the dimension level. The specific expression form of the generated processing result is related to the function of the target model / rule 201.
[0085] In some embodiments of the present application, for example Figure 2 In the embodiment, the "user" can directly interact with the execution device 210, that is, the execution device 210 and the client device are integrated into the same device. Figure 2 It is only a schematic diagram of the architecture of two image processing systems provided by an embodiment of the present invention, and the positional relationship between the devices, components, modules, etc. shown in the figure does not constitute any limitation. In other embodiments of the present application, the execution device 210 and the client device can be independent devices, and the execution device 210 is configured with an input / output interface to interact with the client device for data. The "user" can input the collected image to the input / output interface through the client device, and the execution device 210 returns the processing result to the client device through the input / output interface.
[0086] Depend on Figure 2 As can be seen from the description in, the embodiment of the present application includes a reasoning stage and a training stage, and the processes of the reasoning stage and the training stage are different. The reasoning stage and the training stage are described below respectively.
[0087] 1. Reasoning Stage
[0088] In the embodiment of the present application, in the scenario where sequence data is used to indicate character information in the text to be processed, the inference stage describes the process of how the execution device 210 uses a mature text processing network to process the text to be processed. Specifically, in the large application scenario of text processing, including understanding text information, performing text prediction, text translation or other specific application scenarios, the following describes the three application scenarios of the above examples respectively.
[0089] (1) Applied to the context of understanding text
[0090] In the embodiment of the present application, in the scenario of understanding text, the tasks of the text processing network include but are not limited to classifying the entire text, annotating the words in the text (also known as sequence annotation), or other natural language understanding tasks. Figure 3, Figure 3 A flowchart of a text processing method provided in an embodiment of the present application is provided. The text processing method provided in an embodiment of the present application may include:
[0091] 301. An execution device inputs at least two first characters into a text processing network.
[0092] In some embodiments of the present application, an execution device obtains a text to be processed, the text to be processed includes at least two first characters, and the execution device inputs the entire text to be processed into a text processing network. Specifically, a character table may be stored in the execution device, and the character table includes the original representations of multiple characters. After the execution device obtains at least two first characters included in the text to be processed, it can obtain the original representation of each first character from the character table. The original representation of a first character is a sequence data, which is used to indicate that the sequence data of the first character will carry information of the first character in at least one dimension. As an example, for example, the aforementioned sequence data can be specifically expressed as a vector including d elements, and the d elements in the vector correspond to the d dimensions of the first character respectively; the original representation of each first character is superimposed together, and a matrix corresponding to all the first characters in the text to be processed can be obtained. For example, the text to be processed includes N first characters, and the original representation corresponding to at least one first character included in the text to be processed can be an N×d matrix. Wherein, d is an integer greater than or equal to 1, as an example, the value of d is 1, 2, 3, 4, 5, 6 or other values, and N is an integer greater than or equal to 2, as an example, the value of N is 2, 3, 5, 10, 20, 50 or other values. Optionally, the execution device adds a [CLS] character at the beginning of at least two first characters included in the text to be processed, and the [CLS] character can be understood as a header character, and the feature information corresponding to the [CLS] character is used to reflect the features of the entire text to be processed.
[0093] The text processing network includes a feature extraction network and a feature processing network. The feature extraction network includes a similarity calculation module and a generation module; the feature processing network in this application scenario can be specifically expressed as a classifier, and the classifier outputs a label. Furthermore, the classifier can be specifically expressed as a perceptron, or the classifier includes a linear transformation matrix and a normalized exponential (softmax) function, etc. The classifier can also be specifically expressed in other forms, which are not limited here.
[0094] 302. The execution device extracts features from at least two first characters through a similarity calculation module to obtain first feature information corresponding to the at least two first characters.
[0095] In an embodiment of the present application, after the execution device inputs the original representation corresponding to the text to be processed into the text processing network, the similarity calculation module of the text processing network can perform feature extraction on at least two first characters in the text to be processed to obtain first feature information corresponding to the at least two first characters.
[0096] Among them, the first feature information includes feature information of the first character in at least one dimension. The first feature information may include a first representation and a second representation, and both the first representation and the second representation may include feature information of all first characters in each dimension, and the feature information carried in the first representation and the second representation is used to calculate the similarity of each first character at the dimension level. Furthermore, the first representation and the second representation may be specifically expressed as a matrix, each row in the matrix corresponds to a first character, each row in the matrix carries feature information of a first character in each dimension, and each column in the matrix carries feature information of all first characters in one dimension.
[0097] Optionally, the first feature information may also include a third representation. The meaning and specific expression of the third representation are similar to those of the first representation and the second representation. The difference is that the third representation has a different purpose from the first representation and the second representation. The third representation is used to merge with the similarity of each first character at the dimensional level to generate the second feature information.
[0098] Specifically, in one implementation, the execution device performs a linear transformation on the original representation corresponding to at least two first characters through a similarity calculation module to obtain a first representation and a second representation. Optionally, the execution device performs a linear transformation on the original representation corresponding to at least two first characters through a similarity calculation module to obtain a first representation, a second representation, and a third representation.
[0099] More specifically, the similarity calculation module may include a first linear transformation matrix and a second linear transformation matrix, which are W A and W B . Execute the device through W A A linear transformation is performed on the matrix T (i.e., the original representation corresponding to at least two first characters) to obtain the matrix A (i.e., the first representation); further, W A Specifically, it can be expressed as a d×d matrix, and the matrix A can be expressed as an N×d matrix, that is, the first representation includes feature information of each first character in the N first characters in d dimensions. The execution device passes W B Perform linear transformation processing on the original representation corresponding to at least two first characters to obtain a matrix B (i.e., a second representation); further, W BSpecifically, it can be expressed as a d×d matrix, and matrix B can be expressed as an N×d matrix, that is, the second representation includes the feature information of each first character in the N first characters in d dimensions. It should be noted that, in actual situations, the parameters in the first linear transformation matrix and the second linear transformation matrix can be the same or different, and there is a possibility that matrix A and matrix T are the same, that is, there is a possibility that the converted first representation is the same as the original representation, and there is also a possibility that matrix B and matrix T are the same, that is, there is a possibility that the converted second representation is the same as the original representation, which depends on the training results of the training phase. In this implementation, the first representation and the second representation are generated by the first linear transformation matrix and the second linear transformation matrix respectively. In the training phase, the parameters in the first linear transformation matrix and the second linear transformation matrix can be adjusted respectively, that is, the adjustment process of the parameters in the first linear transformation matrix and the second linear transformation matrix is more flexible, so that the generated first representation and the second representation can more correctly reflect the similarity information at the dimensional level to improve the accuracy of the first similarity information.
[0100] For further understanding of the first and second representations, see Figure 4 , Figure 4 A schematic diagram of a first representation of a text processing method provided in an embodiment of the present application, Figure 4 In the example, the value of d is 4 and the value of N is 5. A1 refers to the first representation (i.e. Figure 4 A1 represents the feature information of a first character, which includes 4 elements, each element represents the feature information of the first character in one dimension, then A1 represents the feature information of a first character in 4 dimensions, A2 refers to a column data in the first representation, A2 includes the feature information of 5 first characters in one dimension, and the matrix A includes the feature information of each of the 5 first characters in 4 dimensions. It should be understood that Figure 4 The examples are only provided to facilitate understanding of the present invention and are not intended to limit the present invention.
[0101] Optionally, the similarity calculation module may also include a third linear transformation matrix (ie, W C ), the execution device passes W C Perform linear transformation on the original representation corresponding to at least two first characters to obtain a matrix C (i.e., a third representation); further, W CSpecifically, it can also be expressed as a d×d matrix, and the matrix C can also be expressed as an N×d matrix, that is, the third representation includes feature information of each first character in the N first characters in d dimensions. The parameters of the third linear transformation matrix and the first linear transformation matrix and the second linear transformation matrix can be the same or different, and there is a possibility that the matrix C is the same as the matrix T, that is, there is a possibility that the converted third representation is the same as the original representation, which also depends on the training results of the training stage.
[0102] In the embodiment of the present application, since the first representation and the second representation are used to calculate the similarity of at least two first characters at the dimensional level, the original representation of the first characters may not be able to adapt to our dimensional level similarity calculation method. A learnable linear transformation model is used to generate the first representation and the second representation. The linear transformation model can adjust the model parameters during the training phase so that the first representation and the second representation can correctly reflect the similarity information at the dimensional level, so as to improve the accuracy of the first similarity information, thereby improving the accuracy of the entire text processing network.
[0103] In another implementation, the similarity calculation module may include a convolution layer, and the execution device performs two convolution processes on the original representations corresponding to the at least two first characters through the convolution layer of the similarity calculation module to obtain the first representation and the second representation. Optionally, the execution device performs three convolution processes on the original representations corresponding to the at least two first characters through the convolution layer of the similarity calculation module to obtain the first representation, the second representation, and the third representation.
[0104] In the embodiment of the present application, another generation scheme of the first representation and the second representation is provided, which improves the implementation flexibility of the present scheme.
[0105] 303. The execution device calculates first similarity information of at least two first characters at a dimension level according to the first feature information through a similarity calculation module.
[0106] In an embodiment of the present application, the first characteristic information includes a first representation and a second representation. The first representation and the second representation can be specifically expressed as matrices. A column of data in the first representation includes characteristic information of at least two first characters in one dimension, and a column of data in the second representation includes characteristic information of at least two first characters in one dimension.
[0107] Step 303 may specifically include: the execution device calculates the similarity between the column data in the first representation and the column data in the second representation through the similarity calculation module to obtain the first similarity information. The first similarity information includes the similarity between the first representation and the second representation in each dimension, and the first similarity information can be specifically expressed as a d×d matrix S, that is, the first similarity information may include d×d elements. Furthermore, the element located in the i-th row and j-th column of the d×d elements represents the similarity score between the i-th dimension of the first representation and the j-th dimension of the second representation. wherein i is an integer greater than or equal to 1 and less than or equal to d, and j is an integer greater than or equal to 1 and less than or equal to d.
[0108] For a more intuitive understanding of this solution, please refer to Figure 5 , Figure 5 A schematic diagram of the first similarity information in the text processing method provided in an embodiment of the present application. Figure 5 In the example, the value of d is 4, where the matrix S represents the entire first similarity information, B1 represents the similarity score between the second column data of the first representation (that is, the second dimensional feature information of all first characters in the first representation) and the third column data of the second representation (that is, the third dimensional feature information of all first characters in the second representation), and it should be understood that Figure 5 The examples are only provided to facilitate understanding of the present invention and are not intended to limit the present invention.
[0109] In the embodiment of the present application, the first representation and the second representation are determined as matrices, and the similarity information of the first representation and the second representation at the dimension level is obtained by calculating the similarity between the column data in the first representation and the column data in the second representation, which is simple to operate.
[0110] More specifically, in one case, the execution device performs transposition processing on the first representation through the similarity calculation module, and calculates the similarity between the row data in the transposed first representation and the column data in the second representation to obtain the first similarity information. In this implementation, a specific implementation method for generating the first similarity information is provided, which improves the degree of integration of this solution with specific application scenarios.
[0111] Furthermore, the execution device can perform a dot product of the row data of the target row in the transposed first representation and the column data of the target column in the second representation through a similarity calculation module to generate a similarity score between the row data of the target row in the transposed first representation and the column data of the target column in the second representation, that is, generate a value in the first similarity information in matrix form. The row data of the target row in the transposed first representation refers to any row of data among the multiple rows of data included in the transposed first representation, and the column data of the target column in the second representation refers to any column of data among the multiple columns of data included in the second representation. The execution device repeatedly performs the aforementioned operations to generate a similarity score between the row data of each row in the transposed first representation and the column data of each column in the second representation, thereby obtaining each value in the first similarity information in matrix form. That is, the first similarity information can be obtained by formula A. T B obtains that the aforementioned A refers to matrix A (that is, the first representation), and the aforementioned B refers to matrix B (that is, the second representation).
[0112] The execution device may also calculate the Euclidean distance between the row data of the target row in the first representation after transposition and the column data of the target column in the second representation through the similarity calculation module; or calculate the Manhattan distance between the row data of the target row in the first representation after transposition and the column data of the target column in the second representation; or calculate the Mahalanobis distance between the row data of the target row in the first representation after transposition and the column data of the target column in the second representation; or calculate the cosine similarity between the row data of the target row in the first representation after transposition and the column data of the target column in the second representation, etc., to generate a similarity score between the row data of the target row in the first representation after transposition and the column data of the target column in the second representation. It should be noted that the execution device may also perform other operations through the similarity calculation module to generate a similarity score between the row data of the target row in the first representation after transposition and the column data of the target column in the second representation, which is not limited here. The execution device repeatedly performs the above operations to generate a similarity score between the row data of each row in the first representation after transposition and the column data of each column in the second representation, thereby obtaining the first similarity information.
[0113] In another implementation manner, the execution device directly calculates the similarity between the column data of the first representation and the column data of the second representation through a similarity calculation module to obtain first similarity information.
[0114] Further, the execution device can perform a dot product of the column data of the target column in the first representation with the column data of the target column in the second representation through a similarity calculation module; or calculate the Euclidean distance between the column data of the target column in the first representation and the column data of the target column in the second representation; or calculate the Manhattan distance between the column data of the target column in the first representation and the column data of the target column in the second representation; or calculate the Mahalanobis distance between the column data of the target column in the first representation and the column data of the target column in the second representation; or calculate the cosine similarity between the column data of the target column in the first representation and the column data of the target column in the second representation, etc., to generate a similarity score between the column data of the target column in the first representation and the column data of the target column in the second representation, that is, to generate a value in the first similarity information in the form of a matrix. Wherein, the column data of the target column in the first representation refers to any one of the multiple columns of data included in the first representation, and the column data of the target column in the second representation refers to any one of the multiple columns of data included in the second representation. It should be noted that the execution device can also perform other operations through the similarity calculation module to generate a similarity score between the column data of the target column in the first representation and the column data of the target column in the second representation, which is not limited here. The execution device repeatedly executes the above operations to generate a similarity score between the column data of each column in the transposed first representation and the column data of each column in the second representation, thereby obtaining each value in the first similarity information in matrix form.
[0115] In the embodiments of the present application, multiple implementation methods for calculating the similarity between the column data in the first representation and the column data in the second representation are provided, thereby improving the implementation flexibility of the present solution.
[0116] It can be seen from the description in step 303 that in the process of generating the first similarity information, a total of d 2 operations, each operation is an operation between two vectors of length N, so the time complexity of calculating the first similarity information is O(Nd 2 ).
[0117] 304. The execution device generates, through a generation module, second feature information corresponding to at least two first characters according to the first similarity information.
[0118] In an embodiment of the present application, the feature extraction network of the text processing network includes a generation module in addition to a similarity calculation module. The similarity calculation module is used to calculate the first similarity information of at least two first characters at the dimension level, and the generation module is used to generate second feature information corresponding to at least two first characters based on the first similarity information. After generating the first similarity information, the execution device can generate second feature information corresponding to at least two first characters based on the first similarity information through the generation module of the text processing network. The difference between the second feature information and the first feature information is that the first similarity information is integrated into the second feature information; the second feature information can be specifically expressed as a two-dimensional matrix, and further, the aforementioned two-dimensional matrix can be an N×d matrix, that is, the two-dimensional matrix includes N rows, each row includes d elements, and each row of data in the aforementioned two-dimensional matrix includes feature information of a first character in d dimensions.
[0119] Specifically, in one case, if the first feature information includes the third representation, the execution device may fuse the third representation and the first similarity information through the generation module to generate the second feature information.
[0120] In an embodiment of the present application, the second feature information simultaneously integrates the word information of the first character and the similarity information of multiple first characters at the dimensional level, further improving the accuracy of the text processing network; in addition, the third representation is generated when the feature of the first character is initially extracted, so that when the second feature information is generated, the previously generated third representation can be directly used for fusion processing with the first similarity information, which is beneficial to improving the processing efficiency of the entire text processing network.
[0121] More specifically, the number of the first characters is N. In one implementation, the execution device generates a third-order tensor representation according to the third representation and the first similarity information through a generation module. The third-order tensor representation includes N matrices, each matrix corresponds to a first character, and a matrix integrates feature information of a first character and similarity information of a first character at the dimension level. Each of the N matrices can be specifically expressed as a d×d matrix. Since the third-order tensor representation includes N matrices, and the second feature information is a two-dimensional matrix, after the execution device generates the third-order tensor representation through the generation module, it is also necessary to compress the third-order tensor representation through the generation module to obtain the second feature information. In an embodiment of the present application, in the fusion process of the third representation and the first similarity information, it is first expanded to a third-order tensor representation and then compressed. Since the third-order tensor representation includes more elements, each feature information can be fully expressed to improve the expression ability of the second feature information.
[0122] Further, for the generation process of the third-order tensor representation. In one implementation, the execution device performs a tensor product operation on the column data in the first similarity information and the column data in the third representation through a generation module to generate a third-order tensor representation. Wherein, the tensor product operation includes but is not limited to the outer product or other types of tensor product operations. Further, since the first similarity information can be a d×d matrix and the third representation can be an N×d matrix, that is, the first similarity information and the third representation are both d columns, the execution device performs a tensor product operation on the kth column data in the first similarity information and the kth column data in the third representation through a generation module to generate an N×d matrix, where k is an integer greater than or equal to 1 and less than or equal to d. The execution device repeats the above operation d times to generate a third-order tensor representation of N×d×d. It can be seen from the above description that the generation process of the third-order tensor representation includes d outer product operations, each of which is an outer product of a vector of length d and a vector of length N, so the time complexity of this step is O(Nd 2 ).
[0123] For further understanding of this solution, please refer to Figure 6 , Figure 6 A flowchart of generating a third-order tensor in the text processing method provided in an embodiment of the present application. Figure 6 The first similarity information (i.e. Figure 6 The matrix S in ( ) is a 4×4 matrix, that is, the value of d is 4, and the third representation (that is, Figure 6 Taking the matrix C in as a 5×4 matrix, that is, the value of N is 5 as an example, the execution device performs an outer product operation on the first column of data in the matrix S and the first column of data in the matrix C through the generation module to obtain a 5×4 matrix. The execution device performs an outer product operation on the second column of data in the matrix S and the second column of data in the matrix C through the generation module to obtain another 5×4 matrix. The execution device repeats the above operations to obtain four 5×4 matrices. The four 5×4 matrices are stacked to obtain the third-order tensor representation. It should be understood that Figure 6 The examples in the example are only for the convenience of understanding the generation process of the third-order tensor representation and are not used to limit this solution.
[0124] In another implementation, the execution device performs an addition operation on the column data in the first similarity information and the column data in the third representation through a generation module to obtain a third-order tensor representation. Furthermore, since the first similarity information can be a d×d matrix and the third representation can be an N×d matrix, that is, the first similarity information and the third representation are both d columns, the execution device performs an addition operation on the k-th column data in the first similarity information and the k-th column data in the third representation through a generation module to generate an N×d matrix. That is, each element of the d elements included in the k-th column of the first similarity information is added to each element of the d elements included in the k-th column of the third representation. The execution device repeats the above operation d times to generate a N×d×d third-order tensor representation. To further understand this solution, combined with Figure 6 To illustrate, the execution device adds each element in the first column of data in the matrix S and each element in the first column of data in the matrix C through the generation module to obtain a 5×4 matrix. The execution device repeats the above operation 4 times through the generation module to obtain 4 5×4 matrices. The 4 5×4 matrices are stacked to obtain the third-order tensor representation. It should be understood that the examples here are only for the convenience of understanding of this solution and are not used to limit this solution.
[0125] In the embodiments of the present application, two specific implementation schemes for generating a third-order tensor representation are provided, which improves the implementation flexibility of the scheme.
[0126] A process for compressing a third-order tensor representation. After the execution device obtains the third-order tensor representation through the generation module, since the third-order tensor representation is an N×d×d third-order tensor, the execution device can compress the third-order tensor representation along any one of the two d directions of the third-order tensor representation through the generation module to obtain second feature information, and the second feature information is an N×d two-dimensional matrix. The compression processing method includes any one of the following: convolution, addition, averaging, maximum value, minimum value or other compression processing methods.
[0127] Furthermore, the third-order tensor is represented as a N×d×d third-order tensor, and the third-order tensor representation can also be regarded as N d×d matrices. When convolution is selected as the compression processing method, the generation module may include d convolution kernels with a length of d and a width of 1. The execution device convolves a column of one of the N matrices represented by the third-order tensor through one of the d convolution kernels to obtain a value. Then, a column of a matrix is convolved through d convolution kernels respectively, so that d values can be obtained, that is, a vector representation corresponding to a first character is obtained, and the vector representation includes d elements. The execution device performs the above operation on each of the N matrices, so as to obtain N vectors including d elements, that is, an N×d two-dimensional matrix, that is, the second feature information. The time complexity of this step is O(Nd 2 ).
[0128] Since the third-order tensor representation can be an N×d×d third-order tensor, the third-order tensor representation can be seen as d N×d two-dimensional matrices. When the compression processing method selects addition, averaging, maximum value or minimum value, the execution device performs addition, averaging, maximum value or minimum value operations along any one of the two d directions represented by the third-order tensor, thereby flattening the d direction of the third-order tensor representation to obtain an N×d two-dimensional matrix, that is, obtaining the second feature information.
[0129] In the embodiments of the present application, a variety of specific implementation schemes for generating the second characteristic information are provided, which improves the implementation flexibility of the scheme.
[0130] In another implementation, the execution device transposes the third representation through the generation module of the text processing network, and multiplies the transposed third representation with the first similarity information to obtain the second feature information. For the specific introduction of the third representation, the first similarity information and the second feature information, please refer to the above description, which will not be repeated here. In the embodiment of the present application, the transposed third representation is multiplied with the first similarity information to directly obtain the second feature information. The implementation method is simple, the calculation is convenient, and the time complexity is relatively low; and a scheme for generating the second feature information is provided, which further enhances the implementation flexibility of the scheme.
[0131] In another case, if the first feature information does not include the third representation, the execution device can generate the third representation through the generation module according to the original representation corresponding to the at least two first characters. The specific generation method of the third representation can refer to the description in step 302, which is not repeated here. Then, the execution device can fuse the third representation and the first similarity information through the generation module to generate the second feature information. The specific implementation method can refer to the above description, which is not repeated here.
[0132] For further understanding of this solution, please refer to Figure 7 , Figure 7 A schematic diagram of generating second feature information in the text processing method provided in the embodiment of the present application. Figure 7 As shown in the figure, the text to be processed is "XX mobile phone is very good", and the function of the entire text processing network is to generate a classification label corresponding to the entire text to be processed. C1 refers to the original representation corresponding to the entire text to be processed, and C2 refers to the second feature information. Through the feature extraction network in the text processing network, using the linear transformation matrix W A Perform linear transformation on C1 to obtain the first representation (i.e. Figure 7 The matrix A in the text processing network is used to extract the feature of the text processing network and use the linear transformation matrix W B Perform linear transformation on C1 to obtain the second representation (i.e. Figure 7 Through the feature extraction network in the text processing network, the linear transformation matrix W is used C Perform linear transformation on C1 to obtain the third representation (i.e. Figure 7 ), by using a feature extraction network, first similarity information of at least two first characters at the dimension level is calculated according to the first representation and the second representation, and the third representation and the first similarity information are fused to generate second feature information (i.e. Figure 7 C2) in, it should be understood that Figure 7 The examples are only provided to facilitate understanding of the present invention and are not intended to limit the present invention.
[0133] Optionally, after generating the second feature information, the execution device can also obtain the original representation corresponding to the text to be processed (i.e., at least two first characters) through the generation module of the text processing network, and add the original representation corresponding to the text to be processed to the second feature information through the generation module of the text processing network, and then perform layer normalization to obtain the fourth feature information.
[0134] 305. The execution device performs a classification operation through a feature processing network, and outputs indication information of a predicted category corresponding to the at least two first characters.
[0135] In some embodiments of the present application, in this application scenario, the feature processing network can perform a classification operation based on the second feature information, and output indication information of the predicted category corresponding to at least two first characters. Wherein, the classification basis of the category is the semantics of the character, or the classification basis of the category is the part of speech of the character. Optionally, the execution device can perform a classification operation based on the fourth feature information through the feature processing network, and output indication information of the predicted category corresponding to at least two first characters. If the task of the entire text processing network is to classify the entire text to be processed, as an example, for example, the text to be processed is "The weather is very good today", then the output indication information indicates that the classification label of the entire text to be processed is weather. If the task of the entire text processing network is to perform sequence annotation on the text to be processed, as an example, for example, the text to be processed is "The weather is very good today", then the output indication information indicates that the classification label corresponding to "today" can be a noun, the classification label corresponding to "weather" can be a noun, the classification label corresponding to "very" can be an adjective, and the classification label corresponding to "good" can be an adjective. It should be understood that the examples here are only for convenience of understanding and are not used to limit this solution.
[0136] It should be noted that the number of executions between steps 302 to 304 and step 305 is not limited in the embodiment of the present application. The number of executions between steps 302 to 304 and step 305 can be multiple to one, that is, after executing step 304, the execution device can re-enter step 302, replace the original representation corresponding to the text to be processed with the second feature information corresponding to the text to be processed, or replace the original representation corresponding to the text to be processed with the fourth feature information corresponding to the text to be processed, and re-execute steps 302 to 304 to generate new second feature information. After repeating steps 302 to 304 at least twice, enter step 305, and the execution device performs a classification operation according to the updated second feature information through the feature processing network, or the execution device performs a classification operation according to the updated fourth feature information through the feature processing network. The number of executions between steps 302 to 304 and step 305 can also be one to one, that is, after generating the second feature information or generating the fourth feature information through the generation module of the text processing network, directly enter step 305.
[0137] For further understanding of this solution, please refer to Figure 8 , Figure 8 A structural diagram of a text processing network provided in an embodiment of the present application. Figure 8In the example, the text to be processed is "The weather is very good today.", and the function of the text processing network is to output the label of the entire text to be processed. As shown in the figure, the execution device adds the [CLS] character at the beginning of at least two first characters included in the text to be processed, and inputs the text to be processed with the [CLS] character added into the text processing network. A text processing network may include multiple feature extraction networks. The steps executed by each feature extraction network can refer to the description in steps 302 to 304. D1 refers to the second feature information generated by the feature extraction network, and D2 refers to the new second feature information generated by the feature extraction network. Among them, h1 to h9 can be represented as a matrix as a whole. The aforementioned matrix has a total of 9 rows, that is, the entire matrix can include 9 vectors, each vector corresponding to h1 to h9 one by one; each vector in h2 to h9 reflects the feature information of the corresponding character, and h1 reflects the information of the entire text to be processed. The execution device inputs h1 into the feature processing network through the feature extraction network, so that the feature processing network performs a classification operation according to h1, and obtains the classification label corresponding to the entire text to be processed as "weather". It should be understood that Figure 8 The examples are only provided to facilitate understanding of the present invention and are not intended to limit the present invention.
[0138] In the embodiment of the present application, it is implemented in the specific application scenario of text classification, which improves the ability of the present solution to be combined with the application scenario.
[0139] In an embodiment of the present application, a feature extraction module is used to receive at least two first characters, perform feature extraction on the at least two first characters to obtain first feature information, the first feature information including feature information of the first characters in at least one dimension, calculate first similarity information of the at least two first characters at the dimension level based on the first feature information, and then generate second feature information corresponding to the at least two characters based on the first similarity information, that is, it is capable of processing two or more characters at one time, providing a more efficient text processing network; in addition, in the process of generating the feature information of the characters, the similarity information of the characters at the dimension level is combined, that is, the generated second feature information incorporates finer-grained information, which is beneficial to improving the accuracy of the entire text processing network.
[0140] (2) Application in text prediction scenarios
[0141] In the present application, please refer to Fig. 9 , Fig. 9 A flowchart of a text processing method provided in an embodiment of the present application is provided. The text processing method provided in an embodiment of the present application may include:
[0142] 901. An execution device inputs at least two first characters into a text processing network.
[0143] In some embodiments of the present application, an execution device obtains a text to be processed, which includes true value characters and characters to be predicted. The execution device can replace the characters to be predicted with mask characters to obtain at least two first characters, and input the at least two first characters into a text processing network. Among the at least two first characters, there is at least one true value character and at least one character to be predicted. As an example, if the text to be processed is "I like traveling, and my favorite place is Yunnan. I must go to XXXX if I have the chance in the future", the entire text to be processed includes 27 true value characters and 4 characters to be predicted. The at least one first character input into the text processing network can be specifically expressed in the form of sequence data. For the specific expression form of the at least two first characters, please refer to Figure 3 The description of step 301 in the corresponding embodiment is not repeated here. The character to be predicted can be replaced by a mask character, which can also be called a [MASK] character.
[0144] Among them, the text processing network includes a feature extraction network and a feature processing network. The feature extraction network includes a similarity calculation module and a generation module; in this application scenario, a character table can be configured on the execution device, and each character in the character table corresponds to a unique index number. The feature processing network in this application scenario can also be specifically expressed as a classifier, and the output of the classifier can be an index number. The execution device determines the predicted character based on the aforementioned index number and the aforementioned character table. For the specific expressions of the similarity calculation module, the generation module and the classifier, please refer to Figure 3 The description in the corresponding embodiment is not repeated here.
[0145] 902. The execution device extracts features from at least two first characters through a similarity calculation module to obtain first feature information corresponding to the at least two first characters.
[0146] 903. The execution device calculates first similarity information of at least two first characters at a dimension level according to the first feature information through a similarity calculation module.
[0147] 904. The execution device generates second feature information corresponding to at least two first characters according to the first similarity information through a generation module.
[0148] In the embodiment of the present application, the specific implementation method of the execution device executing steps 902 to 904 is as follows Figure 3 The specific implementation methods of steps 302 to 304 in the corresponding embodiment are similar, and reference may be made to the above description, which will not be repeated here.
[0149] 905. The execution device outputs a prediction result corresponding to the character to be predicted through a feature processing network, where the prediction result indicates a predicted character corresponding to the character to be predicted.
[0150] In some embodiments of the present application, in this application scenario, the feature processing network can output a prediction result corresponding to the mask character based on the second feature information, thereby obtaining a predicted character corresponding to the character to be predicted. Optionally, the feature processing network can output a prediction result corresponding to the mask character based on the fourth feature information, and the prediction result indicates the predicted character corresponding to the character to be predicted. The prediction result can be specifically expressed as an index number corresponding to the predicted character.
[0151] In a text prediction process, the character to be predicted may be at least one. When there are at least two characters to be predicted, in the process of using the text processing network for text prediction, an autoregressive prediction method can be adopted, that is, the text processing network can only predict one character each time it performs a prediction operation, and outputs an index number of a predicted character in each prediction process, and it is necessary to perform at least two prediction operations to obtain all the characters to be predicted; a non-autoregressive prediction method can also be adopted, that is, the text processing network can predict all the characters to be predicted at one time each time it performs a prediction operation. As an example, here, the method of using autoregressive (monotonic autoregressive) is taken as an example. For example, if the text to be processed is "Today's weather XXX", in this example, a total of 3 predicted characters need to be generated, then the execution device can replace the 3 characters to be predicted with [MASK] characters. In the process of generating the first character to be predicted, the execution device inputs "Today's weather [MASK][MASK][MASK]" into the text processing network, and the text processing network generates the index number of "very". In the process of generating the second character to be predicted, the execution device inputs "Today's weather is very [MASK][MASK]" into the text processing network, and the text processing network generates an index number of "no". In the process of generating the third character to be predicted, the execution device inputs "Today's weather is very bad [MASK]" into the text processing network, and the text processing network generates an index number of "wrong". Thus, the three predicted characters are determined to be "very good". It should be understood that the examples here are only for convenience of understanding and are not used to limit this solution.
[0152] It should be noted that the number of executions between steps 902 to 904 and step 905 is not limited in this application scenario. The number of executions between steps 902 to 904 and step 905 can be multiple to one or one to one. For details, please refer to Figure 3 The description in the corresponding embodiment is not repeated here.
[0153] In the embodiments of the present application, it can be applied not only to the application scenario of text classification, but also to the application scenario of text prediction, which expands the application scenario of the present solution.
[0154] (3) Application in text translation scenarios
[0155] In the present application, please refer to Fig.10 , Fig.10 A flowchart of a text processing method provided in an embodiment of the present application is provided. The text processing method provided in an embodiment of the present application may include:
[0156] 1001. An execution device inputs at least two first characters into a text processing network.
[0157] In some embodiments of the present application, an execution device obtains a text to be translated, the text to be translated includes at least two first characters, and the execution device inputs the entire text to be translated into a text processing network. The specific implementation method can be found in the description of step 1001, which is not repeated here. The text to be translated (that is, at least two first characters) is in a first language, and the translated text is in a second language, and the first language and the second language are different languages.
[0158] Among them, the text processing network includes a feature extraction network and a feature processing network. The feature extraction network includes a similarity calculation module and a generation module. The feature extraction network can be specifically expressed as an encoder. In this application scenario, a character table can be configured on the execution device. Each character in the character table corresponds to a unique index number. The feature processing network in this application scenario can also be specifically expressed as a decoder. The classifier output can be an index number. The execution device determines the predicted character based on the aforementioned index number and the aforementioned character table.
[0159] 1002. The execution device extracts features from at least two first characters through a similarity calculation module to obtain first feature information corresponding to the at least two first characters.
[0160] 1003. The execution device calculates first similarity information of at least two first characters at a dimension level according to the first feature information through a similarity calculation module.
[0161] 1004. The execution device generates, through a generation module, second feature information corresponding to at least two first characters according to the first similarity information.
[0162] In the embodiment of the present application, the specific implementation method of the execution device executing steps 1002 to 1004 is as follows Figure 3 The specific implementation methods of steps 302 to 304 in the corresponding embodiment are similar, and reference may be made to the above description, which will not be repeated here.
[0163] 1005. The execution device performs a translation operation on the first character through a feature processing network to obtain a translated first character, where the translated first character is in a different language from the first character.
[0164] In some embodiments of the present application, in this application scenario, the execution device may use an autoregressive method or a non-autoregressive method to perform a translation operation on the first character through a feature processing network, and output indication information of the translated first character, and the execution device obtains the translated first character according to the indication information of the translated first character. Among them, the execution device may also be configured with a character table of a second language, and the character table of the second language is configured with a plurality of characters of the second language and an index number corresponding to each character of the second language, and the indication information of the translated first character may be specifically expressed as an index number, and the execution device determines the translated first character from the character table of the second language according to the index number included in the indication information of the first character.
[0165] Optionally, the feature processing network may perform a translation operation on the first character based on the second feature information and the fourth feature information, and output indication information of the translated first character, wherein the indication information of the translated first character may be specifically expressed as an index number corresponding to the translated first character one by one.
[0166] and Figure 3 Similar to the corresponding embodiment, the execution times between steps 1002 to 1004 and step 1005 are not limited in this application scenario. The execution times between steps 1002 to 1004 and step 1005 can be multiple to one or one to one. For details, please refer to Figure 3 The description in the corresponding embodiment is not repeated here.
[0167] For further understanding of this solution, please refer to Fig.11 , Fig.11 A structural diagram of a text processing network provided in an embodiment of the present application. Fig.11 In this example, the first language is Chinese and the second language is English. Both the encoder and decoder parts of the machine translation task can be used Figure 3 The feature extraction network shown in the corresponding embodiment is implemented by stacking multiple layers. The input of the encoder is the sequence data corresponding to the text to be translated (that is, the sequence data corresponding to the first language), and Figure 8 Similar to the described embodiment, the [CLS] character is also added to the front of the text to be translated, and the [CLS] character is used to extract the feature information of the entire text to be translated. The steps performed by each layer of the feature extraction network are the same as those in the embodiment described above. Figure 3The corresponding embodiment is similar to steps 302 to 304. The input of the decoder is the language corresponding to the second language. In each layer except the bottom layer, the matrix A (that is, the first representation) and the matrix C (that is, the third representation) of each layer are obtained by linear transformation of the second feature information output by the corresponding layer of the encoder, and the matrix B (that is, the second representation) is obtained by linear transformation of the second feature information generated by the previous layer in the decoder. In this way, the feature information on the decoder side can be integrated with the feature information learned on the encoder side, so that the prediction of each word in the decoding process can effectively take into account the information of the first language. In this embodiment, the decoder takes the translation from left to right autoregressive as an example. After the execution device generates E1 (that is, the second feature information output by the last feature extraction network) through the entire encoder, when generating the first translated character, the training device replaces the ungenerated character with the [MASK] character (such as Fig.11 As shown) is input into the encoder, after the last feature extraction network in the encoder outputs the second feature information, the classification network uses h1 to output the indication information of the first translated character, assuming that the first translated character obtained is "It". In the process of generating the second translated character, the training device inputs "[CLS]It[MASK][MASK][MASK][MASK][MASK][MASK]" into the encoder again, and the classification network uses h2, the top representation of "It", to generate the indication information of the second translated character, and so on, until all the translated characters are obtained. It should be understood that Fig.11 The examples are only for facilitating the understanding of this solution and are not intended to limit this solution.
[0168] In the embodiments of the present application, it can be applied not only to the application scenarios of text classification and text prediction, but also to the application scenarios of text translation, further expanding the application scenarios of the present solution.
[0169] 2. Training Phase
[0170] In the embodiment of the present application, in the scenario where sequence data is used to indicate character information in the text to be processed, the training phase describes the process of how the training device 220 trains the text processing network. Correspondingly, the training phase also includes understanding text information, performing text prediction, text translation or other specific application scenarios. The following describes the three application scenarios of the above examples respectively.
[0171] (1) Applied to the context of understanding text
[0172] In the present application, please refer to Fig.12 , Fig.12A flowchart of a neural network training method provided in an embodiment of the present application is provided. The neural network training method provided in an embodiment of the present application may include:
[0173] 1201. The training device obtains a first training text.
[0174] In some embodiments of the present application, a first training data set may be configured in the training device, the first training data set includes multiple training texts, each training text includes at least one character to be predicted, and the training data set also includes the correct character corresponding to the mask character. Then the training device obtains the first training text from the training data set, the first training text includes at least two second characters, at least two second characters include the character to be predicted, and the character to be predicted in the training stage can be pre-replaced with the mask character. The mask character can be located at any position in the first training text. As an example, the first training text is "Today [MASK] [MASK] [MASK] is good", as another example, for example, "Huawei phone [MASK] [MASK] is good", etc., which are not limited here.
[0175] 1202. The training device inputs the first training text into the first feature extraction network to perform feature extraction on the first training text through the first feature extraction network to obtain first feature information corresponding to at least two second characters.
[0176] In the embodiment of the present application, after obtaining the first training text, the training device obtains the original representation corresponding to the first training text, and inputs the original representation corresponding to the first training text into the first feature extraction network, so as to extract features of the first training text through the first feature extraction network, and obtain first feature information corresponding to at least two second characters. For the specific implementation of step 1202, please refer to Figure 3 The description of step 301 and step 302 in the corresponding embodiment. The difference is that in the training stage, the original representation corresponding to each character in the character table configured on the training device is fixed, and the original representation corresponding to each character in the character table configured on the training device can also be regarded as a model parameter, which is continuously updated during the iterative training process.
[0177] 1203. The training device calculates second similarity information of at least two second characters at a dimension level based on first feature information corresponding to at least two second characters through a first feature extraction network.
[0178] 1204. The training device generates second feature information corresponding to at least two second characters according to the second similarity information through the first feature extraction network.
[0179] 1205. The training device outputs a prediction result through the first feature processing network, where the prediction result indicates a predicted character corresponding to the character to be predicted, and the first feature processing network and the first feature extraction network belong to the first text processing network.
[0180] In the embodiment of the present application, the specific implementation method of the training device executing steps 1203 to 1205 can be found in Fig. 9 The description of steps 903 to 905 in the corresponding embodiment will not be repeated here. Figure 3 The first similarity information described in the corresponding embodiment is similar, except that the first similarity information is the similarity information of at least two first characters at the dimension level, and the second similarity information is the similarity information of at least two second characters at the dimension level. Fig. 9 The description in the corresponding embodiment is not repeated here.
[0181] It should be noted that if the autoregressive prediction method is used in steps 1203 to 1205, each prediction operation can only obtain one predicted character. In the entire prediction process, if the predicted character is an incorrect character, the training device will still use the correct character for the next prediction in the next prediction process. As an example, for example, the correct prediction result corresponding to the first training text is "The weather is very good today", and the predicted character obtained in the first prediction process is "empty". Obviously, a prediction error occurred in this prediction process. If in the inference stage, the execution device will input "Today is empty [MASK][MASK] not bad" into the text processing network for the next prediction operation, but in the training stage, the training device will input "Today [MASK][MASK] not bad" into the text processing network for the next prediction operation, that is, even if a prediction error occurs in the training stage, the correct character will still be used for the next prediction.
[0182] 1206. The training device iteratively trains the first text processing network according to the correct characters corresponding to the characters to be predicted, the predicted characters and the loss function until the preset conditions are met, and outputs a second feature extraction network, which is the trained first feature extraction network.
[0183] In some embodiments of the present application, after obtaining the prediction result, the training device determines the predicted character corresponding to the character to be predicted, calculates the function value of the first loss function according to the correct character corresponding to the character to be predicted, the predicted character and the first loss function, the first loss function reflects the similarity between the correct character and the predicted character, and generates a gradient value according to the function value of the first loss function, and gradient updates the weight parameters of each neural network layer in the first text processing network through the back propagation algorithm. Optionally, the original representation corresponding to the first training text can also be updated to complete a training of the first text processing network. The training device repeatedly performs steps 1201 to 1206 to iteratively train the first text processing network until the preset conditions are met, and outputs a second feature extraction network, which is the trained first feature extraction network.
[0184] Among them, the preset condition can be that the convergence condition of the first loss function is satisfied, or that the number of iterations of iterative training satisfies the preset number of times, etc. The first loss function can be specifically expressed as a 0-1 loss function, a cross entropy loss function, a logarithmic loss function, or other types of loss functions, etc., which are not limited here. To further understand the first loss function, the following uses a non-autoregressive prediction method, and the first loss function is a logarithmic loss function as an example, and discloses the formula of the first loss function:
[0185] L(θ1)=logΠ i∈S p(y i |x;θ1)=∑ i∈S logp(y i |x;θ1); (1)
[0186] Wherein, L(θ1) represents the first loss function, θ1 represents the weight parameter in the first text processing network, optionally, θ1 also includes the original representation corresponding to the first training text, x represents the input first training text, S represents the collection of positions of all characters to be predicted in the first training text, y i represents the character to be predicted at the ith position. It should be understood that the example in formula (1) is only for the convenience of understanding the first loss function and is not used to limit this solution.
[0187] 1207. The training device obtains a second training text.
[0188] In some embodiments of the present application, the training device may also be configured with a second training set, the second training data set including multiple training texts and a correct category corresponding to each training text. The training device obtains a second training text from the second training data set, the second training text including at least two third characters.
[0189] 1208. The training device inputs the second training text into the second feature extraction network to generate second feature information corresponding to at least two third characters through the second feature extraction network.
[0190] 1209. The training device performs a classification operation through a second feature processing network, and outputs indication information of a predicted category corresponding to at least two third characters, wherein the second feature extraction network and the second feature processing network belong to a second text processing network.
[0191] In the embodiment of the present application, the specific implementation method of the training device executing steps 1203 to 1205 can be found in Figure 3 The description of steps 301 to 305 in the corresponding embodiment will not be repeated here. The indication information of the predicted category corresponding to the at least two third characters and the specific expression form of the predicted category can be referred to in Figure 3 The description in the corresponding embodiment is not repeated here.
[0192] 1210. The training device iteratively trains the second text processing network according to the correct category corresponding to the second training text, the indication information of the predicted category, and the loss function until a preset condition is met, and outputs the trained second text processing network.
[0193] In some embodiments of the present application, after obtaining the indication information of the predicted category corresponding to at least two third characters, the training device determines the predicted category corresponding to the second training text, and calculates the function value of the second loss function according to the correct category, the predicted category and the second loss function corresponding to the second training text. Among them, the second loss function reflects the similarity between the correct category and the predicted category, and the specific expression form of the correct category is consistent with the specific expression form of the predicted category. The training device generates a gradient value according to the function value of the second loss function, and gradient updates the weight parameters of each neural network layer in the second text processing network through the back propagation algorithm. Optionally, the original representation corresponding to the second training text can also be updated to complete a training of the second text processing network. The training device repeats steps 1201 to 1206 to iteratively train the second text processing network until the preset conditions are met, and outputs the trained second text processing network.
[0194] Among them, the preset condition can be that the convergence condition of the second loss function is satisfied, or that the number of iterations of iterative training satisfies the preset number of times, etc. The second loss function can be specifically expressed as a 0-1 loss function, a cross entropy loss function, a logarithmic loss function, or other types of loss functions, etc., which are not limited here. To further understand the first loss function, the formula of the second loss function is disclosed below, taking the second loss function as a logarithmic loss function as an example:
[0195] L(θ2)=logP(y|x;θ2); (2)
[0196] Among them, represents the second loss function, θ2 represents the weight parameter in the second text processing network, optionally, θ2 also includes the original representation corresponding to the second training text, x represents the input second training text, y represents the predicted classification and correct classification corresponding to the second training text, it should be understood that the example in formula (2) is only for the convenience of understanding the first loss function, and is not used to limit this solution.
[0197] It should be noted that steps 1207 to 1210 are optional steps. If steps 1207 to 1210 are not performed, the second feature extraction network can be directly output after step 1206 is performed. If steps 1207 to 1210 are performed, steps 1201 to 1206 can be regarded as a pretraining stage, steps 1201 to 1206 can adopt a self-supervised learning method, and steps 1207 to 1210 can be regarded as a fine-tuning stage.
[0198] In an embodiment of the present application, the feature extraction network in the text classification network is first trained, and then the text classification network as a whole is trained. This can effectively transfer the semantic information learned during the initial training process to the entire text classification network, which is beneficial to improving the accuracy of the text classification network after training.
[0199] In an embodiment of the present application, the first feature extraction network is placed in the text prediction scenario and the first feature extraction network is iteratively trained. Since the text prediction scenario has high requirements on the capability of the feature extraction network, it is beneficial to improve the feature extraction capability of the trained first feature extraction network.
[0200] (2) Application in text prediction scenarios
[0201] In the present application, please refer to Fig.13 , Fig.13 A flowchart of a neural network training method provided in an embodiment of the present application is provided. The neural network training method provided in an embodiment of the present application may include:
[0202] 1301. A training device obtains a first training text, where the first training text includes at least two second characters, and the at least two second characters include at least one character to be predicted.
[0203] In the embodiment of the present application, the specific implementation method of the training device executing step 1301 can be found in Fig.11 The description of step 1101 in the corresponding embodiment is not repeated here.
[0204] 1302. The training device inputs at least two second characters into a first feature extraction network, performs feature extraction on the at least two second characters through the first feature extraction network, and obtains first feature information corresponding to the at least two second characters, wherein the first feature information includes feature information of the at least two second characters in at least one dimension.
[0205] 1303. The training device calculates second similarity information of at least two second characters at a dimension level based on first feature information corresponding to at least two second characters through a first feature extraction network.
[0206] 1304. The training device generates second feature information corresponding to at least two second characters according to the second similarity information through the first feature extraction network.
[0207] 1305. The training device outputs a predicted character corresponding to the character to be predicted through the first feature processing network.
[0208] In the embodiment of the present application, the specific implementation of the training device to perform steps 1302 to 1305 can be found in Fig. 9 The description of steps 901 to 905 in the corresponding embodiment will not be repeated here. In this embodiment, the first feature extraction network and the first feature processing network are included in the same text prediction network. The specific implementation of the text prediction network can be found in Fig. 9 In the description of the first text processing network in the corresponding embodiment, the specific expression form of the first feature information corresponding to the at least two second characters, the specific expression form of the second similarity information, and the specific expression form of the second feature information corresponding to the at least two second characters are all in Figure 3 The corresponding embodiments have been introduced, and please refer to the above description, so it will not be repeated here.
[0209] 1306. The training device iteratively trains the text prediction network according to the correct character corresponding to the character to be predicted, the predicted character, and the third loss function until a preset condition is met, and outputs the trained text prediction network.
[0210] In the embodiment of the present application, the specific implementation method of the training device executing step 1306 can be found in Fig.11 The description in step 1106 in the corresponding embodiment is not repeated here. Among them, the preset condition can be to meet the convergence condition of the third loss function, or the number of iterations of iterative training can meet the preset number of times. The specific expression of the third loss function can be similar to the first loss function, and is not repeated here.
[0211] In an embodiment of the present application, a training method is provided when a text processing network is used for text prediction, which expands the application scenarios of the present solution.
[0212] (3) Application in text translation scenarios
[0213] In the present application, please refer to Fig.14 , Fig.14 A flowchart of a neural network training method provided in an embodiment of the present application is provided. The neural network training method provided in an embodiment of the present application may include:
[0214] 1401. A training device obtains a first training text and a correct translation text corresponding to the first training text, where the first training text includes at least two second characters.
[0215] 1402. The training device inputs the first training text into a fourth feature extraction network to perform feature extraction on the first training text through the fourth feature extraction network to obtain first feature information corresponding to at least two second characters, wherein the first feature information includes feature information of the second characters in at least one dimension.
[0216] 1403. The training device calculates second similarity information of at least two second characters at a dimension level based on first feature information corresponding to at least two second characters through a fourth feature extraction network.
[0217] 1404. The training device generates second feature information corresponding to at least two second characters according to the second similarity information through a fourth feature extraction network.
[0218] In the embodiment of the present application, the specific implementation of the training device to perform steps 1402 to 1404 can be found in Fig.10 The descriptions of steps 1002 to 1004 in the corresponding embodiment are not repeated here.
[0219] 1405. The training device performs a translation operation on the first training text according to the correct translation text and the second feature information through the fourth feature processing network, and outputs the translated second character. The fourth feature extraction network and the fourth feature processing network belong to the text translation network, and the translated second character is in a different language from the second character.
[0220] In the embodiment of the present application, the specific implementation method of the training device executing step 1405 is as follows Fig.10The specific implementation of step 1005 in the corresponding embodiment is similar. The difference is that if steps 1402 to 1405 adopt an autoregressive translation method, each translation operation can only obtain one translated character. In the entire translation process, if a translated character is an incorrect character, the training device will still use the correct translated character for the next translation in the next translation process. As an example, for example, the correct translation character corresponding to the first character of the first training text "Today's weather is very good" is "It", and the translation character obtained in the first translation process is "That". Obviously, a translation error occurred in this translation process. If in the inference stage, the execution device will input "That[MASK][MASK][MASK][MASK][MASK][MASK]" into the encoder for the next translation operation, but in the training stage, the training device will input "It[MASK][MASK][MASK][MASK][MASK][MASK]" into the encoder for the next translation operation. That is, even if a translation error occurs in the training stage, the correct translated characters will still be used for the next translation. It should be understood that the examples given here are only for the convenience of understanding this solution and are not intended to limit this solution.
[0221] 1406. The training device iteratively trains the text translation network according to the correctly translated text, the translated second character and the fourth loss function until a preset condition is met, and outputs the trained text translation network.
[0222] In the embodiment of the present application, the specific implementation of step 1406 can be found in Fig.12 The description of step 1206 in the corresponding embodiment. The difference is that the fourth loss function indicates the similarity between the correctly translated text and the translated second character. The preset condition may be that the convergence condition of the fifth loss function is satisfied, or that the number of iterations of the iterative training satisfies the preset number of times, etc. The fifth loss function may be specifically expressed as a 0-1 loss function, a cross entropy loss function, a logarithmic loss function, or other types of loss functions, etc., which are not limited here.
[0223] In an embodiment of the present application, a training method is provided when a text processing network is used for text translation, further expanding the application scenarios of the present solution.
[0224] In an embodiment of the present application, the trained first text processing network can process two or more characters at a time, that is, a more efficient text processing network is provided; in addition, the trained first text processing network can combine the similarity information of the characters at the dimensional level in the process of generating feature information of the characters, that is, the generated second feature information will incorporate more fine-grained information, which is beneficial to improving the accuracy of the entire text processing network.
[0225] The above is an introduction to the application of the method for processing sequence data provided in the embodiments of the present application to the large application scenario of text processing. The embodiments of the present application also provide a method for processing sequence data, please refer to Fig.15 , Fig.15 A flowchart of a method for processing sequence data provided in an embodiment of the present application is provided. The method for processing sequence data provided in an embodiment of the present application may include:
[0226] 1501. The execution device inputs at least two sequence data into a first neural network, where the first neural network is a network for processing sequence data.
[0227] In the embodiment of the present application, the sequence data is used to indicate any of the following information: character information, consumption information, location information and gene information. The first neural network includes a feature extraction network and a feature processing network, and the feature extraction network also includes a similarity calculation module and a generation module. The specific implementation of the similarity calculation module, the generation module and the feature processing network can be determined in combination with the specific functions of the first neural network. Figure 3 , Fig. 9 as well as Fig.10 The specific implementation methods of the similarity calculation module, the generation module and the feature processing network in specific application scenarios are introduced in the corresponding embodiments, which will not be repeated here.
[0228] Specifically, since the sequence data is used to indicate the character information, the specific implementation of step 1501 is already in Figures 3 to 14 The corresponding embodiments have been described in detail and will not be repeated here.
[0229] When the sequence data is used to indicate the user's historical consumption information, the first neural network can be used to predict the user's future consumption. Then step 1501 may include: the execution device converts the user's historical consumption information into at least two sequence data, and inputs the at least two sequence data into the first neural network, one sequence data corresponds to one consumption record. The original representation of each consumption record (i.e., one sequence data corresponding to each consumption record) can be obtained by, but not limited to, random initialization or using item embedding (Item2Vec). The Item2Vec method can generate a corresponding vector representation (i.e., a sequence data) for each application. As an example, for example, the application downloaded by the user can be converted into the expression form of sequence data, one sequence data corresponds to one consumption record, and at least two sequence data indicate the sequence of applications downloaded by the user, such as: "Application 1, Application 2, Application 3, Application 4, and Application 5", and the information output by the first neural network indicates that the applications that the user may be interested in include: "Application 6, Application 7, Application 8, Application 9, and Application 10".
[0230] When the sequence data is used to indicate the user's location information, the first neural network can be used to predict the user's future location information. This application is widely used in scenarios such as crowd flow prediction and information push based on geographic location. Then step 1501 may include: the execution device converts the user's historical location information into at least two sequence data, and inputs the at least two sequence data into the first neural network, one sequence data corresponds to one location record, and at least two sequence data indicate all the user's historical locations. The initial representation of each location information (i.e., a sequence data corresponding to each location information) can be obtained by, but not limited to, random initialization or using location embedding (Loc2Vec). The Loc2Vec method can generate a corresponding vector representation (i.e., a sequence data) for each location information. As an example, for example, the locations that the user has visited include: "home, restaurant, company, restaurant and company", and the information output by the first neural network indicates that the user's possible future locations include: "shopping mall, park, company, shopping mall and home".
[0231] When the sequence data is used to indicate the user's gene information, the role of the first neural network can be the task of sequence annotation of the gene sequence, that is, to classify each gene in the gene sequence. Then step 1501 may include: the execution device converts at least two gene elements included in the gene sequence into at least two sequence data, and inputs the at least two sequence data into the first neural network, one sequence data corresponds to one gene element, and at least two sequence data indicate all gene elements in the gene sequence. The initial representation of each gene element (i.e., one sequence data corresponding to each gene element) can be obtained by, but not limited to, random initialization. As an example, the gene sequence is taken as a base sequence as an example, for example, the base sequence input to the first neural network is {A, T, T, G, C, T, A, T, A}, and the label sequence output by the first neural network is {0, 0, 1, 0, 0, 0, 0, 1}, and 1 in the label sequence means that the corresponding gene element is a valuable gene element, such as a gene element at the beginning of translation, and 0 in the label sequence means that the corresponding gene element is a gene element without value.
[0232] It should be noted that other types of data may also be indicated by sequence data, and thus processed using the sequence data processing method provided in the embodiment of the present application, and the information that can be indicated by sequence data is not exhaustively enumerated herein.
[0233] 1502. The execution device extracts features from at least two sequence data through a similarity calculation module to obtain third feature information corresponding to the at least two sequence data.
[0234] 1503. The execution device calculates third similarity information of at least two sequence data at a dimension level according to the third feature information through a similarity calculation module.
[0235] 1504. The execution device generates fourth feature information corresponding to at least two sequence data according to the third similarity information.
[0236] In the embodiment of the present application, the specific implementation method of the execution device executing steps 1502 to 1504 can be found in Figure 3 The description of steps 302 to 304 in the corresponding embodiment will not be repeated here. Figures 3 to 11 The first feature information in the corresponding embodiment is similar to the third similarity information. Figures 3 to 11 The first similarity information in the corresponding embodiment is similar to that in the fourth feature information. Figures 3 to 11 The second characteristic information in the corresponding embodiment is similar and will not be described again here.
[0237] 1505. The execution device performs feature processing through a feature processing network and outputs a generated processing result corresponding to at least two sequence data.
[0238] In the embodiment of the present application, the execution device performs feature processing through a feature processing network and outputs a generated processing result corresponding to at least two sequence data, wherein the feature processing is any one of the following operations: classification operation, prediction operation and translation operation. Specifically, Figure 3 Corresponding to step 305 in the embodiment, Fig. 9 Step 905 and Fig.10 Step 1005 in the corresponding embodiments is a specific implementation of step 1505, and can be found in the description.
[0239] In addition, when the sequence data is used to indicate the user's historical consumption information or the user's historical location information, and the function of the first neural network is to predict the user's future consumption information or the user's future location information, the specific implementation method of step 1505 can be referred to. Fig. 9 The description of step 905 in the corresponding embodiment is as follows: Fig. 9 Similar to the corresponding embodiment, the execution device can also replace the consumption information or location information to be predicted with the mask sequence, thereby performing a prediction operation based on at least two known sequence data to predict the mask sequence, that is, generating a predicted consumption record based on at least two known consumption records, or generating predicted location information based on at least two known location information.
[0240] When the sequence data is used to indicate gene information and the function of the first neural network is to perform sequence annotation on the gene sequence, the specific implementation of step 1505 can be referred to in Figure 3 The description of step 305 in the corresponding embodiment is as follows: Figure 3 Similar to the corresponding embodiment, the execution device may perform classification operations using a classification network (ie, an example of a feature processing network) to output a category label corresponding to each gene element, etc. Specific cases where the sequence data indicates other types of data are not exhaustively listed here.
[0241] In the embodiment of the present application, not only character information can be processed, but also sequence information such as consumption information, location information or gene information can be processed, which further expands the application scenarios of the present solution and improves the implementation flexibility of the present solution.
[0242] The present application also provides a neural network training method, see Fig.16 , Fig.16 A flowchart of a neural network training method provided in an embodiment of the present application is provided. The neural network training method provided in an embodiment of the present application may include:
[0243] 1601. A training device obtains a second training sample and a correct processing result corresponding to the second training sample, where the second training sample includes at least two training sequence data.
[0244] In the embodiment of the present application, the specific implementation of step 1601 can be found in Fig.12 Corresponding to step 1201 and step 1207 in the embodiment, Fig.13 In the corresponding embodiment, steps 1301 and Fig.14 The second training sample includes two training sequence data, and the concept of at least two training sequence data is the same as Fig.15 The concepts of at least two sequence data in the corresponding embodiments are similar and will not be elaborated here.
[0245] 1602. The training device inputs at least two training sequence data into a first neural network, performs feature extraction on the at least two training sequence data through a similarity calculation module, and obtains third feature information corresponding to the at least two training sequence data. The first neural network is a processing network for sequence data.
[0246] 1603. The training device calculates third similarity information of at least two training sequence data at a dimension level according to the third feature information through a similarity calculation module.
[0247] 1604. The training device generates fourth feature information corresponding to at least two training sequence data according to the third similarity information.
[0248] 1605. The training device performs feature processing through a feature processing network, and outputs a generation processing result corresponding to at least two training sequence data.
[0249] In the embodiment of the present application, the specific implementation of the training device to perform steps 1602 to 1605 can be found in Fig.15 The descriptions of steps 1502 to 1506 in the corresponding embodiment are not repeated here.
[0250] 1606. The training device iteratively trains the first neural network according to the generated processing result, the accurate processing result and the loss function until the preset conditions are met, and outputs the trained first neural network.
[0251] In the embodiment of the present application, the specific implementation of step 1606 can be found in Fig.12 Corresponding to step 1206 and step 1210 in the embodiment, Fig.13 In the corresponding embodiment, steps 1306 and Fig.14 The description of step 1406 in the corresponding embodiment. The specific concepts of the generated processing results and the accurate processing results corresponding to the at least two training sequence data can be referred to in Fig.15The description of the concept of generating a processing result corresponding to at least two sequence data in the corresponding embodiment is not repeated here.
[0252] exist Figures 1 to 16 On the basis of the corresponding embodiments, in order to better implement the above solutions of the embodiments of the present application, the following also provides related devices for implementing the above solutions. Fig.17 , Fig.17 A structural diagram of a text processing network provided for an embodiment of the present application. The text processing network 1700 may include a feature extraction network 1710, and the feature extraction network includes a similarity calculation module 1711 and a generation module 1712. Among them, the similarity calculation module 1711 is used to receive at least two first characters input, and perform feature extraction on the at least two first characters to obtain first feature information corresponding to the at least two first characters, and the first feature information includes feature information of the first characters in at least one dimension; the similarity calculation module 1711 is also used to calculate the first similarity information of the at least two first characters at the dimensional level according to the first feature information; the generation module 1712 is used to generate second feature information corresponding to the at least two first characters according to the first similarity information.
[0253] In a possible design, the first feature information includes a first representation and a second representation, both of which are matrices, a column of data in the first representation includes feature information of at least two first characters in one dimension, and a column of data in the second representation includes feature information of at least two first characters in one dimension;
[0254] The similarity calculation module 1711 is specifically configured to calculate the similarity between the column data in the first representation and the column data in the second representation to obtain first similarity information.
[0255] In a possible design, the similarity calculation module 1711 is specifically configured to perform a transposition process on the first representation, and calculate the similarity between the row data in the transposed first representation and the column data in the second representation, so as to obtain first similarity information.
[0256] In one possible design, the similarity calculation module 1711 is specifically used to: perform a dot product between the column data in the first representation and the column data in the second representation to generate similarity; or, calculate the Euclidean distance between the column data in the first representation and the column data in the second representation to generate similarity; or, calculate the Manhattan distance between the column data in the first representation and the column data in the second representation to generate similarity; or, calculate the Mahalanobis distance between the column data in the first representation and the column data in the second representation to generate similarity; or, calculate the cosine similarity between the column data in the first representation and the column data in the second representation to generate similarity.
[0257] In a possible design, the similarity calculation module 1711 is specifically configured to perform a linear transformation on original representations corresponding to at least two first characters to obtain a first representation and a second representation.
[0258] In one possible design, the similarity calculation module 1711 is specifically used to multiply the original representations of at least two first characters with a first linear transformation matrix to obtain a first representation, and multiply the original representations of at least two first characters with a second linear transformation matrix to obtain a second representation.
[0259] In a possible design, the similarity calculation module 1711 is specifically configured to perform convolution processing on original representations corresponding to at least two first characters to obtain a first representation and a second representation.
[0260] In a possible design, the first feature information includes a third representation, and the third representation includes feature information of at least two first characters; the generation module 1712 is specifically used to fuse the third representation and the first similarity information to generate the second feature information.
[0261] In one possible design, the number of first characters is N, where N is an integer greater than or equal to 2, and the generation module 1712 is specifically used to: generate a third-order tensor representation based on the third representation and the first similarity information, the third-order tensor representation including N matrices, each matrix corresponding to a first character, and a matrix integrating feature information of a first character and similarity information of the first character at a dimensional level; compress the third-order tensor representation to obtain second feature information.
[0262] In one possible design, the first similarity information and the third representation are both matrices; the generation module 1712 is specifically used to perform a tensor product operation on the column data in the first similarity information and the column data in the third representation to obtain a third-order tensor representation; or, the generation module 1712 is specifically used to perform an addition operation on the column data in the first similarity information and the column data in the third representation to obtain a third-order tensor representation.
[0263] In one possible design, the third-order tensor representation includes N matrices, each of which is a d×d two-dimensional matrix; the generation module 1712 is specifically used to compress the third-order tensor representation along a d direction of the third-order tensor representation to obtain second feature information, and the second feature information is an N×d two-dimensional matrix, wherein the compression processing method includes any one of the following: convolution, addition, averaging, maximum value or minimum value.
[0264] In a possible design, the generating module 1712 is specifically configured to transpose the third representation, and multiply the transposed third representation by the first similarity information to obtain the second feature information.
[0265] In one possible design, the text processing network 1700 also includes a feature processing network 1720, which is used to perform a classification operation based on the second feature information and output indication information of a predicted category corresponding to at least two first characters, wherein the classification of the category is based on the semantics of the character, or the classification of the category is based on the part of speech of the character.
[0266] In one possible design, at least two first characters include a character to be predicted, and the text processing network also includes a feature processing network 1720, wherein the feature processing network 1720 is used to output a prediction result corresponding to the character to be predicted based on the second feature information, and the prediction result indicates a predicted character corresponding to the character to be predicted.
[0267] In one possible design, the text processing network also includes a feature processing network 1720, which is used to perform a translation operation on the first character based on the second feature information to obtain a translated first character, where the translated first character is in a different language from the first character.
[0268] It should be noted that the information interaction, execution process, etc. between the modules / units in the text processing network 1700 are the same as those in the present application. Figures 3 to 11 The corresponding method embodiments are based on the same concept. For specific contents, please refer to the description in the method embodiments shown above in this application, which will not be repeated here.
[0269] The present application also provides a neural network training device. Fig.18This is a structural diagram of a neural network training device according to an embodiment of the present application. The neural network training device 1800 includes: an acquisition module 1801, an input module 1802, a processing module 1803 and an output module 1804. Among them, the acquisition module 1801 is used to acquire a first training text, which includes at least two second characters; the input module 1802 is used to input the first training text into the first feature extraction network, so as to extract features of the first training text through the first feature extraction network to obtain first feature information corresponding to the at least two second characters, and the first feature information includes feature information of the second characters in at least one dimension; the processing module 1803 is used to calculate the second similarity information of the at least two second characters at the dimension level through the first feature extraction network according to the first feature information corresponding to the at least two second characters; the processing module 1803 is also used to generate the second feature information corresponding to the at least two second characters according to the second similarity information through the first feature extraction network; the output module 1804 is used to output the generation processing result corresponding to the at least two second characters based on the second feature information corresponding to the at least two second characters through the first feature processing network, and the first feature processing network and the first feature extraction network belong to the first text processing network; the processing module 1803 is also used to iteratively train the first text processing network according to the correct processing result corresponding to the at least two second characters, the generation processing result and the loss function until the preset conditions are met.
[0270] In one possible design, at least two second characters include at least one character to be predicted; the output module 1804 is specifically used to output a prediction result corresponding to the character to be predicted based on the second feature information corresponding to the at least two second characters through the first feature processing network, and the prediction result indicates the predicted character corresponding to the character to be predicted; the processing module 1803 is specifically used to iteratively train the first text processing network according to the correct character corresponding to the character to be predicted, the predicted character and the loss function until the preset conditions are met, and output the second feature extraction network, and the second feature extraction network is the trained first feature extraction network.
[0271] In one possible design, the acquisition module 1801 is also used to acquire a second training text, which includes at least two third characters; the input module 1802 is also used to input the second training text into a second feature extraction network to generate second feature information corresponding to the at least two third characters through the second feature extraction network; the output module 1804 is also used to perform a classification operation based on the second feature information corresponding to the at least two third characters through the second feature processing network, and output indication information of a predicted category corresponding to the at least two third characters, wherein the second feature extraction network and the second feature processing network belong to the second text processing network; the processing module 1803 is specifically used to iteratively train the second text processing network according to the correct category corresponding to the second training text, the indication information of the predicted category and the loss function until a preset condition is met, and output the trained second text processing network.
[0272] In one possible design, at least two second characters include at least one character to be predicted; the output module 1804 is specifically used to output a prediction result corresponding to the character to be predicted through the first feature processing network based on the second feature information corresponding to the at least two second characters and the autoregressive algorithm, and the prediction result indicates the predicted character corresponding to the character to be predicted; the processing module 1803 is specifically used to iteratively train the first text processing network according to the correct character corresponding to the character to be predicted, the predicted character and the loss function until the preset conditions are met, and output the trained first text processing network.
[0273] In one possible design, the output module 1804 is specifically used to perform a translation operation on the first training text through a first feature processing network based on a correct translation text corresponding to the first training text and second feature information corresponding to at least two second characters, and output the translated second characters, where the translated second characters are in a language different from the second characters; the processing module 1803 is specifically used to iteratively train the first text processing network based on the correct translation text, the translated second characters and the loss function until a preset condition is met, and output the trained first text processing network.
[0274] It should be noted that the information interaction, execution process, etc. between the modules / units in the neural network training device 1800 are the same as those in the present application. Figure 12 to Figure 14 The corresponding method embodiments are based on the same concept. For specific contents, please refer to the description in the method embodiments shown above in this application, which will not be repeated here.
[0275] The present application also provides an execution device. Fig.19 , Fig.19 A schematic diagram of a structure of an execution device provided in an embodiment of the present application, wherein the execution device 1900 may be deployed with Fig.17 The text processing network 1700 described in the corresponding embodiment is used to implement Figures 3 to 11 The function of the execution device in the corresponding embodiment. Alternatively, the execution device 1900 is used to implement Fig.15 The functions of the execution device in the corresponding embodiment. Specifically, the execution device 1900 includes: a receiver 1901, a transmitter 1902, a processor 1903 and a memory 1904 (wherein the number of the processor 1903 in the execution device 1900 can be one or more, Fig.19 In the example of FIG. 1903 , the processor 1903 may include an application processor 19031 and a communication processor 19032. In some embodiments of the present application, the receiver 1901, the transmitter 1902, the processor 1903 and the memory 1904 may be connected via a bus or other means.
[0276] The memory 1904 may include a read-only memory and a random access memory, and provides instructions and data to the processor 1903. A portion of the memory 1904 may also include a non-volatile random access memory (NVRAM). The memory 1904 stores processor and operation instructions, executable modules or data structures, or subsets thereof, or extended sets thereof, wherein the operation instructions may include various operation instructions for implementing various operations.
[0277] The processor 1903 controls the operation of the execution device. In a specific application, the various components of the execution device are coupled together through a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus, and a status signal bus, etc. However, for the sake of clarity, various buses are referred to as bus systems in the figure.
[0278] The method disclosed in the above embodiment of the present application can be applied to the processor 1903, or implemented by the processor 1903. The processor 1903 can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 1903. The above processor 1903 can be a general processor, a digital signal processor (digital signal processing, DSP), a microprocessor or a microcontroller, and can further include an application specific integrated circuit (application specific integrated circuit, ASIC), a field programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The processor 1903 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to execute, or the hardware and software modules in the decoding processor can be combined and executed. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 1904, and the processor 1903 reads the information in the memory 1904 and completes the steps of the above method in combination with its hardware.
[0279] The receiver 1901 can be used to receive input digital or character information and generate signal input related to the relevant settings and function control of the execution device. The transmitter 1902 can be used to output digital or character information through the first interface; the transmitter 1902 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; the transmitter 1902 can also include a display device such as a display screen.
[0280] In one embodiment of the present application, the application processor 19031 is used to execute Figures 3 to 11 The corresponding embodiment executes the function of the device. It should be noted that the application processor 19031 executes Figures 3 to 11 For the specific implementation methods and beneficial effects of the functions of the execution device in the corresponding embodiments, please refer to Figures 3 to 11 The descriptions in the corresponding method embodiments will not be repeated here one by one.
[0281] In another embodiment of the present application, the application processor 19031 is used to execute Fig.15The corresponding embodiment executes the function of the device. It should be noted that the application processor 19031 executes Fig.15 For the specific implementation methods and beneficial effects of the functions of the execution device in the corresponding embodiments, please refer to Fig.15 The descriptions in the corresponding method embodiments will not be repeated here one by one.
[0282] The present application also provides a training device. Fig. 20 , Fig. 20 A schematic diagram of a structure of a training device provided in an embodiment of the present application, wherein the training device 2000 may be deployed with Fig.18 The training device 1800 described in the corresponding embodiment is used to implement Figure 12 to Figure 14 The function of the corresponding training device; or, the training device 2000 is used to implement Fig.16 The function of the corresponding training device. Specifically, the training device 2000 is implemented by one or more servers. The training device 2000 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 2022 (for example, one or more processors) and memory 2032, one or more storage media 2030 (for example, one or more mass storage devices) storing application programs 2042 or data 2044. Among them, the memory 2032 and the storage medium 2030 can be short-term storage or permanent storage. The program stored in the storage medium 2030 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the training device. Furthermore, the central processing unit 2022 can be configured to communicate with the storage medium 2030 to execute a series of instruction operations in the storage medium 2030 on the training device 2000.
[0283] The training device 2000 may also include one or more power supplies 2026, one or more wired or wireless network interfaces 2050, one or more input and output interfaces 2058, and / or, one or more operating systems 2041, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0284] In one embodiment of the present application, the central processor 222 is used to implement Figure 12 to Figure 14 The functions of the training device in the corresponding embodiment. It should be noted that the central processor 222 executes Figure 12 to Figure 14 For the specific implementation of the functions of the training device in the corresponding embodiment and the beneficial effects brought about, please refer to Figure 12 to Figure 14The descriptions in the corresponding method embodiments will not be repeated here one by one.
[0285] In another embodiment of the present application, the central processor 222 is used to implement Fig.16 The functions of the training device in the corresponding embodiment. It should be noted that the central processor 222 executes Fig.16 For the specific implementation of the functions of the training device in the corresponding embodiment and the beneficial effects brought about, please refer to Fig.16 The descriptions in the corresponding method embodiments will not be repeated here one by one.
[0286] The present application also provides a computer-readable storage medium in which a program is stored. When the program is run on a computer, the computer executes the above-mentioned Figures 3 to 11 The steps executed by the execution device in the corresponding embodiment, or executing the above Figure 12 to Figure 14 The steps performed by the training device in the corresponding embodiment, or performing the above Fig.15 The steps executed by the execution device in the corresponding embodiment, or executing the above Fig.16 The steps performed by the training device in the corresponding embodiment.
[0287] The present application also provides a computer program product which, when executed on a computer, enables the computer to execute the above Figures 3 to 11 The steps executed by the execution device in the corresponding embodiment, or executing the above Figure 12 to Figure 14 The steps performed by the training device in the corresponding embodiment, or performing the above Fig.15 The steps executed by the execution device in the corresponding embodiment, or executing the above Fig.16 The steps performed by the training device in the corresponding embodiment.
[0288] The present application also provides a circuit system, which includes a processing circuit, wherein the processing circuit is configured to perform the above Figures 3 to 11 The steps executed by the execution device in the corresponding embodiment, or executing the above Figure 12 to Figure 14 The steps performed by the training device in the corresponding embodiment, or performing the above Fig.15 The steps executed by the execution device in the corresponding embodiment, or executing the above Fig.16 The steps performed by the training device in the corresponding embodiment.
[0289] The execution device or training device provided in the embodiment of the present application may be a chip, which includes: a processing unit and a communication unit. The processing unit may be, for example, a processor, and the communication unit may be, for example, an input / output interface, a pin or a circuit. The processing unit may execute the computer execution instructions stored in the storage unit to enable the chip to execute the above Figures 3 to 11 The steps executed by the execution device in the corresponding embodiment, or executing the above Figure 12 to Figure 14 The steps performed by the training device in the corresponding embodiment, or performing the above Fig.15 The steps executed by the execution device in the corresponding embodiment, or executing the above Fig.16 The steps performed by the training device in the corresponding embodiment. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit can also be a storage unit located outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.
[0290] For details, please refer to Fig.21 , Fig.21 A schematic diagram of the structure of a chip provided in an embodiment of the present application, the chip can be expressed as a neural network processor NPU 210, NPU 210 is mounted on the host CPU (Host CPU) as a coprocessor, and the host CPU assigns tasks. The core part of the NPU is the operation circuit 2103, which is controlled by the controller 2104 to extract matrix data from the memory and perform multiplication operations.
[0291] In some implementations, the operation circuit 2103 includes multiple processing units (Process Engine, PE) inside. In some implementations, the operation circuit 2103 is a two-dimensional systolic array. The operation circuit 2103 can also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the operation circuit 2103 is a general-purpose matrix processor.
[0292] For example, assume there is an input matrix A, a weight matrix B, and an output matrix C. The operation circuit 2103 takes the corresponding data of matrix B from the weight memory 2102 and caches it on each PE in the operation circuit. The operation circuit 2103 takes the matrix A data from the input memory 2101 and performs matrix operations with matrix B. The partial results or final results of the obtained matrix are stored in the accumulator 2108.
[0293] The unified memory 2106 is used to store input data and output data. The weight data is directly transferred to the weight memory 2102 through the direct memory access controller (DMAC) 2105. The input data is also transferred to the unified memory 2106 through the DMAC.
[0294] BIU stands for Bus Interface Unit, i.e., bus interface unit 2110 , which is used for the interaction between AXI bus and DMAC and instruction fetch buffer (IFB) 2109 .
[0295] The bus interface unit 2110 (Bus Interface Unit, BIU for short) is used for the instruction fetch memory 2109 to obtain instructions from the external memory, and is also used for the storage unit access controller 2105 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
[0296] DMAC is mainly used to transfer input data in the external memory DDR to the unified memory 2106 or to transfer weight data to the weight memory 2102 or to transfer input data to the input memory 2101.
[0297] The vector calculation unit 2107 includes multiple operation processing units, and further processes the output of the operation circuit 2103 when necessary, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. It is mainly used for non-convolutional / fully connected layer network calculations in neural networks, such as Batch Normalization, pixel-level summation, upsampling of feature planes, etc.
[0298] In some implementations, the vector calculation unit 2107 can store the processed output vector to the unified memory 2106. For example, the vector calculation unit 2107 can apply a linear function and / or a nonlinear function to the output of the operation circuit 2103, such as linear interpolation of the feature plane extracted by the convolution layer, and then, for example, a vector of accumulated values to generate an activation value. In some implementations, the vector calculation unit 2107 generates a normalized value, a pixel-level summed value, or both. In some implementations, the processed output vector can be used as an activation input to the operation circuit 2103, for example, for use in a subsequent layer in a neural network.
[0299] An instruction fetch buffer 2109 connected to the controller 2104 is used to store instructions used by the controller 2104;
[0300] Unified memory 2106, input memory 2101, weight memory 2102 and instruction fetch memory 2109 are all On-Chip memories. External memories are private to the NPU hardware architecture.
[0301] Among them, the operations of each layer in the recurrent neural network can be performed by the operation circuit 2103 or the vector calculation unit 2107.
[0302] The processor mentioned in any of the above places may be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the program of the above-mentioned first aspect method.
[0303] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0304] Through the description of the above implementation mode, the technicians in the relevant field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CLUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, U disk, mobile hard disk, ROM, RAM, disk or optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0305] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0306] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, a computer, a server, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or a data center that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
Claims
1. A text processing network, It is characterized in that The text processing network includes a feature extraction network, and the feature extraction network includes a similarity calculation module and a generation module; The similarity calculation module is used to receive at least two first characters inputted, and perform feature extraction on the at least two first characters to obtain first feature information corresponding to the at least two first characters, wherein the first feature information includes feature information of the first characters in at least one dimension; The similarity calculation module is further used to calculate first similarity information of the at least two first characters at a dimension level according to the first feature information; The generating module is configured to generate second feature information corresponding to the at least two first characters according to the first similarity information.
2. The network according to claim 1, It is characterized in that The first feature information includes a first representation and a second representation, both of which are matrices, a column of data in the first representation includes feature information of the at least two first characters in one dimension, and a column of data in the second representation includes feature information of the at least two first characters in one dimension; The similarity calculation module is specifically configured to calculate the similarity between the column data in the first representation and the column data in the second representation to obtain the first similarity information.
3. The network according to claim 2, It is characterized in that The similarity calculation module is specifically configured to perform transposition processing on the first representation, and calculate the similarity between the row data in the transposed first representation and the column data in the second representation, so as to obtain the first similarity information.
4. The network according to claim 2, It is characterized in that The similarity calculation module is specifically used for: performing a dot product of the column data in the first representation and the column data in the second representation to generate the similarity; or, calculating the Euclidean distance between the column data in the first representation and the column data in the second representation to generate the similarity; or, calculating a Manhattan distance between column data in the first representation and column data in the second representation to generate the similarity; or, calculating a Mahalanobis distance between column data in the first representation and column data in the second representation to generate the similarity; or, A cosine similarity is calculated between the column data in the first representation and the column data in the second representation to generate the similarity.
5. The network according to claim 2, It is characterized in that The similarity calculation module is specifically configured to perform a linear transformation on the original representations corresponding to the at least two first characters to obtain the first representation and the second representation.
6. The network according to claim 5, It is characterized in that The similarity calculation module is specifically used to multiply the original representations corresponding to the at least two first characters by a first linear transformation matrix to obtain the first representation, and multiply the original representations corresponding to the at least two first characters by a second linear transformation matrix to obtain the second representation.
7. The network according to claim 2, It is characterized in that The similarity calculation module is specifically configured to perform convolution processing on original representations corresponding to the at least two first characters to obtain the first representation and the second representation.
8. A network according to any one of claims 1 to 7, It is characterized in that The first characteristic information includes a third representation, and the third representation includes characteristic information of the at least two first characters; The generating module is specifically configured to fuse the third representation and the first similarity information to generate the second feature information.
9. The network according to claim 8, It is characterized in that The number of the first characters is N, where N is an integer greater than or equal to 2, and the generating module is specifically configured to: Generate a third-order tensor representation according to the third representation and the first similarity information, wherein the third-order tensor representation includes N matrices, each matrix corresponds to a first character, and a matrix combines feature information of a first character and similarity information of the first character at a dimension level; The third-order tensor representation is compressed to obtain the second feature information.
10. The network according to claim 9, It is characterized in that The first similarity information and the third representation are both matrices; The generating module is specifically configured to perform a tensor product operation on the column data in the first similarity information and the column data in the third representation to obtain the third-order tensor representation; or The generating module is specifically configured to perform an addition operation on the column data in the first similarity information and the column data in the third representation to obtain the third-order tensor representation.
11. The network according to claim 9, It is characterized in that The third-order tensor representation includes N matrices, each of which is a d×d two-dimensional matrix; The generation module is specifically used to compress the third-order tensor representation along a d direction of the third-order tensor representation to obtain the second feature information, where the second feature information is a two-dimensional matrix of N×d, wherein the compression processing method includes any one of the following: convolution, addition, averaging, maximum value or minimum value.
12. The network according to claim 8, It is characterized in that The generating module is specifically configured to perform a transposition process on the third representation, and multiply the transposed third representation by the first similarity information to obtain the second feature information.
13. A network according to any one of claims 1 to 7, It is characterized in that The text processing network also includes a feature processing network, which is used to perform a classification operation based on the second feature information and output indication information of a predicted category corresponding to the at least two first characters, wherein the classification basis of the category is the semantics of the character, or the classification basis of the category is the part of speech of the character.
14. A network according to any one of claims 1 to 7, It is characterized in that The at least two first characters include a character to be predicted, and the text processing network also includes a feature processing network, which is used to output a prediction result corresponding to the character to be predicted based on the second feature information, and the prediction result indicates a predicted character corresponding to the character to be predicted.
15. A network according to any one of claims 1 to 7, It is characterized in that The text processing network also includes a feature processing network, which is used to perform a translation operation on the first character based on the second feature information to obtain a translated first character, and the translated first character is in a different language from the first character.
16. A neural network training method, It is characterized in that The method comprises: Acquire a first training text, wherein the first training text includes at least two second characters; Inputting the first training text into a first feature extraction network to perform feature extraction on the first training text through the first feature extraction network to obtain first feature information corresponding to the at least two second characters, wherein the first feature information includes feature information of the second characters in at least one dimension; Calculating, by the first feature extraction network, second similarity information of the at least two second characters at a dimension level according to first feature information corresponding to the at least two second characters; generating, by the first feature extraction network, second feature information corresponding to the at least two second characters according to the second similarity information; outputting, by a first feature processing network, a generation processing result corresponding to the at least two second characters based on second feature information corresponding to the at least two second characters, wherein the first feature processing network and the first feature extraction network belong to a first text processing network; According to the correct processing results corresponding to the at least two second characters, the generated processing results and the loss function, the first text processing network is iteratively trained until a preset condition is met.
17. The training method according to claim 16, It is characterized in that The at least two second characters include at least one character to be predicted, and the outputting, through the first feature processing network, the generation processing results corresponding to the at least two second characters based on the second feature information corresponding to the at least two second characters, includes: Outputting, by the first feature processing network, a prediction result corresponding to the character to be predicted based on second feature information corresponding to the at least two second characters, wherein the prediction result indicates a predicted character corresponding to the character to be predicted; The iterative training of the first text processing network according to the correct processing results corresponding to the at least two second characters, the generated processing results and the loss function until a preset condition is met includes: According to the correct characters corresponding to the characters to be predicted, the predicted characters and the loss function, the first text processing network is iteratively trained until preset conditions are met, and a second feature extraction network is output, where the second feature extraction network is the trained first feature extraction network.
18. The training method according to claim 17, It is characterized in that The method further comprises: Acquire a second training text, wherein the second training text includes at least two third characters; Inputting a second training text into the second feature extraction network to generate second feature information corresponding to the at least two third characters through the second feature extraction network; performing a classification operation based on second feature information corresponding to the at least two third characters through a second feature processing network, and outputting indication information of a predicted category corresponding to the at least two third characters, wherein the second feature extraction network and the second feature processing network belong to a second text processing network; According to the correct category corresponding to the second training text, the indication information of the predicted category and the loss function, the second text processing network is iteratively trained until a preset condition is met, and the trained second text processing network is output.
19. The training method according to claim 16, It is characterized in that The at least two second characters include at least one character to be predicted, and the outputting, through the first feature processing network, the generation processing results corresponding to the at least two second characters based on the second feature information corresponding to the at least two second characters, includes: Outputting, by the first feature processing network, a prediction result corresponding to the character to be predicted based on second feature information corresponding to the at least two second characters and an autoregressive algorithm, wherein the prediction result indicates a predicted character corresponding to the character to be predicted; The iterative training of the first text processing network according to the correct processing results corresponding to the at least two second characters, the generated processing results and the loss function until a preset condition is met includes: According to the correct character corresponding to the character to be predicted, the predicted character and the loss function, the first text processing network is iteratively trained until a preset condition is met, and the trained first text processing network is output.
20. The training method according to claim 16, It is characterized in that The step of outputting, through the first feature processing network, a generation processing result corresponding to the at least two second characters based on the second feature information corresponding to the at least two second characters comprises: According to the correct translation text corresponding to the first training text and the second feature information corresponding to the at least two second characters, performing a translation operation on the first training text through the first feature processing network, and outputting a translated second character, wherein the translated second character is in a different language from the second character; The iterative training of the first text processing network according to the correct processing results corresponding to the at least two second characters, the generated processing results and the loss function until a preset condition is met includes: According to the correctly translated text, the translated second character and the loss function, the first text processing network is iteratively trained until a preset condition is met, and the trained first text processing network is output.
21. A neural network for processing sequence data. It is characterized in that The neural network includes a feature extraction network, and the feature extraction network includes a similarity calculation module and a generation module; The similarity calculation module is used to receive at least two sequence data inputted, and perform feature extraction on the at least two sequence data to obtain third feature information corresponding to the at least two sequence data, wherein the third feature information includes feature information of the at least two sequence data in at least one dimension; The similarity calculation module is further used to calculate the third similarity information of the at least two sequence data at the dimension level according to the third feature information; The generating module is used to generate fourth feature information corresponding to the at least two sequence data according to the third similarity information.
22. The network according to claim 21, It is characterized in that The sequence data is used to indicate any one of the following information: character information, consumption information, location information, and gene information.
23. A network according to claim 21 or 22, It is characterized in that The third feature information includes a fourth representation and a fifth representation, both of which are matrices, a column of data in the fourth representation includes feature information of the at least two sequence data in one dimension, and a column of data in the fifth representation includes feature information of the at least two sequence data in one dimension; The similarity calculation module is specifically configured to calculate the similarity between the column data in the fourth representation and the column data in the fifth representation to obtain the third similarity information.
24. A network according to claim 21 or 22, It is characterized in that The third characteristic information includes a sixth representation, and the sixth representation includes characteristic information of the at least two sequence data; The generating module is specifically configured to fuse the sixth representation and the third similarity information to generate the fourth feature information.
25. A network according to claim 21 or 22, It is characterized in that The neural network also includes a feature processing network, which is used to perform feature processing based on the fourth feature information and output a generated processing result corresponding to the at least two sequence data, wherein the feature processing is any one of the following operations: a classification operation, a prediction operation, and a translation operation.
26. A text processing method, It is characterized in that The method comprises: Inputting at least two first characters into a text processing network, the text processing network comprising a feature extraction network, the feature extraction network comprising a similarity calculation module and a generation module; Extracting features of at least two first characters by the similarity calculation module to obtain first feature information corresponding to the at least two first characters, wherein the first feature information includes feature information of the first characters in at least one dimension; Calculating, by the similarity calculation module, first similarity information of the at least two first characters at a dimension level according to the first feature information; The generating module generates second feature information corresponding to the at least two first characters according to the first similarity information.
27. The method according to claim 26, It is characterized in that The first feature information includes a first representation and a second representation, both of which are matrices, a column of data in the first representation includes feature information of the at least two first characters in one dimension, and a column of data in the second representation includes feature information of the at least two first characters in one dimension; The calculating, by the similarity calculation module, first similarity information of the at least two first characters at a dimension level according to the first feature information includes: The similarity calculation module calculates the similarity between the column data in the first representation and the column data in the second representation to obtain the first similarity information.
28. The method according to claim 27, It is characterized in that The calculating, by the similarity calculation module, first similarity information of the at least two first characters at a dimension level according to the first feature information includes: The first representation is transposed by the similarity calculation module, and the similarity between the row data in the transposed first representation and the column data in the second representation is calculated to obtain the first similarity information.
29. The method according to claim 27, It is characterized in that The calculating the similarity between the column data in the first representation and the column data in the second representation comprises: performing a dot product of the column data in the first representation and the column data in the second representation to generate the similarity; or, calculating the Euclidean distance between the column data in the first representation and the column data in the second representation to generate the similarity; or, calculating the Manhattan distance between the column data in the first representation and the column data in the second representation to generate the similarity; or, calculating the Mahalanobis distance between the column data in the first representation and the column data in the second representation to generate the similarity; or, A cosine similarity is calculated between the column data in the first representation and the column data in the second representation to generate the similarity.
30. The method according to claim 27, It is characterized in that The step of extracting features from at least two first characters by the similarity calculation module to obtain first feature information corresponding to the at least two first characters includes: The similarity calculation module performs linear transformation on the original representations corresponding to the at least two first characters to obtain the first representation and the second representation.
31. The method according to claim 30, It is characterized in that The linear transformation of the original representations corresponding to the at least two first characters to obtain the first representation and the second representation includes: The original representations of the at least two first characters are multiplied by a first linear transformation matrix to obtain the first representation, and the original representations of the at least two first characters are multiplied by a second linear transformation matrix to obtain the second representation.
32. The method according to claim 27, It is characterized in that The step of extracting features from at least two first characters by the similarity calculation module to obtain first feature information corresponding to the at least two first characters includes: The similarity calculation module performs convolution processing on the original representations corresponding to the at least two first characters to obtain the first representation and the second representation.
33. A method according to any one of claims 26 to 32, It is characterized in that The first characteristic information includes a third representation, and the third representation includes characteristic information of the at least two first characters; The generating module generates second feature information corresponding to the at least two first characters according to the first similarity information, including: The third representation and the first similarity information are fused through the generation module to generate the second feature information.
34. The method according to claim 33, It is characterized in that The number of the first characters is N, where N is an integer greater than or equal to 2, and the fusing of the third representation and the first similarity information to generate the second feature information includes: Generate a third-order tensor representation according to the third representation and the first similarity information, wherein the third-order tensor representation includes N matrices, each matrix corresponds to a first character, and a matrix combines feature information of a first character and similarity information of the first character at a dimension level; The third-order tensor representation is compressed to obtain the second feature information.
35. The method according to claim 34, It is characterized in that The first similarity information and the third representation are both matrices, and generating a third-order tensor representation according to the third representation and the first similarity information includes: The generating module is specifically configured to perform a tensor product operation on the column data in the first similarity information and the column data in the third representation to obtain the third-order tensor representation; or The generating module is specifically configured to perform an addition operation on the column data in the first similarity information and the column data in the third representation to obtain the third-order tensor representation.
36. The method according to claim 34, It is characterized in that The third-order tensor representation includes N matrices, each of which is a d×d two-dimensional matrix; The compressing the third-order tensor representation to obtain the second feature information includes: The third-order tensor representation is compressed along a d direction of the third-order tensor representation to obtain the second feature information, where the second feature information is a two-dimensional matrix of N×d, wherein the compression processing method includes any one of the following: convolution, addition, averaging, maximum value or minimum value.
37. The method according to claim 33, It is characterized in that The fusing the third representation and the first similarity information to generate the second feature information includes: The third representation is transposed, and the transposed third representation is multiplied by the first similarity information to obtain the second feature information.
38. A method according to any one of claims 26 to 32, It is characterized in that The text processing network also includes a feature processing network, and the method further includes: A classification operation is performed based on the second feature information through the feature processing network, and indication information of the predicted category corresponding to the at least two first characters is output, wherein the classification basis of the category is the semantics of the character, or the classification basis of the category is the part of speech of the character.
39. The method according to any one of claims 26 to 32, It is characterized in that The at least two first characters include a character to be predicted, the text processing network further includes a feature processing network, and the method further includes: Through the feature processing network, based on the second feature information, a prediction result corresponding to the character to be predicted is output, and the prediction result indicates a predicted character corresponding to the character to be predicted.
40. The method according to any one of claims 26 to 32, It is characterized in that The text processing network also includes a feature processing network, and the method further includes: Through the feature processing network, based on the second feature information, a translation operation is performed on the first character to obtain a translated first character, and the translated first character is in a different language from the first character.
41. A neural network training device, It is characterized in that The device comprises: An acquisition module, configured to acquire a first training text, wherein the first training text includes at least two second characters; an input module, configured to input the first training text into a first feature extraction network, so as to perform feature extraction on the first training text through the first feature extraction network, and obtain first feature information corresponding to the at least two second characters, wherein the first feature information includes feature information of the second characters in at least one dimension; a processing module, configured to calculate, by the first feature extraction network, second similarity information of the at least two second characters at a dimension level according to first feature information corresponding to the at least two second characters; The processing module is further configured to generate, through the first feature extraction network, second feature information corresponding to the at least two second characters according to the second similarity information; an output module, configured to output, through a first feature processing network, a generation processing result corresponding to the at least two second characters based on second feature information corresponding to the at least two second characters, wherein the first feature processing network and the first feature extraction network belong to a first text processing network; The processing module is further used to iteratively train the first text processing network according to the correct processing results corresponding to the at least two second characters, generate processing results and a loss function, until a preset condition is met.
42. The training device according to claim 41, It is characterized in that The at least two second characters include at least one character to be predicted; The output module is specifically configured to output a prediction result corresponding to the character to be predicted based on the second feature information corresponding to the at least two second characters through the first feature processing network, wherein the prediction result indicates a predicted character corresponding to the character to be predicted; The processing module is specifically used to iteratively train the first text processing network according to the correct characters corresponding to the characters to be predicted, the predicted characters and the loss function until the preset conditions are met, and output a second feature extraction network, where the second feature extraction network is the trained first feature extraction network.
43. The training device according to claim 42, It is characterized in that The acquisition module is further used to acquire a second training text, wherein the second training text includes at least two third characters; The input module is further used to input the second training text into the second feature extraction network, so as to generate second feature information corresponding to the at least two third characters through the second feature extraction network; The output module is further configured to perform a classification operation based on second feature information corresponding to the at least two third characters through a second feature processing network, and output indication information of a predicted category corresponding to the at least two third characters, wherein the second feature extraction network and the second feature processing network belong to a second text processing network; The processing module is specifically used to iteratively train the second text processing network according to the correct category corresponding to the second training text, the indication information of the predicted category and the loss function until a preset condition is met, and output the trained second text processing network.
44. The training device according to claim 41, It is characterized in that The at least two second characters include at least one character to be predicted; The output module is specifically configured to output a prediction result corresponding to the character to be predicted based on the second feature information corresponding to the at least two second characters and an autoregressive algorithm through the first feature processing network, wherein the prediction result indicates a predicted character corresponding to the character to be predicted; The processing module is specifically used to iteratively train the first text processing network according to the correct character corresponding to the character to be predicted, the predicted character and the loss function until a preset condition is met, and output the trained first text processing network.
45. The training device according to claim 41, It is characterized in that The output module is specifically configured to perform a translation operation on the first training text through the first feature processing network according to the correct translation text corresponding to the first training text and the second feature information corresponding to the at least two second characters, and output the translated second characters, wherein the translated second characters are in a different language from the second characters; The processing module is specifically used to iteratively train the first text processing network according to the correctly translated text, the translated second character and the loss function until a preset condition is met, and output the trained first text processing network.
46. An execution device, It is characterized in that The invention comprises a processor, wherein the processor is coupled to a memory, wherein the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the steps executed by the text processing network described in any one of claims 1 to 15 are implemented, or the steps executed by the neural network for processing sequence data described in any one of claims 21 to 25 are implemented.
47. A training device, It is characterized in that The method comprises a processor, wherein the processor is coupled to a memory, wherein the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the method according to any one of claims 16 to 20 is implemented.
48. A computer readable storage medium, It is characterized in that The invention comprises a program which, when executed on a computer, causes the computer to execute the steps executed by the text processing network as claimed in any one of claims 1 to 15, or causes the computer to execute the method as claimed in any one of claims 16 to 20, or causes the computer to execute the steps executed by the neural network for processing sequence data as claimed in any one of claims 21 to 25.
49. A circuit system, It is characterized in that The circuit system includes a processing circuit, which is configured to execute the steps performed by the text processing network as described in any one of claims 1 to 15, or the processing circuit is configured to execute the method as described in any one of claims 16 to 20, or the processing circuit is configured to execute the steps performed by the neural network for processing sequence data as described in any one of claims 21 to 25.
Citation Information
Patent Citations
Twitter semantic similarity analysis method based on character convolutional network
CN107506351A
Short text similarity calculation method based on multi-dimensional convolution feature
CN109299462A
Model training method, machine translation method and related devices and equipment
CN110162799A
Entity disambiguation method and device based on multiple languages, equipment and storage medium
CN110427612A
Commodity information classification method based on deep feature fusion model
CN110674305A
