A hybrid query method and system for smart home scenarios

By employing a hybrid query method in smart home scenarios, and utilizing a two-dimensional attribute table and an improved KGraph algorithm to optimize index construction, the problem of low retrieval efficiency in smart home systems is solved, enabling fast and accurate device queries as well as flexible and diverse queries.

CN120744201BActive Publication Date: 2025-11-14SHANDONG UNIV +4
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511269570.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-08
Publication Date
2025-11-14
Estimated Expiration
2045-09-08

AI Technical Summary

Technical Problem

Existing smart home retrieval technologies are inefficient when processing large-scale device data, failing to provide real-time and rapid retrieval results. Furthermore, differences in data formats and communication protocols between different brands and types of smart devices increase the difficulty of unified retrieval and management, making it difficult to meet users' diverse query needs.

Method used

A hybrid query approach is adopted, which enhances the processing capability of structured data through conventional hybrid query mechanism and logical hybrid query mechanism. The index construction is optimized by using two-dimensional attribute table and improved KGraph algorithm. Combined with density adaptive join strategy and attribute-aware entry selection, fast and accurate device query is achieved.

Benefits of technology

It improves the accuracy and efficiency of queries, reduces unnecessary computational overhead, meets the needs of complex queries in smart home scenarios, and provides a more flexible and comprehensive query method.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120744201B_ABST
    Figure CN120744201B_ABST
Patent Text Reader

Abstract

This invention relates to the field of hybrid query technology, specifically to a hybrid query method and system for smart home scenarios, as follows: A dataset is constructed containing data of multiple patterns, each representing an object, and each object containing a high-dimensional feature vector and a set of attributes; subsets are created based on the object's attributes, grouping objects with the same attributes into the same subset, and a graph index is constructed for each subset; a query object is determined, and a query method is selected based on the type of structured constraints of the query object. If the structured constraints of the query object are a set of attributes, a conventional hybrid query is performed on the subset matching the query object's attributes; if the structured constraints of the query object are attribute logical expressions, a logical hybrid query mechanism is selected. This invention enhances the processing capability of structured data, improves query accuracy, reduces unnecessary computational overhead, and improves query efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of hybrid query technology, and in particular to a hybrid query method and system for smart home scenarios. Background Technology

[0002] With the rapid development of smart home technology, the number of smart devices in homes is increasing daily, and their functions are becoming more complex and diverse. These devices cover multiple categories such as smart lighting, smart appliances, smart security, and smart environmental monitoring, and each generates a large amount of data, including device status, usage records, and sensor data. Against this backdrop, users' demand for convenient and accurate retrieval and control of home devices is becoming increasingly strong.

[0003] However, existing smart home search technologies have several shortcomings. On the one hand, search methods are often limited, mostly supporting 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 might 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 efficiently complete such queries. On the other hand, when processing large-scale device data, search efficiency is low, response times are long, and real-time, rapid search results cannot be provided, impacting user experience. Furthermore, differences in data formats and communication protocols between different brands and types of smart devices 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 image and sound characteristics of device operation), providing users with a more flexible and comprehensive query method. For example, users can use hybrid queries to find "smart monitoring devices in the living room with high-definition cameras that are currently on" or "smart speakers in the bedroom that match a specific music style."

[0005] Therefore, this invention proposes a hybrid query method and system for smart home scenarios to solve the above problems. Summary of the Invention

[0006] To address the shortcomings of existing technologies, this invention develops a hybrid query method and system for smart home scenarios. By employing both conventional and logical hybrid query mechanisms, this invention enhances the processing capability of structured data, improves query accuracy, reduces unnecessary computational overhead, and increases query efficiency.

[0007] On the one hand, the technical solution of this invention to solve the technical problem is a hybrid query method in a smart home scenario, including the following steps:

[0008] S1. Read data from the smart home system to build a dataset. The dataset 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.

[0009] S2. Divide objects into subsets based on their attributes, group objects with the same attributes into the same subset, and build a graph index for each subset;

[0010] S3. Determine the query object and select the 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 the subset that matches the attributes of the query object for regular mixed query. If the structured constraints of the query object are attribute logical expressions, select the logical mixed query mechanism for query.

[0011] In a specific implementation, the dataset is as follows:

