Multi-scene semantic understanding method and device, electronic device, and storage medium
By combining text classification and mapping dictionaries with a one-dimensional convolutional model, the semantic understanding problem of smart audio glasses when faced with different user expressions is solved, improving the accuracy and response speed of semantic understanding and adapting to the different expression habits of users.
Patent Information
- Application Number
- CN202511456999.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-13
- Publication Date
- 2026-05-29
- Estimated Expiration
- 2045-10-13
AI Technical Summary
Smart audio glasses cannot accurately understand user intent when faced with different users' language expressions and habits, resulting in a decline in user experience.
A text classification model is used to classify user commands, and keywords in user commands are quickly matched by combining a mapping dictionary and a one-dimensional convolutional model, ensuring the accuracy of semantic understanding and the speed of response.
It improves the semantic understanding accuracy and response speed of user commands in multiple scenarios, adapts to the expression habits of different users, and reduces redundant modeling and computational overhead.
Smart Images

Figure CN121351822B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of natural language processing technology, and more specifically, relates to a multi-scenario semantic understanding method and device, electronic device, and storage medium. Background Technology
[0002] Smart audio glasses are wearable devices that integrate audio playback, calls, and intelligent interaction. Users can use simple voice commands to enable the smart audio glasses to perform operations such as playing music, making phone calls, and querying information. However, in practical applications, different users have different language expressions and habits, and commands may be ambiguous or vague, causing the smart audio glasses to fail to accurately execute user intentions, which greatly affects the user experience. Therefore, how to enable smart audio glasses to accurately understand user semantics has become an urgent problem to be solved. Summary of the Invention
[0003] The purpose of this application is to provide a multi-scenario semantic understanding method, device, electronic device, and storage medium to improve the semantic understanding accuracy of wearable devices for user commands.
[0004] A first aspect of this application provides a multi-scenario semantic understanding method, including:
[0005] Get the current user's commands;
[0006] The current user instruction is classified based on a text classification model to obtain the instruction type to which the current user instruction belongs;
[0007] If the instruction type of the current user instruction is a device control instruction or a system setting instruction, extract the first keyword from the current user instruction; search for the second keyword that matches the first keyword in the mapping dictionary to obtain the search result; the mapping dictionary includes standard instructions corresponding to multiple function types, and a set of second keywords corresponding to each standard instruction;
[0008] If the search results show that there is a second keyword in the mapping dictionary that matches the first keyword, the standard instruction corresponding to the second keyword is used as the semantic understanding result of the current user instruction.
[0009] A second aspect of this application provides a multi-scene semantic understanding device, including:
[0010] The instruction acquisition module is used to acquire the current user's instructions;
[0011] The instruction classification module is used to classify the current user instruction based on a text classification model to obtain the instruction type to which the current user instruction belongs;
[0012] The semantic understanding module is used for:
[0013] If the instruction type of the current user instruction is a device control instruction or a system setting instruction, extract the first keyword from the current user instruction; search for the second keyword that matches the first keyword in the mapping dictionary to obtain the search result; the mapping dictionary includes standard instructions corresponding to multiple function types, and a set of second keywords corresponding to each standard instruction;
[0014] If the search results show that there is a second keyword in the mapping dictionary that matches the first keyword, the standard instruction corresponding to the second keyword is used as the semantic understanding result of the current user instruction.
[0015] A third aspect of this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor executes the computer program to implement the steps of the multi-scene semantic understanding method described above.
[0016] In a fourth aspect of this application, a computer-readable storage medium is provided, the computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the multi-scene semantic understanding method described above.
[0017] The beneficial effects of the multi-scenario semantic understanding method and apparatus, electronic device, and storage medium provided in this application embodiment are as follows:
[0018] This application first classifies the current user command according to intent using a text classification model, thus solving the ambiguity problem of natural language from the bottom up. On this basis, different processing procedures are adopted for the semantic characteristics of different classifications (or scenarios), which can improve the semantic understanding accuracy of user commands in multiple scenarios.
[0019] For device control commands or system setting commands, since they directly operate the device's hardware or software, the response to these commands must meet the requirements of low latency and high reliability. Therefore, the current user command can be processed quickly using a mapping dictionary. The first keyword in the current user command is quickly matched with the second keyword corresponding to each standard command in the mapping dictionary to determine the standard command corresponding to the current user command. This standard command is then used as the semantic understanding result of the current user command. While ensuring the accuracy of semantic understanding, the response speed to the current user command can be further improved. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 A flowchart illustrating a multi-scenario semantic understanding method provided in an embodiment of this application;
[0022] Figure 2 This is a structural block diagram of a multi-scene semantic understanding device provided in an embodiment of this application;
[0023] Figure 3 This is a schematic block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0024] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0025] To make the objectives, technical solutions, and advantages of this application clearer, the following description will be provided in conjunction with the accompanying drawings and specific embodiments.
[0026] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating a multi-scenario semantic understanding method provided in an embodiment of this application. The method can be executed by an electronic device and may include:
[0027] S101: Get the current user's instructions.
[0028] In this embodiment, when a user needs an electronic device to perform a certain function (such as playing music, navigation, etc.), the user can input the current user command through a microphone, display screen, or virtual keyboard. The current user command can be a text command or a voice command. For voice commands, they can be converted into text commands first through voice recognition technology.
[0029] S102: Classify the current user command based on the text classification model to obtain the command type to which the current user command belongs.
[0030] In this embodiment, text classification models such as TextCNN and Bidirectional Transformer Encoder Representation Model (BERT) can be trained using historical data of the current user's instructions. This allows the model to learn the semantic features (such as keywords and syntactic structures) of different types of instructions. Based on this, the current user's instructions can be input into the trained text classification model to obtain the instruction type to which the current user's instructions belong.
[0031] For example, the current user command can be classified as a device control command, information query command, system setting command, entertainment control command, or task reminder command. Device control commands are used to operate hardware devices and typically include "device name + operation word" (e.g., "air conditioner + heat up", "Bluetooth + turn off"). Information query commands are used to retrieve various types of information, such as "What's the weather like today?" or "Ticket price for XX scenic spot". Entertainment control commands are used to control entertainment content or functions, such as music playback ("Play XXX song") or content control ("Pause video", "Next song"). Task reminder commands are used to set scheduled tasks or periodic reminders, such as "Remind me of the meeting at 9 am tomorrow". System setting commands are used to configure device or software operating parameters and function options, such as "Adjust screen brightness to 70%".
[0032] S103: If the instruction type of the current user instruction is a device control instruction or a system setting instruction, extract the first keyword of the current user instruction; search for the second keyword that matches the first keyword in the mapping dictionary to obtain the search result; the mapping dictionary includes standard instructions corresponding to multiple function types, and a set of second keywords corresponding to each standard instruction.
[0033] In this embodiment, considering that the semantic parsing of user instructions of different instruction types has different focuses, different instruction processing strategies are pre-set for different instruction types. Based on this, the corresponding instruction processing strategy is determined according to the instruction type to which the current user instruction belongs, which can improve the accuracy of semantic understanding of different user instructions.
[0034] For device control commands or system setting commands, which directly operate the device's hardware or software, the response to these commands must meet the requirements of low latency and high reliability. Therefore, the current user command can be processed quickly first through a mapping dictionary.
[0035] In this embodiment, the mapping dictionary includes standard instructions corresponding to multiple function types, and a set of second keywords corresponding to each standard instruction. The function types may include volume adjustment, air conditioning control, etc., and each function type corresponds to multiple standard instructions. For example, when the function type is volume adjustment, its corresponding standard instructions may be "turn up volume," "turn down volume," etc. Each standard instruction is assigned a corresponding set of second keywords (keyword set) to assist in semantic understanding of the standard instructions. A specific example of the mapping dictionary is shown below:
[0036] {
[0037] "Function Type": "Volume Adjustment"
[0038] "Standard directives": [
[0039] {
[0040] Command Name: "Turn up volume"
[0041] "Keyword set": [
[0042] "Turn up volume", "Turn up volume", "Enlarge sound", "Volume up", "Turn up sound"
[0043] },
[0044] "Action to be performed": "increase_volume"
[0045] },
[0046] {
[0047] Command Name: "Turn down the volume"
[0048] "Keyword set": [...]
[0049] "Action to perform": "decrease_volume"
[0050] }
[0051] ]}.
[0052] In this embodiment, a matching threshold (e.g., semantic similarity above 80%) can be set, and a data structure such as a trie tree can be used to quickly match the first keyword in the current user command with the second keyword corresponding to each standard command in the mapping dictionary, thereby determining the standard command corresponding to the current user command and improving the response speed to the current user command. Other methods can also be used to match the first keyword and the second keyword, as detailed in the following embodiments.
[0053] S104: If the search results show that there is a second keyword in the mapping dictionary that matches the first keyword, the standard instruction corresponding to the second keyword is used as the semantic understanding result of the current user instruction.
[0054] In this embodiment, if there is a second keyword in the mapping dictionary that matches the first keyword with a degree greater than a set matching threshold (e.g., 80%), then the standard instruction corresponding to the second keyword with the highest degree of matching is taken as the semantic understanding result of the current user instruction.
[0055] As can be seen from the above, this embodiment first classifies the current user command according to intent through a text classification model, thereby solving the ambiguity problem of natural language from the bottom up. On this basis, different processing procedures are adopted for the semantic characteristics of different classifications (or scenarios), which can improve the semantic understanding accuracy of user commands in multiple scenarios.
[0056] For device control commands or system setting commands, since they directly operate the device's hardware or software, the response to these commands must meet the requirements of low latency and high reliability. Therefore, the current user command can be processed quickly using a mapping dictionary. The first keyword in the current user command is quickly matched with the second keyword corresponding to each standard command in the mapping dictionary to determine the standard command corresponding to the current user command. This standard command is then used as the semantic understanding result of the current user command. While ensuring the accuracy of semantic understanding, the response speed to the current user command can be further improved.
[0057] Furthermore, if new instruction types are needed during actual use, only the corresponding processing strategy needs to be added, without modifying the core framework, making it easy to expand functionality.
[0058] In one embodiment of this application, searching for a second keyword that matches the first keyword from a mapping dictionary includes:
[0059] Find the second keyword in the mapping dictionary whose matching degree with the first keyword is greater than the first matching degree threshold;
[0060] If the search results show that there is no second keyword matching the first keyword in the mapping dictionary, multi-scenario semantic understanding methods also include:
[0061] A fusion vector is generated based on the current user command and historical user commands. The fusion vector is then input into a one-dimensional convolutional model to obtain the function type corresponding to the current user command.
[0062] Based on the function type and the first keyword, a mapping dictionary is searched to obtain a second keyword with a matching degree greater than the first keyword and a second matching degree threshold. The standard instruction corresponding to the second keyword is used as the semantic understanding result of the current user instruction. The second matching degree threshold is less than the first matching degree threshold.
[0063] In this embodiment, the matching degree threshold can be set as the first matching degree threshold. If there is a second keyword in the mapping dictionary with a matching degree greater than the first matching threshold (e.g., 80%), then the standard instruction corresponding to the second keyword with the highest matching degree is taken as the semantic understanding result of the current user instruction.
[0064] If there is no second keyword in the mapping dictionary that matches the first keyword with a degree greater than the first matching threshold, it indicates that the current user command is a variant command not covered by the mapping dictionary (such as "turn the volume up"). In this case, semantic features can be extracted by a one-dimensional convolutional model, and then the first keyword can be combined with the standard command in the mapping dictionary for a second matching to achieve an accurate understanding of the current user command.
[0065] Specifically, a one-dimensional convolutional model can be pre-trained. Based on this, a fusion vector is generated using the current user command and historical user commands to incorporate contextual information. This fusion vector is then input into the trained one-dimensional convolutional model to obtain the function type corresponding to the current user command. The one-dimensional convolutional model has a simple structure and low computational cost, making it suitable for use in resource-constrained devices such as smart audio glasses.
[0066] Taking the variant command "turn up the volume" as an example, a one-dimensional convolutional model reveals that the corresponding function type is "volume adjustment." Based on this, the search scope can be narrowed down to the standard command set {volume up, volume down} corresponding to the function type "volume adjustment" in the mapping dictionary. Under the semantic constraints of function type, matching the first and second keywords will not be interfered with by keywords of other function types. Therefore, the matching threshold can be lowered from the first matching threshold to the second matching threshold (e.g., 70%). Searching again based on the first keyword "turn up the volume" in the current user command within the aforementioned standard command set {volume up, volume down}, the variant command "turn up the volume" can be matched with "volume up".
[0067] In the above process, this embodiment determines the function type corresponding to the current user command through a one-dimensional convolutional model, without directly outputting the specific command. This allows the one-dimensional convolutional model to focus on semantic abstraction and improve generalization ability. For example, the commands "turn down the volume" and "reduce speaker volume" are both output as "volume adjustment" after being processed by the model, avoiding redundant modeling due to differences in expression. At the same time, the model is only responsible for the abstract layer task of "function classification," and the computational cost is much less than that of directly generating specific commands.
[0068] As can be seen from the above, in this embodiment, for device control instructions or system setting instructions, the standard instruction corresponding to the current user instruction is first determined by looking up the mapping dictionary to ensure the efficiency of semantic understanding. For variant instructions that cannot be covered by the mapping dictionary, the variant instructions can be processed by a one-dimensional convolutional model. Through the hierarchical processing strategy of the mapping dictionary and the one-dimensional convolutional model, the processing efficiency of user instructions can be improved as much as possible while ensuring the accuracy of semantic understanding.
[0069] In one embodiment of this application, there are multiple historical user commands, and a fusion vector is generated based on the current user command and the historical user commands, including:
[0070] Based on specified rules, extract the slot values corresponding to multiple slots from the current user command to obtain the current slot value set;
[0071] The current set of slot values is compared with the most recent set of historical slot values, and the slots that have changed are saved to the target set of slot values; the most recent set of historical slot values is the set of slot values corresponding to the most recent round of historical user commands;
[0072] If the target slot set is empty, then the first target instruction is selected from multiple historical user instructions; a fusion vector is generated based on the current user instruction and the first target instruction; the slot value set corresponding to the first target instruction contains the current slot value set;
[0073] If the target slot set is not empty, then the second target instruction is selected from multiple historical user instructions; a fusion vector is generated based on the current user instruction and the second target instruction; the slot value set corresponding to the second target instruction does not contain the old slot value, and the old slot value is the slot value in the historical user instruction corresponding to the slot that has changed.
[0074] In this embodiment, the specified rule can be a pre-defined regular expression. For example, a regular expression can be used to extract the slot values corresponding to multiple slots such as device type, device location, operation type, or operation parameters from the current user command, resulting in a current set of slot values. Similarly, regular expressions can be used to extract the slot values corresponding to multiple slots such as device type, device location, operation type, or operation parameters from multiple historical user commands, resulting in historical sets of slot values corresponding to multiple historical user commands. Then, the current set of slot values is compared with the most recent set of historical slot values to identify the slots that have changed, and these changed slots are saved to the target set of slot values.
[0075] If the current user instruction does not update any slot values, the target slot set is empty, indicating that the current user instruction continues the previous topic. When merging the current user instruction and historical user instructions, only historical user instructions containing all current slot values are retained. That is, if the historical slot value set corresponding to a certain historical user instruction is the same as the current slot value set, or if the current slot value set is a subset of the historical slot value set corresponding to the historical user instruction, then the historical user instruction is taken as the first target instruction.
[0076] For example, the current slot value set is: {"device": "air conditioner", "location": "living room"};
[0077] Historical User Command 1: "Turn on the living room air conditioner" → The historical slot value set is the same as the current slot value set, so historical user command 1 is retained;
[0078] Historical User Command 2: "The bedroom air conditioner was turned off yesterday" → The location slot for the bedroom has changed, so delete Historical User Command 2 from the historical user commands.
[0079] If the current user command updates the slot value, it indicates that the topic or parameter corresponding to the current user command has changed. When merging the current user command and historical user commands, only historical user commands that do not contain the old slot value are retained.
[0080] For example, the current slot value set is: {"device": "air conditioner", "location": "living room"}
[0081] Historical User Command 1: "Bedroom air conditioner is on" → Includes old location=Bedroom, delete historical user command 1 from multiple historical user commands;
[0082] Historical User Command 2: "System Prompt: Support for adjusting living room equipment" → Includes new slot values, retains historical user command 2.
[0083] As can be seen from the above, this embodiment can filter out historical user instructions that are unrelated to the current user instruction by comparing the slot update status of the current user instruction and the historical user instructions, and only retain user instructions that are related to the current user instruction. This avoids irrelevant historical user instructions interfering with the semantic understanding of the current user instruction, thereby improving the accuracy of semantic understanding.
[0084] In one embodiment of this application, searching for a second keyword that matches the first keyword in a mapping dictionary to obtain search results includes:
[0085] Calculate the character similarity between the first keyword and each of the second keywords to obtain their respective character similarity.
[0086] Calculate the semantic similarity between the first keyword and each second keyword to obtain their respective corresponding semantic similarities;
[0087] Perform a weighted sum of each character similarity and its corresponding semantic similarity to obtain the matching degree between each second keyword and the first keyword;
[0088] Determine the search result based on the matching degree between each second keyword and the first keyword.
[0089] In this embodiment, when matching the first keyword and the second keyword, if there are form differences in the current user instruction such as spelling mistakes (e.g., "set quality alarm" → "set alarm"), simplified and traditional Chinese character conversion ("file folder" → "folder"), synonym variants ("open" → "start"), etc., character-level similarity calculation methods such as the Levenshtein distance and the Jaccard coefficient can effectively calculate the form matching degree of the string, which is robust to spelling mistakes and input errors in the instruction, and avoids matching failures caused by character form deviations.
[0090] When the user uses near synonyms ("search" → "find"), hypernyms and hyponyms ("fruit" → "apple"), synonymous phrases ("play music" → "start music player"), etc., by calculating the semantic similarity, it is possible to break through the limitation of the character form and understand the user's intention from the semantic level.
[0091] Therefore, in this embodiment, by performing a weighted sum of the character similarity and the semantic similarity corresponding to each second keyword to obtain the matching degree between each second keyword and the first keyword, based on this, if the highest matching degree is greater than the matching degree threshold, the second keyword corresponding to the highest matching degree is determined as the search result.
[0092] From the above, it can be concluded that in this embodiment, by performing a weighted sum of the character similarity and the semantic similarity corresponding to each second keyword to obtain the matching degree between each second keyword and the first keyword, it is possible to accurately calculate the matching degree between the first keyword and the second keyword, and avoid missed judgments caused by single-dimensional calculation.
[0093] In an embodiment of the present application, the multi-scenario semantic understanding method further includes:
[0094] If the call frequency of the one-dimensional convolutional model is less than or equal to the set frequency, set the first weight corresponding to the character similarity to be greater than the second weight corresponding to the semantic similarity;
[0095] If the call frequency of the one-dimensional convolutional model is greater than the set frequency, set the first weight corresponding to the character similarity to be less than the second weight corresponding to the semantic similarity;
[0096] The weighted sum of each character's similarity score and its corresponding semantic similarity score is calculated, including:
[0097] Based on the set first and second weights, the similarity of each character is summed with its corresponding semantic similarity.
[0098] In this embodiment, when the frequency of one-dimensional convolutional model calls is less than or equal to a set frequency, it indicates that the user is familiar with the command format of the smart audio glasses and prefers to use standard expressions. The first keyword in the current user command can be quickly matched with the second keyword corresponding to each standard command in the mapping dictionary to determine the standard command corresponding to the current user command, without triggering the one-dimensional convolutional model for semantic generalization processing. For this type of user, the first weight corresponding to character similarity can be increased, emphasizing that character similarity can accurately distinguish the core differences in keywords, ensuring the accuracy of command matching, and further reducing the frequency of one-dimensional convolutional model usage.
[0099] When the frequency of calls to the one-dimensional convolutional model exceeds the set frequency, it indicates that users frequently use non-standard expressions, resulting in a high probability of keyword matching failure. This necessitates relying on the one-dimensional convolutional model to determine the function type before matching, hence the high frequency of calls to the one-dimensional convolutional model. For this type of user, the second weight corresponding to semantic similarity can be increased, emphasizing semantic similarity to lower the usage threshold.
[0100] As can be seen from the above, this embodiment determines the user profile based on the call frequency of the one-dimensional convolutional model, and adjusts the weights of character similarity and semantic similarity based on the user profile. This can adapt to the expression habits of different users, optimize the interactive experience, and minimize the computational overhead of the one-dimensional convolutional model.
[0101] In one embodiment of this application, if a second keyword with a matching degree greater than a second matching degree threshold cannot be found in the mapping dictionary based on the function type and the first keyword, the multi-scenario semantic understanding method further includes:
[0102] Select the N second keywords from the mapping dictionary that have the highest matching degree with the first keyword; where N is a natural number and N≤3;
[0103] Based on the standard instructions corresponding to each of the N second keywords, prompt information is generated to instruct the user to provide supplementary instructions;
[0104] Obtain supplementary instructions provided by the user, select the target standard instruction from the standard instructions corresponding to each of the N second keywords based on the supplementary instructions, and determine the target standard instruction as the semantic understanding result of the current user instruction.
[0105] In this embodiment, if no standard instruction matching the first keyword is found after narrowing the search scope based on function type, the N standard instructions with the highest matching degree with the first keyword can be used as candidate instructions. Based on the candidate instructions, prompt information is generated, such as "Turn up the media volume?" or "Turn up the call volume?" This guides the user to provide further information to determine whether "Turn up the media volume" or "Turn up the call volume" should be used as the target standard instruction. The target standard instruction is then determined as the semantic understanding result of the current user instruction.
[0106] In one embodiment of this application, the multi-scene semantic understanding method further includes:
[0107] If the current user command belongs to the command type of entertainment control command or information query command, the structured semantic information corresponding to the current user command is obtained based on the sequence generation model; the structured semantic information includes domain labels and multiple slot values;
[0108] The corresponding application interface is invoked based on structured semantic information to execute the operation corresponding to the current user instruction, and the operation result is used as the semantic understanding result of the current user instruction.
[0109] In this embodiment, both entertainment control commands and information query commands involve semantic understanding and interact with external resources (such as calling music APIs or querying the weather), and can share the semantic parsing and retrieval module.
[0110] Specifically, a lightweight NER model (such as DistilBERT+CRF) can be used first to extract entities (such as singer name, location, time, etc.) from the current user command and fill the slot values; then, a shared sequence generation model (BiLSTM+Attention) can be used to generate a semantic structure {domain: entertainment control - music playback, action: play, entity: XXX}, which transforms natural language commands into structured semantic information.
[0111] Based on this, for structured semantic information with the domain label "entertainment control - music playback", the music service API can be called, and multiple slot values can be passed as parameters to play music; for structured semantic information with the domain label "information query - weather", the weather service API can be called, and slot values can be passed as parameters to query information.
[0112] As can be seen from the above, this embodiment, targeting the characteristics of entertainment control commands and information query commands, transforms natural language commands into structured semantic information through a sequence generation model, which can quickly locate user intent; the slot values in the structured semantics are directly used as API parameters, thereby realizing automatic mapping from natural language commands to function execution, which can improve the speed of responding to user commands, and at the same time, facilitate the expansion of new functional modules.
[0113] In one embodiment of this application, the multi-scene semantic understanding method further includes:
[0114] If the current user command belongs to the task reminder type, then perform the following operations:
[0115] Extract timestamp information from the current user command;
[0116] Extract the third keyword from the current user command;
[0117] Store the third keyword and timestamp information in the database;
[0118] Start the scheduled task to read the third keyword from the database and execute the task corresponding to the third keyword when the preset time arrives. The task execution result will be used as the semantic understanding result of the current user instruction. The preset time is obtained based on timestamp information.
[0119] In this embodiment, task reminder commands typically contain time information. Therefore, the time information can first be extracted from the user command based on a time parsing model (such as dateparser or TimeML), and the natural language time can be converted into structured timestamp information. For example, "tomorrow" can be parsed as 2025-07-07 00:00:00. The time parsing model can be implemented using an existing date and time parser or Time Markup Language (TimeML).
[0120] Then, using the same method as in the previous embodiments, the third keyword is extracted from the current user command, and the third keyword is bound to timestamp information and stored in the database. Finally, the scheduled task is started to read the third keyword from the database and execute the corresponding task when the user-specified time arrives, thereby achieving accurate execution of the user's intent.
[0121] As can be seen from the above, considering the characteristics of task reminder instructions, this embodiment converts natural language time into structured timestamp information based on a time parsing model, and combined with a timed task scheduler, it can ensure that tasks are triggered on time.
[0122] In one embodiment of this application, storing the third keyword and timestamp information in a database includes:
[0123] The estimated execution time of the current user command is determined based on timestamp information;
[0124] Calculate the time interval between the estimated execution time of the current user instruction and the current time;
[0125] If the interval is less than or equal to the set interval, the third keyword and timestamp information will be stored in the memory database.
[0126] If the interval exceeds the set duration, the third keyword and timestamp information will be stored in a relational database.
[0127] In this embodiment, the estimated execution time of the current user instruction can be determined based on the timestamp information. By subtracting the estimated execution time of the current user instruction from the current time, the interval between the estimated execution time of the current user instruction and the current time can be obtained.
[0128] If the interval is less than or equal to the set interval, it indicates that the task corresponding to the current user command is a short-term task. The third keyword and timestamp information can be stored in an in-memory database (such as Redis) and sorted by timestamp for easy retrieval of tasks that will be triggered soon. If the interval is longer than the set interval, it indicates that the task corresponding to the current user command is a long-term task. The third keyword and timestamp information can be stored in a relational database (such as MySQL) to create a time index, which can quickly locate tasks within a specific time period.
[0129] Corresponding to the multi-scenario semantic understanding method in the above embodiments, Figure 2 This is a structural block diagram of a multi-scene semantic understanding device provided in one embodiment of this application. For ease of explanation, only the parts relevant to the embodiment of this application are shown. References Figure 2 The multi-scenario semantic understanding device 20 includes: an instruction acquisition module 21, an instruction classification module 22, and a semantic understanding module 23.
[0130] The instruction acquisition module 21 is used to acquire the current user instruction;
[0131] The instruction classification module 22 is used to classify the current user instructions based on the text classification model to obtain the instruction type to which the current user instructions belong;
[0132] Semantic understanding module 23 is used for:
[0133] If the current user command belongs to the command type of device control command or system setting command, extract the first keyword of the current user command; search for the second keyword that matches the first keyword in the mapping dictionary to obtain the search result; the mapping dictionary includes standard commands corresponding to multiple function types, and a set of second keywords corresponding to each standard command;
[0134] If the search results show that there is a second keyword in the mapping dictionary that matches the first keyword, the standard instruction corresponding to the second keyword is used as the semantic understanding result of the current user instruction.
[0135] In one embodiment of this application, when searching for a second keyword that matches the first keyword from the mapping dictionary, the semantic understanding module 23 is specifically used for:
[0136] Find the second keyword in the mapping dictionary whose matching degree with the first keyword is greater than the first matching degree threshold;
[0137] If the search results show that there is no second keyword matching the first keyword in the mapping dictionary, the semantic understanding module 23 is further used for:
[0138] A fusion vector is generated based on the current user command and historical user commands. The fusion vector is then input into a one-dimensional convolutional model to obtain the function type corresponding to the current user command.
[0139] Based on the function type and the first keyword, a mapping dictionary is searched to obtain a second keyword with a matching degree greater than the first keyword and a second matching degree threshold. The standard instruction corresponding to the second keyword is used as the semantic understanding result of the current user instruction. The second matching degree threshold is less than the first matching degree threshold.
[0140] In one embodiment of this application, there are multiple historical user instructions, and the semantic understanding module 23 is further used for:
[0141] Based on specified rules, extract the slot values corresponding to multiple slots from the current user command to obtain the current slot value set;
[0142] The current set of slot values is compared with the most recent set of historical slot values, and the slots that have changed are saved to the target set of slot values; the most recent set of historical slot values is the set of slot values corresponding to the most recent round of historical user commands;
[0143] If the target slot set is empty, then the first target instruction is selected from multiple historical user instructions; a fusion vector is generated based on the current user instruction and the first target instruction; the slot value set corresponding to the first target instruction contains the current slot value set;
[0144] If the target slot set is not empty, then the second target instruction is selected from multiple historical user instructions; a fusion vector is generated based on the current user instruction and the second target instruction; the slot value set corresponding to the second target instruction does not contain the old slot value, and the old slot value is the slot value in the historical user instruction corresponding to the slot that has changed.
[0145] In one embodiment of this application, the semantic understanding module 23 is specifically used for:
[0146] Calculate the character similarity between the first keyword and each of the second keywords to obtain their respective character similarity.
[0147] Calculate the semantic similarity between the first keyword and each of the second keywords to obtain their respective semantic similarity.
[0148] The matching degree between each second keyword and the first keyword is obtained by weighted summing of the similarity of each character and its corresponding semantic similarity;
[0149] The search results are determined based on the matching degree between each second keyword and the first keyword.
[0150] In one embodiment of this application, if a second keyword with a matching degree greater than a second matching degree threshold cannot be found in the mapping dictionary based on the function type and the first keyword, the semantic understanding module 23 is further configured to:
[0151] Select the N second keywords from the mapping dictionary that have the highest matching degree with the first keyword; where N is a natural number and N≤3;
[0152] Based on the standard instructions corresponding to each of the N second keywords, prompt information is generated to instruct the user to provide supplementary instructions;
[0153] Obtain supplementary instructions provided by the user, select the target standard instruction from the standard instructions corresponding to each of the N second keywords based on the supplementary instructions, and determine the target standard instruction as the semantic understanding result of the current user instruction.
[0154] In one embodiment of this application, the semantic understanding module 23 is specifically used for:
[0155] If the current user command belongs to the command type of entertainment control command or information query command, the structured semantic information corresponding to the current user command is obtained based on the sequence generation model; the structured semantic information includes domain labels and multiple slot values;
[0156] The corresponding application interface is invoked based on structured semantic information to execute the operation corresponding to the current user instruction, and the operation result is used as the semantic understanding result of the current user instruction.
[0157] In one embodiment of this application, the semantic understanding module 23 is specifically used for:
[0158] If the current user command belongs to the task reminder type, then perform the following operations:
[0159] Extract timestamp information from the current user command;
[0160] Extract the third keyword from the current user command;
[0161] Store the third keyword and timestamp information in the database;
[0162] Start the scheduled task to read the third keyword from the database and execute the task corresponding to the third keyword when the preset time arrives. The task execution result will be used as the semantic understanding result of the current user instruction. The preset time is obtained based on timestamp information.
[0163] See Figure 3 , Figure 3 This is a schematic block diagram of an electronic device provided according to an embodiment of this application. Figure 3 The electronic device 300 in this embodiment may include one or more processors 301, one or more input devices 302, one or more output devices 303, and one or more memories 304. The processors 301, input devices 302, output devices 303, and memories 304 communicate with each other via a communication bus 305. The memories 304 store computer programs, including program instructions. The processors 301 execute the program instructions stored in the memories 304. Specifically, the processors 301 are configured to invoke the program instructions to perform the functions of each module / unit in the above-described device embodiments, for example... Figure 2 The functions of the instruction acquisition module 21, instruction classification module 22, and semantic understanding module 23 are shown.
[0164] It should be understood that, in the embodiments of this application, the processor 301 may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0165] Input device 302 may include a touchpad, a fingerprint sensor (for collecting the user's fingerprint information and fingerprint orientation information), a microphone, etc., and output device 303 may include a display (LCD, etc.), a speaker, etc.
[0166] The memory 304 may include read-only memory and random access memory, and provides instructions and data to the processor 301. A portion of the memory 304 may also include non-volatile random access memory. For example, the memory 304 may also store preset constants such as a first matching threshold, a second matching threshold, a set duration, and a set frequency.
[0167] In specific implementations, the processor 301, input device 302, and output device 303 described in the embodiments of this application can execute the implementation methods described in the multi-scenario semantic understanding method provided in the embodiments of this application, or they can execute the implementation methods of the electronic devices described in the embodiments of this application, which will not be repeated here.
[0168] In another embodiment of this application, a computer-readable storage medium is provided. This computer-readable storage medium stores a computer program, which includes program instructions. When executed by a processor, the program instructions implement all or part of the processes in the methods described above. Alternatively, the computer program can instruct related hardware to complete the process. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include any entity or device capable of carrying computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.
[0169] The computer-readable storage medium can be an internal storage unit of the electronic device in any of the foregoing embodiments, such as a hard disk or memory of the electronic device. The computer-readable storage medium can also be an external storage device of the electronic device, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., equipped on the electronic device. Furthermore, the computer-readable storage medium can include both internal and external storage units of the electronic device. The computer-readable storage medium is used to store computer programs and other programs and data required by the electronic device. The computer-readable storage medium can also be used to temporarily store data that has been output or will be output.
[0170] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.
[0171] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the electronic devices and units described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0172] In the several embodiments provided in this application, it should be understood that the disclosed electronic devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, modules may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connections shown or discussed may be indirect coupling or communication connections through some interfaces or units, or they may be electrical, mechanical, or other forms of connection.
[0173] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of the embodiments of this application, depending on actual needs.
[0174] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.
[0175] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A multi-scene semantic understanding method, characterized in that, include: Get the current user's commands; The current user instruction is classified based on a text classification model to obtain the instruction type to which the current user instruction belongs; If the instruction type of the current user instruction is a device control instruction or a system setting instruction, extract the first keyword from the current user instruction; search for the second keyword that matches the first keyword in the mapping dictionary to obtain the search result; the mapping dictionary includes standard instructions corresponding to multiple function types, and a set of second keywords corresponding to each standard instruction; If the search results show that there is a second keyword in the mapping dictionary that matches the first keyword, the standard instruction corresponding to the second keyword is used as the semantic understanding result of the current user instruction; Search the mapping dictionary for a second keyword that matches the first keyword, including: Search the mapping dictionary for a second keyword whose matching degree with the first keyword is greater than the first matching degree threshold; If the search result shows that there is no second keyword matching the first keyword in the mapping dictionary, the method further includes: A fusion vector is generated based on the current user command and historical user commands. The fusion vector is then input into a one-dimensional convolution model to obtain the function type corresponding to the current user command. Based on the function type and the first keyword lookup mapping dictionary, a second keyword with a matching degree greater than that of the first keyword is obtained, and the standard instruction corresponding to the second keyword is used as the semantic understanding result of the current user instruction; the second matching degree threshold is less than the first matching degree threshold. The historical user commands are multiple, and the generation of a fusion vector based on the current user commands and historical user commands includes: Based on specified rules, extract the slot values corresponding to multiple slots from the current user instruction to obtain the current slot value set; The current slot value set is compared with the most recent historical slot value set, and the slots that have changed are saved to the target slot set; the most recent historical slot value set is the slot value set corresponding to the most recent round of historical user commands; If the target slot set is empty, then a first target instruction is selected from multiple historical user instructions; a fusion vector is generated based on the current user instruction and the first target instruction; the slot value set corresponding to the first target instruction includes the current slot value set; If the target slot set is not empty, a second target instruction is selected from multiple historical user instructions; a fusion vector is generated based on the current user instruction and the second target instruction; the slot value set corresponding to the second target instruction does not contain old slot values, and the old slot values are the slot values in the historical user instructions corresponding to the changed slots.
2. The multi-scene semantic understanding method as described in claim 1, characterized in that, The step of searching for a second keyword that matches the first keyword in the mapping dictionary to obtain the search results includes: Calculate the character similarity between the first keyword and each of the second keywords to obtain their respective character similarity. Calculate the semantic similarity between the first keyword and each of the second keywords to obtain their respective semantic similarity. The similarity of each character is weighted and summed with its corresponding semantic similarity to obtain the matching degree between each second keyword and the first keyword; The search results are determined based on the matching degree between each of the second keywords and the first keyword.
3. The multi-scene semantic understanding method as described in claim 1, characterized in that, If, based on the function type and the first keyword, no second keyword with a matching degree greater than a second matching degree threshold can be found in the mapping dictionary, the method further includes: Select the N second keywords from the mapping dictionary that have the highest matching degree with the first keyword; where N is a natural number and N≤3; Based on the standard instructions corresponding to each of the N second keywords, prompt information is generated to instruct the user to provide supplementary instructions; Obtain supplementary instructions provided by the user, select a target standard instruction from the standard instructions corresponding to each of the N second keywords based on the supplementary instructions, and determine the target standard instruction as the semantic understanding result of the current user instruction.
4. The multi-scene semantic understanding method as described in claim 1, characterized in that, Also includes: If the instruction type of the current user instruction is an entertainment control instruction or an information query instruction, the structured semantic information corresponding to the current user instruction is obtained based on the sequence generation model; the structured semantic information includes domain tags and multiple slot values; Based on the structured semantic information, the corresponding application programming interface is invoked to execute the operation corresponding to the current user instruction.
5. The multi-scene semantic understanding method as described in claim 1, characterized in that, Also includes: If the current user instruction belongs to the instruction type of task reminder instruction, then perform the following operations: Extract timestamp information from the current user command; Extract the third keyword from the current user command; Store the third keyword and the timestamp information in the database; Start the scheduled task to read the third keyword from the database and execute the task corresponding to the third keyword when the preset time arrives; The preset time is obtained based on the timestamp information.
6. A multi-scene semantic understanding device, characterized in that, include: The instruction acquisition module is used to acquire the current user's instructions; The instruction classification module is used to classify the current user instruction based on a text classification model to obtain the instruction type to which the current user instruction belongs; The semantic understanding module is used for: If the instruction type of the current user instruction is a device control instruction or a system setting instruction, extract the first keyword from the current user instruction; search for the second keyword that matches the first keyword in the mapping dictionary to obtain the search result; the mapping dictionary includes standard instructions corresponding to multiple function types, and a set of second keywords corresponding to each standard instruction; If the search results show that there is a second keyword in the mapping dictionary that matches the first keyword, the standard instruction corresponding to the second keyword is used as the semantic understanding result of the current user instruction; When searching for a second keyword that matches the first keyword from the mapping dictionary, the semantic understanding module is specifically used for: Find the second keyword in the mapping dictionary whose matching degree with the first keyword is greater than the first matching degree threshold; If the search results show that there is no second keyword matching the first keyword in the mapping dictionary, the semantic understanding module is further used for: A fusion vector is generated based on the current user command and historical user commands. The fusion vector is then input into a one-dimensional convolutional model to obtain the function type corresponding to the current user command. Based on the function type and the first keyword, a mapping dictionary is searched to obtain a second keyword with a matching degree greater than the first keyword and a second matching degree threshold. The standard instruction corresponding to the second keyword is used as the semantic understanding result of the current user instruction; the second matching degree threshold is less than the first matching degree threshold. There are multiple historical user commands, and the semantic understanding module is specifically used for: Based on specified rules, extract the slot values corresponding to multiple slots from the current user command to obtain the current slot value set; The current set of slot values is compared with the most recent set of historical slot values, and the slots that have changed are saved to the target set of slot values; the most recent set of historical slot values is the set of slot values corresponding to the most recent round of historical user commands; If the target slot set is empty, then the first target instruction is selected from multiple historical user instructions; a fusion vector is generated based on the current user instruction and the first target instruction; the slot value set corresponding to the first target instruction contains the current slot value set; If the target slot set is not empty, then the second target instruction is selected from multiple historical user instructions; a fusion vector is generated based on the current user instruction and the second target instruction; the slot value set corresponding to the second target instruction does not contain the old slot value, and the old slot value is the slot value in the historical user instruction corresponding to the slot that has changed.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Smart home equipment control method and device, and electronic equipment
CN115421396A
Instruction response method and device, equipment and medium
CN119577227A
