A template-based contrastive explanation generation method for common sense question answering

By using a template-based comparative explanation generation method, combined with common sense knowledge graphs and dictionaries, we generate comparative explanation knowledge related to the question, solving the problem of low knowledge discriminability of pre-trained models in common sense question answering, and improving question answering performance and explainability.

CN115687595BActive Publication Date: 2025-09-12ZHEJIANG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211430964.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-15
Publication Date
2025-09-12
Estimated Expiration
2042-11-15

AI Technical Summary

Technical Problem

Existing pre-trained language models have problems with outdated implicit knowledge and low knowledge discriminability in commonsense question-answering tasks, resulting in unfriendly answers. In addition, external knowledge extracted from the knowledge base easily introduces irrelevant or noisy information, which damages model performance.

Method used

A template-based contrastive explanation generation method is adopted. The key concepts in the question-candidate text are extracted through the concept identifier. The common sense knowledge graph and dictionary are combined to retrieve external symbolic knowledge, and contrastive explanation knowledge related to the question and candidate answers is generated. The knowledge is then encoded and reasoned through the explanation-enhanced reasoning module.

Benefits of technology

It improves the knowledge relevance and diversity of the pre-trained model in common sense question answering tasks, enhances the model's discriminability and interpretability, and improves question answering performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115687595B_ABST
    Figure CN115687595B_ABST
Patent Text Reader

Abstract

The present invention discloses a comparative explanation generation method based on template prompts for common sense question and answer. The steps of the present invention are as follows: 1) Symbolic knowledge acquisition: identifying key concepts based on original input, and acquiring relevant external knowledge through multi-knowledge source retrieval, 2) Comparative explanation generation: inputting the retrieved symbolic knowledge and the constructed prompt template into a generative pre-training model to generate corresponding comparative explanation text; 3) Explanation enhancement reasoning: using the obtained comparative explanation text as the context of the original question to enhance the common sense question and answer reasoning. For the knowledge-enhanced common sense question and answer problem, the present invention proposes for the first time a comparative explanation generation method based on template prompts, combining the advantages of the concept-centered external symbolic knowledge and the generative pre-training model, and using comparative explanation text as a new type of knowledge, which can greatly alleviate the problems of low knowledge discrimination and small improvement of downstream tasks in knowledge-enhanced common sense question and answer problems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of natural language processing, and specifically relates to the application of external knowledge retrieval and a comparative explanation generator based on a generative pre-trained model in knowledge-driven common sense question answering. Background Art

[0002] In recent years, a large number of knowledge-enhanced pre-trained language models have been proposed to improve the performance of various NLP tasks. These methods aim to inject knowledge into pre-trained language models (PLMs) and then fine-tune them for downstream tasks. Commonsense question answering is a typical application scenario of pre-trained language models.

[0003] However, the implicit knowledge learned in the pre-trained model has the problem of being outdated, which is not friendly to question answering. To overcome this problem, another research direction is to explicitly retrieve knowledge from different knowledge sources and integrate them into downstream models in the question answering field. However, extracting external knowledge from the knowledge base will inevitably introduce irrelevant or even noisy knowledge, which will damage the performance of the model. By treating the pre-trained model as a knowledge base, relevant implicit knowledge can be obtained from it, but this knowledge is generally general and lacks specific and distinguishing information. Based on previous research, we have concluded that high-quality included knowledge needs to have the following characteristics: 1) diversity, providing different types of knowledge 2) relevance, factual knowledge content should be relevant to the question, 3) discriminability, knowledge can provide additional distinguishing information, which is conducive to establishing the connection between the question and the candidate answer. However, the knowledge obtained by the above methods is difficult to make good progress in the discriminability of knowledge.

[0004] Therefore, in the field of common sense question answering, how to obtain highly discriminative external knowledge and improve the reasoning ability of pre-trained models in common sense question answering tasks is a technical problem that needs to be solved urgently. Summary of the Invention

[0005] The purpose of the present invention is to solve the problems existing in the prior art and provide a comparative explanation generation method based on template prompts for common sense question answering.

