Task reasoning method and device based on answer set programming and language model, equipment and medium

By combining large language models with answer set programming, structured predicates are generated and formally encoded, solving the problem of insufficient accuracy of reasoning results in answer set programming, and achieving high accuracy and interpretable reasoning in complex question-and-answer scenarios.

CN121257752AActive Publication Date: 2026-01-02XINGFAN XINGQI (CHENGDU) TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511814361.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-04
Publication Date
2026-01-02
Estimated Expiration
2045-12-04

AI Technical Summary

Technical Problem

Existing technologies based on answer set programming have insufficient accuracy in reasoning results, making it difficult to provide reliable and interpretable reasoning conclusions in complex question-and-answer scenarios.

Method used

By combining Large Language Model (LLM) with Answer Set Programming (ASP), structured predicates are generated and formally encoded. Logical reasoning is performed using stable model semantics, ensuring the accuracy and consistency of the reasoning results.

Benefits of technology

It significantly improves reasoning accuracy in complex question-answering scenarios, avoids the illusions and numerical errors of language models, overcomes the weak understanding of unstructured input by symbolic systems, and provides more accurate, interpretable and robust reasoning results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121257752A_ABST
    Figure CN121257752A_ABST
Patent Text Reader

Abstract

The invention discloses a task reasoning method and device based on answer set programming and a language model, equipment and a medium. The method comprises the steps of obtaining a target language reasoning task, a corresponding task data set and a corresponding domain knowledge base; outputting a corresponding structure predicate based on a preset large language model and the type of the target reasoning task, and verifying the structure predicate; the task data set, the domain knowledge base and the verified structure predicate are processed, a rule set and a predicate set of answer set programming are obtained, and processing comprises coding and consistency verification; loading a rule set and a predicate set of answer set programming, and executing logical reasoning based on stable model semantics to obtain a reasoning conclusion of the target language reasoning task. The invention belongs to the field of question and answer task reasoning. More accurate reasoning of the question and answer task can be realized based on answer set programming.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of question-answering task reasoning, and more particularly to task reasoning methods, apparatuses, devices, and media based on answer set programming and language models. Background Technology

[0002] In the fields of artificial intelligence and natural language processing, achieving a reliable, interpretable question-answering system with common-sense reasoning capabilities has always been a core challenge. While traditional Large Language Models (LLMs) excel in language generation and understanding, they are prone to "illusions," numerical errors, or conclusions that violate common sense in tasks such as mathematical computation, logical consistency, and causal reasoning. They also lack formal verification mechanisms, making it difficult to meet the demands of high-reliability scenarios (such as education, healthcare, and robotic decision-making). On the other hand, symbolic reasoning systems (such as answer set programming, ASP) can provide accurate and verifiable logical derivations and naturally support non-monotonic reasoning and default negation, but their reliance on manually constructed structured rules makes them difficult to directly process natural language input.

[0003] To address the aforementioned issues, existing technologies have begun exploring neural-symbolic fusion pathways. For example, Chinese invention patent CN116757199A proposes an understanding architecture combining LLM and ASP / s (CASP) for robots. LLM parses natural language into predefined predicates, and ASP encodes common-sense rules for algebraic or qualitative reasoning, significantly improving performance on datasets such as QuaRel and achieving interpretable proof tree output. However, the reasoning process in CN116757199A is simple, and the process modeling is inconsistent for different types of question-answering tasks. Furthermore, the accuracy of the reasoning results is not verified throughout the process, potentially leading to inaccurate results. Therefore, this invention provides a task reasoning method based on answer set programming and language models to achieve more accurate reasoning in question-answering tasks. Summary of the Invention

[0004] This invention provides a task reasoning method, apparatus, device, and medium based on answer set programming and language models, which solves the technical problem of insufficient accuracy of reasoning results when performing reasoning tasks based on answer set programming in the prior art, and achieves the technical effect of more accurate reasoning in question-and-answer tasks based on answer set programming.

[0005] In a first aspect, this invention provides a task reasoning method based on answer set programming and language models, including: Acquire the target language reasoning task, the corresponding task dataset, and the corresponding domain knowledge base. The types of language reasoning tasks include qualitative reasoning tasks, mathematical reasoning tasks, and ontology query tasks. The task dataset includes factual data and scenario constraint parameters. Based on the preset large language model and the type of the target reasoning task, the corresponding structural predicates are output, and the structural predicates are validated. The number of structural predicates is greater than or equal to 1. The task dataset, domain knowledge base, and validated structural predicates are processed to obtain the rule set and predicate set for answer set programming. The processing includes encoding and consistency verification. The rule set and predicate set of the answer set programming are loaded, and logical reasoning is performed based on the semantics of the stable model to obtain the reasoning conclusion of the target language reasoning task.

