Complex logic query question and answer method based on neural symbols

Through the complex logic query and answer method based on neural symbols, path weights and long-tail enhancement are dynamically adjusted, path redundancy and computing efficiency bottlenecks in complex logic queries are solved, and efficient and accurate knowledge graph query is achieved.

CN120429397APending Publication Date: 2025-08-05TIANJIN UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510504790.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-22
Publication Date
2025-08-05

AI Technical Summary

Technical Problem

When handling complex logic queries, the prior art has insufficient path redundancy suppression, lack of long-tail adaptability, and computing efficiency bottlenecks, which are difficult to meet the requirements of knowledge graphs for inference accuracy and efficiency in application scenarios such as intelligent question-and-answer and knowledge retrieval.

Method used

A complex logical query and answer method based on neural symbols is adopted. By receiving first-order logical queries and parsing them into tree calculation diagrams, path weights are dynamically adjusted, relationship-oriented attention mechanisms and gated residual connections are introduced, focus loss functions are designed, and multi-task loss functions are combined to optimize path filtering and long-tail enhancement modules to improve query accuracy and efficiency.

Benefits of technology

It significantly improves the accuracy and efficiency of complex logic queries, improves the accuracy of low-frequency entity queries, alleviates the problem of unbalanced data distribution, reduces computing resource consumption, and enhances the generalization ability of the model in long-tail scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120429397A_ABST
    Figure CN120429397A_ABST
Patent Text Reader

Abstract

The invention discloses a complex logic query question and answer method based on neural symbols, which comprises the following steps of: receiving a first-order logic query, analyzing the query into a tree-shaped computational graph, and splitting the tree-shaped computational graph into atomic queries; generating a relation embedding matrix for the relation in the query path, dynamically adjusting a key value vector, and screening a key path through a relation-oriented attention mechanism; gating residual connection is introduced into multi-hop aggregation, low-weight path noise is suppressed, and high-weight path semantic information is reserved. According to the method, through key technical means such as dynamic path optimization, long-tail semantic enhancement and calculation efficiency optimization, core defects in a complex logic query task in the prior art are effectively overcome, and based on a neural symbol fusion framework, through a relation-oriented attention mechanism and a degree perception aggregation strategy, the algorithm is more accurate and efficient. The path weight and the semantic representation of the low-frequency entity are dynamically adjusted, and meanwhile, a plurality of modules are collaboratively optimized through a joint training framework, so that the accuracy and efficiency of complex logic query are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a complex logic query and answering method based on neural symbols. Background Art

[0002] As the core technology for structured knowledge representation, knowledge graph has important application value in intelligent question answering, semantic search and other fields. Complex logic query (First-Order Logic, FOL) needs to support existential quantifiers. Logical operations such as conjunction (∧), disjunction (∨), and negation () require models to possess multi-hop reasoning capabilities and semantic compositionality. However, practical knowledge graphs are generally incomplete (e.g., missing relationships) and have long-tail distribution characteristics (high proportion of low-frequency entities), leading to the following core challenges for traditional methods:

[0003] 1. Multi-hop path redundant interference

[0004] In multi-hop queries, noisy relationships between intermediate nodes (such as non-causal associations) can introduce semantic drift, and existing methods lack dynamic path screening mechanisms, leading to error accumulation. For example:

[0005] Query2Box (Renetal., ICLR2020) relies on fixed geometric shapes (such as hyperrectangles) to represent queries and cannot dynamically adjust path weights based on context.

[0006] GNN-QE (Zhu et al., ICML 2022) uses mean pooling to aggregate neighbor information, resulting in the indiscriminate accumulation of redundant path information.

[0007] 2. Insufficient long-tail semantic learning

[0008] Low-frequency entities have sparse adjacency relationships, which leads to ambiguous semantic representations. High-frequency entities dominate the training, causing the accuracy of queries involving low-frequency entities to drop significantly. For example:

[0009] BetaE (Renetal., NeurIPS2020) uses Beta distribution to model low-frequency entities, but the KL divergence calculation complexity is high and degree differences are not explicitly modeled.

