A matching-based automatic scene generation method and a computer device
By using the automatic scene generation method based on matching in smart homes, combined with the control operations of database and large language models, the problem of insufficient scene generation accuracy is solved, higher accuracy and security are achieved, and the flexibility of scene generation is improved. and convenience.
Patent Information
- Application Number
- CN202411341608.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2044-09-25
AI Technical Summary
In the existing smart home scene generation methods, the scene generation accuracy is insufficient when using a large language model, and the flexibility and convenience are insufficient, which cannot effectively solve users' flexible scenario needs.
Using the automatic scene generation method based on matching, the user-set target scene name is matched in the scene database, the scene results with high semantic similarity are filtered out, and the successful device control operation is generated by the database. The successful device cannot be matched by The trained large language model generates control operations and integrates the target scenarios.
It improves the accuracy and security of scene generation, ensures that the control operations of all devices are omitted, reduces the situation of automatic generation of errors in large language models, and improves the flexibility and convenience of automatic scene generation.
Smart Images

Figure CN118861385B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of smart home, and in particular relates to an automatic scene generation method based on matching and a computer device. Background Art
[0002] Scene creation is one of the important functions in the field of smart home. There are two common methods: manual setting and template configuration. Manual setting is more troublesome and requires manual operation by the user, which is less user-friendly. Template configuration is set according to relevant rules, which is more convenient than manual setting, but it can only be generated according to fixed templates and is not flexible enough.
[0003] In order to solve the above technical problems and improve the flexibility and convenience of smart home scene generation, the Chinese invention patent application with application publication number CN117687314A proposes a method for generating smart home control scenes based on a large language model. This method improves the accuracy of the large language model in scene generation by splitting the scene generation process into multiple subtasks and setting prompt words for each task. However, although the large language model is artificial intelligence, it is not a human after all. The accuracy of the scene generated in the end is still unsatisfactory, and it is difficult to solve this problem from the large model itself. Summary of the invention
[0004] The purpose of the present invention is to provide a matching-based automatic scene generation method and a computer device to solve the technical problem of insufficient scene generation accuracy when using a large language model for automatic scene generation.
[0005] To solve the above technical problems, the present invention provides a matching-based automatic scene generation method, comprising the following steps:
[0006] According to the target scene name set by the user, a match is performed in the scene database to obtain a matching scene result; all devices in the matching scene result are stored in a matching list, and a device list is generated according to the devices in the target scene. If there is a device in the matching list that is similar to a device in the device list, the device is considered to be matched successfully, otherwise the device is considered to be matched unsuccessfully;
[0007] For a successfully matched device, the control operation of the device in the matching list is used as its control operation; for a failed matched device, the trained large language model is used to generate its control operation;
[0008] Integrate the control operations of all devices to generate the target scene.
[0009] Furthermore, the process of generating a device list according to the devices in the target scenario includes:
[0010] 1) Obtain a device type set including all device types in the matched scene results according to the devices;
[0011] 2) Store all devices in the target scene that are in the device type set into the device list;
[0012] Accordingly, the automatic scene generation method further includes: for a device in the target scene whose type is not in the device type set, considering that the match fails.
[0013] Furthermore, a method for obtaining a matching scene result by matching in a scene database according to a target scene name set by a user includes:
[0014] According to the target scene name set by the user, a match is performed in the scene database to obtain scene results whose matching degree meets the requirements; the scene results whose matching degree meets the requirements are further screened, and the results of the further screening are used as the matching scene results.
[0015] Furthermore, the method for further screening the obtained scenario results is: sorting the scenario results that meet the requirements according to the number of times they are used, and selecting the scenario results with a higher number of times as the results of further screening.
[0016] Furthermore, a method for obtaining a matching scene result by matching in a scene database according to a target scene name set by a user includes:
[0017] A match is performed in the scene database according to the target scene name set by the user, and a scene result whose matching degree meets the requirements is obtained as the matched scene result.
[0018] Furthermore, the method for matching the devices in the matching list and the device list is as follows: constructing character strings for the devices in the matching list and the device list according to their room names and device names respectively, and then performing similarity matching on the devices in the matching list and the device list according to the constructed character strings.
[0019] Furthermore, the method for determining whether the degree of matching meets the requirements is as follows: the semantic similarity between the scene name of the matching result and the target generated scene name is calculated; if the semantic similarity is greater than the similarity threshold, the scene result meets the requirements; otherwise, the scene result does not meet the requirements.
[0020] Furthermore, a method for performing similarity matching on devices in the matching list and the device list based on the constructed character string is as follows: firstly, text similarity matching is performed on the character strings of the devices in the matching list and the device list, and matching results with higher matching degrees are selected for semantic similarity matching.
[0021] Furthermore, the method of integrating the control operations of all devices to generate the target scene is: merging the device control operations generated by matching and the device control operations generated by the large language model, and then filtering out the device control operations that do not conform to the logic of the target scene, and using the control operations of all filtered devices as the result of automatic scene generation.
[0022] The present invention is an improved invention creation, and its beneficial effects are as follows: the automatic scene generation method based on matching of the present invention screens the devices in the scene, uses database matching to generate their control operations for the devices that can be matched by the database, and uses a large model to generate their control operations for the devices that cannot be generated by database matching. Specifically, a device list and a matching list are first generated, and the device list and the matching list are matched. For the successfully matched devices, their control operations are generated according to the matching results, and for the devices that cannot be matched successfully, the trained large language model is used to generate their control operations; the accuracy is high, and the large language model rarely generates errors automatically, so the database matching is used first to generate the device's control operations, and the automatic scene generation is more accurate, safer and more reliable; for the devices that cannot be generated by database matching, the large language model is used to generate their control operations, ensuring that there will be no omissions in the control operations generated for all devices.
[0023] To solve the above technical problems, the present invention also provides a computer device, including a processor, a memory and a computer program stored in the memory, wherein the processor is used to execute the computer program to implement the method steps described in the matching-based automatic scene generation method of the present invention.
[0024] The present invention is an improved invention creation, and its beneficial effects are as follows: the automatic scene generation method based on matching of the present invention screens the devices in the scene, uses database matching to generate their control operations for the devices that can be matched by the database, and uses a large model to generate their control operations for the devices that cannot be generated by database matching. Specifically, a device list and a matching list are first generated, and the device list and the matching list are matched. For the successfully matched devices, their control operations are generated according to the matching results, and for the devices that cannot be matched successfully, the trained large language model is used to generate their control operations; the accuracy is high, and the large language model rarely generates errors automatically, so the database matching is used first to generate the device's control operations, and the automatic scene generation is more accurate, safer and more reliable; for the devices that cannot be generated by database matching, the large language model is used to generate their control operations, ensuring that there will be no omissions in the control operations generated for all devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 It is a flowchart of an automatic scene generation method based on matching and a large language model according to an embodiment of the method of the present invention. DETAILED DESCRIPTION
[0026] The present invention discloses an automatic scene generation method based on matching and a computer device. The automatic scene generation method based on matching of the present invention selects the devices in the scene, uses database matching to generate control operations for devices that can be matched by database, and uses a large model to generate control operations for devices that cannot be matched by database. Specifically, a device list and a matching list are first generated, and the device list and the matching list are matched. For devices that are successfully matched, their control operations are generated according to the matching results. For devices that cannot be matched successfully, the trained large language model is used to generate their control operations. The accuracy is high, and errors in automatic generation of the large language model rarely occur. Therefore, database matching is used first to generate device control operations, and the automatic scene generation is more accurate, safer and more reliable. For devices that cannot be generated by database matching, the large language model is used to generate their control operations, ensuring that the control operations of all devices are generated without omissions.
[0027] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is further described in detail below with reference to the accompanying drawings and embodiments.
[0028] Method Example:
[0029] For reference Figure 1 The automatic scene generation method based on matching of the present invention comprises the following steps:
[0030] Step 1: The algorithm receives the scene name and related information and requests semantic services.
[0031] The algorithm receives the scene name and other relevant information of the scene input by the user, and requests the semantic model in the model to perform semantic services.
[0032] Step 2: The semantic model performs semantic processing on the scene name according to the request.
[0033] Step 3: Find historical scene data with similar semantics from the database. The specific method is as follows:
[0034] According to the name of the scene that the user wants to generate, the scene with semantically similar scene name created by other users is queried from the database using semantic matching, the semantic similarity between the name of the scene that the user wants to generate and the scene name in the database is calculated, and the first 10 results in the database whose semantic similarity of a scene is greater than the similarity threshold are taken as the scene results whose matching degree meets the requirements. In this embodiment, the first 10 results whose semantic similarity is greater than the threshold are taken, and the specific number of results can be freely set as other implementation schemes. When there are less than 10 results whose semantic similarity is greater than the threshold, all results whose semantic similarity is greater than the threshold are taken. The judgment conditions for meeting the requirements can also be set. For example, the semantic similarity is no longer required to be greater than the threshold, and the similarity is sorted from high to low in a straight line, and the first 10 results are taken as the results that meet the requirements.
[0035] In this embodiment, the semantic similarity between the target scene name and the scene name in the database is used for matching, and the accuracy of automatic scene generation is higher. As other implementation methods, other matching methods can also be used, such as matching according to the degree of overlap of devices.
[0036] The retrieved scenes that meet the requirements are sorted according to the number of times the scenes are used. The more times the scenes are used, the higher the ranking is. The scenes whose number of times of use are ranked before (including the set number of times of use) the set number of times of use ranking (third place) are taken as the matching scene results. All devices in the matching scene results are saved as a match list (match_list); in this embodiment, further screening is performed by sorting according to the number of times of use. As other implementation methods, sorting and screening can also be performed according to other parameters such as the last time of use. Even without screening, the results of matching by scene name are directly used as the final matching scene results.
[0037] Step 4: Match device behavior from the historical database. The specific method is:
[0038] All devices in the match list (match_list) are traversed to generate a device type set (match_type_set) including all device types in the match list (match_list).
[0039] Retrieve all devices in the room involved in the current user-set scene and generate a device list (device_list). In this embodiment, the devices whose types exist in the device type set (match_type_set) among all the devices in the room involved in the user-set scene are stored in the device list (device_list); and the devices whose types do not exist in the device type set (match_type_set) are stored in the large model generated device list (device_llm_list). The devices in the large model generated device list (device_llm_list) are all devices whose control operations cannot be generated using matching, and can be considered as devices that have failed matching.
[0040] In this embodiment, when generating the device list, screening is performed in advance, and the devices existing in the device type set are stored in the device list, which can save the amount of data processing for subsequent matching. As another implementation, all devices in the room involved in the current user setting scene can also be directly stored in the device list.
[0041] Construct strings for the device list (device_list) and the match list (match_list) according to the rule of "room name + device name", and use the Bi-gram and LCS rules in order to match the text similarity, and then filter out the matching results with a matching degree above the set threshold, and use the language model mapping to match the semantic similarity to obtain the final matching result. If there is a device in the match list that meets the requirements for the matching degree with a device in the device list, the device in the device list is considered to be matched successfully, and the control operation of the corresponding device in the match list is used as the control operation of the device in the device list. The devices in the device list that do not meet the requirements are added to the large model generated device list (device_llm_list). For those that meet the conditions, the corresponding device control operation in the match list (match_list) is taken out as the control operation of the device to be matched, and the matching part is completed.
[0042] The present invention first uses the Bi-gram rule to divide the text into two consecutive sequences of letters or phonemes, and performs an approximate matching degree between the two texts. Then the LCS (Longest Common Subsequence) rule is used to mainly compare the sequence similarity. In the text similarity comparison task, the main focus is on finding the longest common subsequence between the two texts. This method is particularly suitable for comparing texts of different lengths, and can ignore some irrelevant parts and focus on finding relatively long common parts.
[0043] Semantic similarity screening of language model mappings:
[0044] Use language models such as BERT (Bidirectional Encoder Representations from Transformers) or GPT (Generative Pre-trained Transformer) to convert text into vector representations, and then calculate the similarity between vectors to measure semantic similarity for further matching.
[0045] These models learn the contextual information of the language through pre-training, which can better capture the semantic relationship between words and sentences, and then evaluate the semantic similarity of texts.
[0046] Step 5: Request scene generation service.
[0047] Step 6: Use the private domain large model (large language model) to generate operations for devices that failed to match. The specific method is:
[0048] Extract the names and operability lists of all devices in the device list (device_llm_list) generated by the large model and feed them into the trained large language model.
[0049] Extract the results generated by the large language model, match the device with the corresponding operation, and remove the wrong items. This completes the large language model part.
[0050] The training process of the large language model is as follows:
[0051] 1. Generate training data containing knowledge (automatic scenario generation examples) based on historical data extraction;
[0052] Second, generate training data that does not contain knowledge (automatic scenario generation examples) based on historical data extraction;
[0053] 3. Fuse the two data sets to train the large model end-to-end. This can prevent the large model from overfitting.
[0054] Fourth, conduct training and increase weight_decay during the training process to further reduce the probability of overfitting of the model.
[0055] In order to prevent the overfitting problem of the trained large model, training data that does not contain knowledge (automatic scene generation examples) is added to the training data of this embodiment.
[0056] Step 7: Integrate the results of the matching part and the large language model part.
[0057] Step 8: Verification processing and screening.
[0058] Filter out the following items that do not conform to the logic of the target scene, such as: repeatedly turning the device on and off, turning off the device but performing operations that require it to be turned on, air conditioning heating in summer and cooling in winter, turning on multiple speaker devices at the same time to perform different playback operations, and increasing the brightness of the lights when watching a movie.
[0059] Step nine: Combine the generated control operations of all user devices to obtain a scene that matches the user's target scene, and output the scene.
[0060] Step 10: The Natural Language Processing (NLP) model asks the user whether to execute the generated scenario.
[0061] Through the above-mentioned method steps, the matching-based automatic scene generation method of the present invention preferentially uses semantic matching to search for control operations of devices in scene values with similar names in the database, and uses them as user control operations. For devices whose control operations cannot be generated by semantic matching, a large language model is used to generate their control operations due to the data in the database.
[0062] Computer equipment example:
[0063] The computer device of the present invention includes a processor, a memory, and a computer program stored in the memory, wherein the processor is used to execute the computer program to implement the steps of the matching-based automatic scene generation method described in the method embodiment of the present invention. The specific steps, principles, and beneficial effects of the method have been described in detail in the method embodiment, and will not be repeated in this embodiment.
[0064] The processor may be a microprocessor MCU, a programmable logic device FPGA or other processing device. The memory may be various memories, such as RAM, ROM or the like.
Claims
1. A matching-based automatic scene generation method, characterized in that: The following steps are involved: According to the target scene name set by the user, a match is performed in the scene database to obtain a matching scene result; all devices in the matching scene result are stored in a matching list, and a device list is generated according to the devices in the target scene. If there is a device in the matching list that is similar to a device in the device list, the device is considered to be matched successfully, otherwise the device is considered to be matched unsuccessfully; For a successfully matched device, the control operation of the device in the matching list is used as its control operation; for a failed matched device, the trained large language model is used to generate its control operation; Integrate the control operations of all devices to generate the target scene.
2. The matching-based automatic scene generation method according to claim 1, characterized in that: The process of generating a device list based on the devices in the target scenario includes: 1) Obtain a device type set including all device types in the matched scene results according to the devices; 2) Store all devices in the target scene that are in the device type set into the device list; Accordingly, the automatic scene generation method further includes: for a device in the target scene whose type is not in the device type set, considering that the match fails.
3. The matching-based automatic scene generation method according to claim 1, characterized in that: The method of matching the target scene name set by the user in the scene database to obtain the matching scene result includes: According to the target scene name set by the user, a match is performed in the scene database to obtain scene results whose matching degree meets the requirements; the scene results whose matching degree meets the requirements are further screened, and the results of the further screening are used as the matching scene results.
4. The matching-based automatic scene generation method according to claim 3, characterized in that: The method for further screening the obtained scenario results is: sorting the scenario results that meet the requirements according to the number of times they are used, and selecting the scenario results with a higher number of times as the results of further screening.
5. The matching-based automatic scene generation method according to claim 1, characterized in that: The method of matching the target scene name set by the user in the scene database to obtain the matching scene result includes: A match is performed in the scene database according to the target scene name set by the user, and a scene result whose matching degree meets the requirements is obtained as the matched scene result.
6. The matching-based automatic scene generation method according to claim 1, characterized in that: The method for matching the devices in the matching list and the device list is as follows: constructing character strings for the devices in the matching list and the device list according to their room names and device names respectively, and then performing similarity matching on the devices in the matching list and the device list according to the constructed character strings.
7. The matching-based automatic scene generation method according to any one of claims 3 to 5, characterized in that: The method for judging whether the matching degree meets the requirements is: calculating the semantic similarity between the scene name of the matching result and the target generated scene name, if the semantic similarity is greater than the similarity threshold, the scene result meets the requirements, otherwise the scene result does not meet the requirements.
8. The matching-based automatic scene generation method according to claim 6, characterized in that: The method for performing similarity matching on the devices in the matching list and the device list according to the constructed character string is as follows: firstly, text similarity matching is performed on the character strings of the devices in the matching list and the device list, and then matching results with higher matching degree are selected for semantic similarity matching.
9. The matching-based automatic scene generation method according to any one of claims 1 to 6, characterized in that: The method for integrating the control operations of all devices to generate a target scene is: merging the device control operations generated by matching and the device control operations generated by the large language model, and then filtering out the device control operations that do not conform to the logic of the target scene, and using the control operations of all filtered devices as the result of automatic scene generation.
10. A computer device comprising a processor, a memory and a computer program stored in the memory, characterized in that: The processor is used to execute the computer program to implement the steps of the matching-based automatic scene generation method according to any one of claims 1 to 9.