[0006] Furthermore, based on the pre-defined large language model and the type of the target inference task, the corresponding structural predicates are output, including: If the target language reasoning task is a qualitative reasoning task, then the structural predicate output by the large language model is preset to be a conclusion predicate or an observation predicate; If the target language reasoning task is a mathematical reasoning task, then the structural predicate output by the large language model is assumed to be a functional predicate; If the target language reasoning task is an ontology query task, then the structural predicates output by the large language model are assumed to be atomic predicates.

[0007] Furthermore, the structural predicates are validated, including: Determine whether the parameters contained in each structural predicate meet the predefined quantity. If any one does not meet the requirement, fine-tune the preset large language model and re-output the structural predicate. If all conditions are met, then based on the type of the target language reasoning task, determine the parameters that cannot be omitted and determine whether the parameters that cannot be omitted are in the corresponding structural predicates. If any parameter does not exist, then fine-tune the preset large language model and re-output the structural predicates. If all exist, the duplicate structural predicates are removed before the verification is completed.

[0008] Furthermore, the task dataset, domain knowledge base, and validated structural predicates are processed to obtain the rule set and predicate set for answer set programming, including: The task dataset is encoded as facts under answer set programming, the causal relationships in the domain knowledge base are encoded as logical rules under answer set programming, and the validated structural predicates are used as query targets. Solver based on answer set programming determines whether at least one stable model exists for facts and logical rules; If at least one exists, then all the rules after the fusion of factual and logical rules are used as the rule set for answer set programming; If it does not exist, the rules after the fusion of factual and logical rules are sorted by a preset priority order, and the rules before the preset position are used as the rule set for answer set programming.

[0009] Furthermore, the pre-defined large language model is fine-tuned, including: Based on the task dataset and the corresponding domain knowledge base, the preset large language model is fine-tuned.

[0010] Furthermore, the loading of the rule set and predicate set for answer set programming, and the execution of logical reasoning based on the semantics of the stable model to obtain the reasoning conclusion for the target language reasoning task, also includes: Based on the type of the target language reasoning task, determine the solver for the answer set programming, where the solver includes Clingo or S (CASP); Based on the solver, determine whether at least one stable model exists; If only one stable model exists, the semantics of the stable model are directly output and used as the reasoning conclusion of the target language reasoning task. If multiple stable models exist, semantic fusion is performed based on a pre-defined large language model, and the semantics of the fused stable model are used as the reasoning conclusion for the target language reasoning task.

[0011] Furthermore, after acquiring the domain knowledge base, it also includes: If the domain knowledge base is an unstructured knowledge base, it will be converted into a structured knowledge base based on the causal relationships in the domain knowledge base.

[0012] Secondly, the present invention provides a task reasoning device based on answer set programming and language models, comprising: The acquisition module is used to acquire the target language reasoning task, the corresponding task dataset, and the corresponding domain knowledge base. The types of language reasoning tasks include qualitative reasoning tasks, mathematical reasoning tasks, and ontology query tasks. The task dataset includes factual data and scenario constraint parameters. The structure predicate module is used to output the corresponding structure predicates based on the preset large language model and the type of the target inference task, and to verify the structure predicates. The number of structure predicates is greater than or equal to 1. The set module is used to process the task dataset, domain knowledge base, and validated structural predicates to obtain the rule set and predicate set for answer set programming. The processing includes encoding and consistency verification. The output loading module is used to load the rule set and predicate set for answer set programming, and to perform logical reasoning based on the stable model semantics to obtain the reasoning conclusion of the target language reasoning task.

[0013] Thirdly, the present invention provides an electronic device, comprising: processor; Memory used to store processor-executable instructions; The processor is configured to execute a task reasoning method based on answer set programming and language models, as provided in the first aspect.

[0014] Fourthly, the present invention provides a non-transitory computer-readable storage medium, wherein when the instructions in the non-transitory computer-readable storage medium are executed by a processor of an electronic device, the electronic device is able to execute a task reasoning method based on answer set programming and language model as provided in the first aspect.