[0012] Dataset The data patterns in the dataset include video, images, audio, and text. Each pattern contains several types of data, and each type of data represents an object. The dataset is represented as follows: The dataset contains This type of data, that is, the corresponding One object, The first in the dataset One object;

[0013] Dataset any object Each contains a high-dimensional feature vector and a set of attributes, represented as , Representation Object High-dimensional feature vectors, , The dimension of a high-dimensional feature vector is represented by its number. Representation Object The set of attributes, , Indicates the number of categories of the attribute. Indicates the first There are several attributes, each containing several attribute values. , express The number of attribute values ​​in the middle. The order in which intrinsic attribute values ​​appear is random. Represents attributes The Middle Each attribute value; from the dataset Extracting high-dimensional feature vectors from video, image, audio, and text data. Generate attribute sets based on the content of different datasets. ;

[0014] Based on attribute set The middle attribute generates a two-dimensional attribute table. Each row in the two-dimensional attribute table represents different categories of attributes, and each column represents the attribute value corresponding to each category of attributes. Within each attribute type, the attribute value is mapped to a unique identifier id, which is encoded starting from 0. The order of id generation follows the order in which the attribute values ​​appear in the dataset.

[0015] Traversing the dataset For all objects in the table, extract the attribute set for each object, iterate through all attribute values ​​in the set, and determine whether the attribute value has already been stored in the two-dimensional attribute table. If it does not exist, store the attribute value and assign a unique ID according to its order of appearance in the type. If it exists, skip it.

[0016] In a specific implementation, subsets are divided based on the object's attributes:

[0017] An attribute space partitioning method based on algebraic encoding is introduced, which maps attribute spaces of the same type to a one-dimensional identifier space and establishes a bijective relationship between attribute combinations and subgraph indices.

[0018] Specifically, the dataset Divide into multiple subsets, where vectors within each subset share the same set of attributes, for objects and object , , , , , ,like Then the object and object They are grouped into the same subset and based on the given query object. Assign a unique subgraph identifier to each subset ;

[0019] The subgraph construction process is optimized using an improved KGraph algorithm, specifically through a density-adaptive connection strategy and attribute-aware entry point selection. The optimization process is as follows:

[0020] (1) Density-adaptive connection strategy:

[0021] For subgraphs with low cardinality, the lack of connectivity in sparse subgraphs is compensated by increasing the out-degree of each node. , The upper and lower bounds are defined as follows: when the out-degree of the nodes in the generated subgraph is less than... Adjust the out-degree of the node;

[0022] (2) Entry point selection for attribute awareness:

[0023] Multiple entry points for each subgraph are maintained by calculating the distribution of node feature vectors across various dimensions.

[0024] In a specific implementation, the query method is selected as follows:

[0025] (1) If the query object Composed of high-dimensional feature vectors and attribute sets, and whose structured constraints are consistent with the discrete attributes of the objects in the dataset, method one is chosen: performing a conventional mixed query on the subset matching the attributes of the query object. Those with identical attributes and whose feature vectors are closest in distance One object, The query object consists of several objects. Result set , , , Representing the result set The Middle One object;

[0026] (2) If the query object Composed of high-dimensional feature vectors and logical expressions of attributes, where the structured constraints of the query object are logical operations on discrete attributes in the dataset, then method two, i.e., the logical hybrid query mechanism, is selected for the query. The logical expression of the attribute includes... ,or The logical operator 'NOT' is used to query expressions that satisfy the logical expression 'NOT'. And with the query object The closest One object.

[0027] In a specific implementation, query method one is as follows:

[0028] (1) Subgraph localization:

[0029] For each query object First, parse its attribute constraints. Calculate the target subgraph identifier Estimating completion time using a two-dimensional attribute table Additionally, to accelerate subgraph localization, a global SubGraphMap hash table implemented with a perfect hash function is maintained, with the key being the subgraph identifier. The value is the metadata of the corresponding subgraph, so that in Accurately obtain the required information within a short period of time;

[0030] (2) Perform a two-stage routing query within the subgraph:

[0031] Within the target subgraph, a differentiated routing strategy should be adopted for different stages, namely a two-stage query method. In the stage far 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.

[0032] The two-phase query method is as follows:

[0033] Given a small amount of data As a threshold, when the distance between the visited point and the queried point is greater than... When the distance is less than the first stage of the query, execute the query. Then the second phase of the query is executed. Phase one is coarse-grained navigation, and phase two is fine-grained exploration.