[0006] Inspired by the fact that contrastive explanations offer greater discriminability than other symbolic knowledge and knowledge obtained from pre-trained models, this paper aims to propose a contrastive explanation generation method to improve the performance of existing pre-trained models in commonsense question answering. Based on relevant experience, the advantages of this approach are as follows: First, the contrastive explanation generation process combines the original question-candidate text with relevant external symbolic knowledge, making the knowledge more relevant and diverse. Second, contrastive explanations primarily focus on the differences between candidate concepts in the input text, demonstrating excellent discriminability. Furthermore, as the final form of incorporated knowledge, contrastive explanations not only meet the three characteristics of high-quality knowledge but also make it easier for humans to understand and exhibit better interpretability.

[0007] The technical solutions specifically adopted in the present invention are as follows:

[0008] A template-based comparative explanation generation method for common sense question answering, the steps are as follows:

[0009] S1: For the question-candidate text consisting of a question and candidate answers, a trained concept recognizer is used to identify key concepts. The concept recognizer performs token-level sequence annotation on the question-candidate text and outputs a sequence of tags indicating whether each token in the question-candidate text belongs to a concept or background, thereby extracting all concepts in the question-candidate text. The concept recognizer consists of an encoder and a CRF layer, where the encoder uses the RoBERTa-large model. After the encoder encodes the question-candidate text, the CRF layer outputs a tag sequence.

[0010] S2: Using all the concepts extracted from the question-candidate text in S1 as anchors, more external symbolic knowledge is retrieved from different knowledge bases including common sense knowledge graphs and dictionaries, and the retrieved external symbolic knowledge is spliced ​​into concept-centric knowledge;

[0011] S3: Taking the question-candidate text, all concepts extracted from the question-candidate text in S1, and the concept core knowledge obtained in S2 as input, a pre-trained model generator is used to generate comparative explanation knowledge related to the question and candidate answers; the pre-trained model generator is a template-based comparative explanation generator obtained by fine-tuning the pre-trained generative language model BART-base;

[0012] S4: The contrastive explanation knowledge generated by the contrastive explanation generator in S3 and the question-candidate text are used as the input of the trained explanation enhancement reasoning module. The input is first encoded by the pre-trained model encoder, and the pre-trained model encoder adopts the pre-trained model DeBERTaV3; the encoding result of the pre-trained model encoder is then passed into the pooling layer and the multi-layer perceptron to output the answer to the question, realizing common sense question answering reasoning.

[0013] As a preference, in said S1, the concept recognition task is regarded as a token-level sequence labeling task, the input of the concept recognizer is a sentence S = [CLS] Q [SEP] A [SEP], where [SEP] is a tag used to separate the question Q and the candidate answer A. For the input sentence S, the sequence labeling task needs to find a set of concepts C = {c1, c2, ..., c n}And mark it to form a token sequence, and the final token sequence is marked with 1 and 0 to mark the question - whether each token in the candidate text belongs to the concept or the background, where 1 represents a concept tag and 0 represents a background tag.

[0014] Preferably, the training data sets of the concept identifier include CommonGen, e-SNLI, and CSQA; each training data set contains concepts or tags annotated in instances, and if there are more than 3 recognized concepts in an instance, the top 3 concepts will be selected for subsequent use based on a score ranking mechanism, otherwise all recognized concepts will be selected.

[0015] Preferably, the specific implementation steps of S2 are as follows:

[0016] S21: First, find the path from the problem concept to the candidate concept in the common sense knowledge graph. If there is only one path, directly select this path and extract all triples in the path as relevant knowledge in the common sense knowledge graph; if there is more than one path, compare the lengths of each path and select the shortest path, and extract all triples in the shortest path as relevant knowledge in the common sense knowledge graph; if there is no direct path between the problem concept and the candidate concept in the common sense knowledge graph, but there are triples related to the candidate concept in the common sense knowledge graph, then calculate the score of each triple through the predefined score function, and select the triple with the highest score as the relevant knowledge in the common sense knowledge graph; for any triple j, the score score calculated by the score function j for:

[0017]

[0018] Where: w jis the weight of triple j in the common sense knowledge graph, N is the total number of triples related to the candidate concept in the common sense knowledge graph, and all N triples related to the candidate concept in the common sense knowledge graph are divided into multiple relationship categories through clustering, N k is the number of triples contained in the relation category k where triple j is located;