[0015] One or more technical solutions provided in this invention have at least the following technical effects or advantages: This invention integrates Large Language Model (LLM) and Answer Set Programming (ASP) to construct a neural-symbolic collaborative task reasoning framework, significantly improving reasoning accuracy in complex question-answering scenarios. By guiding the generation of structured predicates based on natural language questions according to task type and formally encoding them using domain knowledge bases and task data, the accuracy of semantic representation is ensured. Furthermore, logical reasoning is performed based on stable model semantics, supporting not only non-monotonic reasoning and default negation but also maintaining consistency through a preference-driven rule-based repair mechanism when conflicts exist. Especially in question-answering scenarios, it avoids reasoning biases caused by illusions or numerical errors in pure language models, while overcoming the weakness of traditional symbolic systems in understanding unstructured input, thus achieving more accurate, interpretable, and robust reasoning results. In addition, the semantic fusion mechanism under multiple stable models can handle uncertainty, providing comprehensive and natural answers.

[0016] This invention performs two checks on the stability of the model. The first check, during the program construction phase, triggers a rule repair mechanism by checking for the existence of a stable model, ensuring that the input ASP program logic is consistent and solvable. The second check, during the inference execution phase, further determines the number of stable models based on the constructed program to decide on a unique output conclusion and integrate multiple solution semantics. These two checks work together to achieve a complete process of repairing before reasoning and verifying before interpreting. This improves the tolerance for knowledge conflicts and supports refined and interpretable reasoning responses, avoiding the limitations of a single check that cannot simultaneously guarantee consistency and handle multiple solutions.

[0017] This invention designs a verification process that, from format to semantics to efficiency, ensures that the final output structural predicates can accurately and error-free carry the core information of the task, providing high-quality input for subsequent ASP rule encoding and stable model semantic reasoning, and avoiding reasoning chain breaks or conclusion deviations caused by predicate issues.

[0018] This invention matches and outputs conclusion predicates, observation predicates, function predicates, or atomic predicates according to the type of the target reasoning task. This allows the structured predicates generated by the pre-set large language model to accurately carry the core semantics of the corresponding task, avoiding semantic ambiguity or information redundancy. It provides highly adaptable and accurate structured input for rule encoding and stable model semantic reasoning in subsequent answer set programming, thereby improving reasoning efficiency and accuracy. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a flowchart illustrating the task reasoning method based on answer set programming and language model provided by the present invention. Detailed Implementation

[0021] This invention provides a task reasoning method based on answer set programming and language models, which solves the technical problem of insufficient accuracy of reasoning results when performing reasoning tasks based on answer set programming in the prior art.

[0022] The technical solution of this invention is to solve the above-mentioned technical problems, and the overall idea is as follows: The task reasoning method based on answer set programming and language models includes: acquiring the target language reasoning task, the corresponding task dataset, and the corresponding domain knowledge base. The types of language reasoning tasks include qualitative reasoning tasks, mathematical reasoning tasks, and ontology query tasks. The task dataset includes factual data and scenario constraint parameters. Based on a pre-defined large language model and the type of the target reasoning task, the method outputs the corresponding structural predicates and validates them, ensuring that the number of structural predicates is greater than or equal to one. The method processes the task dataset, domain knowledge base, and validated structural predicates to obtain the rule set and predicate set for answer set programming, including encoding and consistency verification. Finally, the method loads the rule set and predicate set for answer set programming and performs logical reasoning based on stable model semantics to obtain the reasoning conclusion of the target language reasoning task.

[0023] To better understand the above technical solutions, the following will provide a detailed explanation of the technical solutions in conjunction with the accompanying drawings and specific implementation methods.

[0024] First, it should be clarified that the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.

[0025] The following explains some of the technical terms used in this invention: Answer Set Programming (ASP) is a logic-based declarative programming paradigm that models a problem as a logical program (usually composed of rules and facts) and then solves the problem by computing a stable model of that program (also known as the answer set).

[0026] A stable model is used to characterize the reasonable inference results of a logic program under the presence of negation (especially default negation or non-monotonic negation): a stable model represents a consistent, self-consistent, and rule-satisfied possible world state. In ASP, there is no need to specify how to solve it; you only need to describe what the problem is—that is, express the constraints, causal relationships, and objectives using logical rules. Subsequently, the ASP solver (such as Clingo, S(CASP), etc.) will enumerate or verify all stable models that satisfy these rules.

[0027] Structural predicates are structured intermediaries that connect natural language reasoning tasks with answer set programming logic reasoning. They are logical expressions generated by large language models according to task types, with fixed grammatical structures and clear semantic orientations. Their core function is to transform unstructured task information (such as natural language questions and scenario constraints) into logical units that can be recognized and computed by ASP, laying the foundation for subsequent accurate reasoning.