[0010] LMPNN (Wang et al., ICLR2023) relies on pre-trained embedding initialization and does not design feature enhancement or sample balancing mechanisms for long-tail distribution.

[0011] 3. Computational efficiency bottleneck

[0012] Complex probability distribution modeling and geometric operations lead to high consumption of computing resources and are difficult to scale to large-scale graphs. For example:

[0013] ConE (Zhang et al., NeurIPS 2021) models entity relationships through Cartesian cones and uses cone intersection to capture complex logic, but the computational complexity is high and it is difficult to parallelize.

[0014] The time complexity of BetaE's high-dimensional distribution KL divergence calculation is O(d) (d is the embedding dimension), which significantly increases training time.

[0015] Existing technical solutions and their limitations

[0016] Geometric embedding method

[0017] Query2Box: Maps logical queries to hyperrectangles and implements conjunctive logic through geometric intersection operations. This method uses Disjunctive Normal Form (DNF) to handle existential positive first-order logic (EPFO) queries, but its static geometric assumptions make it difficult to adapt to dynamic path semantic changes and cannot effectively suppress redundant path interference.

[0018] ConE: Modeling entity relationships using Cartesian cones and capturing complex logic using cone intersection. While it supports negation, it has high computational complexity and does not address the semantic ambiguity of long-tail entities.

[0019] Probability distribution embedding method

[0020] BetaE: Maps queries to a Beta distribution, modeling uncertainty through distribution parameterization. However, KL divergence is computationally complex, difficult to scale to large graphs, and can significantly bias the estimated distribution of low-frequency entities.

[0021] Graph Neural Network Methods

[0022] GNN-QE: Combining graph neural networks with fuzzy logic, it implements multi-hop reasoning through message passing. However, its fixed aggregation mechanism leads to the accumulation of redundant path information and lacks long-tail optimization strategies.

[0023] LMPNN: Introduces a logical message passing network and uses pre-trained embeddings to initialize atomic queries. Although the message weights are adjusted through the attention mechanism, the dynamic suppression of path redundancy is insufficient.

[0024] To sum up, when processing complex logical queries, the existing technology has problems such as insufficient path redundancy suppression, lack of long-tail adaptability, and computational efficiency bottlenecks. It is difficult to meet the requirements of knowledge graphs for reasoning accuracy and efficiency in application scenarios such as intelligent question answering and knowledge retrieval. Therefore, the present invention proposes a complex logical query answering method based on neural symbols to solve the above problems. Summary of the Invention

[0025] In view of the above-mentioned defects in the prior art, the purpose of the present invention is to provide a complex logic query and answering method based on neural symbols.

[0026] To achieve the above objectives, the present invention provides a complex logic query and answering method based on neural symbols, comprising the following steps:

[0027] Step 1: Receive a first-order logic query, parse the query into a tree-like computation graph, and split it into atomic queries;

[0028] Step 2: Generate a relation embedding matrix for the relations in the query path, dynamically adjust the key-value vector, and filter the key path through the relation-guided attention mechanism;

[0029] Step 3: Introduce gated residual connections in multi-hop aggregation to suppress low-weight path noise and retain high-weight path semantic information;

[0030] Step 4: Calculate the node degree ratio weight and dynamically weight the neighborhood information of low-frequency entities;

[0031] Step 5: Design a focus loss function to dynamically adjust the weight of low-frequency samples and increase the loss weight of low-frequency samples;

[0032] Step 6: Through the joint training framework, the multi-task loss function is combined to collaboratively optimize the path screening and long-tail enhancement modules to improve the overall performance;

[0033] Step 7: Output the answer entity set and confidence score.

[0034] Furthermore, the step of receiving a first-order logic query and parsing it into a tree-shaped computation graph includes the following:

[0035] Step 1.1: Convert the first-order logic query into disjunctive normal form (DNF), ensuring that conjunctions occur only at leaf nodes. This conversion process decomposes complex logical expressions into simpler sub-expressions, facilitating subsequent processing and computation.

