Question generation method and device, electronic equipment and storage medium
By performing feature analysis on key nodes of samples and generating counterfactual nodes, combined with angle comparison and ternary comparison training models, the accuracy problem of multi-hop question generation is solved, and high-precision multi-hop question generation matching with text is achieved.
Patent Information
- Application Number
- CN202511196424.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-26
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2045-08-26
AI Technical Summary
Existing technologies have difficulty generating multi-hop questions that match text, have low accuracy, and traditional models are not sensitive to subtle differences.
By performing feature analysis on key nodes of samples, counterfactual nodes are generated, and the model is trained using angle comparison and ternary comparison to ensure the generation of logically consistent multi-hop questions.
Improves the accuracy and precision of multi-hop questions, ensures that the generated questions match the text, reduces noise interference, and enhances the model's dependency sensitivity.
Smart Images

Figure CN120706579A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of question generation, and in particular to a question generation method, device, electronic device and storage medium. Background Art
[0002] Question generation (QG) is the task of automatically generating questions based on a given context. It is crucial in applications such as question-answering systems, dialogue systems, education systems, and legal systems. Previous research has focused on generating shallow, factual questions (i.e., single-hop questions), which are typically generated from the sentence containing the answer or adjacent sentences within the same paragraph.
[0003] In recent years, research has shifted toward generating more complex multi-hop questions. These questions require synthesizing multiple pieces of scattered evidence from different paragraphs and generating coherent, factual questions related to the answer through reasoning. Compared to single-hop questions, multi-hop questions are more complex due to the complex entity connections within their reasoning chain. If the reasoning chain is too simple, the problem will degenerate into a single-hop form. Generating multi-hop questions also requires the model to understand the connections between non-sequential information distributed across multiple documents. Otherwise, the generated multi-hop questions will be difficult to match with the documents, resulting in low accuracy. Summary of the Invention
[0004] In view of this, the present application provides a question generation method, device, electronic device and storage medium, which can ensure the generation of multi-hop questions that match the text and can improve the accuracy of the generated multi-hop questions.
[0005] A first aspect of an embodiment of the present application provides a question generation method, comprising: performing feature analysis on a sample text to obtain sample key nodes of the sample text, wherein the sample key nodes are used to carry the context of the sample text; modifying at least one attribute value of the sample key nodes according to a preset modification strategy to obtain multiple counterfactual nodes, wherein the multiple counterfactual nodes have the same dependency type as the sample key nodes; performing model training based on angle comparison and ternary comparison on a first original model according to the sample key nodes and the multiple counterfactual nodes to obtain a first target model; inputting a target text into the first target model to obtain a target key node of the text; and obtaining a multi-hop question matching the target text according to the target key node.
[0006] Compared with the related art, the embodiment of the present application has at least the following advantages: First, since the sample key node is used to carry the context of the sample text, that is, the sample key node is the hub node with the greatest influence on the information flow of the sample text, therefore, by modifying at least one attribute value of the sample key node according to a preset modification strategy, multiple counterfactual nodes are obtained, and multiple counterfactual nodes have the same dependency type as the sample key node. On the one hand, by replacing the traditional global data adjustment of the entire sample key node with the local modification of the attribute value, noise interference is reduced, and the modification amplitude is minimized while maximizing the prediction difference; on the other hand, based on the prototype invariance, counterfactual nodes with bridging dependency invariance are generated, providing the first original model with diverse but logically consistent sample data for processing, thereby improving the accuracy of the trained first target model. Secondly, since the first target model is obtained by training the first original model based on angle comparison and ternary comparison, angle comparison can force the similarity between sample key nodes to be maximized and the similarity between counterfactual nodes to be minimized; ternary comparison solves the problem of traditional contrast learning being insensitive to subtle differences by constraining feature distribution by triples, thereby further improving the accuracy of the trained first target model. Finally, the target text is input into the first target model, which, through its high precision, can output accurate target key nodes, thereby improving the accuracy of multi-hop questions generated based on the target key nodes. Furthermore, because the first target model is trained based on sample key nodes that are designed to take on the context of the sample text, the target key nodes output by the first target model can also accurately take on the context of the target text, thus ensuring that the questions generated based on the target key nodes are multi-hop questions.
[0007] In one possible implementation, the counterfactual nodes include positive counterfactual nodes and negative counterfactual nodes; the model training based on angle comparison and ternary comparison of the first original model is performed based on the sample key nodes and multiple counterfactual nodes, including: constructing an angle comparison loss function based on the positive counterfactual nodes and the negative counterfactual nodes; constructing a ternary comparison loss function based on the original key nodes, the positive counterfactual nodes and the negative counterfactual nodes; model training of the first original model is performed based on the sample key nodes, the positive counterfactual nodes, the negative counterfactual nodes, the angle comparison loss function and the ternary comparison loss function.
[0008] In a possible implementation, constructing a ternary contrast loss function according to the original key node, the positive counterfactual node, and the negative counterfactual node includes: constructing the ternary contrast loss function according to the following formula: ;in, is the ternary contrast loss function, yes and The cosine similarity of For the sample text, yes Counterfactual sample text of are other sample texts, and τ is the temperature hyperparameter.
[0009] In one possible implementation, modifying at least one attribute value of the sample key node according to a preset modification strategy to obtain multiple counterfactual nodes includes: obtaining the multiple counterfactual nodes according to the following formula: ;in, represents an instance of a sample key node, represents an instance of a counterfactual node; Based on Output of multi-hop problem; Based on The multi-hop problem output is The weight used to balance the prediction difference and the instance difference; Measures the distance between the key node of the sample and the counterfactual node.
[0010] In one possible implementation, obtaining a multi-hop question that matches the target text based on the target key node includes: inputting the target key node into a second target model to obtain the multi-hop question; wherein, the second target model is obtained by training a second original model based on the sample key node and multiple counterfactual nodes.
[0011] In a possible implementation, before performing feature analysis on the sample text, the method further includes: extracting instances from the sample text; constructing a graph structure matching the sample text based on the instances; and performing feature analysis on the sample text to obtain sample key nodes of the sample text, including: performing feature analysis on the graph structure to obtain the sample key nodes.
[0012] In a possible implementation, performing feature analysis on the graph structure to obtain the sample key nodes includes: inputting the graph structure into the first original model to obtain the sample key nodes.
[0013] In the second aspect, an embodiment of the present application also provides a question generating device, comprising: an analysis module, a modification module, a training module, an input module and an acquisition module; the analysis module is used to perform feature analysis on a sample text to obtain sample key nodes of the sample text, wherein the sample key nodes are used to carry the context of the sample text; the modification module is used to modify at least one attribute value of the sample key nodes according to a preset modification strategy to obtain multiple counterfactual nodes, wherein the multiple counterfactual nodes have the same dependency type as the sample key nodes; the training module is used to perform model training based on angle comparison and ternary comparison on a first original model according to the sample key nodes and the multiple counterfactual nodes to obtain a first target model; the input module is used to input the target text into the first target model to obtain the target key nodes of the text; the acquisition module is used to obtain multi-hop questions matching the target text according to the target key nodes.
[0014] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a processor and a memory, wherein the memory is used to store instructions, and the processor is used to call the instructions in the memory so that the electronic device executes the question generation method described in the first aspect.
[0015] In a fourth aspect, an embodiment of the present application further provides a storage medium, wherein the computer-readable storage medium stores computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the question generating method as described in the first aspect.
[0016] The technical effects obtained in the above-mentioned second, third and fourth aspects are similar to the technical effects obtained by the corresponding technical means in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 A flowchart of the steps of a question generation method provided in one embodiment of the present application.
[0018] Figure 2 Another step flow chart of the question generation method provided in one embodiment of the present application.
[0019] Figure 3 This is a functional module diagram of a question generation device provided in one embodiment of the present application.
[0020] Figure 4 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0021] In order to more clearly understand the above-mentioned objectives, features and advantages of the present application, the present application is described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features therein can be combined with each other in the absence of conflict.
[0022] In the following description, many specific details are set forth to facilitate a full understanding of the present application. The described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.
[0023] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application pertains. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application.
[0024] It should be further noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0025] In this application, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A alone, A and B together, and B alone, where A and B can be singular or plural. The terms "first," "second," "third," "fourth," and so on (if any) in the specification, claims, and drawings of this application are used to distinguish similar objects, not to describe a specific order or precedence.
[0026] In the embodiments of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be interpreted as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0027] To facilitate understanding, some illustrations of concepts related to the embodiments of the present application are given as examples for reference.
[0028] Key Node Identification: A semantic dependency graph is constructed based on the Graph Attention Network (GAT), and high-impact nodes are screened through node centrality analysis. For example, in multi-document scenarios, entities shared across paragraphs are identified as the core hubs of information flow. GAT uses dynamic attention weight calculation to capture long-range dependencies between nodes and avoid redundant noise interference.
[0029] Counterfactual instance generation: We employ a generation strategy based on prototype invariance constraints, maintaining the node type unchanged and modifying only the attribute values. We optimize the generation process using a heuristic objective function to minimize the modification while maximizing the predicted difference, generating logically consistent counterfactual instances.
[0030] Angular-space contrastive learning: We design a dual-encoder architecture to model semantic relationships in angular space using cosine similarity. Angular contrast maximizes the similarity between the original support data and minimizes the similarity between the counterfactual data. Triplet contrast constrains the feature distribution by triplets, addressing the insensitivity of traditional contrastive learning to subtle differences.
[0031] Model-agnostic collaborative training: This method integrates cross-entropy loss and contrastive loss to adapt to various architectures such as Transformer and GNN. For example, in Transformer, the self-attention mechanism is used to strengthen the association between bridge nodes, and in GNN, graph propagation is used to optimize the inference path representation.
[0032] Zero-shot generalization verification: Combining the contextual learning capabilities of large language models, counterfactual data is encoded as prompts to guide the model to generate multi-hop questions, which has strong generalization properties for complex and dynamically dependent scenarios.
[0033] Multi-hop question generation: Multi-hop question generation is a natural language processing task that aims to generate complex questions that require multi-step reasoning to answer from a given context. It simulates the multi-step human thought process, integrating content scattered across different pieces of information to construct a clear reasoning path, thereby generating deep and logical questions. This process typically includes information retrieval, feature extraction, multi-hop reasoning path construction, and question generation. Multi-hop question generation can effectively improve the complex question handling capabilities of question-answering systems and enhance the depth and accuracy of dialogue systems and information retrieval. It has important research value and broad application prospects in the field of natural language processing.
[0034] Please refer to Figure 1 , Figure 1 This is a flowchart of the steps of one embodiment of the question generation method of the present application. Depending on different needs, the order of the steps in this flowchart can be changed, and some steps can be omitted. The question generation method of the present application can be applied to a question generation device, but is not limited thereto, and the embodiments of the present application are not limited thereto.
[0035] The specific process of this embodiment is as follows Figure 1 As shown, the following steps are included: Step 101: perform feature analysis on a sample text to obtain sample key nodes of the sample text.
[0036] Specifically, the sample key nodes are used to carry the context of the sample text.
[0037] How to perform feature analysis on sample text is described in detail in subsequent embodiments, and will not be described again here to avoid repetition.
[0038] Step 102: modify at least one attribute value of a sample key node according to a preset modification strategy to obtain a plurality of counterfactual nodes.
[0039] Specifically, multiple counterfactual nodes have the same dependency type as the sample key node.
[0040] In some embodiments, multiple counterfactual nodes can be generated by counterfactual instances. Specifically, multiple counterfactual nodes are obtained according to the following formula: ;in, represents an instance of a sample key node, represents an instance of a counterfactual node; Based on Output of multi-hop problem; Based on The multi-hop problem output is The weight used to balance the prediction difference and the instance difference; Measures the distance between the key node of the sample and the counterfactual node.
[0041] To facilitate understanding, the following example illustrates how to generate a counterfactual node in this embodiment: 1. By preserving the attribute set of key bridging nodes and generating different instances, we ensure the consistency of the underlying dependency types and only modify specific values to enhance data diversity: We identify a key bridging node (e.g., "Jeck") and generate a different instance (e.g., "Jock") that retains the same attribute set. Both nodes share exactly the same attributes, ensuring that the underlying dependency types remain unchanged. For example, "Jeck" and "Jock" represent different actor instances while preserving actor-related attributes.
[0042] 2. Fine-tune specific attribute values of the new instance based on the above formula, generating a logically consistent counterfactual node while maintaining the bridging dependency type unchanged: After generating the new instance "Jock," fine-tune its attributes. This involves modifying specific values (for example, adjusting the birth year from 1958 to 1968) while maintaining the bridging dependency type (e.g., "actor → role → position") unchanged.
[0043] Step 103 : Based on the sample key nodes and multiple counterfactual nodes, the first original model is trained based on angle comparison and ternary comparison to obtain a first target model.
[0044] In some embodiments, the first original model is a GAT model. It is understandable that this embodiment does not specifically limit the type of the first original model, and only needs to ensure that the first original model can output sample key nodes based on the sample text.
[0045] In some embodiments, the counterfactual nodes include positive counterfactual nodes and negative counterfactual nodes; the training method of the first original model includes: constructing an angle contrast loss function based on the positive counterfactual nodes and the negative counterfactual nodes; constructing a ternary contrast loss function based on the original key nodes, the positive counterfactual nodes and the negative counterfactual nodes; and performing model training on the first original model based on the sample key nodes, the positive counterfactual nodes, the negative counterfactual nodes, the angle contrast loss function and the ternary contrast loss function.
[0046] Specifically, a ternary contrast loss function is constructed based on the original key node, the positive counterfactual node, and the negative counterfactual node, including: constructing a ternary contrast loss function according to the following formula: ;in, is the ternary contrast loss function, yes and The cosine similarity of For the sample text, yes Counterfactual sample text of are other sample texts, and τ is the temperature hyperparameter.
[0047] Step 104: Input the target text into the first target model to obtain target key nodes of the text.
[0048] Step 105: Acquire multi-hop questions matching the target text according to the target key node.
[0049] In some embodiments, the target key node is input into the second target model to obtain a multi-hop problem.
[0050] Specifically, the second target model is obtained by training the second original model based on the sample key nodes and multiple counterfactual nodes.
[0051] In some embodiments, the second original model is trained by using a binary cross entropy loss function as the training objective function of the second original model. The binary cross entropy loss function is defined as: ; Where L is the binary cross entropy loss function, It is the accuracy of quantifying the counterfactual sample to predict the result of multi-hop problem, σ represents the Sigmoid activation function, is the soft target score of the true problem corresponding to the training sample.
[0052] It is worth noting that by generating counterfactual nodes based on sample key nodes and training the second original model using sample key nodes and counterfactual nodes, zero-shot generalization verification of the second original model is achieved, ensuring that the trained second target model can generate multi-hop questions, thereby improving the reliability of the question generation method. In addition, since the first target model for generating target key nodes is obtained by training the first original model based on angle comparison and ternary comparison, and the second target model is obtained by training the second original model based on the binary cross-entropy loss function, by combining cross-entropy loss with angle-space contrast loss for model-independent collaborative training, the difference between original data and counterfactual data is used to optimize the model's sensitivity to dependencies, further improving the accuracy of the multi-hop questions output by the second target model. Compared with the related art, the embodiment of the present application has at least the following advantages: First, since the sample key node is used to carry the context of the sample text, that is, the sample key node is the hub node with the greatest influence on the information flow of the sample text, therefore, by modifying at least one attribute value of the sample key node according to a preset modification strategy, multiple counterfactual nodes are obtained, and multiple counterfactual nodes have the same dependency type as the sample key node. On the one hand, by replacing the traditional global data adjustment of the entire sample key node with the local modification of the attribute value, noise interference is reduced, and the modification amplitude is minimized while maximizing the prediction difference; on the other hand, based on the prototype invariance, counterfactual nodes with bridging dependency invariance are generated, providing the first original model with diverse but logically consistent sample data for processing, thereby improving the accuracy of the trained first target model. Secondly, since the first target model is obtained by training the first original model based on angle comparison and ternary comparison, angle comparison can force the similarity between sample key nodes to be maximized and the similarity between counterfactual nodes to be minimized; ternary comparison solves the problem of traditional contrast learning being insensitive to subtle differences by constraining feature distribution by triples, thereby further improving the accuracy of the trained first target model. Finally, the target text is input into the first target model, which, through its high precision, can output accurate target key nodes, thereby improving the accuracy of multi-hop questions generated based on the target key nodes. Furthermore, because the first target model is trained based on sample key nodes that are designed to take on the context of the sample text, the target key nodes output by the first target model can also accurately take on the context of the target text, thus ensuring that the questions generated based on the target key nodes are multi-hop questions.
[0053] Please refer to Figure 2 , Figure 2 This is a flowchart of the steps of one embodiment of the question generation method of the present application. Depending on different needs, the order of the steps in this flowchart can be changed, and some steps can be omitted. This question generation method can be applied to the aforementioned question generation device, but is not limited thereto, and this embodiment of the present application is not limited thereto.
[0054] This embodiment is a specific explanation of the above embodiment, mainly explaining how to perform feature analysis on sample text. In this way, the accuracy of question generation can be further ensured.
[0055] The specific process of this embodiment is as follows Figure 2 As shown, the following steps are included: Step 201: extract instances from sample text.
[0056] Step 202: construct a graph structure that matches the sample text based on the instance.
[0057] This embodiment does not specifically limit the construction method of the graph structure, and can be set according to actual conditions. In the graph structure of this embodiment, instances of sample text constitute nodes of the graph structure, and a sentence of the sample text constitutes a link of the graph structure.
[0058] Step 203: Input the graph structure into the first original model to obtain sample key nodes.
[0059] Specifically, the GAT model is used to identify key nodes in the graph structure and screen the hub nodes that have the greatest impact on information flow.
[0060] Step 204 : Modify at least one attribute value of the sample key node according to a preset modification strategy to obtain a plurality of counterfactual nodes.
[0061] Step 205 : Based on the sample key nodes and multiple counterfactual nodes, the first original model is trained based on angle comparison and ternary comparison to obtain a first target model.
[0062] Step 206: Input the target text into the first target model to obtain target key nodes of the text.
[0063] Step 207: Acquire a multi-hop question matching the target text according to the target key node.
[0064] Steps 204 to 207 of this embodiment are similar to steps 102 to 105 of the aforementioned embodiment, and are not described again here to avoid repetition.
[0065] Compared with the related art, the embodiment of the present application has at least the following advantages: First, since the sample key node is used to carry the context of the sample text, that is, the sample key node is the hub node with the greatest influence on the information flow of the sample text, therefore, by modifying at least one attribute value of the sample key node according to a preset modification strategy, multiple counterfactual nodes are obtained, and multiple counterfactual nodes have the same dependency type as the sample key node. On the one hand, by replacing the traditional global data adjustment of the entire sample key node with the local modification of the attribute value, noise interference is reduced, and the modification amplitude is minimized while maximizing the prediction difference; on the other hand, based on the prototype invariance, counterfactual nodes with bridging dependency invariance are generated, providing the first original model with diverse but logically consistent sample data for processing, thereby improving the accuracy of the trained first target model. Secondly, since the first target model is obtained by training the first original model based on angle comparison and ternary comparison, angle comparison can force the similarity between sample key nodes to be maximized and the similarity between counterfactual nodes to be minimized; ternary comparison solves the problem of traditional contrast learning being insensitive to subtle differences by constraining feature distribution by triples, thereby further improving the accuracy of the trained first target model. Finally, the target text is input into the first target model, which, through its high precision, can output accurate target key nodes, thereby improving the accuracy of multi-hop questions generated based on the target key nodes. Furthermore, because the first target model is trained based on sample key nodes that are designed to take on the context of the sample text, the target key nodes output by the first target model can also accurately take on the context of the target text, thus ensuring that the questions generated based on the target key nodes are multi-hop questions.
[0066] Based on the same concept as the question generation method in the above embodiment, the present application also provides a question generation device that can be used to execute the above question generation method. For ease of explanation, the structural diagram of the question generation device embodiment only shows the parts relevant to the embodiment of the present application. Those skilled in the art will understand that the illustrated structure does not constitute a limitation of the device, and it may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0067] like Figure 3 As shown, the question generation device 30 includes an analysis module 301, a modification module 302, a training module 303, an input module 304, and an acquisition module 305. In some embodiments, these modules may be programmable software instructions stored in a memory and invoked and executed by a processor. It is understood that in other embodiments, these modules may also be program instructions or firmware embedded in the processor.
[0068] The analysis module 301 is used to perform feature analysis on the sample text to obtain sample key nodes of the sample text, wherein the sample key nodes are used to carry out the context of the sample text; A modification module 302 is configured to modify at least one attribute value of the sample key node according to a preset modification strategy to obtain a plurality of counterfactual nodes, wherein the plurality of counterfactual nodes have the same dependency type as the sample key node; A training module 303 is configured to perform model training based on angle comparison and ternary comparison on the first original model according to the sample key nodes and the plurality of counterfactual nodes to obtain a first target model; An input module 304 is configured to input a target text into the first target model to obtain target key nodes of the text; The acquisition module 305 is used to acquire a multi-hop question matching the target text according to the target key node. Please refer to Figure 4 , Figure 4 This is a schematic diagram of an embodiment of an electronic device of the present application.
[0069] The electronic device 100 includes a memory 20, a processor 30, and a computer program 40 stored in the memory 20 and executable on the processor 30. When the processor 30 executes the computer program 40, the steps in the above-mentioned question generation method embodiment are implemented, for example Figure 1 Steps 101 to 105 are shown.
[0070] Exemplarily, the computer program 40 can also be divided into one or more modules / units, one or more modules / units being stored in the memory 20 and executed by the processor 30. The one or more modules / units can be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of the computer program 40 in the electronic device 100. For example, it can be divided into the analysis module 301, modification module 302, training module 303, input module 304, and acquisition module 305 shown.
[0071] Those skilled in the art will understand that the schematic diagram is merely an example of the electronic device 100 and does not constitute a limitation on the electronic device 100. The electronic device 100 may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device 100 may also include input and output devices, network access devices, buses, etc.
[0072] The processor 30 may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor, a single-chip microcomputer, or the processor 30 may be any conventional processor, etc.
[0073] The memory 20 can be used to store computer programs 40 and / or modules / units. The processor 30 implements various functions of the electronic device 100 by running or executing the computer programs and / or modules / units stored in the memory 20 and accessing data stored in the memory 20. The memory 20 may primarily include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function (such as a sound playback function or an image playback function); the data storage area may store data generated during the use of the electronic device 100 (such as audio data). Furthermore, the memory 20 may include high-speed random access memory (RAM) and non-volatile memory, such as a hard disk, internal memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device.
[0074] If the modules / units integrated into the electronic device 100 are implemented as software functional units and sold or used as independent products, they can be stored in a storage medium. Based on this understanding, the present application can implement all or part of the process steps in the above-mentioned method embodiments by using a computer program to instruct the relevant hardware. The computer program can be stored in a storage medium, and when executed by a processor, the computer program can implement the steps of each of the above-mentioned method embodiments. The computer program includes computer program code, which can be in source code form, object code form, executable file, or some intermediate form. The storage medium can include: any entity or device capable of carrying computer program code, recording medium, USB flash drive, mobile hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal, and software distribution medium. It should be noted that the content contained in the storage medium can be appropriately increased or decreased according to the requirements of patent practice. For example, according to patent practice, the storage medium does not include electric carrier signal and telecommunication signal.
[0075] The above is a detailed introduction to the question generation method, device, electronic device and storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, based on the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A question generation method, characterized in that: include: Performing feature analysis on the sample text to obtain sample key nodes of the sample text, wherein the sample key nodes are used to carry the context of the sample text; Modifying at least one attribute value of the sample key node according to a preset modification strategy to obtain a plurality of counterfactual nodes, wherein the plurality of counterfactual nodes have the same dependency type as the sample key node; According to the sample key nodes and the plurality of counterfactual nodes, model training based on angle comparison and ternary comparison is performed on the first original model to obtain a first target model; Inputting a target text into the first target model to obtain target key nodes of the text; A multi-hop question matching the target text is obtained according to the target key node.
2. The question generation method according to claim 1, characterized in that: The counterfactual nodes include positive counterfactual nodes and negative counterfactual nodes; The step of performing model training based on angle comparison and ternary comparison on the first original model according to the sample key node and the plurality of counterfactual nodes includes: Constructing an angle comparison loss function based on the positive counterfactual node and the negative counterfactual node; Constructing a ternary contrast loss function based on the original key node, the positive counterfactual node, and the negative counterfactual node; Model training is performed on the first original model according to the sample key nodes, the positive and counterfactual nodes, the negative counterfactual nodes, the angle contrast loss function, and the ternary contrast loss function.
3. The question generation method according to claim 2, characterized in that: The constructing of a ternary contrast loss function according to the original key node, the positive counterfactual node, and the negative counterfactual node includes: The ternary contrast loss function is constructed according to the following formula: ;in, is the ternary contrast loss function, yes and The cosine similarity of For the sample text, yes Counterfactual sample text of are other sample texts, and τ is the temperature hyperparameter.
4. The question generation method according to claim 1, characterized in that: The step of modifying at least one attribute value of the sample key node according to a preset modification strategy to obtain multiple counterfactual nodes includes: The multiple counterfactual nodes are obtained according to the following formula: ;in, represents an instance of a sample key node, represents an instance of a counterfactual node; Based on Output of multi-hop problem; Based on The multi-hop problem output is The weight used to balance the prediction difference and the instance difference; Measures the distance between the key node of the sample and the counterfactual node.
5. The question generation method according to claim 1, characterized in that: The step of obtaining a multi-hop problem matching the target text according to the target key node includes: Inputting the target key node into a second target model to obtain the multi-hop problem; The second target model is obtained by training the second original model according to the sample key nodes and multiple counterfactual nodes.
6. The question generation method according to any one of claims 1 to 5, characterized in that: Before performing feature analysis on the sample text, the method further includes: extracting instances from the sample text; Constructing a graph structure matching the sample text according to the instance; The performing feature analysis on the sample text to obtain the sample key nodes of the sample text includes: performing feature analysis on the graph structure to obtain the sample key nodes.
7. The question generation method according to claim 6, characterized in that: The performing feature analysis on the graph structure to obtain the sample key nodes includes: The graph structure is input into the first original model to obtain the sample key nodes.
8. A question generating device, characterized in that: include: Analysis module, modification module, training module, input module and acquisition module; The analysis module is used to perform feature analysis on the sample text to obtain sample key nodes of the sample text, wherein the sample key nodes are used to carry out the context of the sample text; The modification module is used to modify at least one attribute value of the sample key node according to a preset modification strategy to obtain a plurality of counterfactual nodes, wherein the plurality of counterfactual nodes have the same dependency type as the sample key node; The training module is used to perform model training based on angle comparison and ternary comparison on the first original model according to the sample key node and the plurality of counterfactual nodes to obtain a first target model; The input module is used to input the target text into the first target model to obtain the target key nodes of the text; The acquisition module is used to acquire a multi-hop question matching the target text according to the target key node.
9. An electronic device comprising a processor and a memory, characterized in that: The memory is used to store instructions, and the processor is used to call the instructions in the memory, so that the electronic device executes the question generating method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium stores computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the question generating method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Candidate paragraph generation and multi-hop question answering method based on text classification
CN115878794A
Apparatus and method for predictive computer modeling
CN116685963A
Multi-hop inference knowledge editing method based on model cognitive verification
CN118364912A
Controllable multi-hop problem generation method, system and equipment based on large language model
CN119739823A
Automatic construction method of end-to-end agent based on graph structure semantic fusion
CN120235181A