[0028] In terms of composition, a structural predicate usually consists of two parts: predicate symbols and parameters. The predicate symbols define the semantic type of the information (e.g., obs represents observed facts, transfer represents transfer relationships), while the parameters supplement key details such as specific objects, attributes, and time (e.g., in obs(speed, higher, ice), speed is an attribute, higher is the attribute value, and ice is the scene). The number and type of parameters are strictly matched with the task type.

[0029] Large Language Models (LLMs) – such as GPT, LLaMA, and Qwen – are based on deep neural networks and acquire the ability to understand and generate syntax, semantics, common sense, logic, and even code through self-supervised training on massive amounts of text. Large language models can not only perform tasks such as sentence completion, translation, and summarization, but also engage in complex behaviors such as reasoning, question answering, and writing based on prompts.

[0030] The large language model in this invention is no longer used only to generate free text, but also serves as a semantic parser to transform natural language problems into structural predicates. Please refer to the following description for details.

[0031] This invention provides, for example Figure 1 The task reasoning method based on answer set programming and language model shown includes steps S11-S14: Step S11: Obtain the target language reasoning task, the corresponding task dataset, and the corresponding domain knowledge base. The types of language reasoning tasks include qualitative reasoning tasks, mathematical reasoning tasks, and ontology query tasks. The task dataset includes factual data and scenario constraint parameters.

[0032] Target language reasoning tasks refer to tasks to be processed, which can be divided into three categories: Qualitative reasoning tasks focus on determining the relationships between attributes, paying attention to their relative relationships, such as the relationship between falling resistance and the contact area of ​​an object. The core is to deduce the positive or negative correlations between attributes by comparing their states in different scenarios.

[0033] The mathematical reasoning task focuses on the calculation of quantitative relationships. The core is to process quantitative information containing entities, quantities, and timestamps, and to deduce numerical results (originally there were 5 apples, 2 were eaten, and 3 more were bought, how many are there now?).

[0034] Focusing on concept or relationship verification, the core is to verify the truth or falsehood of a query statement based on the concept hierarchy and class relationships defined in the ontology (e.g., whether the disease belongs to hereditary diseases?).

[0035] A domain knowledge base refers to a structured collection of knowledge, containing concepts, entities, attributes, relationships, rules, and common-sense or specialized causal logic within a specific domain. A domain knowledge base can be an ontology, a set of logical rules, a semantic network, or facts and constraints extracted and normalized from unstructured text. In reasoning frameworks based on answer set programming and language models, the domain knowledge base provides background support for logical reasoning, enabling deductions that conform to domain rules when combined with task data.

[0036] Factual data refers to objective information that is explicit in the task and does not require deduction. For example, in mathematical reasoning, entity1=Fred, quantity=5, time stamp=t1 (Fred has 5 items at time t1); in qualitative reasoning, world=ice, property=friction, value=low (friction is low in an ice scene); and in ontology query, instance=bat, class=Mammal (the bat instance belongs to the mammal class).

[0037] Scene constraint parameters: These are boundary conditions that restrict the reasoning logic, preventing solutions that do not conform to reality or task requirements. For example, in mathematical reasoning, quantity ≥ 0 (the quantity cannot be negative); in qualitative reasoning, attribute values ​​can only be high or low (intermediate values ​​are not considered); and in ontology queries, concepts cannot be defined cyclically (e.g., a bird cannot be a mammal at the same time).

[0038] After acquiring the domain knowledge base, the process also includes: if the domain knowledge base is an unstructured knowledge base, then the unstructured knowledge base will be converted into a structured knowledge base based on the causal relationships in the domain knowledge base.

[0039] Most domain knowledge bases are structured knowledge bases, which can be directly used as input. If the domain knowledge base is an unstructured knowledge base, it cannot be directly encoded by the machine, so it needs to be converted into a structured form based on causal relationships.

[0040] Specifically, regarding unstructured knowledge bases: Cause and effect can be separated from unstructured text. For example, unstructured text states that the friction on ice is less than that on metal, so an object slides faster on ice than on metal. The causal relationship is: ice friction < metal friction; ice speed > metal speed, and it implicitly contains the general rule that friction and speed are negatively correlated. This maps causal relationships to facts or rules, ultimately forming an ASP-encoded structured knowledge base.

[0041] Step S12: Based on the preset large language model and the type of the target reasoning task, output the corresponding structural predicates and verify the structural predicates. The number of structural predicates is greater than or equal to 1.

