Explanatable unsupervised reasoning method
By preprocessing and symbolic inference on the data in the unsupervised inference method, the language model is used to generate statements and negation, and the maximum satisfactory problem is constructed using the symbol solver, the unsupervised inference method is solved. The unsupervised inference method is insufficient in performance and insubstantiable interpretation. The problem achieves higher performance and interpretability.
Patent Information
- Application Number
- CN202411100704.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2025-01-07
AI Technical Summary
Existing unsupervised inference methods are insufficient in performance and lack of interpretability, especially when relying on language models, which are difficult to provide clear explanations.
Using an interpretable unsupervised reasoning method, by preprocessing the data, converting problems and options into statements, and using language models to generate negatives and causes, calculating their respective probabilities, and then constructing the maximum satisfactory problem and using symbols The solver performs the solution to improve the performance and interpretability of the method.
By sharing the workload of language models, the performance of inference methods is improved, and the interpretability of the method is improved through the logic of the symbol solver.
Smart Images

Figure CN119272883A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to an explainable unsupervised reasoning method. Background Art
[0002] Reasoning is an important capability of artificial intelligence systems. Since reasoning is often expressed in words, it has become an important task in the field of natural language processing and is divided into several subtasks, including common sense reasoning, logical reasoning, mathematical reasoning, etc. In addition, reasoning is also the basis of many other natural language processing tasks, including text classification, reading comprehension, natural language generation, etc.
[0003] The most common form of reasoning tasks is multiple-choice questions, that is, given a question, choose the only correct option from several options. For this form of reasoning tasks, a common method is the supervised method based on the language model. This method trains a language model on a specific reasoning dataset (training set), and then verifies and predicts on the same dataset (validation set or test set). Supervised methods have achieved certain success, but have two main problems: supervised methods require a large amount of labeled data and computing resources, which cannot be met in many scenarios; supervised methods often have insufficient generalization capabilities, that is, they perform poorly on datasets that have not been trained.
[0004] In order to solve the two main problems of supervised methods, researchers proposed unsupervised methods based on language models. Unsupervised methods do not train language models, but directly use language models to make predictions on inference datasets. Unsupervised methods alleviate the two problems of supervised methods, but they also have some limitations: due to the lack of training, unsupervised methods often perform worse than supervised methods; unsupervised methods rely on language models, and thus inherit some limitations of language models, especially the lack of interpretability. Summary of the invention
[0005] The technical problem to be solved by the present invention is to propose an explainable unsupervised reasoning method to make up for the problems of insufficient performance and lack of explainability of existing unsupervised reasoning methods.
[0006] The technical solution adopted by the present invention to solve the above technical problems is:
[0007] An explainable unsupervised reasoning method includes the following steps:
[0008] S1: Data preprocessing: For each sample in the dataset to be predicted, the question and each option in the sample are combined into a bigram, and then each bigram is converted into a statement using a language model;
[0009] S2: For each statement, use the language model to generate a negation of the statement and recursively generate the reason, and calculate the probability of the generation process and the probability of the statement, negation and reason respectively;
[0010] S3: Delete inappropriate reasons based on probability;
[0011] S4: Symbolic inference: For each preprocessed sample, a maximum satisfiability problem is constructed based on the statement, negation, cause and related probability of each sample, and then the symbolic solver is called to solve the maximum satisfiability problem to obtain the statement whose value is true, and then select the corresponding option.
[0012] The beneficial effects of the present invention are:
[0013] 1) By distributing part of the reasoning process to the symbolic solver, the workload of the language model is reduced, allowing the language model to focus on tasks it is better at (i.e., generating and calculating probabilities), thereby improving performance.
[0014] 2) The interpretability of the method is improved by combining a symbolic solver that is interpretable and logical. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 is an overall flow chart of the unsupervised reasoning method in the present invention;
[0016] Figure 2 A schematic diagram for generating negations and recursively generating causes for the present invention, and calculating the probability of the corresponding process;
[0017] Figure 3 Flowchart for symbolic inference of the present invention. DETAILED DESCRIPTION
[0018] This invention aims to propose an interpretable unsupervised reasoning method to make up for the problems of insufficient performance and lack of interpretability of existing unsupervised reasoning methods. The overall implementation process is as follows Figure 1 As shown:
[0019] S1. Preprocess the data to be predicted and use the language model to convert each binary consisting of a question and an option into a statement.
[0020] S2. For each statement, use a language model to generate a negation and several reasons for the statement, and calculate the probability of the generation process and the probability of the statement, negation and reason respectively; the language model is mainly GPT-4Turbo, GPT-3.5Turbo, Llama3 or other language models;
[0021] S3, delete inappropriate reasons;
[0022] S4. Construct a maximum satisfiability problem based on the statement, negation, cause and related probability of each sample, and then call the ready-made symbolic solver to solve this maximum satisfiability problem to obtain the statement with the value of true, and then select the corresponding option.
[0023] Example:
[0024] The following is a sample as an example (question q is "Why is this store closed?", the two options are o1: "Because it is spring" and o2: "Because it is midnight", the correct answer is o2), the scheme of the present invention is described in detail, and the specific implementation process is as follows:
[0025] Step 1: Preprocess the sample data, including:
[0026] For a question q and a corresponding option o i The binary group (q,o i ), according to the predefined template T pre Convert this bigram into a piece of text, which is the input p of the language model i :
[0027] p i =T pre ((q,o i ))
[0028] Then, put p i Input into a language model, and then call its generation interface to get the statement h i :
[0029] h i = gen(p i )
[0030] Among them, gen() is the generation interface of the language model.
[0031] For example, for question q and option o1, according to the predefined template T pre ("Question: Option: Statement:") This tuple is converted into a piece of text, namely the input p1 of the language model, namely "Question: Why is this store closed? Option: Because it is spring. Statement:"; then, p1 is input into a language model, and then its generation interface is called to obtain statement h1, namely "This store is closed because it is spring." Similarly, the statement h2 corresponding to option o2 is "This store is closed because it is midnight."
[0032] Step 2, generate negation and recursively generate reasons, and calculate the probability of the corresponding process, such as Figure 2 As shown, the following steps are included:
[0033] Step 21: For each statement, use a language model to generate the negation of the statement and calculate the probability that the negation and the statement satisfy the XOR relationship, including:
[0034] For the statement h i , by negating the template T neg Construct the input of the language model, and then call its generation interface to get negation
[0035]
[0036] Then, by XORing the probability template T xor Will state h i and its negation Combine them into the input of the language model, and then call its scoring interface to get the probability that the two satisfy the XOR relationship:
[0037]
[0038] Among them, P() is the probability; It is an XOR relationship; score() is the interface for the language model to calculate probability (i.e. scoring).
[0039] For example, for statement h1, the template T is generated by negation neg ("Generate Negation:") Construct the input of the language model, and then call its generation interface to get the negation That is, "This store is closed because it is not spring now." Then, by finding the difference or probability template T xor ("Distinct or probability:") will state h1 and its negation Combined into the input of the language model, and then call its scoring interface to get the probability that the two meet the XOR relationship is 0.95.
[0040] Step 22: Use a language model to generate the reason why the statement is true, and calculate the probability that the reason and the statement satisfy the implication relationship; then generate the reason why the statement is false, and calculate the probability that the reason and the statement satisfy the opposition relationship, specifically including:
[0041] For the statement h i , through the reason explanation template T abd Construct the input of the language model, and then call its generation interface to get the reason why this statement is true rt i :
[0042] rt i = gen(T abd (h i ,TRUE))
[0043] Among them, TRUE is a fixed text, which means "true" and is used to state h i Combined into appropriate input; the appropriate input is specifically: the input of the language model is determined by whether the fixed text used is TRUE or FALSE. If the fixed text used is TRUE, then the input is "h (statement), explain the reason for being true:"; if the fixed text used is FALSE, then the input is "h, explain the reason for being false:".
[0044] Then, by implying the probability template T ent Will state h i and explain why it is true i Combine them into the input of the language model, and then call its scoring interface to get the probability that the two satisfy the implied relationship:
[0045] P(rt i →h i )=score(T ent (h i ,rt i ))
[0046] Among them, → is the implication relationship.
[0047] For the statement h i , using the reason explanation template T abd and a fixed text FALSE with the meaning of "false" to construct the input of the language model, and then call its generation interface to get the reason why this statement is false rf i ;
[0048] Then, by the opposition probability template T cont Will state h i and explain why it is false rf i Combine them into the input of the language model, and then call its scoring interface to get the probability that the two meet the opposition relationship
[0049] in, An opposing relationship.
[0050] For example, for statement h1, the template T is explained by the reason abd (“The reason for explaining whether it is true or false:”) constructs the input of the language model, and then calls its generation interface to obtain the reason rt1 that this statement is true, that is, “In spring, people don’t go to work.” Then, by finding the implied probability template T ent(“Find the probability of implication:”) Combine statement h1 and the reason rt1 that explains its truth into the input of the language model, and then call its scoring interface to get the probability P(rt1→h1) that the two satisfy the implication relationship, which is 0.4. Similarly, get the reason rf1 that explains statement h1 is false, that is, “Stores are generally open in spring”, and the probability that the two satisfy the opposition relationship is 0.6.
[0051] Step 23: Use a language model to generate the reason why the negation is true, and calculate the probability that the reason and the negation satisfy the implication relationship, and then generate the reason why the negation is false, and calculate the probability that the reason and the negation satisfy the opposition relationship, specifically including:
[0052] Use negation Replace the corresponding statement h i ;
[0053] Then, follow the same process as step 22 to get the negation The real reason And the probability that the two satisfy the implication relationship
[0054] Finally, follow the same process as step 22 to get the negation Reason for false And the probability that the two satisfy the opposition relationship
[0055] For example, for negation Follow the same process as step 22 to get the negation The real reason That is, "some stores are only open in spring", and the probability that the two satisfy the implication relationship is 0.3; and negative Reason for false That is, "most stores are open all year round", and the probability that the two satisfy the opposite relationship is 0.65.
[0056] Step 24: For each reason generated in step 22 and step 23, recursively generate two reasons for this reason to be true and false, and calculate the corresponding probabilities, specifically including:
[0057] Use reason i (or rf i , ) replace the corresponding statement h i (or negate );
[0058] Then, follow the same process as step 22 to get the reason rt iThe real reason rtt i (The names of other true reasons are similar, that is, t is added before the subscript i of the reason), and the probability P(rtt i →rt i );
[0059] Finally, follow the same process as step 22 to get the reason rt i Reason for false rtf i (Other reasons for falsehood are named similarly, with f added before the subscript i of the reason), and the probability that the two satisfy the opposition relationship
[0060] For example, for reason rt1, the reason rt is obtained by following a process similar to step 22. i The reason rtt1 is true, that is, "people rest in spring, so they don't go to work", and the probability P(rtt1→rt1) that the two satisfy the implication relationship is 0.8; and the reason rt1 is false, that is, rtf1, that is, "spring is the same as other seasons, when people work", and the probability that the two satisfy the opposition relationship It is 0.77.
[0061] Step 25: For each statement, negation, and reason, use a language model to calculate its probability of being true, including:
[0062] For the statement h i (The process of negation and reason is similar), through the true and false probability template T dir And combine it with the text TRUE as the input of the language model, and then call its scoring interface to get the statement h i Probability of being true:
[0063] P(h i )=score(T dir (h i ,TRUE))
[0064] For example, for statement h1 (the process of negation and reason is similar), through the true and false probability template T dir ("Find the probability of being true or false:") and combine it with the text TRUE as the input of the language model, and then call its scoring interface to get the probability P(h1) that the statement h1 is true, which is 0.4.
[0065] Step 3: Delete inappropriate reasons, including:
[0066] For the reason i And the reason why it is true rtt i , calculate the product of probabilities P(rtt i →rti )P(rtt i );
[0067] Then, similarly, for the cause rt i And the reason why it is false rtf i , calculate the product of probabilities
[0068] Finally, the cause corresponding to the larger product of the two probabilities is retained, and the other causes are handled similarly.
[0069] For example, for the cause rt1 and its true cause rtt1, the product of the probabilities P(rtt1→rt1)P(rtt1) is calculated as:
[0070] 0.8*0.3=0.24
[0071] Similarly, for the cause rt1 and its false cause rtf1, calculate the product of the probabilities for:
[0072] 0.77*0.6=0.462
[0073] Because 0.24<0.462, keep rtf1 and delete rtt1.
[0074] Step 4: Symbol inference, such as Figure 3 As shown, the following steps are included:
[0075] Step 41: For each preprocessed sample, a weighted maximum satisfiability problem is constructed based on statements, negations, reasons and their probabilities, which specifically includes the following steps:
[0076] Step 411: Initialize a weighted maximum satisfiability problem wcnf.
[0077] Step 412: add all weighted clauses of statements, negations and reasons to this question, including (taking statements as an example, negations and reasons are similar):
[0078] wcnf.append(h i ,weight=P(h i ))
[0079] Among them, append() is the interface for adding formulas, and weight is the weight of the clause;
[0080] For example, for statement h1, add the following clause:
[0081] wcnf.append(h1,weight=0.4)
[0082] Step 413: Add a single-choice formula to this question, that is, there is only one statement that is true, including:
[0083] First, add the clause that restricts at least one statement to be true:
[0084] wcnf.append(h1∨...∨h n )
[0085] Among them, ∨ is a disjunctive operation;
[0086] Then, add the clause that any two statements cannot be true at the same time:
[0087]
[0088] in, It means that for any two combinations from 1 to n, represents all possible sets of two choices from n options;
[0089] For example, the two clauses of the single-choice formula in this example are h1∨h2 and
[0090] Step 414: Add a weighted XOR formula to this problem, specifically including:
[0091]
[0092] For example, for statement h1, add the following clause:
[0093]
[0094] Step 415: Add a weighted implication formula to this problem, specifically including (the reasons for the reasons are the same):
[0095]
[0096] For example, for statement h1, add the following clause:
[0097] wcnf.append(rt1→h1, weight=0.4)
[0098] Step 416: Add a weighted opposition formula to this problem, specifically including:
[0099]
[0100] For example, for statement h1, add the following clause:
[0101]
[0102] Step 42: Use an existing symbolic solver to solve the weighted maximum satisfiability problem, obtain a true statement, and then select the corresponding option. For example, call the RC2 solver in the PySAT software package to obtain a true statement h2, and then select option o2.
[0103] Although the present invention is described herein with reference to the embodiments of the present invention, the above embodiments are only preferred embodiments of the present invention, and the embodiments of the present invention are not limited to the above embodiments. It should be understood that those skilled in the art can design many other modifications and implementations, which will fall within the scope and spirit of the principles disclosed in this application.
Claims
1. An explainable unsupervised reasoning method, characterized in that: The following steps are involved: S1: Data preprocessing: For each sample in the dataset to be predicted, the question and each option in the sample are combined into a bigram, and then each bigram is converted into a statement using a language model; S2: For each statement, use the language model to generate a negation of the statement and recursively generate the reason, and calculate the probability of the generation process and the probability of the statement, negation and reason respectively; S3: Delete inappropriate reasons based on probability; S4: Symbolic inference: For each preprocessed sample, a weighted maximum satisfiability problem is constructed based on the statement, negation, cause and related probability of each sample, and then the symbolic solver is called to solve this weighted maximum satisfiability problem to obtain the statement whose value is true, and then select the corresponding option.
2. The explainable unsupervised reasoning method according to claim 1, characterized in that: The specific steps of step S1 are as follows: The data to be predicted specifically consists of a question q and a corresponding option o i The binary group (q,o i ), according to the predefined template T pre Convert this bigram into a piece of text, which is the input p of the language model i : p i =T pre ((q,o i )) Then, put p i Input into a language model, and then call its generation interface to get the statement h i : h i =gen(p i ) Among them, gen() is the generation interface of the language model.
3. The explainable unsupervised reasoning method according to claim 2, characterized in that: The specific steps of step S2 are as follows: Step 21: For each statement, use a language model to generate the negation of the statement and calculate the probability that the negation and the statement satisfy the XOR relationship, including: For the statement h i , by negating the template T neg Construct the input of the language model, and then call its generation interface to get negation Then, by XORing the probability template T xor Will state h i and its negation Combine them into the input of the language model, and then call its scoring interface to get the probability that the two satisfy the XOR relationship: Where P() is the probability; is an XOR relationship; score() is the scoring interface of the language model; Step 22: Use a language model to generate the reason why the statement is true, and calculate the probability that the reason and the statement satisfy the implication relationship; then generate the reason why the statement is false, and calculate the probability that the reason and the statement satisfy the opposition relationship, specifically including: For the statement h i , through the reason explanation template T abd Construct the input of the language model, and then call its generation interface to get the reason why this statement is true rt i : rt i =gen(T abd (h i ,TRUE)) Among them, TRUE is a fixed text, which means "true" and is used to state h i Combined into input; then, through the implied probability template T ent Will state h i and explain why it is true i Combine them into the input of the language model, and then call its scoring interface to get the probability that the two satisfy the implied relationship: P(rt i →h i )=score(T ent (h i ,rt i )) Among them, → is the implication relationship; For the statement h i , using the reason explanation template T abd and a fixed text FALSE with the meaning of "false" to construct the input of the language model, and then call its generation interface to get the reason why this statement is false rf i ; Then, by the opposition probability template T cont Will state h i and explain why it is false rf i Combine them into the input of the language model, and then call its scoring interface to get the probability that the two meet the opposition relationship in, An opposing relationship. Step 23: Use a language model to generate the reason why the negation is true, and calculate the probability that the reason and the negation satisfy the implication relationship, and then generate the reason why the negation is false, and calculate the probability that the reason and the negation satisfy the opposition relationship; specifically including: Use negation Replace the corresponding statement h i ; Then, follow the same process as step 22 to get the negation The real reason And the probability that the two satisfy the implication relationship Finally, follow the same process as step 22 to get the negation Reason for false And the probability that the two satisfy the opposition relationship Step 24: For each reason generated in step 22 and step 23, recursively generate two reasons for this reason to be true and false, and calculate the corresponding probabilities, specifically including: Use reason i (or rf i , ) replace the corresponding statement h i (or negate ); Then, follow the same process as step 22 to get the reason rt i The real reason rtt i (The names of other true reasons are similar, that is, t is added before the subscript i of the reason), and the probability P(rtt i →rt i ); Finally, follow the same process as step 22 to get the reason rt i Reason for false rtf i (Other reasons for falsehood are named similarly, with f added before the subscript i of the reason), and the probability that the two satisfy the opposition relationship Step 25: For each statement, negation, and reason, use a language model to calculate its probability of being true, including: For the statement h i (The process of negation and reason is similar), through the true and false probability template T dir And combine it with the text TRUE as the input of the language model, and then call its scoring interface to get the statement h i Probability of being true: P(h i )=score(T dir (h i ,TRUE))。 4. The explainable unsupervised reasoning method according to claim 2, characterized in that: The specific process of step S3 is as follows: For the reason i And the reason why it is true rtt i , calculate the product of probabilities P(rtt i →rt i )P(rtt i ); Then, similarly, for the cause rt i And the reason why it is false rtf i , calculate the product of probabilities Finally, the cause corresponding to the larger product of the two probabilities is retained, and the other causes are handled similarly.
5. The explainable unsupervised reasoning method according to claim 3, characterized in that: The specific process of step S3 is as follows: Step 41: For each preprocessed sample, a weighted maximum satisfiability problem is constructed based on statements, negations, reasons and their probabilities, which specifically includes the following steps: Step 411, initialize a weighted maximum satisfiability problem wcnf; Step 412: Add all the weighted clauses of statements, negations and reasons to this question. Taking statements as an example, it is expressed as follows: wcnf.append(h i ,weight=P(h i )) Among them, append() is the interface for adding formulas, and weight is the weight of the clause; Step 413: Add a single-choice formula to this question, that is, there is only one statement that is true, including: First, add the clause that restricts at least one statement to be true: wcnf.append(h1∨…∨h n ) Among them, ∨ is a disjunctive operation; Then, add the clause that any two statements cannot be true at the same time: in, It means that for any two combinations from 1 to n, represents all possible sets of two choices from n options; Step 414: Add a weighted XOR formula to this problem, specifically including: Step 415: Add a weighted implication formula to this problem, specifically including: Step 416: Add a weighted opposition formula to this problem, specifically including: Step 42: Use a ready-made symbolic solver to solve this weighted maximum satisfiability problem, obtain statements whose values are true, and then select the corresponding options.
6. The explainable unsupervised reasoning method according to claim 4, characterized in that: The language model is mainly GPT-4Turbo, GPT-3.5Turbo, Llama3 or language model.
7. The explainable unsupervised reasoning method according to claim 4, characterized in that: The symbolic solver is the RC2 solver in the PySAT software package.