[0019] S22: For each concept extracted from the question-candidate text in S1, the closest matching definition entry is selected from the dictionary as the concept description;

[0020] S23: For each concept extracted from the question-candidate text, its triples obtained in S21 and the concept description obtained in S22 are concatenated and spliced ​​together as the concept core knowledge corresponding to each concept from the external knowledge source.

[0021] Preferably, in said S22, when selecting the closest matching definition entry in the dictionary as the concept description, if there are multiple forms of definition entries, the priority order of being selected as the concept description is: the original form of the concept itself > Spacy's lemma form > basic word.

[0022] Preferably, in S3, the template-based contrastive explanation generator uses the pre-trained generative language model BART-base, which is fine-tuned using the ECQA, eQASC, and e-SNLI datasets. During the fine-tuning phase, the contrastive explanation generator model only considers the original question and candidate options as input, but during the reasoning phase, it uses concepts and external symbolic knowledge to enhance the model input. The model input during the reasoning phase consists of the task premise prompt, the question in the question-candidate text, the candidate answers in the question-candidate text, all concepts extracted from the question-candidate text, the concept-centric knowledge obtained based on the concepts in the question-candidate text, and a pre-constructed discrete prompt template.

[0023] Preferably, in S4, in the explanation enhanced reasoning module, the pre-trained model DeBERTaV3 first encodes the input comparative explanation knowledge and the question-candidate text, and finally outputs the hidden state of the [CLS] tag as a representation, which is then sequentially outputted through the pooling layer and the multi-layer perceptron to output the answer to the question.

[0024] Preferably, the objective function used in the training of the explanation enhancement reasoning module is defined as follows:

[0025]

[0026] Where: i represents the i-th sample in the training data set, h i Represents the hidden state of the multilayer perceptron output, y irepresents the answer label of the i-th example, and n represents the total number of examples.

[0027] Preferably, the common sense knowledge graph adopts ConceptNet.

[0028] Preferably, the dictionary is the Cambridge Dictionary.

[0029] Compared to existing technologies, this paper proposes a novel template-based method for generating comparative explanations for knowledge-enhanced general knowledge question answering. By combining the advantages of concept-centric external symbolic knowledge with generative pre-trained models, this paper utilizes comparative explanation text as a new type of knowledge. This approach can significantly alleviate the issues of low knowledge discernibility and limited improvement in downstream tasks in general knowledge question answering. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 A schematic diagram of the steps of a template-based comparative explanation generation method for common sense question answering;

[0031] Figure 2 A framework diagram of the method of the present invention; DETAILED DESCRIPTION

[0032] The present invention will be further described and illustrated below with reference to the accompanying drawings and specific embodiments.

[0033] like Figure 1 As shown, in a preferred embodiment of the present invention, a comparative interpretation generation method based on template prompts is provided, and its steps are shown as S1-S4:

[0034] S1: For the question-candidate text consisting of a question and candidate answers, a trained concept recognizer is used to recognize key concepts. In the concept recognizer, the question-candidate text is sequence-labeled at the token level, and a tag sequence is output to indicate whether each token in the question-candidate text belongs to a concept or background, thereby extracting all concepts in the question-candidate text. The concept recognizer is composed of an encoder and a CRF layer, wherein the encoder adopts the RoBERTa-large model. After the question-candidate text is encoded by the encoder, the CRF layer outputs a tag sequence.

[0035] In the embodiment of the present invention, the concept recognition task in the above step S1 is regarded as a token-level sequence labeling task. The question-candidate text is composed of a question Q and a candidate answer A. The input of the concept recognizer is a sentence S = [CLS]Q[SEP]A[SEP], where [SEP] is a tag used to separate the question Q and the candidate answer A. For the input sentence S, the sequence labeling task needs to find a set of concepts C = {c1, c2, ..., c n}And mark it to form a token sequence, and the final token sequence is marked with 1 and 0 to mark the question - whether each token in the candidate text belongs to the concept or the background, where 1 represents a concept tag and 0 represents a background tag.

[0036] In addition, due to the limited size of the training corpus, several similar datasets were collected for concept recognition training in this embodiment. Specific training datasets for concept recognition include CommonGen, e-SNLI, and CSQA. Each training dataset contains the concepts or tags annotated in the instances. If an instance has more than three recognized concepts, the top three are selected for subsequent use based on a score ranking mechanism. Otherwise, all recognized concepts are selected.

