WO2024040831A1 - Natural language processing method and apparatus, electronic device, and storage medium - Google Patents

Natural language processing method and apparatus, electronic device, and storage medium Download PDF

Info

Publication number
WO2024040831A1
WO2024040831A1 PCT/CN2022/142456 CN2022142456W WO2024040831A1 WO 2024040831 A1 WO2024040831 A1 WO 2024040831A1 CN 2022142456 W CN2022142456 W CN 2022142456W WO 2024040831 A1 WO2024040831 A1 WO 2024040831A1
Authority
WO
WIPO (PCT)
Prior art keywords
task
functional
functional neural
neural network
network
Prior art date
Application number
PCT/CN2022/142456
Other languages
French (fr)
Chinese (zh)
Inventor
李林峰
Original Assignee
湖北星纪魅族科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 湖北星纪魅族科技有限公司 filed Critical 湖北星纪魅族科技有限公司
Publication of WO2024040831A1 publication Critical patent/WO2024040831A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking
    • G06F40/295Named entity recognition
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Definitions

  • Embodiments of the present disclosure relate to a natural language processing method and device, electronic equipment and storage media.
  • Natural Language Processing is an important direction in the field of computer science and artificial intelligence. It is used to study various theories and methods that can achieve effective communication between humans and computers using natural language. With the continuous development of artificial intelligence technology, natural language processing has begun to be widely used in a variety of application scenarios such as customer service systems, replacing a large number of manual operations.
  • Deep learning is a major branch of machine learning. Deep learning models, such as convolutional neural networks, recurrent neural networks, etc., are used in natural language processing to continuously learn language features by vectorizing words or sentences to complete natural language classification. , The process of understanding meets the natural language processing requirements of a large number of feature engineering.
  • the natural language processing method includes: obtaining a task text to be processed by the natural language, wherein the task text includes a plurality of characters; using a shared neural network to perform feature extraction on the task text to obtain sharing of the task text Features, wherein the shared features include character features of the multiple characters and global connections between the multiple characters; input the shared features into multiple functional neural networks to obtain the respective functional neural networks. Multiple output processing results, wherein the multiple functional neural networks are used to perform multiple different natural language processing tasks respectively.
  • the shared neural network includes an input sub-network, a word embedding sub-network and a feature extraction sub-network, and the shared neural network is used to process the task text Perform feature extraction to obtain the shared features of the task text, including: using the input sub-network to convert the task text into a word index array, where the multiple index values included in the word index array are consistent with the Multiple characters correspond one to one; the word index array is encoded into multiple word vectors using the word embedding sub-network, wherein the multiple word vectors correspond to the multiple characters one-to-one, and the multiple words Each word vector in the vector includes character features of the corresponding character; based on the multiple word vectors, the feature extraction sub-network is used to extract the global connection between the multiple characters to obtain the shared features.
  • the feature extraction sub-network includes a convolutional neural network and a long short-term memory network.
  • the natural language processing task includes a question and answer functional task, and the question and answer functional task is used to parse the questions in the task text, and provide the Answers corresponding to the questions
  • the plurality of functional neural networks include a first functional neural network, the first functional neural network is used to perform the question and answer functional task, and the shared features are input into the multiple functional neural networks.
  • obtaining the plurality of processing results respectively output by the plurality of functional neural networks including: using the first functional neural network to perform a first process on the shared features to obtain a sentence vector, wherein the sentence vector including the category information of the question in the task text; comparing the sentence vector with multiple knowledge information vectors pre-stored in the database to calculate the vector distance between the multiple knowledge information vectors and the sentence vector The answer corresponding to the smallest knowledge information vector is used as the processing result corresponding to the first functional neural network.
  • the first processing includes convolution processing, pooling processing, feature fusion processing and fully connected processing.
  • the natural language processing task includes a chat-type functional task
  • the chat-type functional task is used to parse purposeless dialogue information in the task text, A system answer corresponding to the purposeless dialogue information is given.
  • the plurality of functional neural networks include a second functional neural network. The second functional neural network is used to perform the chat-type functional task.
  • the functional neural network will The shared features are input into the multiple functional neural networks to obtain the multiple processing results respectively output by the multiple functional neural networks, including: using the second functional neural network to perform a second process on the shared features to obtain A sentence is output as a processing result corresponding to the second functional neural network, and the processing result corresponding to the second functional neural network is used as a system answer corresponding to the task text.
  • the second functional neural network includes a coding sub-network and a decoding sub-network, and the second functional neural network is used to perform all operations on the shared features.
  • the second process to obtain the output sentence as a processing result corresponding to the second functional neural network includes: using the encoding subnetwork to encode the shared features to obtain an intermediate index array; using the decoding The sub-network decodes the intermediate index array to obtain the output sentence as a processing result corresponding to the second functional neural network.
  • the natural language processing task includes a task-type functional task, and the task-type functional task is used to parse the task purpose information and task key in the task text.
  • Word information obtain system questioning or question and answer results according to the task purpose information and the task keyword information
  • the plurality of functional neural networks include a third functional neural network, and the third functional neural network is used to perform the task Type functional task
  • inputting the shared features into the plurality of functional neural networks to obtain the plurality of processing results respectively output by the plurality of functional neural networks includes: using the third functional neural network to Perform a third process on the shared features to obtain intent features and at least one named entity corresponding to the task text, where the intent features include the task purpose information in the task text, and the at least one named entity includes The task keyword information; perform dialogue management on the intent feature and the at least one named entity, and obtain the system questioning or the question and answer result as a processing result corresponding to the third functional neural network.
  • the third functional neural network includes an intent recognition sub-network and a named entity recognition sub-network
  • the third functional neural network is used to analyze the shared Perform the third processing on the features to obtain the intent features and the at least one named entity corresponding to the task text, including: using the intent recognition sub-network to perform intent recognition based on the shared features to obtain the intent features corresponding to the task text.
  • obtaining the task text to be subjected to the natural language processing includes: obtaining the speech segment to be subjected to the natural language processing. ; Convert the voice clip into text form to obtain the task text.
  • the natural language processing method provided by at least one embodiment of the present disclosure further includes selecting one processing result from the plurality of processing results as the output result of the natural language processing through arbitration selection.
  • the natural language processing method before obtaining the task text corresponding to the natural language, further includes: obtaining a training text; based on the training text, multiple functional neural networks to be trained Training is performed to obtain the plurality of trained functional neural networks, where the number of the plurality of functional neural networks is N, and N is an integer greater than 1, wherein in the process of training the N functional neural networks to be trained , the N functional neural networks are trained simultaneously, and the weighted sum of the M intermediate loss values corresponding to the N functional neural networks is calculated as the loss value to update the parameters of the N functional neural networks, and the M The intermediate loss values correspond to M weights respectively.
  • the M weights are dynamically adjusted according to the output accuracy of the N functional neural networks.
  • M is an integer greater than or equal to N.
  • the N functional neural networks include a first functional neural network, a second functional neural network, and a third functional neural network, and the third functional neural network It includes an intent recognition sub-network and a named entity recognition sub-network, and training the multiple functional neural networks to be trained based on the training text includes: using the shared neural network to be trained to characterize the training text.
  • Extract and obtain the training shared features of the training text use the N functional neural networks to process the training shared features respectively, and obtain M sets of first intermediate results respectively output by the N functional neural networks, where,
  • the M sets of first intermediate results include the first intermediate results output by the first functional neural network, the first intermediate results output by the second functional neural network, the first intermediate results output by the intention recognition sub-network, and A first intermediate result output by the named entity recognition sub-network.
  • training the multiple functional neural networks to be trained based on the training text further includes: based on the training text and the M sets of first intermediate results calculate M intermediate loss values corresponding to the N functional neural networks, where the M intermediate loss values include the intermediate loss values corresponding to the first functional neural network, the second functional The intermediate loss value corresponding to the neural network, the intermediate loss value corresponding to the intention recognition sub-network and the intermediate loss value corresponding to the named entity recognition sub-network; calculate the weighted sum of the M intermediate loss values as the loss value; When the loss value does not satisfy the predetermined convergence condition, the parameters of the shared neural network to be trained and the N functional neural networks are updated based on the loss value.
  • training the multiple functional neural networks to be trained based on the training text also includes: obtaining a test text; using the trained The shared neural network and the trained N functional neural networks process the test text to obtain M sets of second intermediate results; based on the M sets of second intermediate results and the test text, determine the respective corresponding The M output accuracies of the N functional neural networks after training, wherein the M output accuracies include the output accuracy of the first functional neural network, the output accuracy of the second functional neural network degree, the output accuracy of the intention recognition sub-network and the output accuracy of the named entity recognition sub-network; adjust the M weights respectively corresponding to the M intermediate loss values based on the M output accuracies; according to the adjustment The subsequent M weights continue to train the multiple functional neural networks to be trained.
  • adjusting the M weights respectively corresponding to the M intermediate loss values based on the M output accuracies includes: determining the M outputs The weight corresponding to the maximum output accuracy in the accuracy is used as the first weight; keep the first weight unchanged, and increase the other M-1 weights among the M weights except the first weight.
  • increasing M-1 weights other than the first weight among the M weights includes: according to the M-1 The magnitude relationship between the M-1 output accuracies corresponding to the M-1 weights is determined, and the M-1 amplification factors of the M-1 weights are determined, wherein, for any one of the M-1 output accuracies, the output accuracy , in response to the greater the accuracy of any of the outputs, the smaller the amplification factor of the weight corresponding to the accuracy of any of the outputs; adjust the M-1 weights according to the amplification factors of the M-1 weights.
  • the natural language processing device includes: an acquisition module configured to acquire a task text to be processed by the natural language, wherein the task text includes a plurality of characters; and an extraction module configured to use a shared neural network to perform the task text on the task text.
  • Feature extraction to obtain shared features of the task text, where the shared features include character features of the multiple characters and global connections between the multiple characters; a processing module configured to input the shared features
  • Multiple functional neural networks are used to obtain multiple processing results respectively output by the multiple functional neural networks, where the multiple functional neural networks are used to perform multiple different natural language processing tasks.
  • the acquisition module is further configured to acquire training text.
  • the natural language processing device provided by at least one embodiment of the present disclosure further includes a training module configured to, based on the training text, train multiple functional neural networks to be trained to obtain the trained Described multiple functional neural networks, wherein the number of the multiple functional neural networks is N, and N is an integer greater than 1, wherein, in the process of training the N functional neural networks to be trained, the N functional neural networks Neural networks are trained simultaneously, and the weighted sum of M intermediate loss values corresponding to the N functional neural networks is calculated as the loss value to update the parameters of the N functional neural networks, and the M intermediate loss values correspond to M respectively. weights, and the M weights are dynamically adjusted according to the output accuracy of the N functional neural networks, where M is an integer greater than or equal to N.
  • a training module configured to, based on the training text, train multiple functional neural networks to be trained to obtain the trained Described multiple functional neural networks, wherein the number of the multiple functional neural networks is N, and N is an integer greater than 1, wherein, in the process of training the N functional neural networks
  • At least one embodiment of the present disclosure also provides an electronic device.
  • the electronic device includes: a processor; a memory including one or more computer program modules; wherein the one or more computer program modules are stored in the memory and configured to be executed by the processor, the One or more computer program modules are included for implementing the natural language processing method provided by any embodiment of the present disclosure.
  • At least one embodiment of the present disclosure also provides a storage medium for storing non-transitory computer-readable instructions.
  • the non-transitory computer-readable instructions are executed by a computer, the natural language provided by any embodiment of the present disclosure can be realized. Approach.
  • Figure 1 is a schematic diagram of a multi-task neural network natural language processing system
  • Figure 2 is an exemplary flow chart of a natural language processing method provided by at least one embodiment of the present disclosure
  • Figure 3 is a schematic diagram of an example of a shared neural network and multiple functional neural networks provided by at least one embodiment of the present disclosure
  • Figure 4 is an exemplary flow chart of an example of step S120 in Figure 2;
  • Figure 5 is a schematic diagram of another example of a shared neural network and multiple functional neural networks provided by at least one embodiment of the present disclosure
  • Figure 6 is a schematic diagram of an example of a first functional neural network provided by at least one embodiment of the present disclosure
  • Figure 7 is a schematic diagram of an example of a second functional neural network provided by at least one embodiment of the present disclosure.
  • Figure 8 is a schematic diagram of an example of a third functional neural network provided by at least one embodiment of the present disclosure.
  • Figure 9 is a schematic diagram of the training part of the natural language processing method provided by at least one embodiment of the present disclosure.
  • Figure 10 is a schematic diagram of an example of step S150 in Figure 9;
  • FIG 11 is a schematic diagram of another example of step S150 in Figure 9;
  • Figure 12 is a schematic diagram of an example of a loss function of a shared neural network and multiple functional neural networks provided by at least one embodiment of the present disclosure
  • Figure 13 is a schematic block diagram of a natural language processing device provided by at least one embodiment of the present disclosure.
  • Figure 14 is a schematic block diagram of an electronic device provided by at least one embodiment of the present disclosure.
  • Figure 15 is a schematic block diagram of another electronic device provided by at least one embodiment of the present disclosure.
  • Figure 16 is a schematic diagram of a storage medium provided by at least one embodiment of the present disclosure.
  • Natural language processing refers to the technology that uses natural language used in human communication to interact with machines, involving multi-dimensional operations such as speech, grammar, semantics, and pragmatics. Simply put, the basic task of natural language processing is to segment the corpus to be processed based on ontology dictionary, word frequency statistics, contextual semantic analysis and other methods to form word units with the smallest part of speech as the unit and rich in semantics.
  • Natural language processing is widely used in human-computer interactive communication situations, such as human-computer voice interaction in cars and mobile phone voice assistants.
  • Human-computer voice interaction in cars and mobile phone voice assistants are multi-vertical applications that support open domains.
  • the human-computer dialogue includes encyclopedia-like knowledge questions and answers, purposeless chatting, and conversations to complete a specific task. Interaction, such as controlling vehicles, checking train tickets, etc.
  • natural language processing tasks can be divided into question-and-answer functional tasks, chat-type functional tasks and task-type functional tasks:
  • Question and answer functional tasks can handle question and answer based on knowledge base, for example:
  • Chat-type functional tasks can handle purposeless conversations, for example:
  • Task-type functional tasks can handle dialogues with word slots or multiple rounds, for example:
  • each neural network independently processes the input of the neural network and outputs the processing result of the neural network.
  • Figure 1 is a schematic diagram of a multi-task neural network for natural language processing.
  • the multi-task neural network consists of three different neural networks: question and answer neural network, chat neural network and task neural network.
  • the three neural networks are set up independently and include input layer, NLP respectively.
  • Feature extraction part multiple hidden layers (such as hidden layer 1-1,..., hidden layer 1-x, etc. in Figure 1) and output layer.
  • the hidden layer can be a suitable neural network structure selected according to actual needs. For example, the weight parameters of each layer of the three neural networks and the specific structure and number of layers of the hidden layer may be different, so that they each complete different functions.
  • question-and-answer neural networks are used to perform question-and-answer functional tasks
  • chat-type neural networks are used to perform chat-type functional tasks
  • task-based neural networks are used to perform task-type functional tasks.
  • the same task text can be input into three neural networks respectively, and the three neural networks perform different inferences on the task text to obtain their own processing results. Finally, arbitration selects the best processing result as the answer to the task text.
  • the three neural networks are composed of multiple network layers (such as input layer, hidden layer, etc.).
  • the scale of each neural network is large, which will lead to too many neural network models.
  • the size of the model is large, so it takes up too much computing resources; especially on end-side devices with limited resources, setting up and running three neural networks at the same time often leads to the problem of insufficient resources.
  • the three neural networks all include an input layer and a feature extraction part.
  • the three network layers have similar functions and are all used to extract features from the input task text; since the three input neural networks are the same
  • the input layer of the three neural networks and the NLP feature extraction part can share parameter weights.
  • the three neural networks are set up independently, the first three layers that can share parameter weights are also set up separately, resulting in duplication and waste of computing resources.
  • the natural language processing method includes: obtaining a task text to be processed by natural language, where the task text includes multiple characters; using a shared neural network to extract features from the task text to obtain shared features of the task text, where the shared features include multiple characters. Character features of characters and global connections between multiple characters; input shared features into multiple functional neural networks to obtain multiple processing results output by multiple functional neural networks respectively, where multiple functional neural networks are used to execute respectively Multiple different natural language processing tasks.
  • Various embodiments of the present disclosure also provide a device, electronic device or storage medium corresponding to executing the above natural language processing method.
  • a shared neural network is used to extract shared features that can be shared between different functional tasks, such as character features of the task text itself, contextual connections between characters, etc.
  • Each shared neural network The network performs different subsequent processing on the shared features to perform different natural language processing tasks, thereby enabling multiple functional neural networks to share the weight parameters of the shared neural network, reducing the size of the neural network parameters and thus saving computing resources. Avoid duplication and waste of computing resources and save computing costs.
  • Figure 2 is an exemplary flow chart of a natural language processing method provided by at least one embodiment of the present disclosure.
  • a natural language processing method provided by at least one embodiment of the present disclosure is used to process multiple different natural language tasks at the same time.
  • the natural language processing method includes the following steps S110 to S130.
  • Step S110 Obtain the task text to be processed by natural language
  • Step S120 Use a shared neural network to extract features from the task text to obtain shared features of the task text;
  • Step S130 Input the shared features into multiple functional neural networks to obtain multiple processing results respectively output by the multiple functional neural networks.
  • the task text to be subjected to natural language processing is, for example, a string of sentences input by the user during human-computer interaction, that is, the task text includes multiple characters.
  • the task text can be text in various languages, such as Chinese, English, Japanese, etc.
  • the characters are in the form of a single Chinese character
  • the task text is English text
  • the characters are in the form of a single word.
  • the task text can also include various numbers, etc., and a single number can also be used as a character.
  • the task text can be a text in a single language, such as a pure Chinese text.
  • the task text can also be a mixed text in multiple languages, such as a mixed Chinese and English text. This disclosure does not place specific restrictions on the form and language of the task text.
  • step S110 may include: obtaining a voice segment to be subjected to natural language processing; and converting the voice segment into text form to obtain the task text.
  • voice segment For example, in applications such as human-computer voice interaction, the user's voice fragments are first obtained, and then the voice fragments are converted into text form as the task text.
  • This disclosure places no specific restrictions on the specific conversion method of speech clips into task text.
  • the shared features include character features of multiple characters and global connections between multiple characters.
  • the task text is transformed into multiple feature vectors through feature extraction by the shared neural network.
  • the shared features are included in multiple feature vectors, that is, multiple feature vectors contain both the meaning of each character and the connections between all characters. (i.e. global connection), thus containing effective information of the entire input sentence.
  • the global connection between multiple characters is the contextual connection between multiple characters.
  • the character characteristics reflect the meaning of a single character, and the global connection between multiple characters reflects the meaningful context between multiple characters. Relationships, express the effective message of the sentence.
  • multiple functional neural networks process shared features to obtain multiple processing results.
  • multiple functional neural networks are used to perform multiple different natural language processing tasks respectively.
  • multiple different natural language processing tasks may include question-and-answer functional tasks, chat-type functional tasks, and task-based functional tasks, or may also include other types generated based on user input text during human-computer interaction.
  • Functional tasks embodiments of the present disclosure do not limit the types of natural language processing tasks.
  • FIG. 3 is a schematic diagram of an example of a shared neural network and multiple functional neural networks provided by at least one embodiment of the present disclosure.
  • the natural language processing method shown in Figure 2 can be implemented by a shared neural network as shown in Figure 3 and N functional neural networks used to perform N different natural languages respectively. Processing tasks, where N is a positive integer.
  • the shared neural network can be used to extract features from the task text in step S120 to obtain the shared features of the task text; N functional neural networks can be used to process the shared feature input in step S130. Output multiple processing results separately.
  • the natural language processing method provided by at least one embodiment of the present disclosure can share the parameter weights of the shared neural network in Figure 3, sharing
  • the neural network can be formed by merging the input layers and NLP feature extraction parts of three independent neural networks in Figure 1; the shared neural network can also be fused by the network layers that share weights in multiple other independent neural networks.
  • This disclosure does not limit this.
  • the shared neural network includes an input sub-network S1, a word embedding sub-network S2 and a feature extraction sub-network S3.
  • the input subnetwork S1 can be implemented as a One-Hot conversion layer, configured to perform one-hot encoding on each character in the task text, convert each character into its corresponding index value, and each index value constitutes a word index. array.
  • the input subnetwork S1 can also be implemented as other structures, and the index value is not limited to the one-hot code form, as long as each character of the task text can be converted into a unique corresponding index value.
  • the word embedding subnetwork S2 can convert the word index array into a multi-dimensional word vector to represent the meaning of each word (i.e., character features); the word embedding subnetwork S2 can be implemented as a suitable neural network structure according to actual needs.
  • the feature extraction subnetwork S3 is configured to extract the global connection between multiple characters of the task text and obtain multiple feature vectors.
  • the feature extraction sub-network S can include a convolutional neural network (CNN) and a long-short memory network (Long-Stort Term Memory, LSTM), or even a larger BERT (Bidirectional Encoder Representation from Transformer) network. It can also be other convolutional, fully connected or larger-scale neural networks.
  • CNN convolutional neural network
  • LSTM Long-Stort Term Memory
  • BERT Bidirectional Encoder Representation from Transformer
  • the network scale or parameter scale of the shared neural network needs to be set larger than the NLP extraction part that is set independently in Figure 1.
  • features can be added
  • the parameter scale of the extraction sub-network S3 can be increased, for example, by increasing the weight parameters in the feature extraction sub-network S3 by 20%.
  • the embodiments of the present disclosure do not limit this. .
  • N functional neural networks respectively include multiple hidden layers and output layers.
  • the hidden layers can be suitable neural networks selected according to actual needs.
  • Network structure For example, the network parameters of each network layer of N functional neural networks and the specific structure and number of hidden layers can be set as needed to perform different natural language processing tasks (for example, including but not limited to question and answer functional tasks, chatting functional tasks). tasks and task-type functional tasks, etc.).
  • FIG. 3 shows only an example of a shared neural network and multiple functional neural networks used in the natural language processing method proposed by the embodiment of the present disclosure.
  • the specific neural network layers of the multiple functional neural networks are described in this disclosure. There are no restrictions on the number of structures or functional neural networks.
  • FIG. 4 is an exemplary flowchart of an example of step S120 in FIG. 2 .
  • step S120 in the natural language processing method shown in Figure 2 includes the following steps S121 to S123.
  • Step S121 Use the input sub-network to convert the task text into a word index array
  • Step S122 Use the word embedding subnetwork to encode the word index array into multiple word vectors
  • Step S123 Based on multiple word vectors, use the feature extraction sub-network to extract global connections between multiple characters to obtain shared features.
  • step S121 after the task text is input into the input sub-network S1, multiple index values included in the word index array output by the input sub-network S1 correspond one-to-one to multiple characters in the task text. For example, if each character corresponds to an index value, the entire task text is converted into an array composed of index values. For example, a corresponding index value can be encoded in advance for all possible characters that need to be used in the language used in the task text.
  • the index value can be an integer value, representing the index of each character.
  • the specific meaningless characters here can correspond to a predetermined index value. The index value is different from the index value corresponding to any character. When the index value appears, it means that the corresponding character is a meaningless character.
  • the length of the output word index array is step, and the first 10 elements in the array are steps in the task text.
  • the index values corresponding to 10 characters, and the remaining step-10 index values are represented by the index values corresponding to the specific meaningless characters mentioned above, thereby converting the user input sentence into a word index array composed of index values.
  • the word embedding sub-network S2 embeds the index value corresponding to each character in the task text and encodes the word index array into multiple word vectors.
  • Multiple word vectors correspond to multiple index values one-to-one, and thus correspond to multiple characters one-to-one; each word vector in the multiple word vectors includes the character characteristics of the corresponding character (such as the meaning of each character itself) and the character The connection between the preceding and following characters (such as the meaning of a word).
  • the word index array output by the input sub-network S1 is transformed into a multi-dimensional word vector through the word embedding sub-network S2.
  • DIM 32-dimensional
  • the task text passes through the input sub-network S1 and then outputs a word index array with a length of step.
  • the word index array passes through the word embedding sub-network S2 and becomes a multi-dimensional word. vector.
  • the first 10 word vectors correspond to 10 characters in the task text.
  • the first 10 word vectors contain the character characteristics of the 10 characters (such as the meaning of each character itself in the task text) and the relationship between each of the 10 characters.
  • step-10 word vectors are represented by floating point numbers (such as null) corresponding to the above-mentioned specific meaningless characters, thus the words corresponding to the task text are
  • the index array is converted into a multidimensional floating-point matrix consisting of word vectors.
  • step S123 based on the multiple word vectors output by the word embedding sub-network S2, the feature extraction sub-network S3 extracts the global connection between multiple characters of the task text from the multiple word vectors, and obtains multiple feature vectors.
  • feature vectors contain shared features. Therefore, multiple feature vectors contain both the meaning of each character and the connections between all characters (i.e., global connections), thus containing effective information of the entire task text.
  • the task text outputs a multi-dimensional floating-point matrix composed of multiple word vectors after passing through the input sub-network S1 and the word embedding sub-network S2.
  • the feature extraction sub-network S3 After the feature extraction sub-network S3, it becomes multiple feature vectors.
  • multiple feature vectors contain both the meaning of each of the 10 characters and the connection between the 10 characters (i.e., the global connection), thereby containing effective information of the entire task text (for example, including the user's request to play a song Intention information, as well as keyword information such as "Yiyi", “Andy Lau", “Wangqingshui”).
  • FIG. 5 is a schematic diagram of another example of a shared neural network and multiple functional neural networks provided by at least one embodiment of the present disclosure.
  • N functional neural networks include a first functional neural network S4, a second functional neural network S5, and a third functional neural network S6, which are respectively used to perform different natural language processing tasks.
  • the first functional neural network S4 can be used to process question-and-answer type functional tasks
  • the second functional neural network S5 can be used to process chatting type functional tasks
  • the third functional neural network S6 can be used to process task-type functions.
  • Task; the first functional neural network S4, the second functional neural network S5 and the third functional neural network S6 can also be used to perform other types of natural language processing tasks respectively, and the embodiments of the present disclosure do not limit this.
  • natural language processing tasks include question and answer functional tasks.
  • the question and answer functional tasks deal with question and answer based on knowledge bases.
  • the question and answer functional tasks are used to parse questions in the task text and give answers corresponding to the questions.
  • N functional neural networks include a first functional neural network S4.
  • the first functional neural network S4 is used to perform a question-and-answer functional task and output a sentence vector.
  • the sentence vector includes the task text.
  • the category information of the question for example, general knowledge, science, etc.; after that, the sentence vector needs to be first post-processed to obtain the answer corresponding to the question in the task text.
  • step S130 in Figure 2 may further include: performing a first process on the shared features using the first functional neural network S4 to obtain a sentence vector; comparing the sentence vector with the database The multiple pre-stored knowledge information vectors are compared, and the answer corresponding to the knowledge information vector with the smallest vector distance from the sentence vector among the multiple knowledge information vectors is used as the processing result corresponding to the first functional neural network.
  • the first processing includes convolution processing, pooling processing, feature fusion processing, and fully connected processing.
  • the first functional neural network may be a convolutional neural network.
  • FIG. 6 is a schematic diagram of an example of a first functional neural network provided by at least one embodiment of the present disclosure.
  • the first functional neural network S4 may include a convolution layer, a pooling layer, a fusion layer, a fully connected layer, and an output layer, respectively used for the convolution in the above-mentioned first processing. Processing, pooling processing, feature fusion processing and full connection processing, and finally the sentence vector is obtained.
  • the specific structures of the convolution layer, pooling layer, fusion layer, fully connected layer, and output layer can be set as needed, and this disclosure does not place specific restrictions on this.
  • the first functional neural network can be a convolutional fully connected network as shown in Figure 6 (for example, TextCNN, etc.), or the twin-tower model can also be used as the first functional neural network S4, or it can also be Other network structures can realize the task of extracting sentence vectors.
  • the embodiments of the present disclosure do not limit the structure of the first functional neural network.
  • a large number of questions and their answers containing various types of encyclopedia knowledge information can be set in advance, and the sentence vectors of the preset questions can be extracted and stored in the database as knowledge information vectors.
  • the sentence vector is compared with multiple knowledge information vectors pre-stored in the database, for example, the distance between each knowledge information vector and the sentence vector is calculated to find the vector with the sentence vector.
  • the knowledge information vector with the smallest distance, and the answer corresponding to the knowledge information vector can be used as the processing result of the first functional neural network S4, that is, the answer corresponding to the question in the task text, that is, the answer to the question raised by the user.
  • the first functional neural network when performing a question-and-answer functional task, the first functional neural network outputs a sentence vector corresponding to the task text, and the sentence vector needs to be post-processed to obtain the final processing result as the processing result of the first functional neural network S4.
  • natural language processing tasks include small talk functional tasks, which can handle purposeless conversations.
  • the chat function task is used to parse the purposeless dialogue information in the task text and provide system answers corresponding to the purposeless dialogue information.
  • the N functional neural networks include the second functional neural network S5.
  • the second functional neural network S5 is used to perform chatting functional tasks and can directly obtain the output sentence as the system answer corresponding to the task text, without Further post-processing operations.
  • step S130 in Figure 2 may further include: using the second functional neural network S5 to perform a second process on the shared features to obtain an output sentence as a corresponding sentence corresponding to the second function.
  • the processing result of the neural network, and the processing result corresponding to the second function neural network is used as the system answer corresponding to the task text.
  • the second processing includes encoding processing and decoding processing.
  • the second functional neural network is typically based on a recurrent neural network architecture, including an encoding subnetwork and a decoding subnetwork.
  • FIG. 7 is a schematic diagram of an example of a second functional neural network provided by at least one embodiment of the present disclosure.
  • the encoding subnetwork includes a recurrent network
  • the decoding subnetwork includes a recurrent network, a fully connected layer, and a decoding layer.
  • the decoding layer in the decoding sub-network generally uses Viterbi decoding, and other decoding methods can also be used; the encoding sub-network and the decoding sub-network can also be other structures that can implement encoding or decoding functions. Embodiments of the present disclosure There are no restrictions on this.
  • the process of using the second functional neural network S5 to perform the second processing on the shared features may further include: using the encoding subnetwork to encode the shared features to obtain an intermediate index array; using the decoding subnetwork to decode the intermediate index array to obtain the output. Sentences as processing results corresponding to the second functional neural network.
  • the intermediate index array is the encoding result obtained by encoding the shared features through the encoding subnetwork, and the intermediate index array is then decoded by the decoding subnetwork to obtain the output sentence.
  • the output sentence is directly used as the processing result of the second functional neural network S5, that is, the system answer corresponding to the task text, that is, the response to the purposeless chat conversation sent by the user.
  • the second functional neural network can be the architecture of a recurrent neural network as shown in Figure 7 (for example, the recurrent network is RNN (Recurrent Neural Network), LSTM or GRU (Gate Recurrent Unit), etc.), or it can be Other network structures that convert shared features into output sentences can be implemented, and embodiments of the present disclosure do not limit this.
  • RNN Recurrent Neural Network
  • LSTM Long Term Evolution
  • GRU Gate Recurrent Unit
  • the natural language processing task includes a task-type functional task
  • the task-type functional task can process a dialogue with word slots or a multi-turn dialogue.
  • Task-type functional tasks are used to parse the task purpose information and task keyword information in the task text, and obtain system questioning or question and answer results based on the task purpose information and task keyword information.
  • task-based functional tasks include processing some complex dialogue processes, such as sentences with word slots, multi-turn dialogues that consider context, etc.
  • the N functional neural networks may include a third functional neural network S6.
  • the third functional neural network S6 is used to perform task-type functional tasks and output intent features and named entities.
  • the intent features and named entities are respectively Corresponding to the task purpose information and task keyword information in the task text; through the second post-processing operation, the intent features and named entities are post-processed to obtain system questioning or question and answer results corresponding to the task text.
  • step S130 in Figure 2 may further include: using the third functional neural network S6 to perform a third process on the shared features to obtain the intent features corresponding to the task text and at least A named entity; performs dialogue management on the intent feature and at least one named entity, and obtains system questioning or question and answer results as processing results corresponding to the third function neural network.
  • the third functional neural network S6 includes an intention recognition sub-network S61 and a named entity recognition sub-network S62.
  • Using the third functional neural network S6 to perform third processing on the shared features to obtain the intent features and at least one named entity corresponding to the task text which may include: using the intent recognition sub-network S61 to perform intent recognition based on the shared features to obtain the intent features corresponding to the task text Intentional features of the text; using the named entity recognition sub-network S62, perform named entity recognition based on the shared features to obtain at least one named entity corresponding to the task text.
  • the intent feature contains the task purpose information in the task text, that is, the intent feature represents the implicit information that the user wants to express. For example, in some specific examples, the intention of "Play me a song by Andy Lau” is to play a song by a certain singer, and the intention of "What will the weather be like in Shanghai tomorrow" is a weather query.
  • At least one named entity contains task keyword information (also called named entity information or word slot information), that is, named entity recognition (Named Entity Recognition, NER) is to recognize the named entity information (including Keyword location, type).
  • task keyword information also called named entity information or word slot information
  • named entity recognition Named Entity Recognition, NER
  • NER named Entity Recognition
  • the user wants to book a train ticket.
  • the shared neural network and multiple functional neural networks need to complete the interactive dialogue with the user and finally complete the ticket booking task. For example:
  • the task text including the above-mentioned task purpose information and task keyword information is converted into shared features through the shared neural network; the shared features are intention-identified through the intention recognition word network S61, and the intention features are output (for example, the intention features include the user's requirements for ordering train ticket intention information), use the named entity sub-network S62 to perform named entity recognition based on shared features, and obtain one or more named entities (for example, the named entities include keyword information such as "Shanghai" and "10 o'clock”); and then Intent features and named entities undergo second post-processing to obtain system questions (for example, asking about location and time, etc.) or question and answer results (for example, answers to complete ticket bookings) corresponding to the task text.
  • system questions for example, asking about location and time, etc.
  • question and answer results for example, answers to complete ticket bookings
  • dialog management can be performed on the intent feature and at least one named entity in the second post-processing process.
  • dialogue management is to maintain and update the status information and context required for task-type functional tasks, such as what information needs to be asked in the next sentence, when to end the reply, when to ask questions, etc.
  • dialogue is generated through system questioning, thereby continuously improving communication, obtaining valuable information, and obtaining question and answer results.
  • FIG. 8 is a schematic diagram of an example of a third functional neural network provided by at least one embodiment of the present disclosure.
  • the intent recognition sub-network can include a convolution layer, a pooling layer, a fusion layer, a fully connected layer, and an activation function layer (such as a SOFTMAX layer), which are respectively used to perform shared feature analysis. Convolution processing, pooling processing, feature fusion processing, fully connected processing and classification processing, etc., to obtain the intended features corresponding to the task text.
  • the named entity recognition sub-network can include a Bidirectional Long-Short Term Memory (Bi-LSTM) layer, a fully connected layer and a decoding layer, which are respectively used for contextual information processing, full connection processing and decoding processing of shared features. wait.
  • Bi-LSTM Bidirectional Long-Short Term Memory
  • the third function neural network can also be other network structures that can realize the conversion of shared features to intention features and named entities.
  • the intention recognition sub-network and the named entity recognition sub-network can also be capable of realizing intention recognition or named entity recognition.
  • embodiments of the present disclosure do not limit the specific structures of the intent recognition sub-network and the named entity recognition sub-network.
  • the natural language processing method provided by at least one embodiment of the present disclosure further includes: selecting one processing result from multiple processing results as the output result of natural language processing through arbitration selection.
  • a task text will produce multiple processing results after being processed by a shared neural network and multiple functional neural networks; a final output can be selected from multiple processing results through arbitration according to the different natural language processing tasks corresponding to the task text. result.
  • the processing result corresponding to the first neural network is the answer to the question in the task text
  • the processing result corresponding to the second neural network is the system answer corresponding to the purposeless dialogue information
  • the processing result corresponding to the third neural network is The processing result is the result of system questioning or question and answer.
  • the task text is a question posed by the user, that is, the natural language processing task is a question and answer functional task, then the answer corresponding to the question output by the functional neural network used to perform the question and answer functional task is selected as the final output result;
  • the task text mainly contains purposeless dialogue information, that is, the natural language processing task is a chat-type functional task, then the system answer output by the functional neural network used to perform the chat-type functional task is selected as the final output result;
  • the task text It mainly contains task purpose information and task keyword information. That is, if the natural language processing task is a task-type functional task, then the system questioning or question and answer result output by the functional neural network used to perform the task-type functional task is selected as the final output result. .
  • the arbitration selection may include the following methods: if contextual information, that is, a multi-round conversation scenario, is detected, then the system questioning or question and answer result is selected as the final output result; if no multi-round conversation scenario is detected, then Based on the static priorities set in advance (such as the priorities of question-and-answer tasks and task-based tasks), the output of the functional neural network corresponding to the high-priority task is selected as the final output result; in addition to the static priorities set in advance, criticism also needs to be considered degree (such as the number of word slots), the confidence level inferred by the model, etc. It should be noted that other implementation methods can be selected for arbitration selection according to actual needs, and the embodiments of the present disclosure do not limit this.
  • the natural language processing method uses multiple neural networks for natural language processing with shared neural networks to perform multiple different natural language processing tasks, reducing the scale of neural network parameters, thereby saving money.
  • Computing resources save computing costs.
  • the shared neural network and multiple functional neural networks provided by at least one embodiment of the present disclosure are obtained through training in advance.
  • Figure 9 is a schematic diagram of the training part of the natural language processing method provided by at least one embodiment of the present disclosure.
  • the natural language processing method further includes the following steps S140 to S150.
  • Step S140 Obtain training text
  • Step S150 Based on the training text, train multiple functional neural networks to be trained to obtain multiple trained functional neural networks.
  • the number of multiple functional neural networks is N, where N is an integer greater than 1.
  • N functional neural networks are trained simultaneously, and the weighted sum of M intermediate loss values corresponding to the N functional neural networks is calculated as the loss value to update the N functional neural networks.
  • M intermediate loss values correspond to M weights respectively, and the M weights are dynamically adjusted according to the output accuracy of N functional neural networks, where M is an integer greater than or equal to N.
  • the three functional neural networks are trained simultaneously.
  • 4 intermediate loss values correspond to 4 weights respectively, and the 4 weights can be dynamically adjusted according to the output accuracy of the 4 functional neural networks.
  • FIG. 10 is a schematic diagram of an example of step S150 in FIG. 9 .
  • step S150 in Figure 9 may include the following steps S151 to S155.
  • Step S151 Use the shared neural network to be trained to perform feature extraction on the training text to obtain training shared features of the training text.
  • the training text is the task text used in the neural network training process.
  • the training text is converted into multiple training feature vectors through feature extraction of the shared neural networks S1 to S3 to be trained.
  • the training shared features are included in multiple training feature vectors.
  • the training shared features include the character features of multiple characters in the training text and the global connections between multiple characters.
  • a large number of task texts and standard processing results corresponding to the task texts can be constructed in advance to train the neural network, and any task text can be selected as the training text.
  • Step S152 Use N functional neural networks to process the training shared features respectively, and obtain M sets of first intermediate results respectively output by the N functional neural networks.
  • the M group of first intermediate results include the first intermediate results output by the first functional neural network S4, the second The first intermediate result output by the functional neural network S5, the first intermediate result output by the intention recognition sub-network and the first intermediate result output by the named entity recognition sub-network.
  • the first intermediate result output is a training sentence vector, and the training sentence vector includes category information of questions in the training text;
  • the first intermediate result output by the second functional neural network S5 is the training output sentence, and the training output sentence includes the system answer corresponding to the training text;
  • the intent recognition sub-network output is the training intention feature, and the first intermediate result output by the named entity recognition sub-network is one or more training named entities.
  • Step S153 Calculate M intermediate loss values corresponding to N functional neural networks based on the training text and M sets of first intermediate results.
  • each function is calculated according to the loss function corresponding to each functional neural network.
  • the functional neural network corresponds to the intermediate loss value respectively.
  • M may be equal to N or not equal to N.
  • M N+1.
  • Step S154 Calculate the weighted sum of M intermediate loss values as the loss value.
  • the M intermediate loss values corresponding to N functional neural networks are Loss1, Loss2...LosM respectively.
  • the loss function of the shared neural network and N functional neural networks after training in steps S151 to S154 can be used as the following formula (1) express:
  • k 1 is the weight of the intermediate loss value Loss1
  • k 2 is the weight of the intermediate loss value Loss2
  • k M is the weight of the intermediate loss value LossM.
  • the initial values of k 1 , k 2 ...k M are all set to 1.
  • Step S155 When the loss value does not meet the predetermined convergence condition, update the parameters of the shared neural network to be trained and the N functional neural networks based on the loss value.
  • a trained functional neural network For example, if the loss value satisfies the predetermined convergence condition, a trained functional neural network will be obtained.
  • the weight of each intermediate loss value when calculating the loss value in step S154 can be dynamically adjusted.
  • N functional neural networks are trained at the same time during the training process.
  • N functional neural networks due to the uneven bias of the training data and the differences among the N functional neural networks, it is impossible for the N functional neural networks to converge at the same time, and it is even difficult for some networks to converge.
  • the output accuracy of the shared neural network and N functional neural networks can be measured during the training process (for example, the output accuracy is measured once every 1/10 of the total number of training rounds), based on N
  • the output accuracy of the functional neural network dynamically adjusts the M weights of the loss function.
  • FIG. 11 is a schematic diagram of another example of step S150 in FIG. 9 .
  • the method shown in Figure 11 is an example of dynamically adjusting the M weights of the loss function by measuring the output accuracy of N functional neural networks.
  • step S150 in Figure 9 may also include the following steps S156 to S1510.
  • Step S156 Obtain the test text
  • Step S157 Use the trained shared neural network and the trained N functional neural networks to process the test text to obtain M sets of second intermediate results;
  • Step S158 Based on M sets of second intermediate results and test text, determine M output accuracies respectively corresponding to the trained N functional neural networks;
  • Step S159 Adjust the M weights corresponding to the M intermediate loss values based on the M output accuracies
  • Step S1510 Continue to train the multiple functional neural networks to be trained according to the adjusted M weights.
  • step S159 further includes: determining the weight corresponding to the maximum output accuracy among the M output accuracies as the first weight; keeping the first weight unchanged, and increasing the other M-1 weights except the first weight among the M weights. a weight.
  • the test text is the task text used in the neural network testing process.
  • step S157 the feature extraction of the shared neural networks S1 to S3 after training (for example, after 1/10 of the total number of training rounds) of the test text is converted into multiple test feature vectors, and the test shared features are included in Among multiple test feature vectors, the test shared features include character features of multiple characters in the test text and global connections between multiple characters.
  • step S158 based on the test text and M sets of second intermediate results respectively output by the N functional neural networks, M output accuracies P1, P2, ... respectively corresponding to the trained N functional neural networks are determined. ,PM.
  • step S159 the M weights k 1 , k 2 ...k M respectively corresponding to the M intermediate loss values are adjusted based on the M output accuracies P1, P2 , ..., PM; in step S1510, based on The adjusted M weights continue to be trained on multiple functional neural networks to be trained.
  • Figure 12 is a schematic diagram of an example of a loss function of a shared neural network and multiple functional neural networks provided by at least one embodiment of the present disclosure.
  • the shared neural network and multiple functional neural networks in Figure 12 are, for example, the shared neural network and multiple functional neural networks in Figure 3 or Figure 5 .
  • the four intermediate loss values include the intermediate loss value Loss1 corresponding to the first functional neural network S4, the intermediate loss value Loss2 corresponding to the second functional neural network S5, and the intermediate loss value corresponding to the intention recognition sub-network S6-1.
  • the loss value Loss3 and the intermediate loss value Loss4 corresponding to the named entity recognition sub-network S6-2.
  • the weighted sum of the four intermediate loss values is calculated as the loss value Loss.
  • the loss functions of the shared neural network and the three functional neural networks trained in steps S151 to S154 can be expressed by the following formula (2) :
  • a is the weight of the intermediate loss value Loss1
  • b is the weight of the intermediate loss value Loss2
  • c is the weight of the intermediate loss value Loss3
  • d is the weight of the intermediate loss value Loss4.
  • the initial values of a, b, c, and d are all set to 1.
  • step S155 if the loss value Loss does not meet the predetermined convergence condition, the parameters of the shared neural networks S1 to S3 and the three functional neural networks to be trained are updated based on the loss value Loss.
  • the output accuracy of the shared neural network and N functional neural networks can be measured during the training process (for example, the accuracy is measured once every 1/10 of the total training epochs), according to the N functional
  • the output accuracy of the neural network dynamically adjusts the M weights of the loss function.
  • three functional neural networks separately process the test shared features to obtain four sets of second intermediate results.
  • the four sets of second intermediate results include the second intermediate results output by the first functional neural network S4 and the second intermediate results output by the second functional neural network S5.
  • the second intermediate result output is a test sentence vector, and the test sentence vector includes the category information of the questions in the test text;
  • the second intermediate result output by the second functional neural network S5 is the test output sentence, and the test output sentence includes the system answer corresponding to the test text;
  • the intent recognition sub-network output is the test intention feature, and the second intermediate result output by the named entity recognition sub-network is at least one test named entity.
  • step S158 based on the test text and 4 sets of second intermediate results (i.e., test sentence vector, test output sentence, test intention feature, and at least one test named entity) respectively output by the three functional neural networks, it is determined that the test text corresponds to 4 output accuracies of 3 functional neural networks after training.
  • the three output accuracies include the output accuracy P1 of the first functional neural network S4, the output accuracy P2 of the second functional neural network S5, and the intention The output accuracy P3 of the recognition sub-network S6-1 and the output accuracy P4 of the named entity recognition sub-network S6-2.
  • step S159 the four weights a, b, c, and d respectively corresponding to the four intermediate loss values are adjusted based on the four output accuracies P1, P2, P3, and P4.
  • sort P1, P2, P3, and P4 from large to small.
  • P2>P1>P3>P4 that is, the maximum output accuracy among the 4 output accuracy is the second function.
  • the weight b corresponding to the output accuracy P2 is used as the first weight; keep the first weight b unchanged, and increase the other three weights a, except the first weight b among the four weights. c, d.
  • the three amplification factors ⁇ , ⁇ , and ⁇ of the three weights a, c, and d can be determined based on the relationship between the three output accuracies corresponding to the three weights a, c, and d, that is, P1>P3>P4. .
  • P1>P3>P4 the greater the response to any output accuracy, the smaller the amplification factor of the weight corresponding to the output accuracy.
  • the above three weights are adjusted according to the amplification factors of the above three weights.
  • the four adjusted weights a’, b’, c’, and d’ can be expressed by the following formulas (3) to (6):
  • the weight b corresponding to the maximum output accuracy P2 remains unchanged, and the weights a, c, and d corresponding to the other three output accuracy are expanded to 1.5 times, 2 times, and 2.5 times respectively.
  • the natural language processing method provided by at least one embodiment of the present disclosure can accelerate the convergence of the neural network model during the training process by dynamically adjusting the weights of each jointly trained neural network during the training process, thereby reducing the training time.
  • Figure 13 is a schematic block diagram of a natural language processing device provided by at least one embodiment of the present disclosure.
  • the natural language processing device 300 includes an acquisition module 310 , an extraction module 320 , a processing module 330 and a training module 340 .
  • the acquisition module 310 is configured to acquire a task text to be subjected to natural language processing, and the task text includes a plurality of characters; that is, the acquisition module 310 can be configured to perform, for example, step S110 shown in FIG. 2 .
  • the extraction module 320 is configured to use a shared neural network to perform feature extraction on the task text to obtain shared features of the task text.
  • the shared features include character features of multiple characters and global connections between multiple characters; that is, the extraction module 320 It may be configured to perform, for example, step S120 shown in FIG. 2 .
  • the processing module 330 is configured to input shared features into multiple functional neural networks to obtain multiple processing results respectively output by the multiple functional neural networks.
  • the multiple functional neural networks are used to perform multiple different natural language processing tasks; that is, the multiple functional neural networks are used to perform multiple different natural language processing tasks;
  • the processing module 330 may be configured to perform, for example, steps S30 to S50 shown in FIG. 6 .
  • the acquisition module 310 is also configured to acquire training text; that is, the acquisition module 310 can also be configured to perform, for example, step S140 shown in Figure 9.
  • the training module 340 is configured to train multiple functional neural networks to be trained based on the training text to obtain multiple trained functional neural networks.
  • the number of multiple functional neural networks is N, where N is greater than 1. integer; that is, the measurement module 340 may be configured to perform, for example, step S150 shown in FIG. 9 .
  • modules in the natural language processing device 300 shown in FIG. 13 can be respectively configured as software, hardware, firmware or any combination of the above items to perform specific functions.
  • these modules may correspond to dedicated integrated circuits, pure software codes, or modules that combine software and hardware.
  • the device described with reference to FIG. 13 may be a PC computer, a tablet device, a personal digital assistant, a smartphone, a web application, or other devices capable of executing program instructions, but is not limited thereto.
  • the natural language processing device 300 is described above as being divided into modules for performing corresponding processing respectively, however, it is clear to those skilled in the art that the processing performed by each module can also be performed in the device without any specific module. Divided or there is no clear demarcation between modules.
  • the natural language processing device 300 described above with reference to FIG. 13 is not limited to including the modules described above, but can also add some other modules (for example, storage module, data processing module, etc.) as needed, or the above modules can also be added. combination.
  • At least one embodiment of the present disclosure also provides an electronic device, the electronic device includes a processor and a memory; the memory includes one or more computer program modules; the one or more computer program modules are stored in the memory and configured to Executed by a processor, one or more computer program modules include a method for implementing the natural language processing method provided by the embodiments of the present disclosure described above.
  • FIG. 14 is a schematic block diagram of an electronic device according to at least one embodiment of the present disclosure.
  • the electronic device 400 includes a processor 410 and a memory 420 .
  • memory 420 is used to store non-transitory computer-readable instructions (eg, one or more computer program modules).
  • the processor 410 is configured to execute non-transitory computer readable instructions. When the non-transitory computer readable instructions are executed by the processor 410, they may perform one or more steps according to the natural language processing method described above.
  • Memory 420 and processor 410 may be interconnected by a bus system and/or other forms of connection mechanisms (not shown).
  • the processor 410 may be a central processing unit (CPU), a digital signal processor (DSP), or other forms of processing units with data processing capabilities and/or program execution capabilities, such as a field programmable gate array (FPGA), etc.;
  • the central processing unit (CPU) may be of X86 or ARM architecture.
  • the processor 410 may be a general-purpose processor or a special-purpose processor that may control other components in the electronic device 400 to perform desired functions.
  • memory 420 may include any combination of one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory.
  • Volatile memory may include, for example, random access memory (RAM) and/or cache memory (cache), etc.
  • Non-volatile memory may include, for example, read-only memory (ROM), hard disk, erasable programmable read-only memory (EPROM), portable compact disk read-only memory (CD-ROM), USB memory, flash memory, and the like.
  • One or more computer program modules may be stored on the computer-readable storage medium, and the processor 410 may run the one or more computer program modules to implement various functions of the electronic device 400 .
  • Various application programs and various data, as well as various data used and/or generated by the application programs, etc. can also be stored in the computer-readable storage medium.
  • FIG. 15 is a schematic block diagram of another electronic device provided by at least one embodiment of the present disclosure.
  • the electronic device 500 is suitable for implementing the natural language processing method provided by the embodiment of the present disclosure. It should be noted that the electronic device 500 shown in FIG. 15 is only an example, which does not bring any limitations to the functions and scope of use of the embodiments of the present disclosure.
  • the electronic device 500 may include a processing device (such as a central processing unit, a graphics processor, etc.) 51 , which may include a natural language processing device according to any embodiment of the present disclosure, and may Various appropriate actions and processes are performed based on the program stored in the read-only memory (ROM) 52 or loaded from the storage device 48 into the random access memory (RAM) 53 . In the RAM 53, various programs and data required for the operation of the temperature error detection device 500 are also stored.
  • the processing device 51, the ROM 52 and the RAM 53 are connected to each other via a bus 54.
  • An input/output (I/O) interface 55 is also connected to bus 54 .
  • the following devices may be connected to the I/O interface 55: input devices 56 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; including, for example, a liquid crystal display (LCD), speakers, vibration An output device 57 such as a computer; a storage device 58 including a magnetic tape, a hard disk, etc.; and a communication device 59.
  • the communication device 59 may allow the temperature error detection device 500 to communicate wirelessly or wiredly with other electronic devices to exchange data.
  • FIG. 15 illustrates electronic device 500 having various means, it should be understood that implementation or provision of all illustrated means is not required and electronic device 500 may alternatively implement or be provided with more or fewer means.
  • Figure 16 is a schematic diagram of a storage medium provided by at least one embodiment of the present disclosure.
  • storage medium 600 is used to store non-transitory computer-readable instructions 610.
  • the non-transitory computer readable instructions 610 when executed by a computer, may perform one or more steps in the natural language processing method described above.
  • the storage medium 600 can be applied to the above-mentioned electronic device 400.
  • the storage medium 600 may be the memory 420 in the electronic device 400 shown in FIG. 15 .
  • the relevant description of the storage medium 600 may refer to the corresponding description of the memory 420 in the electronic device 400 shown in FIG. 15 , which will not be described again here.

Abstract

A natural language processing method and apparatus, an electronic device, and a storage medium. The natural language processing method comprises: acquiring a task text to be subjected to natural language processing, wherein the task text comprises a plurality of characters; performing feature extraction on the task text by using a shared neural network so as to obtain a shared feature of the task text, wherein the shared feature comprises character features of the plurality of characters and a global relationship among the plurality of characters; and inputting the shared feature into a plurality of functional neural networks to obtain a plurality of processing results respectively output by the plurality of functional neural networks, wherein the plurality of functional neural networks are used for respectively executing a plurality of different natural language processing tasks. According to the natural language processing method, a plurality of neural networks used for natural language processing and having a shared neural network are used to execute a plurality of different natural language processing tasks, such that the parameter scale of a multi-task neural network is reduced, thereby saving computing resources and computing costs.

Description

自然语言处理方法及装置、电子设备和存储介质Natural language processing methods and devices, electronic equipment and storage media
本公开要求于2022年8月26日递交的第202211030338.2号中国专利申请的优先权,在此全文引用上述中国专利申请公开的内容以作为本公开的一部分。This disclosure claims priority from Chinese Patent Application No. 202211030338.2 submitted on August 26, 2022. The disclosure of the above Chinese patent application is hereby cited in its entirety as part of this disclosure.
技术领域Technical field
本公开的实施例涉及一种自然语言处理方法及装置、电子设备和存储介质。Embodiments of the present disclosure relate to a natural language processing method and device, electronic equipment and storage media.
背景技术Background technique
自然语言处理(Natural Language Processing,NLP)是计算机科学领域与人工智能领域中的一个重要方向,用于研究能实现人与计算机之间用自然语言进行有效通信的各种理论和方法。随着人工智能技术的不断发展,自然语言处理开始广泛地应用在诸如客服系统等的多种应用场景中,替代了大量的人工操作。Natural Language Processing (NLP) is an important direction in the field of computer science and artificial intelligence. It is used to study various theories and methods that can achieve effective communication between humans and computers using natural language. With the continuous development of artificial intelligence technology, natural language processing has begun to be widely used in a variety of application scenarios such as customer service systems, replacing a large number of manual operations.
深度学习是机器学习的一大分支,在自然语言处理中应用深度学习模型,如卷积神经网络、循环神经网络等,通过将词或句子的向量化,不断学习语言特征,以完成自然语言分类、理解的过程,满足大量特征工程的自然语言处理要求。Deep learning is a major branch of machine learning. Deep learning models, such as convolutional neural networks, recurrent neural networks, etc., are used in natural language processing to continuously learn language features by vectorizing words or sentences to complete natural language classification. , The process of understanding meets the natural language processing requirements of a large number of feature engineering.
发明内容Contents of the invention
本公开至少一实施例提供一种自然语言处理方法。该自然语言处理方法包括:获取待进行所述自然语言处理的任务文本,其中,所述任务文本包括多个字符;利用共享神经网络对所述任务文本进行特征提取,得到所述任务文本的共享特征,其中,所述共享特征包含所述多个字符的字符特征以及所述多个字符之间的全局联系;将所述共享特征输入多个功能神经网络,得到所述多个功能神经网络分别输出的多个处理结果,其中,所述多个功能神经网络用于分别执行多个不同的自然语言处理任务。At least one embodiment of the present disclosure provides a natural language processing method. The natural language processing method includes: obtaining a task text to be processed by the natural language, wherein the task text includes a plurality of characters; using a shared neural network to perform feature extraction on the task text to obtain sharing of the task text Features, wherein the shared features include character features of the multiple characters and global connections between the multiple characters; input the shared features into multiple functional neural networks to obtain the respective functional neural networks. Multiple output processing results, wherein the multiple functional neural networks are used to perform multiple different natural language processing tasks respectively.
例如,在本公开至少一实施例提供的自然语言处理方法中,所述共享神经 网络包括输入子网络、字嵌入子网络和特征提取子网络,所述利用所述共享神经网络对所述任务文本进行特征提取,得到所述任务文本的所述共享特征,包括:利用所述输入子网络将所述任务文本转换为字索引数组,其中,所述字索引数组包括的多个索引值与所述多个字符一一对应;利用所述字嵌入子网络将所述字索引数组编码为多个字向量,其中,所述多个字向量与所述多个字符一一对应,所述多个字向量中的每个字向量包括对应字符的字符特征;基于所述多个字向量,利用所述特征提取子网络提取所述多个字符之间的所述全局联系,得到所述共享特征。For example, in the natural language processing method provided by at least one embodiment of the present disclosure, the shared neural network includes an input sub-network, a word embedding sub-network and a feature extraction sub-network, and the shared neural network is used to process the task text Perform feature extraction to obtain the shared features of the task text, including: using the input sub-network to convert the task text into a word index array, where the multiple index values included in the word index array are consistent with the Multiple characters correspond one to one; the word index array is encoded into multiple word vectors using the word embedding sub-network, wherein the multiple word vectors correspond to the multiple characters one-to-one, and the multiple words Each word vector in the vector includes character features of the corresponding character; based on the multiple word vectors, the feature extraction sub-network is used to extract the global connection between the multiple characters to obtain the shared features.
例如,在本公开至少一实施例提供的自然语言处理方法中,所述特征提取子网络包括卷积神经网络和长短期记忆网络。For example, in the natural language processing method provided by at least one embodiment of the present disclosure, the feature extraction sub-network includes a convolutional neural network and a long short-term memory network.
例如,在本公开至少一实施例提供的自然语言处理方法中,所述自然语言处理任务包括问答型功能任务,所述问答型功能任务用于解析所述任务文本中的问题,给出所述问题对应的答案,所述多个功能神经网络包括第一功能神经网络,所述第一功能神经网络用于执行所述问答型功能任务,所述将所述共享特征输入所述多个功能神经网络,得到所述多个功能神经网络分别输出的所述多个处理结果,包括:利用所述第一功能神经网络对所述共享特征进行第一处理,得到句向量,其中,所述句向量包括所述任务文本中所述问题的类别信息;将所述句向量与数据库中预存的多个知识信息向量进行比较,以将所述多个知识信息向量中的与所述句向量的向量距离最小的知识信息向量对应的答案作为对应于所述第一功能神经网络的处理结果。For example, in the natural language processing method provided by at least one embodiment of the present disclosure, the natural language processing task includes a question and answer functional task, and the question and answer functional task is used to parse the questions in the task text, and provide the Answers corresponding to the questions, the plurality of functional neural networks include a first functional neural network, the first functional neural network is used to perform the question and answer functional task, and the shared features are input into the multiple functional neural networks. network, obtaining the plurality of processing results respectively output by the plurality of functional neural networks, including: using the first functional neural network to perform a first process on the shared features to obtain a sentence vector, wherein the sentence vector including the category information of the question in the task text; comparing the sentence vector with multiple knowledge information vectors pre-stored in the database to calculate the vector distance between the multiple knowledge information vectors and the sentence vector The answer corresponding to the smallest knowledge information vector is used as the processing result corresponding to the first functional neural network.
例如,在本公开至少一实施例提供的自然语言处理方法中,所述第一处理包括卷积处理、池化处理、特征融合处理和全连接处理。For example, in the natural language processing method provided by at least one embodiment of the present disclosure, the first processing includes convolution processing, pooling processing, feature fusion processing and fully connected processing.
例如,在本公开至少一实施例提供的自然语言处理方法中,所述自然语言处理任务包括闲聊型功能任务,所述闲聊型功能任务用于解析所述任务文本中的无目的性对话信息,给出所述无目的性对话信息对应的系统回答,所述多个功能神经网络包括第二功能神经网络,所述第二功能神经网络用于执行所述闲聊型功能任务,所述将所述共享特征输入所述多个功能神经网络,得到所述多个功能神经网络分别输出的所述多个处理结果,包括:利用所述第二功能神经网络对所述共享特征进行第二处理,得到输出句子以作为对应于所述第二功能神经网络的处理结果,并将对应于所述第二功能神经网络的处理结果作为所述任务文本对应的系统回答。For example, in the natural language processing method provided by at least one embodiment of the present disclosure, the natural language processing task includes a chat-type functional task, and the chat-type functional task is used to parse purposeless dialogue information in the task text, A system answer corresponding to the purposeless dialogue information is given. The plurality of functional neural networks include a second functional neural network. The second functional neural network is used to perform the chat-type functional task. The functional neural network will The shared features are input into the multiple functional neural networks to obtain the multiple processing results respectively output by the multiple functional neural networks, including: using the second functional neural network to perform a second process on the shared features to obtain A sentence is output as a processing result corresponding to the second functional neural network, and the processing result corresponding to the second functional neural network is used as a system answer corresponding to the task text.
例如,在本公开至少一实施例提供的自然语言处理方法中,所述第二功能神经网络包括编码子网络和解码子网络,所述利用所述第二功能神经网络对所述共享特征进行所述第二处理,得到所述输出句子以作为对应于所述第二功能神经网络的处理结果,包括:利用所述编码子网络对所述共享特征进行编码处理得到中间索引数组;利用所述解码子网络对所述中间索引数组进行解码处理得到所述输出句子,以作为对应于所述第二功能神经网络的处理结果。For example, in the natural language processing method provided by at least one embodiment of the present disclosure, the second functional neural network includes a coding sub-network and a decoding sub-network, and the second functional neural network is used to perform all operations on the shared features. The second process to obtain the output sentence as a processing result corresponding to the second functional neural network includes: using the encoding subnetwork to encode the shared features to obtain an intermediate index array; using the decoding The sub-network decodes the intermediate index array to obtain the output sentence as a processing result corresponding to the second functional neural network.
例如,在本公开至少一实施例提供的自然语言处理方法中,所述自然语言处理任务包括任务型功能任务,所述任务型功能任务用于解析所述任务文本中的任务目的信息和任务关键词信息,根据所述任务目的信息和所述任务关键词信息得到系统追问或问答结果,所述多个功能神经网络包括第三功能神经网络,所述第三功能神经网络用于执行所述任务型功能任务,所述将所述共享特征输入所述多个功能神经网络,得到所述多个功能神经网络分别输出的所述多个处理结果,包括:利用所述第三功能神经网络对所述共享特征进行第三处理,得到对应于所述任务文本的意图特征和至少一个命名实体,其中,所述意图特征包含所述任务文本中的所述任务目的信息,所述至少一个命名实体包含所述任务关键词信息;对所述意图特征和所述至少一个命名实体进行对话管理,得到所述系统追问或所述问答结果以作为对应于所述第三功能神经网络的处理结果。For example, in the natural language processing method provided by at least one embodiment of the present disclosure, the natural language processing task includes a task-type functional task, and the task-type functional task is used to parse the task purpose information and task key in the task text. Word information, obtain system questioning or question and answer results according to the task purpose information and the task keyword information, the plurality of functional neural networks include a third functional neural network, and the third functional neural network is used to perform the task Type functional task, inputting the shared features into the plurality of functional neural networks to obtain the plurality of processing results respectively output by the plurality of functional neural networks includes: using the third functional neural network to Perform a third process on the shared features to obtain intent features and at least one named entity corresponding to the task text, where the intent features include the task purpose information in the task text, and the at least one named entity includes The task keyword information; perform dialogue management on the intent feature and the at least one named entity, and obtain the system questioning or the question and answer result as a processing result corresponding to the third functional neural network.
例如,在本公开至少一实施例提供的自然语言处理方法中,所述第三功能神经网络包括意图识别子网络和命名实体识别子网络,所述利用所述第三功能神经网络对所述共享特征进行所述第三处理,得到对应于所述任务文本的所述意图特征和所述至少一个命名实体,包括:利用所述意图识别子网络,基于所述共享特征进行意图识别,得到对应于所述任务文本的所述意图特征;利用所述命名实体识别子网络,基于所述共享特征执行命名实体识别,得到对应于所述任务文本的所述至少一个命名实体。For example, in the natural language processing method provided by at least one embodiment of the present disclosure, the third functional neural network includes an intent recognition sub-network and a named entity recognition sub-network, and the third functional neural network is used to analyze the shared Perform the third processing on the features to obtain the intent features and the at least one named entity corresponding to the task text, including: using the intent recognition sub-network to perform intent recognition based on the shared features to obtain the intent features corresponding to the task text. The intended features of the task text; using the named entity recognition sub-network, perform named entity recognition based on the shared features to obtain the at least one named entity corresponding to the task text.
例如,在本公开至少一实施例提供的自然语言处理方法中,所述获取所述待进行所述自然语言处理的所述任务文本,包括:获取所述待进行所述自然语言处理的语音片段;将所述语音片段转换为文字形式,以得到所述任务文本。For example, in the natural language processing method provided by at least one embodiment of the present disclosure, obtaining the task text to be subjected to the natural language processing includes: obtaining the speech segment to be subjected to the natural language processing. ; Convert the voice clip into text form to obtain the task text.
例如,本公开至少一实施例提供的自然语言处理方法,还包括通过仲裁选择从所述多个处理结果中选择一个处理结果作为所述自然语言处理的输出结果。For example, the natural language processing method provided by at least one embodiment of the present disclosure further includes selecting one processing result from the plurality of processing results as the output result of the natural language processing through arbitration selection.
例如,本公开至少一实施例提供的自然语言处理方法,在获取所述自然语言对应的所述任务文本之前,还包括:获取训练文本;基于所述训练文本,对待训练的多个功能神经网络进行训练,以得到训练好的所述多个功能神经网络,其中,所述多个功能神经网络的数量为N,N为大于1的整数,其中,在训练待训练的N个功能神经网络过程中,所述N个功能神经网络同时训练,且计算所述N个功能神经网络对应的M个中间损失值的加权和作为损失值以更新所述N个功能神经网络的参数,所述M个中间损失值分别对应的M个权重,所述M个权重根据所述N个功能神经网络的输出准确度进行动态调整,M为大于等于N的整数。For example, the natural language processing method provided by at least one embodiment of the present disclosure, before obtaining the task text corresponding to the natural language, further includes: obtaining a training text; based on the training text, multiple functional neural networks to be trained Training is performed to obtain the plurality of trained functional neural networks, where the number of the plurality of functional neural networks is N, and N is an integer greater than 1, wherein in the process of training the N functional neural networks to be trained , the N functional neural networks are trained simultaneously, and the weighted sum of the M intermediate loss values corresponding to the N functional neural networks is calculated as the loss value to update the parameters of the N functional neural networks, and the M The intermediate loss values correspond to M weights respectively. The M weights are dynamically adjusted according to the output accuracy of the N functional neural networks. M is an integer greater than or equal to N.
例如,在本公开至少一实施例提供的自然语言处理方法中,所述N个功能神经网络包括第一功能神经网络、第二功能神经网络和第三功能神经网络,所述第三功能神经网络包括意图识别子网络和命名实体识别子网络,所述基于所述训练文本,对所述待训练的多个功能神经网络进行训练,包括:利用待训练的共享神经网络对所述训练文本进行特征提取,得到所述训练文本的训练共享特征;利用所述N个功能神经网络对所述训练共享特征分别进行处理,得到所述N个功能神经网络分别输出的M组第一中间结果,其中,所述M组第一中间结果包括所述第一功能神经网络输出的第一中间结果、所述第二功能神经网络输出的第一中间结果、所述意图识别子网络输出的第一中间结果和所述命名实体识别子网络输出的第一中间结果。For example, in the natural language processing method provided by at least one embodiment of the present disclosure, the N functional neural networks include a first functional neural network, a second functional neural network, and a third functional neural network, and the third functional neural network It includes an intent recognition sub-network and a named entity recognition sub-network, and training the multiple functional neural networks to be trained based on the training text includes: using the shared neural network to be trained to characterize the training text. Extract and obtain the training shared features of the training text; use the N functional neural networks to process the training shared features respectively, and obtain M sets of first intermediate results respectively output by the N functional neural networks, where, The M sets of first intermediate results include the first intermediate results output by the first functional neural network, the first intermediate results output by the second functional neural network, the first intermediate results output by the intention recognition sub-network, and A first intermediate result output by the named entity recognition sub-network.
例如,在本公开至少一实施例提供的自然语言处理方法中,所述基于所述训练文本,对所述待训练的多个功能神经网络进行训练,还包括:基于所述训练文本和所述M组第一中间结果计算所述N个功能神经网络对应的M个中间损失值,其中,所述M个中间损失值包括所述第一功能神经网络对应的中间损失值、所述第二功能神经网络对应的中间损失值、所述意图识别子网络对应的中间损失值和所述命名实体识别子网络对应的中间损失值;计算所述M个中间损失值的加权和作为所述损失值;在所述损失值未满足预定收敛条件时,基于所述损失值更新所述待训练的所述共享神经网络和所述N个功能神经网络的参数。For example, in the natural language processing method provided by at least one embodiment of the present disclosure, training the multiple functional neural networks to be trained based on the training text further includes: based on the training text and the M sets of first intermediate results calculate M intermediate loss values corresponding to the N functional neural networks, where the M intermediate loss values include the intermediate loss values corresponding to the first functional neural network, the second functional The intermediate loss value corresponding to the neural network, the intermediate loss value corresponding to the intention recognition sub-network and the intermediate loss value corresponding to the named entity recognition sub-network; calculate the weighted sum of the M intermediate loss values as the loss value; When the loss value does not satisfy the predetermined convergence condition, the parameters of the shared neural network to be trained and the N functional neural networks are updated based on the loss value.
例如,在本公开至少一实施例提供的自然语言处理方法中,所述基于所述训练文本,对所述待训练的多个功能神经网络进行训练,还包括:获取测试文本;利用训练后的所述共享神经网络和训练后的所述N个功能神经网络对所 述测试文本进行处理,得到M组第二中间结果;基于所述M组第二中间结果和所述测试文本,确定分别对应于所述训练后的N个功能神经网络的M个输出准确度,其中,所述M个输出准确度包括所述第一功能神经网络的输出准确度、所述第二功能神经网络的输出准确度、所述意图识别子网络的输出准确度和所述命名实体识别子网络的输出准确度;基于所述M个输出准确度调整所述M个中间损失值分别对应的M个权重;根据调整后的所述M个权重继续对所述待训练的多个功能神经网络进行训练。For example, in the natural language processing method provided by at least one embodiment of the present disclosure, training the multiple functional neural networks to be trained based on the training text also includes: obtaining a test text; using the trained The shared neural network and the trained N functional neural networks process the test text to obtain M sets of second intermediate results; based on the M sets of second intermediate results and the test text, determine the respective corresponding The M output accuracies of the N functional neural networks after training, wherein the M output accuracies include the output accuracy of the first functional neural network, the output accuracy of the second functional neural network degree, the output accuracy of the intention recognition sub-network and the output accuracy of the named entity recognition sub-network; adjust the M weights respectively corresponding to the M intermediate loss values based on the M output accuracies; according to the adjustment The subsequent M weights continue to train the multiple functional neural networks to be trained.
例如,在本公开至少一实施例提供的自然语言处理方法中,所述基于所述M个输出准确度调整所述M个中间损失值分别对应的M个权重,包括:确定所述M个输出准确度中的最大输出准确度对应的权重作为第一权重;保持所述第一权重不变,增大所述M个权重中除所述第一权重以外的其他M-1个权重。For example, in the natural language processing method provided by at least one embodiment of the present disclosure, adjusting the M weights respectively corresponding to the M intermediate loss values based on the M output accuracies includes: determining the M outputs The weight corresponding to the maximum output accuracy in the accuracy is used as the first weight; keep the first weight unchanged, and increase the other M-1 weights among the M weights except the first weight.
例如,在本公开至少一实施例提供的自然语言处理方法中,所述增大所述M个权重中除所述第一权重以外的其他M-1个权重,包括:根据所述M-1个权重对应的M-1个输出准确度的大小关系,确定所述M-1个权重的M-1个放大因子,其中,对于所述M-1个输出准确度中的任一个输出准确度,响应于所述任一个输出准确度越大,所述任一个输出准确度对应的权重的放大因子越小;根据所述M-1个权重的放大因子,调整所述M-1个权重。For example, in the natural language processing method provided by at least one embodiment of the present disclosure, increasing M-1 weights other than the first weight among the M weights includes: according to the M-1 The magnitude relationship between the M-1 output accuracies corresponding to the M-1 weights is determined, and the M-1 amplification factors of the M-1 weights are determined, wherein, for any one of the M-1 output accuracies, the output accuracy , in response to the greater the accuracy of any of the outputs, the smaller the amplification factor of the weight corresponding to the accuracy of any of the outputs; adjust the M-1 weights according to the amplification factors of the M-1 weights.
本公开至少一实施例还提供一种自然语言处理装置。该自然语言处理装置包括:获取模块,配置为获取待进行所述自然语言处理的任务文本,其中,所述任务文本包括多个字符;提取模块,配置为利用共享神经网络对所述任务文本进行特征提取,得到所述任务文本的共享特征,其中,所述共享特征包含所述多个字符的字符特征以及所述多个字符之间的全局联系;处理模块,配置为将所述共享特征输入多个功能神经网络,得到所述多个功能神经网络分别输出的多个处理结果,其中,所述多个功能神经网络用于执行多个不同的自然语言处理任务。At least one embodiment of the present disclosure also provides a natural language processing device. The natural language processing device includes: an acquisition module configured to acquire a task text to be processed by the natural language, wherein the task text includes a plurality of characters; and an extraction module configured to use a shared neural network to perform the task text on the task text. Feature extraction to obtain shared features of the task text, where the shared features include character features of the multiple characters and global connections between the multiple characters; a processing module configured to input the shared features Multiple functional neural networks are used to obtain multiple processing results respectively output by the multiple functional neural networks, where the multiple functional neural networks are used to perform multiple different natural language processing tasks.
例如,在本公开至少一实施例提供的自然语言处理装置中,所述获取模块还配置为获取训练文本。For example, in the natural language processing device provided by at least one embodiment of the present disclosure, the acquisition module is further configured to acquire training text.
例如,本公开至少一实施例提供的自然语言处理装置,还包括训练模块,所述训练模块配置为,基于所述训练文本,对待训练的多个功能神经网络进行训练,以得到训练好的所述多个功能神经网络,其中,所述多个功能神经网络 的数量为N,N为大于1的整数,其中,在训练所述待训练的N个功能神经网络过程中,所述N个功能神经网络同时训练,且计算所述N个功能神经网络对应的M个中间损失值的加权和作为损失值以更新所述N个功能神经网络的参数,所述M个中间损失值分别对应的M个权重,对所述M个权重根据所述N个功能神经网络的输出准确度进行动态调整,M为大于等于N的整数。For example, the natural language processing device provided by at least one embodiment of the present disclosure further includes a training module configured to, based on the training text, train multiple functional neural networks to be trained to obtain the trained Described multiple functional neural networks, wherein the number of the multiple functional neural networks is N, and N is an integer greater than 1, wherein, in the process of training the N functional neural networks to be trained, the N functional neural networks Neural networks are trained simultaneously, and the weighted sum of M intermediate loss values corresponding to the N functional neural networks is calculated as the loss value to update the parameters of the N functional neural networks, and the M intermediate loss values correspond to M respectively. weights, and the M weights are dynamically adjusted according to the output accuracy of the N functional neural networks, where M is an integer greater than or equal to N.
本公开至少一实施例还提供一种电子设备。该电子设备包括:处理器;存储器,包括一个或多个计算机程序模块;其中,所述一个或多个计算机程序模块被存储在所述存储器中并被配置为由所述处理器执行,所述一个或多个计算机程序模块包括用于实现本公开任一实施例提供的自然语言处理方法。At least one embodiment of the present disclosure also provides an electronic device. The electronic device includes: a processor; a memory including one or more computer program modules; wherein the one or more computer program modules are stored in the memory and configured to be executed by the processor, the One or more computer program modules are included for implementing the natural language processing method provided by any embodiment of the present disclosure.
本公开至少一实施例还提供一种存储介质,用于存储非暂时性计算机可读指令,当所述非暂时性计算机可读指令由计算机执行时可以实现本公开任一实施例提供的自然语言处理方法。At least one embodiment of the present disclosure also provides a storage medium for storing non-transitory computer-readable instructions. When the non-transitory computer-readable instructions are executed by a computer, the natural language provided by any embodiment of the present disclosure can be realized. Approach.
附图说明Description of drawings
为了更清楚地说明本公开实施例的技术方案,下面将对实施例的附图作简单地介绍,显而易见地,下面描述中的附图仅仅涉及本公开的一些实施例,而非对本公开的限制。In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings of the embodiments will be briefly introduced below. Obviously, the drawings in the following description only relate to some embodiments of the present disclosure and do not limit the present disclosure. .
图1为一种多任务神经网络自然语言处理系统的示意图;Figure 1 is a schematic diagram of a multi-task neural network natural language processing system;
图2为本公开至少一实施例提供的一种自然语言处理方法的示例性流程图;Figure 2 is an exemplary flow chart of a natural language processing method provided by at least one embodiment of the present disclosure;
图3为本公开至少一实施例提供的共享神经网络和多个功能神经网络的一个示例的示意图;Figure 3 is a schematic diagram of an example of a shared neural network and multiple functional neural networks provided by at least one embodiment of the present disclosure;
图4为图2中步骤S120的一个示例的示例性流程图;Figure 4 is an exemplary flow chart of an example of step S120 in Figure 2;
图5为本公开至少一实施例提供的共享神经网络和多个功能神经网络的另一示例的示意图;Figure 5 is a schematic diagram of another example of a shared neural network and multiple functional neural networks provided by at least one embodiment of the present disclosure;
图6为本公开至少一实施例提供的第一功能神经网络的一个示例的示意图;Figure 6 is a schematic diagram of an example of a first functional neural network provided by at least one embodiment of the present disclosure;
图7为本公开至少一实施例提供的第二功能神经网络的一个示例的示意图;Figure 7 is a schematic diagram of an example of a second functional neural network provided by at least one embodiment of the present disclosure;
图8为本公开至少一实施例提供的第三功能神经网络的一个示例的示意 图;Figure 8 is a schematic diagram of an example of a third functional neural network provided by at least one embodiment of the present disclosure;
图9为本公开至少一实施例提供的自然语言处理方法的训练部分的示意图;Figure 9 is a schematic diagram of the training part of the natural language processing method provided by at least one embodiment of the present disclosure;
图10为图9中步骤S150的一个示例的示意图;Figure 10 is a schematic diagram of an example of step S150 in Figure 9;
图11为图9中步骤S150的另一示例的示意图;Figure 11 is a schematic diagram of another example of step S150 in Figure 9;
图12为本公开至少一实施例提供的共享神经网络和多个功能神经网络的损失函数的一个示例的示意图;Figure 12 is a schematic diagram of an example of a loss function of a shared neural network and multiple functional neural networks provided by at least one embodiment of the present disclosure;
图13为本公开的至少一实施例提供的自然语言处理装置的示意框图;Figure 13 is a schematic block diagram of a natural language processing device provided by at least one embodiment of the present disclosure;
图14为本公开的至少一实施例提供的一种电子设备的示意框图;Figure 14 is a schematic block diagram of an electronic device provided by at least one embodiment of the present disclosure;
图15为本公开的至少一实施例提供的另一种电子设备的示意框图;以及Figure 15 is a schematic block diagram of another electronic device provided by at least one embodiment of the present disclosure; and
图16为本公开的至少一实施例提供的一种存储介质的示意图。Figure 16 is a schematic diagram of a storage medium provided by at least one embodiment of the present disclosure.
具体实施方式Detailed ways
为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合本公开实施例的附图,对本公开实施例的技术方案进行清楚、完整地描述。显然,所描述的实施例是本公开的一部分实施例,而不是全部的实施例。基于所描述的本公开的实施例,本领域普通技术人员在无需创造性劳动的前提下所获得的所有其他实施例,都属于本公开保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings of the embodiments of the present disclosure. Obviously, the described embodiments are some, but not all, of the embodiments of the present disclosure. Based on the described embodiments of the present disclosure, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present disclosure.
除非另外定义,本公开使用的技术术语或者科学术语应当为本公开所属领域内具有一般技能的人士所理解的通常意义。本公开中使用的“第一”、“第二”以及类似的词语并不表示任何顺序、数量或者重要性,而只是用来区分不同的组成部分。同样,“一个”、“一”或者“该”等类似词语也不表示数量限制,而是表示存在至少一个。“包括”或者“包含”等类似的词语意指出现该词前面的元件或者物件涵盖出现在该词后面列举的元件或者物件及其等同,而不排除其他元件或者物件。“连接”或者“相连”等类似的词语并非限定于物理的或者机械的连接,而是可以包括电性的连接,不管是直接的还是间接的。“上”、“下”、“左”、“右”等仅用于表示相对位置关系,当被描述对象的绝对位置改变后,则该相对位置关系也可能相应地改变。Unless otherwise defined, technical terms or scientific terms used in this disclosure shall have the usual meaning understood by a person with ordinary skill in the art to which this disclosure belongs. "First", "second" and similar words used in this disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. Likewise, similar words such as "a", "an" or "the" do not indicate a quantitative limitation but rather indicate the presence of at least one. Words such as "include" or "comprising" mean that the elements or things appearing before the word include the elements or things listed after the word and their equivalents, without excluding other elements or things. Words such as "connected" or "connected" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right", etc. are only used to express relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
下面通过几个具体的实施例对本公开进行说明。为了保持本公开实施例的以下说明清楚且简明,可省略已知功能和已知部件的详细说明。当本公开实施例的任一部件在一个以上的附图中出现时,该部件在每个附图中由相同或 类似的参考标号表示。The present disclosure is described below through several specific embodiments. In order to keep the following description of the embodiments of the present disclosure clear and concise, detailed descriptions of known functions and components may be omitted. When any component of the disclosed embodiments appears in more than one drawing, the component is designated by the same or similar reference number in each drawing.
自然语言处理是指利用人类交流所使用的自然语言与机器进行交互通讯的技术,涉及语音、语法、语义、语用等多维度的操作。简单而言,自然语言处理的基本任务是基于本体词典、词频统计、上下文语义分析等方式对待处理语料进行分词,形成以最小词性为单位,且富含语义的词项单元。Natural language processing refers to the technology that uses natural language used in human communication to interact with machines, involving multi-dimensional operations such as speech, grammar, semantics, and pragmatics. Simply put, the basic task of natural language processing is to segment the corpus to be processed based on ontology dictionary, word frequency statistics, contextual semantic analysis and other methods to form word units with the smallest part of speech as the unit and rich in semantics.
自然语言处理广泛应用于人机交互通信场合,例如,汽车车内人机语音交互和手机语音助手等。汽车车内人机语音交互和手机语音助手是多垂直领域、支持开放域的应用,其中的人机对话既包含类似百科的知识问答,也包含无目的闲聊,还包含为完成某个特定任务的交互,如控制车辆、查火车票机票等。例如,根据对话类型的不同,可以把自然语言处理任务分成问答型功能任务、闲聊型功能任务和任务型功能任务:Natural language processing is widely used in human-computer interactive communication situations, such as human-computer voice interaction in cars and mobile phone voice assistants. Human-computer voice interaction in cars and mobile phone voice assistants are multi-vertical applications that support open domains. The human-computer dialogue includes encyclopedia-like knowledge questions and answers, purposeless chatting, and conversations to complete a specific task. Interaction, such as controlling vehicles, checking train tickets, etc. For example, according to different types of dialogue, natural language processing tasks can be divided into question-and-answer functional tasks, chat-type functional tasks and task-type functional tasks:
(1)问答型功能任务可以处理基于知识库的问答,举例:(1) Question and answer functional tasks can handle question and answer based on knowledge base, for example:
用户:珠穆朗玛峰高多少米?User: How many meters high is Mount Everest?
系统:珠穆朗玛峰高8848米。System: Mount Everest is 8,848 meters high.
(2)闲聊型功能任务可以处理无目的的对话,举例:(2) Chat-type functional tasks can handle purposeless conversations, for example:
用户:我今天心情不好。User: I'm in a bad mood today.
系统:笑口常开,才能延年益寿。System: Only by smiling often can you prolong your life.
(3)任务型功能任务可以处理带有词槽或者多轮的对话,举例:(3) Task-type functional tasks can handle dialogues with word slots or multiple rounds, for example:
用户:帮我查下去北京的车票。User: Help me find the ticket to Beijing.
系统:查到如下车票,请问您要几点出发的?System: The following tickets were found. What time do you want to depart?
用户:3点半左右的,一等座的高铁。User: Around 3:30, first-class high-speed train.
系统:有如下车次,请问从虹桥站出发还是上海站出发?System: There are the following trains. Does it depart from Hongqiao Station or Shanghai Station?
用户:上海站。User: Shanghai Station.
系统:好的,下面是今天3:30左右从上海站去北京的高铁一等座车票。System: Okay, here are the first-class high-speed rail tickets from Shanghai Station to Beijing around 3:30 today.
例如,由于不同的自然语言处理任务所执行的功能不同,为完成相应的功能所要执行的处理也不同,例如,为完成如上三种不同的对话类型,需要使用不同结构的神经网络实现。由于神经网络的结构不同,各个神经网络均独立执行对神经网络输入的处理,并输出该神经网络的处理结果。For example, since different natural language processing tasks perform different functions, the processing required to complete the corresponding functions is also different. For example, in order to complete the above three different dialogue types, neural network implementations with different structures need to be used. Due to the different structures of neural networks, each neural network independently processes the input of the neural network and outputs the processing result of the neural network.
图1为一种用于自然语言处理的多任务神经网络的示意图。例如,如图1所示,该多任务神经网络由3个不同的神经网络组成:问答型神经网络、闲聊型神经网络和任务型神经网络,3个神经网络独立设置,分别包含输入层、 NLP特征提取部分、多个隐藏层(例如图1中的隐藏层1-1、...、隐藏层1-x等)以及输出层,隐藏层可以为根据实际需要选择适合的神经网络结构。例如,3个神经网络的各层的权重参数以及隐藏层的具体结构和层数可能均不相同,从而各自完成不同的功能。例如,问答型神经网络用于执行问答型功能任务,闲聊型神经网络用于执行闲聊型功能任务,任务型神经网络用于执行任务型功能任务。例如,可以将同一个任务文本分别输入3个神经网络,3个神经网络分别对任务文本进行不同的推理得到各自的处理结果,最后仲裁选择最佳的处理结果作为对任务文本的回答。Figure 1 is a schematic diagram of a multi-task neural network for natural language processing. For example, as shown in Figure 1, the multi-task neural network consists of three different neural networks: question and answer neural network, chat neural network and task neural network. The three neural networks are set up independently and include input layer, NLP respectively. Feature extraction part, multiple hidden layers (such as hidden layer 1-1,..., hidden layer 1-x, etc. in Figure 1) and output layer. The hidden layer can be a suitable neural network structure selected according to actual needs. For example, the weight parameters of each layer of the three neural networks and the specific structure and number of layers of the hidden layer may be different, so that they each complete different functions. For example, question-and-answer neural networks are used to perform question-and-answer functional tasks, chat-type neural networks are used to perform chat-type functional tasks, and task-based neural networks are used to perform task-type functional tasks. For example, the same task text can be input into three neural networks respectively, and the three neural networks perform different inferences on the task text to obtain their own processing results. Finally, arbitration selects the best processing result as the answer to the task text.
对于例如图1的多任务神经网络,3个神经网络分别由多个网络层(如输入层、隐藏层等)组成,每个神经网络的规模都较大,这会导致神经网络模型太多,并且模型尺寸较大,因而占用了过多的计算资源;特别是在资源受限的端侧设备上,同时设置和运行3个神经网络,常常出现资源不够的问题。For example, for the multi-task neural network in Figure 1, the three neural networks are composed of multiple network layers (such as input layer, hidden layer, etc.). The scale of each neural network is large, which will lead to too many neural network models. Moreover, the size of the model is large, so it takes up too much computing resources; especially on end-side devices with limited resources, setting up and running three neural networks at the same time often leads to the problem of insufficient resources.
例如,如图1所示,3个神经网络均包括输入层和特征提取部分,该三个网络层功能接近,均是提取输入的任务文本中的特征;由于输入的3个神经网络为相同的任务文本,3个神经网络的输入层和NLP特征提取部分可以共享参数权重。然而,由于3个神经网络独立设置,可以共享参数权重的前三层也分别设置,导致计算资源的重复和浪费。For example, as shown in Figure 1, the three neural networks all include an input layer and a feature extraction part. The three network layers have similar functions and are all used to extract features from the input task text; since the three input neural networks are the same The task text, the input layer of the three neural networks and the NLP feature extraction part can share parameter weights. However, since the three neural networks are set up independently, the first three layers that can share parameter weights are also set up separately, resulting in duplication and waste of computing resources.
本公开至少一实施例提供一种自然语言处理方法。该自然语言处理方法包括:获取待进行自然语言处理的任务文本,其中,任务文本包括多个字符;利用共享神经网络对任务文本进行特征提取,得到任务文本的共享特征,其中,共享特征包含多个字符的字符特征以及多个字符之间的全局联系;将共享特征输入多个功能神经网络,得到多个功能神经网络分别输出的多个处理结果,其中,多个功能神经网络用于分别执行多个不同的自然语言处理任务。At least one embodiment of the present disclosure provides a natural language processing method. The natural language processing method includes: obtaining a task text to be processed by natural language, where the task text includes multiple characters; using a shared neural network to extract features from the task text to obtain shared features of the task text, where the shared features include multiple characters. Character features of characters and global connections between multiple characters; input shared features into multiple functional neural networks to obtain multiple processing results output by multiple functional neural networks respectively, where multiple functional neural networks are used to execute respectively Multiple different natural language processing tasks.
本公开的多个实施例还提供一种对应于执行上述自然语言处理方法的装置、电子设备或存储介质。Various embodiments of the present disclosure also provide a device, electronic device or storage medium corresponding to executing the above natural language processing method.
在本公开至少一实施例提供的自然语言处理方法中,利用共享神经网络提取不同功能任务之间可以共享的共享特征,例如任务文本自身的字符特征、字符之间的上下文联系等,各个共享神经网络对共享特征进行不同的后续处理,从而执行不同的自然语言处理任务,由此使得多个功能神经网络能够共享该共享神经网络的权重参数,减少了神经网络参数规模,进而节省了计算资源,避免计算资源的重复和浪费,节约了计算成本。In the natural language processing method provided by at least one embodiment of the present disclosure, a shared neural network is used to extract shared features that can be shared between different functional tasks, such as character features of the task text itself, contextual connections between characters, etc. Each shared neural network The network performs different subsequent processing on the shared features to perform different natural language processing tasks, thereby enabling multiple functional neural networks to share the weight parameters of the shared neural network, reducing the size of the neural network parameters and thus saving computing resources. Avoid duplication and waste of computing resources and save computing costs.
下面,将参考附图详细地说明本公开至少一实施例。应当注意的是,不同的附图中相同的附图标记将用于指代已描述的相同的元件。Below, at least one embodiment of the present disclosure will be described in detail with reference to the accompanying drawings. It should be noted that the same reference numbers in different figures will be used to refer to the same elements that have been described.
图2为本公开至少一实施例提供的一种自然语言处理方法的示例性流程图。Figure 2 is an exemplary flow chart of a natural language processing method provided by at least one embodiment of the present disclosure.
例如,如图2所示,本公开至少一实施例提供的自然语言处理方法,用于同时对多个不同的自然语言任务进行处理。例如,该自然语言处理方法包括以下步骤S110~S130。For example, as shown in FIG. 2 , a natural language processing method provided by at least one embodiment of the present disclosure is used to process multiple different natural language tasks at the same time. For example, the natural language processing method includes the following steps S110 to S130.
步骤S110:获取待进行自然语言处理的任务文本;Step S110: Obtain the task text to be processed by natural language;
步骤S120:利用共享神经网络对任务文本进行特征提取,得到任务文本的共享特征;Step S120: Use a shared neural network to extract features from the task text to obtain shared features of the task text;
步骤S130:将共享特征输入多个功能神经网络,得到多个功能神经网络分别输出的多个处理结果。Step S130: Input the shared features into multiple functional neural networks to obtain multiple processing results respectively output by the multiple functional neural networks.
例如,在步骤S110中,待进行自然语言处理的任务文本例如为人机交互过程中的用户输入句子的字符串,即该任务文本包括多个字符。For example, in step S110, the task text to be subjected to natural language processing is, for example, a string of sentences input by the user during human-computer interaction, that is, the task text includes multiple characters.
例如,任务文本可以是各种语言的文本,例如,中文、英文、日文等。例如,当任务文本为中文文本时,字符为单个汉字的形式,当任务文本为英文文本时,字符为单个单词的形式。例如,任务文本还可以包括各种数字等,单个数字也可以作为一个字符。For example, the task text can be text in various languages, such as Chinese, English, Japanese, etc. For example, when the task text is Chinese text, the characters are in the form of a single Chinese character, and when the task text is English text, the characters are in the form of a single word. For example, the task text can also include various numbers, etc., and a single number can also be used as a character.
例如,任务文本可以是单一语言的文本,例如纯中文文本,例如,任务文本也可以是多种语言混合的文本,例如,中英文混合文本。本公开对任务文本的形式、语言不作具体限制。For example, the task text can be a text in a single language, such as a pure Chinese text. For example, the task text can also be a mixed text in multiple languages, such as a mixed Chinese and English text. This disclosure does not place specific restrictions on the form and language of the task text.
例如,在一些示例中,步骤S110可以包括:获取待进行自然语言处理的语音片段;将语音片段转换为文字形式,以得到任务文本。例如,在例如人机语音交互等应用场合中,首先获取用户的语音片段,再将语音片段转换为文字形式以作为任务文本。本公开对语音片段转任务文本的具体转换方法不作具体限制。For example, in some examples, step S110 may include: obtaining a voice segment to be subjected to natural language processing; and converting the voice segment into text form to obtain the task text. For example, in applications such as human-computer voice interaction, the user's voice fragments are first obtained, and then the voice fragments are converted into text form as the task text. This disclosure places no specific restrictions on the specific conversion method of speech clips into task text.
例如,在步骤S120中,共享特征包含多个字符的字符特征以及多个字符之间的全局联系。例如,任务文本经过共享神经网络的特征提取转化为多个特征向量,共享特征被包含在多个特征向量中,即多个特征向量既包含每个字符的含义,又包含所有字符之间的联系(即全局联系),从而包含了整个输入句子的有效信息。这里,多个字符之间的全局联系为多个字符之间的上下文联 系,字符特征体现了单个字符的含义,而多个字符之间的全局联系体现了多个字符之间有意义的前后文关系,表达了句子的有效消息。For example, in step S120, the shared features include character features of multiple characters and global connections between multiple characters. For example, the task text is transformed into multiple feature vectors through feature extraction by the shared neural network. The shared features are included in multiple feature vectors, that is, multiple feature vectors contain both the meaning of each character and the connections between all characters. (i.e. global connection), thus containing effective information of the entire input sentence. Here, the global connection between multiple characters is the contextual connection between multiple characters. The character characteristics reflect the meaning of a single character, and the global connection between multiple characters reflects the meaningful context between multiple characters. Relationships, express the effective message of the sentence.
例如,在步骤S130中,多个功能神经网络对共享特征进行处理得到多个处理结果。例如,多个功能神经网络用于分别执行多个不同的自然语言处理任务。例如,根据对话类型的不同,多个不同的自然语言处理任务可以包括问答型功能任务、闲聊型功能任务和任务型功能任务,或者也可以包括人机交互过程中根据用户输入文本产生的其他类型的功能任务,本公开的实施例对自然语言处理任务的类型不作限制。For example, in step S130, multiple functional neural networks process shared features to obtain multiple processing results. For example, multiple functional neural networks are used to perform multiple different natural language processing tasks respectively. For example, depending on the type of conversation, multiple different natural language processing tasks may include question-and-answer functional tasks, chat-type functional tasks, and task-based functional tasks, or may also include other types generated based on user input text during human-computer interaction. Functional tasks, embodiments of the present disclosure do not limit the types of natural language processing tasks.
图3为本公开至少一实施例提供的共享神经网络和多个功能神经网络的一个示例的示意图。例如,在一些示例中,可以通过如图3所示的共享神经网络和N个功能神经网络实施图2所示的自然语言处理方法,N个功能神经网络用于分别执行N个不同的自然语言处理任务,这里N为正整数。FIG. 3 is a schematic diagram of an example of a shared neural network and multiple functional neural networks provided by at least one embodiment of the present disclosure. For example, in some examples, the natural language processing method shown in Figure 2 can be implemented by a shared neural network as shown in Figure 3 and N functional neural networks used to perform N different natural languages respectively. Processing tasks, where N is a positive integer.
例如,如图3所示,共享神经网络可以用于在步骤S120中对任务文本进行特征提取,得到任务文本的共享特征;N个功能神经网络用于在步骤S130中对共享特征输入进行处理,分别输出多个处理结果。For example, as shown in Figure 3, the shared neural network can be used to extract features from the task text in step S120 to obtain the shared features of the task text; N functional neural networks can be used to process the shared feature input in step S130. Output multiple processing results separately.
例如,相比于图1中3个独立的神经网络的输入层和NLP特征提取部分独立设置,本公开至少一实施例提供的自然语言处理方法可以共享图3中共享神经网络的参数权重,共享神经网络例如可以由图1中3个独立的神经网络的输入层和NLP特征提取部分融合而成;共享神经网络也可以由其他多个独立神经网络中共享权重的网络层融合而成,本公开的实施例对此不作限制。For example, compared with the input layers and NLP feature extraction parts of the three independent neural networks in Figure 1 being set independently, the natural language processing method provided by at least one embodiment of the present disclosure can share the parameter weights of the shared neural network in Figure 3, sharing For example, the neural network can be formed by merging the input layers and NLP feature extraction parts of three independent neural networks in Figure 1; the shared neural network can also be fused by the network layers that share weights in multiple other independent neural networks. This disclosure The embodiment does not limit this.
例如,如图3所示,共享神经网络包括输入子网络S1、字嵌入子网络S2和特征提取子网络S3。For example, as shown in Figure 3, the shared neural network includes an input sub-network S1, a word embedding sub-network S2 and a feature extraction sub-network S3.
例如,输入子网络S1可以实现为独热(One-Hot)转换层,配置为对任务文本中的各个字符进行独热编码,将各个字符转换为其对应的索引值,各个索引值构成字索引数组。当然,输入子网络S1也可以实现为其他结构,索引值不限为独热码形式,只要能将任务文本的各个字符转换成唯一对应的索引值即可。For example, the input subnetwork S1 can be implemented as a One-Hot conversion layer, configured to perform one-hot encoding on each character in the task text, convert each character into its corresponding index value, and each index value constitutes a word index. array. Of course, the input subnetwork S1 can also be implemented as other structures, and the index value is not limited to the one-hot code form, as long as each character of the task text can be converted into a unique corresponding index value.
例如,字嵌入子网络S2可以将字索引数组转换为多维字向量,用以表示每个字的意思(即字符特征);字嵌入子网络S2可以根据实际需要实现为适合的神经网络结构。For example, the word embedding subnetwork S2 can convert the word index array into a multi-dimensional word vector to represent the meaning of each word (i.e., character features); the word embedding subnetwork S2 can be implemented as a suitable neural network structure according to actual needs.
例如,特征提取子网络S3配置为提取出任务文本的多个字符之间的全局 联系,得到多个特征向量。例如,特征提取子网络S可以包括卷积神经网络(Convolutional Neural Network,CNN)和长短记忆网络(Long-Stort Term Memory,LSTM),甚至是更大规模的BERT(Bidirectional Encoder Representation from Transformer)网络,也可以是其他卷积、全连接或者是更大规模的神经网络,本公开的实施例对于特征提取子网络S3的网络结构不作限制。For example, the feature extraction subnetwork S3 is configured to extract the global connection between multiple characters of the task text and obtain multiple feature vectors. For example, the feature extraction sub-network S can include a convolutional neural network (CNN) and a long-short memory network (Long-Stort Term Memory, LSTM), or even a larger BERT (Bidirectional Encoder Representation from Transformer) network. It can also be other convolutional, fully connected or larger-scale neural networks. The embodiments of the present disclosure do not limit the network structure of the feature extraction sub-network S3.
由于共享神经网络需要提取N个功能神经网络可以共享的共享特征,因此需要设置共享神经网络的网络规模或参数规模相对于图1中分别独立设置的NLP提取部分要大一些,例如,可以增加特征提取子网络S3的参数规模,例如可以增加特征提取子网络S3中的权重参数增加20%的参数规模,当然,也可以根据需要选择增大的具体参数规模,本公开的实施例对此不作限制。Since the shared neural network needs to extract shared features that can be shared by N functional neural networks, the network scale or parameter scale of the shared neural network needs to be set larger than the NLP extraction part that is set independently in Figure 1. For example, features can be added The parameter scale of the extraction sub-network S3 can be increased, for example, by increasing the weight parameters in the feature extraction sub-network S3 by 20%. Of course, you can also choose to increase the specific parameter scale as needed. The embodiments of the present disclosure do not limit this. .
例如,如图3所示,N个功能神经网络(S4、S5、……、S(N+3))分别包括多个隐藏层和输出层,隐藏层可以为根据实际需要选择的适合的神经网络结构。例如N个功能神经网络的各个网络层的网络参数以及隐藏层的具体结构和层数可以根据需要设置,以各自执行不同的自然语言处理任务(例如包括但不限于问答型功能任务、闲聊型功能任务和任务型功能任务等)。For example, as shown in Figure 3, N functional neural networks (S4, S5,..., S(N+3)) respectively include multiple hidden layers and output layers. The hidden layers can be suitable neural networks selected according to actual needs. Network structure. For example, the network parameters of each network layer of N functional neural networks and the specific structure and number of hidden layers can be set as needed to perform different natural language processing tasks (for example, including but not limited to question and answer functional tasks, chatting functional tasks). tasks and task-type functional tasks, etc.).
需要说明的是,图3所示仅为用于本公开实施例提出的自然语言处理方法的共享神经网络和多个功能神经网络的一个示例,本公开对多个功能神经网络的具体神经网络层结构和功能神经网络的数量等均不作限制。It should be noted that FIG. 3 shows only an example of a shared neural network and multiple functional neural networks used in the natural language processing method proposed by the embodiment of the present disclosure. The specific neural network layers of the multiple functional neural networks are described in this disclosure. There are no restrictions on the number of structures or functional neural networks.
图4为图2中步骤S120的一个示例的示例性流程图。FIG. 4 is an exemplary flowchart of an example of step S120 in FIG. 2 .
例如,如图4所示,图2所示自然语言处理方法中的步骤S120包括以下步骤S121~S123。For example, as shown in Figure 4, step S120 in the natural language processing method shown in Figure 2 includes the following steps S121 to S123.
步骤S121:利用输入子网络将任务文本转换为字索引数组;Step S121: Use the input sub-network to convert the task text into a word index array;
步骤S122:利用字嵌入子网络将字索引数组编码为多个字向量;Step S122: Use the word embedding subnetwork to encode the word index array into multiple word vectors;
步骤S123:基于多个字向量,利用特征提取子网络提取多个字符之间的全局联系,得到共享特征。Step S123: Based on multiple word vectors, use the feature extraction sub-network to extract global connections between multiple characters to obtain shared features.
在步骤S121中,将任务文本输入到输入子网络S1后,输入子网络S1输出的字索引数组包括的多个索引值与任务文本中的多个字符一一对应。例如,每个字符对应一个索引值,则整个任务文本转换为一个由索引值组成的数组。例如,可以预先为任务文本使用的语言中需要用到的所有可能字符都编码一个对应的索引值,索引值可以是整型数值,代表各个字符的索引。In step S121, after the task text is input into the input sub-network S1, multiple index values included in the word index array output by the input sub-network S1 correspond one-to-one to multiple characters in the task text. For example, if each character corresponds to an index value, the entire task text is converted into an array composed of index values. For example, a corresponding index value can be encoded in advance for all possible characters that need to be used in the language used in the task text. The index value can be an integer value, representing the index of each character.
例如,为使得字嵌入子网络S2输入数据的维度固定,数组的长度可以是预设的固定值step(例如设置step=70),若任务文本的字符长度超过step,则任务文本中第step+1个字符及之后部分将被截断丢弃,若任务文本的字符长度小于step,不足部分用特定的无意义的字符补齐,例如这里特定的无意义的字符可以对应预先规定的一个索引值,该索引值与任何字符对应的索引值都不同,该索引值出现时表示其对应的字符是没有意义的字符。For example, in order to make the dimension of the input data of the word embedding sub-network S2 fixed, the length of the array can be a preset fixed value step (for example, set step = 70). If the character length of the task text exceeds step, the length of the task text is step + 1 character and the following part will be truncated and discarded. If the character length of the task text is less than step, the missing part will be filled with specific meaningless characters. For example, the specific meaningless characters here can correspond to a predetermined index value. The index value is different from the index value corresponding to any character. When the index value appears, it means that the corresponding character is a meaningless character.
例如,以任务文本为“放一首刘德华的忘情水”为例,任务文本经过输入子网络S1后,输出的字索引数组的长度为step,其中数组中的前10个元素为任务文本中的10个字符对应的索引值,其余step-10个索引值使用上述特定的无意义字符对应的索引值表示,由此将用户输入句子转换为一个由索引值组成的字索引数组。For example, take the task text "Play a song of Andy Lau's Forgetful Love" as an example. After the task text passes through the input sub-network S1, the length of the output word index array is step, and the first 10 elements in the array are steps in the task text. The index values corresponding to 10 characters, and the remaining step-10 index values are represented by the index values corresponding to the specific meaningless characters mentioned above, thereby converting the user input sentence into a word index array composed of index values.
在步骤S122中,字嵌入子网络S2对任务文本中每一个字符对应的索引值进行嵌入表示,将字索引数组编码为多个字向量。多个字向量与多个索引值一一对应,从而与多个字符一一对应;多个字向量中的每个字向量包括对应字符的字符特征(例如每个字符本身的含义)以及该字符与前后字符之间的联系(例如某个词的含义)。In step S122, the word embedding sub-network S2 embeds the index value corresponding to each character in the task text and encodes the word index array into multiple word vectors. Multiple word vectors correspond to multiple index values one-to-one, and thus correspond to multiple characters one-to-one; each word vector in the multiple word vectors includes the character characteristics of the corresponding character (such as the meaning of each character itself) and the character The connection between the preceding and following characters (such as the meaning of a word).
例如,输入子网络S1输出的字索引数组经过字嵌入子网络S2变成一个一个多维字向量。多维字向量即为多个字向量构成一个多维的浮点数矩阵,用于表示每个字的意思(即字符特征)。例如,如果多维字向量为32维(DIM)矩阵,则每个字就用32个元素的一维数组(即字向量)表示;当字索引数组长度step=70时,多维字向量为一个[70,32]的矩阵,矩阵中的每个元素是一个浮点数。For example, the word index array output by the input sub-network S1 is transformed into a multi-dimensional word vector through the word embedding sub-network S2. A multi-dimensional word vector is a multi-dimensional floating-point matrix composed of multiple word vectors, which is used to represent the meaning of each word (ie, character characteristics). For example, if the multi-dimensional word vector is a 32-dimensional (DIM) matrix, then each word is represented by a one-dimensional array (ie, word vector) of 32 elements; when the word index array length step=70, the multi-dimensional word vector is a [ 70,32] matrix, each element in the matrix is a floating point number.
例如,同样以任务文本为“放一首刘德华的忘情水”为例,任务文本经过输入子网络S1后输出长度为step的字索引数组,字索引数组经过字嵌入子网络S2变成一个多维字向量。例如,前10个字向量对应于任务文本中的10个字符,前10个字向量包含10个字符的字符特征(例如任务文本中每个字符本身的含义)以及10个字符中每个字符与前后字符之间的联系(例如任务文本中每个词的含义);其余step-10个字向量使用上述特定的无意义字符对应的浮点数(例如null)表示,由此将任务文本对应的字索引数组转换为一个由多个字向量组成的多维浮点数矩阵。For example, taking the task text "Play a song of Andy Lau's Love Affair" as an example, the task text passes through the input sub-network S1 and then outputs a word index array with a length of step. The word index array passes through the word embedding sub-network S2 and becomes a multi-dimensional word. vector. For example, the first 10 word vectors correspond to 10 characters in the task text. The first 10 word vectors contain the character characteristics of the 10 characters (such as the meaning of each character itself in the task text) and the relationship between each of the 10 characters. The connection between the preceding and following characters (such as the meaning of each word in the task text); the remaining step-10 word vectors are represented by floating point numbers (such as null) corresponding to the above-mentioned specific meaningless characters, thus the words corresponding to the task text are The index array is converted into a multidimensional floating-point matrix consisting of word vectors.
在步骤S123中,基于字嵌入子网络S2输出的多个字向量,特征提取子 网络S3从多个字向量中提取出任务文本的多个字符之间的全局联系,得到多个特征向量,多个特征向量中包含共享特征。因此,多个特征向量既包含每个字符的含义,又包含所有字符之间的联系(即全局联系),从而包含了整个任务文本的有效信息。In step S123, based on the multiple word vectors output by the word embedding sub-network S2, the feature extraction sub-network S3 extracts the global connection between multiple characters of the task text from the multiple word vectors, and obtains multiple feature vectors. feature vectors contain shared features. Therefore, multiple feature vectors contain both the meaning of each character and the connections between all characters (i.e., global connections), thus containing effective information of the entire task text.
例如,同样以任务文本为“放一首刘德华的忘情水”为例,任务文本经过输入子网络S1和字嵌入子网络S2后输出由多个字向量组成的多维浮点数矩阵,多维浮点数矩阵经过特征提取子网络S3变成多个特征向量。例如,多个特征向量既包含10个字符中每个字符的含义,又包含10个字符之间的联系(即全局联系),从而包含了整个任务文本的有效信息(例如,包括用户要求播放歌曲的意图信息,以及“一首”、“刘德华”、“忘情水”等关键词信息)。For example, taking the task text "Play a song of Andy Lau's Forgetful Water" as an example, the task text outputs a multi-dimensional floating-point matrix composed of multiple word vectors after passing through the input sub-network S1 and the word embedding sub-network S2. After the feature extraction sub-network S3, it becomes multiple feature vectors. For example, multiple feature vectors contain both the meaning of each of the 10 characters and the connection between the 10 characters (i.e., the global connection), thereby containing effective information of the entire task text (for example, including the user's request to play a song Intention information, as well as keyword information such as "Yiyi", "Andy Lau", "Wangqingshui").
图5为本公开至少一实施例提供的共享神经网络和多个功能神经网络的另一示例的示意图。例如,图5所示的用于自然语言处理的多个神经网络可以包括图3所示的共享神经网络和N个功能神经网络,在图5所示的示例中,N=3。FIG. 5 is a schematic diagram of another example of a shared neural network and multiple functional neural networks provided by at least one embodiment of the present disclosure. For example, the multiple neural networks for natural language processing shown in FIG. 5 may include the shared neural network shown in FIG. 3 and N functional neural networks. In the example shown in FIG. 5, N=3.
例如,如图5所示,N个功能神经网络包括第一功能神经网络S4、第二功能神经网络S5和第三功能神经网络S6,分别用于执行不同的自然语言处理任务。For example, as shown in Figure 5, N functional neural networks include a first functional neural network S4, a second functional neural network S5, and a third functional neural network S6, which are respectively used to perform different natural language processing tasks.
例如,在一些示例中,第一功能神经网络S4可以用于处理问答型功能任务,第二功能神经网络S5可以用于处理闲聊型功能任务,第三功能神经网络S6可以用于处理任务型功能任务;第一功能神经网络S4、第二功能神经网络S5和第三功能神经网络S6也可以分别用于执行其他类型的自然语言处理任务,本公开的实施例对此不作限制。For example, in some examples, the first functional neural network S4 can be used to process question-and-answer type functional tasks, the second functional neural network S5 can be used to process chatting type functional tasks, and the third functional neural network S6 can be used to process task-type functions. Task; the first functional neural network S4, the second functional neural network S5 and the third functional neural network S6 can also be used to perform other types of natural language processing tasks respectively, and the embodiments of the present disclosure do not limit this.
下面结合图5,具体描述三个功能神经网络的结构及得到处理结果的具体过程。The structure of the three functional neural networks and the specific process of obtaining the processing results will be described in detail below in conjunction with Figure 5.
例如,在一些示例中,自然语言处理任务包括问答型功能任务,问答型功能任务处理基于知识库的问答,例如,问答型功能任务用于解析任务文本中的问题,给出问题对应的答案。For example, in some examples, natural language processing tasks include question and answer functional tasks. The question and answer functional tasks deal with question and answer based on knowledge bases. For example, the question and answer functional tasks are used to parse questions in the task text and give answers corresponding to the questions.
例如,如图5所示,N个功能神经网络包括第一功能神经网络S4,第一功能神经网络S4用于执行问答型功能任务,并输出句向量,例如,句向量包括所述任务文本中所述问题的类别信息(例如,常识类、科学类等);之后,需要对句向量进行第一后处理,得到任务文本中问题对应的答案。For example, as shown in Figure 5, N functional neural networks include a first functional neural network S4. The first functional neural network S4 is used to perform a question-and-answer functional task and output a sentence vector. For example, the sentence vector includes the task text. The category information of the question (for example, general knowledge, science, etc.); after that, the sentence vector needs to be first post-processed to obtain the answer corresponding to the question in the task text.
例如,基于第一功能神经网络S4,在一些示例中,图2中的步骤S130可以进一步包括:利用第一功能神经网络S4对共享特征进行第一处理,得到句向量;将句向量与数据库中预存的多个知识信息向量进行比较,以将多个知识信息向量中的与句向量的向量距离最小的知识信息向量对应的答案作为对应于第一功能神经网络的处理结果。For example, based on the first functional neural network S4, in some examples, step S130 in Figure 2 may further include: performing a first process on the shared features using the first functional neural network S4 to obtain a sentence vector; comparing the sentence vector with the database The multiple pre-stored knowledge information vectors are compared, and the answer corresponding to the knowledge information vector with the smallest vector distance from the sentence vector among the multiple knowledge information vectors is used as the processing result corresponding to the first functional neural network.
例如,第一处理包括卷积处理、池化处理、特征融合处理和全连接处理。For example, the first processing includes convolution processing, pooling processing, feature fusion processing, and fully connected processing.
例如,第一功能神经网络可以是卷积神经网络。图6为本公开至少一实施例提供的第一功能神经网络的一个示例的示意图。For example, the first functional neural network may be a convolutional neural network. FIG. 6 is a schematic diagram of an example of a first functional neural network provided by at least one embodiment of the present disclosure.
例如,如图6所示,在一个示例中,第一功能神经网络S4可以包括卷积层、池化层、融合层、全连接层、输出层,分别用于上述第一处理中的卷积处理、池化处理、特征融合处理和全连接处理,最终得到句向量。关于卷积层、池化层、融合层、全连接层、输出层的具体结构可以根据需要进行设置,本公开对此不作具体限制。For example, as shown in Figure 6, in one example, the first functional neural network S4 may include a convolution layer, a pooling layer, a fusion layer, a fully connected layer, and an output layer, respectively used for the convolution in the above-mentioned first processing. Processing, pooling processing, feature fusion processing and full connection processing, and finally the sentence vector is obtained. The specific structures of the convolution layer, pooling layer, fusion layer, fully connected layer, and output layer can be set as needed, and this disclosure does not place specific restrictions on this.
需要说明的是,第一功能神经网络可以为如图6所示的卷积全连接的网络(例如,TextCNN等),或者也可以使用双塔模型作为第一功能神经网络S4,或者也可以为其他能够实现提取句向量任务的网络结构,本公开的实施例对第一功能神经网络的结构不作限制。It should be noted that the first functional neural network can be a convolutional fully connected network as shown in Figure 6 (for example, TextCNN, etc.), or the twin-tower model can also be used as the first functional neural network S4, or it can also be Other network structures can realize the task of extracting sentence vectors. The embodiments of the present disclosure do not limit the structure of the first functional neural network.
例如,预先可以设置大量包含各类百科知识信息的问题及其答案,并提取预设问题的句向量作为知识信息向量存储在数据库中。在对句向量的第一后处理过程中,将句向量与数据库中预存的多个知识信息向量进行向量比较,例如计算各个知识信息向量和句向量之间的距离,以找到与句向量的向量距离最小的知识信息向量,该知识信息向量对应的答案即可以作为第一功能神经网络S4的处理结果,即任务文本中问题对应的答案,也即是用户提出问题的答案。For example, a large number of questions and their answers containing various types of encyclopedia knowledge information can be set in advance, and the sentence vectors of the preset questions can be extracted and stored in the database as knowledge information vectors. In the first post-processing process of the sentence vector, the sentence vector is compared with multiple knowledge information vectors pre-stored in the database, for example, the distance between each knowledge information vector and the sentence vector is calculated to find the vector with the sentence vector. The knowledge information vector with the smallest distance, and the answer corresponding to the knowledge information vector can be used as the processing result of the first functional neural network S4, that is, the answer corresponding to the question in the task text, that is, the answer to the question raised by the user.
需要说明的是,关于第一后处理的具体过程也可以采用其他可行的方式根据句向量得到答案,本公开对此不作具体限制。It should be noted that, regarding the specific process of the first post-processing, other feasible methods can also be used to obtain the answer based on the sentence vector, and this disclosure does not impose specific limitations on this.
例如,在执行问答型功能任务时,第一功能神经网络输出的是任务文本对应的句向量,还需对句向量进行后处理以得到最终的处理结果作为第一功能神经网络S4的处理结果。For example, when performing a question-and-answer functional task, the first functional neural network outputs a sentence vector corresponding to the task text, and the sentence vector needs to be post-processed to obtain the final processing result as the processing result of the first functional neural network S4.
例如,在另一些示例中,自然语言处理任务包括闲聊型功能任务,闲聊型功能任务可以处理无目的的对话。例如,闲聊型功能任务用于解析任务文本中 的无目的性对话信息,给出无目的性对话信息对应的系统回答。For example, in other examples, natural language processing tasks include small talk functional tasks, which can handle purposeless conversations. For example, the chat function task is used to parse the purposeless dialogue information in the task text and provide system answers corresponding to the purposeless dialogue information.
例如,如图5所示,N个功能神经网络包括第二功能神经网络S5,第二功能神经网络S5用于执行闲聊型功能任务,并可以直接得到输出句子作为任务文本对应的系统回答,无需进一步的后处理操作。For example, as shown in Figure 5, the N functional neural networks include the second functional neural network S5. The second functional neural network S5 is used to perform chatting functional tasks and can directly obtain the output sentence as the system answer corresponding to the task text, without Further post-processing operations.
例如,基于第二功能神经网络S5,在一些示例中,图2中的步骤S130可以进一步包括:利用第二功能神经网络S5对共享特征进行第二处理,得到输出句子以作为对应于第二功能神经网络的处理结果,并将对应于第二功能神经网络的处理结果作为任务文本对应的系统回答。For example, based on the second functional neural network S5, in some examples, step S130 in Figure 2 may further include: using the second functional neural network S5 to perform a second process on the shared features to obtain an output sentence as a corresponding sentence corresponding to the second function. The processing result of the neural network, and the processing result corresponding to the second function neural network is used as the system answer corresponding to the task text.
例如,第二处理包括编码处理和解码处理。例如第二功能神经网络典型的是基于循环神经网络的架构,包括编码子网络和解码子网络。图7为本公开至少一实施例提供的第二功能神经网络的一个示例的示意图。For example, the second processing includes encoding processing and decoding processing. For example, the second functional neural network is typically based on a recurrent neural network architecture, including an encoding subnetwork and a decoding subnetwork. FIG. 7 is a schematic diagram of an example of a second functional neural network provided by at least one embodiment of the present disclosure.
例如,如图7所示,在一个示例中,编码子网络包含循环网络,解码子网络包括循环网络、全连接层和解码层。在一些示例中,解码子网络中的解码层一般使用维特比解码,也可以采用其他解码方式;编码子网络和解码子网络也可以为能够实现编码或解码功能的其他结构,本公开的实施例对此不作限制。For example, as shown in Figure 7, in one example, the encoding subnetwork includes a recurrent network, and the decoding subnetwork includes a recurrent network, a fully connected layer, and a decoding layer. In some examples, the decoding layer in the decoding sub-network generally uses Viterbi decoding, and other decoding methods can also be used; the encoding sub-network and the decoding sub-network can also be other structures that can implement encoding or decoding functions. Embodiments of the present disclosure There are no restrictions on this.
例如,利用第二功能神经网络S5对共享特征进行第二处理的过程可以进一步包括:利用编码子网络对共享特征进行编码处理得到中间索引数组;利用解码子网络对中间索引数组进行解码处理得到输出句子,以作为对应于第二功能神经网络的处理结果。For example, the process of using the second functional neural network S5 to perform the second processing on the shared features may further include: using the encoding subnetwork to encode the shared features to obtain an intermediate index array; using the decoding subnetwork to decode the intermediate index array to obtain the output. Sentences as processing results corresponding to the second functional neural network.
例如,中间索引数组为共享特征经过编码子网络的编码处理得到的编码结果,中间索引数组再经过解码子网络的解码处理得到输出句子。将输出句子直接作为第二功能神经网络S5的处理结果,即任务文本对应的系统回答,也即是对于用户发出的无目的闲聊对话的回应。For example, the intermediate index array is the encoding result obtained by encoding the shared features through the encoding subnetwork, and the intermediate index array is then decoded by the decoding subnetwork to obtain the output sentence. The output sentence is directly used as the processing result of the second functional neural network S5, that is, the system answer corresponding to the task text, that is, the response to the purposeless chat conversation sent by the user.
需要说明的是,第二功能神经网络可以为如图7所示的循环神经网络的架构(例如,循环网络为RNN(Recurrent Neural Network)、LSTM或GRU(Gate Recurrent Unit)等),也可以为能够实现共享特征到输出句子转换的其他网络结构,本公开的实施例对此不作限制。It should be noted that the second functional neural network can be the architecture of a recurrent neural network as shown in Figure 7 (for example, the recurrent network is RNN (Recurrent Neural Network), LSTM or GRU (Gate Recurrent Unit), etc.), or it can be Other network structures that convert shared features into output sentences can be implemented, and embodiments of the present disclosure do not limit this.
例如,在又一些示例中,自然语言处理任务包括任务型功能任务,任务型功能任务可以处理带有词槽的对话或者多轮对话。任务型功能任务用于解析任务文本中的任务目的信息和任务关键词信息,根据任务目的信息和任务关键词信息得到系统追问或问答结果。例如,任务型功能任务包括处理一些复杂 的对话流程,例如,带词槽的句子,考虑上下文的多轮对话等。For example, in some examples, the natural language processing task includes a task-type functional task, and the task-type functional task can process a dialogue with word slots or a multi-turn dialogue. Task-type functional tasks are used to parse the task purpose information and task keyword information in the task text, and obtain system questioning or question and answer results based on the task purpose information and task keyword information. For example, task-based functional tasks include processing some complex dialogue processes, such as sentences with word slots, multi-turn dialogues that consider context, etc.
例如,为了执行任务型功能任务,需要完成意图识别、命名实体识别、对话管理等。例如,如图5所示,N个功能神经网络可以包括第三功能神经网络S6,第三功能神经网络S6用于执行任务型功能任务,并输出意图特征和命名实体,意图特征和命名实体分别对应于任务文本中的任务目的信息和任务关键词信息;通过第二后处理操作对意图特征和命名实体进行后处理,得到对应于任务文本的系统追问或问答结果。For example, in order to perform task-based functional tasks, intent recognition, named entity recognition, dialogue management, etc. need to be completed. For example, as shown in Figure 5, the N functional neural networks may include a third functional neural network S6. The third functional neural network S6 is used to perform task-type functional tasks and output intent features and named entities. The intent features and named entities are respectively Corresponding to the task purpose information and task keyword information in the task text; through the second post-processing operation, the intent features and named entities are post-processed to obtain system questioning or question and answer results corresponding to the task text.
例如,基于第三功能神经网络S6,在一些示例中,图2中的步骤S130可以进一步包括:利用第三功能神经网络S6对共享特征进行第三处理,得到对应于任务文本的意图特征和至少一个命名实体;对意图特征和至少一个命名实体进行对话管理,得到系统追问或问答结果以作为对应于第三功能神经网络的处理结果。For example, based on the third functional neural network S6, in some examples, step S130 in Figure 2 may further include: using the third functional neural network S6 to perform a third process on the shared features to obtain the intent features corresponding to the task text and at least A named entity; performs dialogue management on the intent feature and at least one named entity, and obtains system questioning or question and answer results as processing results corresponding to the third function neural network.
例如,第三功能神经网络S6包括意图识别子网络S61和命名实体识别子网络S62。利用第三功能神经网络S6对共享特征进行第三处理,得到对应于任务文本的意图特征和至少一个命名实体,可以包括:利用意图识别子网络S61,基于共享特征进行意图识别,得到对应于任务文本的意图特征;利用命名实体识别子网络S62,基于共享特征执行命名实体识别,得到对应于任务文本的至少一个命名实体。For example, the third functional neural network S6 includes an intention recognition sub-network S61 and a named entity recognition sub-network S62. Using the third functional neural network S6 to perform third processing on the shared features to obtain the intent features and at least one named entity corresponding to the task text, which may include: using the intent recognition sub-network S61 to perform intent recognition based on the shared features to obtain the intent features corresponding to the task text Intentional features of the text; using the named entity recognition sub-network S62, perform named entity recognition based on the shared features to obtain at least one named entity corresponding to the task text.
例如,意图特征包含任务文本中的任务目的信息,也即是,意图特征代表了用户所想要表达的隐含信息。例如,在一些具体的示例中,“给我放一首刘德华的忘情水”的意图是播放某个歌手的一首歌,“明天上海的天气怎么样”的意图是天气查询。For example, the intent feature contains the task purpose information in the task text, that is, the intent feature represents the implicit information that the user wants to express. For example, in some specific examples, the intention of "Play me a song by Andy Lau" is to play a song by a certain singer, and the intention of "What will the weather be like in Shanghai tomorrow" is a weather query.
例如,至少一个命名实体包含任务关键词信息(也称为命名实体信息或词槽信息),也即是,命名实体识别(Named Entity Recognition,NER)就是识别用户一句话中的命名实体信息(包括关键词的位置、类型)。For example, at least one named entity contains task keyword information (also called named entity information or word slot information), that is, named entity recognition (Named Entity Recognition, NER) is to recognize the named entity information (including Keyword location, type).
例如,在一个示例中,用户要订火车票,共享神经网络和多个功能神经网络需要完成与用户的交互对话并最终完成订票任务,举例:For example, in one example, the user wants to book a train ticket. The shared neural network and multiple functional neural networks need to complete the interactive dialogue with the user and finally complete the ticket booking task. For example:
用户:帮我订一张火车票。User: Book a train ticket for me.
系统:好的,请问要去哪里?System: OK, where are you going?
用户:上海。User: Shanghai.
系统:可以,那什么时候出发呢?System: Okay, then when will we set off?
用户:明天上午10点吧。User: Let’s do it at 10 a.m. tomorrow.
系统:好的,查到G0001次列车,明天上10点1刻从北京南站到上海虹桥站,请问要预定吗?System: OK, train G0001 was found. It will depart from Beijing South Railway Station to Shanghai Hongqiao Station at 10:15 tomorrow. Do you want to make a reservation?
用户:是的。User: Yes.
系统:好的,已经定好车票了。System: OK, the ticket has been booked.
例如,为了实现上述任务型功能任务,需要解析用户发出的语音片段对应的任务文本中的任务目的信息和任务关键词信息。对于解析任务文本中的任务目的信息,例如需要理解用户每一个句子中包含的意图,比如第一句的意图是“订火车票”;对于解析任务文本中的任务关键词信息,例如需要提取出每一句中的关键词(命名实体,也叫词槽),比如“上海”、“10点”等;另外,基于获得的任务目的信息和任务关键词信息,还需要向用户追问完成订票所需的其他信息,比如在以上示例中系统追问了地点和时间。For example, in order to realize the above-mentioned task-type functional tasks, it is necessary to analyze the task purpose information and task keyword information in the task text corresponding to the voice fragments uttered by the user. For parsing the task purpose information in the task text, for example, it is necessary to understand the intention contained in each sentence of the user, for example, the intention of the first sentence is "book a train ticket"; for parsing the task keyword information in the task text, for example, it is necessary to extract Keywords (named entities, also called word slots) in each sentence, such as "Shanghai", "10 o'clock", etc.; In addition, based on the obtained task purpose information and task keyword information, the user needs to be asked how to complete the ticket booking Other information required, such as the location and time in the example above.
例如,包括上述任务目的信息和任务关键词信息的任务文本经共享神经网络被转换为共享特征;通过意图识别字网络S61对共享特征进行意图识别,输出意图特征(例如,意图特征包含用户要求订火车票的意图信息),利用命名实体子网络S62基于共享特征执行命名实体识别,得到一个或多个命名实体(例如,命名实体包含“上海”、“10点”等关键词信息);再对意图特征和命名实体进行第二后处理,得到对应于任务文本的系统追问(例如,追问地点和时间等)或问答结果(例如,完成订票的回答)。For example, the task text including the above-mentioned task purpose information and task keyword information is converted into shared features through the shared neural network; the shared features are intention-identified through the intention recognition word network S61, and the intention features are output (for example, the intention features include the user's requirements for ordering train ticket intention information), use the named entity sub-network S62 to perform named entity recognition based on shared features, and obtain one or more named entities (for example, the named entities include keyword information such as "Shanghai" and "10 o'clock"); and then Intent features and named entities undergo second post-processing to obtain system questions (for example, asking about location and time, etc.) or question and answer results (for example, answers to complete ticket bookings) corresponding to the task text.
例如,如图5所示,可以在第二后处理过程中对意图特征和至少一个命名实体进行对话管理(Dialog Management,DM)。例如,对话管理就是维护和更新任务型功能任务所需的状态信息和上下文,比如下一句需要追问什么信息,什么时候结束回话,什么时候追问等。例如,在人机交互过程中,通过系统追问产生对话,从而不断完善沟通,获得有价值的信息,以得到问答结果。For example, as shown in Figure 5, dialog management (DM) can be performed on the intent feature and at least one named entity in the second post-processing process. For example, dialogue management is to maintain and update the status information and context required for task-type functional tasks, such as what information needs to be asked in the next sentence, when to end the reply, when to ask questions, etc. For example, in the process of human-computer interaction, dialogue is generated through system questioning, thereby continuously improving communication, obtaining valuable information, and obtaining question and answer results.
图8为本公开至少一实施例提供的第三功能神经网络的一个示例的示意图。FIG. 8 is a schematic diagram of an example of a third functional neural network provided by at least one embodiment of the present disclosure.
例如,如图8所示,在一个示例中,意图识别子网络可以包括卷积层、池化层、融合层、全连接层、激活函数层(例如SOFTMAX层),分别用于对共享特征进行卷积处理、池化处理、特征融合处理、全连接处理和分类处理等,以得到对应于任务文本的意图特征。命名实体识别子网络可以包括双向长短记忆网络(Bidirectional Long-Short Term Memorry,Bi-LSTM)层、全连接层 和解码层,分别用于对共享特征进行上下文的信息处理、全连接处理和解码处理等。For example, as shown in Figure 8, in one example, the intent recognition sub-network can include a convolution layer, a pooling layer, a fusion layer, a fully connected layer, and an activation function layer (such as a SOFTMAX layer), which are respectively used to perform shared feature analysis. Convolution processing, pooling processing, feature fusion processing, fully connected processing and classification processing, etc., to obtain the intended features corresponding to the task text. The named entity recognition sub-network can include a Bidirectional Long-Short Term Memory (Bi-LSTM) layer, a fully connected layer and a decoding layer, which are respectively used for contextual information processing, full connection processing and decoding processing of shared features. wait.
需要说明的是,第三功能神经网络也可以为能够实现共享特征到意图特征和命名实体转换的其他网络结构,意图识别子网络和命名实体识别子网络也可以为能够实现意图识别或命名实体识别功能的其他结构,本公开的实施例对意图识别子网络和命名实体识别子网络的具体结构不作限制。It should be noted that the third function neural network can also be other network structures that can realize the conversion of shared features to intention features and named entities. The intention recognition sub-network and the named entity recognition sub-network can also be capable of realizing intention recognition or named entity recognition. Regarding other structures of functions, embodiments of the present disclosure do not limit the specific structures of the intent recognition sub-network and the named entity recognition sub-network.
例如,本公开至少一实施例提供的自然语言处理方法还包括:通过仲裁选择从多个处理结果中选择一个处理结果作为自然语言处理的输出结果。例如,一个任务文本经过共享神经网络和多个功能神经网络的处理会产生多个处理结果;可以根据任务文本对应的自然语言处理任务的不同,通过仲裁从多个处理结果中选择出一个最终输出结果。例如,如图5所示,第一神经网络对应的处理结果为任务文本中问题对应的答案,第二神经网络对应的处理结果为无目的性对话信息对应的系统回答,第三神经网络对应的处理结果为系统追问或问答结果。For example, the natural language processing method provided by at least one embodiment of the present disclosure further includes: selecting one processing result from multiple processing results as the output result of natural language processing through arbitration selection. For example, a task text will produce multiple processing results after being processed by a shared neural network and multiple functional neural networks; a final output can be selected from multiple processing results through arbitration according to the different natural language processing tasks corresponding to the task text. result. For example, as shown in Figure 5, the processing result corresponding to the first neural network is the answer to the question in the task text, the processing result corresponding to the second neural network is the system answer corresponding to the purposeless dialogue information, and the processing result corresponding to the third neural network is The processing result is the result of system questioning or question and answer.
例如,如果任务本文为用户提出的问题,也即是,自然语言处理任务为问答型功能任务,则选择用于执行问答型功能任务的功能神经网络输出的问题对应的答案作为最终输出结果;如果任务本文中主要包含无目的性对话信息,也即是,自然语言处理任务为闲聊型功能任务,则选择用于执行闲聊型功能任务的功能神经网络输出的系统回答作为最终输出结果;如果任务本文中主要包含任务目的信息和任务关键词信息,也即是,自然语言处理任务为任务型功能任务,则选择用于执行任务型功能任务的功能神经网络输出的系统追问或问答结果作为最终输出结果。For example, if the task text is a question posed by the user, that is, the natural language processing task is a question and answer functional task, then the answer corresponding to the question output by the functional neural network used to perform the question and answer functional task is selected as the final output result; if The task text mainly contains purposeless dialogue information, that is, the natural language processing task is a chat-type functional task, then the system answer output by the functional neural network used to perform the chat-type functional task is selected as the final output result; if the task text It mainly contains task purpose information and task keyword information. That is, if the natural language processing task is a task-type functional task, then the system questioning or question and answer result output by the functional neural network used to perform the task-type functional task is selected as the final output result. .
例如,在一些示例中,仲裁选择可以包括以下方式:如果检测到上下文信息,也即是多轮会话场景,则选择系统追问或问答结果作为最终输出结果;如果没有检测到多轮会话场景,则基于提前设置的静态优先级(例如问答型任务和任务型任务的优先级),选择优先级高任务对应的功能神经网络的输出作为最终输出结果;除了提前设置的静态优先级,还需要考虑批判度(例如词槽数)、模型推理出来的置信度等。需要说明的是,仲裁选择还可以根据实际需要选择其他实施方式,本公开的实施例对此不作限制。For example, in some examples, the arbitration selection may include the following methods: if contextual information, that is, a multi-round conversation scenario, is detected, then the system questioning or question and answer result is selected as the final output result; if no multi-round conversation scenario is detected, then Based on the static priorities set in advance (such as the priorities of question-and-answer tasks and task-based tasks), the output of the functional neural network corresponding to the high-priority task is selected as the final output result; in addition to the static priorities set in advance, criticism also needs to be considered degree (such as the number of word slots), the confidence level inferred by the model, etc. It should be noted that other implementation methods can be selected for arbitration selection according to actual needs, and the embodiments of the present disclosure do not limit this.
本公开至少一实施例提供的自然语言处理方法,采用具有共享神经网络的用于自然语言处理的多个神经网络来执行多个不同的自然语言处理任务, 减少了神经网络参数规模,进而节省了计算资源,节约了计算成本。The natural language processing method provided by at least one embodiment of the present disclosure uses multiple neural networks for natural language processing with shared neural networks to perform multiple different natural language processing tasks, reducing the scale of neural network parameters, thereby saving money. Computing resources save computing costs.
例如,本公开至少一实施例提供的共享神经网络和多个功能神经网络都是提前通过训练获得的。图9为本公开至少一实施例提供的自然语言处理方法的训练部分的示意图。For example, the shared neural network and multiple functional neural networks provided by at least one embodiment of the present disclosure are obtained through training in advance. Figure 9 is a schematic diagram of the training part of the natural language processing method provided by at least one embodiment of the present disclosure.
例如,如图9所示,在如图2中的步骤S110之前,自然语言处理方法还包括以下步骤S140~S150。For example, as shown in Figure 9, before step S110 in Figure 2, the natural language processing method further includes the following steps S140 to S150.
步骤S140:获取训练文本;Step S140: Obtain training text;
步骤S150:基于训练文本,对待训练的多个功能神经网络进行训练,以得到训练好的多个功能神经网络。Step S150: Based on the training text, train multiple functional neural networks to be trained to obtain multiple trained functional neural networks.
例如,多个功能神经网络的数量为N,这里N为大于1的整数。例如,在训练待训练的N个功能神经网络过程中,N个功能神经网络同时训练,且计算N个功能神经网络对应的M个中间损失值的加权和作为损失值以更新N个功能神经网络的参数。例如,M个中间损失值分别对应M个权重,M个权重根据N个功能神经网络的输出准确度进行动态调整,这里M为大于等于N的整数。For example, the number of multiple functional neural networks is N, where N is an integer greater than 1. For example, in the process of training N functional neural networks to be trained, N functional neural networks are trained simultaneously, and the weighted sum of M intermediate loss values corresponding to the N functional neural networks is calculated as the loss value to update the N functional neural networks. parameters. For example, M intermediate loss values correspond to M weights respectively, and the M weights are dynamically adjusted according to the output accuracy of N functional neural networks, where M is an integer greater than or equal to N.
例如,参考图5所示,在自然语言处理任务包括三个任务时,N=3,也即N个功能神经网络包括第一功能神经网络、第二功能神经网络和第三功能神经网络,并且其中第三功能神经网络包括意图识别子网络和命名实体识别子网络,从而M=4。For example, referring to Figure 5, when the natural language processing task includes three tasks, N=3, that is, the N functional neural networks include the first functional neural network, the second functional neural network and the third functional neural network, and The third functional neural network includes an intent recognition sub-network and a named entity recognition sub-network, so M=4.
例如,在训练待训练的第一功能神经网络、第二功能神经网络和第三功能神经网络的过程中,3个功能神经网络同时训练。第一功能神经网络、第二功能神经网络、意图识别子网络和命名实体识别子网络分别对应4个中间损失值(即M=4),计算4个中间损失值的加权和作为损失值以更新3个功能神经网络的参数。例如,4个中间损失值分别对应4个权重,4个权重可以根据4个功能神经网络的输出准确度进行动态调整。For example, in the process of training the first functional neural network, the second functional neural network and the third functional neural network to be trained, the three functional neural networks are trained simultaneously. The first functional neural network, the second functional neural network, the intent recognition sub-network and the named entity recognition sub-network respectively correspond to 4 intermediate loss values (i.e. M=4), and the weighted sum of the 4 intermediate loss values is calculated as the loss value to update Parameters of 3 functional neural networks. For example, 4 intermediate loss values correspond to 4 weights respectively, and the 4 weights can be dynamically adjusted according to the output accuracy of the 4 functional neural networks.
图10为图9中步骤S150的一个示例的示意图。FIG. 10 is a schematic diagram of an example of step S150 in FIG. 9 .
例如,如图10所示,图9中的步骤S150可以包括以下步骤S151~S155。For example, as shown in Figure 10, step S150 in Figure 9 may include the following steps S151 to S155.
步骤S151:利用待训练的共享神经网络对训练文本进行特征提取,得到训练文本的训练共享特征。Step S151: Use the shared neural network to be trained to perform feature extraction on the training text to obtain training shared features of the training text.
例如,关于待训练的共享神经网络的结构可以参考图3相关内容,这里不再赘述。For example, regarding the structure of the shared neural network to be trained, please refer to the relevant content in Figure 3, which will not be described again here.
例如,训练文本为神经网络训练过程中使用的任务文本,训练文本经过待训练的共享神经网络S1~S3的特征提取转化为多个训练特征向量,训练共享特征被包含在多个训练特征向量中,训练共享特征包含训练文本中的多个字符的字符特征以及多个字符之间的全局联系。For example, the training text is the task text used in the neural network training process. The training text is converted into multiple training feature vectors through feature extraction of the shared neural networks S1 to S3 to be trained. The training shared features are included in multiple training feature vectors. , the training shared features include the character features of multiple characters in the training text and the global connections between multiple characters.
例如,可以预先构造大量的任务文本和任务文本对应的标准处理结果对神经网络进行训练,从中选择任意一个任务文本作为训练文本。For example, a large number of task texts and standard processing results corresponding to the task texts can be constructed in advance to train the neural network, and any task text can be selected as the training text.
步骤S152:利用N个功能神经网络对训练共享特征分别进行处理,得到N个功能神经网络分别输出的M组第一中间结果。Step S152: Use N functional neural networks to process the training shared features respectively, and obtain M sets of first intermediate results respectively output by the N functional neural networks.
例如,在N个功能神经网络包括第一功能神经网络、第二功能神经网络、第三功能神经网络时,M组第一中间结果包括第一功能神经网络S4输出的第一中间结果、第二功能神经网络S5输出的第一中间结果、意图识别子网络输出的第一中间结果和命名实体识别子网络输出的第一中间结果。For example, when the N functional neural networks include the first functional neural network, the second functional neural network, and the third functional neural network, the M group of first intermediate results include the first intermediate results output by the first functional neural network S4, the second The first intermediate result output by the functional neural network S5, the first intermediate result output by the intention recognition sub-network and the first intermediate result output by the named entity recognition sub-network.
例如,对于用于执行问答型功能任务的第一功能神经网络S4,输出的第一中间结果为训练句向量,训练句向量包括训练文本中问题的类别信息;对于用于执行闲聊型功能任务的第二功能神经网络S5,输出的第一中间结果为训练输出句子,训练输出句子包括训练文本对应的系统回答;对于用于执行任务型功能任务的第三功能神经网络S6,意图识别子网络输出的第一中间结果为训练意图特征,命名实体识别子网络输出的第一中间结果为一个或多个训练命名实体。For example, for the first functional neural network S4 used to perform question-and-answer functional tasks, the first intermediate result output is a training sentence vector, and the training sentence vector includes category information of questions in the training text; for the first functional neural network S4 used to perform small talk functional tasks The first intermediate result output by the second functional neural network S5 is the training output sentence, and the training output sentence includes the system answer corresponding to the training text; for the third functional neural network S6 used to perform task-type functional tasks, the intent recognition sub-network output The first intermediate result is the training intention feature, and the first intermediate result output by the named entity recognition sub-network is one or more training named entities.
步骤S153:基于训练文本和M组第一中间结果计算N个功能神经网络对应的M个中间损失值。Step S153: Calculate M intermediate loss values corresponding to N functional neural networks based on the training text and M sets of first intermediate results.
例如,基于训练文本和N个功能神经网络分别输出的M组第一中间结果,例如训练句向量、训练输出句子、训练意图特征和训练命名实体等,根据各个功能神经网络对应的损失函数计算各个功能神经网络分别对应的中间损失值。For example, based on the training text and M sets of first intermediate results output by N functional neural networks respectively, such as training sentence vectors, training output sentences, training intention features, training named entities, etc., each function is calculated according to the loss function corresponding to each functional neural network. The functional neural network corresponds to the intermediate loss value respectively.
例如,M可以等于N也可以不等于N,例如,在第三功能神经网络包括两个子网络时,M=N+1。For example, M may be equal to N or not equal to N. For example, when the third functional neural network includes two sub-networks, M=N+1.
步骤S154:计算M个中间损失值的加权和作为损失值。Step S154: Calculate the weighted sum of M intermediate loss values as the loss value.
例如,N个功能神经网络对应的M个中间损失值分别为Loss1、Loss2……LossM,经步骤S151~S154训练后的共享神经网络和N个功能神经网络的损失函数可以用如下公式(1)表示:For example, the M intermediate loss values corresponding to N functional neural networks are Loss1, Loss2...LosM respectively. The loss function of the shared neural network and N functional neural networks after training in steps S151 to S154 can be used as the following formula (1) express:
Loss=k 1*Loss1+k 2*Loss2+……+k M*LossM    (1) Loss=k 1 *Loss1+k 2 *Loss2+……+k M *LossM (1)
其中,k 1为中间损失值Loss1的权重,k 2为中间损失值Loss2的权重,……,k M为中间损失值LossM的权重。例如,k 1、k 2……k M的初始值都设置为1。 Among them, k 1 is the weight of the intermediate loss value Loss1, k 2 is the weight of the intermediate loss value Loss2,..., k M is the weight of the intermediate loss value LossM. For example, the initial values of k 1 , k 2 ...k M are all set to 1.
步骤S155:在损失值未满足预定收敛条件时,基于损失值更新待训练的共享神经网络和N个功能神经网络的参数。Step S155: When the loss value does not meet the predetermined convergence condition, update the parameters of the shared neural network to be trained and the N functional neural networks based on the loss value.
例如,若损失值满足预定收敛条件,则得到训练好的功能神经网络。For example, if the loss value satisfies the predetermined convergence condition, a trained functional neural network will be obtained.
例如,在训练过程中,步骤S154中计算损失值时的各个中间损失值的权重可以动态调整。For example, during the training process, the weight of each intermediate loss value when calculating the loss value in step S154 can be dynamically adjusted.
例如,训练过程中同时训练N个功能神经网络,但由于训练数据的偏差不均衡以及N个功能神经网络的差异,N个功能神经网络不可能同时收敛,甚至部分网络很难收敛。For example, N functional neural networks are trained at the same time during the training process. However, due to the uneven bias of the training data and the differences among the N functional neural networks, it is impossible for the N functional neural networks to converge at the same time, and it is even difficult for some networks to converge.
例如,为了加速训练过程,可以在训练过程中测量共享神经网络和N个功能神经网络的输出准确度(例如,每训练总轮数的1/10时,测量一次输出准确度),根据N个功能神经网络的输出准确度动态调整损失函数的M个权重。For example, in order to speed up the training process, the output accuracy of the shared neural network and N functional neural networks can be measured during the training process (for example, the output accuracy is measured once every 1/10 of the total number of training rounds), based on N The output accuracy of the functional neural network dynamically adjusts the M weights of the loss function.
例如,图11为图9中步骤S150的另一示例的示意图。例如,图11所示的方法即为通过测量N个功能神经网络的输出准确度来动态调整损失函数的M个权重的一个示例。For example, FIG. 11 is a schematic diagram of another example of step S150 in FIG. 9 . For example, the method shown in Figure 11 is an example of dynamically adjusting the M weights of the loss function by measuring the output accuracy of N functional neural networks.
例如,如图11所示,图9中的步骤S150还可以包括以下步骤S156~S1510。For example, as shown in Figure 11, step S150 in Figure 9 may also include the following steps S156 to S1510.
步骤S156:获取测试文本;Step S156: Obtain the test text;
步骤S157:利用训练后的共享神经网络和训练后的N个功能神经网络对测试文本进行处理,得到M组第二中间结果;Step S157: Use the trained shared neural network and the trained N functional neural networks to process the test text to obtain M sets of second intermediate results;
步骤S158:基于M组第二中间结果和测试文本,确定分别对应于训练后的N个功能神经网络的M个输出准确度;Step S158: Based on M sets of second intermediate results and test text, determine M output accuracies respectively corresponding to the trained N functional neural networks;
步骤S159:基于M个输出准确度调整M个中间损失值分别对应的M个权重;Step S159: Adjust the M weights corresponding to the M intermediate loss values based on the M output accuracies;
步骤S1510:根据调整后的M个权重继续对待训练的多个功能神经网络进行训练。Step S1510: Continue to train the multiple functional neural networks to be trained according to the adjusted M weights.
例如,步骤S159进一步包括:确定M个输出准确度中的最大输出准确度对应的权重作为第一权重;保持第一权重不变,增大M个权重中除第一权重以外的其他M-1个权重。For example, step S159 further includes: determining the weight corresponding to the maximum output accuracy among the M output accuracies as the first weight; keeping the first weight unchanged, and increasing the other M-1 weights except the first weight among the M weights. a weight.
例如,同样以图3或图5所示的共享神经网络和多个功能神经网络为例,在步骤S156中,测试文本为神经网络测试过程中使用的任务文本。For example, taking the shared neural network and multiple functional neural networks shown in Figure 3 or Figure 5 as an example, in step S156, the test text is the task text used in the neural network testing process.
例如,在步骤S157中,测试文本经过训练后的(例如每训练总轮数的1/10后的)共享神经网络S1~S3的特征提取转化为多个测试特征向量,测试共享特征被包含在多个测试特征向量中,测试共享特征包含测试文本中的多个字符的字符特征以及多个字符之间的全局联系。For example, in step S157, the feature extraction of the shared neural networks S1 to S3 after training (for example, after 1/10 of the total number of training rounds) of the test text is converted into multiple test feature vectors, and the test shared features are included in Among multiple test feature vectors, the test shared features include character features of multiple characters in the test text and global connections between multiple characters.
例如,在步骤S158中,基于测试文本和N个功能神经网络分别输出的M组第二中间结果,确定分别对应于训练后的N个功能神经网络的M个输出准确度P1、P2、……、PM。For example, in step S158, based on the test text and M sets of second intermediate results respectively output by the N functional neural networks, M output accuracies P1, P2, ... respectively corresponding to the trained N functional neural networks are determined. ,PM.
例如,在步骤S159中,基于M个输出准确度P1、P2、……、PM调整M个中间损失值分别对应的M个权重k 1、k 2……k M;在步骤S1510中,再根据调整后的M个权重继续对待训练的多个功能神经网络进行训练。 For example, in step S159, the M weights k 1 , k 2 ...k M respectively corresponding to the M intermediate loss values are adjusted based on the M output accuracies P1, P2 , ..., PM; in step S1510, based on The adjusted M weights continue to be trained on multiple functional neural networks to be trained.
图12为本公开至少一实施例提供的共享神经网络和多个功能神经网络的损失函数的一个示例的示意图。例如,图12中共享神经网络和多个功能神经网络例如为图3或图5中的共享神经网络和多个功能神经网络。Figure 12 is a schematic diagram of an example of a loss function of a shared neural network and multiple functional neural networks provided by at least one embodiment of the present disclosure. For example, the shared neural network and multiple functional neural networks in Figure 12 are, for example, the shared neural network and multiple functional neural networks in Figure 3 or Figure 5 .
例如,如图12所示,4个中间损失值包括第一功能神经网络S4对应的中间损失值Loss1、第二功能神经网络S5对应的中间损失值Loss2、意图识别子网络S6-1对应的中间损失值Loss3和命名实体识别子网络S6-2对应的中间损失值Loss4。For example, as shown in Figure 12, the four intermediate loss values include the intermediate loss value Loss1 corresponding to the first functional neural network S4, the intermediate loss value Loss2 corresponding to the second functional neural network S5, and the intermediate loss value corresponding to the intention recognition sub-network S6-1. The loss value Loss3 and the intermediate loss value Loss4 corresponding to the named entity recognition sub-network S6-2.
例如,如图12所示,计算4个中间损失值的加权和作为损失值Loss,经步骤S151~S154训练后的共享神经网络和3个功能神经网络的损失函数可以用如下公式(2)表示:For example, as shown in Figure 12, the weighted sum of the four intermediate loss values is calculated as the loss value Loss. The loss functions of the shared neural network and the three functional neural networks trained in steps S151 to S154 can be expressed by the following formula (2) :
Loss=a*Loss1+b*Loss2+c*Loss3+d*Loss4    (2)Loss=a*Loss1+b*Loss2+c*Loss3+d*Loss4 (2)
其中,a为中间损失值Loss1的权重,b为中间损失值Loss2的权重,c为中间损失值Loss3的权重,d为中间损失值Loss4的权重。例如,a、b、c、d的初始值都设置为1。Among them, a is the weight of the intermediate loss value Loss1, b is the weight of the intermediate loss value Loss2, c is the weight of the intermediate loss value Loss3, and d is the weight of the intermediate loss value Loss4. For example, the initial values of a, b, c, and d are all set to 1.
例如,在步骤S155中,如果损失值Loss未满足预定收敛条件,则基于损失值Loss更新待训练的共享神经网络S1~S3和3个功能神经网络的参数。For example, in step S155, if the loss value Loss does not meet the predetermined convergence condition, the parameters of the shared neural networks S1 to S3 and the three functional neural networks to be trained are updated based on the loss value Loss.
例如,为了加速训练过程,可以在训练过程中测量共享神经网络和N个功能神经网络的输出准确度(例如,每训练总轮数的1/10时,测量一次准确度),根据N个功能神经网络的输出准确度动态调整损失函数的M个权重。For example, in order to speed up the training process, the output accuracy of the shared neural network and N functional neural networks can be measured during the training process (for example, the accuracy is measured once every 1/10 of the total training epochs), according to the N functional The output accuracy of the neural network dynamically adjusts the M weights of the loss function.
例如,3个功能神经网络对测试共享特征分别进行处理得到4组第二中间结果,4组第二中间结果包括第一功能神经网络S4输出的第二中间结果、第二功能神经网络S5输出的第二中间结果、意图识别子网络输出的第二中间结果和命名实体识别子网络输出的第二中间结果。For example, three functional neural networks separately process the test shared features to obtain four sets of second intermediate results. The four sets of second intermediate results include the second intermediate results output by the first functional neural network S4 and the second intermediate results output by the second functional neural network S5. The second intermediate result, the second intermediate result output by the intent recognition sub-network and the second intermediate result output by the named entity recognition sub-network.
例如,对于用于执行问答型功能任务的第一功能神经网络S4,输出的第二中间结果为测试句向量,测试句向量包括测试文本中问题的类别信息;对于用于执行闲聊型功能任务的第二功能神经网络S5,输出的第二中间结果为测试输出句子,测试输出句子包括测试文本对应的系统回答;对于用于执行任务型功能任务的第三功能神经网络S6,意图识别子网络输出的第二中间结果为测试意图特征,命名实体识别子网络输出的第二中间结果为至少一个测试命名实体。For example, for the first functional neural network S4 used to perform question-and-answer functional tasks, the second intermediate result output is a test sentence vector, and the test sentence vector includes the category information of the questions in the test text; for the first functional neural network S4 used to perform small talk functional tasks The second intermediate result output by the second functional neural network S5 is the test output sentence, and the test output sentence includes the system answer corresponding to the test text; for the third functional neural network S6 used to perform task-type functional tasks, the intent recognition sub-network output The second intermediate result is the test intention feature, and the second intermediate result output by the named entity recognition sub-network is at least one test named entity.
例如,在步骤S158中,基于测试文本和3个功能神经网络分别输出的4组第二中间结果(即测试句向量、测试输出句子、测试意图特征和至少一个测试命名实体),确定分别对应于训练后的3个功能神经网络的4个输出准确度。例如,对于如图12所示的共享神经网络和多个功能神经网络,3个输出准确度包括第一功能神经网络S4的输出准确度P1、第二功能神经网络S5的输出准确度P2、意图识别子网络S6-1的输出准确度P3和命名实体识别子网络S6-2的输出准确度P4。For example, in step S158, based on the test text and 4 sets of second intermediate results (i.e., test sentence vector, test output sentence, test intention feature, and at least one test named entity) respectively output by the three functional neural networks, it is determined that the test text corresponds to 4 output accuracies of 3 functional neural networks after training. For example, for the shared neural network and multiple functional neural networks as shown in Figure 12, the three output accuracies include the output accuracy P1 of the first functional neural network S4, the output accuracy P2 of the second functional neural network S5, and the intention The output accuracy P3 of the recognition sub-network S6-1 and the output accuracy P4 of the named entity recognition sub-network S6-2.
例如,在步骤S159中,基于4个输出准确度P1、P2、P3、P4调整4个中间损失值分别对应的4个权重a、b、c、d。For example, in step S159, the four weights a, b, c, and d respectively corresponding to the four intermediate loss values are adjusted based on the four output accuracies P1, P2, P3, and P4.
例如,按照从大到小对P1、P2、P3、P4排序,在一些示例中,例如P2>P1>P3>P4,也即是,4个输出准确度中的最大输出准确度为第二功能神经网络S5的输出准确度P2,以输出准确度P2对应的权重b作为第一权重;保持第一权重b不变,增大4个权重中除第一权重b以外的其他3个权重a、c、d。For example, sort P1, P2, P3, and P4 from large to small. In some examples, such as P2>P1>P3>P4, that is, the maximum output accuracy among the 4 output accuracy is the second function. For the output accuracy P2 of the neural network S5, the weight b corresponding to the output accuracy P2 is used as the first weight; keep the first weight b unchanged, and increase the other three weights a, except the first weight b among the four weights. c, d.
例如,可以根据3个权重a、c、d对应的3个输出准确度的大小关系,即P1>P3>P4,确定该3个权重a、c、d的3个放大因子α、β、γ。例如,对于3个输出准确度中的任一个输出准确度,响应于任一个输出准确度越大,该输出准确度对应的权重的放大因子越小。例如,对于P1>P3>P4,可以确定α<β<γ,例如,设置α=0.5,β=1.0,γ=1.5。For example, the three amplification factors α, β, and γ of the three weights a, c, and d can be determined based on the relationship between the three output accuracies corresponding to the three weights a, c, and d, that is, P1>P3>P4. . For example, for any one of the three output accuracy, the greater the response to any output accuracy, the smaller the amplification factor of the weight corresponding to the output accuracy. For example, for P1>P3>P4, α<β<γ can be determined, for example, α=0.5, β=1.0, and γ=1.5 are set.
例如,根据上述3个权重的放大因子,调整上述3个权重。例如,调整 后的4个权重a’、b’、c’、d’可以用如下公式(3)~(6)表示:For example, the above three weights are adjusted according to the amplification factors of the above three weights. For example, the four adjusted weights a’, b’, c’, and d’ can be expressed by the following formulas (3) to (6):
a′=a*(1+α)                 (3)a′=a*(1+α) (3)
b′=b                       (4)b′=b (4)
c′=c*(1+β)                 (5)c′=c*(1+β) (5)
d′=d*(1+γ)                 (6)d′=d*(1+γ) (6)
也即是,最大输出准确度P2对应的权重b不变,将另外3个输出准确度对应的权重a、c、d分别扩大到原来的1.5倍、2倍和2.5倍。That is, the weight b corresponding to the maximum output accuracy P2 remains unchanged, and the weights a, c, and d corresponding to the other three output accuracy are expanded to 1.5 times, 2 times, and 2.5 times respectively.
需要说明的是,以上以图3、图5或图12所示的共享神经网络和多个功能神经网络为例对训练过程和测试过程的描述仅为一个示例(即N=3,M=4),还可以根据实际需要或基于功能神经网络的数量选择其他对应的N和M,本公开的实施例对此不作限制。It should be noted that the above description of the training process and testing process using the shared neural network and multiple functional neural networks shown in Figure 3, Figure 5 or Figure 12 is only an example (i.e. N=3, M=4 ), other corresponding N and M can also be selected according to actual needs or based on the number of functional neural networks, and the embodiments of the present disclosure do not limit this.
本公开的至少一实施例提供的自然语言处理方法,通过在训练过程中动态调整联合训练的各个神经网络的权重,可以加速训练过程中神经网络模型的收敛,从而减少了训练时间。The natural language processing method provided by at least one embodiment of the present disclosure can accelerate the convergence of the neural network model during the training process by dynamically adjusting the weights of each jointly trained neural network during the training process, thereby reducing the training time.
图13为本公开的至少一实施例提供的自然语言处理装置的示意框图。Figure 13 is a schematic block diagram of a natural language processing device provided by at least one embodiment of the present disclosure.
例如,本公开至少一实施例提供一种自然语言处理装置。如图13所示,该自然语言处理装置300包括获取模块310、提取模块320、处理模块330和训练模块340。For example, at least one embodiment of the present disclosure provides a natural language processing device. As shown in FIG. 13 , the natural language processing device 300 includes an acquisition module 310 , an extraction module 320 , a processing module 330 and a training module 340 .
例如,获取模块310配置为获取待进行自然语言处理的任务文本,该任务文本包括多个字符;即该获取模块310可以被配置为执行例如图2所示的步骤S110。For example, the acquisition module 310 is configured to acquire a task text to be subjected to natural language processing, and the task text includes a plurality of characters; that is, the acquisition module 310 can be configured to perform, for example, step S110 shown in FIG. 2 .
例如,提取模块320配置为利用共享神经网络对任务文本进行特征提取,得到任务文本的共享特征,该共享特征包含多个字符的字符特征以及多个字符之间的全局联系;即该提取模块320可以被配置为执行例如图2所示的步骤S120。For example, the extraction module 320 is configured to use a shared neural network to perform feature extraction on the task text to obtain shared features of the task text. The shared features include character features of multiple characters and global connections between multiple characters; that is, the extraction module 320 It may be configured to perform, for example, step S120 shown in FIG. 2 .
例如,处理模块330配置为将共享特征输入多个功能神经网络,得到多个功能神经网络分别输出的多个处理结果,多个功能神经网络用于执行多个不同的自然语言处理任务;即该处理模块330可以被配置为执行例如图6所示的步骤S30~S50。For example, the processing module 330 is configured to input shared features into multiple functional neural networks to obtain multiple processing results respectively output by the multiple functional neural networks. The multiple functional neural networks are used to perform multiple different natural language processing tasks; that is, the multiple functional neural networks are used to perform multiple different natural language processing tasks; The processing module 330 may be configured to perform, for example, steps S30 to S50 shown in FIG. 6 .
例如,在训练共享神经网络和多个功能神经网络的过程中,获取模块310还配置为获取训练文本;即该获取模块310还可以被配置为执行例如图9所 示的步骤S140。For example, in the process of training a shared neural network and multiple functional neural networks, the acquisition module 310 is also configured to acquire training text; that is, the acquisition module 310 can also be configured to perform, for example, step S140 shown in Figure 9.
例如,训练模块340配置为,基于训练文本,对待训练的多个功能神经网络进行训练,以得到训练好的多个功能神经网络,多个功能神经网络的数量为N,这里N为大于1的整数;即该测量模块340可以被配置为执行例如图9所示的步骤S150。For example, the training module 340 is configured to train multiple functional neural networks to be trained based on the training text to obtain multiple trained functional neural networks. The number of multiple functional neural networks is N, where N is greater than 1. integer; that is, the measurement module 340 may be configured to perform, for example, step S150 shown in FIG. 9 .
由于在描述例如图2和图9所示的自然语言处理方法的过程中,已经对上述自然语言处理装置300的操作所涉及的内容的细节进行了介绍,因此这里为简洁起见不再赘述,相关细节可参照以上关于图1~图12的描述。Since the details of the content involved in the operation of the above-mentioned natural language processing device 300 have been introduced during the description of the natural language processing method shown in FIG. 2 and FIG. 9 , for the sake of brevity, they will not be described again here. For details, please refer to the above description about FIGS. 1 to 12 .
需要说明的是,图13所示的自然语言处理装置300中上述的各个模块可被分别配置为执行特定功能的软件、硬件、固件或上述项的任意组合。例如,这些模块可对应于专用的集成电路,也可对应于纯粹的软件代码,还可对应于软件与硬件相结合的模块。作为示例,参照图13描述的装置可以是PC计算机、平板装置、个人数字助理、智能手机、web应用或其它能够执行程序指令的装置,但不限于此。It should be noted that the above-mentioned modules in the natural language processing device 300 shown in FIG. 13 can be respectively configured as software, hardware, firmware or any combination of the above items to perform specific functions. For example, these modules may correspond to dedicated integrated circuits, pure software codes, or modules that combine software and hardware. As an example, the device described with reference to FIG. 13 may be a PC computer, a tablet device, a personal digital assistant, a smartphone, a web application, or other devices capable of executing program instructions, but is not limited thereto.
另外,尽管以上在描述自然语言处理装置300时将其划分为用于分别执行相应处理的模块,然而,本领域技术人员清楚的是,各模块执行的处理也可以在装置中不进行任何具体模块划分或者各模块之间并无明确划界的情况下执行。此外,以上参照图13描述的自然语言处理装置300并不限于包括以上描述的模块,而是还可以根据需要增加一些其它模块(例如,存储模块、数据处理模块等),或者以上模块也可被组合。In addition, although the natural language processing device 300 is described above as being divided into modules for performing corresponding processing respectively, however, it is clear to those skilled in the art that the processing performed by each module can also be performed in the device without any specific module. Divided or there is no clear demarcation between modules. In addition, the natural language processing device 300 described above with reference to FIG. 13 is not limited to including the modules described above, but can also add some other modules (for example, storage module, data processing module, etc.) as needed, or the above modules can also be added. combination.
本公开的至少一实施例还提供一种电子设备,该电子设备包括处理器和存储器;该存储器包括一个或多个计算机程序模块;一个或多个计算机程序模块被存储在存储器中并被配置为由处理器执行,一个或多个计算机程序模块包括用于实现上文所述的本公开的实施例提供的自然语言处理方法。At least one embodiment of the present disclosure also provides an electronic device, the electronic device includes a processor and a memory; the memory includes one or more computer program modules; the one or more computer program modules are stored in the memory and configured to Executed by a processor, one or more computer program modules include a method for implementing the natural language processing method provided by the embodiments of the present disclosure described above.
图14为本公开的至少一实施例提供的一种电子设备的示意框图。FIG. 14 is a schematic block diagram of an electronic device according to at least one embodiment of the present disclosure.
例如,如图14所示,该电子设备400包括处理器410和存储器420。例如,存储器420用于存储非暂时性计算机可读指令(例如一个或多个计算机程序模块)。处理器410用于运行非暂时性计算机可读指令,非暂时性计算机可读指令被处理器410运行时可以执行根据上文所述的自然语言处理方法的一个或多个步骤。存储器420和处理器410可以通过总线系统和/或其它形式的连接机构(未示出)互连。For example, as shown in FIG. 14 , the electronic device 400 includes a processor 410 and a memory 420 . For example, memory 420 is used to store non-transitory computer-readable instructions (eg, one or more computer program modules). The processor 410 is configured to execute non-transitory computer readable instructions. When the non-transitory computer readable instructions are executed by the processor 410, they may perform one or more steps according to the natural language processing method described above. Memory 420 and processor 410 may be interconnected by a bus system and/or other forms of connection mechanisms (not shown).
例如,处理器410可以是中央处理单元(CPU)、数字信号处理器(DSP)或者具有数据处理能力和/或程序执行能力的其它形式的处理单元,例如现场可编程门阵列(FPGA)等;例如,中央处理单元(CPU)可以为X86或ARM架构等。处理器410可以为通用处理器或专用处理器,可以控制电子设备400中的其它组件以执行期望的功能。For example, the processor 410 may be a central processing unit (CPU), a digital signal processor (DSP), or other forms of processing units with data processing capabilities and/or program execution capabilities, such as a field programmable gate array (FPGA), etc.; For example, the central processing unit (CPU) may be of X86 or ARM architecture. The processor 410 may be a general-purpose processor or a special-purpose processor that may control other components in the electronic device 400 to perform desired functions.
例如,存储器420可以包括一个或多个计算机程序产品的任意组合,计算机程序产品可以包括各种形式的计算机可读存储介质,例如易失性存储器和/或非易失性存储器。易失性存储器例如可以包括随机存取存储器(RAM)和/或高速缓冲存储器(cache)等。非易失性存储器例如可以包括只读存储器(ROM)、硬盘、可擦除可编程只读存储器(EPROM)、便携式紧致盘只读存储器(CD-ROM)、USB存储器、闪存等。在计算机可读存储介质上可以存储一个或多个计算机程序模块,处理器410可以运行一个或多个计算机程序模块,以实现电子设备400的各种功能。在计算机可读存储介质中还可以存储各种应用程序和各种数据以及应用程序使用和/或产生的各种数据等。For example, memory 420 may include any combination of one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and/or cache memory (cache), etc. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, erasable programmable read-only memory (EPROM), portable compact disk read-only memory (CD-ROM), USB memory, flash memory, and the like. One or more computer program modules may be stored on the computer-readable storage medium, and the processor 410 may run the one or more computer program modules to implement various functions of the electronic device 400 . Various application programs and various data, as well as various data used and/or generated by the application programs, etc. can also be stored in the computer-readable storage medium.
需要说明的是,本公开的实施例中,电子设备400的具体功能和技术效果可以参考上文中关于本公开至少一实施例提供的自然语言处理方法的描述,此处不再赘述。It should be noted that in the embodiments of the present disclosure, for the specific functions and technical effects of the electronic device 400, reference can be made to the above description of the natural language processing method provided by at least one embodiment of the present disclosure, which will not be described again here.
图15为本公开的至少一实施例提供的另一种电子设备的示意框图。FIG. 15 is a schematic block diagram of another electronic device provided by at least one embodiment of the present disclosure.
例如,如图15所示,该电子设备500例如适于用来实施本公开实施例提供的自然语言处理方法。需要注意的是,图15示出的电子设备500仅是一个示例,其不会对本公开实施例的功能和使用范围带来任何限制。For example, as shown in FIG. 15 , the electronic device 500 is suitable for implementing the natural language processing method provided by the embodiment of the present disclosure. It should be noted that the electronic device 500 shown in FIG. 15 is only an example, which does not bring any limitations to the functions and scope of use of the embodiments of the present disclosure.
例如,如图15所示,电子设备500可以包括处理装置(例如中央处理器、图形处理器等)51,该处理装置51例如包括根据本公开任一实施例的自然语言处理装置,并且其可以根据存储在只读存储器(ROM)52中的程序或者从存储装置48加载到随机访问存储器(RAM)53中的程序而执行各种适当的动作和处理。在RAM 53中,还存储有温度误差检测设备500操作所需的各种程序和数据。处理装置51、ROM 52以及RAM 53通过总线54彼此相连。输入/输出(I/O)接口55也连接至总线54。通常,以下装置可以连接至I/O接口55:包括例如触摸屏、触摸板、键盘、鼠标、摄像头、麦克风、加速度计、陀螺仪等的输入装置56;包括例如液晶显示器(LCD)、扬声器、振动器等的输出装置57;包括例如磁带、硬盘等的存储装置58;以及通信装置59。 通信装置59可以允许温度误差检测设备500与其他电子设备进行无线或有线通信以交换数据。For example, as shown in FIG. 15 , the electronic device 500 may include a processing device (such as a central processing unit, a graphics processor, etc.) 51 , which may include a natural language processing device according to any embodiment of the present disclosure, and may Various appropriate actions and processes are performed based on the program stored in the read-only memory (ROM) 52 or loaded from the storage device 48 into the random access memory (RAM) 53 . In the RAM 53, various programs and data required for the operation of the temperature error detection device 500 are also stored. The processing device 51, the ROM 52 and the RAM 53 are connected to each other via a bus 54. An input/output (I/O) interface 55 is also connected to bus 54 . Generally, the following devices may be connected to the I/O interface 55: input devices 56 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; including, for example, a liquid crystal display (LCD), speakers, vibration An output device 57 such as a computer; a storage device 58 including a magnetic tape, a hard disk, etc.; and a communication device 59. The communication device 59 may allow the temperature error detection device 500 to communicate wirelessly or wiredly with other electronic devices to exchange data.
虽然图15示出了具有各种装置的电子设备500,但应理解的是,并不要求实施或具备所有示出的装置,电子设备500可以替代地实施或具备更多或更少的装置。Although FIG. 15 illustrates electronic device 500 having various means, it should be understood that implementation or provision of all illustrated means is not required and electronic device 500 may alternatively implement or be provided with more or fewer means.
关于电子设备500的详细说明和技术效果,可以参考上文关于自然语言处理方法的相关描述,此处不再赘述。For detailed description and technical effects of the electronic device 500, please refer to the relevant description of the natural language processing method above, which will not be described again here.
图16为本公开的至少一实施例提供的一种存储介质的示意图。Figure 16 is a schematic diagram of a storage medium provided by at least one embodiment of the present disclosure.
例如,如图16所示,存储介质600用于存储非暂时性计算机可读指令610。例如,当非暂时性计算机可读指令610由计算机执行时可以执行根据上文所述的自然语言处理方法中的一个或多个步骤。For example, as shown in FIG. 16, storage medium 600 is used to store non-transitory computer-readable instructions 610. For example, the non-transitory computer readable instructions 610, when executed by a computer, may perform one or more steps in the natural language processing method described above.
例如,该存储介质600可以应用于上述电子设备400中。例如,存储介质600可以为图15所示的电子设备400中的存储器420。例如,关于存储介质600的相关说明可以参考图15所示的电子设备400中的存储器420的相应描述,此处不再赘述。For example, the storage medium 600 can be applied to the above-mentioned electronic device 400. For example, the storage medium 600 may be the memory 420 in the electronic device 400 shown in FIG. 15 . For example, the relevant description of the storage medium 600 may refer to the corresponding description of the memory 420 in the electronic device 400 shown in FIG. 15 , which will not be described again here.
对于本公开,有以下几点需要说明:Regarding this disclosure, the following points need to be explained:
(1)本公开实施例附图中,只涉及到与本公开实施例涉及到的结构,其他结构可参考通常设计。(1) In the drawings of the embodiments of the present disclosure, only the structures related to the embodiments of the present disclosure are involved, and other structures may refer to common designs.
(2)在不冲突的情况下,本公开同一实施例及不同实施例中的特征可以相互组合。(2) Features in the same embodiment and different embodiments of the present disclosure can be combined with each other without conflict.
以上,仅为本公开的具体实施方式,但本公开的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本公开揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本公开的保护范围之内。因此,本公开的保护范围应以权利要求的保护范围为准。The above are only specific embodiments of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present disclosure, and all of them should be covered. within the scope of this disclosure. Therefore, the protection scope of the present disclosure should be subject to the protection scope of the claims.

Claims (19)

  1. 一种自然语言处理方法,包括:A natural language processing method that includes:
    获取待进行所述自然语言处理的任务文本,其中,所述任务文本包括多个字符;Obtain the task text to be performed on the natural language processing, wherein the task text includes a plurality of characters;
    利用共享神经网络对所述任务文本进行特征提取,得到所述任务文本的共享特征,其中,所述共享特征包含所述多个字符的字符特征以及所述多个字符之间的全局联系;Use a shared neural network to perform feature extraction on the task text to obtain shared features of the task text, where the shared features include character features of the multiple characters and global connections between the multiple characters;
    将所述共享特征输入多个功能神经网络,得到所述多个功能神经网络分别输出的多个处理结果,其中,所述多个功能神经网络用于分别执行多个不同的自然语言处理任务。The shared features are input into multiple functional neural networks to obtain multiple processing results respectively output by the multiple functional neural networks, where the multiple functional neural networks are used to perform multiple different natural language processing tasks respectively.
  2. 根据权利要求1所述的自然语言处理方法,其中,所述共享神经网络包括输入子网络、字嵌入子网络和特征提取子网络,The natural language processing method according to claim 1, wherein the shared neural network includes an input sub-network, a word embedding sub-network and a feature extraction sub-network,
    所述利用所述共享神经网络对所述任务文本进行特征提取,得到所述任务文本的所述共享特征,包括:The use of the shared neural network to perform feature extraction on the task text to obtain the shared features of the task text includes:
    利用所述输入子网络将所述任务文本转换为字索引数组,其中,所述字索引数组包括的多个索引值与所述多个字符一一对应;The input sub-network is used to convert the task text into a word index array, wherein the plurality of index values included in the word index array correspond to the plurality of characters one-to-one;
    利用所述字嵌入子网络将所述字索引数组编码为多个字向量,其中,所述多个字向量与所述多个字符一一对应,所述多个字向量中的每个字向量包括对应字符的字符特征;The word index array is encoded into a plurality of word vectors using the word embedding sub-network, wherein the plurality of word vectors correspond to the plurality of characters one-to-one, and each word vector in the plurality of word vectors Includes character characteristics of corresponding characters;
    基于所述多个字向量,利用所述特征提取子网络提取所述多个字符之间的所述全局联系,得到所述共享特征。Based on the plurality of word vectors, the feature extraction sub-network is used to extract the global connection between the plurality of characters to obtain the shared features.
  3. 根据权利要求2所述的自然语言处理方法,其中,所述特征提取子网络包括卷积神经网络和长短期记忆网络。The natural language processing method according to claim 2, wherein the feature extraction sub-network includes a convolutional neural network and a long short-term memory network.
  4. 根据权利要求1-3中任一项所述的自然语言处理方法,其中,所述自然语言处理任务包括问答型功能任务,所述问答型功能任务用于解析所述任务文本中的问题,给出所述问题对应的答案,The natural language processing method according to any one of claims 1 to 3, wherein the natural language processing task includes a question and answer type functional task, and the question and answer type functional task is used to parse questions in the task text, giving Provide the corresponding answer to the question,
    所述多个功能神经网络包括第一功能神经网络,所述第一功能神经网络用于执行所述问答型功能任务,The plurality of functional neural networks include a first functional neural network, the first functional neural network is used to perform the question and answer functional task,
    所述将所述共享特征输入所述多个功能神经网络,得到所述多个功能神经网络分别输出的所述多个处理结果,包括:The step of inputting the shared features into the multiple functional neural networks to obtain the multiple processing results respectively output by the multiple functional neural networks includes:
    利用所述第一功能神经网络对所述共享特征进行第一处理,得到句向量,其中,所述句向量包括所述任务文本中所述问题的类别信息;Using the first functional neural network to perform first processing on the shared features to obtain a sentence vector, wherein the sentence vector includes category information of the question in the task text;
    将所述句向量与数据库中预存的多个知识信息向量进行比较,以将所述多个知识信息向量中的与所述句向量的向量距离最小的知识信息向量对应的答案作为对应于所述第一功能神经网络的处理结果。The sentence vector is compared with multiple knowledge information vectors pre-stored in the database, so that the answer corresponding to the knowledge information vector with the smallest vector distance from the sentence vector among the multiple knowledge information vectors is used as the answer corresponding to the The processing result of the first functional neural network.
  5. 根据权利要求4所述的自然语言处理方法,其中,所述第一处理包括卷积处理、池化处理、特征融合处理和全连接处理。The natural language processing method according to claim 4, wherein the first processing includes convolution processing, pooling processing, feature fusion processing and fully connected processing.
  6. 根据权利要求1-5中任一项所述的自然语言处理方法,其中,所述自然语言处理任务包括闲聊型功能任务,所述闲聊型功能任务用于解析所述任务文本中的无目的性对话信息,给出所述无目的性对话信息对应的系统回答,The natural language processing method according to any one of claims 1 to 5, wherein the natural language processing task includes a chat-type functional task, and the chat-type functional task is used to parse purposelessness in the task text. Dialogue information, giving the system answer corresponding to the purposeless dialogue information,
    所述多个功能神经网络包括第二功能神经网络,所述第二功能神经网络用于执行所述闲聊型功能任务,The plurality of functional neural networks include a second functional neural network, the second functional neural network is used to perform the chat-type functional task,
    所述将所述共享特征输入所述多个功能神经网络,得到所述多个功能神经网络分别输出的所述多个处理结果,包括:The step of inputting the shared features into the multiple functional neural networks to obtain the multiple processing results respectively output by the multiple functional neural networks includes:
    利用所述第二功能神经网络对所述共享特征进行第二处理,得到输出句子以作为对应于所述第二功能神经网络的处理结果,并将对应于所述第二功能神经网络的处理结果作为所述任务文本对应的系统回答。The second functional neural network is used to perform a second process on the shared features to obtain an output sentence as a processing result corresponding to the second functional neural network, and the processing result corresponding to the second functional neural network is As the system answer corresponding to the task text.
  7. 根据权利要求6所述的自然语言处理方法,其中,所述第二功能神经网络包括编码子网络和解码子网络,The natural language processing method according to claim 6, wherein the second functional neural network includes an encoding sub-network and a decoding sub-network,
    所述利用所述第二功能神经网络对所述共享特征进行所述第二处理,得到所述输出句子以作为对应于所述第二功能神经网络的处理结果,包括:Using the second functional neural network to perform the second processing on the shared features to obtain the output sentence as a processing result corresponding to the second functional neural network includes:
    利用所述编码子网络对所述共享特征进行编码处理得到中间索引数组;Using the encoding sub-network to encode the shared features to obtain an intermediate index array;
    利用所述解码子网络对所述中间索引数组进行解码处理得到所述输出句子,以作为对应于所述第二功能神经网络的处理结果。The decoding sub-network is used to decode the intermediate index array to obtain the output sentence as a processing result corresponding to the second functional neural network.
  8. 根据权利要求1-7中任一项所述的自然语言处理方法,其中,所述自然语言处理任务包括任务型功能任务,所述任务型功能任务用于解析所述任务文本中的任务目的信息和任务关键词信息,根据所述任务目的信息和所述任务关键词信息得到系统追问或问答结果,The natural language processing method according to any one of claims 1 to 7, wherein the natural language processing task includes a task-type functional task, and the task-type functional task is used to parse task purpose information in the task text. and task keyword information, and obtain system questioning or question and answer results based on the task purpose information and the task keyword information,
    所述多个功能神经网络包括第三功能神经网络,所述第三功能神经网络用于执行所述任务型功能任务,The plurality of functional neural networks include a third functional neural network, the third functional neural network is used to perform the task-type functional task,
    所述将所述共享特征输入所述多个功能神经网络,得到所述多个功能神经网络分别输出的所述多个处理结果,包括:The step of inputting the shared features into the multiple functional neural networks to obtain the multiple processing results respectively output by the multiple functional neural networks includes:
    利用所述第三功能神经网络对所述共享特征进行第三处理,得到对应于所述任务文本的意图特征和至少一个命名实体,其中,所述意图特征包含所述任务文本中的所述任务目的信息,所述至少一个命名实体包含所述任务关键词信息;Using the third functional neural network to perform third processing on the shared features, obtain intent features and at least one named entity corresponding to the task text, wherein the intent features include the task in the task text Purpose information, the at least one named entity contains the task keyword information;
    对所述意图特征和所述至少一个命名实体进行对话管理,得到所述系统追问或所述问答结果以作为对应于所述第三功能神经网络的处理结果。Perform dialogue management on the intent feature and the at least one named entity, and obtain the system questioning or the question and answer result as a processing result corresponding to the third functional neural network.
  9. 根据权利要求8所述的自然语言处理方法,其中,所述第三功能神经网络包括意图识别子网络和命名实体识别子网络,The natural language processing method according to claim 8, wherein the third functional neural network includes an intent recognition sub-network and a named entity recognition sub-network,
    所述利用所述第三功能神经网络对所述共享特征进行所述第三处理,得到对应于所述任务文本的所述意图特征和所述至少一个命名实体,包括:Using the third functional neural network to perform the third processing on the shared features to obtain the intended features and the at least one named entity corresponding to the task text includes:
    利用所述意图识别子网络,基于所述共享特征进行意图识别,得到对应于所述任务文本的所述意图特征;Utilize the intent recognition sub-network to perform intent recognition based on the shared features to obtain the intent features corresponding to the task text;
    利用所述命名实体识别子网络,基于所述共享特征执行命名实体识别,得到对应于所述任务文本的所述至少一个命名实体。The named entity recognition sub-network is used to perform named entity recognition based on the shared characteristics to obtain the at least one named entity corresponding to the task text.
  10. 根据权利要求1-9中任一项所述的自然语言处理方法,其中,所述获取所述待进行所述自然语言处理的所述任务文本,包括:The natural language processing method according to any one of claims 1 to 9, wherein the obtaining the task text to be subjected to the natural language processing includes:
    获取所述待进行所述自然语言处理的语音片段;Obtain the speech segments to be subjected to the natural language processing;
    将所述语音片段转换为文字形式,以得到所述任务文本。Convert the voice clip into text form to obtain the task text.
  11. 根据权利要求1-10中任一项所述的自然语言处理方法,还包括:The natural language processing method according to any one of claims 1-10, further comprising:
    通过仲裁选择从所述多个处理结果中选择一个处理结果作为所述自然语言处理的输出结果。Select one processing result from the plurality of processing results as the output result of the natural language processing through arbitration selection.
  12. 根据权利要求1-11中任一项所述的自然语言处理方法,在获取所述自然语言对应的所述任务文本之前,还包括:The natural language processing method according to any one of claims 1-11, before obtaining the task text corresponding to the natural language, further includes:
    获取训练文本;Get training text;
    基于所述训练文本,对待训练的多个功能神经网络进行训练,以得到训练好的所述多个功能神经网络,其中,所述多个功能神经网络的数量为N,N为大于1的整数,Based on the training text, multiple functional neural networks to be trained are trained to obtain the multiple trained functional neural networks, where the number of the multiple functional neural networks is N, and N is an integer greater than 1. ,
    其中,在训练待训练的N个功能神经网络过程中,所述N个功能神经网 络同时训练,且计算所述N个功能神经网络对应的M个中间损失值的加权和作为损失值以更新所述N个功能神经网络的参数,所述M个中间损失值分别对应M个权重,所述M个权重根据所述N个功能神经网络的输出准确度进行动态调整,M为大于等于N的整数。In the process of training the N functional neural networks to be trained, the N functional neural networks are trained simultaneously, and the weighted sum of the M intermediate loss values corresponding to the N functional neural networks is calculated as the loss value to update the The parameters of the N functional neural networks, the M intermediate loss values respectively correspond to M weights, the M weights are dynamically adjusted according to the output accuracy of the N functional neural networks, M is an integer greater than or equal to N .
  13. 根据权利要求12所述的自然语言处理方法,其中,所述N个功能神经网络包括第一功能神经网络、第二功能神经网络和第三功能神经网络,所述第三功能神经网络包括意图识别子网络和命名实体识别子网络,The natural language processing method according to claim 12, wherein the N functional neural networks include a first functional neural network, a second functional neural network and a third functional neural network, and the third functional neural network includes intention recognition subnetworks and named entity recognition subnetworks,
    所述基于所述训练文本,对所述待训练的多个功能神经网络进行训练,包括:The training of the multiple functional neural networks to be trained based on the training text includes:
    利用待训练的共享神经网络对所述训练文本进行特征提取,得到所述训练文本的训练共享特征;Use the shared neural network to be trained to perform feature extraction on the training text to obtain the training shared features of the training text;
    利用所述N个功能神经网络对所述训练共享特征分别进行处理,得到所述N个功能神经网络分别输出的M组第一中间结果,其中,所述M组第一中间结果包括所述第一功能神经网络输出的第一中间结果、所述第二功能神经网络输出的第一中间结果、所述意图识别子网络输出的第一中间结果和所述命名实体识别子网络输出的第一中间结果。The training shared features are separately processed using the N functional neural networks to obtain M sets of first intermediate results respectively output by the N functional neural networks, wherein the M sets of first intermediate results include the The first intermediate result output by a functional neural network, the first intermediate result output by the second functional neural network, the first intermediate result output by the intention recognition sub-network and the first intermediate result output by the named entity recognition sub-network result.
  14. 根据权利要求13所述的自然语言处理方法,其中,所述基于所述训练文本,对所述待训练的多个功能神经网络进行训练,还包括:The natural language processing method according to claim 13, wherein said training the plurality of functional neural networks to be trained based on the training text further includes:
    基于所述训练文本和所述M组第一中间结果计算所述N个功能神经网络对应的M个中间损失值,其中,所述M个中间损失值包括所述第一功能神经网络对应的中间损失值、所述第二功能神经网络对应的中间损失值、所述意图识别子网络对应的中间损失值和所述命名实体识别子网络对应的中间损失值;Calculate M intermediate loss values corresponding to the N functional neural networks based on the training text and the M sets of first intermediate results, where the M intermediate loss values include intermediate loss values corresponding to the first functional neural network The loss value, the intermediate loss value corresponding to the second functional neural network, the intermediate loss value corresponding to the intention recognition sub-network, and the intermediate loss value corresponding to the named entity recognition sub-network;
    计算所述M个中间损失值的加权和作为所述损失值;Calculate the weighted sum of the M intermediate loss values as the loss value;
    在所述损失值未满足预定收敛条件时,基于所述损失值更新所述待训练的所述共享神经网络和所述N个功能神经网络的参数。When the loss value does not satisfy the predetermined convergence condition, the parameters of the shared neural network to be trained and the N functional neural networks are updated based on the loss value.
  15. 根据权利要求13或14中任一项所述的自然语言处理方法,其中,所述基于所述训练文本,对所述待训练的多个功能神经网络进行训练,还包括:The natural language processing method according to any one of claims 13 or 14, wherein said training the plurality of functional neural networks to be trained based on the training text further includes:
    获取测试文本;Get test text;
    利用训练后的所述共享神经网络和训练后的所述N个功能神经网络对所 述测试文本进行处理,得到M组第二中间结果;Use the trained shared neural network and the trained N functional neural networks to process the test text to obtain M sets of second intermediate results;
    基于所述M组第二中间结果和所述测试文本,确定分别对应于所述训练后的N个功能神经网络的M个输出准确度,其中,所述M个输出准确度包括所述第一功能神经网络的输出准确度、所述第二功能神经网络的输出准确度、所述意图识别子网络的输出准确度和所述命名实体识别子网络的输出准确度;Based on the M sets of second intermediate results and the test text, M output accuracies respectively corresponding to the trained N functional neural networks are determined, wherein the M output accuracies include the first The output accuracy of the functional neural network, the output accuracy of the second functional neural network, the output accuracy of the intent recognition sub-network, and the output accuracy of the named entity recognition sub-network;
    基于所述M个输出准确度调整所述M个中间损失值分别对应的M个权重;Adjust the M weights respectively corresponding to the M intermediate loss values based on the M output accuracies;
    根据调整后的所述M个权重继续对所述待训练的多个功能神经网络进行训练。Continue to train the multiple functional neural networks to be trained according to the adjusted M weights.
  16. 根据权利要求15所述的自然语言处理方法,其中,所述基于所述M个输出准确度调整所述M个中间损失值分别对应的M个权重,包括:The natural language processing method according to claim 15, wherein the adjusting the M weights respectively corresponding to the M intermediate loss values based on the M output accuracies includes:
    确定所述M个输出准确度中的最大输出准确度对应的权重作为第一权重;Determine the weight corresponding to the maximum output accuracy among the M output accuracy as the first weight;
    保持所述第一权重不变,增大所述M个权重中除所述第一权重以外的其他M-1个权重。Keep the first weight unchanged, and increase the other M-1 weights among the M weights except the first weight.
  17. 根据权利要求16所述的自然语言处理方法,其中,所述增大所述M个权重中除所述第一权重以外的其他M-1个权重,包括:The natural language processing method according to claim 16, wherein said increasing M-1 weights other than the first weight among the M weights includes:
    根据所述M-1个权重对应的M-1个输出准确度的大小关系,确定所述M-1个权重的M-1个放大因子,其中,对于所述M-1个输出准确度中的任一个输出准确度,响应于所述任一个输出准确度越大,所述任一个输出准确度对应的权重的放大因子越小;According to the size relationship of the M-1 output accuracies corresponding to the M-1 weights, M-1 amplification factors of the M-1 weights are determined, wherein, for the M-1 output accuracies, In response to any output accuracy, the greater the accuracy of any output, the smaller the amplification factor of the weight corresponding to any output accuracy;
    根据所述M-1个权重的放大因子,调整所述M-1个权重。The M-1 weights are adjusted according to the amplification factors of the M-1 weights.
  18. 一种电子设备,包括:An electronic device including:
    处理器;processor;
    存储器,包括一个或多个计算机程序模块,memory, including one or more computer program modules,
    其中,所述一个或多个计算机程序模块被存储在所述存储器中并被配置为由所述处理器执行,所述一个或多个计算机程序模块用于实现权利要求1-17任一所述的自然语言处理方法。Wherein, the one or more computer program modules are stored in the memory and configured to be executed by the processor, and the one or more computer program modules are used to implement any one of claims 1-17 natural language processing methods.
  19. 一种存储介质,用于存储非暂时性计算机可读指令,当所述非暂时性计算机可读指令由计算机执行时可以实现权利要求1-17任一所述的自然语言处理方法。A storage medium used to store non-transitory computer-readable instructions. When the non-transitory computer-readable instructions are executed by a computer, the natural language processing method described in any one of claims 1-17 can be implemented.
PCT/CN2022/142456 2022-08-26 2022-12-27 Natural language processing method and apparatus, electronic device, and storage medium WO2024040831A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211030338.2 2022-08-26
CN202211030338.2A CN115409038A (en) 2022-08-26 2022-08-26 Natural language processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
WO2024040831A1 true WO2024040831A1 (en) 2024-02-29

Family

ID=84160864

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/142456 WO2024040831A1 (en) 2022-08-26 2022-12-27 Natural language processing method and apparatus, electronic device, and storage medium

Country Status (2)

Country Link
CN (1) CN115409038A (en)
WO (1) WO2024040831A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115409038A (en) * 2022-08-26 2022-11-29 湖北星纪时代科技有限公司 Natural language processing method and device, electronic equipment and storage medium
CN116663568B (en) * 2023-07-31 2023-11-17 腾云创威信息科技(威海)有限公司 Critical task identification system and method based on priority

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180013699A1 (en) * 2016-07-08 2018-01-11 Asapp, Inc Assisting entities in responding to a request of a user
CN110598206A (en) * 2019-08-13 2019-12-20 平安国际智慧城市科技股份有限公司 Text semantic recognition method and device, computer equipment and storage medium
CN112015921A (en) * 2020-09-15 2020-12-01 重庆广播电视大学重庆工商职业学院 Natural language processing method based on learning-assisted knowledge graph
CN113963358A (en) * 2021-12-20 2022-01-21 北京易真学思教育科技有限公司 Text recognition model training method, text recognition device and electronic equipment
CN115409038A (en) * 2022-08-26 2022-11-29 湖北星纪时代科技有限公司 Natural language processing method and device, electronic equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180013699A1 (en) * 2016-07-08 2018-01-11 Asapp, Inc Assisting entities in responding to a request of a user
CN110598206A (en) * 2019-08-13 2019-12-20 平安国际智慧城市科技股份有限公司 Text semantic recognition method and device, computer equipment and storage medium
CN112015921A (en) * 2020-09-15 2020-12-01 重庆广播电视大学重庆工商职业学院 Natural language processing method based on learning-assisted knowledge graph
CN113963358A (en) * 2021-12-20 2022-01-21 北京易真学思教育科技有限公司 Text recognition model training method, text recognition device and electronic equipment
CN115409038A (en) * 2022-08-26 2022-11-29 湖北星纪时代科技有限公司 Natural language processing method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN115409038A (en) 2022-11-29

Similar Documents

Publication Publication Date Title
US11503155B2 (en) Interactive voice-control method and apparatus, device and medium
WO2024040831A1 (en) Natural language processing method and apparatus, electronic device, and storage medium
JP7066349B2 (en) Translation method, translation equipment and computer program
US20230206911A1 (en) Processing natural language using machine learning to determine slot values based on slot descriptors
CN110287461B (en) Text conversion method, device and storage medium
CN111862977B (en) Voice conversation processing method and system
JP5901001B1 (en) Method and device for acoustic language model training
US9269354B2 (en) Semantic re-ranking of NLU results in conversational dialogue applications
US9171542B2 (en) Anaphora resolution using linguisitic cues, dialogue context, and general knowledge
CN110807332A (en) Training method of semantic understanding model, semantic processing method, semantic processing device and storage medium
KR20190073525A (en) Implicit bridging of machine learning tasks
US9361884B2 (en) Communicating context across different components of multi-modal dialog applications
US10579835B1 (en) Semantic pre-processing of natural language input in a virtual personal assistant
US11769018B2 (en) System and method for temporal attention behavioral analysis of multi-modal conversations in a question and answer system
CN110795945A (en) Semantic understanding model training method, semantic understanding device and storage medium
CN110795552A (en) Training sample generation method and device, electronic equipment and storage medium
KR20210088461A (en) Method and apparatus for training network, device, storage medium and program
CN111090728A (en) Conversation state tracking method and device and computing equipment
CN112507706B (en) Training method and device for knowledge pre-training model and electronic equipment
CN112509562A (en) Method, apparatus, electronic device and medium for text post-processing
CN113470619A (en) Speech recognition method, apparatus, medium, and device
CN111354343A (en) Voice wake-up model generation method and device and electronic equipment
CN115394321A (en) Audio emotion recognition method, device, equipment, storage medium and product
CN115640520A (en) Method, device and storage medium for pre-training cross-language cross-modal model
JP2021117989A (en) Language generation method, device and electronic apparatus

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22956362

Country of ref document: EP

Kind code of ref document: A1