[0034] In a specific implementation, query method two is as follows:

[0035] (1) Logical expression parsing:

[0036] 1) Lexical analysis:

[0037] Input: A string of raw logical expressions, which contains various logical operators, attribute identifiers, and parentheses, representing the user's query intent;

[0038] Processing: The input character stream is processed character by character using a finite state automaton. The finite state automaton transforms the character stream into a sequence of tokens step by step according to predefined state transition rules.

[0039] Output: Normalized token stream, eliminating spaces and other redundant symbols from the input string;

[0040] 2) Syntax Analysis: A recursive descent parser is used to construct the abstract syntax tree. The recursive descent parser recursively parses the token stream according to predefined context-free grammar rules.

[0041] 3) Semantic optimization: Boolean algebra laws are applied to optimize logical expressions to minimize their complexity and reduce resource consumption in subsequent calculations;

[0042] Transformation into disjunctive normal form: Transform the original logical expression into disjunctive normal form through a series of Boolean algebra operations;

[0043] Eliminate redundant clauses: After converting to disjunctive normal form, optimize the expression, merge identical constraint terms, and remove contradictions;

[0044] 4) Subgraph Space Mapping: Input the optimized disjunctive normal form, extract sub-terms for each optimized expression, and calculate the corresponding subgraph identifier using a formula. For the entire disjunctive term, the set of its corresponding subgraph identifiers is: , where n is the number of subgraphs that satisfy the logical expression, and the final output is the target subgraph identifier set;

[0045] (2) Parallel query of multiple subgraphs:

[0046] Based on the independence of subgraphs, Top-K nearest neighbor queries are executed concurrently on multiple subgraph indexes, and an improved two-stage query algorithm is used within each subgraph;

[0047] (3) Global result merging: A multi-way merging strategy is used to integrate the results of each subgraph;

[0048] Construct a global max-heap with a capacity of k. During the merging process, insert the local Top-K results of each subgraph into the max-heap in sequence. Through heap adjustment operations, always keep the heap containing the current global Top-K.

[0049] 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 for each step in a hybrid query method in a smart home scenario;

[0050] Index building 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 needs;

[0051] The standard hybrid query module utilizes subgraph index calculation and two-stage query to quickly and accurately complete hybrid queries when attributes are fully matched, finding devices with attributes consistent with the query object and similar feature vector distances.

[0052] The logical hybrid query module parses logical expressions to obtain subgraph identifiers that conform to structured constraints, enabling hybrid queries based on feature similarity and attribute information to handle complex query requirements.

[0053] 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:

[0054] (1) This invention proposes the concept of a two-dimensional attribute table and formulates new coding rules to realize efficient storage and convenient retrieval of attribute information of smart home devices. The attribute-aware data partitioning mechanism can accurately partition data subsets based on the attribute characteristics of home, laying a solid foundation for subsequent index construction and query processing. When constructing the subgraph index, the density adaptive connection strategy improves the index connectivity, and the multi-entry point design enhances the robustness to complex queries, making it more suitable for the complex and diverse query scenarios of smart home devices.

[0055] (2) In the conventional mixed query stage, this invention maintains a global SubGraphMap hash table, using the subgraph identifier as the key and the corresponding subgraph entry point as the value, which enables fast subgraph location and access; adopts an improved two-stage query strategy, which greatly reduces unnecessary computational overhead; prioritizes high-potential candidates, which can avoid falling into local optimum traps; and combines caching and early termination strategies to reasonably balance system resource consumption while ensuring service quality, thus providing a guarantee for users to quickly and accurately find smart home devices.

[0056] (3) In the logical hybrid query stage, a logical query framework is constructed. By performing lexical analysis and syntactic analysis on logical expressions to construct abstract syntax trees, the expression is mapped to a subgraph space, reducing computational complexity and laying a good foundation for subsequent query operations. Based on the independence of the subgraph, a parallel architecture is designed. An improved query algorithm is used within the subgraph to maximize the use of computing resources and improve query efficiency. This invention can meet the complex query needs in smart home scenarios and can find specific devices based on multiple attribute logical relationships.

[0057] In summary, this invention enhances the processing capability of structured data, improves query accuracy, reduces unnecessary computational overhead, and increases query efficiency through conventional hybrid query mechanisms and logical hybrid query mechanisms. Attached Figure Description