[0037] S2: Using all concepts extracted from the question-candidate text in S1 as anchors, more external symbolic knowledge is retrieved from different knowledge bases including common sense knowledge graphs and dictionaries, and the retrieved external symbolic knowledge is spliced ​​into concept-centric knowledge.

[0038] In an embodiment of the present invention, the specific implementation steps of the above step S2 are as follows:

[0039] S21: First, find the path from the problem concept to the candidate concept in the common sense knowledge graph. If there is only one path, directly select this path and extract all triples in the path as relevant knowledge in the common sense knowledge graph; if there is more than one path, compare the lengths of each path and select the shortest path, and extract all triples in the shortest path as relevant knowledge in the common sense knowledge graph; if there is no direct path between the problem concept and the candidate concept in the common sense knowledge graph, but there are triples related to the candidate concept in the common sense knowledge graph, then calculate the score of each triple by a predefined score function, and select the triple with the highest score as the relevant knowledge in the common sense knowledge graph; for any triple j, the score scorr calculated by the score function j for:

[0040]

[0041] Where: w j is the weight of triple j in the common sense knowledge graph, N is the total number of triples related to the candidate concept in the common sense knowledge graph, and all N triples related to the candidate concept in the common sense knowledge graph are divided into multiple relationship categories through relationship clustering. k is the number of triples contained in the relation category k where triple j belongs.

[0042] It should be noted that the triples related to the candidate concept in the common sense knowledge graph here refer to the triples in the common sense knowledge graph with the candidate concept as one of the nodes.

[0043] S22: For each concept extracted from the question-candidate text in S1, the closest matching definition entry is selected from the dictionary as the concept description.

[0044] In an embodiment of the present invention, when the most closely matching definition entry is selected in the dictionary as the concept description, if there are multiple forms of definition entries, the priority order of the definition selected as the concept description needs to be defined as follows: the original form of the concept itself > Spacy's lemma form > basic word, that is, if the original form of the concept itself exists, the definition entry of its original form is adopted; if the original form of the concept itself does not exist but Spacy's lemma form exists, the definition entry corresponding to Spacy's lemma form is selected; if neither of them exists, the definition entry corresponding to the basic word (the last word) is selected.

[0045] S23: For each concept extracted from the question-candidate text, the triples obtained in S21 and the concept descriptions obtained in S22 are concatenated and spliced ​​together to form the concept core knowledge from the external knowledge source corresponding to each concept. Specifically, the present invention combines the triples Triples and the concept description Definition to form the concept core knowledge in the form of Triples[SEP]Definition[SEP]} for interpretation generation and downstream reasoning.

[0046] It should be noted that the common sense knowledge graph and dictionary can be in different forms. In this embodiment, the common sense knowledge graph can adopt ConceptNet, and the dictionary can adopt the Cambridge Dictionary.

[0047] S3: Taking the question-candidate text, all concepts extracted from the question-candidate text in S1, and the concept-centric knowledge obtained in S2 as input, a pre-trained model generator is used to generate comparative explanation knowledge related to the question and candidate answers; the pre-trained model generator is a template-prompt-based comparative explanation generator, which is obtained by fine-tuning the pre-trained generative language model BART-base.

[0048] In step S3 of the present invention, the training of the template-based contrastive explanation generator requires first collecting some explanation-related datasets. The principles are as follows: 1) Does the dataset directly contain contrastive explanations? 2) If not, can the dataset provide explanations for different candidate answers, i.e., positive and negative explanations? 3) If not, does the dataset's explanations contain factual knowledge that distinguishes different candidate answers or labels? After careful selection, in an embodiment of the present invention, the contrastive explanation generator uses BART-base, a pre-trained generative language model fine-tuned on the ECQA, eQASC, and e-SNLI datasets. Unlike the contrastive explanation generator, which only considers the original question and candidates as input during the fine-tuning phase, the contrastive explanation generation model uses concepts and external symbolic knowledge to enhance the model input during the reasoning phase. The model input content in the reasoning phase consists of the task premise prompt, the question in the question-candidate text, the candidate answers in the question-candidate text, all concepts extracted from the question-candidate text, the concept-centric knowledge obtained based on the concepts in the question-candidate text, and a pre-constructed discrete prompt template. Specifically, the input content is organized as follows: [Prefix]Task prefix[SEP]Question[SEP]Candidates[SEP]Concept[SEP]Concept-centric knowledge[SEP]Explanation Prompt[SEP], where Task prefix is ​​the task premise prompt, which is set to the fixed text "Generate comparative explanations of this question" in this embodiment, Concept-centric knowledge represents the extracted concept-centric knowledge (including triples and concept descriptions), and Explanation Prompt is a discrete prompt template constructed by humans. Question, Candidates, and Concept are the question, candidate answer, and concept in the question-candidate text, respectively.

