Knowledge question-answering method and system based on large language model and semantic abstract

By constructing a dual-channel knowledge representation system based on a large language model and semantic summarization, generating a multi-level semantic summarization tree and performing hybrid retrieval, the problems of accuracy and structure recognition in retrieval systems for long documents are solved, and high-quality knowledge question answering is achieved.

CN121858703APending Publication Date: 2026-04-14NANJING SCIYON AUTOMATION GRP
View PDF 0 Cites 2 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
NANJING SCIYON AUTOMATION GRP
Filing Date
2025-12-31
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

Traditional RAG intelligent question answering systems cannot effectively retrieve relationships between document fragments in long documents, resulting in inaccurate answers. Furthermore, they cannot recognize the directory structure, making it difficult to extract the main idea of ​​the article and generate multi-level semantic summary trees.

Method used

We employ a method based on large language models and semantic summarization to construct a dual-channel knowledge representation system consisting of "semantic summary knowledge blocks" and "detailed knowledge blocks." We generate multi-level semantic summary trees through document parsing and perform fine-grained fact retrieval. By combining the hybrid retrieval scores of semantic and detailed knowledge blocks, we achieve accurate understanding and high-quality answers.

Benefits of technology

It significantly improves the accuracy and intelligence of the question-answering system, enabling simultaneous perception of global knowledge and precise extraction of local fine-grained knowledge. It solves the limitations of retrieval systems in long documents and provides structured knowledge blocks to ensure the accuracy of answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121858703A_ABST
    Figure CN121858703A_ABST
Patent Text Reader

Abstract

The invention discloses a knowledge question-answering method and system based on a large language model and a semantic abstract. The system comprises a tree structure abstract generation subsystem which comprises a knowledge base configuration module, a file management module, a document analysis module and a knowledge block management module and is used for automatically generating tree structure hierarchical knowledge blocks for large manual documents or multi-chapter manual documents; the dual-channel retrieval engine subsystem comprises a question rewriting module, a semantic abstract retrieval module, a detail knowledge block retrieval module, a father-son retrieval module and a prompt word construction module, and all the modules work cooperatively to ensure that semantic abstract knowledge blocks and detail knowledge blocks related to the question of the user are retrieved. According to the method, by introducing the semantic abstract based on the tree structure and the two-channel retrieval, perception of global knowledge and accurate extraction of local fine-grained knowledge can be achieved at the same time, and then the ability of a knowledge base question-answering system in processing the general and inductive problems is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of retrieval enhancement generation (RAG) for artificial intelligence question answering, and more specifically, to a knowledge question answering method and system based on large language models and semantic summarization. Background Technology

[0002] Traditional RAG intelligent question answering systems typically divide documents into chunks based on a fixed number of tokens (e.g., 512 tokens) or automatically segment paragraphs using semantic models. While this fixed or semantic chunking can meet the needs of specific business scenarios, it also introduces many limitations and challenges.

[0003] First, because long documents are lengthy and each chapter contains multiple sub-chapter sections, if they are stored in the database using fixed or semantic chunks, when a user enters a question for querying, the retrieval mechanism can only retrieve document fragments similar to the user's question, but cannot retrieve the relationships between the document fragments. Finally, when these fragmented document fragments are input into a large model, the lack of logical relationships between them prevents the large language model from providing accurate answers, and the answers provided are unlikely to truly solve the user's actual query.

[0004] Secondly, when users search for the table of contents or main idea of ​​a long document manual, the table of contents of long documents is often long and often spans multiple pages. Furthermore, existing retrieval systems cannot recognize the table of contents structure (retrieval is based solely on text and does not involve extracting the document structure). Therefore, how to extract the main idea and hierarchical structure of the article from the long document and generate a multi-level semantic summary tree has become a major challenge for existing retrieval systems. Summary of the Invention

[0005] The purpose of this invention is to address the shortcomings of existing technologies and provide a knowledge question answering method and system based on a large language model and semantic summarization. This invention uses retrieval enhancement generation (RAG) as the basic framework and document parsing and knowledge block construction as the core to build a dual-channel knowledge representation system of "semantic summary knowledge blocks" and "detailed knowledge blocks" to achieve accurate understanding and high-quality answers to user questions.

[0006] The technical solution provided by this invention is as follows:

[0007] A knowledge question answering method based on large language models and semantic summarization includes the following steps:

[0008] (1) Create a knowledge base and store basic knowledge base information in a MySQL database; basic knowledge base information includes knowledge base name, knowledge base description, embedding model, and parsing strategy;

[0009] (2) Upload and add long document manuals to the knowledge base, segment the document according to the parsing strategy, and generate semantic summary knowledge blocks and detailed knowledge blocks;

[0010] The parsing strategy is as follows:

[0011] Based on the hierarchical structure in the original document structure, obtain the information of each title node in the document, mark the information of the smallest level title node as a leaf node, and obtain the parent node of each level.

[0012] The large model is invoked to generate a unit semantic summary knowledge block for each node information, and the semantic summary information of all child nodes under the parent node is obtained according to the parent node ID information. The information is then aggregated layer by layer upwards to finally form a multi-level semantic summary tree covering the entire text. Among them, the leaf node semantic summary knowledge block is the content summary of each node in the original document, and the root node semantic summary knowledge block is the full text summary.

[0013] Within the same semantic level, the original text content of the document is segmented according to line breaks and categorized according to the number of 512 tokens to form detailed knowledge blocks, which are used to support fine-grained fact retrieval. Each detailed knowledge block establishes a parent-child mapping relationship with its corresponding semantic summary knowledge block for downstream parent-child retrieval.

[0014] The semantic summary knowledge blocks and detailed knowledge blocks are vectorized into one-dimensional vector data using an embedding model, and the semantic summary knowledge blocks and detailed knowledge blocks are segmented into text using the HanLP word segmenter. The vector data and the segmented text are stored in the ElasticSearch database.