[0058] 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.

[0059] Figure 1 This is a schematic diagram of the method flow of the present invention.

[0060] Figure 2 This is a schematic diagram of index construction in this invention.

[0061] Figure 3 This is a schematic diagram of a conventional mixed query in this invention.

[0062] Figure 4 This is a schematic diagram of logical hybrid query in this invention.

[0063] Figure 5 This is an experimental comparison chart of conventional mixed queries in this invention.

[0064] Figure 6 This is an experimental comparison diagram of logical mixed query in this invention. Detailed Implementation

[0065] 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.

[0066] Example 1

[0067] A hybrid query method for smart home scenarios includes the following steps:

[0068] S1. Read data from the smart home system to build a dataset. The dataset 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.

[0069] S2. Divide objects into subsets based on their attributes, group objects with the same attributes into the same subset, and build a graph index for each subset;

[0070] S3. Determine the query object and select the 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 the subset that matches the attributes of the query object for regular mixed query. If the structured constraints of the query object are attribute logical expressions, select the logical mixed query mechanism for query.

[0071] In a specific implementation, the dataset is as follows:

[0072] Dataset The data patterns in the dataset include video, images, audio, and text. Each pattern contains several types of data, and each type of data represents an object. The dataset is represented as follows: The dataset contains This type of data, that is, the corresponding One object, The first in the dataset One object;

[0073] Dataset any object Each contains a high-dimensional feature vector and a set of attributes, represented as , Representation Object High-dimensional feature vectors, , The dimension of a high-dimensional feature vector is represented by its number. Representation Object The set of attributes, , Indicates the number of categories of the attribute. Indicates the first There are several attributes, each containing several attribute values. , express The number of attribute values ​​in the middle. The order in which intrinsic attribute values ​​appear is random. Represents attributes The Middle Each attribute value; from the dataset Extracting high-dimensional feature vectors from video, image, audio, and text data. Generate attribute sets based on the content of different datasets. ;

[0074] Based on attribute set The middle attribute generates a two-dimensional attribute table. Each row in the two-dimensional attribute table represents different categories of attributes, and each column represents the attribute value corresponding to each category of attributes. Within each attribute type, the attribute value is mapped to a unique identifier id, which is encoded starting from 0. The order of id generation follows the order in which the attribute values ​​appear in the dataset.

[0075] Traversing the dataset For all objects in the table, extract the attribute set for each object, iterate through all attribute values ​​in the set, and determine whether the attribute value has already been stored in the two-dimensional attribute table. If it does not exist, store the attribute value and assign a unique ID according to its order of appearance in the type. If it exists, skip it.

[0076] In a specific implementation, subsets are divided based on the object's attributes:

[0077] An attribute space partitioning method based on algebraic encoding is introduced, which maps attribute spaces of the same type to a one-dimensional identifier space and establishes a bijective relationship between attribute combinations and subgraph indices.

[0078] Specifically, the dataset Divide into multiple subsets, where vectors within each subset share the same set of attributes, for objects and object , , , , , ,like Then the object and object They are grouped into the same subset and based on the given query object. Assign a unique subgraph identifier to each subset ;

[0079] The formula for calculating subgraph identifiers is as follows:

[0080] ,

[0081] in, Indicates the subgraph identifier. Representation Object The The identifier of the species attribute, Indicates the first The number of attribute values ​​of each type Representation Object The number of attribute categories;

[0082] The subgraph construction process is optimized using an improved KGraph algorithm, specifically through a density-adaptive connection strategy and attribute-aware entry point selection. The optimization process is as follows:

[0083] (1) Density-adaptive connection strategy:

[0084] For subgraphs with low cardinality, the lack of connectivity in sparse subgraphs is compensated by increasing the out-degree of each node. , The upper and lower bounds are defined as follows: when the out-degree of the nodes in the generated subgraph is less than... Adjust the out-degree of the node;

[0085] The formula for adjusting the out-degree of a node is as follows:

[0086] hour,

[0087] ,

[0088] in, Indicates the original out-degree of the node. Indicates the initial value after adjustment. This indicates the number of vertices in the subgraph;

[0089] (2) Entry point selection for attribute awareness:

[0090] Multiple entry points for each subgraph are maintained by calculating the distribution of node feature vectors across various dimensions.

[0091] In a specific implementation, the query method is selected as follows:

[0092] (1) If the query object Composed of high-dimensional feature vectors and attribute sets, and whose structured constraints are consistent with the discrete attributes of the objects in the dataset, method one is chosen: performing a conventional mixed query on the subset matching the attributes of the query object. Those with identical attributes and whose feature vectors are closest in distance One object, The query object consists of several objects. Result set , , , Representing the result set The Middle One object;

[0093] The following conditions must be met:

[0094] ,

[0095] in, express The set of attributes, Indicates the distance threshold. Represents the query object With object The distance;

[0096] (2) If the query object Composed of high-dimensional feature vectors and logical expressions of attributes, where the structured constraints of the query object are logical operations on discrete attributes in the dataset, then method two, i.e., the logical hybrid query mechanism, is selected for the query. The logical expression of the attribute includes... ,or The logical operator 'NOT' is used to query expressions that satisfy the logical expression 'NOT'. And with the query object The closest One object.

[0097] The formula for calculating the distance between any two objects is as follows:

[0098] ,

[0099] in, The dimension of a high-dimensional feature vector is represented by its length. and They represent high-dimensional feature vectors respectively. and The s-th dimension.

[0100] In a specific implementation, query method one is as follows:

[0101] (1) Subgraph localization:

[0102] For each query object First, parse its attribute constraints. Calculate the target subgraph identifier Estimating completion time using a two-dimensional attribute table Additionally, to accelerate subgraph localization, a global SubGraphMap hash table implemented with a perfect hash function is maintained, with the key being the subgraph identifier. The value is the metadata of the corresponding subgraph, so that in Accurately obtain the required information within a short period of time;

[0103] (2) Perform a two-stage routing query within the subgraph:

[0104] Within the target subgraph, a differentiated routing strategy should be adopted for different stages, namely a two-stage query method. In the stage far 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.

[0105] The two-phase query method is as follows:

[0106] Given a small amount of data As a threshold, when the distance between the visited point and the queried point is greater than... When the distance is less than the first stage of the query, execute the query. Then execute the second phase of the query;

[0107] Phase 1: Coarse-grained navigation;

[0108] During the index building phase, multiple entry points are selected across various dimensions using an entry point selection algorithm. Queries are then executed in parallel starting from these entry points, with entry points being randomly selected. Calculate the distance to each neighbor. Where w is the upper limit of vertex degree, based on the KL divergence between the query vector and the graph node distribution, query branches that deviate from the main distribution path are removed in real time. When the distance between a node and the query object is less than a threshold, the query is removed. Then, proceed to the second stage of the query;

[0109] Phase Two: Fine-grained Exploration;

[0110] 1) Select from Phase 1 - Each node is considered a high-potential seed. To determine the final number of results, high-potential candidates are prioritized, and the density confidence score of the seed node is calculated. The calculation formula is as follows:

[0111] ,

[0112] in, For the first The seed distance between nodes is set, and a density confidence threshold is defined. ,like Expand the seed selection range to 2 ;

[0113] 2) Maintain a double-buffered priority queue:

[0114] Main queue: capacity 2 Sort by distance from the query object;

[0115] Shadow queue: capacity Sort by density confidence level;

[0116] 3) Conditions for early termination:

[0117] a. In front of the main queue The item remained unchanged for three consecutive rounds;

[0118] b. Average confidence of nodes in the shadow queue 0.9;

[0119] c. Number of explored nodes 4 ;

[0120] Stop when any condition is met.

[0121] In a specific implementation, query method two is as follows:

[0122] (1) Logical expression parsing:

[0123] 1) Lexical analysis:

[0124] Input: A string of raw logical expressions, which contains various logical operators, attribute identifiers, and parentheses, representing the user's query intent;

[0125] Processing: The input character stream is processed character by character using a finite state automaton. The finite state automaton transforms the character stream into a sequence of tokens step by step according to predefined state transition rules.

[0126] Output: Normalized token stream, eliminating spaces and other redundant symbols from the input string;

[0127] 2) Syntax Analysis: A recursive descent parser is used to construct the abstract syntax tree. The recursive descent parser recursively parses the token stream according to predefined context-free grammar rules.

[0128] 3) Semantic optimization: Boolean algebra laws are applied to optimize logical expressions to minimize their complexity and reduce resource consumption in subsequent calculations;

[0129] Transformation into disjunctive normal form: Transform the original logical expression into disjunctive normal form through a series of Boolean algebra operations;