[0049] S4: The contrastive explanation knowledge generated by the contrastive explanation generator in S3 and the question-candidate text are used as the input of the trained explanation enhancement reasoning module. The input is first encoded by the pre-trained model encoder, and the pre-trained model encoder adopts the pre-trained model DeBERTaV3; the encoding result of the pre-trained model encoder is then passed into the pooling layer and the multi-layer perceptron to output the answer to the question, realizing common sense question answering reasoning.

[0050] In an embodiment of the present invention, in the above step S4, in the explanation enhancement reasoning module, the pre-trained model DeBERTaV3 first encodes the input comparative explanation knowledge and the question-candidate text, and finally outputs the hidden state of the [CLS] tag as a representation, which is then sequentially outputted through the pooling layer and the multi-layer perceptron to output the answer to the question.

[0051] The objective function used in the training of the explanation-enhanced reasoning module is defined as follows:

[0052]

[0053] Where: i represents the i-th sample in the training data set, h i Represents the hidden state of the multilayer perceptron output, y i represents the answer label of the i-th example, and n represents the total number of examples.

[0054] It should be noted that during the training of the explanation-enhanced reasoning module, the concept identifier and contrastive explanation generator are fixed and no parameter update is required.

[0055] The above method is applied to a specific embodiment below. The specific implementation steps are as described above, and the embodiment mainly demonstrates its effect.

[0056] Example

[0057] As shown in Table 1, in this embodiment, the existing CSQA method is divided into four parts, Pre-trained LanguageModel Only, PLM+Symbolic Knowledge Retrieval, PLM+Generated Knowledge and HumanParties. The experimental results show the effectiveness of the comparative explanation generation method for common sense question answering (denoted as CPACE) of the present invention. Specifically, the CPACE model of the present invention achieved 87.4% in a single model setting by generating comparative explanations. In addition, although KEAR uses external knowledge and retrieved training sets to enhance knowledge, the CPACE model of the present invention outperforms KEAR and achieved a new SOTA on the CSQA ranking. This shows that, unlike retrieving triples, definitions, and training instances, generated comparative explanations can be another effective way to enhance knowledge.

[0058] Table 1. Experimental results on the common sense question answering test set

[0059]

[0060] To further measure the versatility of the method of the present invention, this embodiment evaluates the performance of the model using comparative explanations generated by the CPACE generator on the QASC and OBQA datasets. As shown in Table 2, this embodiment selects some representative baselines for comparison, including UnifiedQA, RoBERTa+AIR, and GenMC. Although ALBERT only achieved 71.8% and 72.5% on QASC and OBQA, ALBERT+KB achieved 80.3% and 83.2% respectively, which only retrieves symbolic knowledge from KB. Using the CPACE model of the present invention, we can further improve by 3.4% and 2.9% respectively. Experimental results show that the CPACE model of the present invention can be used not only for answering common sense questions, but also for QA in other open domains.

[0061] Table 2. Generalization test results of the model on the QASC and OBQA datasets

[0062] Model QASC OBQA BERT 68.4 64.1 UnifiedQA 66.6 70.5 GenMC 67.6 71.6 ALBERT 71.8 72.5 ALBERT+KB 80.3 83.2 ROBERTa+AIR 81.4 81.7 CPACE 83.7 86.1

[0063] As shown in Table 3, this example uses BART-base as a pre-trained model to evaluate the effectiveness of the generator's concepts, prefix hints, and retrieved concept-centric knowledge (concept triples and definitions). Only by using the fine-tuned BART-base as the generator can the resulting explanation-enhanced reasoning model achieve 78.3% on the CSQA development set.

