General sense reasoning method based on knowledge enhancement and semi-supervised verification
By employing knowledge augmentation and semi-supervised verification methods, ontology information is obtained and prompt templates are constructed. Combining positive samples and unlabeled learning, the problem of generating illogical common sense in common sense reasoning is solved, achieving higher quality and more diverse common sense generation.
Patent Information
- Application Number
- CN202411059018.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-02
- Publication Date
- 2024-11-15
AI Technical Summary
Existing commonsense reasoning methods do not consider the ontological information involved in commonsense, such as the category of instances and the hierarchical relationship between instance pairs, leading to the generation of unreasonable commonsense. Methods based on pre-trained language models may generate seemingly reasonable but actually erroneous information, and the small amount of data in the dataset limits the training and testing of the model.
We employ a knowledge-enhanced and semi-supervised verification approach. By obtaining ontology information through relation alignment, we construct prompt templates for common sense pre-generation and train a common sense binary classifier through positive samples and unlabeled learning to expand the dataset and enrich the common sense reasoning data.
It effectively reduced the error rate of common sense reasoning, maintained the diversity of generated common sense, improved the application effect of the model in a wider range of fields, and enhanced semantic understanding and generalization capabilities.
Smart Images

Figure CN118966358A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a common sense reasoning method based on knowledge enhancement and semi-supervised verification. Background Art
[0002] Common sense usually refers to logical statements with clear semantics that can describe the objective laws implied by data distribution. It can generally be structured as a set of conditions (If) and corresponding conclusions (Then). The above condition-conclusion expression not only simplifies the description of complex knowledge, but also introduces domain knowledge. Compared with parameter-based neural network models, the reasoning and decision-making process of common sense is more transparent, which is convenient for users to understand and verify its logical correctness. In fact, inductive common sense is an intuitive reflection of human exploration of the operating mode of the world. By refining common sense, people can not only better understand data and knowledge, but also get effective guidance in decision-making and prediction. In the computer field, common sense extraction is the key to improving information processing efficiency and system intelligence. It is widely used in financial investment, health care, social media and other fields.
[0003] Traditional common sense mining is usually based on statistical learning methods, which is a data mining process that derives common sense from closed data sets. AMIE extracts associative common sense in the form of "If antecedent Then consequent" from the knowledge base, representing the relationship between two groups of entities. The antecedent and consequent can be a collection of one or more entities, connected by one or more relations. The algorithm generates candidate common sense, uses a scoring function, and prunes low-quality common sense to generate higher-quality common sense. AMIE+ further improves the performance of this method and is used for ontology learning and link prediction. However, the above methods are difficult to narrow the search space in large knowledge bases and take a long time. In addition, their ability to learn and predict based on data patterns is also limited.
[0004] In recent years, researchers have defined a new way to acquire common sense, namely common sense reasoning. Common sense reasoning is the logical implication from given premise atoms to hypothesis atoms, which are obtained from the open world in the form of natural language. For example, if [X] is founder of [Y], we can obtain hypothesis atoms such as [X] is CEO of [Y], [X] is member of [Y], and [X] belongs to [Y] from the open world. Compared with traditional common sense generation, common sense reasoning can better cope with data mining tasks in large-scale open knowledge bases, and has more diverse atomic forms, stronger scalability and versatility.
[0005] In the common sense reasoning method, the pre-trained language model uses an unstructured form to represent knowledge, which can be used as an open knowledge base and common sense knowledge base for common sense generation. The existing unsupervised common sense generation model Orion focuses on using the pre-trained language model itself as a knowledge source and discovering the commonalities of the data therein. The model can automatically mine common sense reasoning from the pre-trained language model, breaking away from the constraints of manually annotated common sense. Although the overall quality of the common sense automatically generated by the Orion model is high, it does not consider the ontological information involved in common sense, such as the category of instances, the hierarchical relationship between instance pairs, etc., so it will generate some unreasonable common sense.
[0006] Although pre-trained language models expand the knowledge base that can be used for common sense generation, not all information generated by pre-trained language models is accurate and reliable. Existing studies have found that pre-trained language models have a memory bias for the information in the training data, and are more likely to believe that the data that appeared during the training process is correct. Due to insufficient or biased training data, limitations of model structure and learning mechanisms, pre-trained language models may generate seemingly reasonable but actually wrong information, which is called knowledge hallucination. Existing common sense reasoning methods based on pre-trained language models have not taken effective measures to alleviate this problem.
[0007] In addition, the existing common sense reasoning dataset OpenRule155 only contains 155 premise atoms and their corresponding manually annotated hypothesis atoms. The amount of data is small and the coverage is limited. The lack of scale limits the training and testing of the model, and the limitations of domain coverage make it difficult to evaluate the application effect of the model in a wider range of fields. Specifically, common sense reasoning often needs to rely on specific contexts, and identifying and understanding the nuances in the context is one of the main challenges of current applications. Secondly, humans can provide explanations and reasoning processes when performing common sense reasoning, while the current common sense reasoning system is still insufficient in providing transparency and explainability. In addition, in real application scenarios, the model's knowledge generalization ability, consistency, and diversity are also the main dilemmas of the current common sense reasoning system.
[0008] In order to solve the above problems, the present invention proposes a common sense reasoning method based on knowledge enhancement and semi-supervised verification, which incorporates ontology information for pre-generation of common sense reasoning. Common sense is generated by constraining the information contained in the ontology, and the appearance of unreasonable candidate hypothesis atoms is reduced or even avoided with the help of category information and logical hierarchical relationship information, thereby reducing the error rate of common sense generation. In order to reduce the impact of knowledge hallucinations of pre-trained language models, the present invention designs a method for post-verification of common sense based on positive samples and unlabeled learning (PU Learning). A common sense binary classifier is trained based on a small number of correct common sense samples and a large number of unlabeled common sense samples. Finally, the present invention expands the common sense reasoning data set and verifies the effectiveness of the method through a series of experiments. Further ablation experiments show that the method of the present invention maintains the diversity of generated common sense while effectively reducing the error rate of common sense reasoning. Summary of the invention
[0009] Technical problem: The technical problem to be solved by the present invention is that the existing common sense reasoning methods do not take into account the ontological information involved in common sense, such as the category of instances, the hierarchical relationship between instance pairs, etc., and therefore some unreasonable common sense will be generated. Due to insufficient or biased training data, limitations of model structure and learning mechanism, common sense reasoning methods based on pre-trained language models may generate seemingly reasonable but actually wrong information, resulting in knowledge hallucinations. Existing common sense reasoning data sets have a small amount of data and cover a limited range of fields, which limits the training and testing of the model and makes it difficult to evaluate the application effect of the model in a wider range of fields. A common sense reasoning method based on knowledge enhancement and semi-supervised verification is provided.
[0010] Technical solution: The technical solution adopted by the present invention to solve its technical problem is: a common sense reasoning method based on knowledge enhancement and semi-supervised verification. For a given premise atom [X]t[Y], this method first attempts to align the relationship. If the alignment is successful, the relevant information of the ontology can be obtained, including the logical hierarchical relationship between the instance category and the instance pair. If the alignment fails, referring to the idea of remote supervision, the instance pairs are collected in the search engine to expand the atoms, and the instance extension sets X and Y are obtained, and the ontology information is obtained through entity links. Secondly, a prompt template is constructed to perform common sense pre-generation that incorporates ontology information, including common sense reasoning based on category information and common sense reasoning based on logical hierarchical relationships, and multiple candidate hypothesis atoms [MASK]g[MASK] are obtained based on diverse decoding. Next, a common sense post-verification based on positive samples and unlabeled learning is performed, and a common sense binary classifier is trained based on a small number of correct common sense samples and a large number of unlabeled common sense samples to reduce the impact of knowledge hallucinations of the pre-trained language model. The candidate hypothesis atoms are input into the verification module one by one. If they pass the common sense correctness check, the common sense reasoning [X]t[Y]→[MASK]g[MASK] is obtained; if they fail the common sense correctness check, the common sense pre-generation model will regenerate new candidate hypothesis atoms until the specified number of common sense reasoning is reached. Finally, the present invention expands the common sense reasoning dataset and verifies the effectiveness of the method through a series of experiments. Further ablation experiments show that the method of the present invention maintains the diversity of generated common sense while effectively reducing the error rate of common sense reasoning.
[0011] The common sense reasoning method based on knowledge enhancement and semi-supervised verification of the present invention comprises the following steps:
[0012] 1) For a given premise atom [X]t[Y], define a common sense reasoning task;
[0013] 2) For the common sense reasoning task defined in step 1), for the premise atom [X]t[Y], attempt to perform relationship alignment to obtain relevant information of the ontology;
[0014] 3) For the ontology information obtained in step 2), common sense pre-generation is performed by constructing a prompt template to integrate the ontology information, including common sense reasoning based on category information and common sense reasoning based on logical hierarchical relationships;
[0015] 4) For the common sense obtained in step 3), a common sense post-verification based on positive samples and unlabeled learning is performed, and a common sense binary classifier is trained based on a small number of correct common sense samples and a large number of unlabeled common sense samples to reduce the influence of knowledge hallucination of the pre-trained language model;
[0016] 5) Expand the existing data set to construct a correct common sense sample set that conforms to common sense and knowledge base knowledge,
[0017] Complete the training and testing of the model described in the present invention.
[0018] As a further improvement of the present invention, in step 1), the common sense reasoning task is defined as: for the premise atom [X]t[Y], obtain the hypothesis atom [MASK]g[MASK], and construct the common sense reasoning [X]t[Y]→[MASK]g[MASK].
[0019] As a further improvement of the present invention, in step 2), if the alignment is successful, then the relevant information of the ontology can be obtained, including the logical hierarchical relationship between instance categories and instance pairs. Specifically, for the premise atom [X]t[Y], the relationship t therein is known. The present invention uses the open source information extraction tool OpenIE to perform relationship alignment. If the relationship alignment is successful, the instance category pair set of X and Y can be obtained. and the set of standard instance names This paper assumes that the instance categories in the knowledge graph are correct, so random sampling is used to determine the standard categories k of X and Y. x , k " , to improve the diversity of common sense generation.
[0020] In step 2), if the alignment fails, refer to the idea of remote supervision, collect instance pairs in the search engine to expand atoms, obtain instance extension sets X and Y, and obtain ontology information through entity linking. Specifically, use the query "*t*" (where * represents a wildcard) to search for non-repetitive natural language sentences containing relation t in the Google search engine. Filter out interrogative words such as who, where, when, single letters that do not have actual semantics such as B and C, and (indefinite) pronouns such as he, she, anything, and everyone, and you can get an instance extension set where X and Y meet the condition of relation t. Next, for Each instance in the collection is linked to entities using Spacy to determine its category and determine the standard category k of the instance based on the voting mechanism. x , k " In addition, the collection y s Record the standard instance names returned by Spacy. Finally, filter the natural sentences with the correct instance category to determine the standard instance names. If the instance pair (x, y) from the same sentence satisfies x∈k x , y∈k " , then from Take out the standard instance name x from the collection s ,y s .
[0021] As a further improvement of the present invention, in step 3), instance category information and logical hierarchical relationship information between instance pairs are introduced in the process of common sense generation, thereby improving the accuracy of common sense generation. The common sense reasoning process based on category information is as follows: in step 2), the category information of the instance in the premise atom has been obtained. Based on the above prompt, a prompt "The type of [X] is Type x ","The type of[Y]is Type y " to incorporate instance category information.
[0022] In step 3), the common sense reasoning process based on the logical hierarchical relationship is as follows: In step 2), the logical hierarchical relationship information I of the instance pair is also obtained. h First, remove the root node prefix "Root / ", and then split the relationship information by words and separators. At the decoding end, use the above word information as a prompt to help decode, and finally achieve the goal of integrating the logical hierarchical relationship of the instance.
[0023] In step 3), the Topp kernel sampling common sense decoding method is used to enrich the diversity of generated common sense. Topp kernel sampling follows the basic idea of truncated sampling space, but no longer fixes k. Instead, it fixes the probability density of the candidate set and its proportion in the entire probability distribution to construct a minimum candidate set. Specifically, at time step Δt, for each word v t , retain the candidate word subset with the largest softmax probability value and the cumulative probability just greater than p as the next candidate word set
[0024] As a further improvement of the present invention, in step 4), a common sense post-verification based on positive samples and unlabeled learning is performed to reduce the influence of knowledge hallucination of the pre-trained language model. The present invention trains a common sense binary classifier based on a small number of correct common sense samples and a large number of unlabeled common sense samples. In the common sense binary classification based on label distribution alignment, the set of labeled correct common sense samples is defined as r L , the unlabeled common sense sample set is r U , r S Represents the entire training sample set, that is, r S =r L ∪r U The goal of the common sense post-verification module is to train a binary classification model C(r s ,θ), where r s Yes S A common sense in r s ∈r S ; θ is a learnable parameter vector in m-dimensional Euclidean space, that is When given the input common sense r s When , the model outputs the predicted label of this common sense 0 indicates common sense is wrong, and 1 indicates common sense is correct. In order to update the parameters of the model in an end-to-end manner and continuously adjust and optimize, empirical risk Estimate expected risk.
[0025] In step 4), the present invention uses entropy minimization technology to improve the classification effectiveness of the binary classification model. The present invention introduces entropy minimization technology to make the prediction score s of the input common sense as close to 0 or 1 as possible, rather than focusing on the middle value (such as π p ). Entropy loss function The definition is as follows:
[0026]
[0027] Where s = σ[C(r u ,θ)] is the model for each unlabeled common sense r u The entropy loss function is the largest when s is close to 0.5 and the smallest when s is close to 0 or 1. By minimizing this loss function, positive and negative samples can be effectively distinguished while maintaining low entropy.
[0028] In step 4), the present invention optimizes the proposed classification model based on Mixup regularization. Although entropy minimization technology can strengthen the bimodal distribution of unlabeled common sense prediction scores, it is prone to a common problem in semi-supervised learning: confirmation bias. This is because the model is overconfident about its own prediction errors. Based on the principle of marginal risk minimization, the present invention uses Mixup regularization for optimization. Each time a new sample is generated, two common sense samples are randomly selected. Then randomly extract γ from the Beta distribution, calculate γ′=max(γ,1-γ), and obtain the mixed common sense sample through linear interpolation And make r s The prediction score of ′ is The linear interpolation of is consistent to alleviate the phenomenon of overfitting erroneous data.
[0029] In summary, the common sense binary classification model involves three loss functions, including the empirical risk loss function Entropy loss function and Mixup regularization term Therefore, the overall optimization goal is:
[0030]
[0031] Among them, δ and μ are learnable parameters, δ adjusts Importance of μ control strength.
[0032] As a further improvement of the present invention, in the step 5), the present invention expands the OpenRule155 dataset, mines the potential derivable relations in the knowledge graph WikiData, and constructs the common sense reasoning dataset ORExt. The fields covered by the OpenRule155 dataset are limited, and the amount of data is small, which is not enough to complete the training and testing of the model described in the present invention. Therefore, the present invention expands the OpenRule155 dataset, constructs prompts, and generates more common sense reasoning with richer fields based on the common sense knowledge by imitating the existing premise atoms and manually annotated hypothesis atoms through the large language model ChatGPT. In addition, the present invention records potential derivable relationship combinations as common sense reasoning based on the co-occurrence frequency of relationship pairs in the knowledge graph. The data is cleaned and manually verified, and the data that does not meet the requirements is modified or deleted. Finally, the common sense reasoning dataset ORExt is constructed to complete the training and testing of the model described in the present invention.
[0033] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the common sense reasoning method based on knowledge enhancement and semi-supervised verification when executing the program.
[0034] A computer-readable storage medium stores computer instructions, which, when executed by a processor, implement the common sense reasoning method based on knowledge enhancement and semi-supervised verification.
[0035] Beneficial effects:
[0036] Compared with the prior art, the present invention has the following advantages: 1) The existing common sense reasoning method does not consider the ontological information involved in common sense, such as the category of the instance, the hierarchical relationship between the instance pairs, etc., so some unreasonable common sense will be generated. The present invention, by constructing a prompt template, pre-generates common sense that incorporates ontological information, introduces instance category information and logical hierarchical relationship information between instance pairs in the process of common sense generation, and improves the accuracy of generating common sense; and adopts the Topp kernel sampling common sense decoding method to enrich the diversity of generated common sense. 2) The existing common sense reasoning method based on pre-trained language model may generate seemingly reasonable but actually wrong information due to insufficient training data or deviation, model structure and learning mechanism limitations, resulting in knowledge hallucination. The present invention designs a method for post-verification of common sense based on positive samples and unlabeled learning, and trains a common sense binary classifier based on a small number of correct common sense samples and a large number of unlabeled common sense samples to reduce the impact of knowledge hallucination of pre-trained language model. 3) The existing common sense reasoning data set has a small amount of data and covers a limited field, which limits the training and testing of the model and makes it difficult to evaluate the application effect of the model in a wider range of fields. The present invention expands the existing data set and constructs a common sense reasoning data set ORExt covering 15 fields such as politics, business, technology, and sports, which contains a total of 45,370 data items and completes the training and testing of the model described in the present invention.
[0037] Experimental analysis has proved that the common sense reasoning method based on knowledge enhancement and semi-supervised verification proposed in this method effectively reduces the common sense error rate while maintaining the diversity of generated common sense, enabling the model to demonstrate stronger semantic understanding ability and generalization ability for new samples in practical applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 It is a basic process schematic diagram of the present invention,
[0039] Figure 2 It is a model framework diagram of the present invention,
[0040] Figure 3 is the premise atomic expansion instance of the present invention,
[0041] Figure 4 is the category information of different instances of the present invention,
[0042] Figure 5 This is the common sense reasoning process of the present invention that incorporates ontology information.
[0043] Figure 6 This is the overall flow chart of the common sense post-verification based on label distribution alignment of the present invention,
[0044] Figure 7 This is a schematic diagram of the main sources of the ORExt dataset of the present invention.
[0045] Figure 8 It is a line graph comparing the common sense fluency and the quality index of the present invention through an ablation experiment. DETAILED DESCRIPTION
[0046] The present invention will be further described below in conjunction with the embodiments and the accompanying drawings.
[0047] Example: See Figure 1 — Figure 8 , the common sense reasoning method based on knowledge enhancement and semi-supervised verification includes the following steps:
[0048] 1) For a given premise atom, define a common sense reasoning task. As the core technology of the semantic web, ontology provides shared vocabulary and conceptual knowledge for specific application domains and constrains the relationship between instances through semantic patterns. Specifically, ontology describes concepts, instances, and the relationship between them, which can be formally expressed as in, Represents the set of concepts, instances, relations, and triples respectively. It can be further expressed as Among them, r e is an instance of a relation, r c is a subclass of Relationship, is a general relation set. Can be divided into type sets Subclass Collection General relation set Three disjoint subsets, each formally defined as follows:
[0049]
[0050] Common sense uses universal symbols to represent the knowledge in the data. The present invention uses a headed Horn Clause containing a common sense head to define common sense, and defines the relationship of common sense reasoning as a natural language sentence that describes a certain relationship between two instances (or concepts). The formal definition is as follows:
[0051] Common sense reasoning: Common sense reasoning r is based on the premise atom (e a ,t,e b ) to the hypothetical atom (e a ,g,e b ) implies:
[0052] (e a ,t,e b )→(e a ,g,e b )
[0053] Where t and g are natural language descriptions. This common sense means that pairs of instances with relation t (usually) also have relation g. For example, the common sense reasoning (x, is expert in, y) → (x, knows a lot about, y) indicates that when x is known to be an expert in the field of y, there is usually a relationship that x knows a lot about y. And (John, is expert in, python) → (John, knows a lot about, python) is an example of the above common sense reasoning.
[0054] Common sense reasoning summarizes and generalizes common sense from an open knowledge base, and is the process of deriving new information from known information. Therefore, common sense reasoning requires calculating the probability of deriving the common sense head from the common sense body. The specific definition of the problem is as follows:
[0055] Common sense reasoning: For the premise atom [X]t[Y], obtain the hypothesis atom [MASK]g[MASK] and construct the common sense reasoning [X]t[Y]→[MASK]g[MASK].
[0056] 2) For the premise atom [X]t[Y], first try to align the relationship. If the alignment is successful, the relevant information of the ontology can be obtained, including the logical hierarchical relationship between instance categories and instance pairs. If the alignment fails, refer to the idea of remote supervision, collect instance pairs in the search engine to expand the atom, obtain the instance extension set X, Y, and obtain the ontology information through entity linking.
[0057] Specifically, for the premise atom [X]t[Y], if the relationship t is known, if the relationship can be connected with the existing relationship in the knowledge graph through relationship alignment, the subsequent work of introducing ontology information can be carried out. The present invention uses the open source information extraction tool OpenIE tool to perform relationship alignment. If the relationship alignment is successful, the instance category pair set of X and Y can be obtained. and the set of standard instance names This paper assumes that the instance categories in the knowledge graph are correct, so random sampling is used to determine the standard categories k of X and Y. x , k " , to improve the diversity of common sense generation. For example, when t is located in, possible instance category pairs of X and Y include (city, country), (building, city), (mountain, region), etc., and k are randomly sampled from them. x , k " .
[0058] If the relationship alignment fails, refer to the idea of remote supervision and use the query "*t*" (where * represents a wildcard) to search for non-repeated natural language sentences containing the relationship t in the Google search engine. Filter out interrogative words such as who, where, when, single letters without actual semantics such as B and C, and (indefinite) pronouns such as he, she, anything, and everyone, and you can get an extended set of instances where X and Y meet the relationship t conditions. Next, for Each instance in the collection is linked to entities using Spacy to determine its category and determine the standard category k of the instance based on the voting mechanism. x , k " In addition, the collection Record the standard instance names returned by Spacy. Finally, filter the natural sentences with the correct instance category to determine the standard instance names. If the instance pair (x, y) from the same sentence satisfies x∈k x , y∈k " , then from Take out the standard instance name x from the collection s ,y s .
[0059] Let's take the premise atom [X] is president of [Y] as an example and proceed step by step to the atomic expansion process. Figure 3 First, search "*is president of*" in Google to get the sentences containing the is president of relationship. According to the filtering common sense of the present invention, we can further get the extended set of examples. Entity links can be used to determine the respective categories and standard instance name sets Extending a collection with an instance For example, different instances belong to categories such as Figure 4 According to the voting mechanism, k x =human. Similarly, we can determine k " = country. In the sentence Obama is president of United States, the instances Obama and United States belong to the human class and country class respectively, and both categories are correct. Therefore, from the standard instance name set Take out the standard instance name, x s For Barack Obama, s For the United States of America.
[0060] Based on the above steps, we search for standard instance name pairs (x s ,y s ) to obtain the logical hierarchical relationship information of the instance pair I h For example, by querying the relationship between Barack Obama and the United States of America in Freebase through SPARQL statements, we can get I h =Root / people.person.nationality.
[0061] 3) For the ontology information obtained in step 2), common sense pre-generation is performed by constructing a prompt template to integrate the ontology information, including common sense reasoning based on category information and common sense reasoning based on logical hierarchical relationships. In order to measure the quality of generated common sense, the present invention introduces the uncertainty of common sense in probabilistic modeling. Common sense reasoning integrated into ontology information requires calculating the probability of deriving the common sense head from the common sense body and further integrating it into the ontology information. The formal expression is as follows:
[0062]
[0063] Among them, O represents the ontology information obtained according to the current relationship t, including the instance category information applicable to the relationship t and the logical hierarchical relationship information between instance pairs. For example, P(O|t=[X]is president of[Y]) represents the ontology information introduced when the current premise atom is [X]is president of[Y], mainly including the category of [X]=human, the category of [Y]country, and the logical hierarchical relationship between [X] and [Y]people.person.nationality. P(g=[MASK]iscitizen of[MASK]|O,t=[X]is president of[Y]) represents the conditional probability of obtaining the candidate hypothesis atom [MASK]is citizen of[MASK] when the premise atom [X]is presidentof[Y] and the corresponding ontology information O are known.
[0064] In the language model, P(g|O,t) can be regarded as a special case of the Masked Language Model (MLM). P(g|O,t) is equivalent to predicting the masked text between [X] and [Y] given the ontology O and the relation t. The probability can be detected by constructing prompts. In the common sense reasoning process, a mask may correspond to multiple tokens. Therefore, the present invention uses BART as the basic model, and decodes one or more tokens for each mask through a sequence-to-sequence model. The overall model structure is as follows: Figure 5 shown.
[0065] First, the prompt "[X]t[Y]" is constructed based on the premise atoms. In addition, in order to make full use of the instance category information and the logical hierarchy information of the instance pair obtained in step 2), the present invention adopts common sense reasoning based on category information and common sense reasoning based on logical hierarchy relationship. The specific operations are as follows:
[0066] Common sense reasoning based on category information: In step 2), the category information of the instance in the premise atom has been obtained. Based on the above prompt, we further construct the prompt "The type of [X] is Type x ","The type of[Y]is Type y ” to incorporate instance category information. For example, in the premise atom [X] is president of [Y], the category of [X] is person and the category of [Y] is country, then additional prompts “The type of [X] is person” and “The type of [Y] is country” are constructed.
[0067] Common sense reasoning based on logical hierarchical relationships: In step 2), the logical hierarchical relationship information I of the instance pair is also obtained. h First, remove the root node prefix "Root / ", and then split the relationship information by word and separator. At the decoding end, use the above word information as a prompt to help decode, and finally achieve the goal of integrating the logical hierarchical relationship of the instance. For example, for the existing logical hierarchical relationship information I h =Root / people.person.nationality. After removing the prefix, we get people.person.nationality, which can be split into three prompt words: people, person, and nationality. These prompt words are input one by one between [CLS] and [BOS] at the decoding end.
[0068] Then common sense diverse decoding is performed. Common sense reasoning decoding with ontology information is a typical probabilistic text generation process. All possible generation relations g can be formally defined as g = { <bos>v1,v2,...,v . <eos>|v i ∈v}, where i∈1,2,...,n, <bos> 、 <eos>They are the text start and end markers, v i is each word in the current generation relation, and v is the set of all candidate words. In other words, when decoding common sense, <bos> 、 <eos>The existing generator is parameterized by learning a set of weights θ through a neural network, considering the local reduction model, that is, the model p θ is defined as the product of probability distributions:
[0069]
[0070] Where x represents the input information, including the given relation t and the instance category and logical hierarchy information that conform to the relation t, and Δt represents the time step. When Δt>1, each p > (·|x,v1,v2,...,v Δt-1 ) are satisfied When Δt=1,
[0071] The decoding goal of text generation is to find the most likely hypothesis among all candidate hypotheses, and the present invention expects to find the most likely hypothesis among all candidate common sense relation sets. The most likely generation relationship g is found in , that is, the goal of the present invention is to solve the following optimization problem:
[0072]
[0073] Greedy decoding selects the word with the highest probability at each time step, but it is easy to fall into local optimum. Compared with the greedy algorithm, beam search optimizes the decoding process, but there are still problems such as repetition or contradiction in the context of the text and no actual logical meaning. Some scholars pointed out that the root cause of the above problems is the decoding strategy that attempts to maximize the conditional probability of the sequence, and by comparing the conditional probability of human-written text and machine-generated text word sequences, it is revealed that humans do not always choose the word with the highest probability. One improvement is to truncate the output probability distribution before sampling, that is, select the k words with the highest probability to form a set, and then normalize the probabilities of the words in the set, and finally sample the vocabulary on the new probability distribution. Topp kernel sampling follows the basic idea of truncating the sampling space, but no longer fixes k. Instead, it fixes the probability density of the candidate set and its proportion in the entire probability distribution to construct a minimum candidate set. Specifically, at the time step Δt, for each word v t , retain the candidate word subset with the largest softmax probability value and the cumulative probability just greater than p as the next candidate word set v (p) , which is formally defined as follows:
[0074]
[0075] make And normalized to a probability distribution, that is, the probability of words in the set is renormalized, and the probability of words outside the set is set to 0. The formal definition is as follows:
[0076]
[0077] 4) The common sense obtained in step 3) is subjected to a common sense post-verification based on positive samples and unlabeled learning, and a common sense binary classifier is trained based on a small number of correct common sense samples and a large number of unlabeled common sense samples to reduce the influence of knowledge hallucinations of the pre-trained language model. Although the present invention constrains common sense generation through the category information of instances and the logical hierarchical relationship information between instances, the correctness of the generated common sense still needs to be improved due to problems such as knowledge hallucinations in the pre-trained language model. Therefore, the present invention hopes to construct a binary classifier for judging the correctness of common sense through a common sense post-verification module to eliminate some erroneous common sense, so as to further improve the quality of generated common sense.
[0078] Under the Closed-World Assumption (CWA), it is usually assumed that the knowledge graph contains all knowledge. Therefore, any information not recorded in the knowledge graph is considered invalid or wrong. However, since the knowledge graph itself may not be complete, the above assumption will lead to some correct common sense being mistakenly ignored. In other words, according to the existing predefined relations r in the knowledge graph, G-H Common sense that cannot be mined is not necessarily wrong. In addition, compared with the established correct common sense, the number of wrong common sense is large and the types are diverse, making it difficult to construct a complete set of wrong common sense samples.
[0079] In order to construct a set of correct common sense samples, the present invention expands the OpenRule155 dataset and mines the potential derivable relationships in the knowledge graph. The specific method is detailed in step 5). Therefore, the present invention will learn a common sense binary classification model from a small number of positive samples and a large amount of unlabeled data. This is a typical positive sample and unlabeled learning (Positive Unlabeled Learning, PUL) scenario. At the same time, the common sense pre-generation model proposed in step 3) shows strong stability, and the prior probability of generating correct common sense is π p When the class is known a priori, the label distribution of the unlabeled data is fixed, and the learning optimization of the supervised classification model can be used to make the distribution between the predicted label and the true label as consistent as possible. The overall process of post-verification based on the common sense of label distribution alignment is as follows: Figure 6 shown.
[0080] In the common sense binary classification based on label distribution alignment, the set of labeled correct common sense samples is defined as r L , the unlabeled common sense sample set is r U , r S Represents the entire training sample set, that is, r S =r L ∪r U The goal of the common sense post-verification module is to train a binary classification model C(r s ,θ), where r s Yes S A common sense in r s ∈r s ; θ is a learnable parameter vector in m-dimensional Euclidean space, that is When given the input common sense r s When , the model outputs the predicted label of this common sense Among them, 0 means common sense is wrong, and 1 means common sense is correct.
[0081] The basic goal of this binary classifier is to minimize the average prediction error, that is, the expected risk The formal expression is as follows:
[0082]
[0083] Among them, y∈{0,1} represents r s The true label of is a 0-1 loss function, when 0 when it is, otherwise 1. I (·) indicates that in the entire training sample set r S expectations.
[0084] Due to r U is a set of unlabeled samples, in which the common sense samples do not contain the true label y, so the key to solving the problem lies in how to calculate the loss function of this part. Considering the stability of the common sense pre-generation model, the prior probability π of generating correct common sense p Basically remain unchanged. Let’s assume that the entire training sample set r S The correct and wrong common sense sample sets are r P 、r N ,but Reconstructible into correct common sense expected risk Risks of False Common Sense Expectations sum:
[0085]
[0086] Substitute the 0-1 loss function L(·,·) into Can be further refactored as:
[0087]
[0088] in, That is for
[0089] Next, through the prior probability π p Guide the model to learn so that the distribution between the predicted labels and the true labels is as consistent as possible. For example, for the correct common sense r p ,r p ∈r P , the expectation of the predicted label should be 1; while in the unlabeled common sense sample set r U In the process, correct common sense should account for π p Therefore, E U As close to π as possible p .
[0090]
[0091] Combining the above two formulas and considering the possible negative numbers in the calculation process, we can get:
[0092]
[0093] in, Expect risks for unmarked common sense
[0094] At this point, you can use r L The true label and r in U The prior probability of correct common sense in p calculate In order to update the model parameters in an end-to-end manner and continuously adjust and optimize, empirical risk Estimate expected risk:
[0095]
[0096] Among them, n L 、n U are the correct common sense sample sets r L , unlabeled common sense sample set r U is the number of common sense in , and σ is the sigmoid function.
[0097] Then, the present invention uses entropy minimization technology to improve the classification effectiveness. In the formula, if r U The score of each common sense in is calculated as π p , and a seemingly low loss can also be obtained. At this time, all unlabeled samples have the same score, and the model does not consider the specific characteristics of the input data, so it fails to distinguish correct common sense from incorrect common sense and has no application value. To avoid this situation, the present invention introduces entropy minimization technology to make the predicted score s of the input common sense as close to 0 or 1 as possible, rather than focusing on the middle value (such as π p ). Entropy loss function The definition is as follows:
[0098]
[0099] Where s = σ[C(r u ,θ)] is the model for each unlabeled common sense r u The entropy loss function is the largest when s is close to 0.5 and the smallest when s is close to 0 or 1. By minimizing this loss function, positive and negative samples can be effectively distinguished while maintaining low entropy.
[0100] Finally, the present invention optimizes the proposed model based on the standard empirical risk minimization estimator Mixup. Although the entropy minimization technique can strengthen the bimodal distribution of unlabeled common sense prediction scores, it is prone to a common problem in semi-supervised learning: confirmation bias. This is because the model is overconfident about its own prediction errors. Based on the principle of marginal risk minimization, the present invention uses Mixup regularization for optimization. Each time a new sample is generated, two common sense samples are randomly selected. Then randomly extract γ from the Beta distribution, calculate γ′=max(γ,1-γ), and obtain the mixed common sense sample through linear interpolation And make r s The prediction score of ′ is The linear interpolation of is consistent to alleviate the phenomenon of overfitting erroneous data. Mixup regularization term The formula definition is as follows:
[0101]
[0102] Among them, the binary cross entropy loss function H(a′,a)=-(1-a)log(1-a′)-alog(a′), s′, s1, and s2 are r s '、 The prediction score of .
[0103] In summary, the common sense binary classification model involves three loss functions, including the empirical risk loss function Entropy loss function and Mixup regularization term Therefore, the overall optimization goal is:
[0104]
[0105] Among them, δ and μ are learnable parameters, δ is used to adjust Importance of μ control strength.
[0106] 5) Expand the existing data set to construct a correct sample set that conforms to common sense and knowledge base knowledge, and complete the training and testing of the model described in the present invention. The present invention expands the OpenRule155 data set and mines the potential derivable relationships in the knowledge graph WikiData. The OpenRule155 data set is a common sense reasoning data set, which contains 155 premise atoms and their corresponding manually labeled hypothesis atoms. Since the data set covers a limited range of fields, mainly character relationships and geographic locations, and the amount of data is small, it is not enough to complete the training and testing of the model described in the present invention. Therefore, the present invention expands the OpenRule155 data set and constructs Figure 7 The prompts shown allow the large language model ChatGPT to generate more common sense reasoning with richer fields based on common sense knowledge and by imitating existing premise atoms and manually annotated hypothesis atoms.
[0107] In addition, the present invention records potential derivable relationship combinations as common sense reasoning based on the co-occurrence frequency of relationship pairs in the knowledge graph. a and e b Represent two instances in the knowledge graph, and r a and r b Respectively represent the relationship connecting these two instances. If the knowledge graph contains the triple pair [(e a ,r a ,e b ),(e a ,r b ,e b )], denoted as r a and r b Occurs once. N ab Represents r a and r b Number of co-occurrences, N a 、N b Respectively represent r a 、r b The total number of occurrences of each When a 、r b When the ratio of the number of co-occurrences to the sum of the total number of occurrences of each pair exceeds the threshold η, the relationship pair (r a ,r b ). After traversing the knowledge graph, the above relationship pairs are input into the large language model ChatGPT one by one, and the following is constructed: Figure 7 Through the above prompts, ChatGPT will judge the relationship between the two pairs (r a ,r b ) can be deduced between them. If the relationship r a It can be deduced that r b , then the relationship expressed in natural language form is Add to the collection of correct common sense samples.
[0108] Based on the above steps, the present invention performs data cleaning and manual verification, modifies or deletes data that do not meet the requirements, and finally constructs the common sense reasoning dataset ORExt ( O pen R ule Ext end), containing a total of 45,370 data items, each of which includes premise atoms and generated standard hypothesis atoms, covering the fields of politics, business, technology, sports, entertainment, health, environment, lifestyle, children, film and television, physics, chemistry, biology, earth science, and education.
[0109] The above embodiments are only preferred implementation modes of the present invention. It should be pointed out that ordinary technicians in this technical field can make several improvements and equivalent substitutions without departing from the principles of the present invention. These technical solutions after improvements and equivalent substitutions to the claims of the present invention all fall within the protection scope of the present invention.
[0110] This example uses the following indicators for evaluation:
[0111] In order to evaluate the fluency and quality of the generated common sense, the present invention uses BLEU-n and ROUGE-L for evaluation. Considering that the length of common sense is generally short, n is taken as 1, 2, 3, and 4. BLEU-n is used to evaluate the degree of overlap between the generated results and the standard results, and ROUGE-L evaluates the longest common substring between the generated results and the standard results. In order to evaluate the diversity of the common sense generated by the model, the present invention uses distinct-3 and self-BLEU-2 for evaluation, where the larger the value of the distinct-3 indicator, the higher the diversity of the generated common sense, and the smaller the value of the self-BLEU-2 indicator, the higher the diversity of the generated common sense.
[0112] In order to verify the effect of the present invention, the single-challenge common sense reasoning model was evaluated on the common sense reasoning dataset ORExt constructed by the present invention. The present invention randomly rearranged the ORExt dataset and divided it into four subsets in a ratio of 7:1:1:1, which are respectively recorded as training set 1, training set 2, validation set and test set. Among them, the samples in training set 1 are used to train the common sense pre-generation model that incorporates ontology information; and the samples in training set 2 are used as positive sample sets to train the common sense post-verification model based on positive samples and unlabeled learning, and the premise atoms in training set 2 are input into the above-mentioned common sense pre-generation model, thereby generating a large number of common sense reasoning as unlabeled data to jointly train the common sense post-verification model.
[0113] The experimental results are as follows. The ablation experiment comparison of common sense fluency and quality indicators is shown in Figure 8 :
[0114] Table 1 Overall experimental results of different common sense reasoning models on the ORExt dataset
[0115]
[0116] Table 2 Ablation experiment results of common sense diversity index
[0117]
[0118] The present invention achieves the best performance on the data set and has a significant improvement compared to other methods.
[0119] It should be noted that the above embodiments are not intended to limit the protection scope of the present invention, and equivalent changes or substitutions made on the basis of the above technical solutions all fall within the protection scope of the claims of the present invention.< / eos> < / bos> < / eos> < / bos> < / eos> < / bos>
Claims
1. A common sense reasoning method based on knowledge enhancement and semi-supervised verification, It is characterized in that The steps include: 1) For a given premise atom [X]t[Y], specify the common sense reasoning task; 2) For the common sense reasoning task defined in step 1), for the premise atom [X]t[Y], attempt to perform relationship alignment to obtain relevant information of the ontology; 3) The ontology information obtained in step 2) is integrated with the common sense of the ontology information by constructing a prompt template. Knowledge pre-generation, including common sense reasoning based on category information and common sense generation based on logical hierarchical relationships; 4) For the common sense obtained in step 3), a common sense post-verification based on positive samples and unlabeled learning is performed, and a binary classifier is trained and verified based on a small number of correct common sense samples and a large number of unlabeled common sense samples to reduce pre-training The influence of the knowledge illusion of practicing language models; 5) Expand the existing data set to construct a correct sample set that conforms to common sense and knowledge base knowledge, and complete Training and testing of the model.
2. The common sense reasoning method based on knowledge enhancement and semi-supervised verification according to claim 1, It is characterized in that In the step 1), the common sense reasoning task is defined as: for the premise atom [X]t[Y], obtain the hypothesis atom [MASK]g[MASK], and construct the common sense reasoning process [X]t[Y]→[MASK]g[MASK].
3. According to the common sense reasoning method based on knowledge enhancement and semi-supervised verification as described in claim 1, It is characterized in that In step 2), if the alignment is successful, relevant information of the ontology can be obtained, including the logical hierarchical relationship between instance categories and instance pairs. Specifically, for the premise atom [X]t[Y], the relationship t is known, and the open source information extraction tool OpenIE tool is used to align the relationship. If the relationship alignment is successful, the instance category pair set of X and Y can be obtained. and the set of standard instance names The instance categories in the knowledge graph are all correct, and the standard categories k of X and Y are determined by random sampling. x , k " , to improve the diversity of common sense generation; In the step 2), if the alignment fails, refer to the idea of remote supervision, collect instance pairs in the search engine to expand atoms, obtain instance extension sets X and Y, and obtain ontology information through entity linking. Specifically, use the query "*t*" (where * represents a wildcard) to search for non-repetitive natural language sentences containing relation t in the Google search engine, filter out question words such as who, where, when, single letters that do not have actual semantics such as B, C, and (indefinite) pronouns such as he, she, anything, and everyone, and obtain instance extension sets X and Y that meet the condition of relation t. Next, for Each instance in the collection is linked to entities using the open source natural language processing tool Spacy to determine their respective categories and determine the standard category k of the instance based on the voting mechanism. x , k " In addition, the set Record the standard instance names returned by Spacy. Finally, filter the natural sentences with the correct instance category to determine the standard instance names. If the instance pair (x, y) from the same sentence satisfies x∈k x , y∈k " , then from Take out the standard instance name x from the collection s ,y s .
4. The common sense reasoning method based on knowledge enhancement and semi-supervised verification according to claim 1, It is characterized in that In step 3), instance category information and logical hierarchical relationship information between instance pairs are introduced in the process of common sense generation, which improves the accuracy of common sense generation. The common sense generation process based on category information is as follows: In step 2), the category information of the instance in the premise atom has been obtained. Based on the above prompt, a prompt "The type of [X] is Type x ”, "The type of [Y] is Type y " to incorporate instance category information.
5. The common sense reasoning method based on knowledge enhancement and semi-supervised verification according to claim 1, It is characterized in that In step 3), the common sense generation process based on the logical hierarchical relationship is as follows: In step 2), the logical hierarchical relationship information I of the instance pair is also obtained. $ First, remove the root node prefix "Root / ", then split the relationship information by words and separators. At the decoding end, use the above word information as prompts to help decode, and finally achieve the goal of integrating the logical hierarchical relationship of the instance; In step 3), the kernel sampling method Topp is used to perform common sense decoding. At the time step Δt, for each word v % , retain the candidate word subset with the largest softmax probability value and cumulative probability greater than p as the next candidate word set 6. The common sense reasoning method based on knowledge enhancement and semi-supervised verification according to claim 1, It is characterized in that In step 4), a binary classifier is trained and tested based on a small number of correct common sense samples and a large number of unlabeled common sense samples. In the common sense binary classification based on label distribution alignment, the set of labeled correct common sense samples is defined as r L , the unlabeled common sense sample set is r U , r S Represents the entire training sample set, i.e. r S =r L ∪r U The goal of the common sense post-test module is to train a binary classification model C(r s ,θ), where r s Yes s A common sense in r s ∈r s ; θ is a learnable parameter vector in m-dimensional Euclidean space, that is When given the input common sense r s When , the model outputs the predicted label of this common sense 0 indicates common sense error, and 1 indicates common sense correctness. In order to update the parameters of the model in an end-to-end manner and continuously adjust and optimize, empirical risk Estimate expected risk.
7. The common sense reasoning method based on knowledge enhancement and semi-supervised verification according to claim 1, It is characterized in that In step 4), the entropy minimization technique is used to improve the classification effectiveness of the binary classification model. The entropy minimization technique is introduced to make the prediction score s of the input common sense as close to 0 or 1 as possible, rather than concentrating on the middle value (such as π p ), entropy loss function The definition is as follows: Where s = σ[C(r 3 ,θ)] is the model for each unlabeled common sense r 3 The entropy loss function is the largest when s is close to 0.5 and the smallest when s is close to 0 or 1. By minimizing this loss function, positive and negative samples can be effectively distinguished while maintaining low entropy.
8. The common sense reasoning method based on knowledge enhancement and semi-supervised verification according to claim 1, It is characterized in that In step 4), the standard empirical risk minimization estimator Mixup is used for optimization. Each time a new sample is generated, two common sense samples are randomly selected. Then randomly extract γ from the Beta distribution Beta, calculate γ′=max(γ,1-γ), and obtain the mixed common sense sample through linear interpolation And make r s The prediction score of ′ is The linear interpolation of is consistent to alleviate the phenomenon of overfitting erroneous data. The common sense binary classification model involves three loss functions, including the empirical risk loss function Entropy loss function and Mixup regularization term The overall optimization goal is: Among them, δ and μ are learnable parameters, δ adjusts Importance of μ control strength.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, Features: When the processor executes the program, the common sense reasoning method based on knowledge enhancement and semi-supervised verification as described in any one of claims 1 to 8 above is implemented.
10. A computer-readable storage medium having computer instructions stored thereon, Features: When the computer instructions are executed by a processor, the common sense reasoning method based on knowledge enhancement and semi-supervised verification as described in any one of claims 1 to 8 is implemented.
Citation Information
Cited By
Video understanding large model optimization and evaluation method, system and device and storage medium
CN119888581A
Emotion reason fragment identification method and device
CN122287649A
