Question generation method and device, electronic equipment and storage medium

By performing feature analysis and model training on key nodes of the samples, a multi-hop problem matching the text is generated, which solves the problem of low accuracy of multi-hop problems in the existing technology and achieves higher accuracy in generating multi-hop problems.

CN120706579BActive Publication Date: 2025-11-25WUHAN UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511196424.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-26
Publication Date
2025-11-25
Estimated Expiration
2045-08-26

AI Technical Summary

Technical Problem

Existing technologies struggle to generate multi-hop problems that match text, resulting in low accuracy.

Method used

By performing feature analysis on key nodes of the samples, counterfactual nodes are generated, and the model is trained using angle comparison and ternary comparison to improve the generation accuracy of multi-hop problems.

Benefits of technology

This ensures that the generated multi-hop questions match the text, improving the accuracy and logical consistency of the generated multi-hop questions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120706579B_ABST
    Figure CN120706579B_ABST
Patent Text Reader

Abstract

The application provides a question generation method and device, electronic equipment and a storage medium. The method comprises: performing feature analysis on a sample text to obtain a sample key node of the sample text, wherein the sample key node is used to support 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 multiple counterfactual nodes, wherein the multiple counterfactual nodes have the same dependency type as the sample key node; performing model training based on angle comparison and ternary comparison on a first original model according to the sample key node 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 matched with the target text according to the target key node. The application can ensure that a multi-hop question matched with the text is generated, and can improve the accuracy of the generated multi-hop question.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of question generation, and in particular to a question generation method and device, an electronic device, and a storage medium. BACKGROUND

[0002] Question generation (QG) is the task of automatically generating questions based on a given context, which is crucial in applications such as question-answering systems, dialogue systems, educational systems, and legal systems. Previous research has mostly focused on generating shallow factoid questions (i.e., single-hop questions), which are usually generated from a sentence containing the answer or adjacent sentences within the same paragraph.

[0003] In recent years, research has gradually shifted to generating more complex multi-hop questions. Such questions require integrating multiple scattered evidence from different paragraphs and generating factoid coherent questions related to the answer through reasoning. Compared with single-hop questions, the complexity of multi-hop questions lies in the complex entity connection in the reasoning chain. If the reasoning chain is too simple, the question will degenerate into a single-hop form; and generating multi-hop questions requires the model to understand the association between non-continuous information distributed in multiple documents, otherwise it will lead to the generated multi-hop question being difficult to match the document, and the accuracy is not high. SUMMARY

[0004] Therefore, the present application provides a question generation method and device, an electronic device, and a storage medium, which can ensure that a multi-hop question matching a text is generated, and the accuracy of the generated multi-hop question is improved.

[0005] The first aspect of the embodiment of the present application provides a question generation method, comprising: performing feature analysis on a sample text to obtain a sample key node of the sample text, wherein the sample key node is used to support 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; performing model training based on angle comparison and ternary comparison on a first original model according to the sample key node and the plurality of 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 embodiments of the present application have at least the following advantages: first, since the sample key node is used to undertake the context of the sample text, that is, the sample key node is the most influential hub node to the information flow of the sample text, by modifying at least one attribute value of the sample key node according to a preset modification strategy, a plurality of counterfactual nodes are obtained, and the plurality of counterfactual nodes have the same dependency type as the sample key node. On the one hand, by locally modifying the attribute value to replace the traditional global data adjustment of the entire sample key node, the noise interference is reduced, and the modification range is minimized while the prediction difference is maximized. On the other hand, based on the prototype invariance, the counterfactual nodes with bridging dependency invariance are generated, which provide the first original model with diversified but logically consistent sample data for processing, thereby improving the accuracy of the first target model trained. Second, since the first target model is obtained by training the first original model based on angle comparison and ternary comparison, the angle comparison can maximize the similarity between the sample key nodes and minimize the similarity between the counterfactual nodes. The ternary comparison solves the problem that the traditional contrast learning is not sensitive to subtle differences by constraining the feature distribution of the ternary group, thereby further improving the accuracy of the first target model trained. Finally, by inputting the target text into the first target model, an accurate target key node can be output by the high-precision first target model, thereby improving the accuracy of the multi-hop problem obtained based on the target key node. In addition, since the first target model is trained based on the sample key node used to undertake the context of the sample text, the target key node output by the first target model can also accurately undertake the context of the target text, thereby ensuring that the problem generated based on the target key node is a multi-hop problem.

