Internet of Things system TAP rule generation method and device based on large language model
By defining a common device description format and TAP format, using large language model and Translator components, the problem of poor user experience and low accuracy of IoT systems when creating and deploying TAP rules is solved, and a fast and accurate IoT is achieved Application creation, suitable for different IoT platforms.
Patent Information
- Application Number
- CN202411029900.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2025-01-07
AI Technical Summary
When creating and deploying TAP rules, existing IoT systems have poor user experience due to heterogeneous hardware devices and different software operating systems, low generation accuracy, and do not support interaction, making it difficult to achieve fast and convenient IoT application creation.
Define common device description formats and TAP formats, use large language model (LLM) to convert user needs into general TAP, and translate them into the format required by the actual platform through the Translator component to achieve deployment, including extracting information from device model files and filtering Related content, generate TAPs in appropriate formats, and convert and deploy them through the Multi-Agent system and Translator components.
It improves the accuracy of LLM generation of TAPs, reduces tokens consumption, realizes the user's ability to create TAPs in natural language, saves manpower and time, and is suitable for different IoT platforms, with wide applicability.
Smart Images

Figure CN119271184A_ABST
Abstract
Description
Technical Field
[0001] The present invention provides a method and device for generating TAP rules for an Internet of Things system based on a large language model, which can create TAP through natural language and deploy it to an actual Internet of Things platform. Background Art
[0002] The IoT system connects various sensors and actuators through the network, changing the way users interact with the physical world. The introduction of user-oriented IoT programming frameworks (such as IFTTT and Microsoft Flow) allows users to create IoT applications more conveniently, allowing the use of simple "IF trigger, THEN action" rule programming (called trigger-command programming, TAP). However, due to heterogeneous hardware devices and different software operations, this programming framework is not as convenient as expected, and the rapid creation and deployment of IoT applications is still an important challenge.
[0003] Smart home is a typical scenario with a large number of TAP rules. For example, the TAP of the rule "If someone passes by, turn on the light" can be expressed as "IF Motion_sensor.motion_state == True THEN Light.on = True". However, this is just a restatement of the logic of the rule in a statement closer to machine execution, and cannot be directly used for platform deployment. In actual applications, users often need to adapt to different IoT systems to write actual TAPs. Although there are currently some technologies that allow users to input natural language in a certain format, process it with NLP technology, and extract key information to generate TAPs, the user's input format is limited and the generation accuracy is not high. In addition, there is no support for interaction during the generation process, resulting in a poor user experience.
[0004] The excellent language understanding and text generation capabilities demonstrated by the Large Language Model (LLM) can help users generate TAP rules through natural language. However, the accuracy of LLM in generating TAP for the actual platform directly based on user needs, device and system information is not high, because different IoT device description formats may be different, and the TAP rule formats of different IoT systems may also be different, which may not be suitable for LLM to understand and generate. Therefore, it is particularly important to design a widely applicable method to implement TAP rule generation, improve the accuracy of LLM TAP generation, and reduce the tokens consumed by LLM. Summary of the invention
[0005] In order to solve the above shortcomings of the background technology, the present invention proposes a method and device for generating IoT TAP rules based on a large language model. The core of the method of the present invention is to define a universal device description format and TAP format, and use LLM to convert user requirements into a universal TAP, and then translate it into the format required by the actual platform through the translator component to achieve deployment.
[0006] The first aspect of the present invention proposes a method for generating TAP rules for an Internet of Things system based on LLM, comprising the following steps:
[0007] (1) Extract information from the physical model file of the device and organize it into a suitable format;
[0008] (2) Filter relevant content from device information based on user needs;
[0009] (3) Generate TAP in a suitable format based on LLM according to user requirements and relevant device information;
[0010] (4) The TAP format generated by LLM is converted into the TAP of the actual platform through the Translator component for deployment.
[0011] Wherein, step 1 specifically includes:
[0012] Step 1.1: Collect the physical models of the devices connected to the actual platform and find the corresponding interfaces of the devices on the platform. The physical model fully defines the functions of the devices, and these functions will be mapped to various interfaces of the platform. When generating TAP, it is based on the physical model instead of the interface description on the actual platform, so that it can be compatible with different platforms.
[0013] Step 1.2: The formats of the object models of different devices may be slightly different due to differences in manufacturers and other reasons. Based on the existing format of the object model, the present invention proposes a simplified JSON format, omitting the manufacturer and some other unnecessary information, and focusing on the services provided by the device. The JSON object corresponding to each device is responsible for the description, which contains id (self-assigned device unique identifier), area, type, description, and services, where each field of services identifies a service, and each service contains several fields that identify a property, and the property contains information such as description, value format, and read permissions.
[0014] Among them, step 2 narrows the selection range of devices and filters out relevant information from all device information obtained in step 1 according to user needs, thereby reducing the input tokens of LLM during subsequent TAP generation, avoiding the interference of irrelevant information on TAP generation, and improving the accuracy of TAP generation.
[0015] Step 2.1: Filter device information according to user needs. This is divided into two granularities: device granularity and service granularity. Extract two different granularity filtering criteria for each device. At the device granularity, each device corresponds to a text containing its area, type, and services information. At the service granularity, each service corresponds to a text containing its property information. These criteria are converted into corresponding vectors through the Embedding model and stored. When the user puts forward a requirement, the requirement is also converted into a corresponding vector.
[0016] Step 2.2: Perform information screening at the device granularity, calculate the cosine similarity between the device basis and user needs in the vector space, and then cluster the similarity through DBSCAN, dynamically select the appropriate threshold for screening, retain the device information above the threshold, and omit the device information below the threshold.
[0017] Step 2.3: Similarly, information screening is performed at the service granularity, and the cosine similarity between the service basis of the retained devices and the user needs in the vector space is calculated. Then the similarity is clustered through DBSCAN, and the appropriate threshold is dynamically selected for screening. Service information above the threshold is retained, and service information below the threshold is omitted.
[0018] Among them, step 3 builds a Multi-Agent system to generate a universal TAP format according to user needs and related device information. The Multi-Agent system proposed in the present invention includes three basic agents for preprocessing, TAP generation and TAP evaluation respectively. Each agent is built based on ReAct and CoT technology. Agents communicate by publishing messages in the Environment and request user input to confirm and supplement information when necessary. Each agent follows a similar template and operating paradigm, which is convenient for dynamically adjusting or adding agents to adapt to specific needs.
[0019] Step 3.1: This invention defines a universal TAP format, which is simple and clear enough for LLM generation, and contains complete information to achieve unbiased translation into the format of the actual platform. The TAP is represented by a json, which contains 3 fields: Trigger, Condition and Action. The basic elements in each field are composed of id.service.property <op> <value>,The elements in Trigger and Action are separated by commas, and the elements in Condition are combined by logical symbols and brackets.
[0020] Step 3.2: The preprocessing agent inputs user requirements and related device information, parses user requirements, extracts the device ID, service, and property required by the target TAP, and then publishes a message to the Environment to trigger the TAP generation task.
[0021] Step 3.3: The TAP generation agent organizes the device service and property into the defined TAP format according to user requirements and the extracted property information, and determines the <op>and <value>, and then publishes a message to the Environment to trigger the TAP evaluation task.
[0022] Step 3.4: The TAP evaluation agent verifies whether the generated TAP is consistent with user requirements, ensures that there are no format errors in the TAP, and publishes a message to output the final TAP.
[0023] Among them, step 4 is based on the correspondence between the object model and the platform interface obtained in step 1, and translates the generated universal TAP format into the format required by the actual platform through a Translator component and deploys it.
[0024] The second aspect of the present invention provides an Internet of Things system TAP rule generation device based on a large language model, which realizes information extraction of Internet of Things devices, generation and actual deployment through TAP, including a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, it is used to implement a method for generating TAP rules for an Internet of Things system based on LLM of the present invention.
[0025] The third aspect of the present invention relates to a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the LLM-based TAP rule generation method for an Internet of Things system of the present invention.
[0026] The core of the present invention is to define a universal device description format and TAP format, convert user requirements into a universal TAP with the help of LLM, and then translate into the format required by the actual platform to achieve deployment.
[0027] The advantages of the present invention are that users can create TAPs in natural language, saving manpower and time for simple repetitive work, and are not limited to a specific IoT platform. The present invention can be applied to IoT systems that need to create a large number of TAPs in different scenarios through appropriate adjustments, and has wide applicability. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the examples of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0029] Figure 1 It is the workflow diagram of the method of the present invention.
[0030] Figure 2 This is an example diagram of device information extraction by the method of the present invention.
[0031] Figure 3 This is an example diagram of device information screening of the method of the present invention.
[0032] Figure 4 It is a schematic diagram of the Multi-Agent system in the method of the present invention.
[0033] Figure 5 This is a working example diagram of the Translator in the method of the present invention. DETAILED DESCRIPTION
[0034] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of the present invention.
[0035] Example 1
[0036] Reference Figure 1 , the present invention proposes a method for generating TAP rules for an IoT system based on LLM. The core of the present invention is to define a universal device description format and TAP format, and use LLM to convert user requirements into a universal TAP, and then translate it into the format required by the actual platform to achieve deployment. Through this conversion, users can create and deploy TAPs through natural language, and it is not limited to one IoT system, and has wide applicability.
[0037] The specific steps include:
[0038] Step 1: Extract information from the device's physical model file and organize it into a suitable format, such as Figure 2 shown.
[0039] Step 1.1: Collect the physical models of the devices connected to the actual platform and find the corresponding interfaces of the devices on the platform.
[0040] Step 1.2: The formats of the object models of different devices may be slightly different due to differences in manufacturers and other reasons. Based on the existing format of the object model, the present invention proposes a simplified JSON format, omitting the manufacturer and some other unnecessary information, and focusing on the services provided by the device. The JSON object corresponding to each device is responsible for the description, which contains id (self-assigned device unique identifier), area, type, description, and services, where each field of services identifies a service, and each service contains several fields that identify a property, and the property contains description, value format, and read permission information.
[0041] Step 2: Narrow the scope of device selection and filter out relevant information from all device information obtained in step 1 according to user needs, thereby reducing the input tokens of LLM during subsequent TAP generation and avoiding interference of irrelevant information on TAP generation, such as Figure 3 shown.
[0042] Step 2.1: Filter device information according to user needs. This is divided into two granularities: device granularity and service granularity. Extract two different granularity filtering criteria for each device. At the device granularity, each device corresponds to a text containing its area, type, and services information. At the service granularity, each service corresponds to a text containing its property information. These criteria are converted into corresponding vectors through the Embedding model and stored. When a user raises a requirement, the requirement is also converted into a corresponding vector.
[0043] Step 2.2: Perform information screening at the device granularity, calculate the cosine similarity between the device basis and user needs in the vector space, and then cluster the similarity through DBSCAN, dynamically select the appropriate threshold for screening, retain the device information above the threshold, and omit the device information below the threshold.
[0044] Step 2.3: Similarly, information screening is performed at the service granularity, and the cosine similarity between the service basis of the retained devices and the user needs in the vector space is calculated. Then the similarity is clustered through DBSCAN, and the appropriate threshold is dynamically selected for screening. Service information above the threshold is retained, and service information below the threshold is omitted.
[0045] Step 3: If Figure 4 As shown in the figure, a Multi-Agent system is constructed to generate a universal TAP format according to user needs and related device information. The Multi-Agent system proposed in the present invention includes three basic agents for preprocessing, TAP generation and TAP evaluation respectively. Each agent is constructed based on ReAct and CoT technology, and agents communicate by publishing messages in the Environment. Each agent follows a similar template and operating paradigm, which is convenient for dynamically adjusting or adding agents to adapt to specific needs.
[0046] Step 3.1: This invention defines a universal TAP format, which is simple and clear enough for LLM generation, and contains complete information to achieve unbiased translation into the format of the actual platform. The TAP is represented by a json, which contains 3 fields: Trigger, Condition and Action. The basic elements in each field are composed of id.service.property <op> <value>,The elements in Trigger and Action are separated by commas, and the elements in Condition are combined by logical symbols and brackets.
[0047] Step 3.2: The preprocessing agent inputs user requirements and related device information, parses user requirements, extracts the device ID, service, and property required by the target TAP, and then publishes a message to the Environment to trigger the TAP generation task.
[0048] Step 3.3: The TAP generation agent organizes the device service and property into the defined TAP format according to user requirements and the extracted property information, and determines the <op>and <value>, and then publishes a message to the Environment to trigger the TAP evaluation task.
[0049] Step 3.4: The TAP evaluation agent verifies whether the generated TAP is consistent with user requirements and ensures that there are no format errors in the TAP. It publishes a message to output the final TAP and ends the task.
[0050] Step 4: Figure 5 As shown, based on the correspondence between the physical model and the platform interface obtained in step 1, a Translator component is used to translate the final generated TAP into the format required by the actual platform and deploy it.
[0051] Example 2
[0052] The present embodiment relates to a TAP rule generation device for an Internet of Things system based on a large language model, which realizes information extraction of Internet of Things devices, generation and actual deployment through TAP, and implements a TAP rule generation method for an Internet of Things system based on LLM of Example 1, including a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, it is used to implement a TAP rule generation method for an Internet of Things system based on LLM of the present invention.
[0053] Example 3
[0054] This embodiment relates to a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the LLM-based Internet of Things system TAP rule generation method described in Example 1 is implemented.
[0055] The contents described in the embodiments of this specification are merely an enumeration of the implementation forms of the inventive concept. The protection scope of the present invention should not be regarded as limited to the specific forms described in the embodiments. The protection scope of the present invention also extends to equivalent technical means that can be conceived by those skilled in the art based on the inventive concept.< / value> < / op> < / value> < / op> < / value> < / op> < / value> < / op>
Claims
1. A method for generating TAP rules for an Internet of Things system based on a large language model, comprising the following steps: (1) Extract information from the physical model file of the device and organize it into a suitable format; (2) Filter relevant content from device information based on user needs; (3) Generate TAP in a suitable format based on LLM according to user requirements and relevant device information; (4) The TAP format generated by LLM is converted into the TAP of the actual platform through the Translator component for deployment.
2. The method for generating TAP rules for an Internet of Things system based on LLM as claimed in claim 1, characterized in that: Step 1 specifically includes: Step 1.1: Collect the physical models of the devices connected to the actual platform and find the corresponding interfaces of the devices on the platform; the physical model fully defines the functions of the devices, and these functions will be mapped to various interfaces of the platform; when generating TAP, it is based on the physical model instead of the interface description on the actual platform, so that it can be compatible with different platforms; Step 1.2: Due to differences in manufacturers and other reasons, the formats of object models of different devices may be slightly different. Based on the existing object model format, a simplified JSON format is proposed, which omits the manufacturer and some other unnecessary information and focuses on the services provided by the device. The JSON object corresponding to each device is responsible for the description, which contains id (self-assigned device unique identifier), area, type, description, and services. Each field of services identifies a service, and each service contains several fields that identify a property. The property contains information such as description, value format, and read permissions.
3. The method for generating TAP rules for an Internet of Things system based on LLM as claimed in claim 1, characterized in that: Step 2 narrows the selection range of devices and selects relevant information from all device information obtained in step 1 according to user needs, thereby reducing the input tokens of LLM during subsequent TAP generation, avoiding interference of irrelevant information on TAP generation, and improving the accuracy of TAP generation; specifically, it includes: Step 2.1: Filter device information according to user needs. This is divided into two granularities: device granularity and service granularity. Extract two different granularity filtering criteria for each device. At the device granularity, each device corresponds to a text containing its area, type, and services information. At the service granularity, each service corresponds to a text containing its property information. These criteria are converted into corresponding vectors through the Embedding model and stored. When the user puts forward a requirement, the requirement is also converted into a corresponding vector. Step 2.2: Perform device-level information screening, calculate the cosine similarity between device basis and user requirements in the vector space, and then cluster the similarity through DBSCAN, dynamically select the appropriate threshold for screening, retain the device information above the threshold, and omit the device information below the threshold; Step 2.3: Similarly, information screening is performed at the service granularity, and the cosine similarity between the service basis of the retained devices and the user needs in the vector space is calculated. Then the similarity is clustered through DBSCAN, and the appropriate threshold is dynamically selected for screening. Service information above the threshold is retained, and service information below the threshold is omitted.
4. The method for generating TAP rules for an Internet of Things system based on LLM as claimed in claim 1, characterized in that: Step 3 builds a Multi-Agent system to generate a universal TAP format based on user needs and relevant device information; the proposed Multi-Agent system contains three basic agents for preprocessing, TAP generation and TAP evaluation respectively; each agent is built based on ReAct and CoT technology, and agents communicate by publishing messages in the Environment and requesting user input to confirm and supplement information when necessary; each agent follows a similar template and operating paradigm, which is convenient for dynamic adjustment or adding agents to adapt to specific needs; Specifically include: Step 3.1: Define a common TAP format that is simple and clear enough for LLM to generate, and contains complete information to achieve unbiased translation into the format of the actual platform; the TAP is represented by a json, which contains 3 fields: Trigger, Condition and Action. The basic elements in each field are composed of id.service.property <op> <value> ,The elements in Trigger and Action are separated by commas, and the elements in Condition are combined by logical symbols and brackets;< / value> < / op> Step 3.2: The preprocessing agent inputs user requirements and related device information, parses the user requirements, extracts the device ID, service and property required by the target TAP, and then publishes a message to the Environment to trigger the TAP generation task; Step 3.3: The TAP generation agent organizes the device service and property into the defined TAP format according to user requirements and the extracted property information, and determines the <op>and <value> , then publish a message to the Environment to trigger the TAP evaluation task;< / value> < / op> Step 3.4: The TAP evaluation agent verifies whether the generated TAP is consistent with user requirements and ensures that there are no format errors in the TAP. It publishes a message to output the final TAP and ends the task.
5. The method for generating TAP rules for an Internet of Things system based on LLM as claimed in claim 1, characterized in that: In step 4, based on the correspondence between the object model and the platform interface obtained in step 1, a Translator component is used to translate the generated universal TAP format into the format required by the actual platform and deploy it.
6. A TAP rule generation device for an Internet of Things system based on a large language model, characterized in that: It comprises a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, it is used to implement a TAP rule generation method for an Internet of Things system based on LLM as described in any one of claims 1 to 5.
7. A computer-readable storage medium, characterized in that: A program is stored thereon, and when the program is executed by a processor, the LLM-based Internet of Things system TAP rule generation method described in any one of claims 1 to 5 is implemented.
Citation Information
Cited By
Iot lightweight rule detection method and system based on multi-granularity attention distillation
CN122802289A
Iot lightweight rule detection method and system based on multi-granularity attention distillation
CN122802289B