Method for solving complex query of numerical values contained in knowledge graph reasoning
By introducing a numerical entity predictor and entity filter into the knowledge graph, the mapping and constraint problems of numerical entities in complex queries are solved, achieving more efficient and accurate numerical and entity queries, especially performing well in multi-hop numerical queries and queries with numerical constraints.
Patent Information
- Application Number
- CN202511331183.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-17
- Publication Date
- 2026-02-10
AI Technical Summary
Existing technologies fail to effectively handle numerical entities in knowledge graph reasoning, ignoring the characteristics of numerical values such as magnitude, distribution, range, and unit, resulting in poor model performance in complex queries containing numerical values.
A numerical-to-entity predictor and an entity filter are employed. The numerical-to-entity predictor performs logical mapping between entities and numerical values, a Gaussian mixture model is used to model the numerical distribution, and the entity filter performs numerical constraint filtering to achieve accurate matching between numerical values and entities.
It effectively handles complex queries containing numerical values in knowledge graphs, improving the model's accuracy in numerical queries, entity queries, and constraint queries, especially performing exceptionally well in multi-hop numerical queries and queries with numerical constraints.
Smart Images

Figure CN121501935A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to natural language processing technology, and more particularly to a method for solving complex queries involving numerical values in knowledge graph reasoning. Background Technology
[0002] Complex Question Answering (CQA) is an important task that has emerged in recent years. Its main goal is to reason about knowledge graphs (KGs) and solve complex logical queries based on structured knowledge. In this task, natural language questions are first transformed into queries that include logical operations such as disjunction, conjunction, and existence. Such logical queries can be represented as directed acyclic graphs (DAGs). Encoding-based models can effectively encode entities and relations on DAGs, enabling reasoning on such graphs.
[0003] However, most current methods do not consider numerical entities existing in knowledge graphs. In fact, representing numerical values has always been a challenging problem in natural language processing because values are often represented as discrete entities in knowledge graphs, which contradicts the continuous nature of numbers themselves. This makes models perform poorly on queries containing numerical values during actual modeling and reasoning. Furthermore, these methods ignore the characteristics of numerical nodes, such as amplitude, distribution, range, and unit. These characteristics are crucial for the transformation from entities to numbers in queries, as well as for comparisons and calculations between numbers. For these reasons, these methods face challenges in complex reasoning tasks involving numerical values.
[0004] To address the aforementioned issues, the CNEQ model models the numerical features of numerical nodes. It primarily comprises two modules: a numerical-entity predictor and an entity filter, designed to solve complex queries involving numerical values. The numerical-entity predictor employs a superior method to encode continuous numerical values, thereby learning their semantic information, such as magnitude and units. It also models the range and distribution of the numerical answer set, capturing more macroscopic information. The entity filter predicts entity attribute values and filters out entities that meet specific constraints. To evaluate CNEQ's performance in answering complex queries, we constructed a benchmark dataset for validation. Ultimately, our model achieved state-of-the-art results on the dataset. Further experimental results demonstrate the necessity of modeling numerical values in our approach. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to provide a method for solving complex queries involving numerical values in knowledge graph reasoning, addressing the deficiencies in the prior art.
[0006] The technical solution adopted by this invention to solve its technical problem is: a method for solving complex queries containing numerical values in knowledge graph reasoning, comprising the following steps: 1) Establish a model for complex logical queries that include numerical values; The model includes: a numerical entity predictor and an entity filter; in, Numerical-entity predictors are used to deduce numerical values, entities, or statistics for a given subquery. Entity filters are used to compare the predicted values of subqueries with the calculated entity attribute values, and filter out entities on the knowledge graph that satisfy the constraints using the predicted values of subqueries as constraint values. 2) Model training; 3) Use the trained model to perform complex queries that include numerical values.
[0007] According to the above scheme, the numerical-entity predictor includes two inference processes: 1.1) For subqueries that map from one entity set to another, perform logical entity-to-entity mapping; The logical mapping from entity to entity is achieved through a combination of the following three operations; Relational mapping operations Logical intersection operation , logic and operation ; Relational mapping operations Based on the relation r in the knowledge graph, the source entity set is... Mapping to the set of target entities that satisfy relation r ; Given a subquery and the relationship between an entity Assuming The answer set is After mapping, it is represented as , but The set of answers is represented as ; in, This represents the subquery at step i. For relational mapping; The complete set of entities in the knowledge graph; Indicates if entity With entity If relation r is satisfied, then the result is correct; Logical intersection : Take the intersection of the answer sets of multiple subqueries and filter the entities that satisfy all subqueries simultaneously; Given a set of subqueries After completing the logical intersection operation, it can be represented as The set of answers is represented as ; Logical parallel operations : Take the union of the answer sets of multiple subqueries and filter the entities that satisfy any one of the subqueries; Given a set of subqueries After completing the logic and operations, it is represented as The answer set is represented as ; 1.2) For subqueries that map entities to their attribute values, perform attribute mapping from entities to values; Assuming entity set The attribute is By using a trainable multilayer perceptron (MLP), entity sets are mapped to attribute value nodes. ; The mapping process is represented as: ; in, It is a trainable MLP used to learn the associated feature information of entity sets and attributes; During the learning process, numerical entities have two properties: numerical value and distribution. These two aspects are modeled separately. Modeling the properties of numerical values: Through the encoding conversion of "real number → angle → D-dimensional vector", the values in the real number field are mapped to the D-dimensional space, and the magnitude between numerical values is represented as the cosine distance between vectors; Modeling the properties of the distribution: Introducing the Gaussian Mixture Model (GMM), which uses a weighted combination of K independent Gaussian distributions to model the distribution characteristics of the numerical set; The model assumes that the numerical values are weighted samples from K independent Gaussian models, and we optimize the marginal log-likelihood objective by summing the mixture.
[0008] According to the above scheme, step 3) specifically includes: Numerical constraints are extracted from complex queries, and the threshold of these constraints is calculated by the numerical-entity predictor. Based on the knowledge graph, candidate entities are traversed, and the attribute values of each candidate entity are calculated through a numerical entity predictor. These values are then compared with the constraint thresholds, and entities that meet the constraints are retained.
[0009] According to the above scheme, values in the real number field are mapped to a D-dimensional space, and the magnitude between values is represented as the cosine distance between vectors. The encoding process is as follows: For each value to be encoded Using a linear mapping to to angle :
[0010] in, The observable numerical range of an attribute is represented by the Polar-to-Cartesian transformation, which converts the numerical values into a D-dimensional vector.
[0011] in, yes The encoding, In this context, the superscript d indicates the d-th position in the encoding, and D is the vector dimension.
[0012] According to the above scheme, the specific attributes of the modeled distribution are as follows: Through two MLPs: and Predict the mean of the Gaussian mixture model respectively. and variance ; ;
[0013] Among them, the sigmoid function is used to calculate the mean. Limited to the range [0,1], the output is The subscript k indicates the k-th Gaussian distribution; The distribution generation process and training objective are as follows: Distribution generation: Assume that the value y' is obtained by weighted sampling from K Gaussian distributions; ; in, It follows a normal distribution; Training objective: Maximize the marginal log-likelihood so that the model's predicted distribution is as close as possible to the true numerical distribution; the formula is:
[0014] Where y is a subquery The corresponding real numerical label, These are the weights of the k-th Gaussian distribution. is the normalization constant for a normal distribution.
[0015] The larger the training target, the closer it is to the true distribution.
[0016] According to the above scheme, in step 2), the filtering function used by the entity filter includes the following three filtering functions: Equality filtering function:
[0017] in, express The standard deviation of the attribute The standard deviation of the set of all corresponding values; This indicates an entity Possessing attributes The probability of; Represents the attribute value of an entity. This is a constraint threshold; Represents entity attribute values equal The possibility; Less than filter function:
[0018] Represents the attribute value of an entity Less than The possibility; Greater than the filter function:
[0019] Represents entity attribute values Greater than The possibility.
[0020] The beneficial effects of this invention are: This invention provides a feasible solution for complex question-and-answer scenarios involving "numerical values + logic + statistics" in knowledge graphs by refining the modeling of entity logic, numerical size, and numerical distribution. It can effectively handle complex queries related to statistics and queries with numerical constraints. Attached Figure Description
[0021] The present invention will be further described below with reference to the accompanying drawings and embodiments. In the accompanying drawings: Figure 1 This is a flowchart of a method according to an embodiment of the present invention. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0023] like Figure 1 As shown, a method for solving complex queries containing numerical values in knowledge graph reasoning includes the following steps: 1) Establish a model for complex logical queries that include numerical values; The model includes: a numerical entity predictor and an entity filter; in, Numerical-entity predictors are used to deduce numerical values, entities, or statistics for a given subquery. Entity filters are used to compare the predicted values of subqueries with the calculated entity attribute values, and filter out entities on the knowledge graph that satisfy the constraints using the predicted values of subqueries as constraint values. The numerical-entity predictor includes two inference processes: 1.1) For subqueries that map from one entity set to another, perform logical mapping from entity to entity (handling relationships and set operations between entities). The logical mapping from entity to entity is achieved through a combination of the following three operations; Relational mapping operations Logical intersection operation , logic and operation ; Relational mapping operations Based on the relation r in the knowledge graph, the source entity set is... Mapping to the set of target entities that satisfy relation r ; Given a subquery and the relationship between an entity Assuming The answer set is After mapping, it is represented as , but The set of answers is represented as ; in, This represents the subquery at step i. For relational mapping; The complete set of entities in the knowledge graph; Indicates if entity With entity If relation r is satisfied, then the result is correct; Logical intersection : Take the intersection of the answer sets of multiple subqueries and filter the entities that satisfy all subqueries simultaneously; Given a set of subqueries After completing the logical intersection operation, it can be represented as The set of answers is represented as ; Logical parallel operations : Take the union of the answer sets of multiple subqueries and filter the entities that satisfy any one of the subqueries; Given a set of subqueries After completing the logic and operations, it is represented as The answer set is represented as ; 1.2) For subqueries that map entities to their attribute values, perform attribute mapping from entities to values; Assuming entity set Given attribute 'a', a trainable multilayer perceptron (MLP) is used to map the entity set into attribute value nodes. A is a set of attributes; The mapping process is represented as: ; in, It is a trainable MLP used to learn the associated feature information of entity sets and attributes; During the learning process, numerical entities have two properties: numerical value and distribution. These two aspects are modeled separately. Modeling the properties of numerical values: Through the encoding conversion of "real number → angle → D-dimensional vector", the values in the real number field are mapped to the D-dimensional space, and the magnitude between numerical values is represented as the cosine distance between vectors; The encoding process is as follows: To encode each value Using a linear mapping to to angle :
[0024] in, To represent the range of observable values, the Polar-to-Cartesian transformation is used to convert the values into D-dimensional vectors:
[0025] in, yes The encoding, The superscript d in the code represents the d-th position in the code; Modeling the properties of the distribution: Introducing the Gaussian Mixture Model (GMM), which uses a weighted combination of K independent Gaussian distributions to model the distribution characteristics of the numerical set; The model assumes that the numerical values are weighted samples from K independent Gaussian models, and we optimize the marginal log-likelihood objective by summing the mixtures; Specifically as follows: Through two MLPs: and Predict the mean of the Gaussian mixture model respectively. and variance The distribution generation process and training objective are as follows:
[0026] Among them, the sigmoid function is used to calculate the mean. Limited to the range [0,1], the output is ; Distribution generation: Assume that the numerical value y' is obtained by weighted sampling from K Gaussian distributions; ; in, It follows a normal distribution; Training objective: Maximize the marginal log-likelihood (i.e., make the model's predicted distribution as close as possible to the true numerical distribution), the formula is:
[0027] in, 'y' is the query code, and 'y' is the actual query label. It represents the weights of the k-th Gaussian distribution. The larger the training target, the closer it is to the true distribution.
[0028] The entity filter uses the following three filtering functions: Equality filtering function:
[0029] in, express The standard deviation of the attribute The standard deviation of the set of all corresponding values; This indicates an entity Possessing attributes The probability, The introduction of this feature solves the problem of "filtering noise caused by missing attributes"; Represents the attribute value of an entity. This is a constraint threshold; Represents entity attribute values equal The possibility; Less than filter function:
[0030] Represents the attribute value of an entity Less than The possibility; Greater than the filter function:
[0031] Represents entity attribute values Greater than The possibility.
[0032] Entity filters transform numerical reasoning into entity selection results. Of the three filtering functions mentioned above, the one where the entity cannot be determined is the most suitable. Does it necessarily contain attributes? We use To represent entities Possessing attributes To achieve this, we added virtual nodes to the knowledge graph. If v has an attribute a, then add an edge. Therefore, after the link predictor is trained, the existence of the predicted attribute will become the prediction of the link.
[0033] 2) Model training; Training of numerical entity predictors; The training objective of a numerical entity predictor is to learn the encoded representations of entities and operators, as well as the parameters of the distribution. Therefore, given a training query set and its answers, optimization is performed using the following loss function:
[0034] in, It is one of N positive sample query-answer pairs. It is an indicator function, when it is 1 It is a numerical value, when it is 0 It is an entity; for , The probability that all candidate entities are the answer is defined as follows:
[0035] Among them, the scoring function It will be determined by the backbone model.
[0036] 3) Use the trained model to perform complex queries that include numerical values.
[0037] Numerical constraints are extracted from complex queries, and the threshold of these constraints is calculated by the numerical-entity predictor. Based on the knowledge graph, candidate entities are traversed, and the attribute values of each candidate entity are calculated through a numerical entity predictor. These values are then compared with the constraint thresholds, and entities that meet the constraints are retained.
[0038] For example, when processing the query "US cities with an area greater than 100,000 square kilometers", the model used is: Step 1 (Numerical Entity Predictor): Calculate the encoded vector for "100,000 square kilometers" and obtain the entity set for "US cities" and the area value of each city (encoded as a vector). The second step (entity filter): Compare the area vector of each US city with the vector of "100,000 square kilometers", and filter out the cities whose vector cosine distance satisfies "larger area", which is the final answer.
[0039] Experimental data: To verify the predictive capabilities of the model in this invention for both entities and numerical values, we generated eight query types with entity answers and nine query types with numerical answers. In addition, we created nine constraint queries, each containing three constraints.
[0040] In the experimental section, the model of this invention (denoted as CNEQ) was compared with two query-encoding-based models, GQE and Q2B: GQE (Hamilton et al., 2018): GQE embeds the query into a vector and models different operators as translations and depth sets (Zaheer et al., 2017).
[0041] Q2B (Ren et al., 2020): Q2B encodes queries as hyperrectangles and represents different operators as interactions between hyperrectangles.
[0042] (1) Numerical query results Table 1 Comparison Results of Numerical Queries
[0043] Regarding performance in numerical queries: For numerical queries and subsequent entity queries, GQE and Q2B were used as baselines, and both models were used as the backbone models for CNEQ's numerical-entity predictor. Performance was evaluated using the Mean Inverted Rank (MRR) method in Table 1. The results show that CNEQ is more accurate than GQE and Q2B in predicting queries with multiple numerical answers, especially when using Q2B as the backbone model, where the performance improvement is more significant. Furthermore, for more complex query types (e.g., n_2p, n_3p), CNEQ shows a larger relative improvement (average 3.3 and 3.28), indicating that the proposed model is more capable of addressing the missing value problem in multi-hop numerical queries. The proposed model outperforms the two baseline models on all three datasets.
[0044] Table 2 Entity Query Results
[0045] Regarding entity query performance: We also compared eight complex queries with entity answers. We found that the model's ability to predict entity answers improved after considering the numerical attributes of the entities. The data in Table 2 shows that the model's prediction performance for entity answers also surpasses that of the two baseline models. This indicates that the numerical attributes of entities can serve as additional information to enhance the model's predictive ability for entities.
[0046] Table 3 Comparison Results of Mean Prediction
[0047] Regarding the performance of statistical prediction: As mentioned earlier, the numerical-entity predictor can model numerical distributions, and therefore, statistical values can be predicted by using distribution features. Therefore, we predicted statistical values across 9 numerical queries. It is worth noting that the model was only trained on the presented entity and numerical queries and no additional training was required. For a simple comparison, we used two baselines: (1) Attribute Mean: We used a model that always predicted the mean of attribute a. (2) Q2B (top_k): Since the Q2B model can only rate and rank all numerical values but cannot determine the number of answers, we sampled the top k answers to calculate their statistical values, where k is a hyperparameter that we set as the average number of answers. As shown in Table 3, the model of this invention outperforms the two baseline models on the FB15K dataset.
[0048] Table 4 Comparison Results of Constraint Queries
[0049] Performance on Constrained Queries: To verify CNEQ's ability to answer complex queries with numerical constraints, we tested it on a generated dataset containing three types of constraints: "equal to", "greater than", and "less than". For simple comparison, we replaced our numerical entity predictor with Q2B(top_k) while keeping the entity filter unchanged. The results in Table 4 show that our model performs better on all types of complex queries, indicating that our numerical entity predictor has stronger predictive power for numerical constraints than Q2B(top_k). Furthermore, with the help of the entity filter, our model can effectively answer these constrained queries. Among them, our model shows the most significant improvement in "equal to" type queries, with an average improvement of 3.72 (Hits@10). This is because "equal to" type queries require higher numerical prediction capabilities.
[0050] It should be understood that those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.
Claims
1. A method for solving complex queries involving numerical values in knowledge graph reasoning, characterized in that, Includes the following steps: 1) Establish a model for complex logical queries that include numerical values; The model includes: a numerical entity predictor and an entity filter; in, Numerical-entity predictors are used to deduce numerical values, entities, or statistics for a given subquery. Entity filters are used to compare the predicted values of subqueries with the calculated entity attribute values, and filter out entities on the knowledge graph that satisfy the constraints using the predicted values of subqueries as constraint values. 2) Model training; 3) Use the trained model to perform complex queries that include numerical values.
2. The method for solving complex queries involving numerical values in knowledge graph reasoning according to claim 1, characterized in that, The numerical entity predictor includes two inference processes: 1.1) For subqueries that map from one entity set to another, perform logical entity-to-entity mapping; The logical mapping from entity to entity is achieved through a combination of the following three operations; Relational mapping operations Logical intersection operation , logic and operation ; Relational mapping operations Based on the relation r in the knowledge graph, the source entity set is... Mapping to the set of target entities that satisfy relation r ; Logical intersection : Take the intersection of the answer sets of multiple subqueries and filter the entities that satisfy all subqueries simultaneously; Logical parallel operations : Take the union of the answer sets of multiple subqueries and filter the entities that satisfy any one of the subqueries; 1.2) For subqueries that map entities to their attribute values, perform attribute mapping from entities to values; Assuming entity set The attribute is By using a trainable multilayer perceptron (MLP), entity sets are mapped to attribute value nodes. ; The mapping process is represented as: ; in, It is a trainable MLP used to learn the associated feature information of entity sets and attributes; During the learning process, numerical entities have two properties: numerical value and distribution. These two aspects are modeled separately. Modeling the properties of numerical values: Through the encoding conversion of "real numbers to angles and then to D-dimensional vectors", the values in the real number field are mapped to D-dimensional space, and the magnitude between numerical values is represented as the cosine distance between vectors; Modeling the properties of the distribution: Introduce the Gaussian Mixture Model (GMM) to model the distribution characteristics of the numerical set using a weighted combination of K independent Gaussian distributions.
3. The method for solving complex queries involving numerical values in knowledge graph reasoning according to claim 2, characterized in that, Relational mapping operations Specifically as follows: Given a subquery and the relationship between an entity Assuming The answer set is After mapping, it is represented as , but The set of answers is represented as ; in, This represents the subquery at step i. For relational mapping; The complete set of entities in the knowledge graph; Indicates if entity With entity If relation r is satisfied, then the result is correct.
4. The method for solving complex queries involving numerical values in knowledge graph reasoning according to claim 1, characterized in that, In modeling the properties of numerical values, values in the real number field are mapped to a D-dimensional space, and the magnitudes between numerical values are represented as the cosine distance between vectors. The encoding process is as follows: For each value to be encoded Using a linear mapping to to angle : in, The range of observable numerical values for an attribute is represented by the Polar-to-Cartesian transformation, which converts the numerical values into a D-dimensional vector. in, yes The encoding, In this context, the superscript d indicates the d-th position in the encoding, and D is the vector dimension.
5. The method for solving complex queries involving numerical values in knowledge graph reasoning according to claim 1, characterized in that, The specific properties of the modeled distribution are as follows: Through two MLPs: and Predict the mean of the Gaussian mixture model respectively. and variance ; ; Among them, the sigmoid function is used to calculate the mean. Limited to the range [0,1], the output is The subscript k indicates the k-th Gaussian distribution; The distribution generation process and training objective are as follows: Distribution generation: Assume that the value y' is obtained by weighted sampling from K Gaussian distributions; ; in, It follows a normal distribution; Training objective: Maximize the marginal log-likelihood so that the model's predicted distribution is as close as possible to the true numerical distribution; the formula is: Where y is a subquery The corresponding real numerical label, These are the weights of the k-th Gaussian distribution. is the normalization constant for a normal distribution.
6. The method for solving complex queries involving numerical values in knowledge graph reasoning according to claim 1, characterized in that, In step 2), the entity filter uses the following three filtering functions: Equality filtering function: in, express The standard deviation of the attribute The standard deviation of the set of all corresponding values; This indicates an entity Possessing attributes The probability of; Represents the attribute value of an entity. This is the constraint threshold; Represents entity attribute values equal The possibility; Less than filter function: Represents the attribute value of an entity Less than The possibility; Greater than the filter function: Represents entity attribute values Greater than The possibility.
7. The method for solving complex queries involving numerical values in knowledge graph reasoning according to claim 1, characterized in that, In step 3), the trained model is used to perform complex queries containing numerical values, as follows: Numerical constraints are extracted from complex queries, and the threshold of these constraints is calculated by the numerical-entity predictor. Based on the knowledge graph, candidate entities are traversed. The attribute values of each candidate entity are calculated by the numerical entity predictor. These values are compared with the constraint thresholds, and the entities that meet the constraints are retained as the query results.
8. An electronic device, characterized in that, include: One or more processors; as well as Storage device for storing one or more programs. Wherein, when the one or more programs are executed by the one or more processors, the one or more processors perform the method according to any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 7.