[0036] Step 1.2: Map the logical operators (∧, ∨, ) to fuzzy logic operations, where the conjunction (∧) is the probability product C(x, y) = x⊙y, and the disjunction (∨) is the probability joint cover D(x, y) = x+y - x⊙y, negation () is the probability complement N(x)=1 - x, can effectively handle the uncertainty in queries and improve the robustness of the model.

[0037] Furthermore, the implementation steps of the relationship-guided attention mechanism include the following:

[0038] Step 2.1: Generate a relation embedding matrix B for the relations in the query path r ∈Rd×d ;Dynamically adjust the key-value vector;

[0039] Step 2.2, the attention score formula is:

[0040] Calculate the attention weight, where Q, K, and V are the embedded representations of the query sequence. The attention weight is calculated using the attention score formula to strengthen the feature dimensions related to the current logical relationship and suppress noise interference from irrelevant paths.

[0041] Furthermore, the implementation step of the gated residual connection includes, in multi-hop aggregation, by formula Realize the dynamic allocation of path weights, where β i The step of calculating the node degree ratio weight is as follows: calculating the node degree ratio weight Where α is a learnable scaling factor with an initial value of 0.5.

[0042] Furthermore, the step of designing the focus loss function includes designing the focus loss function where γ q In order to integrate the adjustment factors of query depth and entity scarcity, the focus loss function can dynamically adjust the weight of low-frequency samples, enhance their importance in the training process, and alleviate the problem of uneven data distribution. The implementation steps of the joint training framework include: constructing a multi-task loss function Among them L deg is the degree regularization term, L path For path consistency loss, through a joint training framework, the model takes into account path screening and long-tail enhancement during the optimization process, significantly improving the overall performance.

[0043] Furthermore, the step of outputting the answer entity set and the confidence score includes the following:

[0044] Step 7.1: Generate an answer entity set based on the optimized query embedding and path weights.

[0045] Step 7.2: Evaluate the reliability of the answer entity through the confidence score output by the model.

[0046] Furthermore, the method further includes the optimization of the query decomposition module, specifically: converting the first-order logic query into a dependency graph, where the nodes correspond to the variables of the query and the edges correspond to the relationships of the query; further converting the dependency graph into a computational graph, and specifying the reasoning process through projection, intersection and union operations. This optimization can effectively handle complex logical relationships and improve the accuracy and efficiency of queries.

[0047] Furthermore, the method also includes the optimization of the long-tail entity feature enhancement module, specifically: a dynamic aggregation method based on degree ratio weighting to enhance the effective transmission of low-frequency entity neighborhood information; introducing a focal loss function to dynamically increase the weight of low-frequency samples and alleviate the problem of uneven data distribution. These optimization measures can significantly improve the generalization ability of the model in long-tail scenarios.

[0048] Furthermore, the method also includes the optimization of computational efficiency, specifically: mapping symbolic logic operators into differentiable fuzzy logic operations to replace complex probability distribution calculations; reducing model complexity through lightweight neural symbolic operators to achieve efficient reasoning of large-scale knowledge graphs. These optimization measures can significantly reduce computing resource consumption and improve the scalability and practicality of the model.

[0049] Furthermore, the method further includes the step of dynamically suppressing redundant information in the query path, specifically: in the multi-hop query process, by dynamically evaluating the relevance of each path to the query target, adaptively adjusting the path weight, reducing the interference of redundant paths on the query results, while retaining the semantic information of key paths to improve the accuracy and efficiency of the query. The method further includes the step of optimizing the long-tail data distribution, specifically: by dynamically evaluating the importance of low-frequency entities in the query, enhancing the semantic representation of low-frequency entities, and introducing a dynamic adjustment factor to balance the training weight of low-frequency samples, so that the model pays more attention to the semantic patterns of low-frequency samples during training, thereby improving the generalization ability and reasoning accuracy of the model in long-tail scenarios.

[0050] Compared with the prior art, the present invention has the following beneficial effects:

[0051] 1. This invention effectively solves the core defects of existing technologies in complex logical query tasks through technical means such as dynamic path optimization, long-tail semantic enhancement and computational efficiency optimization. Based on the neural symbolic fusion framework, it dynamically adjusts path weights and the semantic representation of low-frequency entities through a relationship-oriented attention mechanism and a degree-aware aggregation strategy. At the same time, it collaboratively optimizes multiple modules through a joint training framework, significantly improving the accuracy and efficiency of complex logical queries.

[0052] 2. This paper uses a relationship-guided attention mechanism and gated residual connections to dynamically adjust path weights, suppress noise interference from redundant paths, and retain the semantic information of key paths. This effectively solves the semantic offset problem caused by path redundancy in multi-hop queries and significantly improves query accuracy. To address the long-tail data distribution problem, this paper uses degree-aware aggregation and focal loss functions to enhance the semantic representation of low-frequency entities and dynamically adjust the training weights of low-frequency samples. This significantly improves the model's accuracy when processing low-frequency entity queries and significantly improves the model's generalization ability in long-tail scenarios.

[0053] 3. The present invention enhances the effective transmission of low-frequency entity neighborhood information through a dynamic aggregation method weighted by degree ratio, so that low-frequency entities can receive more attention during the reasoning process. At the same time, the focus loss function dynamically increases the loss weight of low-frequency samples, alleviating the problem of uneven data distribution and further improving the accuracy of low-frequency entity queries.

[0054] 4. The present invention maps symbolic logic operators into differentiable fuzzy logic operations, replacing complex probability distribution calculations. It reduces model complexity through lightweight neural symbolic operators, significantly reduces computing resource consumption, and improves the scalability and practicality of the model. The present invention significantly improves the reasoning speed on large-scale knowledge graphs by optimizing path screening and long-tail enhancement modules and combining multi-task loss function collaborative optimization.

[0055] 5. The present invention adopts a joint training framework and combines multi-task loss functions to collaboratively optimize the path screening and long-tail enhancement modules, ensuring that the model takes both path screening and long-tail enhancement into account during the optimization process, so that the model can perform well in different types of query tasks and significantly enhance the generalization ability of the model.

[0056] 6. During multi-hop queries, this invention dynamically evaluates the relevance of each path to the query target and adaptively adjusts path weights, reducing the interference of redundant paths on query results. Furthermore, this method dynamically assesses the importance of low-frequency entities in the query and enhances their semantic representation, allowing the model to focus more on the semantic patterns of low-frequency samples during training, further improving the model's generalization capabilities in long-tail scenarios. This invention evaluates the reliability of answer entities through confidence scores output by the model, providing users with more accurate and reliable query results. This not only improves query accuracy but also enhances user trust in the query results. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] In order to more clearly illustrate the solutions in the present invention, a brief introduction is given below to the drawings required for use in describing the embodiments of the present invention. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0058] Figure 1 It is a schematic diagram provided by the present invention;

[0059] Figure 2 This is a query decomposition diagram provided by the present invention;

[0060] Figure 3 This is a long-tail semantic enhancement module diagram provided by the present invention. DETAILED DESCRIPTION

[0061] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings so that the advantages and features of the present invention can be more easily understood by those skilled in the art, thereby making a clearer and more precise definition of the scope of protection of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without making any creative work are within the scope of protection of the present invention.

[0062] The terms "including," "having," and any variations thereof in the present specification, claims, and accompanying drawings are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the present specification, claims, and accompanying drawings are used to distinguish between different items, not to describe a specific order.

[0063] See also Figure 1-3 , a complex logical query answering method based on neural symbols, comprising the following steps:

[0064] Step 1: Receive a first-order logic query, parse the query into a tree-like computation graph, and split it into atomic queries;

[0065] Step 2: Generate a relation embedding matrix for the relations in the query path, dynamically adjust the key-value vector, and filter the key path through the relation-guided attention mechanism;

[0066] Step 3: Introduce gated residual connections in multi-hop aggregation to suppress low-weight path noise and retain high-weight path semantic information;

[0067] Step 4: Calculate the node degree ratio weight and dynamically weight the neighborhood information of low-frequency entities;