[0015] (3) User query intent recognition: The big model is called to determine the topic and semantic completeness of the latest query and historical dialogue records; when the semantics are incomplete, missing element analysis is performed and natural language is generated and sent to the user to complete the user query until the semantics are complete;

[0016] (4) After determining the semantic completeness, HanLP is used to segment the user question, and the user question is converted into vector data through the embedding model. Then, ElasticSearch is used to perform two-way retrieval on the user question, including semantic summary block retrieval and detailed knowledge block retrieval.

[0017] (5) Merge the search results, combining the retrieved detailed knowledge blocks D={ ... } and the retrieved semantic summary knowledge block S={ ... The following fusion process is performed:

[0018] Based on each detailed knowledge block Based on the mapping relationship established with the upstream, find the corresponding parent semantic summary knowledge block. This allows us to obtain the direct child nodes corresponding to each semantic summary knowledge block. ;

[0019] Detailed knowledge blocks are obtained by calculating using a hybrid retrieval scoring formula. Mixed search score Semantic summarization knowledge block Mixed search score and the corresponding parent semantic summary knowledge block Mixed search score Detailed knowledge blocks are obtained based on the mixed search scores. and semantic summary knowledge blocks Fusion score and ;

[0020] The formula for calculating the hybrid retrieval score is as follows:

[0021]

[0022] In the formula, Representing knowledge blocks The hybrid retrieval score includes knowledge blocks that consist of detailed knowledge blocks and semantic summary knowledge blocks. The text score is calculated through text segmentation. This is achieved by calculating the vector similarity score between the user's question vector and the knowledge block vector, which includes detailed knowledge block vectors and semantic summary knowledge block vectors.

[0023] According to the fusion score and The detailed knowledge blocks and semantic summary knowledge blocks are sorted. For each high-scoring semantic summary knowledge block, all the retrieved detailed knowledge blocks under it are obtained to form a fused multi-granularity knowledge unit, and the output is an ordered sequence of knowledge blocks.

[0024] (6) Prompt word construction stage: In the prompt word construction stage, the fused multi-granularity knowledge units are injected into the context window according to the three-level priority strategy of "document-semantic summary-text content".

[0025] In the above steps, the semantic summary knowledge block represents a summary of all relevant content for each node; the detail knowledge block represents the text content at the lowest level in the original document.

[0026] More specifically, this invention provides a knowledge question answering method based on large language models and semantic summarization, with the following specific steps:

[0027] 1) Users create knowledge bases through the front-end interface and store basic knowledge base information in a MySQL database;

[0028] Furthermore, the basic information of the knowledge base configuration module includes: knowledge base name, knowledge base description, embedding model, and parsing strategy; wherein, when the parsing strategy method is manual parsing (default method), the multi-level semantic summary generation algorithm of this invention is adopted.

[0029] 2) Users upload and add long document manuals through the file management section of the knowledge base via the front-end interface, and click to start parsing. The document is segmented according to the parsing strategy of this invention.

[0030] The specific methods for splitting a document are as follows:

[0031] Based on the hierarchical structure of the original document structure (such as PDF, WORD, Markdown, etc.), information about each title node and its parent node in the document is obtained, and a table of contents hierarchical knowledge block is generated.

[0032] The large model is invoked to generate a unit semantic summary for each node (including all child nodes and parent nodes), and the semantic summary information of all child nodes under the parent node is obtained according to the parent node ID information. The summaries are then aggregated layer by layer upwards to form a multi-level semantic summary tree covering the entire text. The leaf nodes are the content summaries of each node in the original document, and the root node is the full text summary.

[0033] Within the same semantic level, the original text content information is segmented according to line breaks and categorized according to the number of 512 tokens to form detailed knowledge blocks, which are used to support fine-grained fact retrieval. Each detailed knowledge block establishes a parent-child mapping relationship with its semantic summary for downstream parent-child retrieval.

[0034] The semantic summary knowledge blocks and detailed knowledge blocks are vectorized into one-dimensional vector data using an embedding model. The HanLP word segmenter is then used to segment the semantic summary knowledge blocks and detailed knowledge blocks into words. The vector data and the segmented text are stored in the ElasticSearch database.

[0035] 3) User query intent recognition: Based on historical dialogue records and the latest query, the large model is invoked to determine the topic. If the historical questions and answers in the same context do not belong to the same topic, the current question is recorded as a new question. Further, it is determined whether the user's question is semantically complete. If the user's question does not meet the basic field information of the predefined knowledge base slot, i.e., it is semantically incomplete, the missing element analysis is performed based on the predefined knowledge base slot information, and natural language is generated and sent to the user to complete the user's query until the knowledge base slot requirements are met, at which point downstream tasks can continue.

[0036] 4) Dual-channel retrieval for knowledge base documents, performing two-way retrieval for user questions;

[0037] Furthermore, HanLP is used to segment user questions and convert them into vector data for Elasticsearch retrieval.

[0038] Furthermore, the two-way search includes:

[0039] Semantic summary blocks are retrieved based on user questions to match high-level semantic intent knowledge block information;

[0040] Additionally, it performs detailed knowledge block retrieval based on user questions to match specific factual details.

[0041] 5) Search result fusion (parent-child search mechanism): The search results from the previous dual-channel search are fused together.

[0042] For D={ ... } Retrieved detailed knowledge blocks and S={ ... The retrieved semantic summary knowledge blocks are merged as follows:

[0043] Based on each detailed knowledge block Based on the mapping relationship established with the upstream, find the corresponding parent semantic summary knowledge block.

[0044] Based on detailed knowledge blocks Mixed search score Semantic summarization knowledge block Mixed search score and the corresponding parent semantic summary knowledge block Mixed search score Get and Fusion score and ;

[0045] According to the fusion score The detailed knowledge blocks and semantic summary knowledge blocks are sorted. For each high-scoring semantic summary knowledge block, all the retrieved detailed knowledge blocks under it are obtained and output as an ordered sequence of knowledge blocks, taking into account both semantic relevance and detail accuracy.

[0046] 6) Prompt word construction stage. In the prompt word construction stage, the fused multi-granularity knowledge units are injected into the context window according to a three-level priority strategy of "document-semantic summary-text content".