[0064] Since concepts represent the key information of a given sentence, the generator can benefit greatly from having certain concepts. When concepts are used as enhanced input, this embodiment can achieve a 0.8% improvement. This embodiment uses prefix hints as formal constraints and achieves a 4.1% improvement, which fully demonstrates the necessity of contrastive interpretation hints as constraints. At the same time, using external concept-centric knowledge for enhancement, this embodiment can achieve a 5.2% improvement, which shows that concept-centric knowledge is equally important in contrastive interpretation generation. Finally, combining the above three types of knowledge, the reasoning model can achieve a 6.9% improvement.

[0065] Table 3. Ablation experiment results comparing the explanation generator module

[0066] Model Validation set accuracy BART 78.3 BART+Concept 79.1 BART+Prefix Prompt 82.4 BART+Concept-centric Knowledge 83.5 BART+All 85.2

[0067] As shown in Table 4, ALBERT achieved a score of 73.8% and DeBERTa achieved a score of 84.6% in the CSQA question answering task, which shows that a better pre-trained model encoder is of great significance in downstream tasks. Then, this embodiment uses concepts, retrieved concept-centric knowledge, and generated contrastive explanations as different types of additional knowledge to enhance the reasoning model. Although concepts can only bring 1.5% and 0.2% improvements to ALBERT and DeBERTa, improvements of 10.4% and 0.5% can be obtained through triples and concept definitions, respectively. In addition, by using the generated contrastive explanations, significant improvements of 11.4% and 3.3% can be obtained, respectively. This shows that the contrastive explanations generated by the present invention are more effective than the retrieved symbolic knowledge.

[0068] Table 4. Ablation experiment results of model inference module

[0069] Model Validation set accuracy ALBERT 73.8 ALBERT+Concept 75.3 ALBERT+Concept-centric Knowledge 84.2 ALBERT+Contrastive Explanation 85.2 ALBERT+All 88.4 DeBERTaV3 84.6 DeBERTaV3+Concept 84.8 DeBERTaV3+Concept-centric Knowledge 85.1 DeBERTaV3+Contrastive Explanation 87.9 DeBERTaV3+All 91.7 ALBERT+Ground-truth Explanation 96.9 DeBERTaV3+Ground-truth Explanation 97.1

[0070] The embodiment described above is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Persons skilled in the art may make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, any technical solution obtained by equivalent substitution or equivalent transformation falls within the scope of protection of the present invention.

Claims

1. A comparative explanation generation method based on template prompts for common sense question answering, characterized by: Here are the steps: S1: For the question-candidate text consisting of a question and candidate answers, a trained concept recognizer is used to identify key concepts. The concept recognizer performs token-level sequence annotation on the question-candidate text and outputs a sequence of tags indicating whether each token in the question-candidate text belongs to a concept or background, thereby extracting all concepts in the question-candidate text. The concept recognizer consists of an encoder and a CRF layer, where the encoder uses the RoBERTa-large model. After the encoder encodes the question-candidate text, the CRF layer outputs a tag sequence. S2: Using all the concepts extracted from the question-candidate text in S1 as anchors, more external symbolic knowledge is retrieved from different knowledge bases including common sense knowledge graphs and dictionaries, and the retrieved external symbolic knowledge is spliced ​​into concept-centric knowledge; S3: Taking the question-candidate text, all concepts extracted from the question-candidate text in S1, and the concept core knowledge obtained in S2 as input, a pre-trained model generator is used to generate comparative explanation knowledge related to the question and candidate answers; the pre-trained model generator is a template-based comparative explanation generator obtained by fine-tuning the pre-trained generative language model BART-base; S4: The contrastive explanation knowledge generated by the contrastive explanation generator in S3 and the question-candidate text are used as inputs to the trained explanation-enhanced reasoning module. The inputs are first encoded by a pre-trained model encoder, which uses the pre-trained model DeBERTaV3. The encoding result of the pre-trained model encoder is then passed to the pooling layer and the multi-layer perceptron to output the answer to the question, thus realizing common sense question answering reasoning. The specific implementation steps of S2 are as follows: S21: First, find the path from the problem concept to the candidate concept in the common sense knowledge graph. If there is only one path, directly select this path and extract all triples in the path as relevant knowledge in the common sense knowledge graph; if there is more than one path, compare the lengths of each path and select the shortest path, and extract all triples in the shortest path as relevant knowledge in the common sense knowledge graph; if there is no direct path between the problem concept and the candidate concept in the common sense knowledge graph, but there are triples related to the candidate concept in the common sense knowledge graph, then calculate the score of each triple through the predefined score function, and select the triple with the highest score as the relevant knowledge in the common sense knowledge graph; for any triple j, the score score calculated by the score function j for: Where: w j is the weight of triple j in the common sense knowledge graph, N is the total number of triples related to the candidate concept in the common sense knowledge graph, and all N triples related to the candidate concept in the common sense knowledge graph are divided into multiple relationship categories through clustering, N k is the number of triples contained in the relation category k where triple j is located; S22: For each concept extracted from the question-candidate text in S1, the closest matching definition entry is selected from the dictionary as the concept description; S23: For each concept extracted from the question-candidate text, its triples obtained in S21 and the concept description obtained in S22 are concatenated and spliced ​​together as the concept core knowledge corresponding to each concept from the external knowledge source.