[0042] Specifically, it includes: If the target language reasoning task is a qualitative reasoning task, the predefined structural predicate output by the large language model is a conclusion predicate or an observation predicate; if the target language reasoning task is a mathematical reasoning task, the predefined structural predicate output by the large language model is a function predicate; if the target language reasoning task is an ontology query task, the predefined structural predicate output by the large language model is an atomic predicate.

[0043] Conclusion predicates, observation predicates, function predicates, and atomic predicates are all structured logical units adapted to different natural language reasoning tasks. Their core function is to transform task semantics into a form that can be processed by machines.

[0044] Observation predicates are predicates used in qualitative reasoning to encode known scene attribute facts. They directly correspond to the objective observation results in the task dataset and serve as factual inputs for subsequent reasoning. The conclusion predicate also serves qualitative reasoning. It is the conclusion of attribute relationship derived from the observation predicate and the domain knowledge base, and carries the output logic of the reasoning process. Functional predicates are used specifically for mathematical reasoning. They are predicates that encode quantitative relationships such as entities, quantities, and timestamps. Their core is to carry the quantitative information required for mathematical calculations through multi-dimensional parameters. Atomic predicates are adapted for ontology query tasks. They are concise predicates that directly anchor the relationship between concepts and instances, and between concepts. They are used to quickly associate the category rules in the ontology knowledge base and support query verification.

[0045] The core of step S12 lies in using a pre-defined Large Language Model (LLM) as a semantic parser to transform the natural language form of the problem or scenario description into a structural predicate suitable for processing by the logic reasoning engine. The structural predicate is not an arbitrary text fragment, but a symbolic expression with grammatical format, a predefined number of parameters, and semantic roles, such as obs(friction, high, world1) or total(item, t0, q, k).

[0046] Matching the output conclusion predicate, observation predicate, function predicate, or atomic predicate according to the target reasoning task type allows the structured predicates generated by the pre-set large language model to accurately carry the core semantics of the corresponding task, avoiding semantic ambiguity or information redundancy. This provides highly adaptable and accurate structured input for rule encoding of subsequent answer set programming and semantic reasoning of stable models, improving reasoning efficiency and accuracy.

[0047] The structural predicates are validated, including: determining whether the parameters contained in each structural predicate meet the predefined quantity; if any does not meet the requirement, the preset large language model is fine-tuned and the structural predicates are re-output; if all meet the requirement, the indispensable parameters are determined according to the type of the target language inference task, and it is determined whether the indispensable parameters are in the corresponding structural predicates; if any do not exist, the preset large language model is fine-tuned and the structural predicates are re-output; if all exist, duplicate structural predicates are removed and the validation is completed.

[0048] The number of parameters for different types of structural predicates is fixed in advance according to the task reasoning logic; For example, the observation predicate / conclusion predicate in qualitative reasoning needs to contain three parameters: attribute, attribute value, and scenario; the function predicate has in mathematical reasoning needs to contain four parameters: entity, quantity, timestamp, and k / q (fact / query identifier). The atomic predicates for ontology queries must contain two parameters: instance and concept. If the number of any predicate parameters is mismatched, it indicates that the large language model has not accurately captured the predicate structure norms. The LLM needs to be fine-tuned based on the task dataset (containing examples with correct parameters) and the domain knowledge base (predicate definition rules) (e.g., using text-predicate pairs for context learning). Different task types have essential key parameters that support reasoning (these parameters cannot be omitted). Even if the total number of parameters meets the requirement, the absence of key parameters will still cause the reasoning to fail. For example, in mathematical reasoning, the function predicate, quantity, and timestamp are indispensable parameters (the quantity cannot be calculated without it, and the timestamp cannot be distinguished from the transfer behavior at different times). If the LLM generates transfer(Fred, sister, (missing quantity), 1, k), then the LLM needs to be fine-tuned to complete it. The atomic predicate Mammal() (missing instance) in ontology queries also needs to be completed as Mammal(bat), otherwise it cannot be associated with ontology rule verification; If there are predicates that are semantically identical but slightly different in expression (such as obs(speed, high, ice) and obs(speed, higher, ice) both expressing high ice surface speed), keeping them repeatedly will lead to redundancy in the ASP rule set and increase the amount of inference computation. Therefore, duplicate items need to be removed and only one semantically unique predicate should be kept.

[0049] This invention designs a verification process that, from format to semantics to efficiency, ensures that the final output structural predicates can accurately and error-free carry the core information of the task, providing high-quality input for subsequent ASP rule encoding and stable model semantic reasoning, and avoiding reasoning chain breaks or conclusion deviations caused by predicate issues.