[0047] Furthermore, semantic summarization clusters are performed on the retrieved documents. Knowledge blocks with the same document ID are clustered into a logical narrative unit. The semantic summarization knowledge blocks are marked as clusters. Clusters are arranged in narrative flow order, while within a cluster, the original detailed knowledge block paragraph order is strictly maintained and arranged in ascending order to preserve fine-grained causal chains.

[0048] Furthermore, the retrieved documents are compressed and presented at the window level, and the prompts injected into the large LLM model adopt a "summary → detail" hierarchical structure.

[0049] This prompt template can provide both "macro-level arguments" and "micro-level evidence" within a limited context length, significantly improving the consistency and traceability of the generated answers.

[0050] 7) Knowledge Base Question Answering Module. This module encapsulates the question-and-answer process in a unified, pluggable architecture, supporting the following advanced configurations:

[0051] Furthermore, a multi-model backend dynamic routing approach is adopted to manage large models that can register remote API endpoints, such as OpenAI GPT-4 and Zhipu GLM-4. Rate limiting is supported in two ways: the number of requests per minute and the number of tokens requested per minute. The local inference engine supports launching large models using methods such as vLLM, Transformer, and llama.cpp. At runtime, administrators can manually select the optimal large model based on problem complexity and cost strategies, achieving seamless switching.

[0052] Furthermore, the knowledge base-level multi-tenant isolation binds each question-and-answer session to a triplet, supporting whitelists, IP range restrictions, and user information verification.

[0053] Furthermore, a "Deep Thinking" toggle button is introduced. When off, the latency is less than 800 ms, suitable for high-frequency customer service scenarios; when on, the large model will engage in deep thinking, significantly reducing the illusion rate, and users can choose to turn it on or off.

[0054] 8) Dynamically expand knowledge blocks. Based on user feedback, administrators can enhance search performance by manually modifying parsed knowledge blocks or adding new ones.

[0055] In the above invention, the database supports MySQL, Minio, ElasticSearch, and Redis databases.

[0056] In the above invention, the memory queue is a Java LinkedBlockingQueue blocking queue.

[0057] This invention also provides a knowledge question answering system based on a large language model and semantic summarization, including a tree-structured summarization generation subsystem and a dual-channel retrieval engine subsystem;

[0058] 1) The tree structure summary generation subsystem consists of four modules, including:

[0059] a. Knowledge base configuration module, which allows users to create knowledge base names, embedding models and parsing strategies through the front-end interface, and store the configuration information in the database;

[0060] Furthermore, the required fields for the knowledge base configuration module are: knowledge base name, embedded model name, and parsing method rules.

[0061] b. File management module, used by users to upload and manage documents and files through the front-end interface, and store them in the database;

[0062] Furthermore, the file management module binds user-uploaded documents to the knowledge base ID and user ID. When a new document is uploaded, it automatically checks if there is a file with the same name in the user's knowledge base. The user can choose to replace the original file or rename the file according to their needs.

[0063] Furthermore, the default parsing type for the aforementioned file management module is the long document parsing strategy.

[0064] Furthermore, the aforementioned file management module displays the status of each document, such as unparsed, parsed successfully, parsed failed, and parsing progress in real time.

[0065] c. The file parsing module is used by users to start parsing documents through the front-end interface and store the parsed text, images, and tables into the database.

[0066] Furthermore, the file parsing module implementation steps are as follows:

[0067] Step S1: Based on the chapter and title styles of the source document text, recursively obtain the smallest level title and content of each chapter and mark them as leaf nodes, and at the same time obtain the parent node of each level;

[0068] Step S2: Call the large language model to generate semantic summary knowledge blocks for the text content of all leaf nodes; if a parent node contains several leaf nodes, then based on the semantic summaries of all leaf nodes, call the large language model again to generate the semantic summary of the parent node, and use this as the semantic summary knowledge block of the parent node; if the number of tokens after merging the semantic summaries of all leaf nodes exceeds the context length of the large model (16384), then summarize the adjacent semantic summaries iteratively, and require that the number of tokens in the newly generated summary is less than 512, and form the semantic summary information of the parent node one by one; if the parent node is also a child node of other nodes, then continue to recursively generate the semantic summary knowledge block of the grandparent node until the title node, and finally generate the overall summary of the document;

[0069] Step S3: Perform fine-grained segmentation of the smallest chapter text content. In order to maintain semantic integrity, this paper uses line break characters as the basis for subdivision. After a line break, N paragraphs are obtained.

[0070] Step S3.1: Starting from the first paragraph, calculate whether the number of tokens in each paragraph exceeds 512. If the number of tokens in all paragraphs does not exceed 512, use the first paragraph plus the next paragraph to determine whether the number of the two merged paragraphs exceeds 512. If not, try to add the next paragraph to calculate the number of tokens until the number of tokens in the merged text exceeds 512. Then, store the previously merged paragraphs in the ElasticSearch database and continue to merge paragraphs downwards from the latest paragraph as the starting point to ensure that the number of tokens in every piece of data stored in the database is within 512, so as to avoid exceeding the input length of the embedding model.

[0071] Step S3.2: If the number of text tokens in a paragraph exceeds 512, then further subdivide the paragraph according to punctuation marks (period, exclamation mark, question mark, comma in order), divide the paragraph into semantically complete sentences, and start from the first sentence to judge the number of tokens, iterate through and calculate whether the size of the merged sentence tokens exceeds 512, until the entire paragraph is traversed, and store the text in the ES database.

[0072] Step S3.3: If some paragraphs contain images and tables, for images, the images need to be stored in the Minio database, and the address of the image stored in Minio should be used to replace the original image information. For table information, the table information needs to be represented in HTML form, and both the URL address returned by the image and the HTML form of the table will be stored in the ES database as text information. The segmentation strategy is the same as in S3.1 and S3.2. Finally, in order to ensure the integrity of the table structure, the table style will not be split to avoid destroying the original semantics of the table.

