Hybrid query method and system in smart home scene
Through a hybrid query method, using a two-dimensional attribute table and an improved KGraph algorithm to optimize index construction, the problem of low smart home retrieval efficiency is solved, fast and accurate device query is achieved, the diverse needs of users in complex scenarios are met, and query efficiency and user experience are improved.
Patent Information
- Application Number
- CN202511269570.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-08
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2045-09-08
AI Technical Summary
Existing smart home retrieval technology is inefficient when processing large-scale device data and cannot achieve real-time and rapid retrieval result feedback. In addition, the differences in data formats and communication protocols between smart devices of different brands and types increase the difficulty of unified retrieval and management. The existing retrieval methods are relatively simple and cannot meet the diverse needs of users in complex scenarios.
A hybrid query method is adopted to enhance the processing capability of structured data through conventional hybrid query mechanism and logical hybrid query mechanism. The two-dimensional attribute table and improved KGraph algorithm are used to optimize index construction. The density-adaptive connection strategy and attribute-aware entry selection are combined to achieve fast and accurate device query.
It improves the accuracy and efficiency of queries, reduces unnecessary computing overhead, can meet the complex query needs in smart home scenarios, provides flexible and comprehensive query methods, and enhances user experience.
Smart Images

Figure CN120744201A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of hybrid query technology, and in particular to a hybrid query method and system in a smart home scenario. Background Art
[0002] With the rapid development of smart home technology, the number of smart devices in homes is increasing, and their functions are becoming increasingly complex and diverse. These devices cover a wide range of categories, including smart lighting, smart appliances, smart security, and smart environmental monitoring. Each of them generates a large amount of data, including device status, usage history, and sensor data. In this context, users have an increasingly strong demand for convenient and accurate retrieval and control of home devices.
[0003] However, existing smart home search technologies have many shortcomings. For one thing, search methods are often relatively simple, mostly supporting only queries based on device names or simple attributes, making it difficult to meet the diverse needs of users in complex scenarios. For example, a user may want to retrieve all smart devices in a room whose energy consumption exceeds a certain threshold within a specific time period. Existing systems struggle to complete such queries efficiently. On the other hand, when processing large-scale device data, search efficiency is low and response time is long, making it impossible to achieve real-time and rapid search result feedback, which affects the user experience. Furthermore, differences in data formats and communication protocols between smart devices of different brands and types further increase the difficulty of unified search and management.
[0004] Hybrid queries are crucial for smart home management. They integrate structured data (such as device brand, model, and function category) with unstructured data (such as images and sound signatures of device operation), providing users with more flexible and comprehensive query methods. For example, users can use hybrid queries to find "smart surveillance devices in the living room with HD cameras that are currently powered on" or "smart speakers in the bedroom that match a specific music style."
[0005] Therefore, the present invention proposes a hybrid query method and system in a smart home scenario to solve the above problems. Summary of the Invention
[0006] In response to the shortcomings of the existing technology, the present invention develops a hybrid query method and system for smart home scenarios. The present invention enhances the processing capability of structured data, improves the accuracy of queries, reduces unnecessary computing overhead, and improves query efficiency through conventional hybrid query mechanisms and logical hybrid query mechanisms.
[0007] On the one hand, the technical solution to the technical problem of the present invention is a hybrid query method in a smart home scenario, comprising the following steps: S1. Read the data in the smart home system to build a data set. The data set contains data in multiple modes. Each data represents an object. Each object contains a high-dimensional feature vector and an attribute set. The high-dimensional feature vector is essentially an unstructured constraint, and the attribute set is essentially a structured constraint. S2. Divide the objects into subsets based on their attributes, grouping objects with the same attributes into the same subset and constructing a graph index for each subset. S3. Determine the query object and select a query method based on the type of structured constraints of the query object. If the structured constraints of the query object are a set of attributes, select a subset that matches the attributes of the query object for a conventional mixed query. If the structured constraints of the query object are attribute logical expressions, select a logical mixed query mechanism for the query.
[0008] In a specific implementation, the data set is as follows: Dataset The data modes include video, image, audio and text. Each mode contains several types of data, each data represents an object. The data set is represented as , the dataset Type of data, corresponding to objects, Describe the first objects; Dataset Any object in Each contains a high-dimensional feature vector and an attribute set, expressed as , Representation object The high-dimensional feature vector of , represents the dimension of the high-dimensional feature vector, Representation object The attribute set of , Indicates the number of categories of the attribute, Indicates the There are several attributes, each of which contains several attribute values. , express The number of attribute values in , The order in which the internal attribute values appear is random. Representation attributes Middle attribute values; from the dataset Extract high-dimensional feature vectors from video, image, audio and text data , generate attribute sets based on the content of different data sets ; According to the attribute collection The attributes in the two-dimensional attribute table are generated. Each row in the two-dimensional attribute table represents an attribute of a different category, and each column represents the attribute value corresponding to each attribute. Within each attribute type, the attribute value is mapped to a unique identifier id, which starts from 0. The id is generated in the order in which the attribute value appears in the dataset. Iterate over the dataset Extract all objects in the set, extract the attribute set of each object, traverse all attribute values in the set, and determine whether the attribute value is already stored in the two-dimensional attribute table. If not, store the attribute value and assign a unique id according to its appearance order in the type. If it exists, skip it.
[0009] In a specific implementation, subsets are divided according to the attributes of the objects: A method for partitioning attribute space based on algebraic coding is introduced to map attribute spaces of the same type into a one-dimensional identity space, and establish a bijective relationship between attribute combinations and subgraph indices. Specifically, the data set Divide into multiple subsets, where the vectors in each subset share the same set of attributes. and objects , , , , , ,like , then the object and objects are grouped into the same subset and are sorted based on the given query object Assign a unique subgraph ID to each subset ; The improved KGraph algorithm is used to optimize the subgraph construction process, specifically through density-adaptive connection strategy and attribute-aware entry selection. The optimization process is as follows: (1) Density-adaptive connection strategy: For subgraphs with smaller cardinality, the lack of connections in sparse subgraphs is compensated by increasing the out-degree of each node. 、 As the upper and lower bounds, when the out-degree of the node of the generated subgraph is less than , adjust the out-degree of the node; (2) Attribute-aware entry selection: Multiple entry points of each subgraph are maintained by calculating the distribution of node feature vectors in each subgraph in various dimensions.
[0010] In a specific implementation, select the query method: (1) If the query object It is composed of high-dimensional feature vectors and attribute sets. Its structural constraints are consistent with the objects in the data set and are all discrete attributes. Then, method 1 is selected, that is, a conventional mixed query is performed on the subset that matches the query object attributes. The query and the query object The attributes are consistent and the feature vector distance is closest objects, objects constitute the query object The result set , , , Represents a result set Middle objects; (2) If the query object It is composed of high-dimensional feature vectors and logical expressions of attributes. In this case, the structural constraints of the query object are logical operations of discrete attributes in the data set. Then, method 2 is selected, that is, the logical hybrid query mechanism is used for query. The logical expression of the attribute contains ,or , NOT! logical operation, query to meet the logical expression , and the query object The nearest objects.
[0011] In a specific implementation manner, the query method 1 is as follows: (1) Sub-graph positioning: For each query object , first resolve its attribute constraints , calculate the target subgraph identifier , using the two-dimensional attribute table to estimate the completion time ; In addition, to accelerate subgraph positioning, a global SubGraphMap hash table implemented by a perfect hash function is maintained, whose key is the subgraph identifier , the value is the metadata of the corresponding subgraph, so that Get the required information accurately within the time limit; (2) Perform two-stage routing queries within the subgraph: Within the target subgraph, differentiated routing strategies should be adopted for different stages, namely a two-stage query method. In the stage far away from the query object, its neighborhood should be quickly located, and in the stage close to the query object, a more comprehensive query should be performed. The two-stage query method is as follows: Given a smaller data As a threshold, when the distance between the point being visited and the query point is greater than When the distance is less than Then the second phase of query is executed, where phase one is coarse-grained navigation and phase two is fine-grained exploration.
[0012] In a specific implementation, the second query method is as follows: (1) Logical expression analysis: 1) Lexical analysis: Input: Original logical expression string, which contains various logical operators, attribute identifiers, and brackets, indicating the user's query intent. Processing: The input character stream is processed character by character by a finite state automaton. The finite state automaton gradually converts the character stream into a token sequence according to predefined state transition rules. Output: Normalize the Token stream and eliminate spaces and other redundant symbols in the input string; 2) Syntax Analysis: A recursive descent parser is used to construct an abstract syntax tree. The recursive descent parser recursively parses the token stream according to predefined context-free grammar rules. 3) Semantic Optimization: Apply the laws of Boolean algebra to optimize logical expressions to minimize their complexity and reduce resource consumption in subsequent calculations. Convert to disjunctive normal form: Convert the original logical expression to disjunctive normal form through a series of Boolean algebra operation rules; Eliminate redundant clauses: After converting to disjunctive normal form, optimize the expression, merge identical constraints, and delete contradictory clauses; 4) Subgraph space mapping: Input the optimized disjunctive normal form, take the sub-terms of each optimized expression, and calculate the corresponding subgraph identifier through the formula. For the entire disjunctive term, the corresponding subgraph identifier set is , n is the number of subgraphs that satisfy the logical expression, and the target subgraph identification set is finally output; (2) Parallel query of multiple subgraphs: Based on the independence of subgraphs, we concurrently execute Top-K nearest neighbor queries on multiple subgraph indexes, using an improved two-phase query algorithm within each subgraph. (3) Global result merging: a multi-way merging strategy is used to integrate the results of each subgraph; Construct a global maximum heap Max - Heap with a capacity of k. During the merging process, the local Top-K results of each subgraph are inserted into the maximum heap in sequence. Through the heap adjustment operation, the heap always keeps the current global Top-K.
[0013] On the other hand, the present invention also provides a hybrid query system in a smart home scenario, including a module for executing processing instructions of each step in a hybrid query method in a smart home scenario; Index construction module: This module performs attribute-aware data segmentation, divides the dataset into multiple subsets based on the attribute characteristics of smart home devices, and then builds a corresponding graph index on each data subset to meet different attribute retrieval requirements; Conventional hybrid query module: Utilizing subgraph index calculation and two-stage query, it quickly and accurately completes hybrid queries when attributes are fully matched, finding devices with consistent attributes and similar feature vector distances to the query object. Logical hybrid query module: By parsing logical expressions, it obtains subgraph identifiers that meet structured constraints, implements hybrid queries based on collaborative constraints of feature similarity and attribute information, and handles complex query requirements.
[0014] The effects provided in the summary of the invention are only the effects of the embodiments, rather than all the effects of the invention. The above technical solution has the following advantages or beneficial effects: (1) This invention proposes the concept of a two-dimensional attribute table and formulates new encoding rules to achieve efficient storage and convenient retrieval of smart home device attribute information. The attribute-aware data partitioning mechanism can accurately divide data subsets based on the attribute characteristics of the home, laying a solid foundation for subsequent index construction and query processing. When constructing the subgraph index, the density-adaptive connection strategy improves index connectivity, and the multi-entry point design enhances the robustness to complex queries, making it more adaptable to the complex and diverse query scenarios of smart home devices. (2) In the conventional hybrid query stage, the present invention maintains a global SubGraphMap hash table with the subgraph identifier as the key and the corresponding subgraph entry point as the value, so as to achieve fast subgraph positioning and access; adopts an improved two-stage query strategy to greatly reduce unnecessary computational overhead; prioritizes high-potential candidates to avoid falling into the local optimal trap; combines caching and early termination strategies, reasonably balances system resource consumption while ensuring service quality, and provides a guarantee for users to quickly and accurately find smart home devices.
[0015] (3) In the logical hybrid query stage, a logical query framework is constructed. By performing lexical analysis and grammatical analysis on the logical expression to construct an abstract syntax tree, the logical expression is mapped to the subgraph space, thereby reducing the computational complexity and laying a good foundation for subsequent query operations. Based on the independence of the subgraphs, a parallel architecture is designed, and an improved query algorithm is used within the subgraph to maximize the use of computing resources and improve query efficiency. The present invention can meet the complex query requirements in smart home scenarios and can search for specific devices based on the logical relationships of multiple attributes.
[0016] In summary, the present invention enhances the processing capability of structured data, improves query accuracy, reduces unnecessary computational overhead, and improves query efficiency through conventional hybrid query mechanism and logical hybrid query mechanism. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. They are used to explain the present invention together with the embodiments of the present invention and do not constitute a limitation of the present invention.
[0018] Figure 1 Schematic diagram of the method of the present invention.
[0019] Figure 2 Schematic diagram of index construction in the present invention.
[0020] Figure 3 Schematic diagram of conventional mixed query in the present invention.
[0021] Figure 4 Schematic diagram of logical hybrid query in the present invention.
[0022] Figure 5 This is an experimental comparison chart of conventional mixed queries in the present invention.
[0023] Figure 6 This is an experimental comparison chart of the logical hybrid query in the present invention. DETAILED DESCRIPTION
[0024] In order to clearly illustrate the technical features of this solution, the present invention is described in detail below through specific implementation methods and in conjunction with the accompanying drawings.
[0025] Example 1 A hybrid query method in a smart home scenario includes the following steps: S1. Read the data in the smart home system to build a data set. The data set contains data in multiple modes. Each data represents an object. Each object contains a high-dimensional feature vector and an attribute set. The high-dimensional feature vector is essentially an unstructured constraint, and the attribute set is essentially a structured constraint. S2. Divide the objects into subsets based on their attributes, grouping objects with the same attributes into the same subset and constructing a graph index for each subset. S3. Determine the query object and select a query method based on the type of structured constraints of the query object. If the structured constraints of the query object are a set of attributes, select a subset that matches the attributes of the query object for a conventional mixed query. If the structured constraints of the query object are attribute logical expressions, select a logical mixed query mechanism for the query.
[0026] In a specific implementation, the data set is as follows: Dataset The data modes include video, image, audio and text. Each mode contains several types of data, each data represents an object. The data set is represented as , the dataset Type of data, corresponding to objects, Describe the first objects; Dataset Any object in Each contains a high-dimensional feature vector and an attribute set, expressed as , Representation object The high-dimensional feature vector of , represents the dimension of the high-dimensional feature vector, Representation object The attribute set of , Indicates the number of categories of the attribute, Indicates the There are several attributes, each of which contains several attribute values. , express The number of attribute values in , The order in which the internal attribute values appear is random. Representation attributes Middle attribute values; from the dataset Extract high-dimensional feature vectors from video, image, audio and text data , generate attribute sets based on the content of different data sets ; According to the attribute collection The attributes in the two-dimensional attribute table are generated. Each row in the two-dimensional attribute table represents an attribute of a different category, and each column represents the attribute value corresponding to each attribute. Within each attribute type, the attribute value is mapped to a unique identifier id, which starts from 0. The id is generated in the order in which the attribute value appears in the dataset. Iterate over the dataset Extract all objects in the set, extract the attribute set of each object, traverse all attribute values in the set, and determine whether the attribute value is already stored in the two-dimensional attribute table. If not, store the attribute value and assign a unique id according to its appearance order in the type. If it exists, skip it.
[0027] In a specific implementation, subsets are divided according to the attributes of the objects: A method for partitioning attribute space based on algebraic coding is introduced to map attribute spaces of the same type into a one-dimensional identity space, and establish a bijective relationship between attribute combinations and subgraph indices. Specifically, the data set Divide into multiple subsets, where the vectors in each subset share the same set of attributes. and objects , , , , , ,like , then the object and objects are grouped into the same subset and are sorted based on the given query object Assign a unique subgraph ID to each subset ; The calculation formula of the subgraph ID is as follows: , in, Represents the subgraph identifier, Representation object No. The identifier of the attribute, Indicates the The number of attribute values of the type, Representation object The number of attribute categories; The improved KGraph algorithm is used to optimize the subgraph construction process, specifically through density-adaptive connection strategy and attribute-aware entry selection. The optimization process is as follows: (1) Density-adaptive connection strategy: For subgraphs with smaller cardinality, the lack of connections in sparse subgraphs is compensated by increasing the out-degree of each node. 、 As the upper and lower bounds, when the out-degree of the node of the generated subgraph is less than , adjust the out-degree of the node; The calculation formula for adjusting the node out-degree is as follows: hour, , in, represents the original out-degree of the node, Indicates the initial degree after adjustment, Indicates the number of vertices in the subgraph; (2) Attribute-aware entry selection: Multiple entry points of each subgraph are maintained by calculating the distribution of node feature vectors in each subgraph in various dimensions.
[0028] In a specific implementation, select the query method: (1) If the query object It is composed of high-dimensional feature vectors and attribute sets. Its structural constraints are consistent with the objects in the data set and are all discrete attributes. Then, method 1 is selected, that is, a conventional mixed query is performed on the subset that matches the query object attributes. The query and the query object The attributes are consistent and the feature vector distance is closest objects, objects constitute the query object The result set , , , Represents a result set Middle objects; The following conditions are met: , in, express The attribute set of represents the distance threshold, Represents the query object with objects distance; (2) If the query object It is composed of high-dimensional feature vectors and logical expressions of attributes. In this case, the structural constraints of the query object are logical operations of discrete attributes in the data set. Then, method 2 is selected, that is, the logical hybrid query mechanism is used for query. The logical expression of the attribute contains ,or , NOT! logical operation, query to meet the logical expression , and the query object The nearest objects.
[0029] The distance between any two objects is calculated as follows: , in, represents the dimension of the high-dimensional feature vector, and Represent high-dimensional feature vectors and The sth dimension of . In a specific implementation manner, the query method 1 is as follows: (1) Sub-graph positioning: For each query object , first resolve its attribute constraints , calculate the target subgraph identifier , using the two-dimensional attribute table to estimate the completion time ; In addition, to accelerate subgraph positioning, a global SubGraphMap hash table implemented by a perfect hash function is maintained, whose key is the subgraph identifier , the value is the metadata of the corresponding subgraph, so that Get the required information accurately within the time limit; (2) Perform two-stage routing queries within the subgraph: Within the target subgraph, differentiated routing strategies should be adopted for different stages, namely a two-stage query method. In the stage far away from the query object, its neighborhood should be quickly located, and in the stage close to the query object, a more comprehensive query should be performed. The two-stage query method is as follows: Given a smaller data As a threshold, when the distance between the point being visited and the query point is greater than When the distance is less than Then execute the second phase of query; Phase 1: coarse-grained navigation; In the index construction phase, multiple entry points are selected in each dimension through the entry point selection algorithm, and queries are executed in parallel starting from the entry points. Neighbors perform distance calculations, , where w is the upper limit of vertex degree. Based on the KL divergence of query vector and graph node distribution, query branches that deviate from the main distribution path are eliminated in real time. When the distance between the node and the query object is less than the threshold Then, enter the second stage of inquiry; Phase 2: Fine-grained exploration; 1) Select from stage 1 - nodes as high-potential seeds, For the final result number, high potential candidates are prioritized and the density confidence of the seed nodes is calculated. The calculation formula is as follows: , in, For the The distance between the seeds of the nodes, setting the density confidence threshold ,like , expand the seed selection range to 2 ; 2) Maintain a double-buffered priority queue: Main queue: capacity 2 , sorted by distance to the query object; Shadow Queue: Capacity , sorted by density confidence; 3) Early termination conditions: a. Before the main queue The item remains unchanged for three consecutive rounds; b. Average confidence of nodes in the shadow queue 0.9; c. Number of explored nodes 4 ; Stop when any of the conditions are met.
[0030] In a specific implementation, the second query method is as follows: (1) Logical expression analysis: 1) Lexical analysis: Input: Original logical expression string, which contains various logical operators, attribute identifiers, and brackets, indicating the user's query intent. Processing: The input character stream is processed character by character by a finite state automaton. The finite state automaton gradually converts the character stream into a token sequence according to predefined state transition rules. Output: Normalize the Token stream and eliminate spaces and other redundant symbols in the input string; 2) Syntax Analysis: A recursive descent parser is used to construct an abstract syntax tree. The recursive descent parser recursively parses the token stream according to predefined context-free grammar rules. 3) Semantic Optimization: Apply the laws of Boolean algebra to optimize logical expressions to minimize their complexity and reduce resource consumption in subsequent calculations. Convert to disjunctive normal form: Convert the original logical expression to disjunctive normal form through a series of Boolean algebra operation rules; Eliminate redundant clauses: After converting to disjunctive normal form, optimize the expression, merge identical constraints, and delete contradictory clauses; 4) Subgraph space mapping: Input the optimized disjunctive normal form, take the sub-terms of each optimized expression, and calculate the corresponding subgraph identifier through the formula. For the entire disjunctive term, the corresponding subgraph identifier set is , n is the number of subgraphs that satisfy the logical expression, and the target subgraph identification set is finally output; (2) Parallel query of multiple subgraphs: Based on the independence of subgraphs, we concurrently execute Top-K nearest neighbor queries on multiple subgraph indexes, using an improved two-phase query algorithm within each subgraph. (3) Global result merging: a multi-way merging strategy is used to integrate the results of each subgraph; Build a global maximum heap Max-Heap and set its capacity. During the merging process, insert the local Top-K results of each subgraph into the Max-Heap in sequence. Through the heap adjustment operation, the heap always keeps the current global Top-K.
[0031] Example 2 A hybrid query system in a smart home scenario, comprising a module for executing processing instructions for each step in a hybrid query method in a smart home scenario; Index construction module: This module performs attribute-aware data segmentation, divides the dataset into multiple subsets based on the attribute characteristics of smart home devices, and then builds a corresponding graph index on each data subset to meet different attribute retrieval requirements; Conventional hybrid query module: Utilizing subgraph index calculation and two-stage query, it quickly and accurately completes hybrid queries when attributes are fully matched, finding devices with consistent attributes and similar feature vector distances to the query object. Logical hybrid query module: By parsing logical expressions, it obtains subgraph identifiers that meet structured constraints, implements hybrid queries based on collaborative constraints of feature similarity and attribute information, and handles complex query requirements.
[0032] Example 3 like Figure 2 As shown, the present invention divides objects with different attributes into different subsets and constructs a graph index for each subset. These graph indexes are called "subgraphs", that is, objects in the same subgraph have the same attributes, so as to quickly narrow the query space. The present invention uses subgraph-based calculations to effectively lock them into specific subgraphs, rather than filtering the attribute values of each object in the data set individually. These subgraph index calculations effectively narrow the query scope and speed up the entire query process. Therefore, the present invention significantly improves the speed of attribute filtering, thereby improving query efficiency.
[0033] Figure 3 This is the query method described in Method 1, a conventional mixed query. After the query object is input, the query is performed based on the identifier s and the two-dimensional attribute table with the help of the SubGraphMap hash table.
[0034] Figure 4The query method shown in Method 2 is a logical hybrid query, which performs a hybrid query based on the feature vector of the query object and the attribute-based logical expression. The attribute-based logical expression L contains the relationship between multiple attributes. Therefore, it is a logical hybrid query. After logically parsing the query object, the subgraph that matches the query object is screened out, and then multiple subgraphs are queried in parallel to obtain the final result.
[0035] Example 4 Based on nine existing datasets, we conducted mixed query tasks on the proposed method and seven existing methods, and used the number of queries per second (QPS) and recall rate (Recall@k) to evaluate the efficiency and quality of the query. Nine existing datasets: SIFT1M (SIFT million vector dataset), GIST1M (GIST million vector dataset), Glove (global word vector dataset), Crawl (web crawling dataset), Audio (audio feature dataset), Msong (million song dataset), Enron (Enron email dataset), UQ-V (University of Queensland visual dataset), and Paper (academic paper dataset); There are 7 different methods available: Milvus. This method is based on "Milvus: A purpose-built vector data management system," SIGMOD 2021. Vearch. This method is based on “The design and implementation of a real-time visual search system on JD E-commerce platform,” Middleware 2018. NGT, this method is derived from “Optimization of indexing based on k-nearest neighborgraph for proximity search in high-dimensional data,” 2018. SPTAG, a method derived from “SPANN: Highly-efficient Billion-scale Approximate Nearest Neighborhood Search,” NeurIPS 2021. NHQ-NPG nswThis method is derived from “An Efficient and Robust Framework for Approximate Nearest Neighbor Search with Attribute Constraint,” NeurIPS 2023. NHQ-NPG kgraph This method is derived from “An Efficient and Robust Framework for Approximate Nearest Neighbor Search with Attribute Constraint,” NeurIPS 2023. HQANN, this method is derived from “HQANN: Efficient and robust similarity search for hybrid queries with structured and unstructured constraints,” CIKM 2022. In the same experimental environment, the conventional hybrid query and logical hybrid query in the present invention are compared with the existing methods respectively. Figure 5 The experimental results of mixed queries are shown in Figure 6 The experimental results of logical hybrid query are presented in Figure 5 and Figure 6 As can be seen, the method of the present invention (abbreviated as SLS) demonstrates superior performance on most datasets, with faster query speeds and higher recall rates. This demonstrates that while improving query speed, the present invention also ensures that the attributes of the results are consistent with those of the query objects. This demonstrates that in audio-related query scenarios, where recall accuracy is extremely critical, this method not only ensures that all returned results meet the requirements but also processes more query requests per unit time, significantly improving query efficiency.
[0036] In summary, the data format of the logical expression provided by the present invention is more in line with actual scenarios, has good integrity, and can comprehensively process logical operations; of course, this data format does not constitute a limitation to the present invention, and the present invention can also well process data formats of other multiple attribute combinations; in the smart home scenario, the hybrid query method can be used to integrate and process data from multiple smart home devices to provide more comprehensive and personalized intelligent services. The combination of smart home and hybrid index can provide a more intelligent and efficient home management and control experience.
[0037] Although the above describes the specific implementation methods of the invention in conjunction with the accompanying drawings, it does not limit the scope of protection of the invention. Based on the technical solution of the present invention, various modifications or variations that can be made by those skilled in the art without creative work are still within the scope of protection of the present invention.
Claims
1. A hybrid query method based on subgraphs in smart home scenarios, characterized by: The following steps are involved: S1. Read the data in the smart home system to build a data set. The data set contains data in multiple modes. Each data represents an object. Each object contains a high-dimensional feature vector and an attribute set. The high-dimensional feature vector is essentially an unstructured constraint, and the attribute set is essentially a structured constraint. S2. Divide the objects into subsets based on their attributes, grouping objects with the same attributes into the same subset and constructing a graph index for each subset. S3. Determine the query object and select a query method based on the type of structured constraints of the query object. If the structured constraints of the query object are a set of attributes, select a subset that matches the attributes of the query object for a conventional mixed query. If the structured constraints of the query object are attribute logical expressions, select a logical mixed query mechanism for the query.
2. The hybrid query method based on subgraphs in a smart home scenario according to claim 1 is characterized in that: The dataset is as follows: Dataset The data modes include video, image, audio and text. Each mode contains several types of data, each data represents an object. The data set is represented as , the dataset Type of data, corresponding to objects, Describe the first objects; Dataset Any object in Each contains a high-dimensional feature vector and an attribute set, expressed as , Representation object The high-dimensional feature vector of , represents the dimension of the high-dimensional feature vector, Representation object The attribute set of , Indicates the number of categories of the attribute, Indicates the There are several attributes, each of which contains several attribute values. , express The number of attribute values in , Representation attributes Middle attribute values; from the dataset Extract high-dimensional feature vectors from video, image, audio and text data , generate attribute sets based on the content of different data sets ; According to the attribute collection The attributes in the two-dimensional attribute table are generated. Each row in the two-dimensional attribute table represents an attribute of a different category, and each column represents the attribute value corresponding to each attribute. Within each attribute type, the attribute value is mapped to a unique identifier id, which starts from 0. The id is generated in the order in which the attribute value appears in the dataset. Iterate over the dataset Extract all objects in the set, extract the attribute set of each object, traverse all attribute values in the set, and determine whether the attribute value is already stored in the two-dimensional attribute table. If not, store the attribute value and assign a unique id according to its appearance order in the type. If it exists, skip it.
3. The hybrid query method based on subgraphs in a smart home scenario according to claim 2 is characterized in that: Subset objects based on their properties: A method for partitioning attribute space based on algebraic coding is introduced to map attribute spaces of the same type into a one-dimensional identity space, and establish a bijective relationship between attribute combinations and subgraph indices. Specifically, the data set Divide into multiple subsets, where the vectors in each subset share the same set of attributes. and objects , , , , , ,like , then the object and objects are grouped into the same subset and are sorted based on the given query object Assign a unique subgraph ID to each subset ; The improved KGraph algorithm is used to optimize the subgraph construction process, specifically through density-adaptive connection strategy and attribute-aware entry selection. The optimization process is as follows: (1) Density-adaptive connection strategy: For subgraphs with smaller cardinality, the lack of connections in sparse subgraphs is compensated by increasing the out-degree of each node. 、 As the upper and lower bounds, when the out-degree of the node of the generated subgraph is less than , adjust the out-degree of the node; (2) Attribute-aware entry selection: Multiple entry points of each subgraph are maintained by calculating the distribution of node feature vectors in each subgraph in various dimensions.
4. The hybrid query method based on subgraphs in a smart home scenario according to claim 3 is characterized in that: Select a query method: (1) If the query object It is composed of high-dimensional feature vectors and attribute sets. Its structural constraints are consistent with the objects in the data set and are all discrete attributes. Then, method 1 is selected, that is, a conventional mixed query is performed on the subset that matches the query object attributes. The query and the query object The attributes are consistent and the feature vector distance is closest objects, objects constitute the query object The result set , , , Represents a result set Middle objects; (2) If the query object It is composed of high-dimensional feature vectors and logical expressions of attributes. In this case, the structural constraints of the query object are logical operations of discrete attributes in the data set. Then, method 2 is selected, that is, the logical hybrid query mechanism is used for query. The logical expression of the attribute contains ,or , NOT! logical operation, query to meet the logical expression , and the query object The nearest objects.
5. The hybrid query method based on subgraphs in a smart home scenario according to claim 4 is characterized in that: Query method 1 is as follows: (1) Sub-graph positioning: For each query object , first resolve its attribute constraints , calculate the target subgraph identifier , using the two-dimensional attribute table to estimate the completion time ; In addition, to accelerate subgraph positioning, a global SubGraphMap hash table implemented by a perfect hash function is maintained, whose key is the subgraph identifier , the value is the metadata of the corresponding subgraph, so that Get the required information accurately within the time limit; (2) Perform two-stage routing queries within the subgraph: Within the target subgraph, differentiated routing strategies should be adopted for different stages, namely a two-stage query method. In the stage far away from the query object, its neighborhood should be quickly located, and in the stage close to the query object, a more comprehensive query should be performed. The two-stage query method is as follows: Given a smaller data As a threshold, when the distance between the point being visited and the query point is greater than When the distance is less than Then the second phase of query is executed, where phase one is coarse-grained navigation and phase two is fine-grained exploration.
6. The hybrid query method based on subgraphs in a smart home scenario according to claim 5 is characterized in that: The details of query method 2 are as follows: (1) Logical expression analysis: 1) Lexical analysis: Input: Original logical expression string, which contains various logical operators, attribute identifiers, and brackets, indicating the user's query intent. Processing: The input character stream is processed character by character by a finite state automaton. The finite state automaton gradually converts the character stream into a token sequence according to predefined state transition rules. Output: Normalize the Token stream and eliminate spaces and other redundant symbols in the input string; 2) Syntax Analysis: A recursive descent parser is used to construct an abstract syntax tree. The recursive descent parser recursively parses the token stream according to predefined context-free grammar rules. 3) Semantic Optimization: Apply the laws of Boolean algebra to optimize logical expressions to minimize their complexity and reduce resource consumption in subsequent calculations. Convert to disjunctive normal form: Convert the original logical expression to disjunctive normal form through a series of Boolean algebra operation rules; Eliminate redundant clauses: After converting to disjunctive normal form, optimize the expression, merge identical constraints, and delete contradictory clauses; 4) Subgraph space mapping: Input the optimized disjunctive normal form, take the sub-terms of each optimized expression, and calculate the corresponding subgraph identifier through the formula. For the entire disjunctive term, the corresponding subgraph identifier set is , n is the number of subgraphs that satisfy the logical expression, and the target subgraph identification set is finally output; (2) Parallel query of multiple subgraphs: Based on the independence of subgraphs, we concurrently execute Top-K nearest neighbor queries on multiple subgraph indexes, using an improved two-phase query algorithm within each subgraph. (3) Global result merging: a multi-way merging strategy is used to integrate the results of each subgraph; Construct a global maximum heap Max - Heap with a capacity of k. During the merging process, the local Top-K results of each subgraph are inserted into the maximum heap in sequence. Through the heap adjustment operation, the heap always keeps the current global Top-K.
7. A subgraph-based hybrid query system for smart home scenarios, characterized by: A module comprising instructions for executing the processing of each step in a subgraph-based hybrid query method in a smart home scenario as described in any one of claims 1 to 6; Index construction module: This module performs attribute-aware data segmentation, divides the dataset into multiple subsets based on the attribute characteristics of smart home devices, and then builds a corresponding graph index on each data subset to meet different attribute retrieval requirements; Conventional hybrid query module: Utilizing subgraph index calculation and two-stage query, it quickly and accurately completes hybrid queries when attributes are fully matched, finding devices with consistent attributes and similar feature vector distances to the query object. Logical hybrid query module: By parsing logical expressions, it obtains subgraph identifiers that meet structured constraints, implements hybrid queries based on collaborative constraints of feature similarity and attribute information, and handles complex query requirements.
Citation Information
Patent Citations
Automated self-service user support based on ontology
CN103548023A
Semantic parsing of natural language query
CN110727839A
Data query method and device, equipment, medium and computer program product
CN115982197A
Multi-source heterogeneous data association query acceleration method, device and equipment
CN117056316A
Tourism information autonomous query and strategy generation method based on AI Agent technology
CN118503529A