Semantic recognition method and device, electronic equipment and storage medium
By jointly training the intent recognition model and the slot labeling model, and combining the domain knowledge base and the global language knowledge base, the problem of cumbersome training and low recognition efficiency of semantic recognition models in existing technologies is solved, and efficient and accurate semantic recognition results are achieved.
Patent Information
- Application Number
- CN201911151625.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-11-21
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2039-11-21
AI Technical Summary
In existing technologies, the training process of semantic recognition models is cumbersome, with low performance and efficiency, low recognition accuracy, and the lack of correlation between models leads to poor recognition results.
A joint training method combining an intent recognition model and a slot labeling model is adopted. The query text is recognized by a semantic joint recognition model, which is trained and recognized by combining a domain knowledge base and a global language knowledge base. The first model loss of the intent recognition model and the second model loss of the slot labeling model are jointly optimized.
It simplifies the model training process, improves recognition efficiency and accuracy, realizes the correlation prediction output of intent and slot value prediction results, and improves the overall performance of semantic recognition.
Smart Images

Figure CN112825114B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of artificial intelligence, and in particular to a semantic recognition method and device, an electronic device, and a storage medium. BACKGROUND
[0002] A human-computer conversation system supported by voice technology and NLP technology has a relatively wide application in scenarios such as smart phones, smart homes, and vehicle-mounted devices. It usually includes three parts of semantic recognition (which can also be called semantic understanding), dialogue management, and reply generation. Semantic recognition is an important link and the basis for subsequent steps, which refers to recognizing the intent of a query query text input by a user and entity information contained therein, and specifically mainly includes two main tasks of intent recognition and slot value labeling. In related technologies, semantic recognition is only based on global language to recognize the query text by using a trained language model, and usually requires separately training multiple independent neural network models to complete semantic analysis of the query text. The multiple neural network models separately trained have no any correlation, so that the model training process and the semantic recognition process become cumbersome and heavy, the performance and efficiency are relatively low, and the recognition accuracy needs to be improved. SUMMARY
[0003] The semantic recognition method, device, electronic device, and storage medium provided by the embodiments of the present application at least solve the problems in the related art that the model training process and the semantic recognition process are cumbersome, the performance and efficiency are relatively low, and the recognition accuracy is also relatively low.
[0004] To at least solve the above technical problems, the embodiments of the present application provide a semantic recognition method, which comprises: acquiring a to-be-recognized query text; identifying the to-be-recognized query file by using a semantic joint recognition model to output an intent recognition result and a slot value recognition result; the semantic joint recognition model comprises: jointly training an intent recognition model and a slot value labeling model according to a first model loss of the intent recognition model and a second model loss of the slot value labeling model, and the obtained intent recognition model and slot value labeling model have correlation.
[0005] To at least solve the above technical problems, the embodiments of the present application also provide a semantic recognition device, which comprises: a text acquisition module configured to acquire a to-be-recognized query text; and a semantic recognition module configured to identify the to-be-recognized query file by using a semantic joint recognition model to output an intent recognition result and a slot value recognition result; the semantic joint recognition model comprises: jointly training an intent recognition model and a slot value labeling model according to a first model loss of the intent recognition model and a second model loss of the slot value labeling model, and the obtained intent recognition model and slot value labeling model have correlation.
[0006] To at least solve the above technical problems, the embodiment of the present application further provides an electronic device, comprising a processor and a memory; the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory to realize the steps of the semantic recognition method as described above.
[0007] To solve the above technical problems, the embodiment of the present application further provides a computer readable storage medium,
[0008] The computer readable storage medium stores a computer program, and the computer program can be executed by the processor to realize the steps of the semantic recognition method as described above. Advantages
[0009] According to the semantic recognition method, device, electronic device and storage medium provided by the embodiment of the present application, the first model loss of the intent recognition model and the second model loss of the slot value labeling model are used to jointly train the intent recognition model and the slot value labeling model to obtain a semantic joint recognition model, and the semantic joint recognition model is used to predict the query text, so that the association prediction output of the intent prediction result and the slot value prediction result of the query text can be directly realized. Since the intent recognition model and the slot value labeling model are jointly trained in the model training process, the models do not need to be trained separately, the model training process can be simplified, and the efficiency is improved. Moreover, the intent recognition model and the slot value labeling model with the association obtained by training can directly realize the association prediction output of the intent prediction result and the slot value prediction result of the query text, which can not only improve the recognition efficiency, but also improve the accuracy of recognition by using the association.
[0010] Further, the embodiment of the present application combines the fusion of the domain knowledge base and the global language knowledge base to train the model and perform subsequent recognition, which can further improve the accuracy of semantic recognition compared with the method of using only the global language knowledge base.
[0011] Other features and corresponding advantages of the present application are described in the latter part of the specification, and it should be understood that at least part of the advantages is obvious from the description of the present application in the specification. BRIEF DESCRIPTION OF DRAWINGS
[0012] Fig. 1 The flowchart of the semantic recognition model training method of the embodiment one of the present application is shown in the figure;
[0013] Fig. 2 The flowchart of the language information representation quantity extraction method of the embodiment one of the present application is shown in the figure;
[0014] Fig. 3 The flowchart of the domain information representation quantity extraction method of the embodiment one of the present application is shown in the figure;
[0015] Fig. 4A semantic recognition method flowchart of the embodiment one of the present application;
[0016] Fig. 5 A semantic joint recognition model system architecture diagram of the embodiment one of the present application;
[0017] Fig. 6 A semantic recognition model training device structure diagram of the embodiment two of the present application;
[0018] Fig. 7 A semantic recognition device structure diagram of the embodiment two of the present application;
[0019] Fig. 8 A model training flowchart of the embodiment two of the present application;
[0020] Fig. 9 A prediction flowchart of the embodiment two of the present application;
[0021] Fig. 10 An electronic device structure diagram of the embodiment three of the present application. DETAILED DESCRIPTION
[0022] In order to make the objectives, technical solutions and advantages of the present application clearer, further detailed description will be made to the embodiments of the present application in combination with the drawings. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application. Embodiment one:
[0023] In view of the problems that the model training process and the semantic recognition process are complicated, the performance and efficiency are low, and the recognition accuracy is also low, the embodiment jointly trains the intent recognition model and the slot value labeling model in the model training process, without the need of training each model separately, so as to simplify the model training process and improve the efficiency.
[0024] Meanwhile, in the semantic recognition, after obtaining the to-be-recognized query text, the semantic joint recognition model can be used to recognize the to-be-recognized query file, and output the intent recognition result and the slot value recognition result. The semantic joint recognition model includes: jointly training the intent recognition model and the slot value labeling model according to the first model loss of the intent recognition model and the second model loss of the slot value labeling model, and obtaining the intent recognition model and the slot value labeling model with correlation. That is, the embodiment can directly realize the associated prediction output of the query text intent prediction result and the slot value prediction result by using the intent recognition model and the slot value labeling model with correlation, which can not only improve the recognition efficiency, but also improve the recognition accuracy by using the correlation.
[0025] In addition, the embodiment combines the fusion of the domain knowledge base and the global language knowledge base to train the model and perform subsequent recognition, which can further improve the accuracy of semantic recognition compared with the method of using only the global language knowledge base.
[0026] For ease of understanding, the following describes the semantic recognition model training method shown in Fig. 1 Fig. 1 The method includes the following steps.
[0027] S101: Obtain query text for training.
[0028] It should be understood that the query text for training in the embodiment can be input by voice, text, gestures, etc., but is not limited thereto. It should be understood that the content included in the query text in the embodiment can be flexibly set according to specific application scenarios and other factors. The query text is the query information input by the user when the user needs to query.
[0029] S102: Extract language information representation of the query text, and obtain domain information representation of the query text by using a domain knowledge base. The domain knowledge base includes at least one word corresponding to a domain.
[0030] In this step, the language information representation refers to the representation obtained by processing the input query text by using a pre-trained model, which is used to represent the information of the query text. For example, the language information representation can include, but is not limited to, a context vector corresponding to the query text. The context vector can include, but is not limited to, at least one of a start position context vector c CLS、 of a start position of a character sequence of the query text, an end position context vector c SEP、 of an end position of the character sequence of the query text, and a character context vector c token of each character of the query text.
[0031] In one example of the embodiment, the language information representation of the query text can be extracted by, but is not limited to, a pre-trained model. For example, the language knowledge of the query text is extracted by a pre-trained model (for example, a deep pre-trained language model can be used, but is not limited thereto). The input of this stage is the query text, which is segmented by a certain granularity (for example, for Chinese characters, the granularity can be a word), and specific symbols, position information, and fragment information are added. Finally, an input vector is integrated, and the language information representation after conversion shown in the above can be obtained after the pre-trained model. The process of extracting the language information representation of the query text by using the pre-trained model in one example can be seen in Fig. 2 The method can include the following steps.
[0032] S201: convert the query text into a character sequence, and add a start label CLS and an end label SEP at the start and end positions of the character sequence, respectively.
[0033] S202: obtain the character vector, position vector, and segment vector of the character sequence.
[0034] S203: input the character vector, position vector, and segment vector into the pre-trained model, and obtain the context vector of each position through pre-trained model encoding output.
[0035] That is, after inputting the character string of the query text, first convert it into a character sequence, add labels CLS and SEP representing the start position and end position at the start and end positions of the character sequence, respectively, and give its position and segment information. The character vector, position vector, and segment vector are summed as the input vector of the pre-trained model. The input vector passes through the pre-trained model, and the corresponding character context vector C token is obtained for each character. CLS、 The end position context vector c SEP of the character sequence of the query text is obtained. CLS In an example, the output of each can be set as a fixed-dimensional context vector. Among them, the start position context vector c CLS、 is regarded as encoding the semantic information of the segment of the entire query text.
[0036] It should be understood that the specific type of voice model used in the pre-trained model in the embodiment can be flexibly selected according to the specific application scenario. For example, in an example, the pre-trained model can use, but is not limited to, a pre-trained Chinese BERT deep language model to extract features. The BERT deep language model can learn contextual embeddings based on large-scale language data.
[0037] For example, assume a given query text “I want to listen to a song name 1 by Zhou Someone”, as shown in Fig. 5 , the corresponding character vector, position vector, and segment vector are extracted through global language knowledge extraction. The obtained character vector, position vector, and segment vector are input into the deep pre-trained language model, and the start position context vector c CLS、 , the end position context vector c SEP、 , and the character context vector c token of each character are obtained through pre-trained model encoding output.
[0038] In this embodiment, the domain knowledge base can include, but is not limited to, the corresponding relationship between the domain terms and types. The domain terms included in the domain knowledge base are preset in the word segmentation dictionary, so as to perform word segmentation processing on the query text. The word segmentation dictionary in this embodiment includes each term used to indicate the word segmentation processing on the query text, and the query text is processed by word segmentation in units of terms in the word segmentation dictionary.
[0039] For example, the corresponding relationship in an example of the domain knowledge base is shown in Table 1:
[0040] Table 1
[0041] Domain Term Type Qingshanquan Town, Ciqikou,... geo Reader Name 1, Reader Name 2,... appname Zhou Moumou, Liu Moumou,... artist Song Name 1, Song Name 1,... song
[0042] In this step, the domain information representation quantity is extracted based on the domain knowledge base. This stage mainly includes collecting the domain knowledge base to form a knowledge dictionary, then performing correct word segmentation on the query text, annotating the entity information of each part based on the word segmentation result, and finally performing numerical mapping of knowledge, that is, representing by vectorization.
[0043] For example, in an example, different domain proper name information can be crawled from websites of categories such as music, video, entertainment, administrative division, and application store by a network crawler, cleaned, and excluding single-word and double-word terms with greater ambiguity (such as “I”, “I want” and the like), and adding them to the domain knowledge base and filling in related information. It should be understood that the specific number of “types” in the above table 1 can be flexibly set according to specific application scenarios, and the set number can support dynamic increase and decrease.
[0044] In this embodiment, the terms in the domain knowledge base are added to the word segmentation dictionary to ensure that the automatic word segmentation tool can cut the query text into individual terms according to the word segmentation dictionary. For example, given a query text such as “I want to listen to a song name 1 by Zhou Someone”, the word segmentation tool using the integrated dictionary is used to cut it to obtain “I / want / to / listen / to / a / song name 1 / by / Zhou Someone”.
[0045] For ease of understanding, the process of obtaining the domain information representation quantity of the query text using the domain knowledge base will be described below with reference to the process shown in FIG. 3. Fig. 3 The process includes the following steps:
[0046] S301: performing word segmentation processing on the query text using the word segmentation dictionary.
[0047] Continuing the above example, for example, for the query text used for training “I want to listen to a song name 1 by Zhou Someone”, the word segmentation tool using the integrated dictionary is used to cut it to obtain:
[0048] I / want / to / listen / to / a / song name 1 / by / Zhou Someone.
[0049] S302: Determine the target type corresponding to each domain term included in the query text by using the domain knowledge base; and determine the target domain corresponding to the query text according to the received domain configuration instruction.
[0050] In this step, that is, for the word segmentation result of the query text, each term is matched with the above-mentioned domain knowledge base, and then the type information to which each character of the query text belongs is obtained. In addition, for the entire query text, the target domain corresponding to the query text can be labeled according to the received domain configuration instruction in the training process.
[0051] For example, for the query text of the above example, assuming that the domain included in the received domain configuration instruction is multimedia, then according to the received domain configuration instruction, the target domain corresponding to the query text is determined to be multimedia, and the matching result of the query text is as follows:
[0052] I (none) want (none) to (none) listen (none) to (none) a (none) song (song) by (none) Zhou (artist) ||| multimedia;
[0053] That is, Zhou and song name 1 belong to domain terms, and the corresponding target types are artist and song, respectively, and the target domain to which this query text belongs is multimedia.
[0054] In some examples of the embodiment, in order to ensure the accuracy and efficiency of identification, it can be set that the type to which each character in each query text belongs does not exceed K, and each character is only allowed to match one type; the domain to which a query text belongs does not exceed L. The specific values of K and L can be flexibly set according to specific needs.
[0055] S303: Extract the target domain vector q corresponding to the target domain, and obtain the target type vector t corresponding to each character of each query text (where 0 corresponds to a character that is not matched) token .
[0056] For example, the above word segmentation result can be converted so that each character corresponds to a domain knowledge (type), where B represents the beginning of an entity (i.e., a term), M represents the middle of an entity, E represents the end of an entity, and O represents a non-matching:
[0057] I want to listen to a song by artist B, artist M, artist E, song B, song M, song E 1;
[0058] Vectorizing the query text and the domain knowledge of characters: ①The domain information of the query text can be represented as an N-dimensional one-hot vector q, N being the number of domains. If the query involves multiple sub-domains (not more than L), the sub-domains are concatenated, and if there are less than L sub-domains, a 0 vector is added. token ②Similarly, the domain knowledge of characters can also be represented as an M-dimensional one-hot vector t, M being the number of domain knowledge (i.e., type) labels. For example, if the number of types is X, then M=X*K, and if there are less than X types, a 0 vector is added.
[0059] S103: Fuse the language information representation and the domain information representation to obtain a first input vector I of the intent recognition model and a second input vector s of the slot value labeling model. CLS token .
[0060] In this step, the language information representation and the domain information representation extracted in the above process are fused. The first input vector I of the intent recognition model obtained from the language information representation and the domain information representation includes: CLS
[0061] Fuse the start position context vector c CLS and the target domain vector q to obtain the first input vector I CLS . The fusion method in this embodiment includes but is not limited to adding the start position context vector c CLS and the target domain vector q or taking the inner product of the two.
[0062] For example, one representation of I CLS is:
[0063] I CLS = concat(c CLS , qW+b);
[0064] wherein the target domain vector q can be first transformed into a vector with the same dimension as c CLS by a fully connected neural network, and then fused with the start position context vector c CLS , W matrix and b vector being parameters learned in model training. It should be understood that in this embodiment, the target domain vector q is transformed into a vector with the same dimension as c CLS The conversion mode of the same dimension can be flexibly set. For example, the target field vector q can be converted into the same dimension as the character context vector c by, but not limited to, a fully connected neural network. CLS The connected neural network here can be, but is not limited to, one layer of connected neural network.
[0065] Similarly, the second input vector s of the slot value labeling model is obtained according to the language information representation quantity and the field information representation quantity. token The second input vector s includes:
[0066] The target type vector t corresponding to each character of the query text is converted into the same dimension as the character context vector c of each character of the query text. token The target type vector t is converted into the same dimension as the character context vector c. token The target type vector t is converted into the same dimension as the character context vector c. token The second input vector s is obtained by fusing the target type vector t and the character context vector c. token The fusion mode here includes, but is not limited to, adding the target type vector t and the character context vector c, or calculating the inner product of the two. token The fusion mode here includes, but is not limited to, adding the target type vector t and the character context vector c, or calculating the inner product of the two. token The fusion mode here includes, but is not limited to, adding the target type vector t and the character context vector c, or calculating the inner product of the two.
[0067] It should be understood that the conversion mode of the target type vector t into the same dimension as the character context vector c can also be flexibly set. For example, the target type vector t can also be converted into the same dimension as the character context vector c by, but not limited to, a fully connected neural network. token The target type vector t is converted into the same dimension as the character context vector c. token The conversion mode of the same dimension can be flexibly set. For example, the target type vector t can be converted into the same dimension as the character context vector c by, but not limited to, a fully connected neural network. token The target type vector t is converted into the same dimension as the character context vector c. token The connected neural network here can be, but is not limited to, one layer of connected neural network.
[0068] S104: According to the first model loss of the intent recognition model and the second model loss of the slot value labeling model, and the first input vector I and the second input vector s, the intent recognition model and the slot value labeling model are jointly trained to obtain a semantic joint recognition model. CLS The fusion mode here includes, but is not limited to, adding the target type vector t and the character context vector c, or calculating the inner product of the two. token The fusion mode here includes, but is not limited to, adding the target type vector t and the character context vector c, or calculating the inner product of the two.
[0069] In this step, the intent recognition is analyzed as a task, which is in the form of a neural network here, not generally, for example, a feedforward neural network and a softmax layer can be used, but not limited to, learning, while the task of slot value information extraction is analyzed by another model, not generally, for example, a CRF model is used to learn the labels of each entity. In the training stage, the loss function uses the combination of the two as the overall loss, and according to the specific convergence condition, the joint iterative learning is performed, so as to finally obtain the joint model.
[0070] For example, in one example of the embodiment, according to a first model loss of the intent recognition model and a second model loss of the slot value labeling model, and the first input vector I CLS and the second input vector s token , the intent recognition model and the slot value labeling model are jointly trained to obtain a semantic joint recognition model, which includes:
[0071] The first input vector I CLS corresponding intent is learned, and the second input vector s token corresponding entity label is learned by using a preset learning model.
[0072] In the process of learning the first input vector I CLS corresponding intent by using a classification function, and learning the second input vector s token corresponding entity label by using a preset learning model, according to the change of the first model loss li of the intent recognition model and the second model loss ls of the slot value labeling model, the model parameters of the intent recognition model and the slot value labeling model are adjusted until the adjusted first model loss li of the intent recognition model and the adjusted second model loss ls of the slot value labeling model reach a set model loss balance condition. It should be understood that the model parameters adjusted in the embodiment include but are not limited to at least one of various parameters in the intent recognition model and the slot value labeling model that can affect the first model loss li and the second model loss ls.
[0073] The classification function in the embodiment can use but is not limited to a softmax function, a sigmoid function; for example, after obtaining the first input vector I CLS , a fully connected neural network and a softmax function can be used to learn the intent. In the embodiment, the preset learning model can be but is not limited to a conditional random field model (CRF model), a hidden Markov model (HMM model), and a maximum entropy Markov model (MEMM model); for example, after obtaining the second input vector s token , a CRF model can be used to learn the entity label corresponding to each character; for details of the training process, please refer to the description in Fig. 5 .
[0074] In the embodiment, the training of the two tasks of intent recognition and slot value information extraction adopts a self-adaptive optimization method for joint learning. In the training process, the model loss of the intent recognition model and the slot value labeling model is used to update the parameters of the intent recognition model and the slot value labeling model, and the parameters of the entire deep pre-training language model are fine-tuned. Considering that slot value extraction is highly dependent on intent recognition, and the result of slot value extraction also has an impact on intent recognition, the model loss balancing condition set in one example of the embodiment is as follows:
[0075] l = l i + 1 / l i * l s ;
[0076] wherein, l is the total model loss of the intent recognition model and the slot value labeling model, and the value can be flexibly set according to the specific application scenario; li is the first model loss of the intent classification model, and ls is the second model loss of the slot value labeling model. When the first model loss li of the intent recognition model is large, the parameters will be mainly updated according to the first model loss li, which is equivalent to mainly learning the relatively easy intent information in the initial stage; when the first model loss li of the intent recognition model gradually decreases, the influence of the second model loss ls of the slot value labeling model on the model parameters will gradually increase, which means that when the intent information is learned sufficiently, more attention will be paid to learning slot value extraction; during the training process, if the intent recognition effect becomes poor, the first model loss li of the intent recognition model can be automatically associated and adjusted according to the above rules. After repeated adjustment, the first model loss li of the adjusted intent recognition model and the second model loss ls of the adjusted slot value labeling model reach the set model loss balancing condition.
[0077] It should be understood that the embodiment is not limited to using the above Chinese BERT deep language model, the fully connected neural network, the one-layer fully connected neural network followed by a softmax function, and the CRF model. Various results can achieve the analysis method of joint training and prediction in the embodiment, which is within the scope of the present application.
[0078] After obtaining the semantic joint recognition model based on the training process of the above example, the semantic recognition can be performed by using the semantic joint recognition model. One semantic recognition method is shown in FIG. 4 and includes the following steps. Fig. 4
[0079] S401: Obtain the query text to be recognized.
[0080] S402: Perform recognition on the query file to be recognized by using the semantic joint recognition model obtained by the semantic recognition model training method loaded by the system, and output the intent recognition result and the slot value recognition result.
[0081] The method provided by the embodiment realizes joint semantic parsing by fusing global language knowledge and domain knowledge, and is realized through the four stages of global language knowledge extraction, domain knowledge extraction, joint learning based on knowledge fusion, and joint prediction. The fusion of global language knowledge and domain knowledge can extract more and richer deep language representations, and joint learning and prediction can jointly learn and predict intent information and slot value (i.e., key entity) information at one time. Meanwhile, the intent information and the key entity information can complement each other. It can be seen that the method provided by the embodiment integrates the pre-training language model and the domain knowledge base, so that the model can not only learn intent and slot value information from training data, but also can be guided by global language knowledge and domain knowledge at the same time. In the training process, the language model can also be iteratively updated according to the training data and supplemented with domain knowledge, so as to continuously evolve and further provide support for multi-turn dialogue analysis and understanding. Through the joint learning and adaptive optimization method, the technology can capture the relevance and dependency between tasks, and improve the efficiency and accuracy of query semantic understanding. Embodiment two:
[0082] The method provided by the above embodiment can be applied to servers, general PC machines, and even various electronic devices such as embedded mobile devices. The device can have hardware devices such as a central processing unit (CPU), memory, and even a graphics processing unit (GPU) (optional), and needs power supply. The method provided by the above embodiment can also be applied to operating system software (Linux, Windows, etc.), and can be implemented by related algorithm codes integrated with a deep learning platform (such as TensorFlow, Pytorch, etc.), a machine learning software library (such as sk-learn, etc.), or a software integrated development environment based on a related computer language.
[0083] The embodiment provides a semantic recognition model training device, which can be arranged in an electronic device. As shown in Fig. 6 , the device comprises:
[0084] An information extraction module 601 is configured to extract language information representation of a query text for training, and obtain domain information representation of the query text by using a domain knowledge base. The domain knowledge base includes at least one word corresponding to a domain. For details of the extraction process, please refer to the above embodiment, which will not be described here.
[0085] A model training module 602 is configured to fuse the language information representation and the domain information representation to obtain a first input vector I CLS of an intent recognition model and a second input vector s token of a slot value labeling model, respectively, and perform joint training on the first input vector I CLS of the intent recognition model and the second input vector stoken The semantic joint recognition model is obtained by jointly training the intent recognition model and the slot value labeling model. For details of the training process, please refer to the embodiments described above, which will not be repeated here.
[0086] The embodiment also provides a semantic recognition device, which can be arranged in an electronic device. The electronic device can be the same device as the electronic device where the semantic recognition model training device is arranged, or can be a different device. Please refer to FIG. 8, which shows the semantic recognition device, and the semantic recognition device includes: Fig. 7
[0087] The text acquisition module 701 is configured to acquire the query text to be recognized. For details of the acquisition process, please refer to the embodiments described above, which will not be repeated here.
[0088] The semantic recognition module 702 is configured to recognize the query file to be recognized by using the semantic joint recognition model obtained by the semantic recognition model training method, and output the intent recognition result and the slot value recognition result. For details of the recognition process, please refer to the embodiments described above, which will not be repeated here.
[0089] It is understood that the functions of at least one of the modules described above can be implemented by, but not limited to, the processor of the electronic device where the module is arranged. For details of the training process performed by the semantic recognition model training device, please refer to FIG. 7, and the training process can include, but is not limited to: Fig. 8
[0090] S801: Acquire the query text original data for training. The specific acquisition method can use, but is not limited to, the method exemplified in the embodiments described above.
[0091] S802: Extract the domain knowledge and the global language knowledge from the acquired query text original data, respectively. The specific extraction process can use, but is not limited to, the extraction method exemplified in the embodiments described above.
[0092] S803: Label the extracted domain knowledge and the extracted global language knowledge, respectively. The specific labeling method can use, but is not limited to, the labeling method exemplified in the embodiments described above.
[0093] S804: Perform vector representation of the domain knowledge and the global language knowledge according to the labeling results, respectively. The specific vector representation method can use, but is not limited to, the method exemplified in the embodiments described above.
[0094] S805: Convert the vector representation of the domain knowledge and the vector representation of the global language knowledge, respectively. The specific conversion method can use, but is not limited to, the method exemplified in the embodiments described above. Fig. 5 S805: Convert the vector representation of the domain knowledge and the vector representation of the global language knowledge, respectively. The specific conversion method can use, but is not limited to, the method exemplified in the embodiments described above.
[0095] S806: The vector representations of domain knowledge and global language knowledge are fused separately to obtain the first input vector I of the intent recognition model. CLS The second input vector s of the slot labeling model token;
[0096] S807: Jointly train the intent recognition model and the slot labeling model based on the first model loss of the intent recognition model and the second model loss of the slot labeling model;
[0097] S808: Outputs the resulting relevance-based intent recognition model and slot labeling model.
[0098] For the prediction (i.e., recognition) process performed by the semantic recognition device, please refer to [link to documentation]. Fig. 9 As shown, it may include, but is not limited to:
[0099] S901: Obtain the original data of the query text to be identified. The specific acquisition method may be, but is not limited to, the methods exemplified in the above embodiments.
[0100] S902: Perform data preprocessing on the acquired query text raw data.
[0101] S903: Vectorize the preprocessed data.
[0102] S904: Input semantic joint recognition model.
[0103] S905: Outputs intent recognition results and slot value recognition results.
[0104] Among them, Fig. 8 and Fig. 9 The two processes shown differ in their data preprocessing methods. Fig. 8 The training phase shown requires, on the domain knowledge-based side, firstly, word segmentation of the raw data. During segmentation, the use of a knowledge dictionary must be considered to ensure accurate entity segmentation. Then, annotation is performed based on the segmented knowledge entities or non-entity data. For Chinese, annotation is done on a character-by-character basis. For global language knowledge, for Chinese, it is often done on a character-by-character basis, adding specific symbols and then performing vector transformation. Correspondingly, in... Fig. 9 In the prediction flow shown, this preprocessing process can be combined into one; that is, it only requires segmenting them into characters and then vectorizing them separately. Additionally, in Fig. 9In the illustrated prediction process, when determining the target domain to which the query text belongs in the data preprocessing process, a pre-established query text domain prediction model can be used, but is not limited thereto. The query text is input into the query text domain prediction model. The predicted domain output by the query text domain prediction model for the query text is taken as the target domain to which the query text belongs. Embodiment Three
[0105] The embodiment also provides an electronic device, which can be a server and various terminals, as described above. Referring to FIG. 10, the electronic device includes a processor 1001, a memory 1002, and a communication bus 1003. Fig. 10 As shown in the figure, the electronic device includes a processor 1001, a memory 1002, and a communication bus 1003.
[0106] The communication bus 1003 is used to realize the communication connection between the processor 1001 and the memory 1002.
[0107] In an example, the processor 1001 can be used to execute the computer program stored in the memory 1002 to realize the steps of the semantic recognition method in the above embodiments.
[0108] The embodiment also provides a computer readable storage medium, which includes a volatile or non-volatile, removable or non-removable medium implemented in any method or technology for storing information, such as computer readable instructions, data structures, computer program modules or other data. The computer readable storage medium includes but is not limited to RAM (Random Access Memory, Random Access Memory), ROM (Read-Only Memory, Read-Only Memory), EEPROM (Electrically Erasable Programmable read only memory, Electrically Erasable Programmable Read-Only Memory), flash memory or other memory technology, CD-ROM (Compact Disc Read-Only Memory, Compact Disc Read-Only Memory), digital versatile disc (DVD) or other optical disc storage, magnetic cassette, magnetic tape, magnetic disk storage or other magnetic storage device, or any other medium that can be used to store desired information and can be accessed by a computer.
[0109] In an example, the computer readable storage medium in the embodiment can be used to store a computer program that can be executed by a processor to realize the steps of the semantic recognition method in the above embodiments.
[0110] The embodiments also provide a computer program (or computer software) that can be distributed on a computer readable medium for execution by a computing device to implement at least one step of the semantic recognition method of any of the above embodiments; and in some cases, at least one step shown or described can be performed in an order different from that described in the above embodiments.
[0111] The embodiments also provide a computer program product comprising a computer readable device on which is stored any of the computer programs shown above. The computer readable device in the embodiments can comprise a computer readable storage medium as shown above.
[0112] It will be appreciated by persons skilled in the art that all or some of the steps of the methods disclosed above, the functions of the modules / units in the systems and devices can be embodied as software (which can be implemented by computer program codes executable by a computing device), firmware, microcode, hardware, or any suitable combination thereof. In hardware implementation, the division of the functions between the modules / units referred in the above description does not necessarily correspond to the division made between physical components; for example, one physical component can serve multiple functions, or one function or step can be performed by several physical components working in cooperation. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit.
[0113] In addition, it is well known to those of ordinary skill in the art that communications media typically include computer readable instructions, data structures, computer program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. Accordingly, the present application is not limited to any particular hardware and software combination.
[0114] The above further describes the embodiments of the present application in detail in conjunction with specific embodiments, and cannot be deemed to limit the specific implementation of the present application to these descriptions. For those of ordinary skill in the art, some simple derivations or replacements can be made without departing from the concept of the present application, and all of these should be deemed to fall within the protection scope of the present application.
Claims
1. A method of semantic recognition, characterized in that, The method comprises the following steps: acquiring a query text to be recognized; performing recognition on the query text to be recognized by using a semantic joint recognition model, and outputting an intent recognition result and a slot value recognition result; the semantic joint recognition model comprises an intent recognition model and a slot value labeling model which are jointly trained according to a first model loss of the intent recognition model and a second model loss of the slot value labeling model, and the intent recognition model and the slot value labeling model have correlation; The joint training of the intent recognition model and the slot value labeling model comprises: acquiring query text for training; extracting language information representation of the query text, and acquiring domain information representation of the query text by using a domain knowledge base, the domain knowledge base comprising at least one domain corresponding to a term; fusing the language information representation and the domain information representation to obtain a first input vector I CLS of the intent recognition model and a second input vector s token of the slot value labeling model respectively; and performing joint training of the intent recognition model and the slot value labeling model according to a first model loss of the intent recognition model and a second model loss of the slot value labeling model, and the first input vector I CLS and the second input vector s token . wherein the language information representation quantity comprises a context vector of the query text, the domain knowledge base comprises a domain term and type corresponding relationship, and the domain term is pre-set in a word segmentation dictionary; The acquiring the domain information representation quantity of the query text by using the domain knowledge base comprises: performing word segmentation processing on the query text by using the word segmentation dictionary; determining target types corresponding to each domain term included in the query text by using the domain knowledge base; and determining a target domain corresponding to the query text according to a received domain configuration instruction; extracting a target domain vector q corresponding to the target domain; and acquiring a target type vector t corresponding to each character of the query text token ; The context vector of the query text comprises: a start position context vector c of a start position of a character sequence of the query text CLS ; The first input vector I of the obtained intention recognition model CLS comprising: fusing the start position context vector c CLS with the target domain vector q to obtain a first input vector I CLS .
2. The semantic recognition method of claim 1, wherein, The context vector of the query text comprises: a character context vector c of each character of the query text token ; According to the language information representation quantity and the field information representation quantity, a second input vector s of a slot value labeling model is obtained token Comprising: The target type vector t corresponding to each character of each query text is obtained token The character context vector c corresponding to each character of each query text is obtained token The second input vector s is obtained by fusing the target type vector t and the character context vector c token .
3. The semantic recognition method of claim 2, wherein, The first model loss according to the intent recognition model and the second model loss of the slot value labeling model, and the first input vector I CLS and the second input vector s token The intent recognition model and the slot value labeling model are jointly trained, comprising: adopting a classification function on the first input vector I CLS learning a corresponding intent, and adopting a preset learning model on the second input vector s token learning a corresponding entity label; In the adopting the classification function to the first input vector I CLS corresponding intent learning, and using a preset learning model to the second input vector s token In the corresponding entity label learning process, according to the change of the first model loss of the intent recognition model and the second model loss of the slot value labeling model, the model parameters of the intent recognition model and the slot value labeling model are adjusted until the first model loss of the adjusted intent recognition model and the second model loss of the adjusted slot value labeling model reach the set model loss balance condition.
4. A semantic recognition apparatus characterized by comprising: The method comprises the following steps: a text acquisition module is configured to acquire a query text to be recognized; a semantic recognition module is configured to perform recognition on the query text to be recognized by using a semantic joint recognition model, and output an intent recognition result and a slot value recognition result; The semantic joint recognition model comprises: an intent recognition model and a slot value labeling model obtained by jointly training the intent recognition model and the slot value labeling model according to a first model loss of the intent recognition model and a second model loss of the slot value labeling model; wherein the jointly training the intent recognition model and the slot value labeling model comprises: obtaining query text for training; extracting language information representation of the query text, and obtaining domain information representation of the query text by using a domain knowledge base, wherein the domain knowledge base comprises at least one domain corresponding to a term; fusing the language information representation and the domain information representation to obtain a first input vector I CLS of the intent recognition model and a second input vector s token of the slot value labeling model; and jointly training the intent recognition model and the slot value labeling model according to the first model loss of the intent recognition model and the second model loss of the slot value labeling model, and the first input vector I CLS and the second input vector s token ; wherein the language information representation comprises a context vector of the query text, the domain knowledge base comprises a domain term and type corresponding relationship, the domain term is pre-set in a word segmentation dictionary, the obtaining the domain information representation of the query text by using the domain knowledge base comprises: performing word segmentation processing on the query text by using the word segmentation dictionary; determining a target type corresponding to each domain term included in the query text by using the domain knowledge base; and determining a target domain corresponding to the query text according to a received domain configuration instruction; extracting a target domain vector q corresponding to the target domain, and obtaining a target type vector t token corresponding to each character of the query text; the context vector of the query text comprises a start position context vector c CLS of a start position of a character sequence of the query text; and the first input vector I CLS of the intent recognition model comprises: fusing the start position context vector c CLS and the target domain vector q to obtain the first input vector I CLS .
5. An electronic device, comprising: a processor and a memory are comprised; the memory is configured to store a computer program, and the processor is configured to execute the computer program stored in the memory to implement the steps of the semantic recognition method according to any one of claims 1-3.
6. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program can be executed by the processor to implement the steps of the semantic recognition method according to any one of claims 1-3.
Citation Information
Patent Citations
Artificial intelligence-based spoken language query analysis method and apparatus, and storage medium
CN107291828A