[0073] d. Knowledge block management module, which allows users to modify or add knowledge blocks after parsing through the front-end interface and store them in the database of the corresponding document;

[0074] Furthermore, the knowledge block management module supports modifying parsed document knowledge blocks and adding new document knowledge blocks, which are then stored in the database.

[0075] Furthermore, the images of the knowledge blocks are synchronously mapped to the Minio database.

[0076] Furthermore, the text information of the knowledge block is synchronized to the ElasticSearch database.

[0077] 2) The dual-channel retrieval engine subsystem rewrites user queries into semantically complete query statements for retrieval of the knowledge base. It uses semantic summary knowledge blocks to retrieve overview text information from relevant chapters and detail knowledge blocks to retrieve fine-grained text information from long documents. Based on parent-child node IDs, it constructs the overview text information and corresponding fine-grained text information into a semantically cohesive structure, ensuring that the retrieved text information follows a hierarchical structure of "summary → detail". The dual-channel retrieval engine subsystem consists of five modules, including:

[0078] e. The issue rewriting module is used to monitor whether the semantics of user issues are complete and to improve user issues according to a predefined slot matching mechanism;

[0079] Furthermore, the issue rewriting module maps user issues to predefined slots, checks the completeness of user issues, and if necessary slot elements are missing, it prompts the user with missing information through the large model, thus reminding them to complete the user issue. The complete user issue is then stored in a MySQL database.

[0080] f. Semantic summary retrieval module, which matches high-level semantic information such as chapter directory structure, chapter main content, and entity relationships between different chapters based on user questions;

[0081] The semantic summary retrieval module performs hybrid retrieval based on the completed user question. It is used not only to retrieve organizational structure information related to the chapter theme, chapter table of contents structure, and chapter entities, but also to query fine-grained content information of documents that are strongly related to the user question.

[0082] g. Detailed knowledge retrieval module: Matches detailed document fragments that are highly relevant to the user's question;

[0083] h. The parent-child retrieval module is used to organize and construct the hierarchical relationship between semantic summary knowledge blocks and document detail knowledge blocks. Furthermore, based on the acquired semantic summary knowledge blocks and detail knowledge blocks, the parent-child retrieval module performs a novel score calculation for the detail knowledge blocks and semantic summary knowledge blocks through relationship mapping. Fusion score The calculation formula is as follows:

[0084]

[0085] In the formula, The score is based on the integration of detailed knowledge blocks. The score is for mixed retrieval of detailed knowledge blocks. The combined retrieval score for the parent semantic summary knowledge block corresponding to the detailed knowledge block;

[0086] Semantic summarization knowledge blocks Fusion score The calculation formula is as follows:

[0087]

[0088] In the formula, The fusion score for semantic summary knowledge blocks. Direct child nodes of semantic summary knowledge blocks The mixed retrieval score for (detailed knowledge blocks), where m represents the number of detailed knowledge blocks in the search results that have a direct parent-child relationship with the semantic summary knowledge block. The mixed retrieval score is the parent semantic summary knowledge block of the semantic summary knowledge block (the parent semantic summary knowledge block of the semantic summary knowledge block can be obtained through the semantic summary tree structure).

[0089] Furthermore, the detailed knowledge blocks and semantic summary knowledge blocks are sorted in descending order according to the fusion score, and an ordered sequence of knowledge blocks is output, taking into account both semantic relevance and detailed accuracy.

[0090] Furthermore, based on the document ID and the mapping relationship between tree structure nodes, the semantic summary information and detailed knowledge block information of the same document are unified into an organized document source.

[0091] i. Prompt word construction module: The large language model must answer based on the documents returned by the parent and child retrieval modules, and the large model is restricted from answering based on existing knowledge;

[0092] Furthermore, when the text information in the knowledge base is empty, it is explicitly required to return "No relevant information found in the knowledge base".

[0093] The present invention has the following advantages over the prior art:

[0094] This invention introduces tree-based semantic summarization, a dual-channel retrieval strategy, and scalable knowledge blocks, enabling the retrieval system to simultaneously perceive global knowledge and accurately extract fine-grained local knowledge. This significantly improves the performance, reliability, and intelligence of traditional retrieval methods, providing more accurate, complete, and structured knowledge blocks for knowledge base question-answering systems to ensure the accuracy of question answers.

[0095] Specifically, this is reflected in:

[0096] a. Tree-structured summary generation: Based on the original chapter structure of the document, sub-document summaries are generated for the smallest chapter content, and parent document summaries are recursively generated for the upper-level chapters from bottom to top. Finally, a full-text summary is generated for the entire document, and the document structure directory is obtained. During the parsing of long documents, the text content at the same level is divided according to a fixed number of tokens. The final parsed content should include: the original document directory structure, the tree-structured summary document, and detailed knowledge blocks.

[0097] b. Dual-channel retrieval strategy: Through semantic summary retrieval and detailed knowledge block retrieval, it can match high-level semantic document summary information and actual fine-grained document fact information respectively. It dynamically obtains the document structure and content according to the user's query question, which overcomes the problems of users asking questions of chapter overview or classification nature and questions of inter-chapter comparison nature, and solves the problem of the limitations of the current retrieval mechanism itself.

[0098] c. Scalable knowledge blocks: The knowledge base question-answering system designed in this invention can flexibly adapt to the needs of different question-answering environments, and knowledge blocks can be added or modified at any time according to the actual needs of users. Attached Figure Description

[0099] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0100] Figure 1This is a schematic diagram of a knowledge question answering system based on a large language model and semantic summarization.

[0101] Figure 2 for Figure 1 A flowchart illustrating the knowledge block management process in the knowledge block management module;

[0102] Figure 3 for Figure 1 A flowchart illustrating the document parsing process of the Chinese document parsing module;