[0007] In a possible implementation, the counterfactual node includes a positive counterfactual node and a negative counterfactual node; and the model training of the first original model based on angle comparison and ternary comparison according to the sample key node and the plurality of counterfactual nodes includes: constructing an angle comparison loss function according to the positive counterfactual node and the negative counterfactual node; constructing a ternary comparison loss function according to the original key node, the positive counterfactual node and the negative counterfactual node; and training the first original model according to the sample key node, the positive counterfactual node, the negative counterfactual node, the angle comparison loss function and the ternary comparison loss function.

[0008] In a possible implementation, the ternary comparison loss function is constructed according to the original key node, the positive counterfactual node and the negative counterfactual node, including: constructing the ternary comparison loss function according to the following formula: ; wherein, is the ternary comparison loss function, is and cosine similarity, The sample text, yes Counterfactual sample text, These 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 multiple counterfactual nodes according to the following formula:

[0010] ;in, Represents an instance of a key node in a sample. Represents an instance of a counterfactual node; According to Outputting the multi-hop problem; According to The multi-hop output problem The weights used to balance prediction variance and instance variance; Measure the distance between key nodes and counterfactual nodes in the sample.

[0011] In one possible implementation, obtaining the multi-hop problem matching the target text based on the target key nodes includes: inputting the target key nodes into a second target model to obtain the multi-hop problem; wherein the second target model is obtained by training a second original model based on the sample key nodes and multiple counterfactual nodes.

[0012] In one 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 the sample key nodes, which includes: performing feature analysis on the graph structure to obtain the sample key nodes.

[0013] In one possible implementation, the step of 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.

[0014] Secondly, embodiments of this application also provide a question generation apparatus, 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 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 on a first original model based on angle comparison and ternary comparison 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.

[0015] Thirdly, embodiments of this application also provide an electronic device, the electronic device including a processor and a memory, the memory being used to store instructions, and the processor being used to call the instructions in the memory, causing the electronic device to execute the problem generation method as described in the first aspect.

[0016] Fourthly, embodiments of this application also provide a storage medium that stores computer instructions that, when executed on an electronic device, cause the electronic device to perform the problem generation method as described in the first aspect.

[0017] The technical effects achieved by the second, third, and fourth aspects mentioned above are similar to those achieved by the corresponding technical means in the first aspect, and will not be repeated here. Attached Figure Description

[0018] Figure 1 This is a flowchart illustrating one step of a problem generation method provided in an embodiment of this application.

[0019] Figure 2 This is a flowchart illustrating another step of the problem generation method provided in one embodiment of this application.

[0020] Figure 3 A functional block diagram of a problem generation device provided in an embodiment of this application.

[0021] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0022] To better understand the above-mentioned objectives, features, and advantages of this application, the application will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in these embodiments can be combined with each other.

[0023] The following description sets forth many specific details to provide a full understanding of this application. The described embodiments are only some, not all, of the embodiments of this application.

[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein in the specification of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application.

[0025] It should be further noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0026] In this application, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The terms "first," "second," "third," "fourth," etc. (if present) in the specification, claims, and drawings of this application are used to distinguish similar objects, not to describe a specific order or sequence.

[0027] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0028] For ease of understanding, exemplary descriptions of some concepts related to the embodiments of this application are provided for reference.

[0029] Key Node Identification: A semantic dependency graph is constructed based on a Graph Attention Network (GAT), and high-influence nodes are selected through node centrality analysis. For example, in a multi-document scenario, entities shared across paragraphs are identified as core hubs for information flow. GAT captures long-range dependencies between nodes through dynamic attention weight calculation, avoiding redundant noise interference.

[0030] Counterfactual instance generation: A generation strategy employing prototype invariance constraints is used to keep node types unchanged, modifying only attribute values. The generation process is optimized through a heuristic objective function, ensuring that the modification magnitude is minimized while maximizing prediction discrepancies, generating logically consistent counterfactual instances.