[0050] Step S13: Process the task dataset, domain knowledge base, and verified structural predicates to obtain the rule set and predicate set for answer set programming. The processing includes encoding and consistency verification. Specifically, this includes: encoding the task dataset into facts under answer set programming, encoding causal relationships in the domain knowledge base into logical rules under answer set programming, and using the verified structural predicates as query targets; based on the answer set programming solver, determining whether at least one of the facts and logical rules exists as a stable model; if at least one exists, then all rules after the fusion of facts and logical rules are used as the rule set for answer set programming; if none exist, then the rules after the fusion of facts and logical rules are sorted according to a preset priority order, and the rules before the preset position are used as the rule set for answer set programming.

[0051] The core goal of encoding is to eliminate format differences in input information, transforming natural language or semi-structured data into facts, rules, and query targets that ASP can recognize, ensuring that machines can directly parse logical relationships. Task data (such as low friction on an ice surface) is encoded as ASP facts. These facts are the basis of reasoning and are directly true without any preconditions.

[0052] Causal relationships in the domain knowledge base (such as the negative correlation between friction and speed) are encoded as ASP rules (rule body to rule header form), and the rules are the logical engine of reasoning.

[0053] The validated structural predicate is the core objective that the reasoning needs to verify or solve, and it needs to be used as the ASP query predicate. For example, in qualitative reasoning, the validated conc(speed, higher, metal) (higher speed in a metal surface scenario) is the query objective, and it is necessary to verify whether the conclusion is true. In mathematical reasoning, total(Fred, Q, t2, q) (where q represents the query) is the query target, and the specific value of q needs to be solved. In ontology queries, Bird(bat) is the query target, and it is necessary to verify whether this atomic predicate conforms to ontology rules.

[0054] After encoding, consistency verification needs to be performed using the ASP solver. The core is to determine whether there is at least one stable model for the encoded facts and logical rules.

[0055] The existence of a stable model indicates that the input information has no logical conflict and can be directly used for reasoning; the absence of a stable model indicates that the facts contradict the rules (such as the fact that bats are mammals conflicting with the rule that bats are birds).

[0056] The essence of consistency verification is to identify logical contradictions in advance. If this step is skipped and reasoning is done directly using conflict rules, the ASP solver may fail to output a valid and stable model, and the reasoning will fail.

[0057] When at least one stable model exists, it means that all input information can be reasoned collaboratively. At this point, the encoded facts and encoded logical rules are fully integrated as the ASP rule set (the rule set for answer set programming).

[0058] The rule set of answer set programming is a logically consistent set that integrates the facts encoded in the task dataset and the logical rules encoded in the causal relationships of the domain knowledge base. It provides the reasoning basis for the ASP solver and supports its effective conclusions derived from the semantics of a stable model.

[0059] When no stable model exists, the rule set is sorted by priority. If the factual and logical rules conflict (no stable model), the core and reliable rules are retained and the conflict source is eliminated by using preset priority filtering rules.

[0060] The priority ranking logic is to prioritize the retention of core rules of the domain knowledge base (which can be determined based on historical experience, such as long-term verified physical laws and core ontological concept relationships, such as mammals ≠ birds), while the priority of newly added rules or alternative rules can be lower.

[0061] The rules before the preset position can be determined according to the actual situation, such as the preset position being 5, 7, 10, etc.

[0062] Step S14: Load the rule set and predicate set of the answer set programming, and perform logical reasoning based on the stable model semantics to obtain the reasoning conclusion of the target language reasoning task.

[0063] Specifically, this includes: determining the solver for the answer set programming based on the type of the target language reasoning task, where the solver includes Clingo or S (CASP); determining whether there is at least one stable model based on the solver; if there is only one stable model, directly outputting the semantics of the stable model and using it as the reasoning conclusion of the target language reasoning task; if there are multiple stable models, performing semantic fusion based on a preset large language model, and using the fused semantics of the stable model as the reasoning conclusion of the target language reasoning task.

[0064] Clingo is a high-efficiency ASP program suitable for discrete and finite field problems such as ontology querying and qualitative reasoning. s(CASP): Supports non-grounded variables, predicate constraints, and query-driven execution, making it suitable for mathematical reasoning problems involving algebraic expressions or open-domain variables.

[0065] Stable model semantics is a semantic standard in Answer Set Programming (ASP) that ensures that the reasoning conclusion is logically consistent, fits the task semantics, and conforms to common sense. The essence of stable model semantics is the set of valid solutions that directly correspond to the task objective after the task input is processed by ASP logic. Therefore, when only one stable model exists, the stable model semantics are directly output and used as the reasoning conclusion of the target language reasoning task.