[0103] Figure 4 for Figure 1 A schematic diagram illustrating the semantic summarization construction process of the Chinese document parsing module;

[0104] Figure 5 for Figure 1 A diagram illustrating the implementation steps of the problem rewriting module;

[0105] Figure 6 This is a schematic diagram of the dual-channel retrieval process used in this invention;

[0106] Figure 7 for Figure 1 A schematic diagram illustrating the implementation steps of the parent-child retrieval module;

[0107] Figure 8 for Figure 1 A schematic diagram illustrating the implementation steps of the prompt word construction module. Detailed Implementation

[0108] The technical solution of the present invention will be further described in detail below through specific embodiments.

[0109] like Figure 1 As shown, this invention provides a logical diagram of a knowledge question answering system based on a large language model and semantic summarization, comprising a tree-structured summarization generation subsystem and a dual-channel retrieval engine subsystem. The tree-structured summarization generation subsystem consists of four modules: a knowledge base configuration module, a file management module, a file parsing module, and a knowledge block management module. The dual-channel retrieval engine subsystem consists of five modules: a question rewriting module, a semantic summarization retrieval module, a detailed knowledge retrieval module, a parent-child retrieval module, and a prompt word construction module.

[0110] The specific implementation steps are as follows:

[0111] like Figure 2As shown, the implementation steps of knowledge block management are as follows: Users can upload, parse, and delete documents in the file management module within the knowledge base module. After document parsing is complete, users can click on the parsed document to enter the knowledge block management module. In the knowledge block management module interface, the left side displays the parsed knowledge blocks, and the right side shows a document preview. The parsed knowledge block content on the left is sorted sequentially according to the document's order, with the document summary and table of contents displayed at the end. Users can double-click on a knowledge block to modify it. After modifying the content, clicking "confirm" will delete the old knowledge block and store the modified or newly added knowledge block in the ES database. Simultaneously, the old knowledge block in the database will be deleted, and images in the modified knowledge block will be synchronized to the Minio database.

[0112] like Figure 3 As shown, the document parsing implementation steps are as follows: The file management module periodically monitors parsing tasks started by users. If a user uploads a new document and starts a parsing task, the started parsing file is added to the message queue. Files are retrieved from the queue sequentially, and attempts are made to acquire a Redis distributed lock for further parsing. If the document has already been marked as successfully parsed, the current parsing is skipped; otherwise, the tree summary generation parsing method described in this paper is used to process the document. When parsing fails, an automatic retry and maximum retry protection mechanism is triggered. If parsing still fails, the status of the failed files is uniformly and persistently stored in the Redis hash key Minio:pdf_failures; if parsing succeeds, the document is recorded as successfully parsed. Finally, the Redis distributed lock is released, and the parsing status is returned to the frontend, and the system continues to poll for new parsing tasks.

[0113] like Figure 4 As shown, in the document parsing module, for long document types such as manuals and operation instructions, the tree-structured summary generation method described in this paper generates the document's directory structure information based on the original document's title identifier. Simultaneously, a large language model is invoked to generate summaries for the content of each minimum node (chapter). For non-minimum nodes (chapter), their child node IDs and parent node IDs are obtained, and the semantic summary content of all their child nodes is merged before the large model is invoked again for refinement and summarization. If the number of semantic summary tokens for the merged child nodes exceeds the context length of the large model (16384), adjacent semantic summaries are summarized iteratively, requiring the number of tokens in the newly generated summary to be less than 512. This process is repeated to generate the semantic summary information for each parent node sequentially, up to the highest level (title or document) semantic summary information.

[0114] Meanwhile, the natural language text content in the original document is segmented in a fine-grained manner. First, the text under the smallest chapter is divided into paragraphs, and it is determined whether the number of tokens in each paragraph exceeds 512. If not, the next paragraph is merged. The number of tokens in the merged paragraph is then determined whether it exceeds 512. If not, the merging continues until it exceeds 512 tokens. Then, the content of the previously merged paragraphs is stored in the ElasticSearch database, and the current position is used as the new starting point to continue merging paragraphs until all paragraph content is stored in the ElasticSearch database.

[0115] If a paragraph contains more than 512 tokens, the paragraph is divided into periods, question marks, and exclamation marks. The number of tokens in a single sentence is then determined. If the number of tokens in a single sentence does not exceed 512, the next sentence is merged. This process continues until the number of tokens exceeds 512. At this point, the previously merged sentences are stored in the Elasticsearch database, and the current position is used as the new starting point to continue merging sentences downwards until all sentence content is stored in the Elasticsearch database, thus completing the fine-grained partitioning of the document.

[0116] like Figure 5 As shown, the implementation steps of the question rewriting module are as follows: First, based on the user's historical dialogue information, latest query question information, and predefined key slot information, the large language model is invoked to perform intent recognition on the user's latest query question. If the user's question is incomplete, the large model is instructed to complete the latest user question based on the user's historical question and answer information, and to match the latest user question with the predefined slots. If the basic slot information is satisfied, the user question is sent to the downstream semantic summary retrieval and detailed knowledge block retrieval. Otherwise, based on historical information and the latest query question, possible questions for the user to consult are recommended in a human-computer interaction manner. If the user clicks on a recommended question, the recommended question is sent downstream as the user's latest question. If the user re-enters the question, the large model is invoked again to perform intent recognition and slot filling until all key slot information is filled, completing the question rewriting step.

[0117] like Figure 6As shown, the implementation steps for semantic summary retrieval and detailed knowledge retrieval are as follows: Based on the complete user question, the question is first segmented using HanLp, and combined with predefined business terms and synonyms to ensure that business terms and synonyms are not split. Then, a BM25 keyword search is performed on the ElasticSearch database. Simultaneously, the user is vectorized, and vector similarity retrieval is performed. The scores from the keyword and vector searches are summed and used as the scores for the semantic summary knowledge block and the detailed knowledge block, respectively. A re-ranking model is then used to re-score the retrieved content and the user question, removing document information with low thresholds.