[0031] Angular Space Contrastive Learning: A dual-encoder architecture is designed to model semantic relationships in angular space using cosine similarity. Angular contrast forces the maximization of similarity between original support data and the minimization of similarity between counterfactual data; triple contrast constrains feature distribution through triples, addressing the problem of traditional contrastive learning's insensitivity to subtle differences.

[0032] Model-independent collaborative training: This method integrates cross-entropy loss and contrastive loss, adapting to various architectures such as Transformer and GNN. For example, in Transformer, it strengthens the association between bridging nodes through self-attention, while in GNN, it utilizes graph propagation to optimize inference path representation.

[0033] Zero-shot generalization validation: Combining the context learning capabilities of large language models, counterfactual data is encoded as prompts to guide the model in generating multi-hop questions, which has strong generalization characteristics for complex and dynamically dependent scenarios.

[0034] Multi-hop question generation is a natural language processing task designed to generate complex questions that require multi-step reasoning to answer from a given context. It simulates the multi-step human thought process, integrating information scattered across different fragments to construct a clear reasoning path, thereby generating questions with depth and logic. 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, thus possessing significant research value and broad application prospects in the field of natural language processing.

[0035] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating the steps of one embodiment of the problem generation method of this application. Depending on different needs, the order of the steps in this flowchart can be changed, and some steps can be omitted. The problem generation method of this application can be applied to a problem generation apparatus, but is not limited thereto, and the embodiments of this application do not limit it in this regard.

[0036] The specific process of this embodiment is as follows: Figure 1 As shown, it includes the following steps:

[0037] Step 101: Perform feature analysis on the sample text to obtain the key nodes of the sample text.

[0038] Specifically, key nodes in a sample are used to provide context for the sample text.

[0039] The details of how to perform feature analysis on sample text are described in subsequent embodiments, and will not be repeated here to avoid repetition.

[0040] Step 102: Modify at least one attribute value of the key node of the sample according to the preset modification strategy to obtain multiple counterfactual nodes.

[0041] Specifically, multiple counterfactual nodes and sample key nodes have the same dependency type.

[0042] In some embodiments, multiple counterfactual nodes can be generated through counterfactual instance generation. Specifically, multiple counterfactual nodes are obtained according to the following formula:

[0043] ;in, Represents an instance of a key node in a sample. Represents an instance of a counterfactual node; According to Outputting the multi-hop problem; According to The multi-hop output problem The weights used to balance prediction variance and instance variance; Measure the distance between key nodes and counterfactual nodes in the sample.

[0044] To facilitate understanding, the following example illustrates how counterfactual nodes are generated in this embodiment:

[0045] 1. Enhance data diversity by generating different instances while preserving the attribute set of key bridging nodes, ensuring consistency in underlying dependency types and modifying only specific values: 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 completely consistent attributes, ensuring the underlying dependency types remain unchanged. For example, "Jeck" and "Jock" represent different actor instances while retaining actor-related attributes.

[0046] 2. Based on the above formula, fine-tune specific attribute values ​​of the new instance, and generate logically consistent counterfactual nodes while keeping the bridging dependency type unchanged: After generating the new instance "Jock", fine-tune its attributes. Specifically, this includes modifying specific values ​​(e.g., changing the birth year from 1958 to 1968) while keeping the bridging dependency type (e.g., "actor → role → position") unchanged.

[0047] Step 103: Based on the key nodes of the sample and multiple counterfactual nodes, train the first original model using angle comparison and ternary comparison to obtain the first target model.

[0048] In some embodiments, the first original model is a GAT model. It is understood that this embodiment does not specifically limit the type of the first original model, but only needs to ensure that the first original model can output sample key nodes based on the sample text.

[0049] In some embodiments, 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 negative counterfactual nodes; constructing a ternary contrast loss function based on the original key nodes, positive counterfactual nodes, and negative counterfactual nodes; and training the first original model based on the sample key nodes, positive counterfactual nodes, negative counterfactual nodes, angle contrast loss function, and ternary contrast loss function.

[0050] Specifically, a ternary contrastive loss function is constructed based on the original key nodes, positive and negative fact nodes, and negative and negative fact nodes, including: constructing the ternary contrastive loss function according to the following formula: ;in, For the ternary contrast loss function, yes and cosine similarity, The sample text, yes Counterfactual sample text, These are other sample texts, and τ is the temperature hyperparameter.

