Text processing method, apparatus, system, device, storage medium, and program
By converting text processing logic to compiled languages and integrating acceleration operators into deep learning frameworks, the method enhances natural language processing performance and reduces deployment costs, addressing inefficiencies in current frameworks.
Patent Information
- Application Number
- JP2022124589
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2021-12-10
- Filing Date
- 2022-08-04
- Publication Date
- 2024-09-18
- Estimated Expiration
- 2042-08-04
AI Technical Summary
Current deep learning frameworks face challenges in achieving high-performance training and inference for natural language processing tasks, particularly in industrial settings, due to complexities in transitioning between interpreted and compiled languages, leading to high development costs and inefficiencies in text processing and natural language generation.
The implementation of text processing acceleration operators that convert text processing logic from interpreted languages to compiled languages, utilizing multi-thread parallel acceleration and automatic operator generation, and integrating these operators into deep learning frameworks to optimize computational graphs for unified deployment and reduced deployment costs.
This approach significantly improves text processing speed and reduces deployment costs by up to 94% and accelerates training and inference speeds by over 200%, enabling efficient end-to-end natural language understanding and generation across various industrial applications.
Smart Images

Figure 0007553515000023 
Figure 0007553515000006 
Figure 0007553515000019
Abstract
Description
[Technical field]
[0001] The present disclosure relates to the field of computer technology, in particular to the field of artificial intelligence such as natural language processing and deep learning. [Background technology]
[0002] Natural Language Processing (NLP) is one of the application scenarios of deep learning frameworks. With the rapid popularization of pre-training model technology, the application paradigms of two important tasks, natural language understanding and generation, are gradually unified, and the requirements of developers and business scenarios for its performance and ease of use are gradually improving. Summary of the Invention [Problem to be solved by the invention]
[0003] The present disclosure provides a text processing method, apparatus, system, device and storage medium. [Means for solving the problem]
[0004] In one aspect of the present disclosure, there is provided a method of text processing, the method comprising: performing text processing on the first text using a text processing acceleration operator; and performing parallel acceleration on the post-text processing content using the text processing acceleration operator.
[0005] In another aspect of the present disclosure, there is provided a text processing apparatus, the apparatus comprising: The system includes a text processing module for performing text processing on a first text using a text processing acceleration operator, and a parallel acceleration module for performing parallel acceleration on a post-text processing content using the text processing acceleration operator.
[0006] In another aspect of the present disclosure, there is provided a system based on a deep learning framework, the system comprising: A text processing acceleration operator is provided for performing text processing on the first text and for performing parallel acceleration on the content after the text processing.
[0007] In another aspect of the present disclosure, there is provided an electronic device, the device comprising: The system comprises at least one processor and a memory communicatively connected to the at least one processor, the memory storing instructions executable by the at least one processor, the instructions, when executed by the at least one processor, causing a method of any one of the embodiments of the present disclosure to be performed.
[0008] Another aspect of the present disclosure provides a non-transitory computer-readable storage medium having computer instructions stored thereon, the computer instructions being adapted to cause the computer to perform a method according to any one of the embodiments of the present disclosure.
[0009] In another aspect of the present disclosure, there is provided a program, which when executed by a processor, implements the method of any one of the embodiments of the present disclosure.
[0010] It should be understood that the contents described herein are not intended to describe key points or important features of the embodiments of the present disclosure, nor are they used to limit the scope of the present disclosure. Other features of the present disclosure can be understood through the following specification. [Brief description of the drawings]
[0011] [Figure 1] FIG. 2 is a schematic diagram showing the flow of a text processing method according to an embodiment of the present disclosure. [Diagram 2] FIG. 11 is a schematic diagram showing the flow of a text processing method according to another embodiment of the present disclosure. [Diagram 3] FIG. 11 is a schematic diagram showing the flow of a text processing method according to another embodiment of the present disclosure. [Figure 4] FIG. 11 is a schematic diagram showing the flow of a text processing method according to another embodiment of the present disclosure. [Diagram 5] FIG. 11 is a schematic diagram showing the flow of a text processing method according to another embodiment of the present disclosure. [Figure 6] FIG. 11 is a schematic diagram showing the flow of a text processing method according to another embodiment of the present disclosure. [Figure 7] 1 is a schematic diagram showing a configuration of a text processing device according to an embodiment of the present disclosure. [Figure 8] FIG. 11 is a schematic diagram showing a configuration of a text processing device according to another embodiment of the present disclosure. [Figure 9] FIG. 11 is a schematic diagram showing a configuration of a text processing device according to another embodiment of the present disclosure. [Figure 10] FIG. 11 is a schematic diagram showing a configuration of a text processing device according to another embodiment of the present disclosure. [Figure 11] 1 is a schematic diagram showing a configuration of a system based on a deep learning framework according to an embodiment of the present disclosure. [Figure 12] FIG. 11 is a schematic diagram showing the configuration of a system based on a deep learning framework according to another embodiment of the present disclosure. [Figure 13] FIG. 11 is a schematic diagram showing the configuration of a system based on a deep learning framework according to another embodiment of the present disclosure. [Figure 14] FIG. 11 is a schematic diagram showing the configuration of a system based on a deep learning framework according to another embodiment of the present disclosure. [Figure 15] This is a schematic diagram showing the operatorization flow of end-to-end text processing. [Figure 16] FIG. 13 is a schematic diagram illustrating a configuration of an example of a Transformer encoder operator. [Figure 17a] FIG. 1 is a schematic diagram showing a decoder-type generative network. [Figure 17b] FIG. 2 is a schematic diagram showing a generative network of the prefix language model type. [Figure 17c] FIG. 2 is a schematic diagram showing an encoder-decoder type generative network. [Figure 18a] FIG. 13 is a schematic diagram when the decoding strategy is beam search. [Figure 18b] FIG. 13 is a schematic diagram when the decoding strategy is a sampling search. [Figure 19] This is a schematic diagram showing the flow of understanding the deep learning framework and combinatorial optimization of generative models. [Figure 20a] FIG. 1 is a schematic diagram showing the fusion flow of a Transformer encoder operator. [Figure 20b] FIG. 1 is a schematic diagram showing the fusion flow of a Transformer encoder operator. [Figure 20c] FIG. 1 is a schematic diagram showing the fusion flow of a Transformer encoder operator. [Figure 21a] FIG. 13 is a diagram illustrating an example of a comparison of text processing performance by framework. [Figure 21b] FIG. 13 illustrates an example of an improvement in training speed. [Figure 21c] FIG. 13 is a diagram illustrating an example of improvement in reasoning speed. [Figure 21d] FIG. 13 is a diagram illustrating an example of a comparison of conversion encoding speeds. [Figure 22] FIG. 1 is a schematic block diagram of an exemplary electronic device for implementing embodiments of the present disclosure. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0012] The accompanying drawings are provided for a better understanding of the present invention and are not intended to limit the present disclosure.
[0013] In the following, exemplary embodiments of the present disclosure will be described in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure for ease of understanding, but these should be considered as merely exemplary. Therefore, those skilled in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, in the following description, well-known functions and configurations are omitted for clarity and simplicity.
[0014] FIG. 1 is a schematic diagram showing a flow of a text processing method according to an embodiment of the present disclosure, In S101, performing text processing on a first text using a text processing acceleration operator; In S102, using the text processing acceleration operator to perform parallel acceleration on the post-text processing content.
[0015] Specifically, the first text may include specific content that needs to be processed further, for example, one or more string texts. A text acceleration processing operator, for example, a FasterTokenizerOperator, can perform a series of text processing on a plurality of string texts to obtain integer format content corresponding to each string text. The text acceleration processing operator can also perform parallel acceleration on the integer format content after the text processing. In this way, the text processing speed can be improved by performing text processing and parallel acceleration through the text acceleration processing operator.
[0016] 2 is a schematic diagram showing a flow of a text processing method according to another embodiment of the present disclosure. The text processing method of this embodiment may include one or more features of the above-mentioned method embodiments. In one embodiment, in S101, performing text processing on a first text using a text processing acceleration operator includes: In S201, obtaining a first tensor corresponding to the first text; In S202, performing a division on the first tensor to obtain a plurality of division results; In S203, performing identifier mapping for each of the division results; At S204, generating a second tensor using the mapping result.
[0017] Exemplarily, a tensor representation of the first text may be obtained through a first tensor operator, and the first text may be converted into the first tensor. A tensor is one of data structures in a neural network, and may be understood as a data container similar to a multidimensional array or a matrix. The first tensor may include a string tensor, and the string tensor may include one or more string texts (which may be abbreviated as strings) in the first text. For example, the first tensor may include N lines of strings split from the first text. The split operator may perform splitting on the first tensor, which may include performing splitting on the strings in the first tensor. Then, after the splitting results are respectively mapped by the mapping operator, the second tensor operator may obtain a second tensor based on the mapping results. The second tensor may include N lines of integer formatted numbers corresponding to the N lines of strings. In the embodiment of the present disclosure, the first tensor may be ordered for the text, which is advantageous for improving the accuracy of the processing results, and is advantageous for improving the processing speed by operationalizing the text processing process.
[0018] In one embodiment, in S202, performing division on the first tensor to obtain a plurality of division results includes: performing a character segmentation process on the first tensor to obtain a plurality of segmented characters; and performing a word segmentation process on the first tensor to obtain a plurality of segmented words.
[0019] For example, the character string “The air is good today” in the first tensor is split into characters using the split character operator to obtain the multiple split characters “ima”, “hi”, “ha”, “sky”, “ki”, “ga”, “i”, and “i”.
[0020] In addition, the character string "Let's go on a trip together" in the first tensor is subjected to word division processing using a divided word operator to obtain a plurality of divided words of this character string, "Together," "Go," and "Travel."
[0021] In the embodiment of the present disclosure, whether to perform character segmentation, word segmentation, or both character segmentation and word segmentation can be processed according to the needs of actual application scenarios, and there is no limitation thereto. In the embodiment of the present disclosure, it is advantageous to flexibly adapt to more text processing scenarios by performing character segmentation and / or word segmentation processing on the first tensor.
[0022] In one embodiment, performing identifier mapping for each of the segmentation results in S203 includes mapping each segmented character and / or segmented word to a numerical value based on a mapping relationship. For example, a dictionary, a thesaurus, etc. can be set as a mapping relationship in advance, and corresponding integer format numerical values can be found in the dictionary, a thesaurus, etc. In an embodiment of the present disclosure, finding corresponding numerical values of each character segment and / or word segment in the first tensor through the mapping relationship is advantageous for making machine processing easier and improving processing speed and accuracy.
[0023] In one embodiment, in S204, generating a second tensor using the mapping result includes obtaining numerical values for each row of the second tensor based on the mapping result of strings in each row of the first tensor, where the first tensor includes N rows of strings and the second tensor includes N rows of numerical values corresponding to the N rows of strings, where N is a positive integer.
[0024] For example, if the first tensor contains N rows of strings, the above mapping relationship can be used to find the corresponding numeric values of each row of strings to obtain N rows of numeric values. The matrix of the N rows of numeric values can be used as the second tensor. In the embodiment of the present disclosure, the second tensor can provide ordering to the numeric values obtained from the first text transformation, facilitating subsequent accelerated processing.
[0025] In one embodiment, the first text includes a string, the first tensor is a string tensor, the second tensor is an integer tensor, and the numerical values of each row of the second tensor correspond to the strings of each row of the first tensor. In an embodiment of the present disclosure, the first tensor orders the strings, and the second tensor orders the integer numerical values obtained by the string conversion, to facilitate subsequent accelerated processing.
[0026] In one embodiment, in S102, performing parallel acceleration on post-text processing content using the text processing acceleration operator includes: In S205, the method includes using multiple threads to perform parallel processing on the second tensor. For example, multiple threads can be invoked by a multi-thread parallel acceleration operator, and multiple rows of the second tensor can be processed in parallel, where each thread can process one row of the second tensor. In the embodiment of the present disclosure, the multi-threading can greatly improve the text processing speed, and a high-performance character codec can be easily realized. In general, the more threads that can be invoked simultaneously, the faster the parallel processing speed.
[0027] In one embodiment, the text processing is converted from execution in a first language to execution in a second language. In the embodiment of the present disclosure, by converting the text processing from execution in a first language to execution in a second language, multi-thread parallel acceleration can be utilized, which is advantageous for flexibly adapting to different language environments, and can further improve the processing speed.
[0028] In one embodiment, the first language is an interpreted language, and the second language is a compiled language. For example, a text processing flow originally executed by an interpreted language is converted to execution by a compiled language, and parallel acceleration is realized by utilizing the feature that the compiled language can call multithreads. Specifically, for example, the interpreted language includes Python, Java (registered trademark), etc., and the compiled language includes C++, etc. The interpreted language and the compiled language may be of a type other than the above examples, and are not limited here. This allows flexible adaptation to different language environments, reduces the difficulty of development, and improves the processing speed by the compiled language.
[0029] 3 is a schematic diagram showing the flow of a text processing method according to another embodiment of the present disclosure. The text processing method of this embodiment may include one or more features of the above-mentioned method embodiments. In one embodiment, the method includes: In S301, the method further includes using a natural language understanding model to perform natural language understanding processing on the content accelerated by the text processing acceleration operator. In an embodiment of the present disclosure, the text processing acceleration operator is applied to the natural language understanding model to accelerate the processing speed of natural language understanding.
[0030] In one embodiment, the natural language understanding model includes the text processing acceleration operator and a transform encoder operator. In this embodiment, the specific function of the text processing acceleration operator can refer to the description of the embodiment in FIG. 1 and FIG. 2. For example, the multi-thread parallel acceleration operator in the text processing acceleration operator reads a numerical value from the second tensor in parallel, and then transmits it to a transform encoder operator, and the transform encoder operator can perform string encoding on the received numerical value. The transform encoder operator can include a multi-layer transform encoder. In the embodiment of the present disclosure, the text processing acceleration operator and the transform encoder operator can perform natural language understanding processing quickly and accurately.
[0031] In one embodiment, the transform encoder operator includes a fused attention mechanism operator and a fused feedforward operator.
[0032] For example, the fused attention mechanism operator can reduce the number of OPs in the attention mechanism. Specifically, for example, General Matrix-matrix Multiplication (GEMM), bias add, transpose, etc. in the multi-head attention mechanism can be reduced from 3 to 1, improving data reuse and obtaining a fused attention mechanism operator.
[0033] You can also fuse Kernels to get Fused Feedforward operators, such as FusedDropoutActBias, FusedLnAddDropoutBias, and FusedAddDropoutBias.
[0034] In the embodiments of the present disclosure, the fused attention mechanism operator can reduce framework scheduling overhead, and the fused feedforward operator can reduce memory access overhead.
[0035] In one embodiment, the method comprises: In S302, the method further includes using a natural language generation model to perform natural language generation processing on the content processed by the natural language understanding model. For example, after a conversion encoder operator of the natural language generation model outputs a natural language understanding result, the natural language generation model uses a decoder to perform processing such as decoding and prediction on the natural language generation model to obtain a natural language generation result. In an embodiment of the present invention, the natural language generation model can accurately predict the generation result based on the natural language understanding result.
[0036] In one embodiment, the natural language generation model includes a transformer decoder operator and a decoding strategy operator. In an embodiment of the present disclosure, the natural language generation model can perform natural language generation processing quickly and accurately through the transformer decoder operator and the decoding strategy operator.
[0037] In one embodiment, in S302, using a natural language generation model to perform natural language generation processing on the content after processing by the natural language understanding model includes identifying a decoder code characteristic using the conversion decoder operator to identify a generative network type used, and invoking a pre-configured decode operator corresponding to the generative network type.
[0038] For example, a high-performance decoding operator can be pre-configured for various generative network types. When a user selects a certain type of decoder code, the transform decoder operator can identify the type of generative network used by the user based on the decoder code. The transform decoder operator can then call the pre-configured high-performance decoding operator corresponding to the identified generative network type. Thus, the embodiments of the present disclosure can support multiple generative network types, and thus more decoding capabilities.
[0039] In one embodiment, the generating network type is: Decoder type, A prefix language model (LM type), Encoder-Decoder type and Includes at least one of the following:
[0040] For example, a Decoder type generator network may include a decoder layer and a Transformer layer, etc. Also, a Prefix LM type generator network may include a Prefix LM layer and a Transformer layer, etc. As another example, an Encoder-Decoder type generator network may include a decoder layer, a Transformer layer, an encoder-decoder layer, and an encoder layer, etc. In the embodiments of the present disclosure, richer decoding capabilities are provided by supporting more comprehensive generator network types.
[0041] In one embodiment, in S302, using a natural language understanding model to perform natural language generation processing on the content after processing by the natural language understanding model includes using the decoding strategy operator to identify a decoding strategy characteristic to identify a decoding algorithm used, and using the decoding algorithm to automatically translate loop code executed in a first language into code in a second language.
[0042] For example, when a certain decoding algorithm is selected by a user, the decoding strategy operator can identify the decoding strategy characteristics and identify the encryption algorithm used by the user, and then automatically translate the loop code executed on the first language into the code of the second language. Referring to the above example, the first language may be an interpreted language, and the second language may be a compiled language. Using the identified decoding algorithm, the loop code executed on the interpreted language can be automatically translated into the code of the compiled language. This has the effect of automatically performing code conversion between different languages, improving the performance of natural language generation processing, and reducing the difficulty of development.
[0043] In one embodiment, the decoding algorithm comprises: A search-based decoding algorithm; A sampling-based decoding algorithm; Includes at least one of the following:
[0044] For example, search-based decoding algorithms can include greedy search, beam search, etc. Here, greedy search predicts the most likely word at each step and uses that word as the input for the next prediction. Beam search prepares the input grammar sentence in advance with an encoder-decoder, outputs the most likely probability value of the first word, and further considers what the second word is for each selected possible first word.
[0045] As another example, the sampling-based decoding algorithm may include random sampling, Top-K Sampling, and Top-P (nucleus) Sampling. Here, random sampling may include random sampling to determine what the next word will be generated based on the probability distribution for the entire thesaurus of the next word obtained by the language model. Top-K Sampling may include taking the K most probable words, then normalizing the probabilities of the K words before sampling. Top-P Sampling may include accumulating the probabilities of all current words in descending order, and if the accumulated value is greater than a threshold value P, not using the subsequent less probable words, and re-sampling the previous word.
[0046] In the embodiments of the present disclosure, different decoding algorithms can support richer automatic decoding functions and improve transcoding performance.
[0047] In one embodiment, in S302, performing natural language generation processing on the content after processing by the natural language understanding model further includes invoking an on-the-fly compilation capability of a deep learning framework to compile the second language code to obtain a dynamic link library, and linking the dynamic link library with the deep learning framework.
[0048] Referring to the above example, the second language may be a compiled language, and the instant compilation capability of the deep learning framework can be invoked to automatically compile the code of the compiled language to obtain a dynamic link library, and the deep learning framework can be further linked with the dynamic link library to obtain a high-performance transform decoder operator.
[0049] 4 is a schematic diagram showing the flow of a text processing method according to another embodiment of the present disclosure. The text processing method of this embodiment may include one or more features of the above-mentioned method embodiments. In one embodiment, the method further includes the following steps:
[0050] In S401, the thesaurus of the text processing acceleration operator is derived. For example, the thesaurus of the text processing acceleration operator may include a mapping relationship between each word and a numerical value used by the text processing acceleration operator. The thesaurus of the text processing acceleration operator used may be different for each natural language understanding model, or may be partially or entirely the same, and is determined according to the specific function that the natural language understanding model needs to specifically realize. In the embodiment of the present disclosure, the thesaurus of the text processing acceleration operator can be repeatedly used after it is derived, which helps to improve the speed of subsequent deployment and reduce the difficulty of deployment.
[0051] In one embodiment, the method may further include at least one of the following:
[0052] In S402, the derived thesaurus is stored in a binary serialized format.
[0053] In S403, a compression algorithm is used to compress and store the derived thesaurus.
[0054] Serialization and storage are advantageous in improving the speed of reading the thesaurus and in improving the speed of text processing, whereas compression and storage are advantageous in reducing the storage capacity occupied by the thesaurus and in saving storage resources.
[0055] 5 is a schematic diagram showing the flow of a text processing method according to another embodiment of the present disclosure. The text processing method of this embodiment may include one or more features of the above-mentioned method embodiments. In one embodiment, the method further includes the following steps:
[0056] In S501, the text processing acceleration operator and the transform encoder operator are integrated into one operator to derive a natural language understanding model computation graph.
[0057] In an embodiment of the present disclosure, the computation graph can be a directed graph, and the nodes therein can correspond to mathematical operations. The computation graph can be a way of expressing and evaluating mathematical expressions. In an embodiment of the present disclosure, integrating the text processing acceleration operator and the transform encoder operator into the natural language understanding model computation graph is advantageous for accelerating the speed of natural language understanding and obtaining accurate natural language understanding results.
[0058] 6 is a schematic diagram showing the flow of a text processing method according to another embodiment of the present disclosure. The text processing method of this embodiment may include one or more features of the above-mentioned method embodiments. In one embodiment, the method further includes the following steps:
[0059] In S601, a framework computation graph of loop decoding is generated according to a decoding strategy.
[0060] In S602, a transform decoder operator is embedded in the loop decoding framework computation graph.
[0061] In S603, a natural language generation model computation graph is derived.
[0062] For example, first, a framework computation graph for loop decoding (which can be abbreviated as a decoding framework computation graph) is generated according to a decoding strategy, and the decoding framework computation graph mainly includes a loop flow chart. Then, the decoding framework computation graph is supplemented with a decoder computation structure. For example, the decoder computation structure can include a generation network structure obtained by identifying the decoder code characteristics with a transform decoder operator.
[0063] In an embodiment of the present disclosure, embedding the transformation decoder operator into the decoding framework computation graph enables the natural language generation model computation graph to be derived quickly, which is advantageous in reducing the difficulty of subsequent deployment and improving the speed of deployment.
[0064] In one embodiment, the method further includes deriving a natural language processing integrated computation graph including an integrated computation graph of a natural language understanding model computation graph and a natural language generation model computation graph, where the natural language understanding model computation graph includes a text processing acceleration operator and a transformation encoder operator, and the natural language generation model computation graph includes a transformation decoder operator and a decoding strategy operator, where the integrated computation graph can include operators of the natural language understanding model computation graph and operators of the natural language generation model computation graph.
[0065] In the embodiments of the present disclosure, by deriving an integrated computation graph, unified preservation can be realized, the derivation method is simple, and the derived computation graph can support rich natural language understanding and generation functions.
[0066] In one embodiment, the method further includes introducing at least one of the natural language understanding model computation graph, the natural language generation model computation graph, and the integrated computation graph into a deep learning framework of multiple devices, which is advantageous for realizing one-time derivation, many-deployment, and can meet the need for unified deployment for training and inference integration of multiple devices.
[0067] FIG. 7 is a schematic diagram showing a configuration of a text processing device according to an embodiment of the present disclosure. a text processing module 701 for performing text processing on a first text using a text processing acceleration operator; A parallel acceleration module 702 for performing parallel acceleration on post-text processing content using the text processing acceleration operator.
[0068] In embodiments of the present disclosure, text processing speed can be improved by processing and accelerating text with text acceleration operators.
[0069] 8 is a schematic diagram showing the configuration of a text processing device according to another embodiment of the present disclosure. The text processing device of this embodiment may include one or more features of the device embodiments described above. In one embodiment, the text processing module 701: a first tensor submodule 801 for obtaining a first tensor corresponding to the first text; A splitting submodule 802 for performing splitting on the first tensor to obtain a plurality of splitting results; a mapping submodule 803 for performing identifier mapping for each of the segmentation results; and a second tensor sub-module 804 for generating a second tensor using the mapping result.
[0070] In one embodiment, the segmentation submodule 802 is specifically used for performing at least one of: performing a character segmentation process on the first tensor to obtain a plurality of segmented characters; and performing a word segmentation process on the first tensor to obtain a plurality of segmented words.
[0071] In one embodiment, the mapping sub-module 803 is specifically used for mapping each divided character and / or divided word to a numerical value according to a mapping relationship.
[0072] In one embodiment, the second tensor submodule 804 is specifically used for obtaining numerical values of each row of the second tensor based on a mapping result of the strings of each row of the first tensor, where the first tensor includes N rows of strings, and the second tensor includes N rows of numerical values corresponding to the N rows of strings, where N is a positive integer.
[0073] In one embodiment, the first text includes a string, the first tensor is a string tensor, the second tensor is an integer tensor, and the numerical values of each row of the second tensor correspond to the strings of each row of the first tensor.
[0074] In one embodiment, the parallel acceleration module 702 is specifically used to perform parallel processing on the second tensor using multithreading.
[0075] In one embodiment, text processing by the text processing module 701 is converted from a first language implementation to a second language implementation.
[0076] 9 is a schematic diagram showing the configuration of a text processing device according to another embodiment of the present disclosure. The text processing device of this embodiment may include one or more features of the above-mentioned device embodiments. In one embodiment, the device further includes a natural language understanding module 901 for performing natural language understanding processing on the content accelerated by the text processing acceleration operator using a natural language understanding model.
[0077] In one embodiment, the natural language understanding model includes the text processing acceleration operator and a transform encoder operator.
[0078] In one embodiment, the transform encoder operator includes a fused attention mechanism operator and a fused feedforward operator.
[0079] In one embodiment, the apparatus further comprises a natural language generation module 902 for performing natural language generation processing on the content after it has been processed by the natural language understanding model using a natural language generation model.
[0080] In one embodiment, the natural language generation model includes a transform decoder operator and a decoding strategy operator.
[0081] In one embodiment, the natural language generation module 902 includes a transformation decoding submodule 9021 for identifying decoder code characteristics and invoking a pre-configured decoding operator corresponding to the generative network type used using the transformation decoder operator to identify the generative network type used.
[0082] In one embodiment, the generating network type is: Decoder type, A prefix language model (LM type), Encoder-Decoder type and Includes at least one of the following:
[0083] In one embodiment, the natural language generation module 902 includes a decoding strategy submodule 9022 for identifying a decoding strategy characteristic using the decoding strategy operator to identify a decoding algorithm used, and for automatically translating loop code executed in a first language into code in a second language using the decoding algorithm.
[0084] In one embodiment, the decoding algorithm comprises: A search-based decoding algorithm; A sampling-based decoding algorithm; Includes at least one of the following:
[0085] In one embodiment, the natural language generation module 902 further includes a compilation submodule 9023 for invoking an on-the-fly compilation capability of a deep learning framework to compile the second language code to obtain a dynamic link library and link the dynamic link library with the deep learning framework.
[0086] In one embodiment, the first language is an interpreted language and the second language is a compiled language.
[0087] 10 is a schematic diagram showing the configuration of a text processing device according to another embodiment of the present disclosure. The text processing device of this embodiment can include one or more features of the device embodiments described above. In one embodiment, the device further comprises a first derivation module 1001 for deriving a thesaurus of text processing acceleration operators.
[0088] In one embodiment, the apparatus comprises: storing the derived thesaurus in a binary serialized form; and compressing and storing the derived thesaurus using a compression algorithm; The present invention further includes a storage module 1002 for use in at least one of the following:
[0089] In one embodiment, the apparatus further comprises a second derivation module 1003 for integrating the text processing acceleration operator and the transform encoder operator into one operator and deriving a natural language understanding model computation graph.
[0090] In one embodiment, the apparatus further includes a third derivation module 1004 for generating a loop decoding framework computation graph according to a decoding strategy, embedding a transformation decoder operator in the loop decoding framework computation graph, and deriving a natural language generation model computation graph.
[0091] In one embodiment, the apparatus further comprises a fourth derivation module 1005 for deriving a natural language processing integrated computation graph, the natural language understanding model computation graph including an integrated computation graph of a natural language understanding model computation graph and a natural language generation model computation graph, where the natural language understanding model computation graph includes a text processing acceleration operator and a transformation encoder operator, and the natural language generation model computation graph includes a transformation decoder operator and a decoding strategy operator.
[0092] In one embodiment, the apparatus further comprises a deployment module 1006 for deploying at least one of the natural language understanding model computation graph, the natural language generation model computation graph, and the integrated computation graph into a deep learning framework of multiple devices.
[0093] For specific functions and examples of each module of the text processing device according to the embodiment of the present disclosure, reference may be made to the description of the embodiment of the text processing method described above, and therefore no further description will be given here.
[0094] 11 is a schematic diagram illustrating a system based on a deep learning framework according to an embodiment of the present disclosure, including a text processing acceleration operator 1001 for performing text processing on a first text and performing parallel acceleration on the content after the text processing.
[0095] In embodiments of the present disclosure, text processing and acceleration by text acceleration processing operators can improve the text processing speed of systems based on deep learning frameworks.
[0096] 12 is a schematic diagram showing the configuration of a system based on a deep learning framework according to another embodiment of the present disclosure. The system based on the deep learning framework of this embodiment may include one or more features of the above-mentioned system embodiments. In one embodiment, the text processing acceleration operator 1101 includes: a first tensor operator 1201 for obtaining a first tensor corresponding to the first text; a partition operator 1202 for partitioning the first tensor to obtain a plurality of partition results; a mapping operator 1203 for performing identifier mapping for each of the partitioned results; A second tensor operator 1204 for generating a second tensor using the mapping result.
[0097] In one embodiment, the split operator 1202 is specifically
[0098] performing a character segmentation process on the first tensor to obtain a plurality of segmented characters; performing a word segmentation process on the first tensor to obtain a plurality of segmented words; The present invention is used to perform at least one of the following:
[0099] In one embodiment, the mapping operator 1203 is specifically used to map each divided character and / or divided word to a numerical value based on a mapping relationship.
[0100] In one embodiment, the second tensor calculator 1204 is specifically used for obtaining numerical values of each row of the second tensor based on a mapping result of the strings of each row of the first tensor, where the first tensor includes N rows of strings, and the second tensor includes N rows of numerical values corresponding to the N rows of strings, where N is a positive integer.
[0101] In one embodiment, the first text includes a string, the first tensor is a string tensor, the second tensor is an integer tensor, and the numerical values of each row of the second tensor correspond to the strings of each row of the first tensor.
[0102] In one embodiment, the text processing acceleration operator 1101 further comprises a multi-threaded parallel acceleration operator 1205 for performing parallel processing on the second tensor using multiple threads.
[0103] In one embodiment, the first tensor operator, the decomposition operator, the mapping operator, and the second tensor operator are implemented in a first language, and the multi-threaded parallel acceleration operator is implemented in a second language.
[0104] 13 is a schematic diagram illustrating a configuration of a system based on a deep learning framework according to another embodiment of the present disclosure. The system based on the deep learning framework of the embodiment may include one or more features of the above-mentioned system embodiments. In one embodiment, the system further includes a natural language understanding model 1301 for performing natural language understanding processing on the content accelerated by the text processing acceleration operator.
[0105] In one embodiment, the natural language understanding model includes the text processing acceleration operator 1101 and a transform encoder operator 1102 .
[0106] In one embodiment, the transform encoder operator 1102 includes a fused attention mechanism operator and a fused feedforward operator.
[0107] In one embodiment, the system further comprises a natural language generation model 1302 for performing natural language generation processing on the content after it has been processed by the natural language understanding model.
[0108] In one embodiment, the natural language generation model 1302 includes a transform decoder operator 13021 and a decoding strategy operator 13022 .
[0109] In one embodiment, the transform decoder operator 13021 comprises: Identifying decoder code characteristics to identify the type of generative network used; It is used to invoke a pre-configured decoding operator corresponding to the generating network type.
[0110] In one embodiment, the generating network type is: Decoder type, A prefix language model (LM type), Encoder-Decoder type and Includes at least one of the following:
[0111] In one embodiment, the decoding strategy operator 13022 is Identifying a decoding strategy characteristic, such as identifying the decoding algorithm used; The decoding algorithm is used to automatically translate loop code executed in a first language into code in a second language.
[0112] In one embodiment, the decoding algorithm comprises: A search-based decoding algorithm; A sampling-based decoding algorithm; Includes at least one of the following:
[0113] In one embodiment, the natural language generation model further includes a compilation operator 13023 for invoking an on-the-fly compilation capability of a deep learning framework to compile the second language code into a dynamic link library and link the dynamic link library with the deep learning framework.
[0114] In one embodiment, the first language is an interpreted language and the second language is a compiled language.
[0115] 14 is a schematic diagram showing the configuration of a system based on a deep learning framework according to another embodiment of the present disclosure. The system based on the deep learning framework of this embodiment may include one or more features of the above-mentioned system embodiments. In one embodiment, the system further includes a first derivation module 1401 for deriving a thesaurus of the text processing acceleration operator.
[0116] In one embodiment, the system comprises: storing the derived thesaurus in a binary serialized form; and compressing and storing the derived thesaurus using a compression algorithm; The method further includes a storage module 1402 for executing at least one of the following:
[0117] In one embodiment, the system further comprises a second derivation module 1403 for integrating the text processing acceleration operator and the transform encoder operator into one operator and deriving a natural language understanding model computation graph.
[0118] In one embodiment, the system further includes a third derivation module 1404 for generating a loop decoding framework computation graph according to a decoding strategy, embedding a transformation decoder operator in the loop decoding framework computation graph, and deriving a natural language generation model computation graph.
[0119] In one embodiment, the system further comprises a fourth derivation module 1405 for deriving a natural language processing integrated computation graph, the natural language processing integrated computation graph including a computation graph in which a natural language understanding model computation graph and a natural language generation model computation graph are integrated.
[0120] Here, the natural language understanding model computation graph includes a text processing acceleration operator and a transformation encoder operator, and the natural language generation model computation graph includes a transformation decoder operator and a decoding strategy operator.
[0121] In one embodiment, the system further comprises a deployment module 1406 for deploying at least one of the natural language understanding model computation graph, the natural language generation model computation graph, and the integrated computation graph into a deep learning framework of multiple devices.
[0122] For specific functions and examples of each operator and / or module of the system based on the deep learning framework of the embodiment of the present disclosure, please refer to the relevant descriptions in the embodiment of the text processing method described above, and no further mention will be made here.
[0123] When current deep learning frameworks solve the problem of model pre-training for application in NLP scenarios, there is still much room for improvement in training and inference performance, and the development experience shows a discrepancy between training and deployment, which increases the costs of application and deployment in real industrial scenarios.
[0124] Deep learning frameworks such as PyTorch perform processing outside the framework using an interpreted language (e.g., Python), and the deep learning framework focuses on high-performance computation of the deep learning model, such as the DNN (Deep Neural Networks) model, the Transformer model, the ERNIE (PaddlePaddle Semantic Understanding Framework) model, and the BERT (BiDirectional Encoder Representation From Transformers) part. However, for industrial scenes such as Internet companies, in pursuit of ultimate performance and cost, when the model needs to be deployed online, a compiled language (e.g., C++) is selected and used to achieve end-to-end development for the model. At this time, it is necessary to realize the logic of the text processing part on the C++ side. If the deep learning framework only performs C++ inference on a pre-trained model such as (DNN / Transformer / BERT / ERNIE), the developer needs to rewrite the complex text processing logic in Python into a C++ version and rigorously align and test it. With the transition of models and application scenarios, the flow of text processing changes significantly (for example, the transition from text classification to machine translation, the two text processing logics are completely different), the development cost is very high, and it is easy to encounter detailed problems such as coding, which leads to errors and inconsistencies in the online deployment effect. For example, the text processing module that refers to the BERT model for learning and inference does not have a C++ version, but uses a pure Python version of processing separated from the TensorFlow framework.
[0125] Some frameworks have complex implementation logic for text processing (Tokenizer part), high development costs, and many are implemented in interpreted languages (e.g., Python), resulting in relatively low implementation performance. In addition, they are limited to interpreted languages, making multi-threaded parallel acceleration difficult. For this reason, the embodiments of the present disclosure propose a flow of text processing automatic operators, which can provide text processing operators for pre-trained models within the framework, and can realize multi-threaded parallel acceleration using compiled languages.
[0126] For natural language generation models, due to the complexity of the decoding strategy, many frameworks perform loops for decoding on interpreted languages, which generates a large amount of framework scheduling overhead, resulting in low GPU utilization and slow text generation speed. Therefore, the embodiments of the present disclosure propose an acceleration process, such as automatic generation of network identification, decoding strategy identification, compiled code generation, and on-the-fly compilation.
[0127] Other NLP frameworks have a complicated industrial-level deployment process and a relatively high cost. For this reason, the embodiment of the present disclosure performs derivation deployment for the NLP model, and can derive the text processing operator part by fusing it with the computation graph, and proposes a process including the federated derivation of text processing, natural language understanding, and generative computation graphs, thereby reducing the deployment cost.
[0128] In the embodiments of the present disclosure, a method and a system are provided that rely on a deep learning framework, such as the Baidu PaddlePaddle deep learning framework, which is a set of efficient development, training and inference to meet two important application scenarios of natural language understanding and generation. Aspects of the embodiments of the present disclosure can be widely applied to various industrialized fields of natural language processing, such as text classification, sequence labeling, machine translation, text generation, reading comprehension, and general dialogue.
[0129] An embodiment of the present disclosure proposes the following application flow for application features in a deep learning framework for natural language processing, including at least one of end-to-end text processing operatorization, joint acceleration of natural language understanding models and generative models, and an integrated deployment scheme of training and inference.
[0130] Flow of end-to-end text processing operations in deep learning frameworks
[0131] For features that can be accelerated using tensors in the overall deep learning framework, a tensor representation set for the raw text type is provided. This method combines the code generation (Code Gen) principle of compiler technology with the string tensor protocol to automatically fuse low-performance processes realized on interpreted languages (e.g., Python) and automatically generate corresponding high-performance C++ code. For example, automatic parallelization by a central processing unit (CPU) high-performance acceleration library such as MKLDNN has reached approximately 100 times the realization speed of conventional interpreted (e.g., Python) code. Exemplarily, the above low-performance processes can include multiple complex text processing processes such as the functions of fine-grained modules such as a basic word segmentation module and an identifier (ID) mapping module.
[0132] As shown in FIG. 15, this is an operatorization process of deep learning end-to-end text processing, which can automatically operatorize text processing and accelerate parallelization by multithreading. For example, in automatic operatorization of text processing, first, a string tensor operator converts the original string text (String Text) into a string tensor (String Tensor), and a division operator performs character division on the string tensor using a basic character division module. Then, a mapping operator performs ID mapping on each character division result, respectively, to obtain an integer type numerical value corresponding to each character division result, and further, an integer tensor operator obtains an integer tensor (Integer Tensor) using a normal value corresponding to the original string. Integer tensors can be parallelized by multithreading. The automatic operatorization process of text processing can realize the above text processing and parallel acceleration by, for example, an accelerated word divider operator (FasterTokenizer Operator), and converts the basic text processing function realized when executing an interpreter-type language to be realized when executing a compiled language, and significantly improves the text processing speed by utilizing the feature of the compiled language that allows multithread parallel processing. The accelerated word splitter operator may also be referred to as an accelerated word splitter, an accelerated word splitter, a word splitter, or the like.
[0133] Accelerate processes with natural language understanding and automated task generation
[0134] Regarding the type of natural language understanding model, it is mainly a Transformer Encoder (may be abbreviated as transform encoder) type based on a transformation model.
[0135] As shown in FIG. 16, it is a schematic diagram of a transformer encoder structure. The transformer encoder can include Add&Norm and Feed Forward. By way of example, the types of natural language generation models, depending on the encoder type, can include the following:
[0136] As a pure decoder type, as shown in Fig. 17a, a pure decoder type natural language generation model can include a transformer layer, a decoder layer, and a transformer layer. A representative model structure of a pure decoder type is, for example, a generative pre-training (GPT) model.
[0137] As for the prefix language model (Prefix LM) type, as shown in Fig. 17b, a pure prefix LM type natural language generation model can include a Transformer layer, a prefix LM layer, and a Transformer layer. Representative models of the prefix LM type include the Unified Language Model (UniLM) and the PLATO model (a type of general-domain dialogue generation pre-training model).
[0138] As shown in Fig. 17c, the Encoder-Decoder type natural language generation model can include a Transformer layer, a Decoder layer, a Transformer layer, an Encoder-Decoder layer, a Transformer layer, an Encoder-Decoder layer, a Transformer layer, an Encoder layer, an Encoder layer, an Encoder layer, and a Transformer layer. A representative model of the Encoder-Decoder type is the BART (Bidirectional and Auto-Regressive Transformers) model.
[0139] By way of example, the generated decoding strategies may include the following types:
[0140] Search-based decoding algorithms include, for example, Beam Search, Greedy Search, Diverse Sibling Search, etc. As shown in Figure 18a, this is an example of Beam Search. The input grammar sentence is first given using the encoder-decoder to find the most likely probability value of the first word, for example, the probability from word 1 to word 2 is 0.4, the probability from word 3 to word 4 is 0.5, and the probability from word 4 to word 5 is 0.1. Then, for each selected first possible word, consider what the second word is. For example, the probability from word 2 to word 5 is 0.05, the probability from word 6 is 0.05, the probability from word 7 is 0.9, the probability from word 3 to word 8 is 0.4, the probability from word 9 is 0.4, the probability from word 10 is 0.3, the probability from word 4 to word 11 is 0.3, the probability from word 12 is 0.5, and the probability from word 13 is 0.2.
[0141] A sample-based decoding module, such as Top-K Sampling, Top-P Sampling, etc. As shown in FIG. 18(b), this is an example of a sampling search.
[0142] In an embodiment of the present disclosure, as shown in FIG. 19, a process for integrated acceleration of both a natural language understanding model (abbreviated as understanding module) and a natural language generation model (abbreviated as generation module) is provided, which may include the following parts:
[0143] 1. As shown in FIG. 19, accelerated optimization for the understanding model Transformer encoder may include the following steps:
[0144] In S11, for an original text, for example, a string text, the framework can automatically insert a FasterTokenizer Operator to process the original text with high performance.
[0145] In S12, a multi-layer Transformer encoder is invoked to encode the string.
[0146] Illustratively, optimizations for the encoder within the understanding model can include attention mechanism fusion and feedforward fusion.
[0147] (1) To reduce the overhead of framework scheduling, fusion optimization can be performed on the multi-head attention mechanism during the encoding process. For example, the number of operators can be reduced by 1 / 3, as shown in Figures 20a, 20b, and 20c, by reducing GEMM, bias add, transpose, etc. in the multi-head attention mechanism from 3 to 1, improving the data reuse rate and obtaining a fused attention operator.
[0148] (2) Optimize the Feedforward layer by fusing. For example, as shown in Figure 20c, by fusing three traditional GPU kernel operators into one, the fused operators can include FusedDropoutActBias, FusedLnAddDropoutBias, FusedAddDropoutBias, etc., and a fused Feedforward operator is obtained. For example, the access operation overhead can be significantly reduced by 2x, from 8 load / store to 4 load / store.
[0149] 2. Accelerated optimization of the Transformer decoder in the generative model. See also Figures 20a, 20b and 20c. For example, the accelerated optimization process can include the following steps:
[0150] In S21, the generating network type is identified and a threshold decoding operator is called. Specifically, the multi-layer Transformer decoder operator can identify the user decoder code characteristic and classify the generating network type, for example, according to the types shown in Figure 17a, Figure 17b and Figure 17c, the user decoder code characteristic may be identified as any one of these three types of generating networks. Then, the pre-configured high-performance decoding operator corresponding to the identified generating network can be automatically launched and calculated.
[0151] In S22, the decoding strategy is recognized and a compiled language is automatically generated. Specifically, the decoding strategy operator can identify the user decoding strategy characteristics and determine whether the user decoding strategy is a search-based algorithm or a sampling-based algorithm. For the difference between the search-based algorithm and the sampling-based algorithm, the loop code in the interpreted language can be automatically translated into the code of the compiled language to improve the performance.
[0152] In S23, the framework automatically compiles on the fly and automatically generates and links operators. For example, the just-in-time compiler capability of a deep learning framework such as the PaddlePaddle framework is invoked to obtain a high-speed dynamic link library and a high-performance decoder operator is obtained by linking.
[0153] The process is repeated N times until the text generation is completed.
[0154] 3. The deployment flow of the integrated training and inference deployment plan for understanding model and generative model may include the following parts:
[0155] The first part is the derivation of the understanding model, which can include the following steps: In S1.1, we first need to derive the thesaurus in the word splitter and store it in a binary serialized format. In (optional) S1.2, we can also use a set of compression algorithms on the textual properties of the thesaurus to reduce the storage of the thesaurus file. In S1.3, we combine the word splitter and the multi-layer Transformer encoder into one operator and derive the overall understanding model computation graph.
[0156] The second part is the derivation of a generative model, which may include the following steps: In S2.1, a loop decoding framework computation graph (which may be abbreviated as a loop framework computation graph) is first generated based on the decoding strategy; in S2.2, the operators of the multi-layer Transformer decoder are embedded into the loop framework computation graph, which is the decoding strategy loop; in S2.3, a generative model computation graph is generated.
[0157] The third part integrates the computation graph according to business needs. If only the natural language understanding part is needed, only the understanding model computation graph is needed. If the generative model part computation graph is needed, the understanding model computation graph and the generative model computation graph can be integrated into one computation graph, which meets the needs of integrated and unified deployment of training and inference for multiple devices.
[0158] The solution of the embodiments of the present disclosure can effectively improve the training model speed, inference speed and deployment cost of the entire scene application of natural language understanding, and achieve an integrated deployment experience of training and inference.
[0159] FIG. 21a shows a graph comparing the text processing performance of different frameworks. The high-speed word segmentation method (the present method) can greatly exceed the text processing speed of other frameworks. The present method may be, for example, Paddle FasterTokenizer. Comparison method 1 is HuggingFace Tokenizers (Rust), comparison method 2 is HuggingFace Tokenizers (Python), and comparison method 3 is TensorFlow Text.
[0160] The model forward calculation of this scheme supports input of original text, and text processing and model calculation support derivation of the entire graph. The training speed and inference speed of this scheme can be accelerated by more than 200% compared with the conventional method, and the inference speed is improved by 160%, as shown in Figure 21b and Figure 21c.
[0161] The cost of simultaneous deployment can reduce the amount of code by 94% compared to the non-integrated training and inference version. For example, the C++ deployment code is reduced from over 800 lines to 48 lines.
[0162] Referring to FIG. 21d, it can be seen that for generative tasks such as machine translation, when using the strategy of optimizing by combining the generative model and the understanding model according to this method, the acceleration ratio is improved by up to 10 times or more compared to the native realization of the same framework, such as PyTorch.
[0163] The embodiments of the present disclosure propose an overall flow development paradigm in the overall application scene of natural language understanding and natural language generation centered on deep learning frameworks, which can greatly improve the performance of model training and inference and reduce deployment costs. Taking advantage of the characteristics of deep learning tensorization computation, a compiled language is automatically generated for the text processing flow of an interpreted language, and the ability of parallel acceleration is tensorized. The operators of the computation graphs of natural language understanding and generation are fused and optimized, reducing the overhead of framework scheduling and access memory, and greatly improving performance. The computation graphs of text processing, natural language understanding, and natural language generation are jointly derived, the overall flow is integrated and saved, and one-time derivation is deployed to multiple places, forming a distinctive development experience in which training and inference are integrated, and reducing deployment costs.
[0164] In the technical solutions disclosed herein, the acquisition, storage, application, etc. of relevant users' personal information are all in accordance with the provisions of relevant laws and regulations and are not contrary to public order and morals.
[0165] According to an embodiment of the present disclosure, the present disclosure further provides an electronic device, a readable storage medium, and a computer program product.
[0166] 22 is a block diagram of an exemplary electronic device 2200 for implementing embodiments of the present disclosure. The electronic device refers to any type of digital computer, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device also refers to any type of mobile device, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components, their connections, and functions described in this disclosure are merely exemplary and are not intended to limit the implementation of what is described and specified in this disclosure.
[0167] 22, the electronic device 2200 includes a computing unit 2201 that can perform various suitable operations and processes based on computer program instructions stored in a read-only memory (ROM) 2202 or loaded from a storage unit 2208 into a random access memory (RAM) 2203. The RAM 2203 can further store various programs and data required for the operation of the device 2200. The computing unit 2201, the ROM 2202, and the RAM 2203 are connected to each other via a bus 2204. An input / output (I / O) interface 2205 is also connected to the bus 2204.
[0168] A number of components in the electronic device 2200 are connected to an I / O interface 2205, including input units 2206 such as a keyboard and a mouse, output units 2207 such as various displays and speakers, storage units 2208 such as magnetic disks and optical disks, and communication units 2209 such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 2209 allows the device 2200 to exchange information / data with other devices via a computer network such as the Internet and / or various carrier networks.
[0169] The computing unit 2201 may be various general-purpose and / or special-purpose processing components having processing and computing capabilities. Some examples of the computing unit 2201 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, computing units that execute various machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 2201 executes the methods and processes described above. For example, in some embodiments, the methods described above can be implemented as a computer software program tangibly embodied in a machine-readable medium such as the storage unit 2208. In some embodiments, some or all of the computer program can be loaded and / or installed in the electronic device 2200 via the ROM 2202 and / or the communication unit 2209. When the computer program is loaded into the RAM 2203 and executed by the computing unit 2201, one or more steps of the methods described above can be executed. Additionally, in other embodiments, the computing unit 2201 may be configured to perform the methods described above in any other suitable manner (eg, firmware).
[0170] Various embodiments of the systems or techniques described herein may be implemented as digital electronic circuitry systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. Each of these embodiments may include implementation by one or more computer programs executed and / or interpreted by a programmable system including at least one programmable processor, which may be a special purpose or general purpose programmable processor capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transferring data and instructions to the storage system, the at least one input device, and the at least one output device.
[0171] The program codes for carrying out the methods of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general purpose computer, a special purpose computer or other programming data processing apparatus, so that when the program codes are executed by the processor or controller, the functions / operations specified in the flowcharts and / or block diagrams can be carried out. The program codes can be entirely executed on the machine, partially executed on the machine, or partly executed on the machine and partly executed on a remote machine as a separate software package, or entirely executed on a remote machine or server.
[0172] In the context of this disclosure, a machine-readable medium may be a tangible medium, which contains or stores a program for use by or in conjunction with an instruction execution system, apparatus or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Further examples of machine-readable storage media include one or more wired electrical connections, portable computer disk cartridges, hard disks, random access memories (RAMs), read-only memories (RMOs), erasable programmable read-only memories (EPRMOs or flash memories), optical fibers, portable compact disk read-only memories (CD-RMOs), optical storage devices, magnetic storage devices, or any combination of the foregoing.
[0173] To provide for interaction with a user, the systems and techniques described herein can be implemented on a computer that can include a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor, etc.) for displaying information to a user, and a keyboard and a pointing device (e.g., a mouse or trackball, etc.) for the user to provide input to the computer. Other types of devices can also be used to provide for interaction with a user, for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, haptic feedback, etc.) and input from the user can be received in any form (e.g., acoustic input, voice input, tactile input, etc.).
[0174] The systems and techniques described herein may be implemented in a computing system that includes a background component (e.g., as a data server), or a middleware component (e.g., an application server), or a front-end component (e.g., a user computer having a GUI or network browser through which a user can interact with embodiments of the systems and techniques described herein), or any combination of such background, middleware, or front-end components. The components of the system may be connected to each other via any form or medium of digital data communication (e.g., a communications network). Examples of communications networks include a local area network (LAN), a wide area network (WAN), and the Internet.
[0175] The computer system may include a client terminal and a server. Typically, the client terminal and the server are remote from each other and typically interact through a communication network. The client terminal-server relationship is created by a computer program that, when running on a corresponding computer, has a client terminal-server relationship.
[0176] It should be understood that steps can be reordered, added, or deleted using the above various aspects of the flow. For example, each step described in this disclosure can be performed in parallel, sequentially, or in a different order. As long as the technical solution disclosed in this disclosure can achieve the desired results, this disclosure is not limited thereto.
[0177] The above specific embodiments do not constitute limitations on the scope of protection of the present disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions are possible depending on design matters and other factors. Any modifications, equivalent replacements, improvements, etc. within the spirit and principles of the present disclosure should be included in the scope of protection of the present disclosure.
Claims
1. A text processing method executed by a text processing device, comprising: performing text processing on the first text using a text processing acceleration operator, the text processing acceleration operator being capable of performing text processing on the plurality of string texts to obtain integer format content corresponding to each string text; and performing parallel acceleration on the integer format content after text processing using the text processing acceleration operator; Performing text processing on a first text using a text processing acceleration operator includes: obtaining a first tensor corresponding to the first text; performing a partitioning operation on the first tensor to obtain a plurality of partitioning results; performing mapping for each of the segmentation results based on a mapping relationship; and generating a second tensor using the mapping result, the second tensor including obtaining a numerical value for each row of the second tensor based on the mapping result of a character string of each row of the first tensor; wherein the first text includes a string, the first tensor is a string tensor, and the first tensor includes N rows of strings, the second tensor is an integer tensor, the numerical values of each row of the second tensor correspond to the strings of each row of the first tensor, and the second tensor includes N rows of numerical values in an integer format corresponding to the N rows of strings, where N is a positive integer; The division of the first tensor to obtain a plurality of division results includes: performing a character segmentation process on the first tensor to obtain a plurality of segmented characters; performing a word segmentation process on the first tensor to obtain a plurality of segmented words; and Mapping each of the division results based on the mapping relationship includes: Mapping each divided character to a numerical value based on a mapping relationship between a predetermined divided character and / or divided word and a numerical value in an integer format; Mapping each divided word to a numerical value based on a predetermined mapping relationship between divided characters and / or divided words and numerical values in an integer format; and performing parallel acceleration on post-text processing integer format content using the text processing acceleration operator; performing parallel processing on the second tensor using multiple threads; Text processing methods.
2. the text processing is converted from a first language implementation to a second language implementation; the first language is an interpreted language and the second language is a compiled language; 2. The text processing method according to claim 1.
3. The text processing method includes: performing natural language understanding processing on the accelerated content using the text processing acceleration operator using a natural language understanding model; The natural language understanding model includes the text processing acceleration operator and a transform encoder operator, where the transform encoder operator is used to perform string encoding on the content after acceleration by the text processing acceleration operator; The transform encoder operator includes a fused attention mechanism operator and a fused feedforward operator, where the fused attention mechanism operator is obtained by fusing a generalized matrix multiplication (GEMM), a bias add, and a transpose in a multi-head attention mechanism of the natural language understanding model, respectively, and the fused feedforward operator is obtained by fusing a kernel operator in a feedforward layer of the natural language understanding model.
2. The text processing method according to claim 1.
4. The text processing method includes: deriving a mapping relationship for use by the text processing acceleration operator.
2. The text processing method according to claim 1.
5. The text processing method includes: storing the derived mapping relationship in a binary serialized format; and compressing and storing the derived thesaurus using a compression algorithm; Further comprising at least one of:
5. A text processing method according to claim 4.
6. a text processing module for performing text processing on the first text using a text processing acceleration operator, the text processing module being capable of performing text processing on the plurality of string texts to obtain integer format content corresponding to each string text; a parallel acceleration module for performing parallel acceleration on the integer format content after text processing using the text processing acceleration operator; Specifically, the text processing module: obtaining a first tensor corresponding to the first text; performing a partitioning operation on the first tensor to obtain a plurality of partitioning results; performing mapping for each of the segmentation results based on a mapping relationship; and generating a second tensor using the mapping result, the second tensor including obtaining a numerical value for each row of the second tensor based on the mapping result of the character string of each row of the first tensor; wherein the first text includes a string, the first tensor is a string tensor, and the first tensor includes N rows of strings, the second tensor is an integer tensor, the numerical values of each row of the second tensor correspond to the strings of each row of the first tensor, and the second tensor includes N rows of numerical values in an integer format corresponding to the N rows of strings, where N is a positive integer; The division of the first tensor to obtain a plurality of division results includes: performing a character segmentation process on the first tensor to obtain a plurality of segmented characters; performing a word segmentation process on the first tensor to obtain a plurality of segmented words; and Mapping each of the division results based on the mapping relationship includes: Mapping each divided character to a numerical value based on a mapping relationship between a predetermined divided character and / or divided word and a numerical value in an integer format; Mapping each divided word to a numerical value based on a predetermined mapping relationship between divided characters and / or divided words and numerical values in an integer format; and Specifically, the parallel acceleration module includes: and performing parallel processing on the second tensor using multiple threads. Text processing device.
7. A text processing acceleration operator that performs text processing on a plurality of string texts to obtain integer format contents corresponding to each string text, comprising: performing text processing on the first text, obtaining a first tensor corresponding to the first text; performing a partitioning operation on the first tensor to obtain a plurality of partitioning results; performing mapping for each of the segmentation results based on a mapping relationship; and generating a second tensor using the mapping result, the second tensor including obtaining a numerical value for each row of the second tensor based on the mapping result of a character string of each row of the first tensor; wherein the first text includes a string, the first tensor is a string tensor, and the first tensor includes N rows of strings, the second tensor is an integer tensor, the numerical values of each row of the second tensor correspond to the strings of each row of the first tensor, and the second tensor includes N rows of numerical values in an integer format corresponding to the N rows of strings, where N is a positive integer; The division of the first tensor to obtain a plurality of division results includes: performing a character segmentation process on the first tensor to obtain a plurality of segmented characters; performing a word segmentation process on the first tensor to obtain a plurality of segmented words; and Mapping each of the division results based on the mapping relationship includes: Mapping each divided character to a numerical value based on a mapping relationship between a predetermined divided character and / or divided word and a numerical value in an integer format; Mapping each divided word to a numerical value based on a predetermined mapping relationship between divided characters and / or divided words and numerical values in an integer format; and performing parallel acceleration on integer format content after text processing, performing parallel processing on the second tensor using multithreading; and a text processing acceleration operator for use in A system based on a deep learning framework.
8. At least one processor; a memory in communication with the at least one processor; The memory stores instructions executable by the at least one processor, the instructions, when executed by the at least one processor, causing the at least one processor to perform a text processing method according to any one of claims 1 to 5. Electronic devices.
9. A non-transitory computer readable storage medium for storing instructions that cause a computer to perform the text processing method of any one of claims 1 to 5.
10. A program for implementing the text processing method according to any one of claims 1 to 5 when executed by a processor in a computer.