[0118] like Figure 7 As shown, the implementation steps of the parent-child retrieval module are as follows: Based on the knowledge blocks returned by semantic summary retrieval and detailed knowledge retrieval, the semantic and detailed knowledge blocks are first classified according to their knowledge block IDs to ensure that semantic and detailed knowledge blocks of the same document are grouped into the same category. Then, the detailed knowledge blocks and semantic summary knowledge blocks are merged, and the average score of the semantic summary and its associated detailed knowledge blocks is calculated as the final score. The score calculation process is as follows: Through relation mapping, the fusion score of detailed knowledge blocks and semantic summary knowledge blocks is calculated, where the detailed knowledge blocks... Fusion score The calculation formula is as follows:

[0119]

[0120] In the formula, The score is based on the integration of detailed knowledge blocks. The score is for mixed retrieval of detailed knowledge blocks. The hybrid retrieval score for the parent semantic summary knowledge block of the detailed knowledge block;

[0121] Semantic summarization knowledge blocks Fusion score The calculation formula is as follows:

[0122]

[0123] In the formula, The fusion score for semantic summary knowledge blocks. Direct child nodes of semantic summary knowledge blocks The mixed retrieval score for (detailed knowledge blocks), where m represents the number of detailed knowledge blocks in the search results that have a direct parent-child relationship with the semantic summary knowledge block. The combined retrieval score for the parent semantic summary knowledge block of the semantic summary knowledge block;

[0124] The formula for calculating the above hybrid retrieval score is as follows:

[0125]

[0126] In the formula, Representing knowledge blocks The hybrid retrieval score includes knowledge blocks that consist of detailed knowledge blocks and semantic summary knowledge blocks. The text score is calculated through text segmentation. This is achieved by calculating the vector similarity score between the user's question vector and the knowledge block vector, which includes detailed knowledge block vectors and semantic summary knowledge block vectors.

[0127] Finally, a hierarchical knowledge block structure is constructed based on the fusion score. The top layer is the document title, the second layer is semantic summary information, and the third layer is fine-grained document information.

[0128] like Figure 8 As shown, the implementation steps of the prompt word construction module (i.e., the illustrated prompt word module) are as follows: The standard large language model must answer based on the hierarchical document knowledge after parent-child retrieval. It is strictly prohibited for the large model to answer based on existing knowledge. In addition, the system prompt words and user prompt words have been strengthened to effectively prevent prompt injection attacks.

[0129] The above description is only a preferred embodiment of the present invention. It should be noted that those skilled in the art can make several improvements without departing from the principle of the present invention, and these improvements should also be considered within the scope of protection of the present invention.

Claims