[0068] Step 5: Design a focus loss function to dynamically adjust the weight of low-frequency samples and increase the loss weight of low-frequency samples;

[0069] Step 6: Through the joint training framework, the multi-task loss function is combined to collaboratively optimize the path screening and long-tail enhancement modules to improve the overall performance;

[0070] Step 7: Output the answer entity set and confidence score.

[0071] As an improvement to the above technical solution, the steps of receiving a first-order logic query and parsing it into a tree-shaped computation graph include the following:

[0072] Step 1.1: Convert the first-order logic query into disjunctive normal form (DNF), ensuring that conjunctions occur only at leaf nodes. This conversion process decomposes complex logical expressions into simpler sub-expressions, facilitating subsequent processing and computation.

[0073] Step 1.2: Map the logical operators (∧, ∨, ) to fuzzy logic operations, where the conjunction (∧) is the probability product C(x, y) = x⊙y, and the disjunction (∨) is the probability joint cover D(x, y) = x+y - x⊙y, negation () is the probability complement N(x)=1 - x, can effectively handle the uncertainty in queries and improve the robustness of the model.

[0074] As an improvement to the above technical solution, the implementation steps of the relation-guided attention mechanism include the following:

[0075] Step 2.1: Generate a relation embedding matrix B for the relations in the query path r ∈R d×d ; Dynamically adjust the key-value vector, each relation r has a corresponding embedding matrix to capture the semantic information of the relation;

[0076] Step 2.2, the attention score formula is:

[0077] Calculate the attention weight, where Q, K, and V are the embedded representations of the query sequence. The attention weight is calculated using the attention score formula to strengthen the feature dimensions related to the current logical relationship and suppress noise interference from irrelevant paths.

[0078] As an improvement to the above technical solution, the implementation steps of the gated residual connection include: in multi-hop aggregation, through the formula Implement dynamic allocation of path weights, where βi is the path weight based on attention score, and the steps of calculating node degree ratio weights include: calculating node degree ratio weights Where α is a learnable scaling factor with an initial value of 0.5.

[0079] As an improvement to the above technical solution, the steps of designing the focus loss function include: designing the focus loss function, Among them, γq is the adjustment factor that integrates query depth and entity scarcity. The focus loss function can dynamically adjust the weight of low-frequency samples, enhance their importance in the training process, and alleviate the problem of uneven data distribution. The implementation steps of the joint training framework include constructing a multi-task loss function, Ldeg is the degree regularization term, and Lpath is the path consistency loss. Through the joint training framework, the model takes into account path screening and long-tail enhancement during the optimization process, significantly improving overall performance.

[0080] As an improvement to the above technical solution, the steps of outputting the answer entity set and confidence score include the following:

[0081] Step 7.1: Generate an answer entity set based on the optimized query embedding and path weights.

[0082] Step 7.2: Evaluate the reliability of the answer entity through the confidence score output by the model. The confidence score can help users better understand the model's prediction results and improve the usability of the system.

[0083] As an improvement to the above technical solution, the method further includes optimizing the query decomposition module, specifically: converting the first-order logic query into a dependency graph, where the nodes correspond to the variables of the query and the edges correspond to the relationships of the query; further converting the dependency graph into a computational graph, and specifying the reasoning process through projection, intersection and union operations. This optimization can effectively handle complex logical relationships and improve the accuracy and efficiency of queries.

[0084] As an improvement to the above technical solution, this method further includes the optimization of the long-tail entity feature enhancement module, specifically: a dynamic aggregation method based on degree ratio weighting to enhance the effective transmission of low-frequency entity neighborhood information; introducing a focal loss function to dynamically increase the weight of low-frequency samples and alleviate the problem of uneven data distribution. These optimization measures can significantly improve the generalization ability of the model in long-tail scenarios.

[0085] As an improvement to the above technical solution, this method further includes the optimization of computational efficiency, specifically: mapping symbolic logic operators into differentiable fuzzy logic operations to replace complex probability distribution calculations; reducing model complexity through lightweight neural symbolic operators to achieve efficient reasoning of large-scale knowledge graphs. These optimization measures can significantly reduce computing resource consumption and improve the scalability and practicality of the model.

