Graph-driven question-answer generation method, device, medium, and equipment based on structure perception
By constructing a structure tree and knowledge graph for structured documents, and combining structure scoring and understanding scoring mechanisms, we generate full-granularity question and answer pairs, solving the existing problem of question and answer generation for structured documents and achieving efficient and accurate question and answer generation.
Patent Information
- Application Number
- CN202510940680.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-09
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2045-07-09
AI Technical Summary
Existing question-and-answer generation technologies are unable to effectively process structured documents, especially complex documents in government, law, finance and other fields, and cannot meet the needs of efficient and accurate question-and-answer generation.
By performing structure extraction and knowledge extraction on structured documents, a document structure tree and knowledge graph are constructed to form a structure-aware fusion graph. Based on the structure scoring and understanding scoring mechanisms, candidate node-relationship block sets at the entity level, scenario level, and reasoning level are constructed to generate full-granularity question-answer pairs.
It improves the structural reference and semantic consistency of question and answer generation, supports multi-scenario and multi-depth intelligent question and answer generation, is suitable for structured document-intensive fields, and has good granularity adaptation capabilities.
Smart Images

Figure CN120470098B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language processing technology, and in particular to a graph-driven question and answer generation method, device, medium and equipment based on structure perception. Background Art
[0002] Most existing question-and-answer generation technologies mainly process plain text. For structured files such as government documents, due to their complexity, traditional single-modal natural language processing models cannot accurately identify and understand complex document content (such as complex tables, charts, and structural hierarchies), making it difficult to meet the needs of efficient and accurate question-and-answer generation in the government field.
[0003] Therefore, there is an urgent need for a structure-aware graph-driven question-answer generation method to generate full-granularity question-answer pairs for structured documents. Summary of the Invention
[0004] In view of the above problems, the present invention is proposed to provide a structure-aware graph-driven question and answer generation method, device, medium and equipment that overcome the above problems or at least partially solve the above problems.
[0005] Other features and advantages of the present invention will become apparent from the following detailed description, or may be learned in part by practice of the present invention.
[0006] According to a first aspect of an embodiment of the present invention, a structure-aware graph-driven question-answer generation method is provided. The structure-aware graph-driven question-answer generation method includes:
[0007] Performing structural extraction on a structured document to obtain structural information of the structured document, and performing knowledge extraction on the structured document to obtain entities, entity relationships, and event information of the structured document, respectively modeling the structural information and entity relationships of the structured document to obtain a document structure tree and a document knowledge graph, and obtaining a structure-aware fusion graph based on the document structure tree and the document knowledge graph;
[0008] Performing knowledge traversal on the structure-aware fusion graph, implementing a chunk building strategy based on a structure scoring mechanism and an understanding scoring mechanism, and constructing candidate node-relationship chunk sets in three dimensions: entity level, scenario level, and reasoning level;
[0009] The constructed candidate node-relationship chunk sets are fused with the prompt word templates corresponding to the three dimensions to generate a full-granularity question-answer pair set.
[0010] In some embodiments of the present invention, extracting the structure of the structured document to obtain the structure information of the structured document includes:
[0011] Performing document preprocessing on the structured document to convert the structured document into a to-be-processed file in a target format;
[0012] Segmenting the document to be processed into pages using a document image analysis tool to obtain a structured representation of the document pages;
[0013] After sequentially reorganizing the structured representation of the document page, extracting the text content using OCR technology;
[0014] Regular expressions and template matching technology are used to identify the title hierarchy and paragraph structure in the text content by matching the set numbering pattern, and the structural information of the structured document is obtained.
[0015] In some embodiments of the present invention, extracting knowledge from the structured document to obtain entities, entity relationships, and event information of the structured document includes:
[0016] Identify and extract entities in the text content through a large language model;
[0017] Based on the extracted entities, high-precision entity type classification is performed by matching them with predefined Schema constraints to obtain a standardized unified entity representation for each entity;
[0018] According to the standardized unified entity representation of all the entities, corresponding entity relationships and event information are extracted from the text content.
[0019] In some embodiments of the present invention, respectively modeling the structural information and entity relationships of the structured document to obtain a document structure tree and a document knowledge graph includes:
[0020] Modeling the structural information of the structured document, identifying hierarchical nodes based on the structural features of the structural information, and establishing a document structure tree with parent-child relationships to form a tree-like structure;
[0021] The entity relationships of the structured document are modeled, and based on the extracted entities, entity relationships and event information, each entity and event information is used as a node, and the entity relationship is used as an edge to construct a document knowledge graph in the form of triples.
[0022] In some embodiments of the present invention, obtaining a structure-aware fusion graph based on the document structure tree and the document knowledge graph includes:
[0023] Establish a unique mapping relationship between all nodes of the document structure tree and all nodes of the document knowledge graph;
[0024] An index match is formed based on the node mapping relationship between the document structure tree and the document knowledge graph to obtain the structure-aware fusion graph.
[0025] In some embodiments of the present invention, performing knowledge traversal on the structure-aware fusion graph, implementing a chunk construction strategy based on a structure scoring mechanism and an understanding scoring mechanism, and constructing candidate node-relationship chunk sets at the entity level, scenario level, and reasoning level dimensions include:
[0026] When performing knowledge traversal on the structure-aware fusion graph, obtaining entity-level chunks;
[0027] During edge sampling, chunks are extracted according to the preset scene-level chunk construction strategy and the inference-level chunk construction strategy, and the scores of the edges on the structure-aware fusion graph are calculated based on the structure-semantic collaborative generation algorithm to obtain scene-level chunks and inference-level chunks respectively.
[0028] According to the extracted entity-level chunks, scene-level chunks and reasoning-level chunks, candidate node-relationship chunk sets of three dimensions, namely, entity-level, scene-level and reasoning-level, are constructed.
[0029] In some embodiments of the present invention, the score of the edge on the structure-aware fusion graph calculated based on the structure-semantic collaborative generation algorithm is obtained by the following formula:
[0030] ;
[0031] Where, is the structural similarity score, is the semantic confidence score, is the structural weight hyperparameter, For the edge score.
[0032] According to a second aspect of an embodiment of the present invention, a graph-driven question-answer generation device based on structure perception is provided. The graph-driven question-answer generation device based on structure perception includes:
[0033] A document processing module is configured to perform structural extraction on a structured document to obtain structural information of the structured document, and to perform knowledge extraction on the structured document to obtain entities, entity relationships, and event information of the structured document, respectively model the structural information and entity relationships of the structured document to obtain a document structure tree and a document knowledge graph, and to obtain a structure-aware fusion graph based on the document structure tree and the document knowledge graph;
[0034] A chunk building module is used to perform knowledge traversal on the structure-aware fusion graph, implement chunk building strategies based on the structure scoring mechanism and the understanding scoring mechanism, and construct candidate node-relationship chunk sets in three dimensions: entity level, scenario level, and reasoning level;
[0035] The question-answer pair generation module is used to fuse the constructed candidate node-relationship chunk sets with the prompt word templates corresponding to the three dimensions to generate a full-granularity question-answer pair set.
[0036] According to a third aspect of an embodiment of the present invention, a computer-readable storage medium is provided, in which computer program instructions are stored. The computer program instructions are loaded and executed by a processor to implement the operations performed by any of the methods described above.
[0037] According to a fourth aspect of an embodiment of the present invention, an electronic device is provided, comprising a processor and a memory, wherein the memory stores computer program instructions that can be executed by the processor, and when the processor executes the computer program instructions, it implements instructions of any of the methods described above.
[0038] The technical solutions provided in the embodiments of the present invention have at least the following technical effects or advantages:
[0039] The embodiments of the present invention provide a graph-driven question and answer generation method, device, medium and equipment based on structure perception. The graph-driven question and answer generation method based on structure perception forms an index match based on the node mapping relationship between the document structure tree and the document knowledge graph to obtain the structure-aware fusion graph, retains the complete document chapter tree, embeds the semantic network of the knowledge graph, ensures clear hierarchy and content association, significantly improves the structural reference and semantic consistency in the question and answer generation process, and improves the accuracy of knowledge retrieval. At the same time, a block construction mechanism of three dimensions, namely entity level, scenario level and reasoning level, is designed to support coverage from simple fact-based questions and answers to multi-hop logical reasoning questions and answers, has good granularity adaptation capabilities, meets the multi-scenario and multi-depth intelligent question and answer generation needs, and is particularly suitable for structured document-intensive fields such as government affairs, law, and finance.
[0040] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are specifically listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0042] Figure 1 A schematic diagram of a flow chart of a structure-aware graph-driven question-answer generation method provided in an embodiment of the present invention;
[0043] Figure 2 A schematic diagram of the principle structure of a graph-driven question-and-answer generation device based on structure perception provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0044] Exemplary embodiments of the present disclosure will be described below in more detail with reference to the accompanying drawings.
[0045] The accompanying drawings illustrate various schematic diagrams of structures according to embodiments of the present disclosure. These figures are not drawn to scale, and for the purpose of clarity, certain details are exaggerated and certain details may be omitted. The shapes of the various regions and layers shown in the figures, as well as their relative sizes and positional relationships, are merely exemplary and may deviate in practice due to manufacturing tolerances or technical limitations. Those skilled in the art may design regions / layers with different shapes, sizes, and relative positions as needed.
[0046] In the context of this disclosure, when a layer / element is referred to as being "on" another layer / element, the layer / element may be directly on the other layer / element or an intervening layer / element may exist therebetween. Additionally, if a layer / element is "on" another layer / element in one orientation, the layer / element may be "below" the other layer / element when the orientation is reversed. In the context of this disclosure, similar or identical components may be denoted by the same or similar reference numerals.
[0047] In order to better understand the above technical solution, the above technical solution will be described in detail below in combination with specific implementation methods. It should be understood that the embodiments of the present disclosure and the specific features in the embodiments are detailed descriptions of the technical solution of the present invention, rather than limitations on the technical solution of the present invention. In the absence of conflict, the embodiments of the present invention and the technical features in the embodiments can be combined with each other.
[0048] Figure 1 This is a flow chart of a structure-aware graph-driven question-answer generation method provided by an embodiment of the present invention. Figure 1 As shown in the figure, the structure-aware graph-driven question-answering generation method includes the following steps:
[0049] S1. Performing structural extraction on a structured document to obtain structural information of the structured document, and performing knowledge extraction on the structured document to obtain entities, entity relationships, and event information of the structured document, respectively modeling the structural information and entity relationships of the structured document to obtain a document structure tree and a document knowledge graph, and obtaining a structure-aware fusion graph based on the document structure tree and the document knowledge graph;
[0050] In the embodiment of the present invention, the structured documents include but are not limited to government documents, legal documents, and financial documents in document structuring-intensive fields.
[0051] In step S1 of the embodiment of the present invention, the structure extraction of the structured document to obtain the structural information of the structured document includes: performing document preprocessing on the structured document to convert the structured document into a to-be-processed file of a target format; performing page segmentation on the to-be-processed file by a document image analysis tool to obtain a structured representation of the document page; extracting the text content by OCR technology after sequential reorganization based on the structured representation of the document page; using regular expressions and template matching technology to identify the title hierarchy and paragraph structure in the text content by matching a set numbering pattern, and arranging to obtain the structural information of the structured document.
[0052] To improve the processing efficiency and accuracy of the structured documents, an embodiment of the present invention performs document preprocessing on all structured documents to be processed, converting the structured documents into files to be processed in a target format, such as PDF, to ensure format consistency and processing operability. A document image analysis tool is then used to segment the files to be processed, dividing the PDF document pages into different types of regions, including but not limited to text regions, table regions, and image regions, thereby achieving a structured representation of the document pages. The document image analysis tool can be, for example, a pre-trained model of LayoutParser or other tools with equivalent functions. After obtaining the structured representation of the document pages, the title / section title / text sections are screened out based on the document page layout segmentation and sequentially reorganized. OCR (optical character recognition) technology is used to extract text content. Regular expressions and template matching technology are then used to identify the title hierarchy (such as main title, subtitle, chapter title, etc.) and paragraph structure in the text content by matching a set numbering pattern (such as "1.", "1.1," or "Chapter 1"), thereby organizing the structural information of the structured document.
[0053] In step S1 of the embodiment of the present invention, knowledge extraction is performed on the structured document to obtain entities, entity relationships and event information of the structured document, including: identifying and extracting entities in the text content through a large language model; performing high-precision entity type classification based on the extracted entities by matching with predefined Schema constraints to obtain a standardized unified entity representation of each entity; and extracting corresponding entity relationships and event information from the text content based on the standardized unified entity representations of all entities.
[0054] An embodiment of the present invention uses a large language model (LLM) to identify and extract entities in the text content, wherein the entities are, for example, names of people, places, and terminology in various fields. In order to ensure the accurate representation of each entity, deduplication and merging are required to unify the entity representation. An embodiment of the present invention performs high-precision entity type classification based on the extracted entities by matching them with predefined Schema constraints, and obtains a standardized unified entity representation for each entity. For example, by combining a rule-based matching algorithm with a deep learning model, the entity type Schema constraints are defined based on expert knowledge in the corresponding field and a large amount of document analysis content in the same field, and high-precision entity type classification is performed. That is, entities are mapped to specific Schema types according to their context and structure. By mapping different entity expressions to a standard entity name, the standardized process unifies the entity representation. And according to the standardized unified entity representation of all the entities, the corresponding entity relationships and event information are extracted from the text content.
[0055] In step S1 of the embodiment of the present invention, the structural information and entity relationships of the structured document are modeled respectively to obtain a document structure tree and a document knowledge graph, including: modeling the structural information of the structured document, identifying hierarchical nodes with the structural features of the structural information, and establishing a document structure tree with parent-child relationships to form a tree structure; modeling the entity relationships of the structured document, based on the extracted entities, entity relationships and event information, taking each entity and event information as a node, taking the entity relationship as an edge, and constructing a document knowledge graph in the form of triples.
[0056] Structured documents typically have a distinct hierarchical organization (e.g., chapters, sections, first-level headings, second-level headings, etc.), which can be compared to an HTML DOM tree. Embodiments of the present invention extract the hierarchical structure of a structured document based on its chapter structure, generating a document structure tree. By analyzing features such as the document's title sequence and format indentation, hierarchical nodes are identified and parent-child relationships are established to form a tree-like structure. For example, a first-level heading serves as the root node, with its second-level headings acting as child nodes in a recursive order. Each node represents a structural unit (e.g., a chapter or section) in the structured document, and its content includes the unit title and a corresponding text summary or pointer. This structure tree accurately depicts the document's logical hierarchy and paragraph boundaries, laying the foundation for generating questions at different levels. The resulting document structure tree provides a skeletal reference for subsequent knowledge extraction and graph fusion, with its nodes serving as key nodes in the fused graph for subsequent processing.
[0057] The step S1 of the embodiment of the present invention of obtaining a structure-aware fusion graph based on the document structure tree and the document knowledge graph includes: establishing a unique mapping relationship between all nodes of the document structure tree and all nodes of the document knowledge graph; forming an index match based on the node mapping relationship between the document structure tree and the document knowledge graph to obtain the structure-aware fusion graph.
[0058] The embodiment of the present invention establishes a mapping relationship by linking the entity node in each document knowledge graph to the leaf node corresponding to the document structure tree. After the mapping association, the structure-aware fusion graph formed is a knowledge network with a hierarchical structure.
[0059] S2. Performing knowledge traversal on the structure-aware fusion graph, implementing a chunk building strategy based on a structure scoring mechanism and an understanding scoring mechanism, and constructing candidate node-relationship chunk sets at the entity level, scenario level, and reasoning level.
[0060] In step S2 of the embodiment of the present invention, knowledge traversal is performed on the structure-aware fusion graph, and a chunk construction strategy is implemented based on a structure scoring mechanism and an understanding scoring mechanism to construct candidate node-relationship chunk sets of three dimensions: entity level, scene level, and reasoning level. The steps include: obtaining entity-level chunks when performing knowledge traversal on the structure-aware fusion graph; extracting chunks according to preset scene-level chunk construction strategies and reasoning-level chunk construction strategies during edge sampling, calculating the scores of edges on the structure-aware fusion graph based on a structure-semantic collaborative generation algorithm, and obtaining scene-level chunks and reasoning-level chunks respectively; and constructing candidate node-relationship chunk sets of three dimensions: entity level, scene level, and reasoning level based on the extracted entity-level chunks, scene-level chunks, and reasoning-level chunks.
[0061] Specifically, when performing knowledge traversal on the structure-aware fusion graph, the embodiment of the present invention calculates the scores of edges based on the structural semantic collaborative generation algorithm to select edges. By modeling the edge scoring function as a fusion of structural prior (tree structure) and large language model semantic score (edge interpretation credibility), the calculated scores of the two factors of structure and semantics are combined to give priority to edges with "similar structure + credible semantics".
[0062] Define the structure-aware fusion graph , For nodes, For edge; each knowledge edge , characterizing de novo entities To the end entity For the document structure tree T, each knowledge point corresponds to a leaf node on the tree; the "closest common parent (LCA)" of any two nodes can be obtained in the tree structure diagram. Indicates the closest common parent node of two leaf nodes; each edge The semantic description of can be prompted to the large language model through the prompt word prompt, and the output is whether the sentence is credible (return the softmax probability, recorded as ).
[0063] The score of the edge of the structure-aware fusion graph is calculated based on the structure-semantic collaborative generation algorithm by the following formula:
[0064] ;
[0065] Where, is the structural similarity score (structural prior), , is the semantic confidence score (semantically credible), , is the structural weight hyperparameter, , For the edge score.
[0066] In the embodiment of the present invention, for the structural similarity score, the closer the score is to 1, the closer the two nodes are to each other, and the stronger the scene association is.
[0067] In an embodiment of the present invention, for the semantic confidence score, a large language model is used to output an unnormalized prediction value logits, and the semantic confidence score is obtained through softmax. For example, the semantic confidence score constructs a natural language prompt word prompt for each knowledge edge:
[0068]
[0069] In the embodiment of the present invention, the structural weight hyperparameter can be determined by the scenario-level chunk construction strategy and the inference-level chunk construction strategy.
[0070] A chunk is the smallest unit for generating question-answer pairs. The entity-level chunk uses a dumbbell-shaped (two nodes and one edge) chunk as the smallest unit to represent fine-grained questions. The scenario-level chunk uses a radial (multiple nodes and edges) chunk as the smallest unit to represent scenario-type comprehensive questions. The reasoning-level chunk uses a single-path (multiple-hop nodes and edges) chunk as the smallest unit to represent complex reasoning problems. The entity-level chunk is directly obtained by recording each time the knowledge edge is traversed. The scenario-level chunk and the reasoning-level chunk are selected based on the structure and edge understanding scoring mechanism during edge sampling, and are grouped in combination with the scenario-level chunk construction strategy and the reasoning-level chunk construction strategy.
[0071] See Table 1 for a reference table of grouping parameters for the scene-level chunking strategy and the inference-level chunking strategy:
[0072] Table 1 Reference table of grouping parameters for scenario-level chunk building strategies and reasoning-level chunk building strategies
[0073]
[0074] Regarding Table 1, the termination condition for edge expansion is set to the maximum number of tokens (in large models, a "token" is the basic unit of text processing; it usually refers to a word, character, or subword in the text, depending on the model's word segmentation method). Expansion stops when the maximum number of tokens is exceeded. The maximum number of edges can be obtained similarly. Secondly, for the max_depth parameter (i.e., the divergence of the initial node or the number of logical reasoning steps), if the scenario-level chunking strategy is used, it means that the longest path from the initial node does not exceed the max_depth parameter value, but the initial node's out-degree is not restricted. The out-degree of a graph node represents the number of edges emanating from that node. If the reasoning-level chunking strategy is used, it means that the longest path from the initial node does not exceed the max_depth parameter value, but the initial node's out-degree is restricted to 1. The out-degree of a graph node represents the number of edges emanating from that node.
[0075] For example, for a scene-level block, the sub-block B is initialized first during construction, and contains only one input initial node , calculate and Adjacent edges are taken as candidate edge set C, and the candidate edge set scores are calculated according to the scene-level chunking strategy. Select an edge and the corresponding node from the candidate set to add to the sub-block, remove the added edge from the candidate set, and terminate the expansion if the current sub-block meets some preset constraints, and return the extracted sub-block B.
[0076] The scene-level chunk construction strategy preset in the embodiment of the present invention is implemented by a scene-level chunk construction algorithm, which is shown in the following reference:
[0077]
[0078] For example, for the inference-level block, the sub-block B is first initialized during construction, containing only one input initial node , calculate and Adjacent edges are taken as candidate edge set C, and the candidate edge set scores are calculated according to the inference level chunking strategy. Select an edge and the corresponding node from the candidate set to add to the sub-block. The added edge is removed from the candidate set. After the edge e is expanded (after adding the sub-block), all new adjacent edges at both ends of the path are added to the candidate set C so that the sub-block can be further expanded. If the current sub-block meets some preset constraints, the expansion is terminated and the extracted sub-block B is returned.
[0079] The inference-level chunk construction strategy preset in the embodiment of the present invention is implemented by an inference-level chunk construction algorithm, and the inference-level chunk construction algorithm is shown in the following reference:
[0080]
[0081] The embodiment of the present invention constructs a set of candidate node-relationship chunks in three dimensions: entity level, scenario level, and reasoning level through the extracted entity-level chunks, scenario-level chunks, and reasoning-level chunks, thereby realizing multi-granularity chunk generation from simple entity relationships to complex scenario and reasoning relationships, significantly improving the intelligence and granularity adaptability of question-answer pair generation.
[0082] S3. The constructed candidate node-relationship chunk set is fused with the prompt word templates corresponding to the three dimensions to generate a full-granularity question-answer pair set.
[0083] After extracting the three-dimensional chunks and constructing a set of candidate node-relationship chunks, an embodiment of the present invention creates corresponding prompt word templates based on question-answer pairs (QA) of different granularities, and then generates corresponding question-answer pairs based on a large language model. For scene-level chunks, the large language model rephrases the radial chunk content into a coherent text (answer), and then uses the large language model to generate its corresponding question. For inference-type chunks, the large language model is given some context and a few examples (few shots), and then instructed to generate question-answer pairs (QA) that require multi-step reasoning. A full-granularity question-answer pair set is generated based on all the obtained question-answer pairs.
[0084] Compared with existing technologies, the structure-aware graph-driven question-answer generation described in the embodiments of the present invention has the following advantages:
[0085] 1. An index match is formed based on the node mapping relationship between the document structure tree and the document knowledge graph to obtain the structure-aware fusion graph, which retains the complete document chapter tree and embeds the semantic network of the knowledge graph to ensure clear hierarchy and content association. Through the fusion of the two, knowledge nodes can be traced back to their chapters, paragraphs or superordinate topics through links. The fused structure-aware fusion graph has the dual semantics of "structure + knowledge", which significantly improves the structural reference and semantic consistency in the question and answer generation process and improves the accuracy of knowledge retrieval. The structure tree as a skeleton effectively limits the context scope of the question and answer, reduces the "hallucination" problem when generating question and answer pairs, and ensures that the generated content is accurate and reliable.
[0086] 2. A block construction mechanism has been designed at the entity level, scenario level, and reasoning level. It supports a range of question-answering tasks, from simple factual questions to multi-hop logical reasoning questions. It has good granularity adaptability and meets the needs of intelligent question-answering in multiple scenarios and at multiple depths. It is particularly suitable for structured document-intensive fields such as government affairs, law, and finance.
[0087] 3. The structural semantic collaborative scoring mechanism helps to discover relatively hidden but structurally sound and semantically credible edge relationships in the graph, thereby enhancing the coverage of long-tail knowledge and multi-hop semantics. Compared with traditional sampling methods based on frequency or simple semantic similarity, the embodiments of the present invention can expand the coverage of question and answer content while maintaining semantic relevance.
[0088] 4. With the help of a clear structural hierarchy and edge scoring function, each generated question-answer pair can be traced back to the corresponding graph subgraph and structural path, making the question-answer generation process highly controllable and transparent, which is conducive to subsequent manual review, debugging optimization and visualization.
[0089] On the basis of the above embodiment, as the above Figure 1The present invention provides an embodiment of a graph-driven question-answer generation device based on structure perception. Figure 1 The device can be applied to various electronic devices, see Figure 2 As shown, the structure-aware graph-driven question-answer generation device includes:
[0090] The document processing module 100 is configured to perform structural extraction on a structured document to obtain structural information of the structured document, and to perform knowledge extraction on the structured document to obtain entities, entity relationships, and event information of the structured document, respectively model the structural information and entity relationships of the structured document to obtain a document structure tree and a document knowledge graph, and to obtain a structure-aware fusion graph based on the document structure tree and the document knowledge graph;
[0091] A chunk building module 200 is configured to perform knowledge traversal on the structure-aware fusion graph, implement a chunk building strategy based on a structure scoring mechanism and an understanding scoring mechanism, and construct candidate node-relationship chunk sets at the entity level, scenario level, and reasoning level.
[0092] The question-answer pair generation module 300 is used to fuse the constructed candidate node-relationship chunk set with the prompt word templates corresponding to the three dimensions to generate a full-granularity question-answer pair set.
[0093] The structure-aware graph-driven question and answer generation device described in the embodiment of the present invention can execute the structure-aware graph-driven question and answer generation method provided in the above embodiment. The structure-aware graph-driven question and answer generation device has the corresponding functional steps and beneficial effects of the structure-aware graph-driven question and answer generation method described in the above embodiment. Please refer to the embodiment of the structure-aware graph-driven question and answer generation method for details. The embodiment of the present invention will not be repeated here.
[0094] An embodiment of the present invention further provides an electronic device that may include a processor and a memory, wherein the processor and the memory may be connected via a bus or other means. The processor may be a central processing unit (CPU). The processor may also be another general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of these chips. The memory, as a non-transitory computer-readable storage medium, may be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as the program instructions / modules corresponding to the structure-aware graph-driven question-and-answer generation method in the embodiment of the present invention. The processor executes the non-transitory software programs, instructions, and modules stored in the memory to perform various functional applications and data processing of the processor, thereby implementing the structure-aware graph-driven question-and-answer generation method in the above method embodiment.
[0095] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required by at least one function; the data storage area may store data created by the processor, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. The one or more modules are stored in the memory, and when executed by the processor, the graph-driven question-and-answer generation method based on structure perception in the above-mentioned method embodiment is executed. The specific details of the above-mentioned electronic device can be understood by corresponding to the corresponding descriptions and effects in the above-mentioned method embodiment, and will not be repeated here. Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiment method can be implemented by instructing the relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it may include the processes of the embodiments of the above-mentioned methods. The storage medium may be a read-only memory (ROM), a random access memory (RAM), a flash memory (Flash Memory), a hard disk drive (HDD) or a solid-state drive (SSD); the storage medium may also include a combination of the above types of memory.
[0096] In the description provided herein, numerous specific details are described. However, it is understood that embodiments of the present invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of this description.
[0097] Similarly, it should be understood that in order to streamline the present disclosure and help understand one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, the various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the disclosure herein and practicing the disclosure herein. This application is intended to encompass any variations, uses, or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are intended to be exemplary only, and it should be noted that the above-described embodiments illustrate the present invention rather than limit it, and those skilled in the art can design alternative embodiments without departing from the scope thereof.
Claims
1. A graph-driven question-answering generation method based on structure perception, characterized in that: The structure-aware graph-driven question-answering generation method includes: Performing structural extraction on a structured document to obtain structural information of the structured document, and performing knowledge extraction on the structured document to obtain entities, entity relationships, and event information of the structured document, respectively modeling the structural information and entity relationships of the structured document to obtain a document structure tree and a document knowledge graph, and obtaining a structure-aware fusion graph based on the document structure tree and the document knowledge graph; Performing knowledge traversal on the structure-aware fusion graph, implementing a chunk building strategy based on a structure scoring mechanism and an understanding scoring mechanism, and constructing candidate node-relationship chunk sets in three dimensions: entity level, scenario level, and reasoning level; The knowledge traversal is performed on the structure-aware fusion graph, and a chunk construction strategy is implemented based on the structure scoring mechanism and the understanding scoring mechanism to construct candidate node-relationship chunk sets in three dimensions: entity level, scenario level, and reasoning level. The set includes: When performing knowledge traversal on the structure-aware fusion graph, obtaining entity-level chunks; During edge sampling, chunks are extracted according to the preset scene-level chunk construction strategy and the inference-level chunk construction strategy, and the scores of the edges on the structure-aware fusion graph are calculated based on the structure-semantic collaborative generation algorithm to obtain scene-level chunks and inference-level chunks respectively. Constructing candidate node-relationship chunk sets of three dimensions: entity level, scenario level, and reasoning level based on the extracted entity level chunks, scenario level chunks, and reasoning level chunks; The score of the edge of the structure-aware fusion graph is calculated based on the structure-semantic collaborative generation algorithm by the following formula: ; Where, is the structural similarity score, is the semantic confidence score, is the structural weight hyperparameter, For the edge score; The constructed candidate node-relationship chunk sets are fused with the prompt word templates corresponding to the three dimensions to generate a full-granularity question-answer pair set.
2. The structure-aware graph-driven question-answer generation method according to claim 1 is characterized in that: The step of extracting the structure of the structured document to obtain the structure information of the structured document includes: Performing document preprocessing on the structured document to convert the structured document into a to-be-processed file in a target format; Segmenting the document to be processed into pages using a document image analysis tool to obtain a structured representation of the document pages; After sequentially reorganizing the structured representation of the document page, extracting the text content using OCR technology; Regular expressions and template matching technology are used to identify the title hierarchy and paragraph structure in the text content by matching the set numbering pattern, and the structural information of the structured document is obtained.
3. The structure-aware graph-driven question-answer generation method according to claim 2 is characterized in that: The step of extracting knowledge from the structured document to obtain entities, entity relationships, and event information of the structured document includes: Identify and extract entities in the text content through a large language model; Based on the extracted entities, high-precision entity type classification is performed by matching them with predefined Schema constraints to obtain a standardized unified entity representation for each entity; According to the standardized unified entity representation of all the entities, corresponding entity relationships and event information are extracted from the text content.
4. The structure-aware graph-driven question-answer generation method according to claim 3 is characterized in that: The step of modeling the structure information and entity relationships of the structured document to obtain a document structure tree and a document knowledge graph includes: Modeling the structural information of the structured document, identifying hierarchical nodes based on the structural features of the structural information, and establishing a document structure tree with parent-child relationships to form a tree-like structure; The entity relationships of the structured document are modeled, and based on the extracted entities, entity relationships and event information, each entity and event information is used as a node, and the entity relationship is used as an edge to construct a document knowledge graph in the form of triples.
5. The structure-aware graph-driven question-answer generation method according to claim 1 is characterized in that: The obtaining of a structure-aware fusion graph according to the document structure tree and the document knowledge graph includes: Establish a unique mapping relationship between all nodes of the document structure tree and all nodes of the document knowledge graph; An index match is formed based on the node mapping relationship between the document structure tree and the document knowledge graph to obtain the structure-aware fusion graph.
6. A graph-driven question-answer generation device based on structure perception, applied to the method according to any one of claims 1 to 5, characterized in that: The structure-aware graph-driven question-answer generation device includes: A document processing module is configured to perform structural extraction on a structured document to obtain structural information of the structured document, and to perform knowledge extraction on the structured document to obtain entities, entity relationships, and event information of the structured document, respectively model the structural information and entity relationships of the structured document to obtain a document structure tree and a document knowledge graph, and to obtain a structure-aware fusion graph based on the document structure tree and the document knowledge graph; A chunk building module is used to perform knowledge traversal on the structure-aware fusion graph, implement chunk building strategies based on the structure scoring mechanism and the understanding scoring mechanism, and construct candidate node-relationship chunk sets in three dimensions: entity level, scenario level, and reasoning level; The question-answer pair generation module is used to fuse the constructed candidate node-relationship chunk sets with the prompt word templates corresponding to the three dimensions to generate a full-granularity question-answer pair set.
7. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer program instructions, which are loaded and executed by a processor to implement the operations performed by the method according to any one of claims 1 to 5.
8. An electronic device comprising a processor and a memory, characterized in that: The memory stores computer program instructions that can be executed by the processor, and when the processor executes the computer program instructions, the processor implements the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Geographic scene parameterization three-dimensional modeling method and system driven by large language model, storage medium and program product
CN119445016A
Question and answer pair generation method and system
CN120258146A