[0066] Multiple stable models usually originate from the existence of multiple consistent subsets in the rule set. For example, in ontology queries, two stable models may be generated due to rule conflicts. In this case, LLM can be used to combine task semantics and common sense to fuse them or to integrate the semantics of multiple models (such as excluding contradictory terms and retaining common conclusions).

[0067] In addition, this invention performs a stability model check in both S13 and S14. In the program construction phase of S13, the existence of a stable model is checked to trigger a rule repair mechanism, ensuring the consistency and solvability of the input ASP program logic. In the inference execution phase of S14, based on the constructed program, the number of stable models is further determined to output a unique conclusion and integrate multiple solution semantics. These two checks collaboratively achieve a complete process of repairing before reasoning and verifying before interpreting, which improves tolerance for knowledge conflicts and supports refined and interpretable reasoning responses, avoiding the limitations of a single check that cannot simultaneously guarantee consistency and handle multiple solutions.

[0068] In summary, this invention integrates Large Language Model (LLM) and Answer Set Programming (ASP) to construct a neural-symbolic collaborative task reasoning framework, significantly improving reasoning accuracy in complex question-answering scenarios. By guiding the generation of structured predicates based on natural language questions according to task type and formally encoding them with domain knowledge base and task data, the accuracy of semantic representation is ensured. Furthermore, logical reasoning is performed based on stable model semantics, supporting not only non-monotonic reasoning and default negation, but also maintaining consistency through a preference-driven rule repair mechanism when conflicts exist. Especially in question-answering scenarios, it avoids reasoning biases caused by illusions or numerical errors in pure language models, while overcoming the weakness of traditional symbolic systems in understanding unstructured input, thus achieving more accurate, interpretable, and robust reasoning results. In addition, the semantic fusion mechanism under multiple stable models can handle uncertainty and provide comprehensive and natural answers.

[0069] Based on the same inventive concept, this invention also provides a task reasoning device based on answer set programming and language models, comprising: The acquisition module is used to acquire the target language reasoning task, the corresponding task dataset, and the corresponding domain knowledge base. The types of language reasoning tasks include qualitative reasoning tasks, mathematical reasoning tasks, and ontology query tasks. The task dataset includes factual data and scenario constraint parameters. The structure predicate module is used to output the corresponding structure predicates based on the preset large language model and the type of the target inference task, and to verify the structure predicates. The number of structure predicates is greater than or equal to 1. The set module is used to process the task dataset, domain knowledge base, and validated structural predicates to obtain the rule set and predicate set for answer set programming. The processing includes encoding and consistency verification. The output loading module is used to load the rule set and predicate set for answer set programming, and to perform logical reasoning based on the stable model semantics to obtain the reasoning conclusion of the target language reasoning task.

[0070] Based on the same inventive concept, the present invention also provides an electronic device, comprising: processor; Memory used to store processor-executable instructions; The processor is configured to execute task reasoning methods based on answer set programming and language models, as described above.

[0071] Based on the same inventive concept, the present invention also provides a non-transitory computer-readable storage medium, which, when the instructions in the storage medium are executed by the processor of an electronic device, enables the electronic device to execute the task reasoning method based on answer set programming and language model as described above.

[0072] Since the electronic device described in this embodiment is an electronic device used to implement the information processing method in the embodiments of the present invention, those skilled in the art can understand the specific implementation methods and various variations of the electronic device in this embodiment based on the information processing method described in the embodiments of the present invention. Therefore, how the electronic device implements the method in the embodiments of the present invention will not be described in detail here. Any electronic device used by those skilled in the art to implement the information processing method in the embodiments of the present invention falls within the scope of protection of the present invention.

[0073] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0074] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0075] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0076] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0077] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.

[0078] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.

Claims

1. A task reasoning method based on answer set programming and language models, characterized in that, include: Obtain the target language reasoning task, the corresponding task dataset, and the corresponding domain knowledge base. The types of language reasoning tasks include qualitative reasoning tasks, mathematical reasoning tasks, and ontology query tasks. The task dataset includes factual data and scenario constraint parameters. Based on the preset large language model and the type of the target reasoning task, the corresponding structural predicates are output, and the structural predicates are validated. The number of structural predicates is greater than or equal to 1. The task dataset, the domain knowledge base, and the verified structural predicates are processed to obtain the rule set and predicate set for answer set programming, wherein the processing includes encoding and consistency verification. The rule set and predicate set of the answer set programming are loaded, and logical reasoning is performed based on the semantics of the stable model to obtain the reasoning conclusion of the target language reasoning task.