[0086] As an improvement to the above technical solution, the method further includes a step of dynamically suppressing redundant information in the query path, specifically: in the multi-hop query process, by dynamically evaluating the relevance of each path to the query target, adaptively adjusting the path weight, reducing the interference of redundant paths on the query results, while retaining the semantic information of key paths to improve the accuracy and efficiency of the query. The method further includes a step of optimizing the long-tail data distribution, specifically: by dynamically evaluating the importance of low-frequency entities in the query, enhancing the semantic representation of low-frequency entities, and introducing a dynamic adjustment factor to balance the training weight of low-frequency samples, so that the model pays more attention to the semantic patterns of low-frequency samples during training, thereby improving the generalization ability and reasoning accuracy of the model in long-tail scenarios.

[0087] Working principle and usage of the present invention:

[0088] When used, the system first receives a first-order logic query, parses the query into a tree-like computational graph, and splits it into atomic queries. This process simplifies the query structure by converting the query into a disjunctive normal form (DNF), ensuring that conjunction operations only appear at leaf nodes. Logical operators (such as conjunction ∧, disjunction ∨, and negation) are mapped to fuzzy logic operations. For example, conjunction operations are implemented through probability products C(x, y) = x⊙y, and disjunction operations are implemented through probability joint coverage D(x, y) = x+y. - x⊙y is realized, and the negation operation is achieved through the probability complement N(x)=1 - This mapping method can effectively be compatible with symbolic logic rules and neural operators, providing a basis for subsequent dynamic path optimization and long-tail enhancement. In the multi-hop query process, the system dynamically adjusts the path weight through the relationship-oriented attention mechanism. Specifically, the relationship embedding matrix B is generated for the relationship in the query path. r ∈R d×d , and dynamically adjust the key-value vector. The attention weight is calculated through the attention score formula, the feature dimensions related to the current logical relationship are strengthened, the noise interference of irrelevant paths is suppressed, the gated residual connection is introduced, and the dynamic allocation of path weights is realized through the formula. The semantic information of high-weight paths is retained and the noise of low-weight paths is suppressed. It can effectively solve the problem of multi-hop path redundancy and improve the accuracy and efficiency of queries. For the long-tail data distribution problem, the system adopts a degree-aware aggregation strategy. By calculating the node degree ratio weight, the neighborhood information of low-frequency entities is dynamically weighted to enhance the semantic representation of low-frequency entities, the focus loss function is designed, the low-frequency sample weight is dynamically adjusted, the loss weight of low-frequency samples is increased, and the problem of uneven data distribution is alleviated. Through these strategies, the model can better learn the semantic patterns of low-frequency entities and improve the generalization ability in long-tail scenarios. The system uses a joint training framework and combines multi-task loss functions to collaboratively optimize the path screening and long-tail enhancement modules. The multi-task loss function includes the degree regularization term L deg and path consistency loss L path , ensuring that the model takes into account both path screening and long-tail enhancement during the optimization process. Finally, based on the optimized query embedding and path weight, a set of answer entities is generated, and the reliability of the answer entities is evaluated through the confidence score output by the model. In order to improve computational efficiency, the system maps symbolic logic operators to differentiable fuzzy logic operations, replacing complex probability distribution calculations, and reducing model complexity through lightweight neural symbolic operators to achieve efficient reasoning of large-scale knowledge graphs.

[0089] Example

[0090] Experimental background

[0091] This example demonstrates the effectiveness of a neural symbolic-based complex logical query answering method (hereinafter referred to as "this method") for complex logical query tasks in large-scale knowledge graphs. The experiment uses a simulated knowledge graph containing multi-hop logical relationships and a long-tail data distribution. This graph covers entities and relationships in multiple fields, such as medicine, science, and history.

[0092] Experimental environment

[0093] Hardware environment: NVIDIA RTx3090 GPU, 64GB memory, Intel i9 processor; Software environment: Python 3.8, PyTorch 1.9, CUDA 11.1.