[0051] Step 104: Input the target text into the first target model to obtain the target key nodes of the text.

[0052] Step 105: Obtain the multi-hop problem that matches the target text based on the target key nodes.

[0053] In some embodiments, the target key node is input into a second target model to obtain a multi-hop problem.

[0054] Specifically, the second target model is obtained by training the second original model based on the key nodes of the samples and multiple counterfactual nodes.

[0055] In some embodiments, the second original model is trained using the binary cross-entropy loss function as the training objective function. The binary cross-entropy loss function is defined as follows:

[0056] Where L is the binary cross-entropy loss function, It quantifies the accuracy of counterfactual sample predictions for multi-hop problems, where σ represents the Sigmoid activation function. Let be the soft target score of the real problem corresponding to the i-th training sample.

[0057] It is worth noting that by generating counterfactual nodes based on sample key nodes and training the second original model using both sample key nodes and counterfactual nodes, zero-shot generalization validation of the second original model was achieved. This ensures that the trained second target model can generate multi-hop problems, improving the reliability of the problem generation method. Furthermore, since the first target model for generating target key nodes is obtained by training the first original model using angle comparison and ternary comparison, while the second target model is obtained by training the second original model using a binary cross-entropy loss function, combining cross-entropy loss and angle space comparison loss for model-independent co-training further improves the accuracy of the multi-hop problem output by the second target model by leveraging the differences between the original and counterfactual data to optimize the model's sensitivity to dependencies.

[0058] Compared with related technologies, the embodiments of this application have at least the following advantages: First, since the sample key nodes are used to carry the context of the sample text, that is, the sample key nodes are the hub nodes that have the greatest impact on the information flow of the sample text, by modifying at least one attribute value of the sample key nodes according to the preset modification strategy, multiple counterfactual nodes are obtained, and the multiple counterfactual nodes have the same dependency type as the sample key nodes. 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 prediction difference is maximized while minimizing the modification magnitude. On the other hand, the generation of counterfactual nodes with bridging dependency invariance based on prototype invariance provides diverse but logically consistent sample data for the first original model to process, thereby improving the accuracy of the trained first target model. Second, 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, on the other hand, solves the problem of traditional contrastive learning being insensitive to subtle differences by constraining the feature distribution through triples, thereby further improving the accuracy of the trained first target model. Finally, inputting the target text into the first target model allows it to output accurate target key nodes, thereby improving the accuracy of multi-hop problems derived from these key nodes. Furthermore, since the first target model is trained based on sample key nodes that serve as context for the sample text, the target key nodes output by the first model also accurately reflect the context of the target text, ensuring that the problems generated based on these key nodes are indeed multi-hop problems.

[0059] Please refer to Figure 2 , Figure 2 This is a flowchart illustrating the steps of one embodiment of the problem generation method of this application. Depending on different needs, the order of the steps in this flowchart can be changed, and some steps can be omitted. This problem generation method can be applied to the aforementioned problem generation apparatus, but is not limited thereto, and this embodiment of the application does not limit it in this regard.

[0060] This embodiment is a detailed description of the foregoing embodiments, mainly illustrating how to perform feature analysis on sample text. This method further ensures the accuracy of the generated questions.

[0061] The specific process of this embodiment is as follows: Figure 2 As shown, it includes the following steps:

[0062] Step 201: Extract instances from the sample text.

[0063] Step 202: Construct a graph structure that matches the sample text based on the instance.

[0064] This embodiment does not impose specific limitations on the construction method of the graph structure, which can be set according to the actual situation. In the graph structure of this embodiment, instances of sample text constitute nodes of the graph structure, and a sentence of sample text constitutes a link of the graph structure.

[0065] Step 203: Input the graph structure into the first original model to obtain the key nodes of the sample.

[0066] Specifically, the GAT model is used to identify key nodes in the graph structure and filter out the hub nodes that have the greatest impact on information flow.

[0067] Step 204: Modify at least one attribute value of the key node of the sample according to the preset modification strategy to obtain multiple counterfactual nodes.

