A hypergraph-based document question answering method and device
By constructing document hypergraphs and performing multi-level searches in it, the problem of low Q&A quality caused by single search hierarchy is solved, and higher quality and accurate document Q&A is achieved.
Patent Information
- Application Number
- CN202510508674.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-22
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2045-04-22
AI Technical Summary
Existing search enhancement techniques have single search levels in document Q&A, resulting in low quality and accuracy of Q&A.
The document question-and-answer method is adopted based on the hypergraph. By dividing the document into subparagraphs, the entity and entity relationship are extracted to construct the document hypergraph, and the candidate node path is searched in the hypergraph in the order of global hyper edges, local hyper edges, and entity nodes, the search process information is recorded, and the replies are generated using sequence scores and search strategy information.
It improves the quality and accuracy of question-and-answer questions, and can filter out the content related to the question layer by layer in the document super-picture to balance the overall and detailed information.
Smart Images

Figure CN120030103B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of artificial intelligence, and in particular, to a hypergraph-based document question answering method and apparatus. Background Art
[0002] The retrieval enhancement technology is a technical framework that combines information retrieval technology and language models. When the model needs to generate text or answer questions, it can retrieve relevant information from documents and then use the retrieved information to guide the generation of text to reduce model hallucinations and improve the quality and accuracy of the generated content.
[0003] Currently, the existing retrieval enhancement technology mainly divides the text into smaller text blocks and then performs single-level matching on the text blocks using keywords to extract key information for generating answers. This method has a single retrieval level, which easily leads to insufficient similarity and fineness of retrieval results, and thus results in low quality and accuracy of question answering. Summary of the Invention
[0004] Aiming at the above problems, the purpose of the present invention is to provide a hypergraph-based document question answering method and apparatus, which can enrich the retrieval level and improve the quality and accuracy of question answering.
[0005] To solve the above technical problems, the present invention provides the following technical solutions:
[0006] On the one hand, the present invention provides a hypergraph-based document question answering method, including:
[0007] Obtain a document to be processed and a question to be processed;
[0008] Extract entities and entity relationships from each sub-paragraph in the document to be processed to construct a document hypergraph, where the document hypergraph includes entity nodes representing entities, ordinary edges representing entity relationships, local hyperedges representing that entities belong to the same sub-paragraph, and global hyperedges representing similar local hyperedges;
[0009] In the document hypergraph, search for multiple candidate node paths matching the question to be processed in a specified order, and the specified order is the order of global hyperedges, local hyperedges, and entity nodes;
[0010] During the process of searching for the candidate node paths, record the search process information of the candidate node paths, where the search process information includes a search sequence, a sequence score, and search strategy information;
[0011] Use the sequence score and the search strategy information to determine target search process information from the search process information of the candidate node paths;
[0012] Generate a target response corresponding to the problem to be processed based on the target search process information.
[0013] On the other hand, the present invention also provides a hypergraph-based document question-answering device, including:
[0014] An acquisition module, configured to acquire a document to be processed and a question to be processed;
[0015] A construction module, configured to extract entities and entity relationships from each sub-paragraph in the document to be processed to construct a document hypergraph, where the document hypergraph includes entity nodes representing entities, ordinary edges representing entity relationships, local hyperedges representing that entities belong to the same sub-paragraph, and global hyperedges representing similar local hyperedges;
[0016] A search module, configured to search for multiple candidate node paths matching the question to be processed in the document hypergraph in a specified order, where the specified order is the order of global hyperedges, local hyperedges, and entity nodes;
[0017] A recording module, configured to record the search process information of the candidate node paths during the process of searching for the candidate node paths, where the search process information includes a search sequence, a sequence score, and search strategy information;
[0018] A screening module, configured to determine target search process information from the search process information of the candidate node paths by using the sequence score and the search strategy information;
[0019] A response module, configured to generate a target response corresponding to the question to be processed based on the target search process information.
[0020] On the other hand, the present invention also provides an electronic device, including a processor and a memory, where the memory stores multiple instructions; the processor loads instructions from the memory to execute the steps in any one of the hypergraph-based document question-answering methods provided by the present invention.
[0021] On the other hand, the present invention also provides a computer-readable storage medium, where the computer-readable storage medium stores multiple instructions, and the instructions are suitable for being loaded by a processor to execute the steps in any one of the hypergraph-based document question-answering methods provided by the present invention.
[0022] On the other hand, an embodiment of the present invention also provides a computer program product, including computer programs / instructions, where the computer programs / instructions, when executed by a processor, implement the steps in any one of the hypergraph-based document question-answering methods provided by the present invention.
[0023] The beneficial effects brought by the technical solution provided by the present invention at least include:
[0024] In the embodiments of the present invention, after the document to be processed is divided into sub-paragraphs, entity and entity relationship extraction is performed according to the sub-paragraphs, so as to convert the document content into a document hypergraph, and candidate node paths related to the problem to be processed are retrieved in the document hypergraph in a specified order. During the process of searching for candidate node paths, search process information corresponding to the candidate node paths can be obtained; by using the sequence score and search strategy information in the search process information, the target search process information is filtered out, and based on this, the target answer to the problem to be processed is generated. By constructing a hypergraph structure of global hyperedges and local hyperedges, the overall and detailed information can be balanced, and the content related to the problem to be processed can be accurately filtered out through progressive search in the hypergraph, thereby improving the quality and accuracy of question answering. Description of the Drawings
[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings required for the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those skilled in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.
[0026] Figure 1 It is a schematic diagram of an application scenario of the document question answering method based on a hypergraph provided by an embodiment of the present invention;
[0027] Figure 2 It is a schematic flowchart of the document question answering method based on a hypergraph provided by an embodiment of the present invention;
[0028] Figure 3 It is a schematic diagram of constructing a document hypergraph provided by an embodiment of the present invention;
[0029] Figure 4 It is a schematic diagram of searching for candidate node paths in a document hypergraph provided by an embodiment of the present invention;
[0030] Figure 5 It is a schematic diagram of the structure of a document question answering device based on a hypergraph provided by an embodiment of the present invention;
[0031] Figure 6 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Detailed Embodiments
[0032] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts fall within the protection scope of the present invention.
[0033] It is understandable that in the specific embodiments of the present invention, data related to user information and the like need to obtain user permission or consent, and the collection, use, and processing of relevant data need to comply with relevant laws, regulations, and standards of relevant countries and regions.
[0034] See Figure 1 , which shows a schematic diagram of an application scenario of a document question-answering method based on a hypergraph. Among them, the application scenario may include a terminal 101 and a server 102. Data exchange can be carried out between the terminal 101 and the server 102 through a network, and an application program related to question-answering can be installed on the terminal 101. Among them, the terminal 101 can be a mobile phone, a tablet computer, a smart Bluetooth device, a computer, a large screen, etc., a robot, etc.; the server 102 can be a single server or a server cluster composed of multiple servers.
[0035] The user can send the document to be processed and the question to be processed to the server 102 through the terminal 101. Thus, the server 102 can construct a document hypergraph based on the entities and entity relationships extracted from each sub-paragraph in the document to be processed. The document hypergraph may include entity nodes representing entities, ordinary edges representing entity relationships, local hyperedges representing that entities belong to the same sub-paragraph, and global hyperedges representing similar local hyperedges. Then, multiple candidate node paths matching the question to be processed can be searched in the document hypergraph in a specified order, and the specified order is the order of global hyperedges, local hyperedges, and entity nodes; and during the process of searching for the candidate node paths, the search process information of the candidate node paths can be recorded, and the search process information may include a search sequence, a sequence score, and search strategy information; using the sequence score and the search strategy information, the target search process information is determined from the search process information of the candidate node paths; finally, a target answer to the question to be processed is generated based on the target search process information.
[0036] Then, the server 102 can send the generated target answer to the terminal 101 so that the target answer can be displayed to the user through the terminal 101.
[0037] In this embodiment, a document question-answering method based on a hypergraph is provided, as Figure 2 shown, and the specific process of the document question-answering method based on a hypergraph can be as follows:
[0038] S110. Obtain the document to be processed and the question to be processed.
[0039] The problem to be processed refers to the problem that needs to be solved, and this problem to be processed can be provided by the user. The document to be processed is the basis for solving the problem to be processed. That is to say, understanding the content of the document to be processed is required to solve the problem to be processed. The document to be processed can be input by the user when inputting the problem to be processed. Among them, the input form of the document to be processed is diverse. For example, it can be directly uploading the corresponding document file, inputting it in the form of a picture, inputting it in the form of a document link, etc. It can be specifically set according to actual needs and will not be specifically limited here.
[0040] S120. Extract entities and entity relationships from each sub-paragraph in the document to be processed to construct a document hypergraph.
[0041] After obtaining the document to be processed, the document to be processed can be divided into multiple sub-paragraphs. For each sub-paragraph, entities and entity relationships can be extracted from it to construct a document hypergraph corresponding to the document to be processed.
[0042] The constructed document hypergraph can include multiple entity nodes and edges. Among them, entity nodes can be used to represent the specific entities extracted, and one entity corresponds to one entity node. Edges can be used to represent the association relationships between nodes. Specifically, the edges in the document hypergraph can include ordinary edges, local hyper-edges, and global hyper-edges.
[0043] Among them, an ordinary edge is a connecting edge between two entity nodes. The number of entity nodes that a hyper-edge can connect is not limited to 2, and it can be multiple. Among them, the extracted entity relationships can be represented by ordinary edges, while local hyper-edges can connect the entity nodes corresponding to the entities belonging to the same sub-paragraph, and global hyper-edges can connect similar local hyper-edges.
[0044] As an implementation method, when generating a document hypergraph, the document to be processed can be divided into multiple sub-paragraphs; for each of the sub-paragraphs, entities and entity relationships are extracted from the sub-paragraph; using the entities as entity nodes and the entity relationships as ordinary edges between the entity nodes, a basic document graph is constructed; in the basic document graph, local hyper-edges are established for the entity nodes belonging to the same sub-paragraph, and local descriptions corresponding to the local hyper-edges are generated based on the context of the sub-paragraph to obtain an intermediate document graph; in the intermediate document graph, global hyper-edges and global descriptions are generated using all local descriptions to obtain a document hypergraph.
[0045] Please refer to Figure 3, which shows a schematic diagram of constructing a document hypergraph. The document to be processed can be divided into multiple sub-paragraphs. For example, the text in the document to be processed can be directly segmented into sub-paragraphs according to natural paragraphs. To ensure the semantic coherence within the sub-paragraphs and improve the reliability of subsequent entity extraction, the semantic analysis ability of the large model can be utilized to further adjust the content initially divided into text blocks, making the semantics of the sub-paragraphs more compact and the themes more unified.
[0046] Optionally, when dividing the document to be processed into multiple sub-paragraphs, the document to be processed can be segmented into multiple text blocks; for each text block, the text block is spliced with a segmentation template to obtain a segmentation prompt word. The segmentation template is a prompt word template for segmenting text blocks, and the segmentation prompt word includes a segmentation rule and a summary rule; the segmentation prompt word is input into a segmentation model to guide the segmentation model to segment the text block into sub-texts according to the segmentation rule and summarize the sub-texts according to the summary rule to obtain sub-paragraphs.
[0047] The document to be processed is segmented into multiple text blocks, and the segmentation method can be segmentation according to natural paragraphs or segmentation according to a fixed number of characters. Among them, segmentation according to natural paragraphs means using line breaks, blank lines or other custom punctuation marks in the document as the boundaries between paragraphs to divide the text into blocks according to the boundaries. In this way, the internal semantics of each text block are coherent, which is applicable to the case where the structure is clear and the paragraphs are distinct. And segmentation according to a fixed number of characters is for when the document to be processed does not have clear paragraph identifiers, and it can be segmented according to a fixed number of characters or times. In the embodiments of the present invention, at least one of these two segmentation methods can be adopted to segment the document to be processed into multiple text blocks.
[0048] For each text block, the text block can be segmented and reorganized into multiple sub-paragraphs, and the content in each sub-paragraph has a unified theme. Among them, the segmentation template is a prompt word template for segmenting text blocks into sub-paragraphs, and the segmentation template can be set in advance according to actual needs. In the embodiments of the present invention, the segmentation template can be:
[0049] "You are a text processing expert, and your task is to perform semantic analysis on the given text block, and then according to the internal semantic relationship of the content, segment and reorganize the text block into multiple sub-paragraphs so that the content within each sub-paragraph has a unified theme.
[0050] Carefully analyze the given text block, then merge the sentences with similar themes into the same sub-paragraph, and generate a comprehensive and coherent summary description for each sub-paragraph to summarize the sub-paragraph. The final result is returned in JSON format.
[0051] Precautions:
[0052] 1. The key information in the sub-paragraph content needs to be retained in the summary description.
[0053] 2. The summary description needs to be objective and true. Remember not to add knowledge that does not exist in the sub - paragraph.
[0054] 3. The summary description needs to briefly summarize the key entity relationships in the sub - paragraph.
[0055] Output format requirements:
[0056] ```json
[0057] {
[0058] "segments":
[0059] {
[0060] "summary": "",
[0061] "content": ""
[0062] }
[0064] }
[0065] The input text block is as follows: {input_text}”
[0066] Filling the text block into {input_text} can realize splicing the text block and the segmentation template to obtain a segmentation prompt. Based on the foregoing segmentation template, the segmentation prompt may include the segmentation rules and summary rules of the text. Among them, the segmentation rule may be "carefully analyze the given text block, and then merge sentences with similar themes into the same sub - paragraph", and the content in "Precautions" can be regarded as the summary rule. After inputting the segmentation prompt into the segmentation model, it can guide the segmentation model to segment the text block into sub - texts according to the segmentation rules, and summarize the sub - texts according to the summary rules to obtain sub - paragraphs. That is, the sub - paragraph may include sub - texts and the summarized content.
[0067] For each sub - paragraph, entities and entity relationships can be extracted from the sub - paragraph for constructing a document hyper - graph. To accurately extract entities and entity relationships, a combination of a large - language model and prompts can be used for extraction. For example, it can be filling the preset entity types and the sub - paragraph into an extraction template to obtain an extraction prompt. The extraction template includes multiple extraction steps, extraction examples, and output requirements; executing the multiple extraction steps based on the extraction examples to extract entities and entity relationships from the sub - paragraph; organizing the entities and entity relationships according to the output requirements and outputting.
[0068] The preset entity types can be set according to actual needs. The preset entity types refer to the possible types of entities that appear in the sub-paragraphs, and multiple types can be preset in advance. The extraction template is a prompt word template for entity and entity relationship extraction and can also be set according to actual needs. In the embodiments of the present invention, the extraction template can be:
[0069] "You are a text processing expert, and your task is to analyze the given text block and then identify all entities of these types and all relationships between the identified entities in the given text block. Also, for each entity and relationship, summarize a comprehensive description in combination with the context.
[0070] Task process:
[0071] 1. Identify all entities. For each identified entity, extract the following information:
[0072] entity_name: The name of the entity. If it is in English, it needs to be capitalized.
[0073] entity_type: The type of the entity: one of the following types: [{entity_types}]
[0074] entity_description: A comprehensive description of the entity's attributes and related activities.
[0075] Format each entity as:
[0076] ("entity"{tuple_delimiter}<entity_name>{tuple_delimiter}<entity_type>{tuple_delimiter}<entity_description>)
[0077] 2. From the entities determined in step 1, find all pairs of relationships (source_entity, target_entity) that are "clearly related" to each other.
[0078] For each pair of related entities, extract the following information:
[0079] source_entity: The name of the source entity, as determined in step 1.
[0080] target_entity: The name of the target entity determined in step 1.
[0081] relation_description: Explain the reason why you think the source entity and the target entity are related to each other.
[0082] relation_strength: A numerical value indicating the strength of the relationship between the source entity and the target entity
[0083] Format each relationship as:
[0084] ("relationship"{tuple_delimiter}<source_entity> {tuple_delimiter}<target_entity> {tuple_delimiter}<relationship_description> {tuple_delimiter}<relationship_strength> )
[0085] 3. Return the Chinese output, a single list of all entities and relations identified in steps 1 and 2. Use {record_delimiter} as a list separator.
[0086] 4. After completion, output {completion_delimiter}.
[0087] By filling the sub-paragraphs and the preset entity types into the extraction template, an extraction prompt word can be obtained. Based on the content in the aforementioned extraction template, it can be known that the extraction prompt word may include multiple extraction steps, extraction examples, and output requirements. The extraction prompt word is input into the extraction model, and the extraction model can fully understand the extraction steps and output requirements through the extraction examples, and execute multiple extraction steps to extract entities and entity relationships from the sub-paragraphs, and then output according to the output requirements.
[0088] It should be noted that after extracting entities and entity relationships from each sub-paragraph, the entity relationships can be deduplicated first, and similar entities can be merged to reduce redundancy. Then, the extracted entities can be used as entity nodes, and for the two entities in the entity relationship, edges can be established in the corresponding entity nodes as ordinary edges, so that a common graph is obtained, which is subsequently called the basic document graph.
[0089] In order to further enrich the relationships between entities and explore deeper associations between entities, hyperedges can be constructed based on basic documents. Hyperedges refer to edges that can connect any number of edges and can represent more complex relationships.
[0090] In the embodiments of the present invention, in the basic document graph, local hyperedges can be established for entity nodes belonging to the same sub-paragraph, and the local description corresponding to the local hyperedge can be generated with the context of the corresponding sub-paragraph. That is, for each sub-paragraph, all entity nodes in the sub-paragraph can be connected by a hyperedge as the local hyperedge. The context of the sub-paragraph can be understood as the corresponding summary description when obtaining the sub-paragraph, and it is used as the local description corresponding to the local hyperedge to obtain the intermediate document graph.
[0091] Optionally, in the intermediate document graph, the occurrence frequency of each entity node in the local hyperedge can also be recorded, and the weight of the corresponding entity node can be increased for the entity nodes that repeatedly appear in multiple local hyperedges to enhance their importance in the entire document to be processed.
[0092] In the intermediate document graph, global hyperedges and corresponding global descriptions can be constructed based on the local hyperedges to obtain the document hypergraph. Optionally, it can be to perform clustering processing on all the local hyperedges using the local descriptions to obtain multiple clustering clusters; in the intermediate document graph, global hyperedges are established for the local hyperedges belonging to the same clustering cluster; for each global hyperedge, based on the local descriptions of all the local hyperedges in the clustering cluster, the global description corresponding to the global hyperedge is generated to obtain the document hypergraph.
[0093] Local hyperedges are constructed in the aforementioned intermediate document graph, and each local hyperedge has a corresponding local description. For each local description, a mainstream embedding model can be used to convert the local description into a local description vector, and then clustering processing is performed on all the local hyperedges using the local description vector to obtain multiple clustering clusters. For each clustering cluster, a global hyperedge can be established for all the local hyperedges in the clustering cluster, that is, the global hyperedge contains similar local hyperedges.
[0094] Among them, the clustering processing can adopt existing clustering algorithms, such as K-means clustering, HDBSCAN clustering algorithm, etc., which can be specifically set according to actual needs. In the embodiments of the present invention, the HDBSCAN clustering algorithm is used for clustering processing. When performing clustering processing, the minimum number of local hyperedges included in the cluster can be set first, and then the algorithm can automatically determine the number of global hyperedges and the local hyperedges they contain according to the density distribution of the local description vectors.
[0095] After constructing the global hyperedges, it is necessary to generate the global descriptions corresponding to the global hyperedges. As an implementation manner, for each global hyperedge, the local descriptions of all the local hyperedges therein can be obtained, and these local descriptions are used to generate the global description corresponding to the global hyperedge.
[0096] As an implementation, for a global hyperedge, the local descriptions corresponding to all local hyperedges within the global hyperedge can be directly concatenated to obtain a global description.
[0097] As another implementation, a large language model and sample prompts can be used to summarize these local descriptions to obtain the global description corresponding to the global hyperedge. For example, all local descriptions corresponding to local hyperedges included in the global hyperedge can be filled into a description template to generate a description prompt; then the description prompt is input into a description model to generate the corresponding global description. Among them, the description template is a pre-set prompt template for summarizing multiple local descriptions and can be set according to actual needs. In the embodiments of the present invention, the description template can specifically be:
[0098] "You are an experienced text analysis and processing expert, and your task is to summarize the descriptions of all local hyperedges in each global hyperedge to generate a global hyperedge description that accurately reflects the global theme and key information.
[0099] Precautions:
[0100] 1. The output global hyperedge description should cover the key information of all provided local hyperedge descriptions
[0101] 2. It is necessary to take into account both the overall theme direction and specific details
[0102] 3. Specific concepts or terms appearing in the local hyperedge descriptions need to be completely retained
[0103] 4. The language expression should be concise and clear, and the logic should be clear. The final result is output in text form
[0104] The input content format is as follows:
[0106] "Local hyperedge description 1",
[0107] "Local hyperedge description 2", ...
[0110] <example>
[0111] Example 1:
[0112] Local hyperedge description:
[0114] "Project A focuses on technological innovation using solar and wind energy.",
[0115] "Project B emphasizes the role of green energy in promoting economic development."
[0117] Global hyperedge description:
[0118] "This global hyperedge as a whole focuses on green energy technologies and their applications and impacts in economic development."
[0119] Example 2:
[0120] Local hyperedge description:
[0122] "Part of the description discusses strategies for optimizing and allocating educational resources.",
[0123] "Another part focuses on measures to improve teaching quality and students' abilities."
[0125] Global hyperedge description:
[0126] "This global hyperedge centrally reflects the comprehensive strategies for resource optimization and teaching quality improvement in education"
[0127] Actual query:
[0128] Local hyperedge description: [...]
[0129] Global hyperedge description:”
[0130] Filling the local descriptions corresponding to all local hyperedges in the global hyperedge into the description template can obtain a description prompt. Inputting this description prompt into the description model can guide the description model to generate a global description, and then a corresponding document hypergraph can be obtained. Among them, the description model can be a large language model.
[0131] The document hypergraph established in the above manner can include entity nodes, ordinary edges between entity nodes, local hyperedges and corresponding local descriptions, global hyperedges and corresponding global descriptions. Among them, local hyperedges can connect entity nodes belonging to the same sub-paragraph, and local descriptions can be considered as summary descriptions of a single sub-paragraph; global hyperedges can connect entity nodes in similar sub-paragraphs together, which is equivalent to clustering similar sub-paragraphs in the document, and global descriptions are summary descriptions of similar sub-paragraphs.
[0132] S130. In the document hypergraph, search for multiple candidate node paths that match the problem to be processed in the specified order, where the specified order is the order of global hyperedges, local hyperedges, and entity nodes.
[0133] According to the foregoing processing, the document to be processed has been converted into a document hypergraph representation. To answer the problem to be processed, the candidate node paths that match it can be searched in the document hypergraph in the specified order. From the foregoing content, it can be seen that the document hypergraph contains three different levels of edges, and the specified order refers to the order from the largest level to the smallest level. In the embodiments of the present invention, the specified order can be the order of global hyperedges, local hyperedges, and entity nodes.
[0134] Among them, a candidate node path refers to a node path formed by entity nodes related to the problem to be processed in the document hypergraph. Please refer to Figure 4 , which shows a schematic diagram of searching for candidate node paths in the document hypergraph.
[0135] Optionally, when determining the candidate node path, it can be to search for the intermediate entity node corresponding to the problem to be processed in the document hypergraph in the specified order; obtain multiple intermediate node paths corresponding to the intermediate entity node; calculate the path resource value of the intermediate node path according to the node resource value of each entity node in the intermediate node path and the number of nodes in the intermediate node path; and determine the candidate node path from the intermediate node paths based on the path resource value.
[0136] Retrieve in the document hypergraph in the order of global hyperedges, local hyperedges, and entity nodes in turn to retrieve the intermediate entity node corresponding to the problem to be processed, where the intermediate entity node is an entity node related to the problem to be processed. As an implementation manner, it can be to perform a similarity match between the problem to be processed and the global description of the global hyperedge to screen out multiple candidate global hyperedges; in the local hyperedges corresponding to the candidate global hyperedges, perform a similarity match between the problem to be processed and the local description of the local hyperedge to determine multiple candidate local hyperedges; for each entity node in the candidate local hyperedges, perform a similarity match between the problem to be processed and the entity node to determine multiple intermediate entity nodes.
[0137] As another implementation, in order to perform more precise and detailed matching, when determining the intermediate entity node, global keywords and local keywords can be extracted from the problem to be processed; calculate the global matching degree between the global keywords and each global hyperedge to determine the candidate global hyperedges; for each candidate global hyperedge, calculate the local matching degree between the local keywords and each local hyperedge in the candidate global hyperedge to determine the candidate local hyperedges; for each candidate local hyperedge, calculate the entity matching degree between the local keywords and each entity node in the candidate local hyperedge to determine the intermediate entity node.
[0138] Global keywords refer to the words that represent the main subjects and directions of the problem in the problem to be processed, usually being conceptual, thematic, and generalized intention keywords. Local keywords refer to the words that represent specific details and specific information in the problem to be processed, usually being specific entities, detail information, or specific terms. These two levels of keywords can be extracted from the problem to be processed, so as to utilize the extracted global keywords and local keywords to search in the document hypergraph subsequently.
[0139] Among them, the extraction of global keywords and local keywords can rely on a large language model, that is, a prompt template used for keyword extraction is pre-constructed and denoted as a preset template. Fill the problem to be processed into the preset template, and the corresponding prompt can be obtained. Then input the prompt into the large language model so that the large language model can analyze and process the problem to be processed and extract the global keywords and local keywords.
[0140] Among them, the preset template can be set according to the actual situation. In the embodiments of the present invention, the preset template can be as follows:
[0141] "You are an expert in text analysis and processing, and your task is to identify the global keywords and local keywords in the user's query.
[0142] For the given query, list the global and local keywords. Global keywords focus on the overall concept or theme, while local keywords focus on specific entities, details, or specific terms.
[0143] Precautions:
[0144] 1. Please output the keywords in JSON format.
[0145] 2. The JSON should contain two keys:
[0146] "high_level_keywords": for the overall concept or theme.
[0147] "low_level_keywords": for specific entities or details.
[0148] 3. For each keyword, a confidence level from 0 to 1 needs to be given to indicate the credibility of the keyword match.
[0149] <example>
[0150] Example 1:
[0151] Query: "How to promote economic development using green energy?"
[0152] Output:
[0153] {
[0154] "high_level_keywords":
[0155] {"keyword": "green energy", "confidence": 0.95},
[0156] {"keyword": "economic development", "confidence": 0.90},
[0157] {"keyword": "sustainable development", "confidence": 0.85}
[0158] ,
[0159] "low_level_keywords":
[0160] {"keyword": "solar energy", "confidence": 0.80},
[0161] {"keyword": "wind energy", "confidence": 0.80},
[0162] {"keyword": "incentive", "confidence": 0.75},
[0163] {"keyword": "investment cost", "confidence": 0.70}
[0165] }
[0166] Example 2:
[0167] Query: "What is the application prospect of artificial intelligence in the field of medical and health?"
[0168] Output:
[0169] {
[0170] "high_level_keywords":
[0171] {"keyword": "Artificial Intelligence", "confidence": 0.95},
[0172] {"keyword": "Medical and Health", "confidence": 0.90},
[0173] {"keyword": "Application Prospect", "confidence": 0.85}
[0174] ,
[0175] "low_level_keywords":
[0176] {"keyword": "Diagnosis Assistance", "confidence": 0.80},
[0177] {"keyword": "Personalized Medicine", "confidence": 0.80},
[0178] {"keyword": "Data Analysis", "confidence": 0.75},
[0179] {"keyword": "Medical Imaging", "confidence": 0.70}
[0181] }
[0182] Actual Query:
[0183] Query: {query}
[0184] Output:”
[0185] In this way, the global keywords and local keywords can be extracted according to the problem to be processed, and both the extracted global keywords and local keywords have their corresponding confidence levels.
[0186] Among them, there are multiple global hyperedges, and there may also be multiple extracted global keywords, which can form a global keyword set. For each global hyperedge, the global matching degree of the global hyperedge can be calculated using all global keywords and the global description of the global hyperedge; the candidate global hyperedges can be determined from the global hyperedges using the global matching degree. Optionally, when calculating the global matching degree of each global hyperedge using all global keywords and the global description of the global hyperedge, for each global keyword, the cosine similarity between the global description of the global hyperedge and the global keyword can be calculated; the cosine similarity is multiplied by the confidence of the global keyword to obtain an intermediate global matching degree; the intermediate global matching degrees corresponding to each global keyword are summed to obtain the global matching degree of the global hyperedge.
[0187] Among them, the global keyword and the global description can be converted into a global keyword vector and a global description vector through an embedding model, and then the cosine similarity between the two can be calculated.
[0188] Optionally, the global matching degree of a global hyperedge can be calculated by the following formula:
[0189] ;
[0190] Among them, S global (e global ) represents the global matching degree corresponding to a global hyperedge; K High represents the global keyword set; represents the confidence of the global keyword H; sim(H, e global ) represents the cosine similarity between the global keyword H and the global description.
[0191] After calculating the global matching degree corresponding to each global hyperedge in this way, the global hyperedges can be sorted in descending order of the global matching degree, and then the top n1 global hyperedges with the highest ranking can be determined as candidate global hyperedges. Where n1 is a positive integer and can be set according to actual needs.
[0192] Similarly, a candidate global hyperedge may include multiple local hyperedges, and there may also be multiple extracted local keywords, which can form a set of local keywords. For each local hyperedge in each candidate global hyperedge, the local matching degree of the local hyperedge can be calculated using all the local keywords and the local description of the local hyperedge; the candidate local hyperedges can be determined from the local hyperedges using the local matching degree. Optionally, when calculating the global matching degree of the global hyperedge for each local hyperedge in the candidate global hyperedge using all the local keywords and the local description of the local hyperedge, for each local keyword, the cosine similarity between the local description of the local hyperedge and the local keyword can be calculated; the cosine similarity is multiplied by the confidence of the local keyword to obtain an intermediate local matching degree; the intermediate local matching degrees corresponding to each local keyword are summed to obtain the local matching degree of the local hyperedge.
[0193] Among them, the local keywords and the local description can be converted into local keyword vectors and local description vectors through an embedding model, and then the cosine similarity between the two can be calculated.
[0194] Optionally, the local matching degree of a local hyperedge can be calculated by the following formula:
[0195] ;
[0196] Among them, S local (e local ) represents the local matching degree corresponding to a local hyperedge; represents the set of local keywords; represents the confidence of the local keyword L; sim(L, e local ) represents the cosine similarity between the local keyword L and the local description.
[0197] After calculating the local matching degree corresponding to each local hyperedge in this way, the local hyperedges in the candidate global hyperedges can be sorted in descending order of the local matching degree, and then the top n2 local hyperedges with the highest ranking can be determined as the candidate local hyperedges. Where n2 is a positive integer and can be set according to actual needs.
[0198] A candidate local hyperedge may include multiple entity nodes. For each entity node in each candidate local hyperedge, the entity matching degree of the entity node can be calculated using all the local keywords and the entity node; the intermediate entity nodes can be determined from the entity nodes using the entity matching degree. Optionally, when calculating the entity matching degree, for each local keyword, the cosine similarity between the entity node and the local keyword can be calculated; the cosine similarity is multiplied by the confidence of the local keyword to obtain an intermediate entity matching degree; the intermediate entity matching degrees corresponding to each local keyword are summed to obtain the entity matching degree of the entity node.
[0199] Among them, the local keywords and entity nodes can be converted into local keyword vectors and entity vectors through an embedding model, and then the cosine similarity between the two can be calculated.
[0200] Optionally, the entity matching degree of an entity node can be calculated by the following formula:
[0201] ;
[0202] where S entity (ent) represents the entity matching degree corresponding to an entity node; represents the set of local keywords; represents the confidence of the local keyword L; sim(L, ent) represents the cosine similarity between the local keyword L and the entity node.
[0203] In this way, the entity matching degree corresponding to each entity node in the candidate local hyperedge can be calculated, and then the entity matching degree can be compared with the entity threshold, and the entity node with the entity matching degree greater than the entity threshold is determined as the intermediate entity node. Among them, the entity threshold can be set according to actual needs and is not specifically limited here. In the embodiments of the present invention, the entity threshold can be set to 0.6. It can be seen that the intermediate entity node is an entity node related to the query to be processed searched in a specified order, and the candidate node path can be determined based on the intermediate entity node subsequently.
[0204] After calculating the intermediate entity node, multiple intermediate node paths can be determined from the document hypergraph based on the intermediate entity. Among them, the intermediate entity nodes can be combined in pairs to obtain multiple entity pairs; for each entity pair, all node paths connecting the entity pair are obtained to get multiple intermediate node paths. An entity pair contains two intermediate entity nodes, one can be denoted as the starting node ent start , and the other can be denoted as the ending node ent end . Between the starting node and the ending node, there may be multiple paths connecting the starting node and the ending node, and the paths existing in all node pairs can be used as the intermediate node paths.
[0205] These intermediate node paths are pruned to extract the key paths related to the problem to be processed. Among them, the path resource value of the intermediate node path can be calculated according to the node resource values of each entity node in the intermediate path and the number of nodes in the intermediate node path; then the candidate node path is determined from the intermediate node paths based on the path resource value, and the candidate node path is the extracted key path.
[0206] That is, first calculate the path resource value corresponding to each intermediate node path. The calculation of the path resource value refers to the following steps: For each of the intermediate node paths, set an initial resource value for the entity nodes in the intermediate node path, and obtain the in-nodes and out-nodes of the entity nodes; For each entity node in the intermediate node path, calculate the node resource value corresponding to the entity node based on the propagation of the initial resource value on the in-nodes and out-nodes; Divide the sum of the node resource values of all entity nodes in the intermediate node path by the number of entity nodes in the intermediate node path to obtain the path resource value of the intermediate node path.
[0207] According to the foregoing, an intermediate node path refers to a node path composed of a start node to an end node. For each node in the intermediate node path, an initial resource value can be set for it to facilitate the subsequent calculation of the node resource value. Among them, the initial resource value of the start node can be set to a first value, and the initial resource values of the other nodes in the intermediate node path except the start node can be set to a second value. Among them, the first value can be set to 1, and the second value can be set to 0, which can be specifically adjusted according to actual needs. The resource value of each entity node will be propagated to the surrounding nodes through the entity relationship network, and the surrounding nodes closer to the entity node can obtain a higher resource value.
[0208] For each entity node in the intermediate node path, there is a corresponding in-node and out-node. If an entity node is called the central node, there are multiple entity nodes pointing to the central node, and these nodes are the in-nodes. At the same time, the central node may also point to multiple other entity nodes, and these nodes are the out-nodes. The in-nodes and out-nodes can be obtained by analyzing the document hypergraph.
[0209] Thus, for each entity node in the intermediate node path, its node resource value can be calculated according to the following formula:
[0210] ;
[0211] Among them, S(ent i ) represents the node resource value of the entity node; represents the set of all nodes pointing to the entity node, that is, the in-nodes; represents the set of all entity nodes pointed to by the entity node, that is, the out-nodes; represents the number of nodes pointed to by the entity node; θ represents the attenuation rate during resource propagation.
[0212] Among them, Stop resource transfer when it is less than the specified threshold, and the specified threshold can be set according to actual needs. In the embodiments of the present invention, it can be set to 0.1. That is, when the average resources of an entity node are less than the specified threshold, no resources will be transferred to its neighbor nodes.
[0213] After calculating the node resource values of each entity node in the intermediate node path, the node resource values of all entity nodes in the intermediate node path can be added up and then divided by the number of entity nodes in the intermediate node path to obtain the path resource value corresponding to the intermediate node path.
[0214] Specifically, the path resource value of the intermediate node path can be calculated according to the following formula:
[0215] ;
[0216] where score path represents the path resource value of the intermediate node path; S(ent i ) represents the node resource value of the entity node in the intermediate node path; R path represents the intermediate node path; │R path │ represents the number of entity nodes in the intermediate node path.
[0217] After calculating the path resource value of each intermediate node path, multiple candidate node paths can be selected therefrom according to the path resource value. For example, multiple intermediate node paths can be sorted in descending order according to the path resource value, and the first n3 intermediate node paths with higher rankings can be used as candidate node paths. Where n3 is a positive integer and can be set according to actual needs.
[0218] S140. During the process of searching the candidate node paths, record the search process information of the candidate node paths.
[0219] During the process of searching for the candidate node paths by using the problem to be processed in the document hypergraph in the order of global hyperedges, local hyperedges, and entity nodes, a series of search process information can be generated. This search process information can include search sequences, sequence scores, and search strategy information.
[0220] Among them, the search sequence is the search path when searching in the document hypergraph in the specified order. If the global hyperedges, local hyperedges, and entity nodes are regarded as different levels, it records the content selected at each level. The sequence score is the score corresponding to the search sequence, which can be obtained from the matching degrees calculated at each level and the path resource value corresponding to the candidate node path. The search strategy information is the content selected at each level and the content that has been discarded recorded during the search process, which can be used for backtracking.
[0221] Optionally, during the process of searching for candidate node paths, when recording the search process information of the candidate node paths, the global hyperedges, local hyperedges, and intermediate entity nodes corresponding to the candidate node paths can be combined to obtain a search sequence; according to the specified weights, based on the search process, the global matching degree corresponding to the global hyperedges, the local matching degree corresponding to the local hyperedges, and the path resource value corresponding to the candidate node paths are superimposed to obtain a sequence score; the selection information during the search process is obtained to obtain search strategy information.
[0222] When searching for candidate node paths as described above, the search is performed in the hierarchical order of global hyperedges, local hyperedges, and entity nodes. By calculating the global matching degree between the global keywords and the global description in the problem to be processed, candidate global hyperedges can be screened out. There are multiple candidate global hyperedges, and one candidate global hyperedge needs to be selected from them during the search, and the search continues in the local hyperedges of the selected candidate global hyperedge.
[0223] The candidate global hyperedge selected at this time can be denoted as the global hyperedge , which can be used as one content in the search sequence, and at the same time, its corresponding sequence score can be obtained. The sequence score at this time is the product of the global matching degree corresponding to this global hyperedge and the global factor. Specifically, the search sequence at this time can be expressed as , and the sequence score is , where is the global factor, and S global (e i ) is the global matching degree of the global hyperedge .
[0224] Since this global hyperedge contains multiple local hyperedges, the local matching degree can continue to be calculated using the local keywords in the problem to be processed and the local descriptions of these local hyperedges to screen out candidate local hyperedges. There are multiple candidate local hyperedges, and one candidate local hyperedge needs to be selected from them, and the search continues in the entity nodes of the selected candidate local hyperedge.
[0225] The candidate local hyperedge selected at this time can be denoted as the local hyperedge , which can be added to the search sequence, and at the same time, the corresponding sequence score can be updated. The sequence score at this time is the previous score plus the product of the local matching degree corresponding to this local hyperedge and the local factor. Specifically, the search sequence at this time can be expressed as , and the sequence score is , where is the local factor, and S local (e ij ) is the local matching degree of the local hyperedge .
[0226] Since this local hyperedge contains multiple entity nodes, the entity matching degree can be continuously calculated using the local keywords in the problem to be processed and these entity nodes to filter out intermediate entity nodes. The intermediate entity node can be denoted as . As previously stated, the intermediate node path will be determined from the intermediate entity nodes, and the path resource value of the intermediate node path will be calculated to filter out candidate node paths. At this time, the search sequence can be updated using the intermediate entity node, and the sequence score can be updated with the product of the path resource value of the candidate node path determined by this intermediate entity node and the path factor.
[0227] Specifically, the search sequence at this time can be expressed as , and the sequence score is , where is the path factor, and score is the path resource value of the candidate node path. Then, all the entity nodes on the candidate node path corresponding to the maximum score can be denoted as E P , and added to the search process information.
[0228] Among them, when calculating the sequence score, a global factor , a local factor , and a path factor are introduced. These factors can all be set according to actual needs. By adjusting the global factor , the local factor , and the path factor , the final result can be biased towards the overall summary or specific entity description. In the embodiments of the present invention, each factor can be set as: .
[0229] During the aforementioned search process, the current selection and the discarded selections can be recorded each time, which can be used to backtrack the search process. The content of this record can be called search strategy information. In summary, the search process information can include the sequence score S P , the search sequence P, the search strategy information B P , and the matched entity nodes E P .
[0230] Thus, while searching for candidate node paths in the document hypergraph, the search process information corresponding to the candidate node paths can be obtained through the above method.
[0231] S150. Use the sequence score and the search strategy information to determine target search process information from the search process information of the candidate node paths.
[0232] Using the sequence scores and search strategy information in the search process information, the target search process information can be determined from the search process information of the candidate node paths, which is used to generate the target response to the problem to be processed subsequently.
[0233] As an implementation manner, when determining the target search process information, it can be based on the search strategy information to determine similar information pairs from the search process information of the candidate node paths; replace the similar information pairs with the search process information having the highest sequence score in the similar information pairs to obtain intermediate search process information; and determine the target search process information from the intermediate search process information according to the sequence scores in the intermediate search process information.
[0234] Obtain the search process information corresponding to each candidate node path; combine the search process information in pairs to obtain multiple information pairs; for each information pair, calculate the similarity between the two search process information in the information pair; and determine the information pairs with similarity greater than the specified similarity as the similarity information pairs. Among them, the specified similarity can be set according to actual needs and is not specifically limited here. In the embodiments of the present invention, the specified similarity can be set to 0.8.
[0235] Among them, the similarity can refer to the jaccard similarity, and can be specifically calculated according to the following formula:
[0236] ;
[0237] Among them, S Jaccard (B P1 , B P2 ) represents the similarity of an information pair; B P1 represents one search process information in the information pair; B P2 represents the other search process information in the information pair.
[0238] For the similar information pairs, the sequence scores of the two search process information can be obtained, and the search process information with the highest sequence score between the two is used to replace the similar information pair. In other words, the search process information with the lowest sequence score between the two is deleted, and only the one with the higher sequence score is retained.
[0239] Then, the above steps of combining information pairs and calculating the similarity of information pairs can be continuously executed on the remaining search process information until the similarity of all information pairs is not greater than the specified similarity to obtain the intermediate search process information.
[0240] For the intermediate search process information, the sequence scores of each intermediate search process information can be obtained, and the intermediate search process information with the highest sequence score is used as the target search process information.
[0241] S160. Generate a target response corresponding to the problem to be processed based on the target search process information.
[0242] Based on the target search process information, the search sequence contained therein can be obtained. For the search sequence, the global hyperedges and local hyperedges are recorded. Based on the document hypergraph, the global descriptions corresponding to the global hyperedges in the search sequence and the local descriptions corresponding to the local hyperedges can be obtained. The foregoing shows that the search process information also records all the entity nodes in the corresponding candidate node path, and the descriptions corresponding to the entity relationships between these entity nodes can be obtained based on the document hypergraph. After splicing the above information with the problem to be processed, the corresponding target prompt word can be obtained. The target prompt word is input into the large language model, and the large language model combines this information to generate and output the target response corresponding to the problem to be processed.
[0243] The hypergraph-based document question-answering solution provided by the embodiments of the present invention can be applied to various scenarios of using documents for question answering. For example, taking the document question-answering scenario as an example, by establishing a hypergraph, the relationships of document content at multiple levels can be mined. When answering the problem to be processed, search in the hypergraph according to the level to obtain the corresponding search results, and then use the search results to generate an answer to improve the accuracy of the answer.
[0244] Through the method provided by the embodiments of the present invention, the text blocks can be semantically reorganized into sub-paragraphs with a unified main body by using a language model, and then entities and entity relationships are extracted from the sub-paragraphs to construct a document hypergraph including entity nodes, local hyperedges, and global hyperedges. During the search, global keywords and local keywords are extracted from the problem to be processed for precise matching at different levels, realizing progressive retrieval layer by layer, which can take into account both the whole and the details, ensure the accuracy of the retrieval results, and thus improve the quality and accuracy of the question answering.
[0245] To better implement the above method, the embodiments of the present invention also provide a hypergraph-based document question-answering device. The hypergraph-based document question-answering device can be specifically integrated in an electronic device, and the electronic device can be a terminal, a server, or other devices. Among them, the terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop computer, a personal computer, or other devices; the server can be a single server or a server cluster composed of multiple servers.
[0246] For example, in this embodiment, taking the hypergraph-based document question-answering device specifically integrated in the server as an example, the method of the embodiments of the present invention will be described in detail.
[0247] For example, as Figure 5 shown, the hypergraph-based document question-answering device 200 may include:
[0248] An acquisition module 210, configured to acquire a document to be processed and a problem to be processed;
[0249] A building block 220 is configured to extract entities and entity relationships from each sub-paragraph in the to-be-processed document to construct a document hypergraph, where the document hypergraph includes entity nodes representing entities, ordinary edges representing entity relationships, local hyperedges representing entities belonging to the same sub-paragraph, and global hyperedges representing similar local hyperedges;
[0250] A search module 230 is configured to search for multiple candidate node paths matching the to-be-processed problem in the document hypergraph in a specified order, where the specified order is the order of global hyperedges, local hyperedges, and entity nodes;
[0251] A recording module 240 is configured to record information on the search process of the candidate node paths during the search for the candidate node paths, where the search process information includes a search sequence, a sequence score, and search strategy information;
[0252] A screening module 250 is configured to determine target search process information from the search process information of the candidate node paths by using the sequence score and the search strategy information;
[0253] A reply module 260 is configured to generate a target reply corresponding to the to-be-processed problem based on the target search process information.
[0254] In some embodiments, the building block 220 is specifically configured to:
[0255] Divide the to-be-processed document into multiple sub-paragraphs;
[0256] For each of the sub-paragraphs, extract entities and entity relationships from the sub-paragraph;
[0257] Construct a basic document graph with the entities as entity nodes and the entity relationships as ordinary edges between the entity nodes;
[0258] In the basic document graph, establish local hyperedges for entity nodes belonging to the same sub-paragraph, and generate local descriptions corresponding to the local hyperedges based on the context of the sub-paragraph to obtain an intermediate document graph;
[0259] In the intermediate document graph, generate global hyperedges and global descriptions by using all the local descriptions to obtain a document hypergraph.
[0260] In some embodiments, the building block 220 is specifically configured to:
[0261] Cut the to-be-processed document into multiple text blocks;
[0262] For each text block, splice the text block with a segmentation template to obtain a segmentation prompt word. The segmentation template is a prompt word template for segmenting text blocks, and the segmentation prompt word includes a segmentation rule and a summarization rule;
[0263] Input the segmentation prompt word into a segmentation model, and guide the segmentation model to segment the text block into sub-texts according to the segmentation rule, and summarize the sub-texts according to the summarization rule to obtain sub-paragraphs.
[0264] In some embodiments, the construction module 220 is specifically configured to:
[0265] Use the local description to perform clustering processing on all the local hyperedges to obtain multiple clustering clusters;
[0266] In the intermediate document graph, establish global hyperedges for the local hyperedges belonging to the same clustering cluster;
[0267] For each global hyperedge, generate a global description corresponding to the global hyperedge based on the local descriptions of all the local hyperedges in the clustering cluster to obtain a document hypergraph.
[0268] In some embodiments, the search module 230 is specifically configured to:
[0269] Search for intermediate entity nodes corresponding to the problem to be processed in the document hypergraph in a specified order;
[0270] Obtain multiple intermediate node paths corresponding to the intermediate entity nodes;
[0271] Calculate the path resource value of the intermediate node path according to the node resource values of the entity nodes in the intermediate node path and the number of nodes in the intermediate node path;
[0272] Determine candidate node paths from the intermediate node paths based on the path resource values.
[0273] In some embodiments, the search module 230 is specifically configured to:
[0274] Extract global keywords and local keywords from the problem to be processed;
[0275] Calculate the global matching degree between the global keywords and each global hyperedge to determine candidate global hyperedges;
[0276] For each candidate global hyperedge, calculate the local matching degree between the local keywords and each local hyperedge in the candidate global hyperedge to determine candidate local hyperedges;
[0277] For each candidate local hyperedge, calculate the entity matching degree between the local keyword and each entity node in the candidate local hyperedge to determine intermediate entity nodes.
[0278] In some embodiments, the search module 230 is specifically configured to:
[0279] For each of the intermediate node paths, set an initial resource value for the entity nodes in the intermediate node path, and obtain the inflow nodes and outflow nodes of the entity nodes;
[0280] For each entity node in the intermediate node path, calculate the node resource value corresponding to the entity node based on the propagation of the initial resource value on the inflow nodes and outflow nodes;
[0281] Divide the sum of the node resource values of all entity nodes in the intermediate node path by the number of entity nodes in the intermediate node path to obtain the path resource value of the intermediate node path.
[0282] In some embodiments, the recording module 240 is specifically configured to:
[0283] Combine the global hyperedge, local hyperedge, and intermediate entity nodes corresponding to the candidate node path to obtain a search sequence;
[0284] According to the specified weight and based on the search process, superimpose the global matching degree corresponding to the global hyperedge, the local matching degree corresponding to the local hyperedge, and the path resource value corresponding to the candidate node path to obtain a sequence score;
[0285] Obtain the selection information in the search process to obtain search strategy information.
[0286] In some embodiments, the screening module 250 is specifically configured to:
[0287] Based on the search strategy information, determine similar information pairs from the search process information of the candidate node path;
[0288] Replace the similar information pairs with the search process information with the highest sequence score in the similar information pairs to obtain intermediate search process information;
[0289] According to the sequence score in the intermediate search process information, determine target search process information from the intermediate search process information.
[0290] In specific implementation, each of the above modules can be implemented as an independent entity, or can be combined arbitrarily to be implemented as the same or several entities. For the specific implementation of each of the above modules, reference can be made to the foregoing method embodiments, which will not be elaborated herein.
[0291] As described above, the hypergraph-based document question answering device according to this embodiment can divide the document to be processed into sub-paragraphs and then extract entities and entity relationships, so as to convert the document content into a document hypergraph, and retrieve candidate node paths related to the question to be processed in the document hypergraph in a specified order. During the process of searching for candidate node paths, search process information corresponding to the candidate node paths can be obtained; using the sequence scores and search strategy information in the search process information, target search process information is filtered out, and based on this, a target answer to the question to be processed is generated. By constructing a hypergraph structure with global hyperedges and local hyperedges, advancing layer by layer, the overall and detailed information can be balanced. Searching layer by layer in the hypergraph can ensure that content related to the question to be processed is filtered out, thereby improving the quality and accuracy of the answer.
[0292] An embodiment of the present invention further provides an electronic device, which can be a device such as a terminal or a server. Among them, the terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop computer, a personal computer, and so on; the server can be a single server or a server cluster composed of multiple servers, and so on.
[0293] In some embodiments, the hypergraph-based document question answering device can also be integrated in multiple electronic devices. For example, the hypergraph-based document question answering device can be integrated in multiple servers, and the hypergraph-based question answering method of the present invention can be implemented by multiple servers.
[0294] In this embodiment, the electronic device in this embodiment being a server will be described in detail as an example. For example, as Figure 6 shown, it shows a schematic structural diagram of the electronic device involved in the embodiment of the present invention. Specifically:
[0295] The electronic device may include a processor 310 with one or more processing cores, a memory 320 with one or more computer-readable storage media, a power supply 330, an input module 340, and a communication module 350 and other components. Those skilled in the art can understand that Figure 6 the structural diagram of the electronic device shown in does not constitute a limitation on the electronic device, and it may include more or fewer components than shown, or combine certain components, or have different component arrangements. Among them:
[0296] The processor 310 is the control center of the electronic device, connecting various parts of the entire electronic device through various interfaces and circuits. By running or executing software programs and / or modules stored in the memory 320, and by calling the data stored in the memory 320, it performs various functions of the electronic device and processes data. In some embodiments, the processor 310 may include one or more processing cores; in some embodiments, the processor 310 may integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interface, application programs, etc., and the modem processor mainly processes wireless communications. It can be understood that the above-mentioned modem processor may not be integrated into the processor 310 either.
[0297] The memory 320 can be used to store software programs and modules. The processor 310 executes various functional applications and data processing by running the software programs and modules stored in the memory 320. The memory 320 mainly includes a program storage area and a data storage area. Among them, the program storage area can store the operating system, application programs required for at least one function (such as the sound playback function, image playback function, etc.); the data storage area can store the data created according to the use of the electronic device. In addition, the memory 320 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage devices. Correspondingly, the memory 320 may also include a memory controller to provide the processor 310 with access to the memory 320.
[0298] The electronic device also includes a power supply 330 that powers each component. In some embodiments, the power supply 330 can be logically connected to the processor 310 through a power management system, so as to implement functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 330 may also include any components such as one or more DC or AC power supplies, a recharge system, a power failure detection circuit, a power converter or inverter, and a power status indicator.
[0299] The electronic device may also include an input module 340, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.
[0300] The electronic device may also include a communication module 350. In some embodiments, the communication module 350 may include a wireless module. The electronic device can perform short-range wireless transmission through the wireless module of the communication module 350, thereby providing users with wireless broadband Internet access. For example, the communication module 350 can be used to help users send and receive emails, browse web pages, and access streaming media, etc.
[0301] Although not shown, the electronic device may further include a display unit and the like, which will not be elaborated herein. Specifically, in this embodiment, the processor 310 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 320 according to the following instructions, and the processor 310 will run the application programs stored in the memory 320, thereby implementing the steps in the methods of the embodiments of the present invention.
[0302] For the specific implementation of each of the above operations, reference may be made to the previous embodiments, which will not be elaborated herein.
[0303] As can be seen from the above, the electronic device provided by the embodiment of the present invention can divide the document to be processed into sub-paragraphs, extract entities and entity relationships according to the sub-paragraphs, so as to convert the document content into a document hypergraph, and retrieve the candidate node paths related to the problem to be processed in the document hypergraph in a specified order. During the process of searching for candidate node paths, the search process information corresponding to the candidate node paths can be obtained; using the sequence score and search strategy information in the search process information, the target search process information is filtered out, and based on this, the target answer to the problem to be processed is generated. By constructing the hypergraph structure of global hyperedges and local hyperedges, the overall and detailed information can be balanced, and the content related to the problem to be processed can be accurately filtered out through progressive search in the hypergraph, thereby improving the quality and accuracy of question answering.
[0304] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions, or by instructions controlling related hardware. The instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0305] Therefore, the embodiment of the present invention provides a computer-readable storage medium, in which multiple instructions are stored, and the instructions can be loaded by a processor to execute the steps in any one of the hypergraph-based document question answering methods provided by the embodiments of the present invention.
[0306] Among them, the storage medium may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc.
[0307] According to one aspect of the present invention, there is provided a computer program product or a computer program, which includes computer programs / instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer programs / instructions from the computer-readable storage medium, and the processor executes the computer programs / instructions, so that the electronic device executes the methods provided in various alternative implementations of the hypergraph construction aspect or the hypergraph-based document question answering aspect provided in the above embodiments.
[0308] Since the instructions stored in the storage medium can execute the steps in any of the hypergraph-based document question answering methods provided in the embodiments of the present invention, the beneficial effects achievable by any of the hypergraph-based document question answering methods provided in the embodiments of the present invention can be realized. For details, see the previous embodiments and will not be repeated here.
[0309] The above has introduced in detail a hypergraph-based document question answering method and apparatus provided by an embodiment of the present invention. Specific examples are used herein to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention; at the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present invention.< / example> < / example>
Claims
1. A hypergraph-based document question answering method, characterized in that The method includes: Obtaining a document to be processed and a problem to be processed; Extracting entities and entity relationships from each sub-paragraph in the document to be processed to construct a document hypergraph, where the document hypergraph includes entity nodes representing entities, ordinary edges representing entity relationships, local hyperedges representing that entities belong to the same sub-paragraph, and global hyperedges representing similar local hyperedges; In the document hypergraph, searching for multiple candidate node paths matching the problem to be processed in a specified order, where the specified order is the order of global hyperedges, local hyperedges, and entity nodes; During the process of searching for the candidate node paths, recording the search process information of the candidate node paths, where the search process information includes a search sequence, a sequence score, and search strategy information; Using the sequence score and the search strategy information, determining target search process information from the search process information of the candidate node paths; Generating a target response corresponding to the problem to be processed based on the target search process information; Among them, extracting entities and entity relationships from each sub-paragraph in the document to be processed to construct a document hypergraph includes: dividing the document to be processed into multiple sub-paragraphs; for each sub-paragraph, extracting entities and entity relationships from the sub-paragraph; using the entities as entity nodes and the entity relationships as ordinary edges between the entity nodes to construct a basic document graph; in the basic document graph, establishing local hyperedges for entity nodes belonging to the same sub-paragraph, and generating a local description corresponding to the local hyperedges with the context of the sub-paragraph to obtain an intermediate document graph; using the local descriptions to perform clustering processing on all the local hyperedges to obtain multiple clustering clusters; in the intermediate document graph, establishing global hyperedges for local hyperedges belonging to the same clustering cluster; for each global hyperedge, generating a global description corresponding to the global hyperedge based on the local descriptions of all the local hyperedges in the clustering cluster to obtain a document hypergraph.
2. The method according to claim 1, characterized in that, The dividing the document to be processed into multiple sub-paragraphs includes: Segmenting the document to be processed into multiple text blocks; For each text block, splicing the text block with a segmentation template to obtain a segmentation prompt word, where the segmentation template is a prompt word template for segmenting text blocks, and the segmentation prompt word includes a segmentation rule and a summary rule; Inputting the segmentation prompt word into a segmentation model, guiding the segmentation model to segment the text block into sub-texts according to the segmentation rule and summarize the sub-texts according to the summary rule to obtain sub-paragraphs.
3. The method according to claim 1, characterized in that, The searching for multiple candidate node paths matching the problem to be processed in the document hypergraph in a specified order includes: Searching for intermediate entity nodes corresponding to the problem to be processed from the document hypergraph in a specified order; Obtaining multiple intermediate node paths corresponding to the intermediate entity nodes; Calculating the path resource value of the intermediate node path according to the node resource value of each entity node in the intermediate node path and the number of nodes in the intermediate node path; Determining candidate node paths from the intermediate node paths with the path resource value.
4. The method according to claim 3, wherein Searching for the intermediate entity nodes corresponding to the problem to be processed from the document hypergraph in the specified order includes: Extracting global keywords and local keywords from the problem to be processed; Calculating the global matching degree between the global keywords and each global hyperedge to determine candidate global hyperedges; For each candidate global hyperedge, calculating the local matching degree between the local keywords and each local hyperedge in the candidate global hyperedge to determine candidate local hyperedges; For each candidate local hyperedge, calculating the entity matching degree between the local keywords and each entity node in the candidate local hyperedge to determine intermediate entity nodes.
5. The method according to claim 3, wherein Calculating the path resource value of the intermediate node path according to the node resource values of each entity node in the intermediate node path and the number of nodes in the intermediate node path includes: For each intermediate node path, setting an initial resource value for the entity nodes in the intermediate node path and obtaining the incoming nodes and outgoing nodes of the entity nodes; For each entity node in the intermediate node path, calculating the node resource value corresponding to the entity node based on the propagation of the initial resource value on the incoming nodes and outgoing nodes; Dividing the sum of the node resource values of all entity nodes in the intermediate node path by the number of entity nodes in the intermediate node path to obtain the path resource value of the intermediate node path.
6. The method according to claim 4, wherein During the process of searching for candidate node paths, recording the search process information of the candidate node paths includes: Combining the global hyperedges, local hyperedges, and intermediate entity nodes corresponding to the candidate node paths to obtain a search sequence; According to the specified weights, superimposing the global matching degree corresponding to the global hyperedge, the local matching degree corresponding to the local hyperedge, and the path resource value corresponding to the candidate node path during the search process to obtain a sequence score; Obtaining the selection information during the search process to obtain search strategy information.
7. The method according to claim 1, characterized in that Using the sequence score and the search strategy information to determine target search process information from the search process information of the candidate node paths includes: Based on the search strategy information, determining similar information pairs from the search process information of the candidate node paths; Replacing the similar information pairs with the search process information with the highest sequence score in the similar information pairs to obtain intermediate search process information; According to the sequence score in the intermediate search process information, determining target search process information from the intermediate search process information.
8. A hypergraph-based document question answering device, which is used to implement the method described in any one of claims 1-7, characterized in that, The apparatus includes: An acquisition module for acquiring a document to be processed and a problem to be processed; A construction module for extracting entities and entity relationships from each sub-paragraph in the document to be processed to construct a document hypergraph, where the document hypergraph includes entity nodes representing entities, ordinary edges representing entity relationships, local hyperedges representing entities belonging to the same sub-paragraph, and global hyperedges representing similar local hyperedges; A search module for searching for multiple candidate node paths matching the problem to be processed in the document hypergraph in the specified order, where the specified order is the order of global hyperedges, local hyperedges, and entity nodes; A recording module, configured to record search process information of the candidate node path during the process of searching for the candidate node path, where the search process information includes a search sequence, a sequence score, and search strategy information; A screening module, configured to determine target search process information from the search process information of the candidate node path by using the sequence score and the search strategy information; A reply module, configured to generate a target reply corresponding to the problem to be processed based on the target search process information; Wherein, extracting entities and entity relationships from each sub-paragraph in the document to be processed to construct a document hypergraph includes: dividing the document to be processed into multiple sub-paragraphs; for each sub-paragraph, extracting entities and entity relationships from the sub-paragraph; using the entities as entity nodes and the entity relationships as ordinary edges between the entity nodes to construct a basic document graph; in the basic document graph, establishing local hyperedges for entity nodes belonging to the same sub-paragraph, and generating local descriptions corresponding to the local hyperedges with the context of the sub-paragraph to obtain an intermediate document graph; using the local descriptions to perform clustering processing on all the local hyperedges to obtain a plurality of clustering clusters; in the intermediate document graph, establishing global hyperedges for local hyperedges belonging to the same clustering cluster; for each global hyperedge, generating a global description corresponding to the global hyperedge based on the local descriptions of all the local hyperedges in the clustering cluster to obtain a document hypergraph.
Citation Information
Patent Citations
Financial question and answer retrieval enhancement generation method and system based on hypergraph
CN119294526A
Construction method, system and equipment of power dispatching knowledge question-answering system and storage medium
CN119311826A