Slot identification method, device, electronic device and readable storage medium
By combining a parser and a named entity recognition model to perform slot recognition on voice commands, the problem of low slot recognition accuracy in the existing technology is solved, achieving higher recognition accuracy and simplification of configuration.
Patent Information
- Application Number
- CN202111287097.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-02
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2041-11-02
AI Technical Summary
Existing slot recognition technology has low accuracy and cannot completely exhaust the sentence templates, resulting in the inability to accurately recognize the voice commands actually issued by the user.
A combination of a parser and a named entity recognition (NER) model is used to identify slots for voice commands, and enumerable and non-enumerable slots are identified through recursive configuration and deep learning models.
It improves the accuracy of slot recognition, simplifies the configuration of slot recognition, and can maximize the recognition of slot information in voice commands.
Smart Images

Figure CN114023319B
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of artificial intelligence technology, and in particular, to a slot identification method, device, electronic device, and readable storage medium. Background Art
[0002] At present, when performing slot recognition, a pre-set sentence template is usually used to match the voice command issued by the user. When the voice command is successfully matched with the sentence template, the slot can be identified through the sentence template and the voice command. However, since the sentence structure of the voice command actually issued by the user is open, it is impossible to accurately predict what sentence structure the user will use to issue the voice command. Therefore, a lot of manpower is required to write sentence templates for various possible situations, and it is impossible to completely and exhaustively list the sentence templates, resulting in a low accuracy rate of slot recognition. Summary of the invention
[0003] The embodiments of the present disclosure provide a slot identification method, device, electronic device and readable storage medium to solve the problem of low accuracy of existing slot identification.
[0004] To solve the above problems, the present disclosure is implemented as follows:
[0005] In a first aspect, an embodiment of the present disclosure provides a slot identification method, the method comprising:
[0006] receiving a first voice command;
[0007] Using a parser and a named entity recognition (NER) model to perform slot recognition on the first voice instruction respectively, and obtaining a first slot recognition result corresponding to the parser and a second slot recognition result corresponding to the NER model;
[0008] The slot of the first voice instruction is determined according to the first slot recognition result and the second slot recognition result.
[0009] In a second aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:
[0010] A receiving module, used for receiving a first voice command;
[0011] A recognition module, configured to perform slot recognition on the first voice instruction using a parser and a named entity recognition (NER) model, respectively, to obtain a first slot recognition result corresponding to the parser and a second slot recognition result corresponding to the NER model;
[0012] A determination module is used to determine the slot of the first voice instruction according to the first slot recognition result and the second slot recognition result.
[0013] In a third aspect, an embodiment of the present disclosure further provides an electronic device, which includes a processor, a memory, and a program stored in the memory and executable on the processor, wherein the program implements the steps of the slot identification method as described above when executed by the processor.
[0014] In a fourth aspect, an embodiment of the present disclosure further provides a readable storage medium having a program stored thereon, and when the program is executed by a processor, the steps of the slot identification method applied to an electronic device as described above are implemented.
[0015] In the embodiment of the present disclosure, the slot of the voice command is identified by combining the parser and the NER model, thereby improving the accuracy of slot identification. In addition, since the parser supports recursive configuration, the embodiment of the present disclosure can also simplify the configuration of enumerable slot identification.
[0016] It is to be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 is a flow chart showing a slot identification method according to an exemplary embodiment;
[0018] Figure 2 is a structural diagram of a slot identification device according to an exemplary embodiment;
[0019] Figure 3 is a structural diagram of an electronic device according to an exemplary embodiment.
[0020] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure. DETAILED DESCRIPTION
[0021] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0022] The terms "first", "second", etc. in this application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0023] The slot identification method according to the embodiment of the present disclosure is described below.
[0024] See also Figure 1 , Figure 1 1 is a flow chart of a slot identification method according to an exemplary embodiment. The slot identification method of the disclosed embodiment is applied to an electronic device. In practical applications, the electronic device may be a mobile phone, a computer, a television, a wearable device, or a vehicle-mounted device.
[0025] like Figure 1 As shown, the slot identification method may include the following steps:
[0026] In step 101, a first voice instruction is received.
[0027] The first voice instruction may be understood as any voice instruction received by the electronic device.
[0028] In step 102, a parser and a named entity recognition (NER) model are used to perform slot recognition on the first voice instruction respectively, so as to obtain a first slot recognition result corresponding to the parser and a second slot recognition result corresponding to the NER model.
[0029] In the disclosed embodiment, after receiving a voice command, the electronic device can use a parser and a named entity recognition (NER) model to perform slot recognition on the voice command, that is, perform a slot recognition operation. In specific implementation, the two slot recognition operations can be performed simultaneously or successively. The disclosed embodiment does not limit the execution time of the two slot recognition operations, which can be determined according to actual needs.
[0030] In addition, before the electronic device performs the slot recognition operation on the voice command, it can first convert the voice command into text, and then perform the operation recognition on the text. Of course, the electronic device can also directly perform slot recognition on the voice, which can be determined according to the actual situation, and the embodiments of the present disclosure do not limit this.
[0031] The working principles of the parser and NER model are explained below.
[0032] 1. Parser.
[0033] The parser corresponds to the context-free grammar and can be represented and analyzed using a recursive transition network. The biggest difference between a recursive transition network and a finite state machine is that the edges connecting nodes in a finite state machine must be terminal symbols, while the edges connecting nodes in a recursive transition network can be networks.
[0034] Similar to regular expressions, recursive transfer networks require grammar rules to be written first, and voice instructions are passed to the grammar rules for recognition during recognition, and the corresponding results are returned according to the configuration rules. Unlike regular expressions, recursive transfer networks support recursive configuration during the configuration process, that is, networks can be nested in each other, similar to static functions when writing code, and all modules can be shared, reducing the complexity and workload of rule configuration.
[0035] The parser can also return specific mapping results according to different requirements, that is, it can not only return the words in the voice command, but also map the words and return the corresponding mapping results. In addition, the parser can also sort by different priorities according to the length or number of the recognized slots and return different results.
[0036] In terms of rule and keyword configuration, the parser has stronger performance and a lower and more convenient configuration method, which can significantly reduce the manual configuration cost while ensuring recognition accuracy.
[0037] 2. NER model.
[0038] NER models can be specifically expressed as various deep learning models such as Long Short-Term Memory (LSTM)-Conditional Random Field (CRF), Bi-directional LSTM (BiLSTM)-CRF, or Bidirectional Encoder Representation from Transformers (BERT)-BiLSTM-CRF. Their main purpose is to train to recognize entities in sentences, such as names, locations, organizations, and time. The recognized entities can be used in various downstream applications or as features of machine learning systems for other natural language processing tasks.
[0039] The NER model can label each word according to the training results, such as B, M, E, I, O, etc., where B represents the first word of the entity, M represents the middle word of the entity, E represents the last word of the entity, I represents a single-word entity, and O represents a non-entity word. The NER model can also add entity category information to the entity and can identify entities of different categories. The characteristic of the NER model in identifying slots is that it can identify non-enumerable slots, such as names, addresses, etc. It does not require manual writing of rules, and only needs to be trained through labeled data.
[0040] In this way, by combining the Parser and NER models to identify slots, it is possible to accurately identify enumerable slots and non-enumerable slots, and to maximize the recognition of slots in voice commands.
[0041] In step 103, the slot of the first voice instruction is determined according to the first slot recognition result and the second slot recognition result.
[0042] During implementation, in the first embodiment, the electronic device can choose to use the first slot recognition result or the second slot recognition result to determine the slot of the first voice instruction based on the slot type of each slot in the first slot recognition result and the second slot recognition result.
[0043] In the second implementation, the electronic device may select and use the first slot recognition result and / or the second slot recognition result according to a certain rule to determine the slot of the first voice instruction.
[0044] In a third implementation, the electronic device may determine the slot of the first voice instruction by using the first slot recognition result and the second slot recognition result with the aid of a classification model.
[0045] The above implementation is only an example and does not limit the implementation of step 103. Any implementation that uses a combination of parser and NER model to perform slot identification can fall within the protection scope of the present disclosure.
[0046] In the embodiment of the present disclosure, the slot of the first voice instruction can be a slot in the first slot recognition result, or a slot in the second slot recognition result, or a union or collection of a slot in the first slot recognition result and a slot in the second slot recognition result. The specific setting can be determined according to actual conditions, and the embodiment of the present disclosure is not limited to this.
[0047] The slot recognition method of the embodiment of the present disclosure uses a combination of parser and NER model to recognize the slot of the voice command, thereby improving the accuracy of slot recognition. In addition, since the parser supports recursive configuration, the embodiment of the present disclosure can also simplify the configuration of enumerable slot recognition.
[0048] The specific implementation of step 103 is described below.
[0049] For the first implementation, it can be seen from the above content that the parser is more suitable for the recognition of enumerable slots such as countries and cities, and the NER model is more suitable for the recognition of non-enumerable slots such as names and place names. Therefore, in this implementation, the number of slot types in the voice command can be used to determine whether to select the slot recognition result corresponding to the parser or the slot recognition result corresponding to the NER model as the final slot recognition result of the first voice command.
[0050] In an implementation manner, optionally, determining the slot of the first voice instruction according to the first slot recognition result and the second slot recognition result includes:
[0051] Determine a slot type of each slot in the first slot identification result and the second slot identification result, where the slot type includes an enumerable slot and a non-enumerable slot;
[0052] The slot of the first voice command is determined according to the number of slots of each slot type in the first slot identification result and the second slot identification result.
[0053] In a specific implementation, in one implementation, optionally, determining the slot of the first voice command according to the number of slots of each slot type in the first slot recognition result and the second slot recognition result includes:
[0054] When the number of slots that can be enumerated in the first slot identification result and the second slot identification result is greater than a first threshold, determining the slot in the first slot identification result as the slot of the first voice instruction;
[0055] When the number of enumerable slots in the first slot recognition result and the second slot recognition result is less than or equal to the first threshold, the slot in the second slot recognition result is determined as the slot of the first voice instruction.
[0056] In this optional implementation, the electronic device can set a threshold value corresponding to the enumerable slots, that is, a first threshold value, and the first threshold value is a benchmark for determining whether the enumerable slots are more or less. In this way, the electronic device can determine whether to select the slot recognition result corresponding to the parser or the slot recognition result corresponding to the NER model as the final slot recognition result of the first voice instruction based on the comparison result of the first slot recognition result and the number of slots of the enumerable slots in the second slot recognition result and the first threshold value, thereby improving the accuracy of slot recognition.
[0057] If the first number is greater than the first threshold, it means that the number of enumerable slots in the first slot recognition result and the second slot recognition result is large, and the slot recognition result of the parser can be used as the final slot recognition result of the first voice command.
[0058] If the first number is less than or equal to the first threshold, it means that the number of enumerable slots in the first slot recognition result and the second slot recognition result is small, and the slot recognition result of the NER model can be used as the final slot recognition result of the first voice instruction.
[0059] In practical applications, the first threshold can be set according to actual needs, and the embodiments of the present disclosure do not limit this.
[0060] In another implementation, the electronic device may directly compare the number of enumerable slots and non-enumerable slots in the first slot recognition result and the second slot recognition result. If the number of enumerable slots is greater than the number of non-enumerable slots, the slot recognition result of the parser may be used as the final slot recognition result of the first voice instruction; if the number of enumerable slots is less than the number of non-enumerable slots, the slot recognition result of the NER model may be used as the final slot recognition result of the first voice instruction.
[0061] Through the above manner, the slot of the voice instruction can be determined based on the comparison result of the number of enumerable slots in the voice instruction and the first threshold, thereby improving the accuracy of slot determination.
[0062] For the second implementation manner, the electronic device may determine the slot of the first voice instruction based on any of the following rules in combination with the first slot recognition result and the second slot recognition result:
[0063] Rule 1: The longer slot length of the two slots obtained by respectively performing slot recognition on the same word using the parser and the NER model is determined as the slot of the word;
[0064] Rule 2: Determine the slot of the voice command based on the number of slots in two slot recognition results obtained by respectively performing slot recognition on the same voice command using the parser and the NER model;
[0065] Rule 3: When there are identical characters in two slot recognition results obtained by respectively performing slot recognition on the same voice command using the parser and the NER model, the two slot recognition results are merged to obtain the slot of the voice command.
[0066] In Rule 1, the electronic device considers the entire sentence, focuses on the slot recognition results of the words in the voice command, and determines the slot of the voice command; in Rules 2 and 3, the electronic device considers the entire sentence, focuses on the slot recognition results of the voice command, and determines the slot of the voice command. The specific instructions are as follows:
[0067] In Rule 1, the electronic device can compare the lengths of the word slots obtained by the parser and the NER model for recognizing the same word to determine the final slot recognition result of the word, which can be specifically expressed as: selecting the longer of the two items as the final slot recognition result of the word.
[0068] In actual applications, for different words in the voice command, the length comparison results recognized by the parser and the NER model may be the same or different. Therefore, it can be understood that in the case of determining the slots of the voice command according to Rule 1, the slots of the voice command may all be the recognition results of the parser, or may all be the recognition results of the NER model, or may include partial recognition results of the parser and partial recognition results of the NER model. The specific details can be determined according to the actual situation, and the embodiments of the present disclosure do not limit this.
[0069] In Rule 2, the electronic device can compare the number of slots obtained by the parser and the NER model for recognizing the same voice command to determine the final slot recognition result of the voice command.
[0070] In specific implementation, Rule 2 may include at least one of the following:
[0071] Rule 2-1: The one with the larger number of two slot recognition results obtained by using the parser and the NER model to perform slot recognition on the same voice command is used as the final slot recognition result of the voice command;
[0072] Rule 2-2: When the total number of characters in the two slot recognition results obtained by using the parser and the NER model to perform slot recognition on the same voice command is equal, the one with the smaller number of characters in the two slot recognition results obtained by using the parser and the NER model to perform slot recognition on the same voice command will be used as the final slot recognition result of the voice command.
[0073] It should be noted that in Rule 2-1, regardless of whether the total number of characters in the two slot recognition results obtained by using the parser and the NER model to perform slot recognition on the same voice instruction is the same, the electronic device can always select the one with the larger number of the two slot recognition results as the final slot recognition result of the voice instruction. In Rule 2-2, the final slot recognition result of the voice instruction is related to the total number of characters in the two slot recognition results obtained by using the parser and the NER model to perform slot recognition on the voice instruction, specifically: when the total number of characters in the two slot recognition results obtained by using the parser and the NER model to perform slot recognition on the same voice instruction is equal, the electronic device can select the one with the smaller number of the two slot recognition results as the final slot recognition result of the voice instruction; when the total number of characters in the two slot recognition results obtained by using the parser and the NER model to perform slot recognition on the same voice instruction is different, the electronic device can select the one with the larger number of the two slot recognition results as the final slot recognition result of the voice instruction.
[0074] When the slots of the voice command are determined according to rule 2-1 or 2-2, the slots of the voice command may all be the recognition results of the parser, or may all be the recognition results of the NER model.
[0075] In Rule 3, the electronic device can determine whether the slots obtained by the parser and the NER model for the same voice command have the same characters. If so, the two items can be combined as the final slot recognition result of the voice command. If not, the final slot recognition result of the voice command can be determined by using the first implementation, any one of Rules 1 and 2 in the second implementation, or the third implementation.
[0076] It should be noted that, in some implementations, the electronic device can determine whether the slots obtained by the parser and the NER model for the same word have the same characters. If so, the two items can be merged as the final slot recognition result of the word. The difference between this implementation and Rule 3 mainly lies in the focus object: this implementation focuses on words, and Rule 3 focuses on voice commands.
[0077] During implementation, the electronic device may apply the above rules to determine the slot of the first voice command, as described below:
[0078] Implementation method 1: Optionally, the first voice instruction includes P words, where P is a positive integer;
[0079] The determining the slot of the first voice command according to the first slot recognition result and the second slot recognition result includes:
[0080] Determining a first word slot corresponding to a target word in the first slot recognition result;
[0081] Determining a second word slot corresponding to the target word in the second slot recognition result;
[0082] Determine the longer one of the first word slot and the second word slot as the target word slot of the target word, and the slot of the first voice instruction includes the target word slot;
[0083] The target word is any one of the P words.
[0084] In this implementation, the slot of each word in the first voice instruction is the longer of the two word slots obtained by slot recognition of the word based on the parser and the NER model. For example, for the target word, if the length of the first word slot is greater than the length of the second word slot, the first word slot can be determined as the final slot of the target word, otherwise, the second word slot can be determined as the final slot of the target word.
[0085] It can be understood that the slots for different words in the first voice instruction may be the recognition results of the parser or the recognition results of the NER model. Therefore, the slots of the first voice instruction may all be the recognition results of the parser or the recognition results of the NER model, or may include partial recognition results of the parser and partial recognition results of the NER model. The specific details can be determined according to the actual situation, and the embodiments of the present disclosure do not limit this. Implementation method 1 can be understood as the application of the above rule 1, but it can also be independent of rule 1.
[0086] Implementation 2: Optionally, determining the slot of the first voice command according to the first slot recognition result and the second slot recognition result includes:
[0087] Determine the number of slots in the first slot identification result to obtain a first slot number;
[0088] Determine the number of slots in the second slot identification result to obtain a second slot number;
[0089] According to the comparison result of the first slot number and the second slot number, the first slot recognition result or the second slot recognition result is determined as the slot of the first voice instruction.
[0090] Further, the determining, according to the comparison result of the first slot number and the second slot number, the first slot recognition result or the second slot recognition result as the slot of the first voice command includes:
[0091] Implementation method 2-1: determining the slot recognition result corresponding to the first target slot number as the slot of the first voice command, wherein the first target slot number is the larger one between the first slot number and the second slot number; or
[0092] Implementation method 2-1: When the total number of slot characters in the first slot recognition result is equal to the total number of slot characters in the second slot recognition result, the slot recognition result corresponding to the second target slot number is determined as the slot of the first voice command, and the second target slot number is the smaller one between the first slot number and the second slot number.
[0093] In implementation 2-1, the electronic device can directly determine the one with the larger number of slots between the first slot recognition result and the second slot recognition result as the slot of the first voice instruction. Specifically, when the number of slots in the first slot recognition result is greater than the number of slots in the second slot recognition result, the slot of the first slot recognition result is determined as the slot of the first voice instruction, and vice versa, the slot of the second slot recognition result is determined as the slot of the first voice instruction.
[0094] In implementation manner 2-2, the electronic device may first determine whether the total number of slot characters respectively included in the first slot identification result and the second slot identification result are equal.
[0095] If they are equal, the one with the smaller number of slots between the first slot recognition result and the second slot recognition result can be determined as the slot of the first voice instruction. Specifically, when the total number of words in the first slot recognition result is equal to the total number of words in the second slot recognition result, if the number of slots in the first slot recognition result is greater than the number of slots in the second slot recognition result, the slot of the second slot recognition result is determined as the slot of the first voice instruction; otherwise, the slot of the first slot recognition result is determined as the slot of the first voice instruction.
[0096] If they are not equal, the one with the larger total number of slot words in the first slot recognition result and the second slot recognition result can be determined as the slot of the first voice instruction. Specifically, when the total number of words in the first slot recognition result is not equal to the total number of words in the second slot recognition result, if the total number of words in the first slot recognition result is more than the number of slots in the second slot recognition result, the slot of the first slot recognition result is determined as the slot of the first voice instruction, otherwise, the slot of the second slot recognition result is determined as the slot of the first voice instruction.
[0097] In implementation 2, the slots of the first tone instruction may all be the recognition results of the parser, or may all be the recognition results of the NER model, which can be determined according to the actual situation, and the embodiments of the present disclosure do not limit this. Implementation 2-1 can be understood as the application of the above rule 2-1, but it can also be independent of rule 2-1. Implementation 2-2 can be understood as the application of the above rule 2-2, but it can also be independent of rule 2-2.
[0098] Implementation 3: Optionally, determining the slot of the first voice command according to the first slot recognition result and the second slot recognition result includes:
[0099] Determine whether the first slot recognition result and the second slot recognition result have the same character;
[0100] When the same character exists in the first slot recognition result and the second slot recognition result, the first slot recognition result and the second slot recognition result are merged to obtain the slot of the first voice instruction.
[0101] In implementation method 3, when the first slot recognition result and the second slot recognition result have the same characters, the first slot recognition result and the second slot recognition result are merged to obtain the slot of the first voice instruction. Otherwise, other methods can be used to determine the slot of the first voice instruction, which can be determined according to actual needs, and the embodiments of the present disclosure do not limit this. Implementation method 3 is understood as the application of the above rule 3, but it can also be independent of rule 3.
[0102] Through the above method, the slot of the voice command can be determined with the help of rules, thereby improving the flexibility of slot determination.
[0103] For the third implementation manner, optionally, determining the slot of the first voice command according to the first slot recognition result and the second slot recognition result includes:
[0104] Inputting the first slot recognition result, the second slot recognition result and a first text into a classification model, where the first text is a text corresponding to the first voice instruction;
[0105] Determining the output of the classification model as the slot of the first voice instruction;
[0106] Among them, the classification model is used to determine whether the slot input into the classification model is the slot of the first voice instruction.
[0107] The classification model is a binary classification model, which can be implemented by any of the following: Gradient Boosting Decision Tree (GBDT), extreme gradient boosting (XGBoost) or Naive Bayes ( bayes) etc.
[0108] When inputting a slot into the classification model, the identification method of the slot can be marked, that is, whether it is identified by a parser or a NER model. The classification model can perform a binary classification judgment on the slot based on the slot and the first text, that is, judge whether the slot is a real slot, and if so, output the slot; otherwise, do not output the slot.
[0109] Through the above method, the slot of the voice command can be determined with the help of the classification model, thereby improving the flexibility of slot determination.
[0110] It should be noted that the various optional implementations introduced in the embodiments of the present disclosure may be implemented in combination with each other or may be implemented separately if they do not conflict with each other, and the embodiments of the present disclosure are not limited to this.
[0111] For ease of understanding, the following examples are provided:
[0112] By combining Parser and NER to identify slots, we can accurately identify both enumerable slots and non-enumerable slots, and maximize the recognition of the entity slot information said by the user. Parser and NER can be combined in many ways, depending on the actual application scenario, including but not limited to the following situations:
[0113] 1. When the slot information contains less non-enumerable information such as names and time, a parser priority solution can be used. For example, Sun Yat-sen's Former Residence, Yellow River Street, Louis XIII, etc., all of which contain information such as names and place names. If NER recognition is used, it is likely that the recognition will not be complete. Therefore, a parser priority solution is used to give priority to such entity slots. The configuration method is such as "[name] Former Residence".
[0114] 2. When there is less enumerable information, a NER-first solution can be adopted, such as when names, addresses, time, etc. appear more frequently.
[0115] 3. According to the characteristics of the entity slot, the priority of the parser and NER can be dynamically configured. Usually, the priority can be based on the longer length of the recognized entity slot. For example, for "Yellow River Street", its NER may recognize "Yellow River" and the parser will recognize "Yellow River Street". At this time, it is more appropriate to choose the longer "Yellow River Street".
[0116] 4. If the whole sentence is considered, the recognition scheme can be dynamically determined according to the total number of slots recognized in the sentence. In this case, dynamic programming can be used to select the case with the most recognized entity words in the sentence. For example, the slot for "today's local epidemic" can be "today / Japan / land point" or "today / local / location". It can be seen that the latter has a longer and more accurate recognition slot. Another example is "Quanyang County and Pinggu County", which can be recognized as "Quanyang County / Heping / Gu County" and "Quanyang County / and / Pinggu County". Obviously, the latter is more correct.
[0117] 5. When the same length of characters is identified, the one with fewer slots is usually used. For example, "I want to apply for a 15-yuan phone package" can be identified as "I want to recharge 15 yuan of phone bills / traffic" and "I want to recharge 15 yuan of phone bills and traffic". The latter is also more semantically complete.
[0118] 6. If there are overlapping words in Parser and NER, you can also use a combined method to process them. For example, in "Chinese and foreign scientific classics", the parser gets "Chinese and foreign science", and the NER gets "scientific classics". There are overlapping parts, so the words can be merged into "Chinese and foreign scientific classics".
[0119] 7. You can use decision-making models for merging, including but not limited to GBDT, XGBoost or bayes, etc. The model is used to make binary judgments on all entity slots recognized by NER and Parser. The advantage is that it can handle slot decisions more flexibly. For example, for "independence and equality and mutual benefit", the parser obtains "independence" and "peace", and the NER obtains "equality and mutual benefit". At this time, the model can be used to make decisions. The trained decision model is obtained by training with annotated corpus. The decision model is used to obtain the "independence" of the parser and the "equality and mutual benefit" of the NER.
[0120] See also Figure 2 , Figure 2 FIG. 1 is a structural diagram of a slot identification device according to an exemplary embodiment. Figure 2 As shown, the slot identification device 200 includes:
[0121] The receiving module 201 is used to receive a first voice command;
[0122] The recognition module 202 is used to perform slot recognition on the first voice instruction using a parser and a named entity recognition (NER) model, respectively, to obtain a first slot recognition result corresponding to the parser and a second slot recognition result corresponding to the NER model;
[0123] The determination module 203 is used to determine the slot of the first voice instruction according to the first slot recognition result and the second slot recognition result.
[0124] Optionally, the determining module 203 includes:
[0125] A first determining unit, configured to determine a slot type of each slot in the first slot identification result and the second slot identification result, wherein the slot type includes an enumerable slot and a non-enumerable slot;
[0126] The second determining unit is used to determine the slot of the first voice instruction according to the number of slots of each slot type in the first slot identification result and the second slot identification result.
[0127] Optionally, the second determining unit is specifically configured to:
[0128] When the number of slots that can be enumerated in the first slot identification result and the second slot identification result is greater than a first threshold, determining the slot in the first slot identification result as the slot of the first voice instruction;
[0129] When the number of enumerable slots in the first slot recognition result and the second slot recognition result is less than or equal to the first threshold, the slot in the second slot recognition result is determined as the slot of the first voice instruction.
[0130] Optionally, the first voice instruction includes P words, where P is a positive integer;
[0131] The determination module 203 is specifically used for:
[0132] Determining a first word slot corresponding to a target word in the first slot recognition result;
[0133] Determining a second word slot corresponding to the target word in the second slot recognition result;
[0134] Determine the longer one of the first word slot and the second word slot as the target word slot of the target word, and the slot of the first voice instruction includes the target word slot;
[0135] The target word is any one of the P words.
[0136] Optionally, the determining module 203 is specifically configured to:
[0137] Determine the number of slots in the first slot identification result to obtain a first slot number;
[0138] Determine the number of slots in the second slot identification result to obtain a second slot number;
[0139] According to the comparison result of the first slot number and the second slot number, the first slot recognition result or the second slot recognition result is determined as the slot of the first voice instruction.
[0140] Optionally, the determining module 203 is specifically configured to:
[0141] Determine the slot recognition result corresponding to the first target slot number as the slot of the first voice command, wherein the first target slot number is the larger one between the first slot number and the second slot number; or
[0142] When the total number of slot characters in the first slot recognition result is equal to the total number of slot characters in the second slot recognition result, the slot recognition result corresponding to the second target slot number is determined as the slot of the first voice instruction, and the second target slot number is the smaller one between the first slot number and the second slot number.
[0143] Optionally, the determining module 203 is specifically configured to:
[0144] Determine whether the first slot recognition result and the second slot recognition result have the same character;
[0145] When the same character exists in the first slot recognition result and the second slot recognition result, the first slot recognition result and the second slot recognition result are merged to obtain the slot of the first voice instruction.
[0146] Optionally, the determining module 203 includes:
[0147] An input unit, configured to input the first slot recognition result, the second slot recognition result, and a first text into a classification model, wherein the first text is a text corresponding to the first voice instruction;
[0148] a third determining unit, configured to determine an output of the classification model as a slot of the first voice instruction;
[0149] Among them, the classification model is used to determine whether the slot input into the classification model is the slot of the first voice instruction.
[0150] The electronic device 200 can implement various processes that the electronic device in the embodiment of the method disclosed herein can implement, and achieve the same beneficial effects. To avoid repetition, they will not be described again here.
[0151] See also Figure 3 , Figure 3 FIG. 1 is a structural diagram of an electronic device according to an exemplary embodiment. Figure 3 As shown, the electronic device 300 includes: a processor 301, a memory 302, a user interface 303, a transceiver 304 and a bus interface.
[0152] In the embodiment of the present disclosure, the electronic device 300 further includes: a program stored in the memory 302 and executable on the processor 301, and when the program is executed by the processor 301, the following steps are implemented:
[0153] Receiving a first voice command via the user interface 303;
[0154] Using a parser and a named entity recognition (NER) model to perform slot recognition on the first voice instruction respectively, and obtaining a first slot recognition result corresponding to the parser and a second slot recognition result corresponding to the NER model;
[0155] The slot of the first voice instruction is determined according to the first slot recognition result and the second slot recognition result.
[0156] Optionally, when the program is executed by the processor 301, the following steps are implemented:
[0157] Determine a slot type of each slot in the first slot identification result and the second slot identification result, where the slot type includes an enumerable slot and a non-enumerable slot;
[0158] The slot of the first voice command is determined according to the number of slots of each slot type in the first slot identification result and the second slot identification result.
[0159] Optionally, the target slot type is an enumerable slot;
[0160] When the program is executed by the processor 301, the following steps are implemented:
[0161] When the number of slots that can be enumerated in the first slot identification result and the second slot identification result is greater than a first threshold, determining the slot in the first slot identification result as the slot of the first voice instruction;
[0162] When the number of enumerable slots in the first slot recognition result and the second slot recognition result is less than or equal to the first threshold, the slot in the second slot recognition result is determined as the slot of the first voice instruction.
[0163] Optionally, the first voice instruction includes P words, where P is a positive integer; when the program is executed by the processor 301, the following steps are implemented:
[0164] Determining a first word slot corresponding to a target word in the first slot recognition result;
[0165] Determining a second word slot corresponding to the target word in the second slot recognition result;
[0166] Determine the longer one of the first word slot and the second word slot as the target word slot of the target word, and the slot of the first voice instruction includes the target word slot;
[0167] The target word is any one of the P words.
[0168] Optionally, when the program is executed by the processor 301, the following steps are implemented:
[0169] Determine the number of slots in the first slot identification result to obtain a first slot number;
[0170] Determine the number of slots in the second slot identification result to obtain a second slot number;
[0171] According to the comparison result of the first slot number and the second slot number, the first slot recognition result or the second slot recognition result is determined as the slot of the first voice instruction.
[0172] Optionally, when the program is executed by the processor 301, the following steps are implemented:
[0173] Determine the slot recognition result corresponding to the first target slot number as the slot of the first voice command, wherein the first target slot number is the larger one between the first slot number and the second slot number; or
[0174] When the total number of slot characters in the first slot recognition result is equal to the total number of slot characters in the second slot recognition result, the slot recognition result corresponding to the second target slot number is determined as the slot of the first voice instruction, and the second target slot number is the smaller one between the first slot number and the second slot number.
[0175] Optionally, when the program is executed by the processor 301, the following steps are implemented:
[0176] Determine whether the first slot recognition result and the second slot recognition result have the same character;
[0177] When the same character exists in the first slot recognition result and the second slot recognition result, the first slot recognition result and the second slot recognition result are merged to obtain the slot of the first voice instruction.
[0178] Optionally, when the program is executed by the processor 301, the following steps are implemented:
[0179] Inputting the first slot recognition result, the second slot recognition result and a first text into a classification model, where the first text is a text corresponding to the first voice instruction;
[0180] Determining the output of the classification model as the slot of the first voice instruction;
[0181] Among them, the classification model is used to determine whether the slot input into the classification model is the slot of the first voice instruction.
[0182] exist Figure 3 In the embodiment, the bus architecture may include any number of interconnected buses and bridges, specifically one or more processors represented by processor 301 and various circuits of memory represented by memory 302 are linked together. The bus architecture may also link together various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface. The transceiver 304 may be a plurality of components, namely, a transmitter and a receiver, providing a unit for communicating with various other devices on a transmission medium. For different user devices, the user interface 303 may also be an interface capable of externally and internally connecting required devices, and the connected devices include but are not limited to a keypad, a display, a speaker, a microphone, a joystick, and the like.
[0183] The processor 301 is responsible for managing the bus architecture and general processing, and the memory 302 can store data used by the processor 2601 when performing operations.
[0184] The electronic device 300 can implement each process of the above method embodiment, which will not be described again here to avoid repetition.
[0185] The embodiment of the present disclosure also provides a readable storage medium, on which a program is stored, and when the program is executed by a processor, each process of the above slot identification method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0186] The embodiments of the present disclosure are described above in conjunction with the accompanying drawings, but the present disclosure is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present disclosure, ordinary technicians in this field can also make many forms without departing from the scope of protection of the purpose of the present disclosure and the claims, all of which are within the protection of the present disclosure.
Claims
1. A slot identification method, It is characterized in that The method comprises: receiving a first voice command; Using a parser and a named entity recognition (NER) model to perform slot recognition on the first voice instruction respectively, and obtaining a first slot recognition result corresponding to the parser and a second slot recognition result corresponding to the NER model; Determining a slot of the first voice command according to the first slot recognition result and the second slot recognition result; The determining the slot of the first voice command according to the first slot recognition result and the second slot recognition result includes: Determine a slot type of each slot in the first slot identification result and the second slot identification result, where the slot type includes an enumerable slot and a non-enumerable slot; Determining a slot for the first voice command according to the number of slots of each slot type in the first slot recognition result and the second slot recognition result; The determining the slot of the first voice command according to the number of slots of each slot type in the first slot recognition result and the second slot recognition result includes: When the number of slots that can be enumerated in the first slot identification result and the second slot identification result is greater than a first threshold, determining the slot in the first slot identification result as the slot of the first voice instruction; When the number of slots of the enumerable slots in the first slot identification result and the second slot identification result is less than or equal to the first threshold, determining the slot in the second slot identification result as the slot of the first voice instruction; The first voice instruction includes P words, where P is a positive integer; The determining the slot of the first voice command according to the first slot recognition result and the second slot recognition result includes: Determining a first word slot corresponding to a target word in the first slot recognition result; Determining a second word slot corresponding to the target word in the second slot recognition result; Determine the longer one of the first word slot and the second word slot as the target word slot of the target word, and the slot of the first voice instruction includes the target word slot; The target word is any one of the P words.
2. The method according to claim 1, It is characterized in that The determining the slot of the first voice command according to the first slot recognition result and the second slot recognition result includes: Determine the number of slots in the first slot identification result to obtain a first slot number; Determine the number of slots in the second slot identification result to obtain a second slot number; According to the comparison result of the first slot number and the second slot number, the first slot recognition result or the second slot recognition result is determined as the slot of the first voice instruction.
3. The method according to claim 2, It is characterized in that The determining, according to the comparison result between the first slot number and the second slot number, the first slot recognition result or the second slot recognition result as the slot of the first voice command includes: Determine the slot recognition result corresponding to the first target slot number as the slot of the first voice command, wherein the first target slot number is the larger one between the first slot number and the second slot number; or When the total number of slot characters in the first slot recognition result is equal to the total number of slot characters in the second slot recognition result, the slot recognition result corresponding to the second target slot number is determined as the slot of the first voice instruction, and the second target slot number is the smaller one between the first slot number and the second slot number.
4. The method according to claim 1, It is characterized in that The determining the slot of the first voice command according to the first slot recognition result and the second slot recognition result includes: Determine whether the first slot recognition result and the second slot recognition result have the same character; When the same character exists in the first slot recognition result and the second slot recognition result, the first slot recognition result and the second slot recognition result are merged to obtain the slot of the first voice instruction.
5. The method according to claim 1, It is characterized in that The determining the slot of the first voice command according to the first slot recognition result and the second slot recognition result includes: Inputting the first slot recognition result, the second slot recognition result and a first text into a classification model, where the first text is a text corresponding to the first voice instruction; Determining the output of the classification model as the slot of the first voice instruction; Among them, the classification model is used to determine whether the slot input into the classification model is the slot of the first voice instruction.
6. A slot identification device, It is characterized in that include: A receiving module, used for receiving a first voice command; A recognition module, configured to perform slot recognition on the first voice instruction using a parser and a named entity recognition (NER) model, respectively, to obtain a first slot recognition result corresponding to the parser and a second slot recognition result corresponding to the NER model; A determination module, configured to determine a slot of the first voice instruction according to the first slot recognition result and the second slot recognition result; The determining module comprises: A first determining unit, configured to determine a slot type of each slot in the first slot identification result and the second slot identification result, wherein the slot type includes an enumerable slot and a non-enumerable slot; a second determining unit, configured to determine a slot of the first voice instruction according to the number of slots of each slot type in the first slot identification result and the second slot identification result; The second determining unit is specifically configured to: When the number of slots that can be enumerated in the first slot identification result and the second slot identification result is greater than a first threshold, determining the slot in the first slot identification result as the slot of the first voice instruction; When the number of slots of the enumerable slots in the first slot identification result and the second slot identification result is less than or equal to the first threshold, determining the slot in the second slot identification result as the slot of the first voice instruction; The first voice instruction includes P words, where P is a positive integer; The determination module is specifically used for: Determining a first word slot corresponding to a target word in the first slot recognition result; Determining a second word slot corresponding to the target word in the second slot recognition result; Determine the longer one of the first word slot and the second word slot as the target word slot of the target word, and the slot of the first voice instruction includes the target word slot; The target word is any one of the P words.
7. An electronic device, It is characterized in that The method comprises a processor, a memory and a program stored in the memory and executable on the processor, wherein the program, when executed by the processor, implements the steps of the slot identification method as claimed in any one of claims 1 to 5.
8. A readable storage medium, It is characterized in that The readable storage medium stores a program, and when the program is executed by a processor, the steps of the slot identification method according to any one of claims 1 to 5 are implemented.