[0068] Step 205: Based on the key nodes of the sample and multiple counterfactual nodes, train the first original model using angle comparison and ternary comparison to obtain the first target model.

[0069] Step 206: Input the target text into the first target model to obtain the target key nodes of the text.

[0070] Step 207: Obtain the multi-hop problem that matches the target text based on the target key nodes.

[0071] Steps 204 to 207 in this embodiment are similar to steps 102 to 105 in the previous embodiment. To avoid repetition, they will not be described again here.

[0072] Compared with related technologies, the embodiments of this application have at least the following advantages: First, since the sample key nodes are used to carry the context of the sample text, that is, the sample key nodes are the hub nodes that have the greatest impact on the information flow of the sample text, by modifying at least one attribute value of the sample key nodes according to the preset modification strategy, multiple counterfactual nodes are obtained, and the multiple counterfactual nodes have the same dependency type as the sample key nodes. 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 prediction difference is maximized while minimizing the modification magnitude. On the other hand, the generation of counterfactual nodes with bridging dependency invariance based on prototype invariance provides diverse but logically consistent sample data for the first original model to process, thereby improving the accuracy of the trained first target model. Second, 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, on the other hand, solves the problem of traditional contrastive learning being insensitive to subtle differences by constraining the feature distribution through triples, thereby further improving the accuracy of the trained first target model. Finally, inputting the target text into the first target model allows it to output accurate target key nodes, thereby improving the accuracy of multi-hop problems derived from these key nodes. Furthermore, since the first target model is trained based on sample key nodes that serve as context for the sample text, the target key nodes output by the first model also accurately reflect the context of the target text, ensuring that the problems generated based on these key nodes are indeed multi-hop problems.

[0073] Based on the same idea as the problem generation method in the above embodiments, this application also provides a problem generation apparatus, which can be used to execute the above problem generation method. For ease of explanation, the structural schematic diagram of the problem generation apparatus embodiment only shows the parts related to the embodiments of this application. Those skilled in the art will understand that the illustrated structure does not constitute a limitation on the apparatus, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0074] like Figure 3 As shown, the problem 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, the above modules can be programmable software instructions stored in memory and executable by a processor. It is understood that in other embodiments, the above modules can also be program instructions or firmware embedded in the processor.

[0075] Analysis module 301 is used to perform feature analysis on 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.

[0076] Modification module 302 is used to modify at least one attribute value of the sample key node 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 node;

[0077] Training module 303 is used to train the first original model based on angle comparison and ternary comparison according to the sample key nodes and multiple counterfactual nodes to obtain the first target model;

[0078] Input module 304 is used to input target text into the first target model to obtain the target key nodes of the text;

[0079] The acquisition module 305 is used to acquire multi-hop problems that match the target text based on the target key nodes.

[0080] Please refer to Figure 4 , Figure 4 This is a schematic diagram of an embodiment of the electronic device of this application.

[0081] Electronic device 100 includes memory 20, processor 30, and computer program 40 stored in memory 20 and executable on processor 30. When processor 30 executes computer program 40, it implements the steps described in the problem generation method embodiments above, for example... Figure 1 Steps 101 to 105 are shown.

[0082] For example, computer program 40 can also be divided into one or more modules / units, one or more of which are stored in memory 20 and executed by processor 30. One or more modules / units can be a series of computer program instruction segments capable of performing a specific function, the instruction segments describing the execution process of computer program 40 in 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.

[0083] 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. It may include more or fewer components than shown in the diagram, or combine certain components, or different components. For example, the electronic device 100 may also include input / output devices, network access devices, buses, etc.

[0084] Processor 30 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. General-purpose processors can be microprocessors, single-chip microcomputers, or any conventional processor.

[0085] 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 by calling data stored in the memory 20. The memory 20 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device 100 (such as audio data), etc. In addition, the memory 20 may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, RAM, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other non-volatile solid-state storage device.

[0086] If the modules / units integrated in 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, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The storage medium can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the storage medium can be appropriately added or removed according to the requirements of patent practice. For example, according to patent practice, the storage medium does not include electrical carrier signals and telecommunication signals.