[0130] Eliminate redundant clauses: After converting to disjunctive normal form, optimize the expression, merge identical constraint terms, and remove contradictions;

[0131] 4) Subgraph Space Mapping: Input the optimized disjunctive normal form, extract sub-terms for each optimized expression, and calculate the corresponding subgraph identifier using a formula. For the entire disjunctive term, the set of its corresponding subgraph identifiers is: , where n is the number of subgraphs that satisfy the logical expression, and the final output is the target subgraph identifier set;

[0132] (2) Parallel query of multiple subgraphs:

[0133] Based on the independence of subgraphs, Top-K nearest neighbor queries are executed concurrently on multiple subgraph indexes, and an improved two-stage query algorithm is used within each subgraph;

[0134] (3) Global result merging: A multi-way merging strategy is used to integrate the results of each subgraph;

[0135] Construct a global max-heap, set its capacity, and during the merging process, insert the local Top-K results of each subgraph into the max-heap in sequence. Through heap adjustment operations, always keep the heap containing the current global Top-K.

[0136] Example 2

[0137] A hybrid query system for a smart home scenario includes a module for executing processing instructions for each step in a hybrid query method for a smart home scenario;

[0138] Index building 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 needs;

[0139] The standard hybrid query module utilizes subgraph index calculation and two-stage query to quickly and accurately complete hybrid queries when attributes are fully matched, finding devices with attributes consistent with the query object and similar feature vector distances.

[0140] The logical hybrid query module parses logical expressions to obtain subgraph identifiers that conform to structured constraints, enabling hybrid queries based on feature similarity and attribute information to handle complex query requirements.

[0141] Example 3

[0142] like Figure 2 As shown, this invention divides objects with different attributes into different subsets and constructs a graph index for each subset. These graph indexes are called "subgraphs," meaning that objects in the same subgraph have the same attributes. This achieves the goal of quickly reducing the query space. This invention uses subgraph-based computation to effectively lock them into specific subgraphs, rather than filtering the attribute values ​​of each object in the dataset individually. These subgraph index calculations effectively narrow the query range and speed up the entire query process. Therefore, this invention significantly improves the speed of attribute filtering, thereby improving query efficiency.

[0143] Figure 3 The query method described in Method 1 is a conventional hybrid query. After inputting the query object, the query is performed based on the identifier s and the two-dimensional attribute table, and with the help of the SubGraphMap hash table.

[0144] Figure 4 The query method shown in Method 2 is a hybrid logical query, which combines the feature vector of the query object with the logical expression based on the attribute. The logical expression L based on the attribute contains the relationship between multiple attributes, hence it is a hybrid logical query. After logically parsing the query object, the subgraph that matches the query object is selected, and then multiple subgraphs are queried in parallel to obtain the final result.

[0145] Example 4

[0146] Based on nine existing datasets, a hybrid query task was performed on the method in this invention and seven existing different methods, and the efficiency and quality of the queries were evaluated using queries per second (QPS) and recall (Recall@k).

[0147] The nine existing datasets are:

[0148] SIFT1M (SIFT Million Vector Dataset), GIST1M (GIST Million Vector Dataset), Glove (Global Word Vector Dataset), Crawl (Web Scraping Dataset), Audio (Audio Feature Dataset), Msong (Million Songs Dataset), Enron (Enron Email Dataset), UQ-V (University of Queensland Visual Dataset), and Paper (Academic Paper Dataset).

[0149] The seven existing methods are as follows:

[0150] Milvus, this method originates from "Milvus: A purpose-built vector data management system," SIGMOD 2021.

[0151] Vearch, this method originates from "The design and implementation of a real-time visual search system on JD E-commerce platform," Middleware 2018.

[0152] NGT, this method originates from "Optimization of indexing based on k-nearest neighborgraph for proximity search in high-dimensional data," 2018.

[0153] SPTAG, this method originates from "SPANN: Highly-efficient Billion-scale Approximate Nearest Neighborhood Search", NeurIPS 2021.

[0154] NHQ-NPG nsw This method is derived from "An Efficient and Robust Framework for Approximate Nearest Neighbor Search with Attribute Constraint," NeurIPS 2023.

[0155] NHQ-NPG kgraph This method is derived from "An Efficient and Robust Framework for Approximate Nearest Neighbor Search with Attribute Constraint," NeurIPS 2023.

