Document knowledge base LLM intelligent question and answer method, device and equipment and storage medium

By dynamically segmenting and vectorizing document knowledge blocks, and combining vector retrieval and keyword retrieval, the problem of insufficient table and image processing in existing document question-and-answer systems is solved, achieving more efficient and secure document information parsing and retrieval.

CN121117147APending Publication Date: 2025-12-12CHINA ELECTRONICS CLOUD DIGITAL INTELLIGENCE TECH CO LTD
View PDF 0 Cites 5 Cited by

Patent Information

Application Number
CN202511133124.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-13
Publication Date
2025-12-12

AI Technical Summary

Technical Problem

Existing document question-answering systems cannot effectively handle tables and images in documents, resulting in problems such as missing semantic understanding, unreasonable segmentation mechanisms, insufficient retrieval accuracy, high update costs, and data security risks.

Method used

The system dynamically segments user-uploaded documents into blocks, vectorizes and indexes these blocks, and integrates vector and keyword search results when receiving natural language questions. It then uses a large language model to generate answers and synchronously updates the vector library and index when documents are updated, thus optimizing the segmentation strategy.

Benefits of technology

It solves the problem of missing information in table images, ensures the integrity of document information parsing, improves multi-hop recall and retrieval accuracy, reduces update costs, improves data security and universality, and enhances the speed and efficiency of intelligent question answering in the document knowledge base LLM.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121117147A_ABST
    Figure CN121117147A_ABST
Patent Text Reader

Abstract

The invention discloses a document knowledge base LLM intelligent question and answer method, device and equipment and a storage medium. The method comprises the steps that dynamic partitioning is conducted on a to-be-processed document, and vectorization and index storage are conducted on knowledge blocks; vector retrieval and keyword retrieval are carried out according to the natural language question, a vector retrieval result and a keyword retrieval result are fused, an answer is obtained through LLM, and the answer is fed back to a user after being safely filtered; when it is detected that the to-be-processed document is updated, the vector library and the index are synchronously updated, and the cue word template and the partitioning strategy are periodically optimized, so that the problem of form picture information loss can be solved, the integrity of document information analysis is guaranteed, the situation that the partitioning strategy is single is avoided, the multi-hop recall rate is increased, and the problem of semantic missing is avoided; a partitioning mechanism is reasonable, retrieval precision is improved, updating cost is reduced, data security is improved, implementation is convenient, universality is good, and the speed and efficiency of LLM intelligent question answering of the document knowledge base are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of document question answering, and in particular to a document knowledge base LLM intelligent question answering method, device, equipment and storage medium. BACKGROUND

[0002] Current document question answering systems mainly adopt three technical routes: Keyword retrieval system: based on Elasticsearch and other search engines, document retrieval is achieved through inverted index.

[0003] Basic retrieval augmented generation (RAG) architecture: combining vector retrieval and generative large models, the core process is document blocking → vector indexing → retrieval → generation.

[0004] Fine-tuned question answering model: using a fine-tuned large model to directly generate answers.

[0005] However, these methods have the following main defects and deficiencies: Document picture table information loss: existing systems cannot effectively process tables and pictures in documents, and the accuracy of optical character recognition (OCR) technology for complex tables is low.

[0006] Keyword retrieval: there is a problem of semantic understanding missing, such as being unable to handle abstract questions such as “What is the reason for the growth of 2023 revenue?”.