[0087] The problem generation method, apparatus, electronic device, and storage medium provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A problem generation method, characterized in that, include: Feature analysis is performed on the sample text to obtain the sample key nodes of the sample text, wherein the sample key nodes are used to carry the context of the sample text; According to a preset modification strategy, at least one attribute value of the sample key node is modified to obtain multiple counterfactual nodes, wherein the multiple counterfactual nodes have the same dependency type as the sample key node; Based on the key nodes of the sample and multiple counterfactual nodes, the first original model is trained using angle comparison and ternary comparison to obtain the first target model; Input the target text into the first target model to obtain the target key nodes of the text; Based on the target key nodes, obtain the multi-hop problem that matches the target text; The counterfactual nodes include positive counterfactual nodes and negative counterfactual nodes; The step of training the first original model based on angle comparison and ternary comparison according to the sample key nodes and multiple counterfactual nodes includes: Construct an angle comparison loss function based on the positive and negative fact nodes and the negative fact nodes; A ternary contrast loss function is constructed based on the key nodes of the sample, the positive and negative fact nodes, and the negative and negative fact nodes; The first original model is trained based on the sample key nodes, the positive and negative fact nodes, the negative and negative fact nodes, the angle contrast loss function, and the ternary contrast loss function.

2. The problem generation method according to claim 1, characterized in that, The construction of a ternary contrast loss function based on the sample key nodes, the positive and negative fact nodes, and the negative and negative fact nodes includes: The ternary contrastive loss function is constructed according to the following formula: ;in, For the ternary contrast loss function, yes and cosine similarity, The sample text, yes Counterfactual sample text, These are other sample texts, and τ is the temperature hyperparameter.

3. The problem generation method according to claim 1, characterized in that, The step of modifying at least one attribute value of the key node of the sample according to a preset modification strategy to obtain multiple counterfactual nodes includes: Multiple counterfactual nodes are obtained according to the following formula: ;in, Represents an instance of a key node in a sample. Represents an instance of a counterfactual node; According to Outputting the multi-hop problem; According to The multi-hop output problem The weights used to balance prediction variance and instance variance; Measure the distance between key nodes and counterfactual nodes in the sample.

4. The problem generation method according to claim 1, characterized in that, The step of obtaining the multi-hop problem matching the target text based on the target key nodes includes: The target key nodes are input into the second target model to obtain the multi-hop problem; The second target model is obtained by training the second original model based on the sample key nodes and multiple counterfactual nodes.

5. The problem generation method according to any one of claims 1 to 4, characterized in that, Before performing feature analysis on the sample text, the following is also included: Extract instances from the sample text; Construct a graph structure that matches the sample text based on the example; The step of performing feature analysis on the sample text to obtain the sample key nodes includes: performing feature analysis on the graph structure to obtain the sample key nodes.

6. The problem generation method according to claim 5, characterized in that, The step of performing feature analysis on the graph structure to obtain the key nodes of the sample includes: The graph structure is input into the first original model to obtain the key nodes of the sample.

7. A problem generation 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 the 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 node 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 node; The training module is used to train the first original model based on angle comparison and ternary comparison according to the sample key nodes and multiple counterfactual nodes to obtain the first target model; The counterfactual nodes include positive counterfactual nodes and negative counterfactual nodes; The step of training the first original model based on angle comparison and ternary comparison according to the sample key nodes and multiple counterfactual nodes includes: Construct an angle comparison loss function based on the positive and negative fact nodes and the negative fact nodes; A ternary contrast loss function is constructed based on the key nodes of the sample, the positive and negative fact nodes, and the negative and negative fact nodes; The first original model is trained based on the sample key nodes, the positive and negative fact nodes, the negative and negative fact nodes, the angle contrast loss function, and the ternary contrast loss function. 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 multi-hop problems that match the target text based on the target key nodes.

8. An electronic device, the electronic device comprising a processor and a memory, characterized in that, The memory is used to store instructions, and the processor is used to invoke the instructions in the memory to cause the electronic device to execute the problem generation method as described in any one of claims 1 to 6.

9. A storage medium, characterized in that, The storage medium stores computer instructions that, when executed on an electronic device, cause the electronic device to perform the problem generation method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Candidate paragraph generation and multi-hop question answering method based on text classification

    CN115878794A

  • Multi-hop inference knowledge editing method based on model cognitive verification

    CN118364912A