[0156] HQANN, this method originates from "HQANN: Efficient and robust similarity search for hybrid queries with structured and unstructured constraints," CIKM 2022.

[0157] Under the same experimental conditions, the conventional hybrid query and logical hybrid query methods of this invention were compared with existing methods. Figure 5 The experiment results of mixed queries are shown in the figure. Figure 6 The experimental results of logical mixed queries are shown in the middle; by Figure 5 and Figure 6 As can be seen, the method of this invention (SLS for short) exhibits higher performance on most datasets, with faster query speed and higher recall. This demonstrates that while improving query speed, this invention also ensures that the attributes of the results match the attributes of the query object. This indicates that in audio-related query scenarios where recall accuracy is extremely important, 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.

[0158] In summary, the data format of the logical expression provided by this invention is more in line with actual scenarios and has good integrity, enabling comprehensive handling of logical operations. Of course, this data format does not constitute a limitation of this invention, which can also handle data formats with combinations of other attributes. In smart home scenarios, 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.

[0159] 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 subgraph-based hybrid query method for smart home scenarios, characterized in that, Includes the following steps: S1. Read data from the smart home system to construct a dataset. The dataset contains data in multiple patterns, with each data type representing an object. Each object... Contains a high-dimensional feature vector and a set of attributes High-dimensional feature vectors are essentially unstructured constraints, while attribute sets are essentially structured constraints. The dataset is as follows: Dataset The data patterns in the dataset include video, images, audio, and text. Each pattern contains several types of data, and each type of data represents an object. The dataset is represented as follows: The dataset contains This type of data, that is, the corresponding One object, The first in the dataset One object; Dataset any object Each contains a high-dimensional feature vector and a set of attributes, represented as , Representation Object The high-dimensional feature vector, , The dimension of a high-dimensional feature vector is represented by its number. Representation Object The set of attributes , Indicates the number of categories of the attribute. Indicates the first There are several attributes, each containing several attribute values. , express The number of attribute values ​​in the middle. Representing attributes The Middle Each attribute value; from the dataset Extracting high-dimensional feature vectors from video, image, audio, and text data. Generate attribute sets based on the content of different datasets. ; Based on attribute set The middle attribute generates a two-dimensional attribute table. Each row in the two-dimensional attribute table represents different categories of attributes, and each column represents the attribute value corresponding to each category of attributes. Within each attribute type, the attribute value is mapped to a unique identifier id, which is encoded starting from 0. The order of id generation follows the order in which the attribute values ​​appear in the dataset. Traversing the dataset For all objects in the table, extract the attribute set of each object, iterate through all attribute values ​​in the set, and determine whether the attribute value has been stored in the two-dimensional attribute table. If it does not exist, store the attribute value and assign a unique ID according to its order of appearance in the type. If it exists, skip it. S2. Divide objects into subsets based on their attributes, group objects with the same attributes into the same subset, and build a graph index for each subset; S3. Determine the query object and select the 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 the subset that matches the attributes of the query object for regular mixed query. If the structured constraints of the query object are attribute logical expressions, select the logical mixed query mechanism for query. Select query method: (1) If the query object Composed of high-dimensional feature vectors and attribute sets, and whose structured constraints are consistent with the discrete attributes of the objects in the dataset, method one is chosen: performing a conventional mixed query on the subset matching the attributes of the query object. Those with identical attributes and whose feature vectors are closest in distance One object, The query object consists of several objects. Result set , , , Representing the result set The Middle One object; (2) If the query object Composed of high-dimensional feature vectors and logical expressions of attributes, where the structured constraints of the query object are logical operations on discrete attributes in the dataset, then method two, i.e., the logical hybrid query mechanism, is selected for the query. The logical expression of the attribute includes... ,or The logical operator 'NOT' is used to query expressions that satisfy the logical expression 'NOT'. And with the query object The closest One object.

