Cardinality estimation method, system and equipment based on super-relation knowledge graph and medium
By combining conditional variational autoencoders and multilayer graph neural networks, the problem of inaccurate cardinality estimation in super-relational knowledge graphs is solved, enabling full capture and utilization of complex qualifiers and improving the accuracy and adaptability of estimation.
Patent Information
- Application Number
- CN202511480861.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-16
- Publication Date
- 2026-02-10
AI Technical Summary
Existing technologies for hyperrelation knowledge graphs suffer from inaccurate cardinality estimation. In particular, random walk methods have a high sampling failure rate, neural network methods are insufficient for constrained word vectorization and cannot adapt to query patterns of varying complexity, and training relies on a large amount of scarce labeled data.
A conditional variational autoencoder is used to supplement missing qualifiers, and explicit qualifiers are deeply aggregated through rotation operations. Combined with a multi-layer graph neural network and an adaptive weight fusion mechanism, multiple rounds of iterative information transmission and representation generation are performed. Finally, a nonlinear regression mapping is performed to output the cardinality estimate.
It improves the accuracy and practicality of cardinality estimation, reduces the average estimation error, effectively handles complex query patterns, adapts to query scenarios of varying complexity, and performs exceptionally well in long-chain and loop queries.
Smart Images

Figure CN121502005A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data query technology, and in particular to a cardinality estimation method, system, device and medium based on hyperrelation knowledge graph. Background Technology
[0002] With the large-scale application of hyperrelation knowledge graphs in fields such as intelligent question answering, recommendation systems, and semantic search, the demand for efficient and accurate cardinality estimation for complex queries is becoming increasingly prominent.
[0003] Existing technical solutions have obvious limitations. Sampling methods based on random walks cause a surge in sampling failure probability in super-relation queries due to the explosion of qualifier combinations, systematically underestimating the true cardinality. Although neural network-based methods can avoid sampling bias, they do not provide sufficient vectorized representation of qualifiers, simply using summation or averaging operations. Furthermore, they employ a graph neural network architecture with a fixed number of layers, which cannot adapt to query patterns of varying complexity. They also heavily rely on a large number of labeled query-cardinality pairs for training, while labeled data is extremely scarce in real-world scenarios.
[0004] Therefore, how to effectively estimate the cardinality of data query results has become a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0005] This invention provides a cardinality estimation method, system, device, and medium based on hyperrelation knowledge graphs to improve the accuracy and practicality of cardinality estimation for hyperrelation knowledge graph queries.
[0006] To address the aforementioned technical problems, embodiments of the present invention provide a cardinality estimation method based on hyperrelation knowledge graphs, comprising:
[0007] The obtained user-submitted query graph is initialized to obtain the query vector and relation vector in the query graph;
[0008] The query vector is input into a pre-trained conditional variational autoencoder to fill in missing qualifiers, resulting in a supplemented qualifier vector; the explicit qualifiers in the query vector are aggregated to obtain an explicit qualifier vector; the supplemented qualifier vector and the explicit qualifier vector are fused to obtain a comprehensive qualifier vector.
[0009] By merging the comprehensive qualifying word vector and the relation vector, an enhanced relation representation is obtained;
[0010] Based on the enhanced relation representation, the nodes in the query graph are subjected to multiple rounds of iterative information transmission and vector updates through a graph neural network. During the multiple rounds of iteration, the vector outputs of each layer are fused to generate the final representation of each node.
[0011] The final representations of each node are aggregated to form a global representation of the query graph. The global representation is then subjected to a nonlinear regression mapping to output a cardinality estimate of the query graph.
[0012] Further, the initialization of the obtained user-submitted query graph to obtain the query vector and relation vector in the query graph includes:
[0013] Vector mapping is performed on entity nodes and qualifiers in the query graph to obtain the query vector;
[0014] Vector mapping is performed on the relation edges in the query graph to obtain relation vectors.
[0015] Furthermore, the step of performing vector mapping on entity nodes and qualifiers in the query graph to obtain the query vector includes:
[0016] Map the known entity nodes and known qualifiers in the query graph to a first query vector;
[0017] Map the known entity nodes in the query graph to the second query vector;
[0018] The first query vector and the second query vector are used as query vectors.
[0019] Further, the step of inputting the query vector into a pre-trained conditional variational autoencoder for missing qualifier word imputation to obtain an imputed qualifier word vector includes:
[0020] Extract the head entity vector, tail entity vector, and corresponding relation vector of the current edge from the query vector;
[0021] A random vector is obtained by sampling. The head entity vector, the relation vector, the tail entity vector and the random vector are concatenated. The concatenated vector is then input into a conditional variational autoencoder to generate supplementary limiting word vectors.
[0022] Further, the step of vector aggregating the explicit qualifiers in the query vector to obtain an explicit qualifier vector includes:
[0023] Perform a rotation operation on each pair of explicit qualifiers in the query vector to obtain the corresponding combined vector;
[0024] The summation operation is performed on each of the combined vectors to obtain the aggregated explicit qualifying word vector.
[0025] Furthermore, the fusion of the supplementary qualifying word vector and the explicit qualifying word vector to obtain the comprehensive qualifying word vector includes:
[0026] The supplementary qualifying word vector and the explicit qualifying word vector are weighted and summed using learnable weight coefficients, and the weighted sum is used as the comprehensive qualifying word vector.
[0027] Furthermore, the fusion of vector outputs from each layer to generate the final representation of each node includes:
[0028] The learned adaptive weights are used to sum the node vectors output by each layer to obtain the final representation of each node.
[0029] Another embodiment of the present invention provides a cardinality estimation system based on a hyperrelation knowledge graph, comprising:
[0030] An initialization module is used to initialize the query graph submitted by the user, and obtain the query vector and relation vector in the query graph;
[0031] The qualifier acquisition module is used to input the query vector into a pre-trained conditional variational autoencoder to supplement missing qualifiers and obtain supplemented qualifier vectors; to aggregate the explicit qualifiers in the query vector to obtain explicit qualifier vectors; and to fuse the supplemented qualifier vectors and the explicit qualifier vectors to obtain a comprehensive qualifier vector.
[0032] The vector merging module is used to merge the comprehensive limiting word vector and the relation vector to obtain an enhanced relation representation;
[0033] The iterative update module is used to perform multiple rounds of information transmission and vector update on the nodes in the query graph through a graph neural network based on the enhanced relation representation. During the multiple rounds of iteration, the vector outputs of each layer are fused to generate the final representation of each node.
[0034] The cardinality estimation module is used to aggregate the final representations of each node to form a global representation of the query graph, perform nonlinear regression mapping on the global representation, and output the cardinality estimate of the query graph.
[0035] Another embodiment of the present invention provides a computer device including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements the cardinality estimation method based on the hyperrelationship knowledge graph as described above.
[0036] In another embodiment of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing a computer program, wherein when the device containing the computer-readable storage medium executes the computer program, it implements the cardinality estimation method based on the hyperrelationship knowledge graph as described above.
[0037] Compared with the prior art, the beneficial effects of the embodiments of the present invention are at least one of the following:
[0038] A conditional variational autoencoder is employed to intelligently supplement missing qualifiers, and rotation operations are combined to perform deep aggregation of explicit qualifiers. This ensures the full capture and utilization of the semantics of complex qualifiers in the hyperrelationship knowledge graph, overcoming the shortcomings of traditional methods in insufficient utilization of qualifier information. A multi-layer graph neural network and adaptive weight fusion mechanism are designed. The multi-layer iterative information transmission process can effectively handle complex patterns such as long-chain queries and loop queries, while the attention-based inter-layer fusion strategy enables the model to flexibly adapt to query scenarios of various complexity. Attached Figure Description
[0039] Figure 1 This is a flowchart illustrating the steps of a cardinality estimation method based on a hyperrelationship knowledge graph in one embodiment of the present invention.
[0040] Figure 2 This is a flowchart of a cardinality estimation method based on a hyperrelation knowledge graph according to one embodiment of the present invention;
[0041] Figure 3 This is a structural block diagram of a cardinality estimation system based on a hyperrelation knowledge graph according to one embodiment of the present invention;
[0042] Figure 4 A structural diagram of a computer device provided in an embodiment of the present invention. Detailed Implementation
[0043] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The purpose of providing these embodiments is to make the disclosure of the present invention more thorough and comprehensive. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0044] In the description of this application, the terms "first," "second," "third," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined with "first," "second," "third," etc., may explicitly or implicitly include one or more of that feature. In the description of this application, unless otherwise stated, "a plurality of" means two or more.
[0045] In the description of this application, it should be noted that, unless otherwise expressly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to fixed connections, detachable connections, or integral connections; they can refer to mechanical connections or electrical connections; they can refer to direct connections or indirect connections through an intermediate medium; and they can refer to the internal communication between two components. The terms "vertical," "horizontal," "left," "right," "upper," "lower," and similar expressions used herein are for illustrative purposes only and do not indicate or imply that the device or component referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as limiting the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances.
[0046] In the description of this application, it should be noted that, unless otherwise defined, all technical and scientific terms used in this invention have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used in this specification is for the purpose of describing specific embodiments only and is not intended to limit the invention. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances.
[0047] One embodiment of the present invention provides a cardinality estimation method based on a hyperrelation knowledge graph. For details, please refer to [link to relevant documentation]. Figure 1 , Figure 1 The flowchart shown is a step-by-step flowchart of a cardinality estimation method based on a hyperrelationship knowledge graph according to one embodiment of the present invention, including steps S11-S15:
[0048] S11. Initialize the query graph submitted by the user to obtain the query vector and relation vector in the query graph.
[0049] The obtained user-submitted query graph is initialized to obtain vectorized representations of each element in the query graph, specifically including two components: query vectors and relation vectors. This initialization process is a fundamental step in subsequent graph neural network processing, and its core objective is to transform the structured query graph into a numerical feature representation that can be processed by machine learning models.
[0050] Vector mapping is performed on entity nodes and qualifiers in the query graph to obtain the query vector. The specific implementation process includes the following steps: First, all entity nodes and qualifier elements in the query graph are identified and classified. Second, different vectorization strategies are applied based on whether the element has a predefined representation in the knowledge base. Finally, the vector results obtained from different strategies are combined into a complete query vector. This process ensures that all elements in the query graph receive appropriate numerical representation.
[0051] The known entity nodes and known qualifiers in the query graph are mapped to a first query vector, where known entity nodes and known qualifiers refer to entities and qualifiers that already have pre-trained embedded representations in the knowledge graph. Specifically, the system queries a pre-built hyper-relational knowledge graph embedding model to obtain the embedding vectors corresponding to these known elements. These vectors already contain the semantic information and relational features of the elements in the knowledge space.
[0052] The unknown entity nodes in the query graph are mapped to the second query vector. The difference between the second query vector and the first query vector is that the second query vector does not use the known qualifiers in the query graph.
[0053] Using the first and second query vectors as query vectors, a complete query vector combination is formed. This combination includes vectorized representations of entity nodes and qualifiers in the query graph, preserving the semantic information of known elements while providing distinguishable identifying features for querying and generating unknown elements.
[0054] The system performs vector mapping on the relation edges in the query graph to obtain relation vectors, maintaining consistency with the vectorization process for entity nodes. For known relation edges, the system retrieves their corresponding relation embedding vectors from a pre-trained embedding model; for unknown relation edges, the system uses the same processing method as for unknown entities to generate vector representations containing unique identifiers.
[0055] Specifically, in this embodiment, each node and relation in the query, as well as the qualifying words, are initialized as vectors. Specifically, an HKGE model (Hyper-Relational Knowledge Graph Embedding Model) is pre-trained, which maps each entity and relation in the HKG (Hyper-Relational Knowledge Graph) to a 200*1 dimensional vector. For nodes and relations in the query that can be directly mapped to the HKG, they are initialized as the corresponding vectors in the HKGE. For uncertain nodes and edges that need to be matched in the query, the first dimension is set to a unique numeric ID. For example, the first dimension of ? v1 is set to ID1, and the remaining 199 dimensions are set to 0. If the nodes / edges in the qualifying words also need to be matched, the remaining dimensions are set to 1 to correspond to the rotation calculation in formula (1).
[0056] For example, for edge f in the query q = (v2, ?r, ?v3, qr1, qe1), where v2 and ?v3 represent the head and tail nodes, ?r represents the relation, and qr1 and qe1 represent a pair of qualifiers. The determined parts, v2, qr1, and qe1, are initialized with their representations in HKGE, denoted as . and This is the first query vector. For the parts to be matched, ?r and ?v3, they are initialized as vectors with ID as the first dimension and 0 as the last 199 dimensions, denoted as... and This is the second query vector, where h represents a vector, and the superscript (0) indicates that it is the input to the 0th layer of the graph neural network. As part of the second query vector, it is also a relation vector. It is a second query vector because it is an unknown relation that needs to be matched, and it is a relation vector because it is a representation of relation edges. In practical applications, there is overlap.
[0057] S12. Input the query vector into the pre-trained conditional variational autoencoder to supplement missing qualifiers, obtaining supplemented qualifier vectors; aggregate the explicit qualifiers in the query vector to obtain explicit qualifier vectors; fuse the supplemented qualifier vectors and explicit qualifier vectors to obtain a comprehensive qualifier vector. Specifically, when processing the query graph, in order to fully capture and utilize the semantics of qualifiers in the hyperrelationship knowledge graph, this embodiment divides the edges in the query graph into two processing methods. One method uses the original qualifiers to generate qualifier vectors, and the other method does not use the original qualifiers, but uses other vector data besides the qualifiers to generate supplemented qualifier vectors. Then, the supplemented qualifier vectors and the original qualifier vectors are fused to achieve full utilization of the data. The original qualifiers, as known data, are called explicit qualifiers, and their corresponding vectors are explicit qualifier vectors.
[0058] In the data preparation stage of qualifier supplementation processing, the head entity vector, relation vector, and tail entity vector of the current edge are extracted from the query vector.
[0059] A random vector is obtained through sampling. The head entity vector, relation vector, tail entity vector, and random vector are concatenated, and the concatenated vector is input into the conditional variational autoencoder to generate supplementary qualified word vectors. The random vector is sampled from a standard normal distribution to introduce randomness and enhance the diversity of generation. The concatenation operation fuses edge structure information with random noise into high-dimensional input features. The conditional variational autoencoder decodes the fused features based on its decoder module to generate the predicted supplementary qualified word vectors.
[0060] For example, a pre-trained Conditional Variational Autoencoder (CVAE) can be used to supplement the qualifiers for edge f.q =(v2,?r,?v3,qr1,qe1), during the completion process, only f is used. q The head and tail entities and their relationships, i.e., v2, ? v3 and ? r, without using f. q The qualifiers already appearing in the text. Specifically, following a normal distribution N(0, I), a 200-dimensional vector z is randomly sampled. For example, z is concatenated with the vectors corresponding to the head node, relationships, and tail nodes of the edges, i.e. The input is fed into the decoder of the CVAE, and the 200-dimensional vector output by the decoder is used as f. q supplementary qualifiers It participates in the calculation of formula x. In each graph neural network layer, z is sampled, and supplementary limiting word vectors are calculated.
[0061] This CVAE model consists of an encoder and a decoder. The entire model accepts x as input and outputs y as the result. Let x = h|c be the input to the encoder, where c is a conditional vector. The encoder transforms h into a latent variable z. The latent variable z passes through the decoder to obtain an output vector y. CVAEs can be pre-trained using HKG. First, given a fact f = (s, r, o, QF) in HKG... f ), where s and o represent the head and tail nodes, r represents the relation, QF f This indicates a pair of determiners. First, in QF... f Sampling of partial qualifiers for QF f,p Then use s, p, o, and QF f,p To predict incomplete qualifier information QF f,l =QF f \QF f,p Even using input To predict in Let j represent the vector at the i-th layer of the graph neural network. The value of j can be s, r, o, QF. f QF f,p or QF f,l .For example, This represents the vector s in the 0th layer of the graph neural network. This represents the vector of r in the 0th layer of the graph neural network. This represents the vector of o in the 0th layer of the graph neural network. Indicates the determiner QF f The vector in the 0th layer of the graph neural network, Indicates from QF f Sampled qualifiers QF f,p The vector in the 0th layer of the graph neural network, Indicates from QFf The remaining qualifier QF f,l =QF f \QF f,p The vector in the 0th layer of the graph neural network. || represents the vector concatenation operation, corresponding to the CVAE model. As a condition. Secondly, randomly replace f = (s, r, o, QF) f Some entities / relationships in the model are used as training data for uncertain points that need to be matched, for example, replacing certain points s with uncertain points ? s, and then using... As input, cause CVAE output Even if we use the concatenation of the vectors s, r, and o at layer 0 and the zero vector to predict QF... f The vector at layer 0. The entire CVAE model is trained using the root mean square error between the encoder output and y.
[0062] Rotation is performed on each pair of explicit qualifiers in the query vector to obtain the corresponding combined vector. Rotation is a mathematical operation that transforms the relative angles of each pair of qualifier vectors in complex space. It can effectively capture the semantic association and relative position information between qualifier pairs and generate a combined representation that preserves the relational characteristics.
[0063] For existing qualifiers in the query graph, their vectors need to be incorporated into the representation of the nodes and relations containing the qualifiers. We take... Figure 2 edge f in the query graph q =(v2,?r,?v3,QF) q For example, the vector of the qualifier can be converted into a 200-dimensional vector using the following formula:
[0064]
[0065] in, It is a trainable projection matrix that is shared by all qualifiers in the query, where qr and qe refer to f. q The qualifier QF q For any pair in the vector, ξ(·) is the vector of each pair of definite words. and The combination function uses rotation operations.
[0066] Summing the combined vectors yields the aggregated explicit qualifier vector. By summing and aggregating the combined vectors of all qualifier pairs, local pairing information is integrated into a global qualifier representation, forming a vector representation of the overall information of all explicit qualifiers in the current edge.
[0067] The supplementary qualifying word vector and the explicit qualifying word vector are weighted and summed using learnable weight coefficients, and the weighted sum is used as the comprehensive qualifying word vector. The weight coefficients are parameters automatically learned during model training, dynamically adjusting the contribution ratio of generated qualifying words and explicit qualifying words in the final representation.
[0068] Because each query fact f q Qualifier information in QF q It may be incomplete, therefore after calculation using formula (1), and The weighted sum as f q qualifier vectors Recorded as:
[0069]
[0070] Where λ is a shared hyperparameter of each layer of the graph neural network, controlling the influence of the qualifier completion vector, and k refers to any layer of the graph neural network. In each layer, the above qualifier completion and qualifier aggregation operations are performed once on each edge of the query graph, and then the resulting qualifier vector is used for information transmission.
[0071] S13. Merge the comprehensive limiting word vector and relation vector to obtain the enhanced relation representation.
[0072] For f q First, obtain the qualified word vectors. Merge into relation vector Above, here γ(·) uses the addition operation, that is Then, neighborhood aggregation is performed according to the following formula to obtain the enhanced relation representation:
[0073]
[0074]
[0075] During the neighborhood aggregation process, the directional relationship of each edge in the query graph is preserved. For an edge pointing to node s, i.e. from the node set N, the directional relationship is preserved. + (s)(o fi This indicates that any one of the points has the qualifier QF. fi For edges originating from node s, use formula (3); for edges pointing from node s to other nodes, i.e. to N... - (s)(o fg This indicates that any one of the points has the qualifier QF. fg The edges of ) are defined using formula (4). σ represents the ReLU activation function. It is a trainable projection matrix.
[0076] After neighborhood aggregation, update the vector of each node using formula (5):
[0077]
[0078] Graph Isomorphism Network (GIN) is used as the base neural network for information transmission, where... It is a multilayer perceptron used to update the vectors of nodes.
[0079] This step is the core feature enhancement operation for realizing hyper-relational knowledge graph query processing in this scheme. By deeply integrating the comprehensive qualifying word representation with the basic relation representation, the semantic integrity and expression accuracy of the relation representation are significantly improved, laying a solid foundation for the efficient information transmission of the subsequent graph neural network.
[0080] S14. Based on enhanced relation representation, the graph neural network performs multi-round iterative information transmission and vector update on the nodes in the query graph. During the multi-round iterative process, the vector outputs of each layer are fused to generate the final representation of each node.
[0081] Based on enhanced relation representation, a graph neural network is used to perform multi-round iterative information transmission and vector update of nodes in the query graph. During the multi-round iterative process, the vector outputs of each layer are fused to generate the final representation of each node.
[0082] Specifically, the adaptive weight fusion mechanism dynamically evaluates the importance of node representations in different network layers through learnable weight parameters, effectively integrates multi-level features, and finally generates node representations rich in multi-scale semantic information.
[0083] The fixed 2-layer graph neural network in existing cardinality estimation models limits the receptive field, leading to poor performance. However, a larger receptive field can cause the vector representations of nodes to become indistinguishable, a problem known as oversmoothing. Specifically, in this embodiment, a trainable 200*1 dimensional projection vector w is applied, which is shared by all nodes, to normalize the amount of information provided by each graph neural network layer, thereby alleviating the oversmoothing problem. Specifically, for each node vector in the k-th layer... The model passes A retention score is obtained and used as an adaptive weight to control the amount of information used in the vector at the k-th layer. The final representation vector of each node e∈{s,o} in the query graph is calculated as follows:
[0084]
[0085] Where ⊙ represents the vector dot product operation, for any node e in the query graph, formula (6) will merge the vectors of e output from each layer of the graph neural network in the L-layer network structure to obtain the final representation.
[0086] S15. Aggregate the final representations of each node to form a global representation of the query graph. Perform a nonlinear regression mapping on the global representation and output the cardinality estimate of the query graph.
[0087] After obtaining the final representation of each node vector, global summation is used to summarize the vectors of the entire query graph. This vector is then converted into a numerical value through a multilayer perceptron as an estimate of the query graph, thereby outputting the numerical value of the cardinality estimate of the query graph.
[0088] Preferably, this embodiment also includes data-augmented model training.
[0089] To address the problem of scarce training data and enhance the model's generalization ability, this embodiment also designs a simple yet effective data augmentation strategy: for each query graph Q in the training set, two auxiliary query graph sets are constructed, denoted as Q0. add and Q rm Q add The query is obtained by adding an edge or a qualifier to Q. Intuitively, adding an extra edge or qualifier to Q means adding conditions to the query. add The cardinality of the query should be less than or equal to the cardinality of Q. Conversely, Q rm The query in Q is obtained by removing an edge or a qualifier from Q, and its cardinality should be greater than or equal to the cardinality of Q.
[0090] Based on Q add and Q rm Let ||Q|| Q To query the true cardinality of Q, To estimate the cardinality for the model, an enhanced loss function can be developed based on the cardinality relationship as follows:
[0091]
[0092] During training, the root mean square error (MSE) is first used to minimize the error between the estimated cardinality and the true cardinality. For the auxiliary query set, only the relative magnitude relationship between the predicted cardinality and the true cardinality of the original query graph Q is normalized. Therefore, this embodiment adds a ReLU function σ to prevent the model from incorrectly outputting the same value for the auxiliary query set and a given instance. The cardinality of the auxiliary query estimated by the model.
[0093] The cardinality estimation method based on hyper-relational knowledge graphs in this invention employs a conditional variational autoencoder to intelligently supplement missing qualifiers and combines rotation operations to deeply aggregate explicit qualifiers, ensuring full capture and utilization of the semantics of complex qualifiers in the hyper-relational knowledge graph, overcoming the shortcomings of traditional methods in insufficient utilization of qualifier information. A multi-layer graph neural network and adaptive weight fusion mechanism are designed. The multi-layer iterative information transmission process can effectively handle complex patterns such as long-chain queries and cyclic queries, while the attention-based inter-layer fusion strategy enables the model to flexibly adapt to query scenarios of various complexities.
[0094] By using qualifier supplementation and aggregation mechanisms, this embodiment reduces the average estimation error, improving it by up to two orders of magnitude compared to the strongest baseline; on a dataset containing qualifiers in 45.9% of its data, the error is only 1 / 16 of the baseline method.
[0095] Based on adaptive merging of entity vectors encoded by multi-layer graph neural networks, this embodiment achieves significant results on long chains and cyclic graph topologies.
[0096] The proposed data augmentation strategy based on adding / deleting edges enables this embodiment to estimate the error of new query topology, new entities, and new qualifier distributions that are not seen before, with an error of less than 10% to 20% of the baseline.
[0097] This embodiment is on par with other machine learning methods in terms of estimation time, and is much faster than sampling methods; the complexity of cardinality estimation is linearly related to the number of query nodes, and can be smoothly scaled to larger graphs.
[0098] This invention also provides a cardinality estimation system based on a hyperrelation knowledge graph, used to perform the cardinality estimation method based on a hyperrelation knowledge graph as described above. Figure 2 This is a structural block diagram of a cardinality estimation system based on a hyperrelation knowledge graph according to an embodiment of the present invention. The system includes:
[0099] Initialization module 21 is used to initialize the obtained user-submitted query graph to obtain the query vector and relation vector in the query graph;
[0100] The qualifier acquisition module 22 is used to input the query vector into a pre-trained conditional variational autoencoder to supplement missing qualifiers and obtain supplemented qualifier vectors; to aggregate the explicit qualifiers in the query vector to obtain explicit qualifier vectors; and to fuse the supplemented qualifier vectors and the explicit qualifier vectors to obtain a comprehensive qualifier vector.
[0101] Vector merging module 23 is used to merge the comprehensive limiting word vector and the relation vector to obtain an enhanced relation representation;
[0102] The iterative update module 24 is used to perform multiple rounds of iterative information transmission and vector update on the nodes in the query graph through a graph neural network based on the enhanced relation representation. During the multiple rounds of iteration, the vector outputs of each layer are fused to generate the final representation of each node.
[0103] The cardinality estimation module 25 is used to aggregate the final representations of each node to form a global representation of the query graph, perform nonlinear regression mapping on the global representation, and output the cardinality estimate of the query graph.
[0104] The technical features and effects of the system proposed in the embodiments of the present invention are the same as those of the method proposed in the embodiments of the present invention, and will not be repeated here. Each module in the above system can be implemented entirely or partially through software, hardware, or a combination thereof. Each module can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0105] See Figure 3 This is a structural block diagram of a computer device provided in an embodiment of the present invention. The computer device includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the steps described in the above embodiment of the cardinality estimation method based on a hyperrelationship knowledge graph. Figure 1 Steps S11 to S15 as described above; or, when the processor executes the computer program, it implements the functions of each module in the above-described device embodiments, such as modules 21 to 25 of the cardinality estimation system based on the hyperrelation knowledge graph.
[0106] For example, the computer program may be divided into one or more modules, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the computer device.
[0107] The computer device may include, but is not limited to, a processor and memory. Those skilled in the art will understand that the schematic diagram is merely an example of a computer device and does not constitute a limitation on the computer device. It may include more or fewer components than illustrated, or combine certain components, or different components. For example, the computer device may also include input / output devices, network access devices, buses, etc.
[0108] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the computer device, connecting various parts of the computer device via various interfaces and lines.
[0109] The memory can be used to store the computer programs and / or modules. The processor implements various functions of the computer device by running or executing the computer programs and / or modules stored in the memory and by calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0110] If the modules integrated into the computer device are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.
[0111] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0112] Accordingly, embodiments of the present invention provide a computer-readable storage medium comprising a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform steps in the cardinality estimation method based on hyperrelationship knowledge graphs as described in the above embodiments, for example... Figure 1 Steps S11 to S15 as described above.
[0113] In summary, compared with the prior art, the cardinality estimation method, system, computer device, and computer-readable storage medium based on hyperrelationship knowledge graphs provided by the embodiments of the present invention have the following beneficial effects:
[0114] A conditional variational autoencoder is employed to intelligently supplement missing qualifiers, and rotation operations are combined to perform deep aggregation of explicit qualifiers. This ensures the full capture and utilization of the semantics of complex qualifiers in the hyperrelationship knowledge graph, overcoming the shortcomings of traditional methods in insufficient utilization of qualifier information. A multi-layer graph neural network and adaptive weight fusion mechanism are designed. The multi-layer iterative information transmission process can effectively handle complex patterns such as long-chain queries and loop queries, while the attention-based inter-layer fusion strategy enables the model to flexibly adapt to query scenarios of various complexity.
[0115] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of this patent should be determined by the appended claims.
Claims
1. A cardinality estimation method based on hyperrelation knowledge graphs, characterized in that, include: The obtained user-submitted query graph is initialized to obtain the query vector and relation vector in the query graph; The query vector is input into a pre-trained conditional variational autoencoder to fill in missing qualifiers, resulting in a supplemented qualifier vector; the explicit qualifiers in the query vector are aggregated to obtain an explicit qualifier vector. The supplementary qualifying word vector and the explicit qualifying word vector are fused to obtain a comprehensive qualifying word vector; By merging the comprehensive qualifying word vector and the relation vector, an enhanced relation representation is obtained; Based on the enhanced relation representation, the nodes in the query graph are subjected to multiple rounds of iterative information transmission and vector updates through a graph neural network. During the multiple rounds of iteration, the vector outputs of each layer are fused to generate the final representation of each node. The final representations of each node are aggregated to form a global representation of the query graph. The global representation is then subjected to a nonlinear regression mapping to output a cardinality estimate of the query graph.
2. The cardinality estimation method based on super-relational knowledge graph as described in claim 1, characterized in that, The initialization of the obtained user-submitted query graph to obtain the query vector and relation vector in the query graph includes: Vector mapping is performed on entity nodes and qualifiers in the query graph to obtain the query vector; Vector mapping is performed on the relation edges in the query graph to obtain relation vectors.
3. The cardinality estimation method based on hyperrelation knowledge graph as described in claim 2, characterized in that, The process of vector mapping between entity nodes and qualifiers in the query graph to obtain the query vector includes: Map the known entity nodes and known qualifiers in the query graph to a first query vector; Map the known entity nodes in the query graph to the second query vector; The first query vector and the second query vector are used as query vectors.
4. The cardinality estimation method based on hyperrelation knowledge graph as described in claim 1, characterized in that, The step of inputting the query vector into a pre-trained conditional variational autoencoder for missing term completion to obtain a supplemented term vector includes: Extract the head entity vector, tail entity vector, and corresponding relation vector of the current edge from the query vector; A random vector is obtained by sampling. The head entity vector, the relation vector, the tail entity vector and the random vector are concatenated. The concatenated vector is then input into a conditional variational autoencoder to generate supplementary limiting word vectors.
5. The cardinality estimation method based on super-relational knowledge graph as described in claim 1, characterized in that, The step of vector aggregation of explicit qualifiers in the query vector to obtain explicit qualifier vectors includes: Perform a rotation operation on each pair of explicit qualifiers in the query vector to obtain the corresponding combined vector; The summation operation is performed on each of the combined vectors to obtain the aggregated explicit qualifying word vector.
6. The cardinality estimation method based on hyperrelation knowledge graph as described in claim 1, characterized in that, The process of fusing the supplementary qualifying word vector and the explicit qualifying word vector to obtain a comprehensive qualifying word vector includes: The supplementary qualifying word vector and the explicit qualifying word vector are weighted and summed using learnable weight coefficients, and the weighted sum is used as the comprehensive qualifying word vector.
7. The cardinality estimation method based on hyperrelation knowledge graph as described in claim 1, characterized in that, The fusion of vector outputs from each layer generates the final representation of each node, including: The learned adaptive weights are used to sum the node vectors output by each layer to obtain the final representation of each node.
8. A cardinality estimation system based on hyperrelation knowledge graphs, characterized in that, include: An initialization module is used to initialize the query graph submitted by the user, and obtain the query vector and relation vector in the query graph; The qualifier acquisition module is used to input the query vector into a pre-trained conditional variational autoencoder to supplement missing qualifiers and obtain supplemented qualifier vectors; and to aggregate the explicit qualifiers in the query vector to obtain explicit qualifier vectors. The supplementary qualifying word vector and the explicit qualifying word vector are fused to obtain a comprehensive qualifying word vector; The vector merging module is used to merge the comprehensive limiting word vector and the relation vector to obtain an enhanced relation representation; The iterative update module is used to perform multiple rounds of information transmission and vector update on the nodes in the query graph through a graph neural network based on the enhanced relation representation. During the multiple rounds of iteration, the vector outputs of each layer are fused to generate the final representation of each node. The cardinality estimation module is used to aggregate the final representations of each node to form a global representation of the query graph, perform nonlinear regression mapping on the global representation, and output the cardinality estimate of the query graph.
9. A computer device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements the cardinality estimation method based on a hyperrelationship knowledge graph as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein when the device containing the computer-readable storage medium executes the computer program, it implements the cardinality estimation method based on hyperrelationship knowledge graph as described in any one of claims 1 to 7.