1. A knowledge question answering method based on large language models and semantic summarization, characterized in that, Includes the following steps: (1) Create a knowledge base and store basic knowledge base information in a MySQL database; the basic knowledge base information includes knowledge base name, knowledge base description, embedding model, and parsing strategy; (2) Upload and add long document manuals to the knowledge base, segment the documents according to the parsing strategy, and generate semantic summary knowledge blocks and detailed knowledge blocks; The parsing strategy is as follows: Based on the hierarchical structure in the original document structure, obtain the information of each title node in the document, mark the information of the smallest level title node as a leaf node, and obtain the parent node of each level. The large model is invoked to generate a unit semantic summary knowledge block for each node information, and the semantic summary information of all child nodes under the parent node is obtained according to the parent node ID information. The information is then aggregated layer by layer upwards to finally form a multi-level semantic summary tree covering the entire text. Among them, the leaf node semantic summary knowledge block is the content summary of each node in the original document, and the root node semantic summary knowledge block is the full text summary. Within the same semantic level, the original text content of the document is segmented according to line breaks and categorized according to the number of 512 tokens to form detailed knowledge blocks, which are used to support fine-grained fact retrieval. Each detailed knowledge block establishes a parent-child mapping relationship with its corresponding semantic summary knowledge block for downstream parent-child retrieval. The semantic summary knowledge blocks and detailed knowledge blocks are vectorized into one-dimensional vector data using an embedding model, and the semantic summary knowledge blocks and detailed knowledge blocks are segmented into text using the HanLP word segmenter. The vector data and the segmented text are stored in the ElasticSearch database. (3) User query intent recognition: The big model is called to determine the topic and semantic completeness of the latest query and historical dialogue records; when the semantics are incomplete, missing element analysis is performed and natural language is generated and sent to the user to complete the user query until the semantics are complete; (4) After determining the semantic completeness, HanLP is used to segment the user question, and the user question is converted into vector data through the embedding model. Then, ElasticSearch is used to perform two-way retrieval on the user question, including semantic summary block retrieval and detailed knowledge block retrieval. (5) Merge the search results, combining the retrieved detailed knowledge blocks D={ ... } and the retrieved semantic summary knowledge block S={ ... The following fusion process is performed: Based on each detailed knowledge block Based on the mapping relationship established with the upstream, find the corresponding parent semantic summary knowledge block. This allows us to obtain the direct child nodes corresponding to each semantic summary knowledge block. ; Detailed knowledge blocks are obtained by calculating using a hybrid retrieval scoring formula. Mixed search score Semantic summarization knowledge block Mixed search score and the corresponding parent semantic summary knowledge block Mixed search score Detailed knowledge blocks are obtained based on the mixed search scores. and semantic summary knowledge blocks Fusion score and ; The formula for calculating the hybrid retrieval score is as follows: ; In the formula, Representing knowledge blocks The hybrid retrieval score includes knowledge blocks that consist of detailed knowledge blocks and semantic summary knowledge blocks. The text score is calculated through text segmentation. This is achieved by calculating the vector similarity score between the user's question vector and the knowledge block vector, which includes detailed knowledge block vectors and semantic summary knowledge block vectors. According to the fusion score and The detailed knowledge blocks and semantic summary knowledge blocks are sorted. For each high-scoring semantic summary knowledge block, all the retrieved detailed knowledge blocks under it are obtained to form a fused multi-granularity knowledge unit, and the output is an ordered sequence of knowledge blocks. (6) Prompt word construction stage: In the prompt word construction stage, the fused multi-granularity knowledge units are injected into the context window according to the three-level priority strategy, which is: document-semantic summary-text content.

2. The knowledge question-answering method according to claim 1, characterized in that, The parsing strategy in step (2) is as follows: Step S1: Based on the chapter and title styles of the source document text, recursively obtain the smallest level title and content of each chapter and mark them as leaf nodes, and at the same time obtain the parent node of each level; Step S2: Call the large language model to generate semantic summary knowledge blocks for the text content of all leaf nodes; if a parent node contains several leaf nodes, then based on the semantic summaries of all leaf nodes, call the large language model again to generate the semantic summary of the parent node, and use this as the semantic summary knowledge block of the parent node; if the number of tokens after merging the semantic summaries of all leaf nodes exceeds the context length of the large model (16384), then summarize the adjacent semantic summaries iteratively, and require that the number of tokens in the newly generated summary is less than 512, and form the semantic summary information of the parent node one by one; if the parent node is also a child node of other nodes, then continue to recursively generate the semantic summary knowledge block of the grandparent node until the title node, and finally generate the overall summary of the document; Step S3: Divide the text content of the smallest chapter into fine-grained blocks based on line breaks; Step S3.1: Starting from the first paragraph, calculate whether the number of tokens in each paragraph exceeds 512. If the number of tokens in all paragraphs does not exceed 512, use the first paragraph plus the next paragraph to determine whether the number of the two merged paragraphs exceeds 512. If not, try to add the next paragraph to calculate the number of tokens until the number of tokens in the merged text exceeds 512. Then, store the previously merged paragraphs in the ElasticSearch database and continue to merge paragraphs downwards from the latest paragraph as the starting point to ensure that the number of tokens in every piece of data stored in the database is within 512, so as to avoid exceeding the input length of the embedding model. Step S3.2: If the number of text tokens in a paragraph exceeds 512, then subdivide the paragraph according to period, exclamation mark, question mark and comma in turn, divide the paragraph into semantically complete sentences, and start from the first sentence to judge the number of tokens, traverse and calculate whether the size of the merged sentence tokens exceeds 512, until the entire paragraph is traversed, and store the text in the ES database. Step S3.3: If some paragraphs contain images and tables, for images, the images need to be stored in the Minio database, and the address of the image stored in Minio is used to replace the original image information; for table information, the table information needs to be represented in HTML form, and both the URL address returned by the image and the HTML form of the table will be further stored in the ES database as text information, and the segmentation strategies of steps S3.1 and S3.2 will be adopted. Finally, in order to ensure the integrity of the table structure, the table style will not be segmented.

3. The knowledge question-answering method according to claim 2, characterized in that, The specific method for identifying the user's intent in step (3) is as follows: Based on the historical dialogue records and the latest query question, the large model is called to determine the topic. If the historical questions and answers in the same context do not belong to the same topic, the current question is recorded as a new question. Further, it is determined whether the user question is semantically complete. If the user question does not meet the basic field information of the predefined knowledge base slot, it is determined to be semantically incomplete. Then, the missing element analysis is performed in combination with the preset knowledge base slot information, and natural language is generated and sent to the user to complete the user's query question until the knowledge base slot requirements are met.

4. The knowledge question-answering method according to claim 3, characterized in that, In step (4), a fusion score is calculated for the detailed knowledge block and the semantic summary knowledge block, wherein the detailed knowledge block Fusion score The calculation formula is as follows: ; In the formula, The score is based on the integration of detailed knowledge blocks. The score is for mixed retrieval of detailed knowledge blocks. The combined retrieval score for the parent semantic summary knowledge block corresponding to the detailed knowledge block; Semantic summarization knowledge blocks Fusion score The calculation formula is as follows: ; In the formula, The fusion score for semantic summary knowledge blocks. Direct child nodes of semantic summary knowledge blocks The mixed retrieval score, where m represents the number of detailed knowledge blocks in the search results that have a direct parent-child relationship with the semantic summary knowledge block. The combined retrieval score is the score of the parent semantic summary knowledge block corresponding to the semantic summary knowledge block.

5. The knowledge question-answering method according to claim 4, characterized in that, The knowledge question answering method based on large language models and semantic summarization also includes dynamically expanding knowledge blocks: based on user feedback status information, the administrator can manually modify the parsed knowledge blocks or directly add new knowledge blocks.

6. A knowledge question answering system based on a large language model and semantic summarization, characterized in that, It includes a tree-structured summary generation subsystem and a dual-channel retrieval engine subsystem; The tree structure summary generation subsystem includes: a. Knowledge base configuration module, used by users to create knowledge base name, embedding model and parsing strategy through front-end interface, and store configuration information in database; the configuration information includes knowledge base name, embedding model name, and parsing strategy; the parsing strategy is based on the chapter, title and text content of document, obtains node information, calls large model to generate unit semantic summary, and aggregates layer by layer upward to form a multi-level semantic summary tree covering the whole text, performs fine-grained block division of text content within the same semantic level to obtain detailed knowledge blocks, and builds parent-child mapping relationship with the semantic summary to its corresponding semantic summary; b. File management module, used by users to upload and manage documents and files through the front-end interface, and store them in the database; c. The file parsing module is used by users to start parsing documents through the front-end interface and store the parsed text, images, and tables into the database. d. Knowledge block management module, which allows users to modify or add knowledge blocks after parsing through the front-end interface and store them in the database of the corresponding document; The dual-channel retrieval engine subsystem rewrites the user's query into a semantically complete query statement for retrieval of the knowledge base, obtains semantic summary knowledge blocks and detailed knowledge blocks from long documents, and constructs a semantic summary cohesive structure; the dual-channel retrieval engine subsystem includes: e. The issue rewriting module is used to monitor whether the semantics of user issues are complete and to improve user issues according to a predefined slot matching mechanism; f. Semantic summary retrieval module, which matches the improved user question with high-level semantic information such as chapter directory structure, chapter main content, and entity relationships between different chapters; g. Detailed knowledge retrieval module: Matches detailed document fragments that are highly relevant to the user's question; h. The parent-child retrieval module, based on the semantic summary knowledge blocks obtained by the semantic summary retrieval module and the document detail knowledge blocks obtained by the detail knowledge retrieval module, organizes and constructs the hierarchical relationship between the semantic summary knowledge blocks and the document detail knowledge blocks through mapping relationships, and merges and outputs an ordered sequence of knowledge blocks; i. Prompt word construction module: The standard requires the large language model to answer based on the documents returned by the parent and child retrieval modules, restricting the large model from answering based on existing knowledge.

7. The knowledge question answering system based on a large language model and semantic summarization according to claim 6, characterized in that, The file parsing module is implemented in the following steps: Step S1: Based on the chapter and title styles of the source document text, recursively obtain the smallest level title and content of each chapter and mark them as leaf nodes, and at the same time obtain the parent node of each level; Step S2: Call the large language model to generate semantic summary knowledge blocks for the text content of all leaf nodes; if a parent node contains several leaf nodes, then based on the semantic summaries of all leaf nodes, call the large language model again to generate the semantic summary of the parent node, and use this as the semantic summary knowledge block of the parent node; if the number of tokens after merging the semantic summaries of all leaf nodes exceeds the context length of the large model (16384), then summarize the adjacent semantic summaries iteratively, and require that the number of tokens in the newly generated summary is less than 512, and form the semantic summary information of the parent node one by one; if the parent node is also a child node of other nodes, then continue to recursively generate the semantic summary knowledge block of the grandparent node until the title node, and finally generate the overall summary of the document; Step S3: Divide the text content of the smallest chapter into fine-grained blocks based on line breaks: Step S3.1: Starting from the first paragraph, calculate whether the number of tokens in each paragraph exceeds 512. If the number of tokens in all paragraphs does not exceed 512, use the first paragraph plus the next paragraph to determine whether the number of tokens in the merged paragraphs exceeds 512. If not, merge the two paragraphs and try to add the next paragraph to calculate the number of tokens until the number of tokens in the merged text exceeds 512. Then, store the previously merged paragraphs in the ElasticSearch database and continue to merge paragraphs downwards from the latest paragraph as the starting point to ensure that the number of tokens in every piece of data stored in the database is less than 512, so as to avoid exceeding the input length of the embedding model. Step S3.2: If the number of text tokens in a paragraph exceeds 512, then subdivide the paragraph according to period, exclamation mark, question mark, and comma, dividing the paragraph into semantically complete sentences. Starting from the first sentence, check the number of tokens. If it does not exceed 512, use the first sentence plus the next sentence to check if the number of tokens in the merged sentences exceeds 512. Continue in this way, traversing and calculating the size of the merged sentence tokens to see if it exceeds 512, until the number of text tokens in the merged text exceeds 512. Then, store the previously merged sentences in the ElasticSearch database, and continue merging sentences downwards from the latest sentence as the starting point until the entire paragraph is traversed and the text is stored in the ES database. Step S3.3: If some paragraphs contain images and tables, for images, the images need to be stored in the Minio database, and the address of the image stored in Minio should be used to replace the original image information; for table information, the table information needs to be represented in HTML format, and the URL address returned by the image and the HTML format of the table should be stored in the ES database as text information. The segmentation strategies of steps S3.1 and S3.2 should be adopted. Finally, in order to ensure the integrity of the table structure, the table style should not be segmented.

8. The knowledge question answering system based on a large language model and semantic summarization according to claim 7, characterized in that, The file management module binds user-uploaded documents to a knowledge base ID and a user ID. When a new document is uploaded, it automatically checks if there is a file with the same name in the user's knowledge base. The user can choose to replace the existing file or rename the file as needed. The file management module displays the status of each document, including unparsed, parsed successfully, parsed failed, and real-time parsing progress.

9. The knowledge question answering system based on a large language model and semantic summarization according to claim 7, characterized in that, The knowledge block management module synchronously maps the images of knowledge blocks to the Minio database and synchronizes the text information of knowledge blocks to the ElasticSearch database.

10. The knowledge question answering system based on a large language model and semantic summarization according to claim 7, characterized in that, The parent-child retrieval module, based on the semantic summary knowledge blocks obtained by the semantic summary retrieval module and the document detail knowledge blocks obtained by the detail knowledge retrieval module, calculates a fusion score for each detail knowledge block and its corresponding parent semantic summary knowledge block through relation mapping. The detail knowledge blocks and semantic summary knowledge blocks are sorted in descending order according to the fusion score, and an ordered knowledge block sequence is output. At the same time, according to the mapping relationship between the document ID and the tree structure node of the multi-level semantic summary tree, the semantic summary knowledge block information and detail knowledge block information of the same document are unified into an organized document source. The fusion score calculation process is as follows: fusion scores are calculated for detailed knowledge blocks and semantic summary knowledge blocks, wherein the detailed knowledge blocks... Fusion score The calculation formula is as follows: ; In the formula, The score is based on the integration of detailed knowledge blocks. The score is for mixed retrieval of detailed knowledge blocks. The combined retrieval score for the parent semantic summary knowledge block corresponding to the detailed knowledge block; Semantic summarization knowledge blocks Fusion score The calculation formula is as follows: ; In the formula, The fusion score for semantic summary knowledge blocks. Direct child nodes of semantic summary knowledge blocks The mixed retrieval score, where m represents the number of detailed knowledge blocks in the search results that have a direct parent-child relationship with the semantic summary knowledge block. The mixed retrieval score for the parent semantic summary knowledge block of the semantic summary knowledge block.

Citation Information

Cited By

  • Artificial intelligence-based document knowledge tree generation and interactive exploration method and system

    CN122152825A

  • A government affairs field knowledge enhanced Text2SQL framework construction method and system

    CN122221976A