2. The method for generating comparative explanations based on template prompts for common sense question answering according to claim 1, characterized in that: In S1, the concept recognition task is regarded as a token-level sequence labeling task. The input of the concept recognizer is a sentence S = [CLS]Q[SEP]A[SEP], where [SEP] is a tag used to separate the question Q and the candidate answer A. For the input sentence S, the sequence labeling task needs to find a set of concepts C = {c1, c2, ..., c n }And mark it to form a token sequence, and the final token sequence is marked with 1 and 0 to mark the question - whether each token in the candidate text belongs to the concept or the background, where 1 represents a concept tag and 0 represents a background tag.

3. The method for generating comparative explanations based on template prompts for common sense question answering according to claim 1, characterized in that: The training datasets for the concept recognizer include CommonGen, e-SNLI, and CSQA; each training dataset contains concepts or tags annotated in instances, and if there are more than three recognized concepts in an instance, the top three concepts will be selected for subsequent use based on a score ranking mechanism; otherwise, all recognized concepts will be selected.

4. The method for generating comparative explanations based on template prompts for common sense question answering according to claim 1, characterized in that: In said S22, when selecting the closest matching definition entry in the dictionary as the concept description, if there are multiple forms of definition entries, the priority order of being selected as the concept description is: the original form of the concept itself > Spacy's lemma form > basic word.

5. The method for generating comparative explanations based on template prompts for common sense question answering according to claim 1, characterized in that: In S3, the template-prompt-based contrastive explanation generator is obtained by fine-tuning the pre-trained generative language model BART-base with the ECQA, eQASC and e-SNLI datasets. The BART-base model uses concepts and external symbolic knowledge to enhance the model input. The model input content consists of task premise prompts, questions in question-candidate texts, candidate answers in question-candidate texts, all concepts extracted from question-candidate texts, the concept-centric knowledge obtained based on the concepts in the question-candidate texts, and a pre-constructed discrete prompt template.

6. The method for generating comparative explanations based on template prompts for common sense question answering according to claim 1, characterized in that: In S4, in the explanation-enhanced reasoning module, the pre-trained model DeBERTaV3 first encodes the input comparative explanation knowledge and the question-candidate text, and finally outputs the hidden state of the [CLS] tag as a representation, which is then sequentially output through the pooling layer and the multi-layer perceptron to output the answer to the question.

7. The method for generating comparative explanations based on template prompts for common sense question answering according to claim 1, characterized in that: The objective function used in the training of the explanation-enhanced reasoning module is defined as follows: Where: i represents the i-th sample in the training data set, h i Represents the hidden state of the multilayer perceptron output, y i represents the answer label of the i-th example, and n represents the total number of examples.

8. The method for generating comparative explanations based on template prompts for common sense question answering according to claim 1, characterized in that: The common sense knowledge graph adopts ConceptNet.

9. The method for generating comparative explanations based on template prompts for common sense question answering according to claim 1, characterized in that: The dictionary used is the Cambridge Dictionary.