[0007] Basic RAG: there are problems of unreasonable blocking mechanism and insufficient retrieval accuracy. For example, there are fixed-length blocking that leads to table cutting and context breaking; and multi-hop problem recall rate <40% (such as “What are the risk factors in A company's 2023 financial report?”).

[0008] Fine-tuned model: the model needs to be retrained when new documents are added, which takes several days or even weeks of time, and the update cost is high.

[0009] Commercial system: there is a problem of data security risks, which requires uploading documents to third-party cloud services.

[0010] General solution: there is a problem of poor domain adaptation, and there is a lack of professional knowledge guidance mechanism for data governance, development, and financial, medical and other fields. SUMMARY

[0011] The main purpose of the present application is to provide a document knowledge base LLM intelligent question answering method, device, equipment and storage medium, aiming at solving the technical problems that the existing document question answering cannot effectively process the tables and pictures in the document, the recognition accuracy of complex tables is low, the keyword retrieval has semantic loss, the block mechanism is unreasonable, the retrieval precision is insufficient, the update cost is high, there are data security risks, and the universality is poor.

[0012] In a first aspect, the present application provides a document knowledge base LLM intelligent question answering method, which comprises the following steps: Receiving a user uploaded to-be-processed document, dynamically blocking the to-be-processed document, and vectorizing and index storing the knowledge block; When a natural language question input by a user is received, vector retrieval and keyword retrieval are performed according to the natural language question, the vector retrieval result and the keyword retrieval result are fused, an answer is obtained through a large language model LLM, and the answer is fed back to the user after being safely filtered; When it is detected that the to-be-processed document is updated, the vector library and the index are synchronously updated, and the prompt word template and the blocking strategy are periodically optimized.

[0013] Optionally, the receiving a user uploaded to-be-processed document, dynamically blocking the to-be-processed document, and vectorizing and index storing the knowledge block comprises: When it is detected that a user uploads a to-be-processed document through a web interface or an API, the to-be-processed document is received; Separating and processing each element in the to-be-processed document, respectively analyzing each separated element, and obtaining analyzed document data; According to the semantic boundary, the document data is knowledge block cut, and the cut target knowledge block is obtained; The text content of the target knowledge block is converted into a vector, and the target knowledge block is stored in a preset elastic search database.

[0014] Optionally, the separating and processing each element in the to-be-processed document, respectively analyzing each separated element, and obtaining analyzed document data comprises: The document format of the to-be-processed document is automatically analyzed, and a matched document parser is selected according to the document format; According to the document parser, the page data in the to-be-processed document is detected, each element is obtained, and each element is separated and processed; The table element in each element is processed for table information, and table data is obtained; A picture OCR processor is called to analyze the picture element in each element, and picture data is obtained; Generate document data according to text data, table data and picture data in the page data.

[0015] Optionally, the table element in each element is subjected to table information processing to obtain table data, including: The table structure, table header and row and column information of the table element in each element are extracted using the Tabula library; The table structure, table header and row and column information are subjected to structured conversion to obtain table data.

[0016] Optionally, the document data is subjected to knowledge block segmentation according to semantic boundaries to obtain segmented target knowledge blocks, including: The sentence text in the document data is converted into sentence vectors using a Sentence Transformers model, the cosine similarity of adjacent sentence vectors is calculated, and the cosine similarity is taken as a semantic similarity; The similarity is compared with a preset breakpoint threshold, forced segmentation is performed when the similarity is less than the preset breakpoint threshold, and secondary segmentation or merging is performed according to a knowledge block size to ensure that each knowledge block after segmentation is within a preset block size range; Text in the document data that is not segmented by a sentence boundary is segmented according to punctuation marks to obtain segmented target knowledge blocks.

[0017] Optionally, when a natural language question input by a user is received, vector retrieval and keyword retrieval are performed according to the natural language question, the vector retrieval result and the keyword retrieval result are fused, an answer is obtained through a large language model LLM, and the answer is fed back to the user after being safely filtered, including: When a natural language question input by a user is received, vector retrieval and keyword retrieval are performed according to the natural language question to obtain a vector retrieval result and a keyword retrieval result; The vector retrieval result and the keyword retrieval result are fused according to a preset weight to obtain a fusion result; The fusion result is subjected to normalization calculation, reordering is performed according to a calculated fusion score, and the top K document segments of the fusion score are returned; Prompt words are generated according to the document segments, an answer is generated through a large language model LLM according to the prompt words, and the answer is fed back to the user after being safely filtered.

[0018] Optionally, when the to-be-processed document is detected to be updated, the vector library and the index are synchronously updated, and the prompt word template and the segmentation strategy are periodically optimized, including: Monitor the document changes of the to-be-processed document, and incrementally update the vector library and the index when detecting the to-be-processed document update. According to a preset optimization period, update the prompt word templates and the blocking strategy of each field.

[0019] In the second aspect, to achieve the above object, the present application further provides a document knowledge base LLM intelligent question answering device, which comprises: The dynamic blocking module is configured to receive a to-be-processed document uploaded by a user, perform dynamic blocking on the to-be-processed document, and perform vectorization and index storage on the knowledge block. The retrieval fusion module is configured to, when receiving a natural language question input by a user, perform vector retrieval and keyword retrieval according to the natural language question, fuse the vector retrieval result and the keyword retrieval result, obtain an answer through a large language model LLM, and feed back the answer to the user after security filtering. The update optimization module is configured to, when detecting the to-be-processed document update, synchronously update the vector library and the index, and periodically optimize the prompt word templates and the blocking strategy.

[0020] In the third aspect, to achieve the above object, the present application further provides a document knowledge base LLM intelligent question answering device, which comprises a memory, a processor, and a document knowledge base LLM intelligent question answering program stored in the memory and executable on the processor, and the document knowledge base LLM intelligent question answering program is configured to implement the steps of the document knowledge base LLM intelligent question answering method as described above.

[0021] In the fourth aspect, to achieve the above object, the present application further provides a storage medium, which stores a document knowledge base LLM intelligent question answering program, and the document knowledge base LLM intelligent question answering program implements the steps of the document knowledge base LLM intelligent question answering method as described above when executed by a processor.

[0022] The document knowledge base LLM intelligent question answering method provided by the application can solve the problem of missing table picture information, guarantee the integrity of document information analysis, avoid the case of single block strategy, improve the multi-hop recall rate, avoid the problem of semantic loss, the block mechanism is reasonable, the retrieval precision is improved, the update cost is reduced, the data security is improved, the implementation is convenient, the universality is good, and the speed and efficiency of the document knowledge base LLM intelligent question answering are improved. BRIEF DESCRIPTION OF DRAWINGS

[0023] Figure 1 The device structure schematic diagram of the hardware running environment involved in the embodiment scheme of the application; Figure 2 The flowchart of the document knowledge base LLM intelligent question answering method first embodiment of the application; Figure 3 The flowchart of the document knowledge base LLM intelligent question answering method second embodiment of the application; Figure 4 The document knowledge base LLM intelligent question answering method Chinese document vectorization and index flowchart of the application; Figure 5 The flowchart of the document knowledge base LLM intelligent question answering method third embodiment of the application; Figure 6 The user question and answer processing flowchart of the document knowledge base LLM intelligent question answering method of the application; Figure 7 The flowchart of the document knowledge base LLM intelligent question answering method fourth embodiment of the application; Figure 8 The overall architecture design schematic diagram of the system corresponding to the document knowledge base LLM intelligent question answering method of the application; Figure 9 The function module diagram of the document knowledge base LLM intelligent question answering device first embodiment of the application.

[0024] The implementation, functional characteristics and advantages of the application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION

[0025] It should be understood that the specific embodiments described herein are merely illustrative of the present application and do not limit the present application.

[0026] The solution of the embodiment of the present application is mainly: receiving a user uploaded to-be-processed document, dynamically chunking the to-be-processed document, vectorizing and index storing the knowledge block; when a natural language question input by a user is received, performing vector retrieval and keyword retrieval according to the natural language question, fusing the vector retrieval result and the keyword retrieval result, obtaining an answer through a large language model LLM, and feeding back the answer to the user after security filtering; when the to-be-processed document is detected to be updated, synchronously updating the vector library and the index, and periodically optimizing the prompt word template and the chunking strategy, which can solve the problem of missing table picture information, guarantee the integrity of document information parsing, avoid the case of single chunking strategy, improve the multi-hop recall rate, avoid the problem of semantic loss, the chunking mechanism is reasonable, the retrieval precision is improved, the update cost is reduced, the data security is improved, the implementation is convenient, the generality is good, the speed and efficiency of the document knowledge base LLM intelligent question answering are improved, and the technical problems of the prior art that the document question answering cannot effectively process the tables and pictures in the document, the complex table recognition accuracy is low, the keyword retrieval has semantic loss, the chunking mechanism is unreasonable, the retrieval precision is insufficient, the update cost is high, there are data security risks, and the generality is poor are solved.

[0027] Reference Figure 1 , Figure 1 The device structure schematic diagram of the hardware running environment involved in the embodiment of the present application.

[0028] As Figure 1 shown, the device can include a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to realize the connection and communication between the components. The user interface 1003 can include a display screen (Display) and an input unit such as a keyboard (Keyboard). The optional user interface 1003 can also include a standard wired interface, a wireless interface. The network interface 1004 can optionally include a standard wired interface, a wireless interface (such as a Wi-Fi interface). The memory 1005 can be a high-speed RAM memory or a stable memory (Non-Volatile Memory), such as a magnetic disk memory. The memory 1005 can also be an independent storage device from the aforementioned processor 1001.

[0029] Those skilled in the art can understand that Figure 1 The device structure shown in the foregoing embodiments does not constitute a limitation on the device, and can include more or fewer components than the diagram, or combine certain components, or different component arrangements.

[0030] As shown in Figure 1 The memory 1005 as a storage medium can include an operation device, a network communication module, a user interface module and a document knowledge base LLM intelligent question and answer program.

[0031] The device of the application calls the document knowledge base LLM intelligent question and answer program stored in the memory 1005 through the processor 1001, and performs the following operations: Receiving the user uploaded document to be processed, dynamically blocking the document to be processed, vectorizing and index storing the knowledge block; When receiving the natural language question input by the user, vector retrieval and keyword retrieval are performed according to the natural language question, the vector retrieval result and the keyword retrieval result are fused, an answer is obtained through a large language model LLM, and the answer is fed back to the user after safety filtering; When detecting that the to-be-processed document is updated, synchronously updating the vector library and the index, and periodically optimizing the prompt word template and the blocking strategy.

[0032] The device of the application calls the document knowledge base LLM intelligent question and answer program stored in the memory 1005 through the processor 1001, and also performs the following operations: When detecting that the user uploads the document to be processed through the web interface or the API, receiving the document to be processed; Separating and processing each element in the document to be processed, respectively analyzing each element separated out to obtain the analyzed document data; According to the semantic boundary, the document data is knowledge block cut, and the target knowledge block is obtained; The text content of the target knowledge block is converted into a vector, and the target knowledge block is stored in a preset elastic search database.

[0033] The device of the application calls the document knowledge base LLM intelligent question and answer program stored in the memory 1005 through the processor 1001, and also performs the following operations: Automatically analyzing the document format of the document to be processed, and selecting a matched document parser according to the document format; According to the document parser, the page data in the document to be processed is detected, each element is obtained, and each element is separated and processed; The table element in each element is processed to obtain table data; Calling a picture OCR processor to analyze the picture element in each element to obtain picture data; Generating document data according to the text data in the page data, the table data and the picture data.

[0034] The device of the present application calls the document knowledge base LLM intelligent question and answer program stored in the memory 1005 through the processor 1001, and also performs the following operations: The table structure, table header and row and column information of the table element in each element are extracted using the Tabula library; The table structure, the table header and the row and column information are structured and converted to obtain table data.

[0035] The device of the present application calls the document knowledge base LLM intelligent question and answer program stored in the memory 1005 through the processor 1001, and also performs the following operations: The sentence text in the document data is converted into a sentence vector using the Sentence Transformers model, the cosine similarity of adjacent sentence vectors is calculated, and the cosine similarity is taken as the semantic similarity; The similarity is compared with the preset breakpoint threshold, forced segmentation is performed when the similarity is less than the preset breakpoint threshold, and secondary segmentation or merging is performed according to the knowledge block size, to ensure that each knowledge block after segmentation is within the preset block size range; The text in the document data that is not segmented by sentence boundaries is segmented according to punctuation marks to obtain segmented target knowledge blocks.

[0036] The device of the present application calls the document knowledge base LLM intelligent question and answer program stored in the memory 1005 through the processor 1001, and also performs the following operations: When receiving a natural language question input by a user, vector retrieval and keyword retrieval are simultaneously performed according to the natural language question to obtain vector retrieval results and keyword retrieval results; The vector retrieval results and the keyword retrieval results are fused according to a preset weight to obtain a fusion result; The fusion result is normalized and reordered according to the calculated fusion score, and the top K document segments according to the fusion score are returned; Prompt words are generated according to the document segments, answers are generated by a large language model LLM according to the prompt words, and the answers are filtered and fed back to the user after safety filtering.

[0037] The device of the present application calls the document knowledge base LLM intelligent question and answer program stored in the memory 1005 through the processor 1001, and also performs the following operations: The document changes of the to-be-processed document are monitored, and the vector library and the index are incrementally updated when the to-be-processed document is detected to be updated; The prompt word templates and the block strategy of each field are updated according to a preset optimization period.

[0038] The embodiment can solve the problem of missing table picture information, guarantee the integrity of document information analysis, avoid the case of single block strategy, improve the multi-hop recall rate, avoid the problem of semantic loss, the block mechanism is reasonable, the retrieval precision is improved, the update cost is reduced, the data security is improved, the implementation is convenient, the generality is good, and the speed and efficiency of the document knowledge base LLM intelligent question answering are improved.

[0039] Based on the above hardware structure, the document knowledge base LLM intelligent question answering method embodiment of the application is proposed.

[0040] Reference Figure 2 , Figure 2 The flowchart of the first embodiment of the document knowledge base LLM intelligent question answering method of the application is shown in the figure.

[0041] In the first embodiment, the document knowledge base LLM intelligent question answering method comprises the following steps: Step S10, receiving a user uploaded document to be processed, dynamically block the document to be processed, and vectorize and index store the knowledge block.

[0042] It should be noted that after receiving the user uploaded document to be processed, the document to be processed can be dynamically blocked to obtain the corresponding knowledge block, and then the knowledge block can be vectorized and index stored.

[0043] Step S20, when receiving a natural language question input by a user, performing vector retrieval and keyword retrieval according to the natural language question, fusing the vector retrieval result and the keyword retrieval result, obtaining an answer through a large language model LLM, and feeding back the answer to the user after security filtering.

[0044] It should be understood that when receiving a natural language question input by a user, vector retrieval and keyword retrieval can be performed on the to-be-processed text according to the natural language question, corresponding vector retrieval results and keyword retrieval results are obtained, the vector retrieval results and the keyword retrieval results are fused, an answer is obtained through a large language model (LLM), the answer is filtered after the answer is obtained, and then the answer filtered is fed back to the user, thereby improving data security.

[0045] Step S30, when detecting that the to-be-processed document is updated, synchronously updating the vector library and the index, and periodically optimizing the prompt word template and the blocking strategy.

[0046] It can be understood that when the to-be-processed document is detected to be updated, the vector library and the index can be synchronously updated, and the prompt word template and the blocking strategy can be periodically optimized, thereby further improving the speed and efficiency of the document knowledge base LLM intelligent question answering.

[0047] The embodiment can receive a to-be-processed document uploaded by a user, perform dynamic blocking on the to-be-processed document, and perform vectorization and index storage on a knowledge block. When receiving a natural language question input by a user, vector retrieval and keyword retrieval are performed according to the natural language question, the vector retrieval results and the keyword retrieval results are fused, an answer is obtained through a large language model (LLM), the answer is filtered after the answer is obtained, and then the answer filtered is fed back to the user. When detecting that the to-be-processed document is updated, the vector library and the index are synchronously updated, and the prompt word template and the blocking strategy are periodically optimized. The embodiment can solve the problem of missing information of a table picture, guarantee the integrity of document information analysis, avoid the case of single blocking strategy, improve multi-hop recall rate, avoid the problem of semantic loss, the blocking mechanism is reasonable, the retrieval precision is improved, the update cost is reduced, the data security is improved, the implementation is convenient, the generality is good, and the speed and efficiency of the document knowledge base LLM intelligent question answering are improved.

[0048] Further, Figure 3 A flowchart of a second embodiment of the document knowledge base LLM intelligent question answering method is shown in FIG. 2. Figure 3 As shown in FIG. 2, the second embodiment of the document knowledge base LLM intelligent question answering method is based on the first embodiment. In the embodiment, the step S10 specifically includes the following steps. Step S11, when detecting that a user uploads a to-be-processed document through a web interface or an API, receiving the to-be-processed document.

[0049] It should be noted that when it is detected that a user uploads a to-be-processed document through a web interface or an Application Programming Interface (API), the to-be-processed document is received.

[0050] In step S12, each element in the to-be-processed document is separated and processed, and each separated element is parsed to obtain parsed document data.

[0051] It can be understood that each element in the to-be-processed document is separated and processed, and each separated element is parsed to obtain parsed document data.

[0052] Further, the step S12 specifically includes the following steps: The document format of the to-be-processed document is automatically parsed, and a matched document parser is selected according to the document format; According to the document parser, the page data in the to-be-processed document is detected to obtain each element, and each element is separated and processed; The table information in each element is processed to obtain table data; The picture element in each element is parsed by calling a picture OCR processor to obtain picture data; The document data is generated according to the text data in the page data, the table data, and the picture data.

[0053] It should be noted that the document format of the to-be-processed document is automatically parsed, and after recognizing the document formats such as PDF and Word, different document parsers can be selected. The document parser detects the element type of the page data, that is, identifies the text, table, picture, and other elements contained in the page data. For table and picture data, table information processing and picture OCR processing are called for parsing, and then the document data is generated according to the text data in the page data, the table data, and the picture data.

[0054] In a specific implementation, picture OCR processing can use Tesseract OCR to identify picture text. Taking a PDF document as an example, the text extraction can be continued preferentially, that is, extract_text(path) is called to attempt to extract original text from the PDF; if the length of the extracted text exceeds 100 characters (a valid text threshold), the extraction result is directly returned; scan OCR processing: that is, when the text extraction fails (the length is insufficient), pdf2image.convert_from_path is used to convert the PDF into an image list; pytesseract.image_to_string is executed on each image to perform OCR text recognition; and then all OCR results are spliced into complete text and returned; the corresponding exception handling mechanism is: all exceptions in the parsing process are captured; error information is recorded by the log_error method; and an empty string is returned as the default result after exception handling.

[0055] It can be understood that the two-stage strategy of "text extraction first and then OCR" is used to parse the PDF, the electronic document with directly extractable text is preferentially processed, the image recognition mode is automatically switched when a scan is encountered, the program robustness is ensured through exception capture, and the final return of the text content in a unified format or an empty string provides basic support for subsequent document segmentation and knowledge base construction.

[0056] Further, the step of processing table information in each element to obtain table data specifically includes the following steps: extracting the table structure, table header, and row and column information of the table element in each element using the Tabula library; structurally converting the table structure, the table header, and the row and column information to obtain table data.

[0057] It can be understood that the table can be processed specially: the table structure, the table header, and the row and column information are extracted using the Tabula library, and then the table structure, the table header, and the row and column information are structurally converted to obtain table data.

[0058] In a specific implementation, taking a PDF document as an example, the table in the PDF document is first extracted using the Tabula library. Generally, the network mode can be used to improve the table recognition accuracy, and after the corresponding information is proposed, the structured data, that is, the table data, is converted.

[0059] Step S13, according to the semantic boundary, the document data is segmented into knowledge blocks to obtain segmented target knowledge blocks.

[0060] It should be understood that according to the semantic boundary, the document data parsed can be segmented into knowledge blocks, thereby obtaining the segmented target knowledge blocks.

[0061] Further, the step S13 specifically includes the following steps: Converting the sentence text in the document data into a sentence vector using the Sentence Transformers model, calculating the cosine similarity of adjacent sentence vectors, and taking the cosine similarity as the semantic similarity; Comparing the similarity with a preset breakpoint threshold, performing forced segmentation when the similarity is less than the preset breakpoint threshold, and performing secondary segmentation or merging according to the knowledge block size, to ensure that each knowledge block after segmentation is within the preset block size range; Segmenting the text in the document data that is not segmented by the sentence boundary according to the punctuation symbol to obtain the segmented target knowledge block.

[0062] It should be noted that the dynamic block generation process is: after parsing the text, table, and picture elements of the document, the semantic boundary detection of the obtained text data is performed, and the natural boundaries such as titles and paragraphs are recognized. Different types of knowledge blocks are created according to the boundaries. These knowledge blocks will eventually be vectorized to a vector database and index; the specific implementation logic includes the following aspects: Semantic similarity calculation: use Sentence Transformers to generate sentence embedding, calculate the cosine similarity of adjacent sentences, and determine whether to segment based on the similarity threshold; when the similarity is lower than breaKpoint_threshold, forced segmentation, such as 0.6; Chunk size limit: need to ensure that the block is between min_chunK_size and max_chunK_size; secondary segmentation is performed on excessively large blocks; small blocks need to be merged.

[0063] Special processing: preferentially segmenting at the sentence boundary, and secondarily segmenting at the punctuation symbol.

[0064] It can be understood that the role of Sentence Transformers is to map any length of text (sentence, paragraph, document) to a fixed-dimensional numerical vector based on the pre-trained model library of PyTorch (such as text-embedding-v3), and capture the deep semantic features of the text through a fine-tuned Transformer model.

[0065] In specific implementation, the process of generating embedding is to load the specified model by SentenceTransformer(model_name), and encode the input text by encode(texts) to return a vector array in numpy.ndarray format, the dimension of which is determined by the model (such as 768 dimensions); its application scenarios are as follows: Vector Search: used by Milvus and other vector databases to calculate similarity.

[0066] Semantic Matching: measures text relevance by vector space distance.

[0067] Text Clustering: categorizes texts with similar semantics into the same vector space region.

[0068] It should be understood that using the Sentence Transformers library to convert text into vector representation (Embedding) can support batch processing of text, and the generated vector can preserve contextual semantics and can customize the model (such as multilingual support). It can be understood that Sentence Transformers converts text into semantic vectors through a deep learning model, enabling computers to understand the meaning of text through vector similarity calculation, which is the basis for building semantic search, intelligent question answering, and other systems, and can break through the limitations of traditional keyword matching and achieve "image level" text understanding.

[0069] In a specific implementation, the NLTK pumKt tokenizer can be downloaded (the first time it needs to be run); the semantic text segmentation includes but is not limited to the following parameters: sentence embedding model name, semantic similarity threshold, segmentation below this value, maximum block size (number of characters), minimum block size (number of characters), forced segmentation point threshold (must be segmented below this value).

[0070] The main segmentation method includes: Step 1: Basic segmentation (sentence level) Step 2: Generate sentence embeddings Step 3: Calculate the similarity of adjacent sentences Step 4: Dynamic chunking Step 5: Post-processing (ensure block size is reasonable) Specifically, calculate the similarity of adjacent sentences, create chunks based on similarity: need to check if segmentation is needed (based on similarity), generally check from the second sentence, encounter strong segmentation points (such as topic mutation), check if it exceeds the maximum size, check if semantic segmentation is needed, add the last block, post-processing to ensure block size is reasonable, process small blocks (merge with the previous block), process large blocks (forced segmentation), process blocks that exceed the maximum size (recursive segmentation), try to split at sentence boundaries, split at punctuation if there are no sentence boundaries, split long texts by punctuation, find natural breakpoints (commas, semicolons, etc.), if no breakpoints are found, hard split by length, find breakpoints close to the middle.

[0071] Take the semantic analysis-based intelligent text segmentation as an example: First, perform semantic embedding analysis: Convert sentences into vectors using the Sentence Transformers model (such as all-MiniLM-L6-v2); Calculate the cosine similarity of adjacent sentences (cosine_similarity) to determine semantic continuity; Dynamic chunking strategy: Semantic segmentation: force segmentation when the similarity between adjacent sentences is below the threshold (0.45); Breakpoint segmentation: immediately segment when the similarity is below a stricter threshold (0.2) (to deal with theme mutations); Size control: maximum 300 characters and minimum 50 characters per chunk to prevent excessive fragmentation or size; Multi-stage processing flow: Basic sentence-level segmentation → semantic similarity analysis → dynamic combination chunking → post-processing optimization Post-processing includes: Merge small chunks (<50 characters) with the previous chunk; Split large chunks (>300 characters) recursively; Prioritize segmentation at sentence boundaries, and secondarily at punctuation marks; Application scenarios: Suitable for document preprocessing to provide semantically coherent text chunks for vector database construction (such as Milvus); especially suitable for processing mixed content documents (such as the cross-text of Natural Language Processing (NLP) and quantum computing in the example).

[0072] It can be understood that by calculating semantic vectors, the traditional length-based hard segmentation method is broken through, ensuring reasonable chunk size while preserving contextual semantic coherence; first capture the semantic relationship between sentences through the Sentence Transformers model, then dynamically adjust based on size restrictions, and finally solve complex situations through recursive processing, providing high-quality semantic chunking for subsequent knowledge base construction, significantly improving the accuracy of vector retrieval and dialogue generation.

[0073] Step S14, convert the text content of the target knowledge chunk into a vector, and store the target knowledge chunk in a pre-set elastic search database.

[0074] It can be understood that after obtaining the knowledge chunk, the knowledge chunk can be vectorized and indexed and stored, i.e., the text content of the knowledge chunk is converted into a vector, and the knowledge chunk is also stored in a pre-set elastic search database, such as an Elasticsearch (Es) database. Es is an open-source distributed search engine, and is also commonly used as a high-performance full-text retrieval database.

[0075] It should be noted that the data is stored and indexed by vectorization after being chunked, which facilitates subsequent mixed retrieval.

[0076] It can be understood that the vectorization and index construction process is as follows: initialize the vector retrieval system: embedding model instance, server address, Milvus port; connect Milvus, define collection structure, create or get collection, create index, load collection to memory, index knowledge block, knowledge block list, each element contains id (unique identifier of the current data unit), content (actual content information of the current data unit), doc_id (unique identifier of the original document to which it belongs), chunK_type (classification or role of the text block), extract text content, generate embedding vector, prepare data, insert data; Document chunk chunK index: initialize the keyword retrieval system: Elasticsearch server address, connect Elasticsearch, create index (if not exist), create Elasticsearch index and define mapping, index knowledge block, knowledge block list, bulk index document.

[0077] In a specific implementation, the Milvus vector retrieval system: Connect to the Milvus server at initialization, define a collection structure containing an embedding vector field (dimension determined by embedding model); Use IVF_FLAT index type (inverted file-based vector index) and IP (inner product) similarity measure; Support bulk insertion of document chunks, store semantic vectors generated by embedder; Finally, load the collection into memory to improve retrieval performance; Elasticsearch keyword retrieval system: Connect to the ES server at initialization, create an index containing Chinese word segmentation configuration; Define a content field containing a text analyzer (use iK_max_word tokenizer and lowercase filter); Support storing metadata such as semantic tags (semantic_tags) of chunks; Use bulk operation (bulK) to efficiently insert documents, and use refresh to ensure data is searchable.

[0078] Understandably, Milvus achieves semantic retrieval through vector similarity calculation, while Elasticsearch achieves precise retrieval through traditional keyword matching. By indexing documents in chunks to both systems simultaneously, the advantages of semantic understanding and keyword matching can be combined to provide more comprehensive knowledge retrieval capabilities. Milvus's IVF_FLAT index is suitable for fast retrieval of high-dimensional vectors, while ES's iK Chinese word segmentation configuration optimizes keyword processing for Chinese documents.

[0079] It should be understood that the document parsing, vectorization, and indexing process is as follows: Document Upload: Users upload documents via a web interface or API; Format parsing: Automatically recognizes and processes PDF, Word, and other formats; Element separation: Separate and process elements such as text, tables, and images; Table processing: Extracting table structure and content; Dynamic chunking: Segmenting the parsed document data into knowledge blocks based on semantic boundaries; Vectorization: Converting the text content of a knowledge block into vectors; Index storage: Knowledge blocks are also stored in the Es database.

[0080] In specific implementations, such as Figure 4 As shown, Figure 4 This is a flowchart illustrating the document vectorization and indexing process in the LLM intelligent question-answering method of the document knowledge base of this invention. (See attached diagram.) Figure 4 After uploading the document, the format is parsed to obtain elements of different types, including text, tables, and images. For text elements, semantic boundary detection is first performed to create corresponding text blocks and add corresponding text metadata. For table elements, the table structure is first extracted to create table blocks and then table metadata is added. For image elements, OCR text recognition is performed to create image blocks and add image metadata. After obtaining the text metadata, table metadata, and image metadata, they are stored in a vectorized form.

[0081] This embodiment, through the above-described scheme, receives the document to be processed when a user uploads it via a web interface or API; separates and processes each element in the document, parses each element to obtain parsed document data; segments the document data into knowledge blocks based on semantic boundaries to obtain segmented target knowledge blocks; converts the text content of the target knowledge blocks into vectors; and stores the target knowledge blocks in a preset elastic search database. This improves retrieval accuracy and enhances the speed and efficiency of the document knowledge base LLM intelligent question answering system.

[0082] Furthermore, Figure 5A flowchart of the third embodiment of the document knowledge base LLM intelligent question answering method is shown in FIG. 3. Figure 5 The third embodiment of the document knowledge base LLM intelligent question answering method is proposed based on the first embodiment. In this embodiment, step S20 specifically includes the following steps: Step S21, upon receiving the natural language question input by the user, simultaneously performing vector retrieval and keyword retrieval according to the natural language question to obtain vector retrieval results and keyword retrieval results.

[0083] It should be noted that upon receiving the natural language question input by the user, simultaneously performing vector retrieval and keyword retrieval according to the natural language question, i.e. improving the accuracy of retrieval by mixing the two retrieval engines and reducing model hallucinations, thereby obtaining vector retrieval results and keyword retrieval results.

[0084] In a specific implementation, parallel retrieval is performed, i.e. simultaneously performing vector retrieval and keyword retrieval, and unifying the retrieved data structures, which can improve the recall rate of retrieval by fusing the two retrieval paths of vector semantic retrieval + keyword retrieval.

[0085] Step S22, fusing the vector retrieval results and the keyword retrieval results according to a preset weight to obtain a fusion result.

[0086] It can be understood that the vector retrieval results and the keyword retrieval results can be fused according to the pre-set weight to obtain a fusion result.

[0087] In a specific implementation, the two retrieval results can be fused by customizing the weight, such as vectorization retrieval weight 0.7 and keyword retrieval weight 0.3, with keyword retrieval as a supplement to vectorization retrieval.

[0088] Step S23, performing normalization calculation on the fusion result, reordering according to the calculated fusion score, and returning the top K document segments of the fusion score.

[0089] It should be understood that the normalized calculation is performed on the fused result, reordered according to the calculated score, and the top K most relevant document segments are returned, i.e. by performing normalization calculation on the fusion result, reordering according to the calculated fusion score, the top K document segments of the fusion score can be returned.

[0090] Step S24, generating a prompt word according to the document segment, answering according to the prompt word by a large language model LLM, generating an answer, and feeding back the answer to the user after safety filtering.

[0091] It can be understood that the prompt word can be generated according to the document fragment, and then the answer is generated by the large language model LLM according to the prompt word, and the answer is fed back to the user after being safely filtered.

[0092] Correspondingly, the user retrieval process is as follows: User input: the user raises a natural language question.

[0093] Hybrid retrieval: vector and keyword retrieval are performed in parallel.

[0094] Result fusion: weighted fusion of two retrieval results.

[0095] Fine sorting: reordering using normalized algorithm score to get the top K most relevant answers.

[0096] Answer generation: generate Prompt prompt word based on retrieval results, and answer LLM Safety filtering: verify the safety and accuracy of the answer, encrypt or mask the data that needs to be desensitized, and then return it to the user.

[0097] In a specific implementation, see Figure 6 , Figure 6 The user question and answer processing flowchart in the document knowledge base LLM intelligent question and answer method of the application is shown in Figure 6 As shown, the user sends a query request to the system, the system analyzes the user state, and returns immediate guidance prompts. The system performs retrieval through a hybrid engine, which sends a vector retrieval request to a vector database (Database, DB), and simultaneously sends a keyword retrieval request to a keyword index. The vector DB feeds back the vector result to the hybrid engine, and the keyword index feeds back the keyword result to the hybrid engine. The hybrid engine generates fusion results according to (70% vector + 30% keyword). The hybrid engine sends the fusion results at this time as candidate results to a reordering module, which performs cross-encoder fine sorting and returns TOP-K results to the hybrid engine. The hybrid engine returns the retrieval results to the system, the system generates a request (containing results + query) and sends it to the LLM engine, the LLM engine generates a natural language answer and returns the original answer to the system, the system continues safety filtering and verification, and returns the final answer + field guidance to the user.

[0098] In a specific implementation, the implementation steps of the hybrid dual search engine are as follows: initializing the embedding model: initializing the text embedding model, embedding model name (compatible with text-embedding-v3 format), converting the text list to a vector, text list, vector array, initializing the dialogue model, model name, generating an answer, user query, retrieved context, maximum generation length, generated answer, building a prompt, knowledge base context, generating an answer, decoding and returning the result; vector retrieval (using Milvus): initializing the vector retrieval system: embedding model instance, server address, Milvus port; connecting Milvus, defining the collection structure, creating or obtaining the collection, creating the index, loading the collection into memory; executing vector retrieval: query text, return result quantity, limit the list of document IDs for retrieval, list of retrieval results, generate query vector; build search parameters, build filter expression, execute search, and feedback processing result; keyword search (using Elasticsearch): initializing the keyword search system, Elasticsearch server address, connecting Elasticsearch, creating index (if not exists), executing keyword search, query text, return result quantity, limit the list of document IDs for retrieval, list of retrieval results, build query Domain Specific Language (DSL), execute search, and feedback processing result; hybrid search system, initializing the hybrid search system: vector retrieval instance, keyword retrieval instance; executing hybrid search: query text, return result quantity, limit the list of document IDs for retrieval, fused result; parallel execution of two retrievals, create result mapping, feedback processing vector result, feedback processing keyword result; fusion score, normalization processing, calculate fusion score, sort by fusion score, return TOP-K result.

[0099] It should be noted that the Embedding model can use the SentenceTransformer to load the text-embedding-v3 model, and provide the embed() method to convert the text into a high-dimensional vector (dimension determined by the model), as the basic component of vector retrieval.

[0100] The dialogue model ChatModel can generate dialogue based on the DeepSeek-Chat model; the generate() method is used to combine the retrieved context and user query to generate an answer; the system prompt is used to constrain the model behavior to ensure that the answer is based on the knowledge base.

[0101] VectorRetriever (Milvus): Establish a connection to the Milvus vector database, define a collection structure containing the embedding vector field, use the IVF_FLAT index and inner product (IP) similarity measure, support filtering by document ID and vector similarity retrieval.

[0102] KeywordRetriever (Elasticsearch): Configure the Chinese tokenizer (ik_max_word) and semantic label field, build a composite query DSL containing match and term, set weights for table type and semantic label fields to enhance recall, support document ID filtering and multi-field matching.

[0103] HybridRetriever: Parallelly call vector retrieval and keyword retrieval, merge the results by ID mapping, set default weights (vector 0.7, keyword 0.3), normalize zero-score results to prevent weight imbalance, and finally return the TOP-K results sorted by the fusion score.

[0104] It can be understood that the hybrid retrieval system realizes high-dimensional vector semantic retrieval (capturing deep text semantics) through Milvus, combines with Elasticsearch's precise keyword matching (improving accurate recall), balances the advantages of both by using a weighted fusion strategy, optimizes the Chinese scenario (ik tokenizer) and structured content (table type weight) through special optimization, and finally integrates the multi-source retrieval results through a dialogue model to generate a natural language answer, forming a complete semantic enhanced knowledge retrieval closed loop.

[0105] The above-mentioned scheme, when receiving a natural language question input by a user, simultaneously performs vector retrieval and keyword retrieval according to the natural language question, obtains vector retrieval results and keyword retrieval results; fuses the vector retrieval results and the keyword retrieval results according to a preset weight, obtains a fusion result; performs normalization calculation on the fusion result, reorders according to the calculated fusion score, and returns the top K document segments according to the fusion score; generates a prompt word according to the document segment, answers through a large language model LLM according to the prompt word, generates an answer, and feeds back the answer to the user after security filtering, which can solve the problem of missing table picture information, guarantee the integrity of document information parsing, avoid the single block strategy, improve the multi-hop recall rate, avoid the problem of semantic missing, the block mechanism is reasonable, the retrieval precision is improved, the data security is improved, the implementation is convenient, the universality is good, the speed and efficiency of the document knowledge base LLM intelligent question and answer are improved.

[0106] Further, Figure 7As shown in the flowchart of the fourth embodiment of the document knowledge base LLM intelligent question answering method of the present application, Figure 7 The fourth embodiment of the document knowledge base LLM intelligent question answering method of the present application is proposed based on the first embodiment. In this embodiment, the step S30 specifically includes the following steps: Step S31, monitoring the document changes of the to-be-processed document, and incrementally updating the vector library and index when detecting that the to-be-processed document is updated.

[0107] It should be noted that system maintenance includes incremental update and periodic optimization. The incremental update is to monitor the document changes and incrementally update the vector library and index, that is, the document changes of the to-be-processed document can be monitored in real time, and the vector library and index are incrementally updated when the to-be-processed document is detected to be updated.

[0108] Step S32, updating the prompt word templates and blocking strategies of each field according to a preset optimization period.

[0109] It can be understood that the prompt word templates and blocking strategies of each field can be updated according to the preset optimization period. The periodic optimization period is taken as an example of a week: the prompt word templates and blocking strategies of each field are updated every week. Of course, other update periods can also be set according to actual conditions, and the present embodiment does not limit this.

[0110] Further, as shown in the flowchart of the fourth embodiment of the document knowledge base LLM intelligent question answering method of the present application, Figure 8 Figure 8 The system overall architecture design diagram corresponding to the document knowledge base LLM intelligent question answering method of the present application is shown in Figure 8 The present system adopts a layered architecture and includes four core modules: Knowledge processing layer: responsible for document parsing and semantic blocking, such as parsing the text, table, picture and other data of the document, and separately parsing and blocking the text, table and picture.

[0111] Knowledge storage layer: responsible for storing the vectorized vectors and original data blocks of the blocked data, as well as the index relationship between keywords and documents; including a vector database and an index system.

[0112] Intelligent service layer: responsible for understanding customer input, obtaining related knowledge from the vector database through a hybrid retrieval mechanism, and interacting with the Prompt prompt word and large model to obtain results; including conforming retrieval, reordering, security filtering and other functions.

[0113] Interactive application layer: dialogue management and storage, as well as user guidance function; including gateway and user guidance interface.

[0114] ​The embodiment can reduce the update cost, improve the data security, and improve the speed and efficiency of the document knowledge base LLM intelligent question answering by monitoring the document changes of the to-be-processed document, incrementally updating the vector library and the index when detecting that the to-be-processed document is updated, and updating the prompt word template and the blocking strategy of each field according to a preset optimization period.

[0115] Correspondingly, the application further provides a document knowledge base LLM intelligent question answering device.

[0116] Reference Figure 9 , Figure 9 The function module diagram of the first embodiment of the document knowledge base LLM intelligent question answering device is shown in the figure.

[0117] The document knowledge base LLM intelligent question answering device comprises: The dynamic blocking module 10 is configured to receive a to-be-processed document uploaded by a user, dynamically block the to-be-processed document, and vectorize and index store the knowledge blocks.

[0118] The retrieval fusion module 20 is configured to, when receiving a natural language question input by the user, perform vector retrieval and keyword retrieval according to the natural language question, fuse the vector retrieval result and the keyword retrieval result, obtain an answer through a large language model LLM, and feed back the answer to the user after security filtering.

[0119] The update optimization module 30 is configured to, when detecting that the to-be-processed document is updated, synchronously update the vector library and the index, and periodically optimize the prompt word template and the blocking strategy.

[0120] The dynamic blocking module 10 is further configured to, when detecting that the user uploads the to-be-processed document through a web interface or an API, receive the to-be-processed document; separate and process each element in the to-be-processed document, analyze each separated element, and obtain analyzed document data; perform knowledge block segmentation on the document data according to a semantic boundary, and obtain segmented target knowledge blocks; convert the text content of the target knowledge blocks into vectors, and store the target knowledge blocks in a preset elastic search database.

[0121] The dynamic block module 10 is further used for automatically analyzing a document format of the to-be-processed document, selecting a matched document parser according to the document format, detecting page data in the to-be-processed document according to the document parser, obtaining each element, and separating and processing each element; performing table information processing on a table element in each element to obtain table data; calling a picture OCR processor to analyze a picture element in each element to obtain picture data; and generating document data according to text data in the page data, the table data and the picture data.

[0122] The dynamic block module 10 is further used for extracting a table structure, a table header and row and column information of the table element in each element by using a Tabula library, and performing structured conversion on the table structure, the table header and the row and column information to obtain the table data.

[0123] The dynamic block module 10 is further used for converting a sentence text in the document data into a sentence vector by using a Sentence Transformers model, calculating a cosine similarity of adjacent sentence vectors, taking the cosine similarity as a semantic similarity, comparing the similarity with a preset breakpoint threshold, performing forced segmentation when the similarity is less than the preset breakpoint threshold, and performing secondary segmentation or merging according to a knowledge block size, to ensure that each knowledge block after segmentation is within a preset block size range, and performing normalization calculation on the document data that is not segmented by a sentence boundary.

[0124] The retrieval fusion module 20 is further used for, when receiving a natural language question input by a user, simultaneously performing vector retrieval and keyword retrieval according to the natural language question to obtain a vector retrieval result and a keyword retrieval result, fusing the vector retrieval result and the keyword retrieval result according to a preset weight to obtain a fusion result, performing normalization calculation on the fusion result, reordering according to a calculated fusion score, returning K document segments with the highest fusion scores, generating a prompt word according to the document segments, answering the prompt word by a large language model LLM to generate an answer, and feeding back the answer to the user after safety filtering.

[0125] The update optimization module 30 is further used for monitoring a document change of the to-be-processed document, incrementally updating a vector library and an index when detecting that the to-be-processed document is updated, and updating a prompt word template and a block strategy of each field according to a preset optimization period.

[0126] The steps implemented by each functional module of the document knowledge base LLM intelligent question and answer device can refer to the steps implemented by each embodiment of the document knowledge base LLM intelligent question and answer method, which will not be described here again.

[0127] In addition, the embodiment of the present application further provides a storage medium, and the storage medium stores the document knowledge base LLM intelligent question answering program. The document knowledge base LLM intelligent question answering program is executed by the processor to realize the operations corresponding to the steps in the document knowledge base LLM intelligent question answering method.

[0128] Those skilled in the art can understand that all or part of the steps of the methods in the above embodiments can be instructed by programs to relevant hardware, and the programs are stored in a storage medium, and the programs include a plurality of instructions to make a device (which can be a single-chip microcomputer, a chip, etc.) or a processor execute all or part of the steps of the methods described in various embodiments of the present application. The aforementioned storage medium is a computer readable storage medium, including a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.

[0129] It should be noted that, in this document, the terms "comprising", "including", or any other variant thereof are intended to cover non-exclusive inclusions, so that a process, method, article, or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such a process, method, article, or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of another identical element in the process, method, article, or device including the element.

[0130] The above-mentioned serial numbers of the embodiments of the present application are only for description, and do not represent the advantages and disadvantages of the embodiments.

[0131] The above is only the preferred embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation, or direct or indirect application in other related technical fields based on the content of the specification and drawings of the present application, are also included in the patent protection scope of the present application.

Claims

1. A document knowledge library (LLM) intelligent question answering method, characterized in that, The document knowledge base LLM intelligent question answering method comprises: Receiving a user uploaded to-be-processed document, dynamically chunking the to-be-processed document, vectorizing and index storing the knowledge block; When receiving a user input natural language question, performing vector retrieval and keyword retrieval according to the natural language question, fusing the vector retrieval result and the keyword retrieval result, obtaining an answer through a large language model LLM, and feeding back the answer to the user after safety filtering; When detecting that the to-be-processed document is updated, synchronously updating the vector library and the index, and periodically optimizing the prompt word template and the chunking strategy.

2. The document knowledge base LLM intelligent question answering method of claim 1, wherein, The receiving a user uploaded to-be-processed document, dynamically chunking the to-be-processed document, vectorizing and index storing the knowledge block comprises: When detecting that a user uploads a to-be-processed document through a web interface or an API, receiving the to-be-processed document; Separately processing each element in the to-be-processed document, separately analyzing each element separated out, and obtaining analyzed document data; According to a semantic boundary, knowledge block segmentation is performed on the document data to obtain segmented target knowledge blocks; The text content of the target knowledge block is converted into a vector, and the target knowledge block is stored in a preset elastic search database.

3. The document knowledge base LLM intelligent question answering method of claim 2, wherein, The separately processing each element in the to-be-processed document, separately analyzing each element separated out, and obtaining analyzed document data comprises: Automatically analyzing the document format of the to-be-processed document, and selecting a matched document parser according to the document format; According to the document parser, detecting page data in the to-be-processed document to obtain each element, and separately processing each element; Table information processing is performed on table elements in each element to obtain table data; A picture OCR processor is called to analyze picture elements in each element to obtain picture data; Document data is generated according to text data in the page data, the table data, and the picture data.

4. The document knowledge base LLM intelligent question answering method of claim 3, wherein, The table information processing performed on the table elements in each element to obtain the table data comprises: A Tabula library is used to extract table structures, table headers, and row and column information of the table elements in each element; The table structures, the table headers, and the row and column information are structured converted to obtain the table data.

5. The document knowledge base LLM intelligent question answering method of claim 2, wherein, The according to a semantic boundary, knowledge block segmentation is performed on the document data to obtain segmented target knowledge blocks comprises: A Sentence Transformers model is used to convert sentence text in the document data into sentence vectors, a cosine similarity of adjacent sentence vectors is calculated, and the cosine similarity is taken as a semantic similarity; The similarity is compared with a preset breakpoint threshold, forced segmentation is performed when the similarity is less than the preset breakpoint threshold, and secondary segmentation or merging is performed according to a knowledge block size to ensure that each knowledge block after segmentation is within a preset block size range; Text in the document data that is not segmented by a sentence boundary is segmented according to punctuation marks to obtain segmented target knowledge blocks.

6. The document knowledge base LLM intelligent question answering method of claim 1, wherein, The method comprises the following steps: when a natural language question input by a user is received, vector retrieval and keyword retrieval are performed according to the natural language question, the vector retrieval result and the keyword retrieval result are fused, an answer is obtained through a large language model LLM, and the answer is fed back to the user after being safely filtered. When a natural language question input by a user is received, vector retrieval and keyword retrieval are performed according to the natural language question, the vector retrieval result and the keyword retrieval result are fused, an answer is obtained through a large language model LLM, and the answer is fed back to the user after being safely filtered. The vector retrieval result and the keyword retrieval result are fused according to a preset weight to obtain a fusion result. The fusion result is normalized and reordered according to the calculated fusion score, and the top K document segments according to the fusion score are returned. A prompt word is generated according to the document segment, an answer is generated through the large language model LLM according to the prompt word, and the answer is fed back to the user after being safely filtered.

7. The document knowledge base LLM intelligent question answering method of claim 1, wherein, The vector library and the index are updated synchronously when the to-be-processed document is updated, and the prompt word template and the blocking strategy are periodically optimized, comprising the following steps: The document changes of the to-be-processed document are monitored, and the vector library and the index are incrementally updated when the to-be-processed document is updated. The prompt word template and the blocking strategy of each field are updated according to a preset optimization period.

8. A document knowledge library (LLM) intelligent question answering apparatus, characterized in that, The document knowledge base LLM intelligent question answering device comprises: A dynamic blocking module is configured to receive a to-be-processed document uploaded by a user, perform dynamic blocking on the to-be-processed document, and vectorize and index store the knowledge blocks. A retrieval and fusion module is configured to, when a natural language question input by a user is received, perform vector retrieval and keyword retrieval according to the natural language question, fuse the vector retrieval result and the keyword retrieval result, obtain an answer through a large language model LLM, and feed back the answer to the user after being safely filtered. An update and optimization module is configured to, when the to-be-processed document is updated, update the vector library and the index synchronously, and periodically optimize the prompt word template and the blocking strategy.

9. A document knowledge library (LLM) intelligent question answering device, characterized in that, The document knowledge base LLM intelligent question answering device comprises a memory, a processor, and a document knowledge base LLM intelligent question answering program stored on the memory and executable on the processor, wherein the document knowledge base LLM intelligent question answering program is configured to implement the steps of the document knowledge base LLM intelligent question answering method according to any one of claims 1 to 7.

10. A storage medium, characterized by The storage medium stores a document knowledge base LLM intelligent question answering program, and the document knowledge base LLM intelligent question answering program implements the steps of the document knowledge base LLM intelligent question answering method according to any one of claims 1 to 7 when executed by a processor.

Citation Information

Cited By

  • Document retrieval control method and system and server

    CN121327210A

  • Space-time signal classification and interpretation system and method based on retrieval enhancement generation

    CN121659038A

  • Retrieval enhancement generation method and device based on gynecologic specialist knowledge base

    CN121681848A

  • Information extraction index construction system for complex table

    CN121807862A

  • Data retrieval method and system based on ES large model scoring

    CN122153036A