[0094] Experimental data

[0095] The self-built simulated knowledge graph contains approximately 1 million entities and 2 million relationships, of which low-frequency entities account for about 30%. It includes 1,000 complex logical queries, including multi-hop queries, existential quantifier queries, conjunction queries, etc.

[0096] Experimental procedures

[0097] Accepts first-order logic queries, such as The query goal is to find out the graduate schools of scholars who have won the Turing Award and are researching in the field of deep learning.

[0098] The query is converted to Disjunctive Normal Form (DNF), ensuring that conjunctions only appear at leaf nodes. Logical operators (∧, ∨,) are mapped to fuzzy logic operations, for example, conjunction (∧) is a probability product C(x, y) = x⊙y, and disjunction (∨) is a probability joint cover D(x, y) = x+y - x⊙y, negation () is the probability complement N(x)=1 - x.

[0099] The query is further parsed into a tree-like computational graph, where nodes correspond to the variables of the query and edges correspond to the relationships of the query. For example, the above query is parsed into a tree structure with the root node being the existential quantifier Its child nodes are existential quantifiers The conjunction node connects the atomic formulas Win(U, TuringAward), Field(U, DeepLearning) and Graduate(U, V).

[0100] Generate relation embedding matrix B for the relations in the query path r ∈R d×d , dynamically adjust the key-value vector, through the attention score formula Calculate attention weights, strengthen feature dimensions related to the current logical relationship, and suppress noise interference from irrelevant paths.

[0101] Introducing gated residual connections in multi-hop aggregation;

[0102] By formula It realizes the dynamic allocation of path weights, retains the semantic information of high-weight paths, and suppresses the noise of low-weight paths.

[0103] Calculate node degree ratio weight The neighborhood information of low-frequency entities is dynamically weighted to enhance the semantic representation of low-frequency entities.

[0104] Designing the focal loss function Dynamically adjust the weight of low-frequency samples, increase the loss weight of low-frequency samples, and alleviate the problem of uneven data distribution.

[0105] Through the joint training framework, the path screening and long-tail enhancement modules are optimized in combination with the multi-task loss function. The multi-task loss function includes the degree regularization term L deg and path consistency loss L path , ensuring that the model takes into account both path screening and long-tail enhancement during the optimization process.

[0106] Based on the optimized query embedding and path weights, a set of answer entities is generated, and the reliability of the answer entities is evaluated through the confidence score output by the model.

[0107] Experimental results

[0108] In 1,000 complex logical queries, the average accuracy of this method reached 85%, which is 15% and 10% higher than traditional methods (such as Query2Box and GNN-QE) respectively.

[0109] The accuracy of low-frequency entity queries has increased to 75%, a 20% improvement compared to traditional methods.

[0110] Training time was reduced by 30%, GPU memory usage was reduced by 40%, and inference speed was increased by 2 times compared to the BetaE method.

[0111] Experimental Conclusion

[0112] This method effectively addresses the core shortcomings of existing technologies in complex logical query tasks through key technical means such as dynamic path optimization, long-tail semantic enhancement, and computational efficiency optimization. Experimental results show that this method outperforms traditional methods in query accuracy, long-tail data performance, and computational efficiency, demonstrating its high practicality and promotional value.

[0113] The above description is only used to illustrate the technical solution of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, it should be understood by those skilled in the art that the technical solutions described in the aforementioned embodiments can still be modified, or some or all of the technical features therein can be replaced by equivalents. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied to other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A complex logic query and answering method based on neural symbols, characterized by: The following steps are involved: Step 1: Receive a first-order logic query, parse the query into a tree-like computation graph, and split it into atomic queries; Step 2: Generate a relation embedding matrix for the relations in the query path, dynamically adjust the key-value vector, and filter the key path through the relation-guided attention mechanism; Step 3: Introduce gated residual connections in multi-hop aggregation to suppress low-weight path noise and retain high-weight path semantic information; Step 4: Calculate the node degree ratio weight and dynamically weight the neighborhood information of low-frequency entities; Step 5: Design a focus loss function to dynamically adjust the weight of low-frequency samples and increase the loss weight of low-frequency samples; Step 6: Through the joint training framework, the multi-task loss function is combined to collaboratively optimize the path screening and long-tail enhancement modules to improve the overall performance; Step 7: Output the answer entity set and confidence score.

