A government affair question and answer method and system based on a knowledge graph and retrieval enhancement
By employing a knowledge graph-based and retrieval-enhanced government question-answering method, the accuracy and security issues of government question-answering systems in multimodal information processing and complex problem handling were resolved, resulting in more accurate and secure answer generation and improved user experience.
Patent Information
- Application Number
- CN202510670423.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-23
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2045-05-23
AI Technical Summary
Existing government question-and-answer systems are inaccurate when handling multimodal information and complex questions, and there is a risk that large language models will generate incorrect answers. Furthermore, the answer processing mechanism is imperfect and may leak sensitive information.
By using knowledge graph-based and retrieval enhancement methods, textual information, multimodal information, and metadata from government documents are extracted to construct an entity relationship graph. Based on the user query type, retrieval enhancement techniques are used to generate answers, and the accuracy and security of the answers are ensured through optimization steps.
It significantly improves the accuracy and security of government Q&A, reduces the illusion of large language models, enhances user experience, and is able to more comprehensively understand document content and user intent, providing more complete answers.
Smart Images

Figure CN120179797B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of large models, in particular to a government affair question and answer method and system based on knowledge graph and retrieval enhancement. BACKGROUND
[0002] At present, government affair question and answer is mainly carried out in the following ways: one is keyword matching-based query question and answer, which matches the user input question with the pre-set keyword library to query the relevant content from the document library as the answer returned; the other is to introduce natural language processing technology, such as using large language model, knowledge graph and other technologies to try to understand the semantic of user question and provide more intelligent answers.
[0003] However, the above two methods have the following problems:
[0004] (1) Weak multi-modal information processing capability: It relies heavily on text information and cannot process corresponding multi-modal information such as pictures, tables and formulas in government documents, resulting in poor context understanding and affecting the accuracy of question and answer.
[0005] (2) Unable to handle complex problems: When facing complex government problems, the keyword matching-based method can only find keywords in isolation and cannot logically disassemble and deeply analyze the problem, so the query answer may be one-sided and scattered, which cannot meet the user's needs.
[0006] (3) "Illusion" problem of large language model: When using large language model for government affair question and answer, "illusion" phenomenon occurs from time to time, although it can generate seemingly reasonable answers, but there may be factual errors.
[0007] (4) Incomplete answer processing mechanism: The query answer is directly transmitted to the user, resulting in poor accuracy and potential risks of leaking sensitive information. SUMMARY
[0008] Therefore, the present application provides a government affair question and answer method and system based on knowledge graph and retrieval enhancement to solve the problem of poor accuracy and potential risks of existing government affair question and answer.
[0009] In the first aspect, the present application provides a government affair question and answer method based on knowledge graph and retrieval enhancement, which comprises:
[0010] For each government document, information extraction is performed on the government document to obtain text information, multi-modal information and metadata;
[0011] Fusing the text information, multi-modal information and metadata, the document information of the government document is obtained;
[0012] entity and relation extraction based on the document information of the government document, to obtain the entity, relation and text key-value pair corresponding to the government document;
[0013] constructing a government knowledge graph based on the entity, relation and text key-value pair corresponding to each government document;
[0014] generating a query answer of the user query statement based on the type of the user query statement and the government knowledge graph by using retrieval enhancement technology;
[0015] optimizing the query answer of the user query statement to generate a target answer of the user query statement.
[0016] The government question answering method based on the knowledge graph and retrieval enhancement provided by the embodiment of the application can ensure comprehensive understanding of the government document by extracting text information, multi-modal information and metadata, fuse different types of information together to obtain document information, ensure sufficient understanding of the context, extract entity and relation from the document information and generate text key-value pair, better understand semantic information in the document, construct a government knowledge graph through entity, relation and text key-value pair, enable logical reasoning and deep analysis based on the government knowledge graph, and provide an efficient query mechanism, which can quickly locate relevant information in large-scale data. When performing government question answering, the retrieval enhancement technology can be used to more accurately match relevant answers in combination with the query type of the user and the knowledge graph, and the answer is optimized to ensure that the generated answer is more accurate. Through multi-modal information processing and the introduction of the knowledge graph, the document content and the user query intention can be more comprehensively understood, the accuracy of the question answering is significantly improved, the knowledge graph and the retrieval enhancement technology are fused to reduce the "hallucination" phenomenon that may occur in the large language model, improve the accuracy of the answer, and further ensure the safety, accuracy and readability of the answer through the optimization step to improve the user experience.
[0017] In an optional implementation, the entity and relation extraction based on the document information of the government document to obtain the entity, relation and text key-value pair corresponding to the government document comprises:
[0018] segmenting the document information of the government document to obtain a plurality of text segments;
[0019] For each text segment, a large language model is used to identify entity and relation from the text segment;
[0020] for each entity, the entity is taken as a key, and the related content of the entity in the text segment is taken as a value to generate a text key-value pair corresponding to the entity;
[0021] for each relation, the relation and the entity constituting the relation are taken as a key, and the related content of the relation in the text segment is taken as a value to generate a text key-value pair corresponding to the relation.
[0022] The government affair question answering method based on the knowledge graph and retrieval enhancement provided by the embodiment of the application can improve the quality of the text key-value pair through preprocessing, and can convert the entity, the relationship and the text key-value pair in the government affair document into the node, the edge and the connection relationship in the graph, and can add the attribute to the node and the edge, so that the information in the government affair document can be more comprehensively and accurately represented, and the knowledge graph can support the query and reasoning based on the graph, so that more complex query problems can be processed and more complete answers can be provided.
[0023] In an optional implementation, based on the entity, the relationship and the text key-value pair corresponding to each government affair document, a government affair knowledge graph is constructed, including:
[0024] Based on the text key-value pair corresponding to each government affair document, the text key-value pair is preprocessed to obtain a target key-value pair;
[0025] Based on the entity in each government affair document, a node is created, and based on the relationship in each government affair document, an edge is created;
[0026] Based on the target key-value pair corresponding to each government affair document, the node and the edge are connected, and the attribute is added to the node and the edge respectively, to generate the government affair knowledge graph, and the attribute refers to the value corresponding to the node or the value corresponding to the edge.
[0027] The government affair question answering method based on the knowledge graph and retrieval enhancement provided by the embodiment of the application can improve the quality of the text key-value pair through preprocessing, and can convert the entity, the relationship and the text key-value pair in the government affair document into the node, the edge and the connection relationship in the graph, and can add the attribute to the node and the edge, so that the information in the government affair document can be more comprehensively and accurately represented, and the knowledge graph can support the query and reasoning based on the graph, so that more complex query problems can be processed and more complete answers can be provided.
[0028] In an optional implementation, based on the type of the user query statement and the government affair knowledge graph, before the query answer of the user query statement is generated by using the retrieval enhancement technology, the method further includes:
[0029] For each node in the government affair knowledge graph, based on the node attribute of the node, the edge directly connected to the node and the node and the attribute thereof, a vector corresponding to the node is constructed;
[0030] Based on the vectors corresponding to all the nodes, a vector database is constructed.
[0031] The government affair question answering method based on the knowledge graph and the retrieval enhancement provided by the embodiment of the application extracts feature information from the attributes of a node, edges directly connected to the node, and the node and its attributes, converts the feature information into a vector, thereby obtaining a vector database constructed based on vectors corresponding to all nodes, and through vectorization processing, complex structured information can be converted into a form convenient for calculation, and more complex query and analysis tasks are supported.
[0032] In an optional implementation, based on the type of the user query statement and the government affair knowledge graph, the retrieval enhancement technology is adopted to generate a query answer of the user query statement, including:
[0033] In a case where the type of the user query statement is a concept type, a large language model is adopted to identify a query entity from the user query statement;
[0034] The query entity is converted into a first query vector, and at least one first target vector with a similarity greater than a preset similarity threshold to the first query vector is determined from the vector database;
[0035] Based on the at least one first target vector, a corresponding first target node, a first target edge and a first adjacent node are determined from the government affair knowledge graph, the first target edge refers to an edge directly connected to the first target node, and the first adjacent node refers to another node directly connected to the first target edge;
[0036] Based on the attributes of the first target node, the attributes of the first adjacent node, the first target edge and the attributes of the first target edge, a large language model is adopted to generate a query answer of the user query statement.
[0037] The government affair question answering method based on the knowledge graph and the retrieval enhancement provided by the embodiment of the application extracts feature information from the attributes of a node, edges directly connected to the node, and the node and its attributes, converts the feature information into a vector, thereby obtaining a vector database constructed based on vectors corresponding to all nodes, and through vectorization processing, complex structured information can be converted into a form convenient for calculation, and more complex query and analysis tasks are supported.
[0038] In an optional implementation, based on the type of the user query statement and the government affair knowledge graph, the retrieval enhancement technology is adopted to generate a query answer of the user query statement, further including:
[0039] In the case that the type of the user query statement is a process type, a large language model is used to identify query entities, query relationships and abstract concepts from the user query statement;
[0040] The query entities, query relationships and abstract concepts are respectively converted into second query vectors, and at least one second target vector with a similarity greater than a preset similarity threshold is determined from the vector database for each second query vector;
[0041] Based on the at least one second target vector, corresponding second target nodes, second target edges and second adjacent nodes are determined from the government knowledge graph, the second target edges include edges directly connected to the second target nodes and edges with attributes consistent with the query relationships, and the second adjacent nodes refer to other nodes directly connected to the second target edges;
[0042] The thought chain technology is used to process based on the attributes of the second target nodes, the attributes of the second adjacent nodes, the second target edges and the attributes of the second target edges to obtain a query result;
[0043] The large language model is used to integrate based on the query result to generate a query answer of the user query statement.
[0044] The government affair question and answer method based on knowledge graph and retrieval enhancement provided by the embodiment of the application provides entities, relationships and abstract concepts in the query statement by identifying and extracting the query statement in the case that the query statement input by the user is of a process type, converts the entities, relationships and abstract concepts into second query vectors, queries second target vectors from a vector database based on vector similarity, then determines corresponding second target nodes, second target edges and second adjacent nodes from a government knowledge graph based on the second target vectors, provides more comprehensive information, and finally generates a query answer using a large language model to ensure that the query answer is accurate, complete and consistent with the query intention of the user, and the combination of the vector database and the knowledge graph significantly improves the speed and efficiency of the query.
[0045] In an optional implementation, the query answer of the user query statement is optimized to generate a target answer of the user query statement, which includes:
[0046] The query answer is subjected to rule filtering and model filtering to obtain an initial answer;
[0047] The initial answer is scored using a large language model to obtain a quality score;
[0048] In the case that the quality score is greater than a preset score threshold, the initial answer is taken as the target answer; or,
[0049] In a case where the quality score is not less than the preset score threshold, the initial answer is taken as a new query answer, and the step of returning to the rule filtering and model filtering on the query answer is performed until the initial answer is taken as the target answer.
[0050] The government affair question answering method based on the knowledge graph and search enhancement provided by the embodiment of the application improves the overall accuracy of the answer through the rule filtering and model filtering on the query answer, scores the initial answer after the rule and model filtering, ensures that the quality score of the generated answer meets the requirements, improves the accuracy and reliability of the final answer, and avoids potential sensitive risks.
[0051] In an optional implementation, for each government affair document, information extraction is performed on the government affair document to obtain text information, multi-modal information and metadata, including:
[0052] The government affair document is converted into a standard format;
[0053] A parsing tool is used to extract the text information and metadata of the government affair document in the standard format;
[0054] A computer vision model is used to perform non-text recognition on the government affair document in the standard format to obtain non-text content;
[0055] The non-text content is preprocessed to obtain the multi-modal information.
[0056] The government affair question answering method based on the knowledge graph and search enhancement provided by the embodiment of the application converts government affair documents in different formats into a standard format, which is convenient for subsequent processing, then uses a parsing tool to extract pure text content and metadata in the government affair document, and simultaneously uses computer vision technology to extract non-text elements, so that the understanding of the document is not limited to understanding the text, but also the semantics in the multi-modal information can be interpreted, so that the document content can be more comprehensively grasped.
[0057] In an optional implementation, the text information, the multi-modal information and the metadata are fused to obtain document information of the government affair document, including:
[0058] The text information and the multi-modal information are preprocessed to obtain preprocessed text information and multi-modal information;
[0059] A large language model is used to convert the metadata, the preprocessed text information and the multi-modal information into vectors respectively;
[0060] A fusion layer is used to perform feature fusion on the multiple vectors to obtain a fusion vector;
[0061] The fusion vector is decoded to obtain the document information of the government affair document.
[0062] The government affair question answering method based on the knowledge graph and retrieval enhancement provided by the embodiment of the application improves the quality of the text and the multi-modal information by preprocessing the extracted text information, encodes the preprocessed text information using a large language model, converts the text information into a high-dimensional vector representation, can capture the semantic information of the text, and then uses a fusion layer to perform feature fusion on multiple vectors to obtain a fusion vector, and finally decodes the fusion vector into readable document information, which can better reflect the semantic information of the government affair document.
[0063] In a second aspect, the application provides a government affair question answering system based on a knowledge graph and retrieval enhancement, which comprises:
[0064] A document information processing module is configured to, for each government affair document, perform information extraction on the government affair document to obtain text information, multi-modal information and metadata, and fuse the text information, the multi-modal information and the metadata to obtain document information of the government affair document.
[0065] A knowledge graph construction module is configured to perform entity relationship extraction based on the document information of the government affair document to obtain entities, relationships and text key-value pairs corresponding to the government affair document, and construct a government affair knowledge graph based on the entities, the relationships and the text key-value pairs corresponding to each government affair document.
[0066] A content query and generation module is configured to generate a query answer of a user query statement based on the type of the user query statement and the government affair knowledge graph using a retrieval enhancement technology.
[0067] A data quality control module is configured to optimize the query answer of the user query statement to generate a target answer of the user query statement.
[0068] In a third aspect, the application provides a computer device, which comprises a memory and a processor, the memory and the processor are communicatively connected with each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the government affair question answering method based on the knowledge graph and the retrieval enhancement of the first aspect or any of the corresponding embodiments thereof.
[0069] In a fourth aspect, the application provides a computer readable storage medium, which stores computer instructions, and the computer instructions are used to make a computer execute the government affair question answering method based on the knowledge graph and the retrieval enhancement of the first aspect or any of the corresponding embodiments thereof.
[0070] In a fifth aspect, the application provides a computer program product, which comprises computer instructions, and the computer instructions are used to make a computer execute the government affair question answering method based on the knowledge graph and the retrieval enhancement of the first aspect or any of the corresponding embodiments thereof. BRIEF DESCRIPTION OF DRAWINGS
[0071] In order to more clearly illustrate the technical solutions in the specific embodiments of the present application or the prior art, the drawings required to be used in the specific embodiments or prior art description will be briefly introduced as follows. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of these drawings.
[0072] Figure 1 is a schematic diagram of a government affair question answering system based on knowledge graph and retrieval enhancement according to an embodiment of the present application;
[0073] Figure 2 is a flowchart of a government affair question answering method based on knowledge graph and retrieval enhancement according to an embodiment of the present application;
[0074] Figure 3 is a flowchart of a document information processing module according to an embodiment of the present application;
[0075] Figure 4 is a schematic diagram of a government affair knowledge graph according to an embodiment of the present application;
[0076] Figure 5 is a flowchart of a data quality control module according to an embodiment of the present application;
[0077] Figure 6 is a hardware structure schematic diagram of a computer device according to an embodiment of the present application. DETAILED DESCRIPTION
[0078] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0079] The existing government question and answer is mainly carried out in the following ways: one is a query type question and answer based on keyword matching; and the other is to introduce natural language processing technology. However, the above two methods have the problems of poor accuracy of answers and potential risks. In the prior art, a multi-strategy switching process is adopted to deal with government problems, and attention is paid to multi-source data integration and intent inheritance. In addition, the prior art uses a general question and answer system to support a large language model to generate a query statement + similar question matching. The government question and answer method based on knowledge graph and retrieval enhancement provided in the embodiments of the present application can more comprehensively understand the document content and the user query intent through multi-modal information processing and the introduction of a knowledge graph, significantly improves the accuracy of the question and answer, reduces the "hallucination" phenomenon that may occur in the large language model by fusing the knowledge graph and the retrieval enhancement technology, improves the accuracy of the answer, and further ensures the safety, accuracy and readability of the answer through optimization steps, improves the user experience, and at the same time, the present application focuses on the combination of logical reasoning and retrieval enhancement of the government knowledge graph, designs a double-mode retrieval for concept type / flow type problems, improves the analysis accuracy of complex government processes, and forms a unique technical path in the aspects of knowledge graph construction, question and answer mechanism and answer optimization, solves the problems of insufficient generalization, weak logical reasoning and safety compliance of the prior art in the government field.
[0080] According to the embodiments of the present application, a government question and answer method based on knowledge graph and retrieval enhancement is provided. It should be noted that the steps shown in the flowchart of the drawings can be executed in a computer system such as a group of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0081] Figure 1 is a schematic diagram of a government question and answer system based on knowledge graph and retrieval enhancement according to the embodiments of the present application, as Figure 1 shown, the system comprises: a document information processing module, configured to, for each government document, perform information extraction on the government document to obtain text information, multi-modal information and metadata, and fuse the text information, the multi-modal information and the metadata to obtain document information of the government document; a knowledge graph construction module, configured to perform entity relationship extraction based on the document information of the government document to obtain entities, relationships and text key-value pairs corresponding to the government document, and construct a government knowledge graph based on the entities, the relationships and the text key-value pairs corresponding to each government document; a content query and generation module, configured to generate a query answer of a user query statement based on the type of the user query statement and the government knowledge graph using retrieval enhancement technology; and a data quality control module, configured to optimize the query answer of the user query statement to generate a target answer of the user query statement.
[0082] Specifically, the document information processing module is configured to perform information extraction on each government document to obtain text information, multi-modal information and metadata, and fuse the three types of data to obtain document information with fully mined semantics and understood context. The knowledge graph construction module is configured to extract entities and relationships from the document information, and construct text key-value pairs based on the entities and relationships, so as to construct a government knowledge graph based on the entities, relationships and text key-value pairs, to visually display the information contained in the government documents, and serve as a basis for efficient query of government question answering. The content query and generation module is configured to efficiently and accurately query corresponding information from the government knowledge graph based on a user query statement, and generate a query answer. The data quality control module is configured to optimize the query answer to avoid potential risks.
[0083] In the embodiment, a government question answering method based on a knowledge graph and retrieval enhancement is provided, which can be used in the government question answering system based on the knowledge graph and retrieval enhancement, Figure 2 is a flowchart of the government question answering method based on the knowledge graph and retrieval enhancement according to the embodiment of the present application, as Figure 2 shown, the flow includes the following steps:
[0084] In step S201, for each government document, information extraction is performed on the government document to obtain text information, multi-modal information and metadata. Specifically, the government document refers to a file used to record, convey and process various government information, has legal effect and administrative binding force, and is the basis of government question answering, including policy documents, meeting minutes, work reports, application and approval documents, etc. For each government document, text information, multi-modal information and metadata are extracted therefrom. The text information refers to pure text content; the multi-modal information refers to non-pure text content, including pictures, tables and formulas, etc.; and the metadata is used to describe the attributes of the government document, including basic attributes such as title, author, theme, keywords, creation / modification date, etc., technical attributes such as PDF version, software for generating PDF, encryption status, etc., and extended attributes such as XMP (Extensible Metadata Platform) metadata and custom metadata, etc. By extracting the above-mentioned multiple types of information, compared with the related art which only processes single text information, the content of the government document can be comprehensively extracted and understood, providing a basis for government question answering.
[0085] In step S202, the text information, multi-modal information and metadata are fused to obtain document information of the government document. Specifically, the multiple types of information are fused to comprehensively integrate the multi-aspect information in the government document, fully mine the semantic information in the government document, form the document information of the government document, and complement different types of information to provide a more complete and accurate data basis for subsequent analysis.
[0086] At step S203, entity relationship extraction is performed based on the document information of the government document, to obtain entities, relationships and text key-value pairs corresponding to the government document. Specifically, different entities (such as names, times, places, events, etc.) and their relationships are identified from the fused document information. For example, from the text “The same unit 3 or more owners, and the owners committee or its commissioned property service enterprises can apply to the city property special maintenance fund management center for purchase of elevator maintenance insurance with value-added income account funds”, the entities “owner”, “owner committee”, “property service enterprise”, “city property special maintenance fund management center” and “elevator maintenance insurance” are extracted, as well as the relationships “the owner committee applies to the city property special maintenance fund management center for purchase of elevator maintenance insurance” and “the owner commissions the property service enterprise to purchase elevator maintenance insurance from the city property special maintenance fund management center”. Based on the entities and relationships, text key-value pairs can also be generated, laying a foundation for constructing a government knowledge graph.
[0087] At step S204, a government knowledge graph is constructed based on the entities, relationships and text key-value pairs corresponding to each government document. Specifically, the entities, relationships and text key-value pairs are organized in the form of a graph, more intuitively displaying the information in the government document, facilitating quick query and information acquisition, and helping to improve the accuracy and efficiency of data query, providing support for government question answering.
[0088] At step S205, based on the type of the user query statement and the government knowledge graph, a retrieval enhancement technique is used to generate a query answer to the user query statement. Specifically, retrieval augmented generation (RAG) is a natural language processing technique that combines query and generation, which can improve the accuracy and reliability of complex queries. According to the type of the user query statement, combined with the government knowledge graph, the retrieval enhancement technique is used to generate an accurate and comprehensive query answer to meet the user's needs.
[0089] At step S206, the query answer to the user query statement is optimized to generate a target answer to the user query statement. Specifically, since the query answer may contain factors affecting security and accuracy, the target answer that is more accurate, reliable and meets the user's needs can be obtained by optimizing the query answer.
[0090] The government affair question answering method based on the knowledge graph and retrieval enhancement provided in the embodiment of the application can ensure comprehensive understanding of government affair documents by extracting text information, multi-modal information and metadata, fuse different types of information together to obtain document information, ensure sufficient understanding of context, extract entities and relationships from the document information and generate text key-value pairs, better understand semantic information in the document, construct a government affair knowledge graph through entities, relationships and text key-value pairs, enable logical reasoning and deep analysis based on the government affair knowledge graph, and provide an efficient query mechanism that can quickly locate relevant information in large-scale data. When performing government affair question answering, the query type of the user and the knowledge graph are combined, retrieval enhancement technology is adopted to more accurately match relevant answers, and answer optimization is performed to ensure that the generated answers are more accurate. Through multi-modal information processing and the introduction of the knowledge graph, document content and user query intentions can be more comprehensively understood, the accuracy of question answering is significantly improved, the knowledge graph and retrieval enhancement technology are fused to reduce the "hallucination" phenomenon that may occur in large language models, improve the accuracy of answers, and further ensure the safety, accuracy and readability of the answers through optimization steps to improve the user experience.
[0091] A government affair question answering method based on a knowledge graph and retrieval enhancement is provided in the embodiment, which can be used in the government affair question answering system based on the knowledge graph and retrieval enhancement, and the method specifically includes the following steps.
[0092] In step S301, information extraction is performed on each government affair document to obtain text information, multi-modal information and metadata.
[0093] Specifically, step S301 includes the following steps.
[0094] In step S3011, the government affair document is converted into a standard format. Specifically, since there are various formats of government affair documents, different formats of government affair documents are uniformly converted into a standard format, such as a PDF format, to facilitate subsequent information extraction and processing.
[0095] In step S3012, a parsing tool is used to extract text information and metadata of the government affair document in the standard format. Specifically, a PDF parsing tool, such as MinerU, Apache PDFBox, PyPDF2, etc., is used to read pure text content in the PDF government affair document, that is, text information, and extract metadata, which are key information for understanding core content and background of the document.
[0096] In step S3013, a computer vision model is used to perform non-text recognition on the standard format government document to obtain non-text content. Specifically, the non-text content such as pictures, tables, and formulas in the government document is recognized by the computer vision model to obtain the non-text content. First, the government document is preprocessed by layout recognition, paragraph sorting, useless block removal, and useless layout filtering. Then, different types of non-text content are processed accordingly, such as coordinate positioning (i.e., determining the context position information), content extraction and storage for pictures, and table merging and storage for tables.
[0097] In step S3014, the non-text content is preprocessed to obtain multi-modal information. Specifically, the non-text content is stored in a structured data format such as JSON or Excel to obtain multi-modal information containing rich non-text content.
[0098] In step S302, the text information, multi-modal information, and metadata are fused to obtain document information of the government document.
[0099] Specifically, step S302 includes:
[0100] In step S3021, the text information and multi-modal information are preprocessed to obtain preprocessed text information and multi-modal information. Specifically, the text information and multi-modal information are preprocessed by removing duplicate information and handling OCR (Optical Character Recognition) garbled codes to improve data usability.
[0101] In step S3022, a large language model is used to convert the metadata, preprocessed text information, and multi-modal information into vectors. Specifically, a large language model (LLM) is an artificial intelligence technology based on deep learning, which is specifically used to process and generate natural language text. The large language model learns the complex structure and pattern of language by training on a large-scale dataset, and can understand and generate grammatically correct and semantically rich text. By using a large language model, the text information, multi-modal information, and metadata in the government document are converted into vectors, which facilitates subsequent processing by the model.
[0102] In step S3023, a fusion layer is used to perform feature fusion on multiple vectors to obtain a fusion vector. Specifically, the fusion layer in the large language model is used to analyze the vectors of different types of information based on its pre-trained semantic understanding ability and correlation mining ability. Finally, these information is fused in a logically coherent manner, so that the fused vector contains more comprehensive government information and reflects the correlation between different types of information, which helps to more comprehensively understand the content of the government document.
[0103] Step S3024, the fusion vector is decoded to obtain the document information of the government document. Specifically, the fusion vector is restored to understandable and usable document information by using a decoding algorithm, the document information of the integrated government document is obtained, the fusion of multi-source information is realized, and compared with only considering single text information, the accuracy and reliability of the government document are improved. Optionally, the document information can be converted into a lightweight Markdown format for subsequent processing.
[0104] In some optional embodiments, Figure 3 is a flowchart of a document information processing module according to an embodiment of the application, as Figure 3 shown, the document information processing module includes a document preprocessing layer, a multi-modal data processing layer, and a fusion layer. The government document is converted into a standard format through the document preprocessing layer, and then the text information and metadata are extracted. Through the multi-modal data processing layer, the multi-modal data recognition is performed on the government document in the standard format, such as picture recognition, table recognition, formula detection, and text block detection, so as to extract the multi-modal information and convert it into a JSOM, Excel, or the like. Through the fusion layer, the text information and metadata extracted by the document preprocessing layer and the multi-modal information extracted by the multi-modal data processing layer are processed, and finally fused to obtain the document information.
[0105] Step S303, based on the document information of the government document, entity relationship extraction is performed to obtain the entity, relationship, and text key-value pair corresponding to the government document.
[0106] Specifically, the above step S303 includes:
[0107] Step S3031, the document information of the government document is cut into a plurality of text blocks. Specifically, as shown in the following formula (1), the document information is divided into smaller text blocks for easy processing, improving the efficiency and accuracy of entity relationship extraction.
[0108] (1)
[0109] wherein, denotes a set of the government document containing text blocks; denotes the document information; denotes a segmentation module; denotes an index value of the text block, which is usually represented by a hash value; denotes the text block.
[0110] In step S3032, for each text chunk, a large language model is used to identify entities and relationships from the text chunk. Specifically, the natural language processing capability of the large language model is used to identify entities such as names, times, places, events, etc. from the text chunk, as well as the relationships between them, providing basic data for subsequent generation of text key-value pairs and construction of a knowledge graph.
[0111] In step S3033, for each entity, the entity is taken as a key and the related content of the entity in the text chunk is taken as a value to generate a text key-value pair corresponding to the entity. Specifically, the identified entity is taken as an index key and the text description related to the entity in the text chunk is taken as a value to generate a text key-value pair. For example, assuming that the text chunk is "The same unit 3 or more owners, and the owners committee or its entrusted property service enterprise can apply to the city property special maintenance fund management center to purchase elevator maintenance insurance with value-added income account funds", the entity "owner" is taken as a key and the related content "The same unit 3 or more owners, and the owners committee or its entrusted property service enterprise can apply to the city property special maintenance fund management center to purchase elevator maintenance insurance with value-added income account funds" is taken as a value to generate a text key-value pair. By generating a text key-value pair corresponding to the entity, the entity information is structured, facilitating subsequent construction of a knowledge graph and information query.
[0112] In step S3034, for each relationship, the relationship and the entities constituting the relationship are taken as keys and the related content of the relationship in the text chunk is taken as a value to generate a text key-value pair corresponding to the relationship. Specifically, the relationship and the entities constituting the relationship are taken as index keys and the description of the relationship in the text chunk is taken as a value to generate a corresponding text key-value pair, which helps to accurately present the relationships between entities.
[0113] In step S304, based on the entities, relationships and text key-value pairs corresponding to each government document, a government knowledge graph is constructed.
[0114] Specifically, the above step S304 includes:
[0115] In step S3041, based on the text key-value pairs corresponding to each government document, the text key-value pairs are preprocessed to obtain target key-value pairs. Specifically, all text key-value pairs corresponding to a government document can be imported into an open-source graph database to complete the construction of a knowledge graph in the graph database. After import, the text key-value pairs are first preprocessed to remove duplicates, noise, and convert to a standard format, etc. to improve the quality of the text key-value pairs and obtain corresponding target key-value pairs.
[0116] In step S3042, nodes are created based on the entities in each government document and edges are created based on the relationships in each government document. Specifically, each entity in a government document is taken as a node and each relationship is taken as an edge.
[0117] In step S3043, based on the target key-value pair corresponding to each government document, the nodes and edges are connected, and attributes are added to the nodes and edges respectively, to generate a government knowledge graph. The attributes refer to the values corresponding to the nodes or the values corresponding to the edges. Specifically, according to the key-value correspondence in the target key-value pair, the relationship between entities can be obtained, so that the entities with the relationship are connected, that is, the nodes and edges are connected. At the same time, if the target key-value pair is generated based on an entity, the value in the key-value pair is taken as an attribute of the node corresponding to the entity. If the target key-value pair is generated based on a relationship, the value in the key-value pair is taken as an attribute of the edge corresponding to the relationship. Based on the above process, a complete government knowledge graph is generated, which contains rich entities, relationships and attributes, and can intuitively show the relationship between government information, providing strong support for government question answering.
[0118] In some optional embodiments, the government knowledge graph can be represented by the following formula (2).
[0119] (2)
[0120] wherein, represents the government knowledge graph; represents a relationship index generation large language model; represents an entity; represents a relationship; represents an entity relationship extraction large language model; represents text chunking.
[0121] In some optional embodiments, Figure 4 is a schematic diagram of the government knowledge graph according to an embodiment of the present application, as shown in Figure 4 The government knowledge graph takes multiple entities as nodes and takes relationships as edges, connects the nodes and edges based on the relationships between the entities, and shows the association relationship between government information. Optionally, Figure 4 The node attributes, the relationships corresponding to the edges, and the attributes are not shown.
[0122] In step S305, for each node in the government knowledge graph, a vector corresponding to the node is constructed based on the node attributes of the node, the edges directly connected to the node, and the nodes and their attributes. Specifically, the attributes of the node, the edges directly connected to the node, and the nodes and their attributes are comprehensively considered, and these information is converted into a vector corresponding to the node. Optionally, the dimension and calculation method of the vector are determined according to specific requirements. A corresponding vector is generated for each node, so that the information in the knowledge graph can be stored and processed in the form of a vector, saving storage resources and facilitating query.
[0123] Step S306, based on the vectors corresponding to all nodes, a vector database is constructed. Specifically, based on the vectors generated by all nodes in the government knowledge graph, a vector database is constructed for fast query.
[0124] Step S307, based on the type of the user query statement and the government knowledge graph, a retrieval enhancement technique is used to generate the query answer of the user query statement.
[0125] Specifically, the above step S307 includes:
[0126] Step S3071, in the case where the type of the user query statement is a concept type, a large language model is used to identify the query entity from the user query statement. Specifically, the query statement input by the user during query generally belongs to a specific concept type query or a general process type query, and the process of query and answer generation is different for different query types. If the user query statement is of a concept type, such as "what is special deduction?", through steps S3071 to S3074, the corresponding query answer is generated. More specifically, a large language model is used to identify the query entity in the user query statement, such as "deduction" in "what is special deduction?".
[0127] Step S3072, the query entity is converted into a first query vector, and at least one first target vector with a similarity greater than a preset similarity threshold to the first query vector is determined from the vector database. Specifically, the identified query entity is converted into a vector form, i.e. a first query vector, and by calculating the similarity between vectors, vectors with a similarity greater than a preset threshold are selected from the vector database as first target vectors. By combining knowledge graph query with vector database query, the efficiency and accuracy of government question answering are improved.
[0128] Step S3073, based on the at least one first target vector, a corresponding first target node, a first target edge and a first adjacent node are determined from the government knowledge graph, the first target edge refers to an edge directly connected to the first target node, and the first adjacent node refers to other nodes directly connected to the first target edge. Specifically, the first target node corresponding to the first target vector is found from the government knowledge graph, the first target edge directly connected to the first target node, and other adjacent nodes other than the first target node directly connected to the first target edge. Not only can detailed information related to a specific query entity be accurately queried, but also more extensive related knowledge can be obtained, thereby providing comprehensive answers to users and meeting user needs.
[0129] At step S3074, a query answer of the user query statement is generated based on the attribute of the first target node, the attribute of the first adjacent node, the first target edge, and the attribute of the first target edge by using the large language model. Specifically, the first target node, the first adjacent node, the first target edge, and the attribute information thereof are input into the large language model, and the large language model generates a query answer in natural language form according to the information, so as to meet the demand of the user for specific concept information.
[0130] (3)
[0131] wherein, represents the query answer; represents the large language model; represents the user query statement; represents the queryer; represents the government affair knowledge graph.
[0132] At step S3075, in a case where the type of the user query statement is a flow type, a query entity, a query relationship, and an abstract concept are identified from the user query statement by using the large language model. Specifically, in a case where the user query statement is of the flow type, for example, “how to fill in the special deduction of personal income tax?”, a corresponding query answer is generated through steps S3075 to S3079. More specifically, the query entity in the user query statement is identified by using the large language model, for example, the query entity “special deduction of personal income tax” and the query relationship “fill in” in “how to fill in the special deduction of personal income tax?”. The abstract concept is a word having a specific meaning in the user query statement, for example, a specific rule or the like.
[0133] At step S3076, the query entity, the query relationship, and the abstract concept are respectively converted into second query vectors, and at least one second target vector having a similarity greater than a preset similarity threshold value with each second query vector is determined from a vector database. Specifically, the identified query entity, query relationship, and abstract concept are respectively converted into vectors, i.e., second query vectors. For each second query vector, a vector having a similarity greater than a preset similarity threshold value is selected from the vector database as a corresponding second target vector, so as to provide a clue for obtaining related information from the knowledge graph.
[0134] At step S3077, based on the at least one second target vector, a corresponding second target node, a second target edge, and a second adjacent node are determined from the government affair knowledge graph, the second target edge includes an edge directly connected to the second target node and an edge having an attribute consistent with the query relationship, and the second adjacent node refers to other nodes directly connected to the second target edge. Specifically, reference is made to step S3073, and details are not repeated here.
[0135] At step S3078, the thought chain technology is adopted to process based on the attribute of the second target node, the attribute of the second adjacent node, the second target edge and the attribute of the second target edge to obtain a query result. Specifically, the thought chain technology is used to comb the logical process for solving the process problem raised by the user according to the information obtained from the government knowledge graph, such as the steps for filling in the special deduction of individual income tax, to obtain the query result.
[0136] At step S3079, a large language model is adopted to integrate based on the query result to generate a query answer of the user query sentence. Specifically, the query result obtained by the thought chain technology is input into the large language model, and the large language model integrates it into a natural language text that is smooth and easy to understand as a query answer.
[0137] At step S308, the query answer of the user query sentence is optimized to generate a target answer of the user query sentence.
[0138] Specifically, the above step S308 includes:
[0139] At step S3081, the query answer is subjected to rule filtering and model filtering to obtain an initial answer. Specifically, the length rule, the sensitive word library and the like are used for rule filtering. For example, a reasonable length range of the answer is set, and if the query answer is too short, it may not be able to completely answer the question, and if it is too long, it may contain redundant information, and the query answer that does not meet the length requirement is processed; at the same time, the sensitive word library is used to check the query answer to remove the content containing sensitive words and the like, such as words related to personal privacy, confidential information or inappropriate remarks. Then, model filtering is performed, that is, problem relevance filtering and answer accuracy filtering are performed, and the query answer that is incomplete, fabricated or ambiguous is processed. More specifically, for the query answer that does not meet the rule filtering and model filtering, manual intervention or retrieval enhancement technology is adopted to requery related information and generate a query answer. After rule filtering and model filtering, a relatively more compliant and more accurate initial answer is obtained, which provides a basis for subsequent scoring and further optimization.
[0140] At step S3082, a large language model is adopted to score the initial answer to obtain a quality score. Specifically, the large language model is used to comprehensively evaluate the initial answer in combination with the relevance, accuracy, expression clarity and the like. The large language model analyzes the relevance of the initial answer to the user query sentence, such as judging whether the initial answer accurately answers the user query sentence; checks the accuracy of the initial answer to ensure that there is no factual error; evaluates the expression clarity of the initial answer to determine whether it is logically coherent and easy to understand. According to the evaluation results of these dimensions, a score reflecting the quality of the initial answer is obtained.
[0141] Step S3083, in the case that the quality score is greater than the preset score threshold, the initial answer is taken as the target answer. Specifically, the quality score of the initial answer is compared with the preset score threshold. If the quality score is greater than the preset score threshold, it indicates that the initial answer performs well in terms of relevance, accuracy and expression clarity and the like, and can meet the needs of the user, and the initial answer is taken as the target answer and returned to the user to accurately meet the query needs of the user.
[0142] Step S3084, in the case that the quality score is not greater than the preset score threshold, the initial answer is taken as a new query answer, and returned to the step of performing rule filtering and model filtering on the query answer until the quality score is not less than the preset score threshold, and the initial answer is taken as the target answer. Specifically, when the quality score is not greater than the preset score threshold, the current initial answer is taken as a new query answer again, and rule filtering, model filtering and scoring are performed again, and optimization is performed again to improve the quality of the answer, and comparison with the preset score threshold is performed again, and the cycle is continued until the quality score is not less than the preset score threshold. After multiple iterations and optimization, the target answer meeting the quality requirements is finally obtained, and the overall quality of the government affair question answering is improved.
[0143] In some optional embodiments, Figure 5 is a flowchart of a data quality control module according to an embodiment of the application, as Figure 5 shown, the data quality control module includes a rule filtering layer, a model filtering layer and a model scoring layer. The query answer is processed by the rule filtering layer according to length rules and sensitive word rules. Optionally, the sensitive word library can be expanded according to actual needs. The answer filtered by the rule filtering layer is again filtered by the model filtering layer according to problem relevance and answer accuracy to obtain an initial answer. The initial answer is evaluated by the model scoring layer in multiple dimensions to obtain a quality score. Through comparison of the quality score with the preset score threshold, if the quality score is not less than the threshold, the initial answer is output, and if the quality score is less than the threshold, the initial answer is returned to the rule filtering layer for re-filtering.
[0144] The government affair question answering method based on the knowledge graph and the retrieval enhancement provided by the embodiment of the application can ensure comprehensive understanding of government affair documents by extracting text information, multi-modal information and metadata, can ensure that different types of information are fused together to obtain document information, can ensure sufficient understanding of context, can better understand semantic information in the document by extracting entities and relationships from the document information and generating text key-value pairs, can construct a government affair knowledge graph through entities, relationships and text key-value pairs, can enable logical reasoning and deep analysis based on the government affair knowledge graph, and can provide an efficient query mechanism that can quickly locate relevant information in large-scale data. When the government affair question answering is performed, the query type of the user and the knowledge graph are combined, the retrieval enhancement technology is adopted, relevant answers can be more accurately matched, and the answers are optimized to ensure that the generated answers are more accurate. Through multi-modal information processing and the introduction of the knowledge graph, document content and user query intentions can be more comprehensively understood, the accuracy of question answering is significantly improved, the knowledge graph and the retrieval enhancement technology are fused, the "hallucination" phenomenon that may occur in a large language model is reduced, the accuracy of answers is improved, and the safety, accuracy and readability of the answers are further ensured through optimization steps, and the user experience is improved.
[0145] The embodiment of the application further provides a computer device, please refer to Figure 6 , Figure 6 is a structural schematic diagram of a computer device provided by an optional embodiment of the application, as Figure 6 shown, the computer device includes one or more processors 10, a memory 20, and an interface for connecting various components, including a high-speed interface and a low-speed interface. Various components are communicatively connected to each other using different buses, and can be installed on a common motherboard or in other ways as needed. The processor can process instructions executed within the computer device, including instructions stored in the memory or graphics information stored on the memory to display a GUI on an external input / output device such as a display device coupled to the interface. In some optional embodiments, multiple processors and / or multiple buses can be used with multiple memories and multiple memories, if necessary. Similarly, multiple computer devices can be connected, each providing part of the necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 In the above description, the processor 10 is taken as an example.
[0146] The processor 10 can be a central processor, a network processor or a combination thereof. The processor 10 can further include a hardware chip. The hardware chip can be an application specific integrated circuit, a programmable logic device or a combination thereof. The programmable logic device can be a complex programmable logic device, a field programmable logic gate array, a general array logic or any combination thereof.
[0147] The memory 20 stores instructions executable by the at least one processor 10 to cause the at least one processor 10 to perform the methods illustrated by the above embodiments.
[0148] The memory 20 can include a program region and a data region. The program region can store an operating system and application programs required by at least one function. The data region can store data created according to the use of the computer device, and the like. In addition, the memory 20 can include a high-speed random access memory, and can further include a non-transitory memory such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state memory device. In some alternative embodiments, the memory 20 can optionally include a memory disposed remotely with respect to the processor 10, and these remote memories can be connected to the computer device through a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0149] The memory 20 can include a volatile memory such as a random access memory, and can further include a non-volatile memory such as a flash memory, a hard disk, or a solid state disk, and can further include a combination of the above-mentioned kinds of memories.
[0150] The computer device further includes a communication interface 30 for communication of the computer device with other devices or communication networks.
[0151] The embodiments of the present application also provide a computer readable storage medium, and the above-mentioned methods according to the embodiments of the present application can be implemented in hardware, firmware, or recorded in a storage medium, or stored in a remote storage medium or a non-transitory machine readable storage medium and downloaded to a local storage medium through network downloading of computer code, so that the methods described herein can be processed by such software on a storage medium using a general purpose computer, a special purpose processor, or programmable or special purpose hardware. The storage medium can be a magnetic disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk, or a solid state disk, and the like. Further, the storage medium can further include a combination of the above-mentioned kinds of memories. It can be understood that the computer, the processor, the microprocessor controller, or the programmable hardware includes a storage component that can store or receive software or computer code, and when the software or computer code is accessed and executed by the computer, the processor, or the hardware, the methods illustrated by the above embodiments are implemented.
[0152] Part of the present application can be applied as a computer program product, for example, computer program instructions, when executed by a computer, through the operation of the computer, can invoke or provide the method and / or technical solutions according to the present application. Those skilled in the art should understand that the form of computer program instructions in computer readable medium includes but is not limited to source files, executable files, installation package files and the like, and accordingly, the way of computer program instructions executed by computer includes but is not limited to: the computer directly executes the instructions, or the computer compiles the instructions and then executes the corresponding compiled program, or the computer reads and executes the instructions, or the computer reads and installs the instructions and then executes the corresponding installed program. Here, the computer readable medium can be any available computer readable storage medium or communication medium accessible to the computer.
[0153] Although the embodiments of the present application are described in conjunction with the drawings, various modifications and changes can be made by those skilled in the art without departing from the spirit and scope of the present application, and such modifications and changes fall within the scope defined by the appended claims.
Claims
1. A government affair question and answer method based on a knowledge graph and retrieval enhancement, characterized in that, The method comprises: For each government document, information extraction is performed on the government document to obtain text information, multi-modal information and metadata; Fusion of the text information, the multi-modal information and the metadata obtains the document information of the government document; Based on the document information of the government document, entity relationship extraction is performed to obtain the entity, relationship and text key-value pair corresponding to the government document; Based on the entity, relationship and text key-value pair corresponding to each government document, a government knowledge graph is constructed; For each node in the government knowledge graph, a vector corresponding to the node is constructed based on the node attribute of the node, the edge and node directly connected to the node, and the attribute of the node; Based on the vectors corresponding to all nodes, a vector database is constructed; Using a large language model, based on the type of a user query statement and the government knowledge graph, a retrieval enhancement technique is used to generate a query answer to the user query statement; The query answer to the user query statement is optimized to generate a target answer to the user query statement; The optimization of the query answer to the user query statement to generate the target answer to the user query statement comprises: Rule filtering and model filtering are performed on the query answer to obtain an initial answer, the rule filtering comprises length rule filtering and sensitive word library filtering, and the model filtering comprises question relevance filtering and answer accuracy filtering; A large language model is used to score the initial answer to obtain a quality score; In the case where the quality score is greater than a preset score threshold, the initial answer is taken as the target answer; or In the case where the quality score is not greater than the preset score threshold, the initial answer is taken as a new query answer, and the step of returning to rule filtering and model filtering on the query answer to obtain an initial answer is performed until the quality score is not less than the preset score threshold, and the initial answer is taken as the target answer.
2. The method of claim 1, wherein, The entity relationship extraction based on the document information of the government document to obtain the entity, relationship and text key-value pair corresponding to the government document comprises: The document information of the government document is cut to obtain a plurality of text cuts; For each text cut, a large language model is used to identify entities and relationships from the text cut; For each entity, the entity is taken as a key, and the related content of the entity in the text cut is taken as a value to generate a text key-value pair corresponding to the entity; For each relationship, the relationship and the entities constituting the relationship are taken as keys, and the related content of the relationship in the text cut is taken as a value to generate a text key-value pair corresponding to the relationship.
3. The method of claim 2, wherein, The construction of a government knowledge graph based on the entity, relationship and text key-value pair corresponding to each government document comprises: Based on the text key-value pair corresponding to each government document, the text key-value pair is preprocessed to obtain a target key-value pair; Based on the entities in each government document, nodes are created, and based on the relationships in each government document, edges are created; The nodes and edges are connected based on the target key-value pairs corresponding to each government document, and attributes are added to the nodes and edges respectively, to generate the government knowledge graph, the attributes indicating values corresponding to the nodes or values corresponding to the edges.
4. The method of claim 1, wherein, The query answer of the user query statement is generated based on the type of the user query statement and the government knowledge graph by using a retrieval enhancement technique, including: In a case where the type of the user query statement is a concept type, a large language model is used to identify a query entity from the user query statement; The query entity is converted into a first query vector, and at least one first target vector with a similarity greater than a preset similarity threshold to the first query vector is determined from the vector database; Based on the at least one first target vector, a corresponding first target node, a first target edge and a first adjacent node are determined from the government knowledge graph, the first target edge indicating an edge directly connected to the first target node, and the first adjacent node indicating another node directly connected to the first target edge; Based on the attributes of the first target node, the attributes of the first adjacent node, the first target edge and the attributes of the first target edge, a large language model is used to generate a query answer of the user query statement.
5. The method of claim 1, wherein, The query answer of the user query statement is generated based on the type of the user query statement and the government knowledge graph by using a retrieval enhancement technique, including: In a case where the type of the user query statement is a concept type, a large language model is used to identify a query entity from the user query statement; The query entity is converted into a first query vector, and at least one first target vector with a similarity greater than a preset similarity threshold to the first query vector is determined from the vector database; Based on the at least one first target vector, a corresponding first target node, a first target edge and a first adjacent node are determined from the government knowledge graph, the first target edge indicating an edge directly connected to the first target node, and the first adjacent node indicating another node directly connected to the first target edge; Based on the attributes of the first target node, the attributes of the first adjacent node, the first target edge and the attributes of the first target edge, a large language model is used to generate a query answer of the user query statement. The query answer of the user query statement is generated based on the type of the user query statement and the government knowledge graph by using a retrieval enhancement technique, including:
6. The method of claim 1, wherein, In a case where the type of the user query statement is a concept type, a large language model is used to identify a query entity from the user query statement; The query entity is converted into a first query vector, and at least one first target vector with a similarity greater than a preset similarity threshold to the first query vector is determined from the vector database; Based on the at least one first target vector, a corresponding first target node, a first target edge and a first adjacent node are determined from the government knowledge graph, the first target edge indicating an edge directly connected to the first target node, and the first adjacent node indicating another node directly connected to the first target edge; Based on the attributes of the first target node, the attributes of the first adjacent node, the first target edge and the attributes of the first target edge, a large language model is used to generate a query answer of the user query statement. The query answer of the user query statement is generated based on the type of the user query statement and the government knowledge graph by using a retrieval enhancement technique, including:
7. The method of claim 1, wherein, In a case where the type of the user query statement is a concept type, a large language model is used to identify a query entity from the user query statement; The query entity is converted into a first query vector, and at least one first target vector with a similarity greater than a preset similarity threshold to the first query vector is determined from the vector database; Based on the at least one first target vector, a corresponding first target node, a first target edge and a first adjacent node are determined from the government knowledge graph, the first target edge indicating an edge directly connected to the first target node, and the first adjacent node indicating another node directly connected to the first target edge; Based on the attributes of the first target node, the attributes of the first adjacent node, the first target edge and the attributes of the first target edge, a large language model is used to generate a query answer of the user query statement. The query answer of the user query statement is generated based on the type of the user query statement and the government knowledge graph by using a retrieval enhancement technique, including: In a case where the type of the user query statement is a concept type, a large language model is used to identify a query entity from the user query statement; The query entity is converted into a first query vector, and at least one first target vector with a similarity greater than a preset similarity threshold to the first query vector is determined from the vector database; Based on the at least one first target vector, a corresponding first target node, a first target edge and a first adjacent node are determined from the government knowledge graph, the first target edge indicating an edge directly connected to the first target node, and the first adjacent node indicating another node directly connected to the first target edge; Based on the attributes of the first target node, the attributes of the first adjacent node, the first target edge and the attributes of the first target edge, a large language model is used to generate a query answer of the user query statement. The text information and the multi-modal information are preprocessed to obtain preprocessed text information and multi-modal information; The metadata, the preprocessed text information and the multi-modal information are respectively converted into vectors by using a large language model; A fusion layer is used to perform feature fusion on the plurality of vectors to obtain a fusion vector; The fusion vector is decoded to obtain document information of the government document.
8. A government affair question and answer system based on a knowledge graph and retrieval enhancement, characterized in that, The system comprises: A document information processing module configured to, for each government document, perform information extraction on the government document to obtain text information, multi-modal information and metadata, and fuse the text information, the multi-modal information and the metadata to obtain document information of the government document; A knowledge graph construction module configured to perform entity relationship extraction based on the document information of the government document to obtain entities, relationships and text key-value pairs corresponding to the government document, and construct a government knowledge graph based on the entities, relationships and text key-value pairs corresponding to each government document; A content query and generation module configured to, for each node in the government knowledge graph, construct a vector corresponding to the node based on node attributes of the node, edges and nodes directly connected to the node and attributes of the nodes; The content query and generation module is further configured to construct a vector database based on the vectors corresponding to all nodes; The content query and generation module is further configured to use a large language model to generate a query answer to a user query statement based on a type of the user query statement and the government knowledge graph by using retrieval enhancement technology; A data quality control module configured to optimize the query answer to the user query statement to generate a target answer to the user query statement; The data quality control module is specifically configured to: perform rule filtering and model filtering on the query answer to obtain an initial answer, the rule filtering comprising length rule filtering and sensitive word library filtering, and the model filtering comprising question relevance filtering and answer accuracy filtering; score the initial answer by using a large language model to obtain a quality score; in a case where the quality score is greater than a preset score threshold, take the initial answer as the target answer; or in a case where the quality score is not greater than the preset score threshold, take the initial answer as a new query answer, return to the step of performing rule filtering and model filtering on the query answer to obtain an initial answer, and repeat until the quality score is not less than the preset score threshold and the initial answer is taken as the target answer.
Citation Information
Patent Citations
Government affair service field multi-strategy fusion dialogue method based on knowledge graph
CN116628172A
System and method for extracting project information based on multi-modal large model
CN119739907A