2. The task reasoning method based on answer set programming and language model as described in claim 1, characterized in that, Based on the predefined large language model and the type of the target inference task, the corresponding structural predicates are output, including: If the target language reasoning task is a qualitative reasoning task, then the structural predicate output by the preset large language model is a conclusion predicate or an observation predicate; If the target language reasoning task is a mathematical reasoning task, then the structural predicate output by the preset large language model is a functional predicate; If the target language reasoning task is an ontology query task, then the structural predicates output by the preset large language model are atomic predicates.

3. The task reasoning method based on answer set programming and language model as described in claim 2, characterized in that, Validation of structural predicates includes: Determine whether the parameters contained in each structural predicate meet the predefined quantity. If any one does not meet the requirement, fine-tune the preset large language model and re-output the structural predicate. If all conditions are met, then based on the type of the target language reasoning task, determine the parameters that cannot be omitted and determine whether the parameters that cannot be omitted are in the corresponding structural predicates. If any parameter does not exist, then fine-tune the preset large language model and re-output the structural predicates. If all exist, the duplicate structural predicates are removed before the verification is completed.

4. The task reasoning method based on answer set programming and language model as described in claim 1, characterized in that, The task dataset, the domain knowledge base, and the validated structural predicates are processed to obtain the rule set and predicate set for answer set programming, including: The task dataset is encoded as facts under answer set programming, the causal relationships in the domain knowledge base are encoded as logical rules under answer set programming, and the validated structural predicates are used as query targets. Solver based on answer set programming determines whether at least one stable model exists for facts and logical rules; If at least one exists, then all the rules after the fusion of factual and logical rules are used as the rule set for answer set programming; If it does not exist, the rules after the fusion of factual and logical rules are sorted by a preset priority order, and the rules before the preset position are used as the rule set for answer set programming.

5. The task reasoning method based on answer set programming and language model as described in claim 3, characterized in that, Fine-tuning the pre-defined large language model, including: Based on the task dataset and the corresponding domain knowledge base, the preset large language model is fine-tuned.

6. The task reasoning method based on answer set programming and language model as described in claim 1, characterized in that, The algorithm loads the rule set and predicate set for answer set programming, performs logical reasoning based on stable model semantics, and obtains the reasoning conclusion for the target language reasoning task. It also includes: Based on the type of the target language reasoning task, determine the solver for the answer set programming, where the solver includes Clingo or S (CASP); Based on the solver, determine whether at least one stable model exists; If only one stable model exists, the semantics of the stable model are directly output and used as the reasoning conclusion of the target language reasoning task. If multiple stable models exist, semantic fusion is performed based on a pre-defined large language model, and the semantics of the fused stable model are used as the reasoning conclusion for the target language reasoning task.

7. The task reasoning method based on answer set programming and language model as described in claim 1, characterized in that, After acquiring the domain knowledge base, it also includes: If the domain knowledge base is an unstructured knowledge base, it will be converted into a structured knowledge base based on the causal relationships in the domain knowledge base.

8. A task reasoning device based on answer set programming and language model, characterized in that, include: The acquisition module is used to acquire the target language reasoning task, the corresponding task dataset, and the corresponding domain knowledge base. The types of language reasoning tasks include qualitative reasoning tasks, mathematical reasoning tasks, and ontology query tasks. The task dataset includes factual data and scenario constraint parameters. The structure predicate module is used to output the corresponding structure predicates based on the preset large language model and the type of the target inference task, and to verify the structure predicates. The number of structure predicates is greater than or equal to 1. The set module is used to process the task dataset, the domain knowledge base, and the verified structural predicates to obtain the rule set and predicate set for answer set programming, wherein the processing includes encoding and consistency verification. The output loading module is used to load the rule set and predicate set for answer set programming, and to perform logical reasoning based on the stable model semantics to obtain the reasoning conclusion of the target language reasoning task.

9. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the task reasoning method based on answer set programming and language model as described in any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium, characterized in that, When the instructions in the non-transitory computer-readable storage medium are executed by the processor of the electronic device, the electronic device is able to perform the task reasoning method based on answer set programming and language model as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Large language model and answer set programmed understanding architecture model for robots

    CN116757199A

  • Multi-context system construction process based on ontology and hexlite

    CN118364900A

  • Systems and methods for training language models to reason over tables

    US20220309087A1

  • Inference device, inference method, and inference program

    US20230370498A1