2. The complex logic query and answering method based on neural symbols according to claim 1 is characterized in that: The steps of receiving a first-order logic query and parsing it into a tree-shaped computation graph include the following: Step 1.1: Convert the first-order logic query into disjunctive normal form (DNF), ensuring that conjunctions only appear at leaf nodes. Step 1.2: Map the logical operators (∧, ∨, ) to fuzzy logic operations, where the conjunction (∧) is the probability product C(x, y) = x⊙y, and the disjunction (∨) is the probability joint cover D(x, y) = x+y - x⊙y, negation () is the probability complement N(x)=1-x.

3. The complex logic query and answering method based on neural symbols according to claim 2 is characterized in that: The implementation steps of the relationship-guided attention mechanism include the following: Step 2.1: Generate a relation embedding matrix B for the relations in the query path r ∈R d×d ;Dynamically adjust the key value vector; Step 2.2, the attention score formula is: Calculate the attention weights, where Q, K, and V are the embedding representations of the query sequence.

4. The complex logic query and answering method based on neural symbols according to claim 3, characterized in that: The implementation steps of the gated residual connection include: in multi-hop aggregation, through the formula Realize the dynamic allocation of path weights, where β i The step of calculating the node degree ratio weight is as follows: calculating the node degree ratio weight Where α is a learnable scaling factor with an initial value of 0.

5.

5. The complex logic query and answering method based on neural symbols according to claim 4, characterized in that: The design steps of the focus loss function include: where γ q In order to integrate the adjustment factors of query depth and entity scarcity, the implementation steps of the joint training framework include constructing a multi-task loss function Among them L deg is the degree regularization term, L path is the path consistency loss.

6. The complex logic query and answering method based on neural symbols according to claim 5 is characterized in that: The steps of outputting the answer entity set and the confidence score include the following: Step 7.1: Generate an answer entity set based on the optimized query embedding and path weights. Step 7.2: Evaluate the reliability of the answer entity through the confidence score output by the model.

7. The complex logic query and answering method based on neural symbols according to claim 6 is characterized in that: The method further includes optimizing the query decomposition module, converting the first-order logic query into a dependency graph, where nodes correspond to query variables and edges correspond to query relations; and further converting the dependency graph into a computational graph, specifying the reasoning process through projection, intersection and union operations.

8. The complex logic query and answering method based on neural symbols according to claim 7, characterized in that: The method further includes the optimization of the long-tail entity feature enhancement module, a dynamic aggregation method based on degree ratio weighting to enhance the effective transmission of low-frequency entity neighborhood information; the introduction of a focal loss function to dynamically increase the weight of low-frequency samples and alleviate the problem of uneven data distribution.

9. The complex logic query and answering method based on neural symbols according to claim 8, characterized in that: The method further includes optimizing computational efficiency by mapping symbolic logic operators into differentiable fuzzy logic operations to replace complex probability distribution calculations; reducing model complexity through lightweight neural symbolic operators to achieve efficient reasoning of large-scale knowledge graphs.

10. The complex logic query and answering method based on neural symbols according to claim 9, characterized in that: The method further includes a step of dynamically suppressing redundant information in the query path. During the multi-hop query process, the relevance of each path to the query target is dynamically evaluated, and the path weight is adaptively adjusted to reduce the interference of redundant paths on the query results while retaining the semantic information of the key path. The method further includes a step of optimizing the long-tail data distribution. The importance of low-frequency entities in the query is dynamically evaluated to enhance the semantic representation of low-frequency entities, and a dynamic adjustment factor is introduced to balance the training weight of low-frequency samples.

Citation Information

Cited By

  • Financial consultation response method and system

    CN120806166A