Knowledge graph reasoning learning method for smart home dialogue system
By combining a multi-head attention mechanism with a graph neural network, a knowledge graph for smart homes is constructed, which solves the hardware and privacy constraints of lightweight devices, enables precise collaborative management of devices and intelligent decision-making in complex scenarios, and improves the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- LINYI UNIVERSITY
- Filing Date
- 2026-02-03
- Publication Date
- 2026-05-15
AI Technical Summary
Lightweight smart home dialogue devices are limited by hardware and privacy constraints, making it difficult to support complex algorithm models and large-scale data processing. Traditional dialogue logic cannot handle the multi-intent association needs in complex scenarios, leading to semantic understanding bias and response logic breakage. Existing knowledge graph reasoning methods are inefficient and have difficulty capturing complex structural information.
By employing a multi-head attention mechanism combined with graph neural networks, a smart home knowledge graph is constructed to deeply mine the direct associations between entities and relationships, enabling accurate reasoning. The multi-layer cascaded structure and Gumbel-Top-K sampling technology are used to dynamically adjust the importance weights of entities, thereby improving reasoning efficiency and accuracy.
It enhances the collaborative management capabilities of devices in smart home scenarios, enabling precise, rich, and real-time dialogue and interaction, thereby improving user experience and the intelligence of device decision-making.
Smart Images