2. The hybrid query method based on subgraphs in a smart home scenario according to claim 1, characterized in that, Divide objects into subsets based on their attributes: An attribute space partitioning method based on algebraic encoding is introduced, which maps attribute spaces of the same type to a one-dimensional identifier space and establishes a bijective relationship between attribute combinations and subgraph indices. Specifically, the dataset Divide into multiple subsets, where vectors within each subset share the same set of attributes, for objects and object , , , , , ,like Then the object and object They are grouped into the same subset and based on the given query object. Assign a unique subgraph identifier to each subset ; The subgraph construction process is optimized using an improved KGraph algorithm, specifically through a density-adaptive connection strategy and attribute-aware entry point selection. The optimization process is as follows: (1) Density-adaptive connection strategy: For subgraphs with low cardinality, the lack of connectivity in sparse subgraphs is compensated by increasing the out-degree of each node. , The upper and lower bounds are defined as follows: when the out-degree of the nodes in the generated subgraph is less than... Adjust the out-degree of the node; (2) Entry point selection for attribute awareness: Multiple entry points for each subgraph are maintained by calculating the distribution of node feature vectors across various dimensions.

3. The hybrid query method based on subgraphs in a smart home scenario according to claim 2, characterized in that, The specific steps for querying method one are as follows: (1) Subgraph localization: For each query object First, parse its attribute constraints. Calculate the target subgraph identifier Estimating completion time using a two-dimensional attribute table Additionally, to accelerate subgraph localization, a global SubGraphMap hash table implemented with a perfect hash function is maintained, with the key being the subgraph identifier. The value is the metadata of the corresponding subgraph, so that in Accurately obtain the required information within a short period of time; (2) Perform a two-stage routing query within the subgraph: Within the target subgraph, a differentiated routing strategy should be adopted for different stages, namely a two-stage query method. In the stage far 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-phase query method is as follows: Given a small amount of data As a threshold, when the distance between the visited point and the queried point is greater than... When the distance is less than the first stage of the query, execute the query. Then the second phase of the query is executed. Phase one is coarse-grained navigation, and phase two is fine-grained exploration.

4. The hybrid query method based on subgraphs in a smart home scenario according to claim 3, characterized in that, The second query method is as follows: (1) Logical expression parsing: 1) Lexical analysis: Input: A string of raw logical expressions, which contains various logical operators, attribute identifiers, and parentheses, representing the user's query intent; Processing: The input character stream is processed character by character using a finite state automaton. The finite state automaton transforms the character stream into a sequence of tokens step by step according to predefined state transition rules. Output: Normalized token stream, eliminating spaces and other redundant symbols from the input string; 2) Syntax Analysis: A recursive descent parser is used to construct the abstract syntax tree. The recursive descent parser recursively parses the token stream according to predefined context-free grammar rules. 3) Semantic optimization: Boolean algebra laws are applied to optimize logical expressions to minimize their complexity and reduce resource consumption in subsequent calculations; Transformation into disjunctive normal form: Transform the original logical expression into disjunctive normal form through a series of Boolean algebra operations; Eliminate redundant clauses: After converting to disjunctive normal form, optimize the expression, merge identical constraint terms, and remove contradictions; 4) Subgraph Space Mapping: Input the optimized disjunctive normal form, extract sub-terms for each optimized expression, and calculate the corresponding subgraph identifier using a formula. For the entire disjunctive term, the set of its corresponding subgraph identifiers is: , where n is the number of subgraphs that satisfy the logical expression, and the final output is the target subgraph identifier set; (2) Parallel query of multiple subgraphs: Based on the independence of subgraphs, Top-K nearest neighbor queries are executed concurrently on multiple subgraph indexes, and an improved two-stage query algorithm is used within each subgraph; (3) Global result merging: A multi-way merging strategy is used to integrate the results of each subgraph; Construct a global max-heap with a capacity of k. During the merging process, insert the local Top-K results of each subgraph into the max-heap in sequence. Through heap adjustment operations, always keep the heap containing the current global Top-K.

5. A subgraph-based hybrid query system for smart home scenarios, characterized in that: Includes a module for executing the processing instructions for each step in the subgraph-based hybrid query method for a smart home scenario as described in any one of claims 1-4; Index building 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 needs; The standard hybrid query module utilizes subgraph index calculation and two-stage query to quickly and accurately complete hybrid queries when attributes are fully matched, finding devices with attributes consistent with the query object and similar feature vector distances. The logical hybrid query module parses logical expressions to obtain subgraph identifiers that conform to structured constraints, enabling hybrid queries based on feature similarity and attribute information to handle complex query requirements.

Citation Information

Patent Citations

  • Automated self-service user support based on ontology

    CN103548023A

  • Semantic parsing of natural language query

    CN110727839A