Figure CN122047489A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of smart home technology, and in particular to a knowledge graph reasoning and learning method for smart home dialogue systems. Background Technology
[0002] With the deep integration of IoT technology and artificial intelligence, the smart home industry is developing rapidly. Among them, lightweight smart home interactive devices, with their voice interaction and convenient control features, have become the core entry point for daily information interaction and device management in the home. Users can use these devices to perform various home operations such as adjusting lights, controlling temperature, and starting and stopping appliances, greatly improving the convenience of life.
[0003] However, the expansion of application scenarios and the deepening of functions of lightweight smart home dialogue devices are still constrained by two core factors, seriously affecting user experience and industrial development potential. Firstly, hardware and privacy limitations create significant bottlenecks. Lightweight devices, in order to balance portability, cost, and energy consumption, generally use low-computing-power chips and limited storage resources, making it difficult to support the operation of complex algorithm models and the real-time processing of large-scale data. At the same time, users are increasingly concerned about personal privacy and information security in their home environments. Devices cannot collect and upload sensitive data such as user dialogue logs and operation records without restriction, resulting in limited data availability and further restricting the intelligent decision-making capabilities of dialogue systems. Secondly, traditional dialogue logic has inherent limitations. Traditional smart home dialogue systems mostly rely on preset rule bases or simple semantic matching algorithms, which can only handle single interaction needs in structured, fixed scenarios. When faced with fuzzy user queries, multi-intent related needs, or complex scenario inquiries, they are prone to semantic understanding biases and broken response logic, failing to achieve deep intelligent human-computer interaction. With the development of artificial intelligence, knowledge graphs are widely used in many fields, but they suffer from incomplete information, requiring effective reasoning methods to mine implicit knowledge. Traditional reasoning methods each have their limitations. Rule-based reasoning relies on manually defined rules, resulting in low efficiency and poor scalability. While embedding-based reasoning is computationally efficient, it has limited ability to express semantic relationships and struggles to capture complex structural information. Graph neural networks (GNNs) have significant advantages in processing graph-structured data; however, in knowledge graph reasoning, they face challenges in multi-source information fusion and focusing on key information. Attention mechanisms, which allocate weights based on information importance, have yielded significant results in other fields. Combining GNNs with GNNs for knowledge graph reasoning holds promise for overcoming the shortcomings of existing methods and improving reasoning performance.
[0004] Therefore, this invention proposes a knowledge graph reasoning learning method for smart home dialogue systems to solve the above problems. Summary of the Invention
[0005] This invention addresses the shortcomings of existing technologies by developing a knowledge graph reasoning and learning method for smart home dialogue systems. By deeply mining the direct and indirect relationships between entities and relationships in the smart home knowledge graph, this invention can achieve accurate reasoning, improve reasoning efficiency, better realize device collaborative management in smart home scenarios, and enhance user experience.
[0006] The technical solution of this invention to solve the technical problem is a knowledge graph reasoning and learning method for smart home dialogue systems, comprising the following steps: S1. Collect structured, semi-structured and unstructured data to construct a knowledge graph dataset, load the knowledge graph dataset and generate corresponding reverse triples based on the data in the knowledge graph dataset; Structured data originates from the manuals and product specifications of devices in smart home scenarios, semi-structured data originates from user dialogue logs and operation records in smart home scenarios, and unstructured data originates from user feedback and troubleshooting in smart home scenarios. S2. Construct a knowledge graph for training based on the data from the smart home knowledge graph dataset and the generated inverse triples. Read the query information and initialize the entity set of the 0th layer propagation path of the query entity in the query information; S3. The entity set of the propagation path of the query entity at layer 0 is processed layer by layer through the multi-head attention mechanism to obtain the entity set of each layer. Then, the message and edge weight are calculated through the multi-head attention mechanism based on the entity, relationship and position information in the entity set of each layer. The message is then updated according to the edge weight to obtain the updated message of each triple. Finally, the updated messages are concatenated and linearly mapped to obtain the target entity. S4. Define a scoring function to calculate the score of the target entity. Calculate the probability of generating the target entity based on its score. Use Gumbel-Top-K sampling technique to sample the top K highest-scoring entities from the probability distribution of the target entities and merge them with the entity set of the previous layer to form the entity set of the current layer. S5. Repeat steps S3-S4 until the propagation path depth reaches... At that time, the first The complete entity set of each layer, calculate the first layer respectively. The target entity with the highest score in the layer entity set is selected as the final target entity to be queried.
[0007] S1 is as follows: Load the knowledge graph dataset. Each data point in the knowledge graph dataset is represented as a triple. A set of triplets is constructed based on each triplet. ,in, Indicates the head entity. Indicates the tail entity. express and Relationship; Describe the set of triples The set of head and tail entities, the entity categories in the set include space entities, device entities, device attribute entities, operation instruction entities, scene mode entities, fault type entities and user demand entities in the smart home scenario; Describe the set of triples China-US relations The set contains relationships categorized as belonging, control, attribute adjustment, scene linkage, fault association, and status query. According to the set of triples Generate a set of reverse triples , , express and Relationship, Represents the set of reverse triples China-US relations The set, , Describe the set of triples The number of relations between China and the United States exist The triple represents the head entity. exist The triple represents the tail entity.
[0008] S2 is as follows: S2.1, The set of triples formed by the data in the knowledge graph dataset. and based on triplet sets The generated set of reverse triples Generate a set of triples for training. , ; Based on the set of triples used for training Building knowledge graphs The specific process is as follows: Set the triplet set In and Mapped to knowledge graph The nodes in the set of triples The relationships in the graph are mapped to a knowledge graph. From the edges in the graph, we obtain the knowledge graph. , , Representation of knowledge graph A set of relationships; S2.2 Read query information through smart home dialogue devices , , Indicates the entity being queried. Indicates the target entity to be queried. This indicates the relationship between the queried entity and the entity to be queried, for the queried entity The set of entities in the propagation path at layer 0. Perform initialization; Smart home interactive devices include smart speakers, smart control panels, and voice modules for smart appliances.
[0009] S3 is as follows: The multi-head attention mechanism employs a multi-layered cascading structure to process the entity set along the 0th layer propagation path of the query entity, layer by layer. During message passing at each layer, according to the first layer Layer Entity Collection From knowledge graphs The set of direct neighbor entities queried in the middle Calculate the new target entity set ,from Remove from The entity in, and guarantee The calculation formula is as follows: ; from The triplet information obtained from the middle is represented as , , The number of target entities is The number of triples is , No. Query entities of the layer Indicates the first The target entity of the layer, the first target entity of layer Indicates the first The query entity of the layer, Indicates the first Query entities of the layer and the target entity of layer The relationship between them; for Each triple in the array will Embedded feature vector representation , Embedded feature vector representation , Embedded feature vector representation and location information The message is obtained by performing calculations using a multi-head attention mechanism. Location information , The initial value is 1, where , , This represents the embedding dimension of the entity vector. The embedding dimension of the resulting message vector is represented by the following: , , and The inputs are fed into the multi-head attention mechanism module to calculate the edge weights. By edge weight Regarding the message The update is performed, and then all the updated messages are concatenated to obtain the target entity based on the concatenated messages.
[0010] The specific computational process of the multi-head attention mechanism is as follows: (1) , , respectively with By splicing the components, the features are obtained separately. , , , Then, a linear transformation is performed to obtain the query matrix of the current layer's multi-head attention. Key matrix Sum matrix The calculation formula is as follows: , , , , , , in, This indicates a splicing operation. , , These represent the trainable weight matrices used for the query matrix, key matrix, and value matrix, respectively. , , Let represent the trainable bias vectors used for the query matrix, key matrix, and value matrix, respectively. , Indicates the number of long positions; (2) , , Divided into Size, Attention weights are calculated for each head, specifically through matrix multiplication and... Function to calculate attention weights , The calculation formula is as follows: , in, Indicates transpose; Next and Perform a weighted summation to obtain the weighted output. , Then through a fully connected layer Restored to the original dimensions, the calculation formula in the fully connected layer is as follows: , in, Indicates the relationships between nodes. , This represents the operation of expanding a matrix into row vectors. This represents a trainable weight matrix. , This represents a trainable bias vector. ; (3) Through a linear layer pair Projection, and through The function normalizes its values to (0,1) and then uses a gating mechanism to fuse them. and The message indicated The calculation formula is as follows: , , in, Represents the weight vector. express function, Represents element-wise product; (4) , , and The inputs are processed together using multi-head attention. The calculation method for each input is the same as in steps (1)-(3), but the computational parameters are independent of each other. After multi-head attention calculation, the inputs are processed by ReLU activation function, linear mapping, and... The edge weights are obtained after the function processes the edge layer by layer. edge weight It is a one-dimensional vector with edge weights. The calculation formula is as follows: , in, This represents multi-head attention computation; (5) Based on edge weights Update message Generate updated information The calculation formula is as follows: ; For the l Layer Repeat steps (1)-(4) to obtain three triples. One reason Received message Then, the message is updated, and subsequently, the updated messages of all candidate entities in that layer are concatenated to obtain the messages of all target entities in that layer. The formula is as follows: , Messages pointing to the same target entity are aggregated and, after a linear mapping, the target entity is obtained. Feature representation The calculation formula is as follows: , in, , express l The number of target entities in the layer. This represents the trainable weight matrix, and ACG represents the summation operation. Indicates query information The target entity to be queried .
[0011] S4 is as follows: For target entity Define the scoring function The calculation formula is as follows: , in, Indicates trainable parameters, Representation device; Based on score Calculate and generate target entity probability distribution The calculation formula is as follows: , in, This represents the temperature parameter used to adjust the smoothness of the distribution. , express l All candidate target entities in the layer; Using Gumbel-Top-K technology to analyze the target entity probability distribution The K highest-scoring target entities before sampling are denoted as And the sampled entities are compared with the historical entity set. Merge, form l The complete set of entities in a layer is calculated using the following formula: , Update the feature representation of the target entity using the GRU gating mechanism. The updated data is then passed to the next layer of the neural network in the multi-head attention mechanism.
[0012] S5 is detailed below: Repeat steps S3-S4 until the propagation path depth reaches At that time, the first The complete entity collection of a layer Through the first The complete entity collection of a layer Feature representation of target entities Predict a score for each target entity, and select the target entity with the highest score as the final target entity to be queried. The formula for calculating the target entity score is as follows: , in, This represents a trainable weight matrix.
[0013] The effects described in the invention are merely those of the embodiments, and not all the effects of the invention. The above technical solutions have the following advantages or beneficial effects: This invention combines triples with a multi-head attention mechanism. Specifically, it concatenates and fuses the relation feature vector of the query triple with the corresponding layer feature vector to form the query matrix Q in the attention mechanism; it concatenates and fuses the head entity feature vector of the query with the layer feature vector to form the key matrix K in the attention mechanism; and it concatenates and fuses the feature vectors of possible tail entities in the path with the layer feature vector to form the value matrix V. Simultaneously, it introduces a layer decay factor, dynamically adjusting the importance weights of entities at different levels by taking the reciprocal of the layer number. This enables automatic decay of the influence of high-level entities and dynamic weight calculation for different level paths, enhancing the modeling ability of coefficient relationships. It provides an extensible and general framework for complex relational reasoning, thereby improving the semantic accuracy, computational efficiency, and interpretability in knowledge graph reasoning. This invention also employs a dual-path parallel multi-head attention mechanism architecture in the attention calculation module. The parameter matrices of the two multi-head attention sub-modules are independent of each other and they perform forward propagation calculations separately. The first attention sub-module is dedicated to calculating the message vector in the propagation path, and the second attention sub-module is dedicated to calculating the weight coefficients of the edges. The dual-path attention mechanism can decouple the functions of message passing and edge weight calculation through independent parameter space learning, providing an interpretable and scalable solution for complex relationship modeling.
[0014] In summary, by employing a multi-head attention mechanism, this invention captures the correlation information between nodes and their edges in the propagation path, which can effectively improve the accuracy of graph neural network knowledge graph reasoning and learning, thereby achieving accurate, rich, and real-time dialogue interaction and providing convenience for users' lives. Attached Figure Description
[0015] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used together with the embodiments of the invention to explain the invention and do not constitute a limitation thereof.
[0016] Figure 1 This is a schematic diagram of the method flow of the present invention.
[0017] Figure 2 This is a bar chart comparing the performance of the method of the present invention with that of existing methods.
[0018] Figure 3 Example of a knowledge graph for querying.
[0019] Figure 4 This is an example of the reasoning and learning process in a knowledge graph. Detailed Implementation
[0020] To clearly illustrate the technical features of this solution, the invention will be described in detail below through specific implementation methods and in conjunction with the accompanying drawings.
[0021] Example 1 This invention addresses the core pain points of lightweight smart home dialogue devices, which are constrained by hardware and privacy limitations to incorporate large language models, and the weak knowledge reasoning and insufficient dialogue accuracy of existing solutions. It provides a graph neural network knowledge graph reasoning learning method. By constructing a domain knowledge graph and reasoning modules, it deeply mines "entity-relationship" association information, enabling rapid reasoning and accurate responses to user needs such as knowledge queries and device control. Figure 1 As shown, a knowledge graph reasoning learning method for smart home dialogue systems has the following specific steps: S1. Collect structured, semi-structured and unstructured data to construct a knowledge graph dataset, load the knowledge graph dataset and generate corresponding reverse triples based on the data in the knowledge graph dataset; Structured data originates from the manuals and product specifications of devices in smart home scenarios, semi-structured data originates from user dialogue logs and operation records in smart home scenarios, and unstructured data originates from user feedback and troubleshooting in smart home scenarios. S2. Construct a knowledge graph for training based on the data from the smart home knowledge graph dataset and the generated inverse triples. Read the query information and initialize the entity set of the 0th layer propagation path of the query entity in the query information; S3. The entity set of the propagation path of the query entity at layer 0 is processed layer by layer through the multi-head attention mechanism to obtain the entity set of each layer. Then, the message and edge weight are calculated through the multi-head attention mechanism based on the entity, relationship and position information in the entity set of each layer. The message is then updated according to the edge weight to obtain the updated message of each triple. Finally, the updated messages are concatenated and linearly mapped to obtain the target entity. S4. Define a scoring function to calculate the score of the target entity. Calculate the probability of generating the target entity based on its score. Use Gumbel-Top-K sampling technique to sample the top K highest-scoring entities from the probability distribution of the target entities and merge them with the entity set of the previous layer to form the entity set of the current layer. S5. Repeat steps S3-S4 until the propagation path depth reaches... At that time, the first The complete entity set of each layer, calculate the first layer respectively. The target entity with the highest score in the layer entity set is selected as the final target entity to be queried.
[0022] In a specific implementation, S1 is as follows: Load the knowledge graph dataset. Each data point in the knowledge graph dataset is represented as a triple. A set of triplets is constructed based on each triplet. ,in, Indicates the head entity. Indicates the tail entity. express and Relationship; Describe the set of triples The set of head and tail entities, the entity categories in the set include space entities, device entities, device attribute entities, operation instruction entities, scene mode entities, fault type entities and user demand entities in the smart home scenario; Describe the set of triples China-US relations The set contains relationships categorized as belonging, control, attribute adjustment, scene linkage, fault association, and status query. The physical spaces include bedrooms, living rooms, kitchens, balconies, studies, and bathrooms; The equipment includes smart lights, smart air conditioners, smart curtains, smart robot vacuum cleaners, etc. Device attributes include the brightness of lights, the temperature of air conditioners, the wind speed of fans, and the power level of the device entity. Operation command entities include open, close, increase, decrease, timer, etc.; Scene mode entities include sleep mode, children's mode, movie viewing mode, away from home mode, etc.; Fault types include offline, low battery, connection failure, etc. User needs include energy saving, quiet operation, and air purification, etc. According to the set of triples Generate a set of reverse triples , , express and Relationship, Represents the set of reverse triples China-US relations The set, , Describe the set of triples The number of relations between China and the United States exist The triple represents the head entity. exist The triple represents the tail entity.
[0023] In a specific implementation, S2 is as follows: S2.1, The set of triples formed by the data in the knowledge graph dataset. and based on triplet sets The generated set of reverse triples Generate a set of triples for training. , ; Based on the set of triples used for training Building knowledge graphs The specific process is as follows: Set the triplet set In and Mapped to knowledge graph The nodes in the set of triples The relationships in the graph are mapped to a knowledge graph. From the edges in the graph, we obtain the knowledge graph. , , Representation of knowledge graph A set of relationships; S2.2 Read query information through smart home dialogue devices , , Indicates the entity being queried. Indicates the target entity to be queried. This indicates the relationship between the queried entity and the entity to be queried, for the queried entity The set of entities in the propagation path at layer 0. Perform initialization; Smart home interactive devices include smart speakers, smart control panels, and voice modules for smart appliances.
[0024] In a specific implementation, S3 is as follows: The multi-head attention mechanism employs a multi-layered cascading structure to process the entity set along the 0th layer propagation path of the query entity, layer by layer. During message passing at each layer, according to the first layer Layer Entity Collection From knowledge graphs The set of direct neighbor entities queried in the middle Calculate the new target entity set ,from Remove from The entity in, and guarantee The calculation formula is as follows: ; from The triplet information obtained from the middle is represented as , , The number of target entities is The number of triples is , No. Query entities of the layer Indicates the first The target entity of the layer, the first target entity of layer Indicates the first The query entity of the layer, Indicates the first Query entities of the layer and the target entity of layer The relationship between them; for Each triple in the array will Embedded feature vector representation , Embedded feature vector representation , Embedded feature vector representation and location information The message is obtained by performing calculations using a multi-head attention mechanism. Location information , The initial value is 1, where , , This represents the embedding dimension of the entity vector. The embedding dimension of the resulting message vector is represented by the following: , , and The inputs are fed into the multi-head attention mechanism module to calculate the edge weights. By edge weight Regarding the message The update is performed, and then all the updated messages are concatenated to obtain the target entity based on the concatenated messages.
[0025] In a specific implementation, the computational process of the multi-head attention mechanism is as follows: (1) , , respectively with By splicing the components, the features are obtained separately. , , , Then, a linear transformation is performed to obtain the query matrix of the current layer's multi-head attention. Key matrix Sum matrix The calculation formula is as follows: , , , , , , in, This indicates a splicing operation. , , These represent the trainable weight matrices used for the query matrix, key matrix, and value matrix, respectively. , , Let represent the trainable bias vectors used for the query matrix, key matrix, and value matrix, respectively. , Indicates the number of long positions; (2) , , Divided into Size, Attention weights are calculated for each head, specifically through matrix multiplication and... Function to calculate attention weights , The calculation formula is as follows: , in, Indicates transpose; Next and Perform a weighted summation to obtain the weighted output. , Then through a fully connected layer Restored to the original dimensions, the calculation formula in the fully connected layer is as follows: , in, Indicates the relationships between nodes. , This represents the operation of expanding a matrix into row vectors. This represents a trainable weight matrix. , This represents a trainable bias vector. ; (3) Through a linear layer pair Projection, and through The function normalizes its values to (0,1) and then uses a gating mechanism to fuse them. and The message indicated The calculation formula is as follows: , , in, Represents the weight vector. express function, Represents element-wise product; (4) , , and The inputs are processed together using multi-head attention. The calculation method for each input is the same as in steps (1)-(3), but the computational parameters are independent of each other. After multi-head attention calculation, the inputs are processed by ReLU activation function, linear mapping, and... The edge weights are obtained after the function processes the edge layer by layer. edge weight It is a one-dimensional vector with edge weights. The calculation formula is as follows: , in, This represents multi-head attention computation; (5) Based on edge weights Update message Generate updated information The calculation formula is as follows: ; For the l Layer Repeat steps (1)-(4) to obtain three triples. One reason Received message Then, the message is updated, and subsequently, the updated messages of all candidate entities in that layer are concatenated to obtain the messages of all target entities in that layer. The formula is as follows: , Messages pointing to the same target entity are aggregated and, after a linear mapping, the target entity is obtained. Feature representation The calculation formula is as follows: , in, , express l The number of target entities in the layer. This represents the trainable weight matrix, and ACG represents the summation operation. Indicates query information The target entity to be queried .
[0026] In a specific implementation, S4 is as follows: For target entity Define the scoring function The calculation formula is as follows: , in, Indicates trainable parameters, Representation device; Based on score Calculate and generate target entity probability distribution The calculation formula is as follows: , in, This represents the temperature parameter used to adjust the smoothness of the distribution. , express l All candidate target entities in the layer; Using Gumbel-Top-K technology to analyze the target entity probability distribution The K highest-scoring target entities before sampling are denoted as And the sampled entities are compared with the historical entity set. Merge, form l The complete set of entities in a layer is calculated using the following formula: , Update the feature representation of the target entity using the GRU gating mechanism. The updated data is then passed to the next layer of the neural network in the multi-head attention mechanism.
[0027] In a specific implementation, S5 is as follows: Repeat steps S3-S4 until the propagation path depth reaches At that time, the first The complete entity collection of a layer Through the first The complete entity collection of a layer Feature representation of target entities Predict a score for each target entity, and select the target entity with the highest score as the final target entity to be queried. The formula for calculating the target entity score is as follows: , in, This represents a trainable weight matrix.
[0028] Example 2 To demonstrate that the performance of the method in this invention is superior to existing technologies, experiments were conducted on the WN18RR knowledge graph inference dataset to demonstrate the performance improvement of the method and the current best knowledge graph inference models. The current best knowledge graph inference models include ConvE (Convolutional Knowledge Graph Embedding), CompGCN (Combined Graph Convolutional Network), NBFNet (Neural Bellman-Ford Network), RED-GNN (Relation Evolution Detection Graph Neural Network), and AdaProp (Adaptive Propagation Model). The evaluation metrics were MRR (MRR represents the average of the inverse ranking of correct predictions; a smaller value indicates a higher ranking) and Hit@k (Hit@k represents the proportion of correct predictions within the top-k; a larger value is better, with k taking values of 1 and 10 respectively). (See Table 1 and...) Figure 2 It can be seen that the solution of the present invention has a more obvious advantage in reasoning ability, and the method of the present invention has higher prediction accuracy and better performance.
[0029] Table 1. Performance comparison of the method of this invention with the current best knowledge graph reasoning model on the WN18RR dataset in reasoning tasks. Example 3 To demonstrate the application effect of the method of the present invention, it is applied to a smart home system. Since the linkage rules between devices in a smart home system (such as "if the temperature sensor detects a high temperature, the air conditioner will turn on automatically") usually rely on manual pre-defined rules or simple rule engines, it is difficult to handle complex scenarios (such as multi-device collaboration, user habit learning, etc.). Therefore, the graph neural network knowledge graph reasoning method based on the attention mechanism proposed in this invention is applied to a smart home system. By constructing a smart home knowledge graph, the implicit relationships between devices can be automatically mined, and more intelligent decision-making can be achieved.
[0030] The specific operation process is as follows: Construct a smart home knowledge graph that includes entities such as environmental sensing, human status, and home appliances. This includes triples such as: (temperature sensor, detection, high temperature), (human sensor, detected, no one), (air conditioner, function is, cooling), (indoor high temperature when people are present, optimal adjustment action, air conditioner), (indoor high temperature when people are present, secondary adjustment action, fan), (no one, appropriate action, shut down unnecessary equipment), etc. Inverse triples are generated based on these triples to enhance graph connectivity, for example: (high temperature, detected, temperature sensor), (cooling, performed by the device, air conditioner).
[0031] Given a specific home scenario query: "The indoor temperature is currently high, and the system has detected that someone is home. What device should be activated to adjust the environment?", such as... Figure 3 The image shows an example of a knowledge graph for querying. This natural language query is then transformed into a structured query as defined in this invention: query= Among them, the query entity For "indoor high temperature when people are present", query the relationship. For "optimal adjustment action", It is the target entity to be reasoned about (i.e., the specific equipment action to be performed).
[0032] The system performs inference according to the method described in this invention (steps S1-S5): Initialize the set of entities for the propagation path at level 0. .
[0033] The system uses knowledge graphs In this process, starting with the set of entities, we explore the associated triples, such as (indoor high temperature when people are present, optimal adjustment action, air conditioner), (indoor high temperature when people are present, secondary adjustment action, fan), etc. At each layer l, the invention's unique dual-path multi-head attention mechanism begins to operate: one path calculates the "message" m propagating along different relational paths, which integrates the query relation (optimal adjustment action), the current layer entity... (e.g., "indoor high temperature when people are present"), path relationships and hierarchical information; another path independently calculates the "edge weight" s of each path, dynamically assessing the importance of the path to the current query; the message is updated using edge weights to effectively focus on the path most relevant to "indoor high temperature when people are present", filtering out noise.
[0034] By using Gumbel-Top-K sampling, the K candidate entities with the highest probabilities are retained at each layer (e.g., the first layer might yield {air conditioner, fan}), forming a new set of entities. The state of these entities is then updated using GRU, and the message is passed to the next layer. This process simulates the agent's stepwise, focused exploration.
[0035] Once the propagation reaches a preset depth of L layers, the final score is calculated for all candidate target entities in the last layer of entity set.
[0036] Finally, the system calculates the score for each candidate target entity. For example, the device entity "air conditioner" (corresponding to the action "turn on air conditioner") scores 0.92, the device entity "fan" scores 0.06, and the device entity "humidifier" scores 0.02. The system selects "air conditioner" with the highest score as the final inferred target entity. The reasoning process is as follows: Figure 4 As shown.
[0037] This result demonstrates that the present invention, by abstracting the state of "high temperature and people" into the scene entity "indoor high temperature when people are present" in the knowledge graph, and using a dual-path attention mechanism to perform deep reasoning and weight differentiation on different adjustment actions ("optimal adjustment action" and "secondary adjustment action") in this scene, can ultimately make accurate decisions on the most suitable device action (starting the air conditioner) for the current complex scene, rather than simply triggering preset rules, thus demonstrating its effectiveness in achieving intelligent and adaptive decision-making in complex smart home scenarios.
[0038] Although the specific embodiments of the invention have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of the invention. Based on the technical solutions of the invention, various modifications or variations that can be made by those skilled in the art without creative effort are still within the scope of protection of the invention.
Claims
1. A knowledge graph reasoning learning method for smart home dialogue systems, characterized in that, Includes the following steps: S1. Collect structured, semi-structured and unstructured data in smart home scenarios to build a knowledge graph dataset, load the knowledge graph dataset and generate corresponding inverse triples based on the data in the knowledge graph dataset; Structured data originates from the manuals and product specifications of devices in smart home scenarios, semi-structured data originates from user dialogue logs and operation records in smart home scenarios, and unstructured data originates from user feedback and troubleshooting in smart home scenarios. S2. Construct a knowledge graph for training based on the data from the smart home knowledge graph dataset and the generated inverse triples. Read the query information and initialize the entity set of the 0th layer propagation path of the query entity in the query information; S3. The entity set of the propagation path of the query entity at layer 0 is processed layer by layer through the multi-head attention mechanism to obtain the entity set of each layer. Then, the message and edge weight are calculated through the multi-head attention mechanism based on the entity, relationship and position information in the entity set of each layer. The message is then updated according to the edge weight to obtain the updated message of each triple. Finally, the updated messages are concatenated and linearly mapped to obtain the target entity. S4. Define a scoring function to calculate the score of the target entity. Calculate the probability of generating the target entity based on its score. Use Gumbel-Top-K sampling technique to sample the top K highest-scoring entities from the probability distribution of the target entities and merge them with the entity set of the previous layer to form the entity set of the current layer. S5. Repeat steps S3-S4 until the propagation path depth reaches... At that time, the first The complete entity set of each layer, calculate the first layer respectively. The target entity with the highest score in the layer entity set is selected as the final target entity to be queried.
2. The knowledge graph reasoning and learning method for a smart home dialogue system according to claim 1, characterized in that, S1 is as follows: Load the knowledge graph dataset. Each data point in the knowledge graph dataset is represented as a triple. A set of triplets is constructed based on each triplet. ,in, Indicates the head entity. Indicates the tail entity. express and Relationship; Describe the set of triples The set of head and tail entities, the entity categories in the set include space entities, device entities, device attribute entities, operation instruction entities, scene mode entities, fault type entities and user demand entities in the smart home scenario; Describe the set of triples China-US relations The set contains relationships categorized as belonging, control, attribute adjustment, scene linkage, fault association, and status query. According to the set of triples Generate a set of reverse triples , , express and Relationship, Represents the set of reverse triples China-US relations The set, , Describe the set of triples The number of relations between China and the United States exist The triple represents the head entity. exist The triple represents the tail entity.
3. The knowledge graph reasoning and learning method for a smart home dialogue system according to claim 2, characterized in that, S2 is as follows: S2.1, The set of triples formed by the data in the knowledge graph dataset. and based on triplet sets The generated set of reverse triples Generate a set of triples for training. , ; Based on the set of triples used for training Building knowledge graphs The specific process is as follows: Set the triplet set In and Mapping to a knowledge graph The nodes in the set of triples The relationships in the graph are mapped to a knowledge graph. From the edges in the graph, we obtain the knowledge graph. , , Representation of knowledge graph A set of relationships; S2.2 Read query information through smart home dialogue devices , , Indicates the entity being queried. Indicates the target entity to be queried. This indicates the relationship between the queried entity and the entity to be queried, for the queried entity The set of entities in the propagation path at layer 0. Perform initialization; Smart home interactive devices include smart speakers, smart control panels, and voice modules for smart appliances.
4. The knowledge graph reasoning and learning method for a smart home dialogue system according to claim 3, characterized in that, S3 Specifically as follows: The multi-head attention mechanism employs a multi-layered cascading structure to process the entity set along the 0th layer propagation path of the query entity, layer by layer. During message passing at each layer, according to the first layer Layer Entity Collection From knowledge graph The set of direct neighbor entities queried in the middle Calculate the new target entity set ,from Remove from The entity in, and guarantee The calculation formula is as follows: ; from The triplet information obtained from the middle is represented as , , The number of target entities is The number of triples is , No. Query entities of the layer Indicates the first The target entity of the layer, the first target entity of layer Indicates the first The query entity of the layer, Indicates the first Query entities of the layer and the target entity of layer The relationship between them; for Each triple in the array will Embedded feature vector representation , Embedded feature vector representation , Embedded feature vector representation and location information The message is obtained by performing calculations using a multi-head attention mechanism. Location information , The initial value is 1, where , , This represents the embedding dimension of the entity vector. The embedding dimension of the resulting message vector is represented by the following: , , and The inputs are fed into the multi-head attention mechanism module to calculate the edge weights. By edge weight Regarding the message The update is performed, and then all the updated messages are concatenated to obtain the target entity based on the concatenated messages.
5. The knowledge graph reasoning and learning method for a smart home dialogue system according to claim 4, characterized in that, The specific computational process of the multi-head attention mechanism is as follows: (1) , , respectively with By splicing the components, the features are obtained separately. , , , Then, a linear transformation is performed to obtain the query matrix of the current layer's multi-head attention. Key matrix Sum matrix The calculation formula is as follows: , , , , , , in, This indicates a splicing operation. , , These represent the trainable weight matrices used for the query matrix, key matrix, and value matrix, respectively. , , Let represent the trainable bias vectors used for the query matrix, key matrix, and value matrix, respectively. , Indicates the number of long positions; (2) , , Divided into Size, Attention weights are calculated for each head, specifically through matrix multiplication and... Function to calculate attention weights , The calculation formula is as follows: , in, Indicates transpose; Next and Perform a weighted summation to obtain the weighted output. , Then through a fully connected layer Restored to the original dimensions, the calculation formula in the fully connected layer is as follows: , in, Indicates the relationships between nodes. , This represents the operation of expanding a matrix into row vectors. This represents a trainable weight matrix. , This represents a trainable bias vector. ; (3) Through a linear layer pair Projection, and through The function normalizes its values to (0,1) and then uses a gating mechanism to fuse them. and The message indicated The calculation formula is as follows: , , in, Represents the weight vector. express function, Represents element-wise product; (4) , , and The inputs are processed together using multi-head attention. The calculation method for each input is the same as in steps (1)-(3), but the computational parameters are independent of each other. After multi-head attention calculation, the inputs are processed by ReLU activation function, linear mapping, and... The edge weights are obtained after the function processes the edge layer by layer. edge weight It is a one-dimensional vector with edge weights. The calculation formula is as follows: , in, This represents multi-head attention computation; (5) Based on edge weights Update message Generate updated information The calculation formula is as follows: ; For the l Layer Repeat steps (1)-(4) to obtain three triples. One reason Received message Then, the message is updated, and subsequently, the updated messages of all candidate entities in that layer are concatenated to obtain the messages of all target entities in that layer. The formula is as follows: , Messages pointing to the same target entity are aggregated and, after a linear mapping, the target entity is obtained. Feature representation The calculation formula is as follows: , in, , express l The number of target entities in the layer. This represents the trainable weight matrix, and ACG represents the summation operation. Indicates query information The target entity to be queried .
6. The knowledge graph reasoning and learning method for a smart home dialogue system according to claim 5, characterized in that, S4 is as follows: For target entity Define the scoring function The calculation formula is as follows: , in, Indicates trainable parameters, Representation device; Based on score Calculate and generate target entity probability distribution The calculation formula is as follows: , in, This represents the temperature parameter used to adjust the smoothness of the distribution. , express l All candidate target entities in the layer; Using Gumbel-Top-K technology to analyze the target entity probability distribution The K highest-scoring target entities before sampling are denoted as And the sampled entities are compared with the historical entity set. Merge, form l The complete set of entities in a layer is calculated using the following formula: , Update the feature representation of the target entity using the GRU gating mechanism. The updated data is then passed to the next layer of the neural network in the multi-head attention mechanism.
7. The knowledge graph reasoning and learning method for a smart home dialogue system according to claim 6, characterized in that, S5 is detailed below: Repeat steps S3-S4 until the propagation path depth reaches At that time, the first The complete entity collection of a layer Through the first The complete entity collection of a layer Feature representation of target entities Predict a score for each target entity, and select the target entity with the highest score as the final target entity to be queried. The formula for calculating the target entity score is as follows: , in, This represents a trainable weight matrix.