Intelligent document query method and system for enterprise knowledge base
By deploying large language models and extraction vector models in enterprise servers, building standardized knowledge bases and performing dual retrieval processes, the deficiencies of intelligent document assistants in query professionalism and accuracy are solved, and accurate understanding and response to complex issues are achieved. .
Patent Information
- Application Number
- CN202411052714.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-10-15
AI Technical Summary
Existing intelligent document assistants have shortcomings in query professionalism and accuracy, especially when processing complex or fuzzy queries, they cannot effectively understand semantics and context, and the knowledge coverage and update speed of large language models are limited, making it difficult to meet specific fields. professional knowledge needs.
Deploy large language models and extraction vector models in enterprise servers, screen and preprocess enterprise documents, build standardized knowledge bases, continuously update through inverted indexes and feedback loop mechanisms, calculate the correlation between user queries and document blocks, and use extraction vectors The model is converted into vector form, cosine similarity is calculated, and prompt words are generated and input into the large language model to generate response results.
It improves the professionalism and accuracy of intelligent document query, narrows the scope of query through dual search processes, enhances the professional ability of output content, and ensures accurate understanding and response to complex issues.
Smart Images

Figure CN118779404A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to an enterprise knowledge base intelligent document query method and system. Background Art
[0002] Large Language Model (LLM) is a large-scale neural network model trained based on deep learning technology, which is specially used to handle natural language understanding and generation tasks. These models have parameters ranging from hundreds of millions to hundreds of billions. By training on massive text data, they can learn the grammar, semantics, context and various complex language patterns of the language.
[0003] Before AI technology became popular, internal intelligent document assistants in enterprises mainly relied on keyword searches and directory indexes. Users needed to enter accurate query keywords before the system could search the document title, directory, or full text to find documents or paragraphs containing keywords. This method relies on the accuracy and completeness of user input and may not provide accurate results for complex or ambiguous queries. It also fails to understand the semantics or context of the query and relies only on superficial text matching.
[0004] With the development of natural language processing technology, document assistants have begun to use technologies such as text understanding, semantic parsing, and sentiment analysis to process and analyze text more intelligently. Although natural language processing technology can understand semantics and context, it is still limited by the knowledge coverage and update speed of pre-trained models. It has limited ability to understand expertise in specific fields and may have difficulty handling complex query requirements for large-scale documents.
[0005] More complex enterprise internal intelligent document assistants based on large language models can combine external knowledge of large models to improve the document assistant's generation capabilities and information accuracy, but problems such as data quality and real-time performance still need to be addressed. Summary of the invention
[0006] In view of this, an embodiment of the present invention provides an enterprise knowledge base intelligent document query method and system to eliminate or improve the problem of poor professionalism and accuracy of intelligent document assistant query results in the prior art.
[0007] A first aspect of the present invention provides an enterprise knowledge base intelligent document query method, the method comprising the following steps:
[0008] Deploy large language models and extracted vector models in enterprise servers for query response tasks;
[0009] Screening documents that meet preset format standards from enterprise documents, preprocessing the documents to form standardized documents to construct a knowledge base as an external knowledge source for the large language model;
[0010] The standardized documents in the knowledge base are divided into blocks to generate document blocks, each document block is numbered and the word frequency of each document block is calculated to construct an inverted index table; each document block is converted into a document block vector in vector form using the extraction vector model, and stored in a vector database of the knowledge base; the knowledge base responds to the received feedback information based on a feedback loop mechanism to continuously update;
[0011] Receive a user query request, calculate the relevance scores of the user query request in text form and all document blocks, and rank them to screen out a preset number of candidate document blocks according to preset rules;
[0012] Searching for a corresponding document block vector according to the number of the candidate document block, and converting the user query request into a query vector in vector form using the extraction vector model;
[0013] Calculating the cosine similarity between the query vector and the document block vectors corresponding to the candidate document blocks, and selecting the candidate document block with the highest similarity;
[0014] The candidate document block with the highest similarity, the user query request and preset configuration parameters are integrated to generate prompt words, the prompt words are input into the large language model, and a response result in a preset format is output.
[0015] In some embodiments of the present invention, preprocessing the document includes: cleaning and formatting the document, deduplicating the document, and randomly sampling and checking the document.
[0016] In some embodiments of the present invention, the knowledge base responds to received feedback information based on a feedback loop mechanism to continuously update, wherein the feedback information includes: feedback information based on user needs and feedback information based on system performance monitoring.
[0017] In some embodiments of the present invention, the knowledge base responds to the received feedback information based on a feedback loop mechanism to continuously update, and the updated content includes: the number of each document block, the word frequency of each document block, the inverted index table and the document vector block.
[0018] In some embodiments of the present invention, the calculation formula for calculating the relevance scores of the user query request and all document blocks and ranking them is:
[0019]
[0020] Wherein, q represents the user query request, q i represents each term split by the user query request q, C represents the document block, f(q i , C) represents the term q i The frequency of words appearing in the document block C, |C| represents the length of the document block C, avg(C) represents the average length of all document blocks, k and b represent adjustable parameters, IDF(q f ) represents the inverse document frequency, so IDF(q i ) is the term q i The weight among all document blocks is calculated as follows:
[0021]
[0022] Where N is the total number of all document blocks, n(q i ) is the term containing the term q i The number of blocks indicates the frequency of occurrence of the term in the block set.
[0023] In some embodiments of the present invention, the preset configuration parameters include: a task description for informing the large language model of the identity role, static configurable parameters of the large language model set based on the query task, and an output specification of the response result.
[0024] In some embodiments of the present invention, the extraction vector model is bge-base-zh-v1.5, and the vector database is Elasticsearch.
[0025] The second aspect of the present invention provides an enterprise knowledge base intelligent document query system, comprising a processor, a memory and a computer program stored in the memory, wherein the processor is used to execute the computer program / instructions, and when the computer program is executed, the system implements the steps of any of the above methods.
[0026] A third aspect of the present invention provides a computer-readable storage medium having a computer program / instruction stored thereon, which implements the steps of any of the above methods when executed by a processor.
[0027] A fourth aspect of the present invention provides a computer program product, comprising a computer program / instruction, which implements the steps of any of the above methods when executed by a processor.
[0028] The beneficial effects of the present invention are at least:
[0029] The present invention application provides an enterprise knowledge base intelligent document query method and system, which is deployed in the enterprise server for a large language model and an extraction vector model. Enterprise documents are screened, preprocessed to form standardized documents, and a knowledge base is constructed. Standardized documents are processed in blocks to generate document blocks, an inverted index table is constructed, and each document block is converted into a document block vector using an extraction vector model and stored. A user query request is received, the relevance of the user query request to all document blocks is calculated, and multiple candidate document blocks are screened. The similarity between the document block vector corresponding to the candidate document block and the query vector converted from the user query request is calculated, and the candidate document block with the highest similarity is selected. The candidate document block with the highest similarity, the user query request, and the preset configuration parameters are fused to generate prompt words, which are input into the large language model and the response result is output. The present invention designs a dual retrieval process in the intelligent retrieval method based on the large language model and the extraction vector model, obtains a preset number of preliminary screening document blocks related to the user query request by calculating BM25 to narrow the query scope, and then calculates the query vector converted from the user query request and the cosine similarity converted from the document block to obtain the document block with the highest similarity, thereby improving the professional ability of the output content.
[0030] Additional advantages, purposes, and features of the present invention will be described in part in the following description, and will become apparent to those skilled in the art after studying the following, or may be learned from the practice of the present invention. The purposes and other advantages of the present invention may be achieved and obtained by the structures specifically indicated in the specification and the accompanying drawings.
[0031] Those skilled in the art will appreciate that the objectives and advantages that can be achieved with the present invention are not limited to the above specific description, and the above and other objectives that can be achieved by the present invention will be more clearly understood from the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of the present application, and do not constitute a limitation of the present invention. In the drawings:
[0033] Figure 1 The figure is a flow chart of a method for intelligent document query in an enterprise knowledge base in one embodiment of the present invention.
[0034] Figure 2 This is a flow chart of the data preparation phase in another embodiment of the present invention.
[0035] Figure 3 A flowchart for obtaining the best relevant knowledge for data retrieval in another embodiment of the present invention.
[0036] Figure 4 This is a flow chart of fusing prompt words and generating content in another embodiment of the present invention.
[0037] Figure 5 This is a flow chart of dynamically updating the knowledge base in another embodiment of the present invention. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments and the accompanying drawings. Here, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0039] It should also be noted that, in order to avoid obscuring the present invention due to unnecessary details, only structures and / or processing steps closely related to the solutions according to the present invention are shown in the accompanying drawings, while other details that are not closely related to the present invention are omitted.
[0040] It should be emphasized that the term “include / comprises” when used herein refers to the presence of features, elements, steps or components, but does not exclude the presence or addition of one or more other features, elements, steps or components.
[0041] It should also be noted that, unless otherwise specified, the term “connection” herein may refer not only to a direct connection but also to an indirect connection with an intermediate.
[0042] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In the accompanying drawings, the same reference numerals represent the same or similar components, or the same or similar steps.
[0043] An embodiment of the present invention provides an enterprise knowledge base intelligent document query method, the method comprising the following steps S101 to S107:
[0044] Step S101: deploying a large language model and an extraction vector model for responding to query tasks in an enterprise server.
[0045] Step S102: Filter documents that meet preset format standards from enterprise documents, pre-process the documents to form standardized documents, and build a knowledge base as an external knowledge source for the large language model.
[0046] Step S103: Divide the standardized documents in the knowledge base into blocks to generate document blocks, generate numbers for each document block and calculate the word frequency of each document block to build an inverted index table. Use the vector extraction model to convert each document block into a document block vector in vector form and store it in the vector database of the knowledge base. The knowledge base responds to the received feedback information based on the feedback loop mechanism to continuously update.
[0047] Step S104: receiving a user query request, calculating the relevance scores between the user query request in text form and all document blocks, and ranking them to screen out a preset number of candidate document blocks according to preset rules.
[0048] Step S105: searching for the corresponding document block vector according to the number of the candidate document block, and converting the user query request into a query vector in vector form by using the vector extraction model.
[0049] Step S106: Calculate the cosine similarity between the query vector and the document block vectors corresponding to the candidate document blocks, and select the candidate document block with the highest similarity.
[0050] Step S107: The candidate document block with the highest similarity, the user query request and the preset configuration parameters are integrated to generate prompt words, the prompt words are input into the large language model, and a response result in a preset format is output.
[0051] In step S101, a large language model (LLM) is a large-scale neural network model based on a deep learning architecture such as Transformer, which can process and generate natural language text by training on large-scale text data. In the present invention, the large language model can be selected from Ollama, qwen2 or BigBird, etc.
[0052] Deploying large language models and extraction vector models locally in enterprise servers ensures that information is processed within the enterprise firewall to avoid the risk of information leakage.
[0053] In step S102, documents meeting a preset format standard are screened from enterprise documents in order to ensure the quality of information in the knowledge base.
[0054] In some embodiments, preprocessing the documents includes: cleaning and formatting the documents, deduplicating the documents, and randomly sampling and checking the documents. For example, the operation of cleaning and formatting the documents may be to remove outdated documents that have not been updated for a long time, and to remove template documents without actual content. Deduplicating the documents may be to filter out redundant copies of similar documents. Random sampling and checking the documents may be to manually check whether there is content in the randomly sampled documents that does not meet the preset standards or contains substantial errors.
[0055] In step S102, a knowledge base is constructed as an external knowledge source for the large language model, which enables the large language model to supplement the context and understand the question or text more deeply. In an enterprise environment, the large language model can access and analyze the internal enterprise knowledge base to support decision-making and information retrieval.
[0056] In step S103, the block processing is to divide the preprocessed document into meaningful paragraphs or chapters. For example, the block strategy can be: use Chinese period as segment identifier, set the maximum segment length to 512, replace continuous spaces, line breaks and tabs, and retain URL and email format.
[0057] Among them, the inverted index is an efficient index data structure, which is widely used in information retrieval and search engines. Its main function is to associate each term that appears in a document with the documents containing these terms, so as to quickly find documents containing specific terms. Compared with the traditional sequential index, the inverted index has a significant performance advantage when processing large-scale document collections.
[0058] In step S107, the prompt is a guiding input to the large language model, which is used to start or guide the large language model to generate text output of a specific type or style. It is a key mechanism to control the behavior and output of the model. The prompt is generated by fusing the candidate document blocks with the highest similarity, the user query request, and the preset configuration parameters to form a complete context for the large language model to understand and generate a response result.
[0059] In some embodiments, the knowledge base responds to received feedback information based on a feedback loop mechanism to continuously update, wherein the feedback information includes: feedback information based on user needs and feedback information based on system performance monitoring.
[0060] In some embodiments, the knowledge base responds to the received feedback information based on a feedback loop mechanism to continuously update, and the updated content includes: the number of each document block, the word frequency of each document block, the inverted index table and the document vector block.
[0061] For example, the feedback information is the user's demand for adding new documents. The feedback loop mechanism reuses the operations such as pre-processing and block processing of the documents in the above query method and then adds them to the processing flow of the knowledge base to update the knowledge base.
[0062] In some embodiments, the calculation formula for calculating the relevance scores of the user query request and all document blocks and ranking them is:
[0063]
[0064] Among them, q represents the user query request, q i represents each term split by the user query request q, C represents the document block, f(q i , C) represents the term q i The frequency of words appearing in document block C, |C| represents the length of document block C, avg(C) represents the average length of all document blocks, k and b represent adjustable parameters, and IDF(q i) represents the inverse document frequency, so IDF(q i ) is the term q i The weight among all document blocks is calculated as follows:
[0065]
[0066] Where N is the total number of all document blocks, n(q i ) is the term containing the term q i The number of blocks indicates the frequency of occurrence of the term in the block set.
[0067] In some embodiments, the preset configuration parameters include: a task description for informing the large language model of the identity role, static configurable parameters of the large language model based on the query task settings, and output specifications for the response results.
[0068] In some embodiments, the extraction vector model is bge-base-zh-v1.5, and the vector database is Elasticsearch.
[0069] Another embodiment of the present invention provides an enterprise knowledge base intelligent document query method and system, and the implementation scheme of the method is as follows:
[0070] 1. Model selection and deployment
[0071] In this embodiment, the selection and deployment of the Large Language Model (LLM) is the cornerstone of the intelligent document query and reading assistant system. The goal is to build an intelligent robot that can understand complex user questions and generate accurate responses to promote efficient retrieval and utilization of internal documents in the enterprise. The system involves two key components: one for text vectorization and the other as the core LLM, which is responsible for in-depth processing of user requests.
[0072] 1. Extract vector model: used to realize text vectorization
[0073] Model function: The extraction vector model (also called embedding model) converts words, phrases, sentences or documents into continuous digital vectors, so that texts with similar meanings are closer in the vector space. It can vectorize user requests and pre-prepared documents for easy retrieval and storage.
[0074] Deployment tools: Open source tools transformers to deploy models.
[0075] Open source model: Open source model bge-base-zh-v1.5, parameter selection 0.3B, model size 0.8G.
[0076] 2. Large language model: used to deeply understand questions and process user requests
[0077] Model function: Quickly understand the user's intention, combine the context information provided by the RAG system, and generate more detailed, professional and direct answers. It can quickly determine the type of document that the user may need through a pre-set label system, thereby guiding the RAG system to quickly locate relevant information. The model can handle more complex language structures and domain-specific terms to ensure that the final answer is both accurate and in-depth.
[0078] Deployment tool: open source tool Ollama deployment model.
[0079] Open source model: Alibaba open source model qwen2, parameter selection 8B, model size 4.4G.
[0080] Mechanism of action: ① Limit the scope of the request, identify the request intent and refuse to answer other questions except document retrieval and document content consultation. (② The key information extracted by the RAG system is passed to the LLM model together with the user's question. The core model integrates internal and external knowledge to generate the final response.
[0081] 2. Document Screening
[0082] In order to build a good private knowledge base, it is necessary to manually screen documents with clear expressions and standard formats from corporate documents.
[0083] 1. Cleaning and standardization
[0084] Only business knowledge documents and related documents are selected, and template documents without actual content, outdated documents that have not been updated for a long time (not updated for 5 years), and empty project documents are excluded; the documents are standardized, the content format is set and reformatted according to a fixed template, and the document format is unified using pdf / docx.
[0085] 2. Noise data removal
[0086] For duplicate removal, only one similar document should be selected to ensure the highest content coverage. Use the query directory of the internal document system of the enterprise to select the best document based on the overall project template and samples.
[0087] 3. Quality Assurance
[0088] Manual inspection: Randomly check a sample of pre-processed documents to confirm that they meet the above standards.
[0089] Feedback loop: Establish a review mechanism to continuously update the knowledge base through user feedback or system performance monitoring.
[0090] 3. Blocking and Storage
[0091] The document content of the established knowledge base is divided into blocks, an inverted index is constructed, and the embedded vectors are extracted and stored.
[0092] 1. Block strategy: Use Chinese period as segment identifier, set the maximum segment length to 512, replace consecutive spaces, line breaks, and tabs, and retain URL and email formats.
[0093] 2. Build index: Generate a number for each block, namely the block ID.
[0094] 3. Generate an inverted index: This is used to calculate the BM25 score in the retrieval phase to retrieve the associated block number and obtain the vector.
[0095] 4. Maintain the index table, calculate the word frequency, and dynamically update the index.
[0096] As an example, the left side of the inverted index table is the term (product line name), and the right side is a numbered list of the blocks in which the term appears. At the same time, TF is calculated, which represents the frequency of the term in the block.
[0097] Term "cloud letter"->[(block ID-1.1.1, TF=6)), (block ID-2.4.2, TF=4)];
[0098] Term "cloud rental"->[(block ID-3.5.1, TF=15), (block ID-3.5.4, TF=9), (block ID-5.5.8., TF=10)].
[0099] 5. Vector Expression
[0100] Use the vector extraction model bge-base-zh-v1.5 to convert document chunks containing at least one term into vector representations.
[0101] Normalize the generated vector and limit the vector value range to [-1, 1].
[0102] 6. Storage and Update
[0103] Storing vectors: The vectorized document blocks and their corresponding block numbers are stored in a vector database. This patent uses ES storage.
[0104] Dynamic Update: Allows the index to be updated in real time or periodically, ensuring that the database content is synchronized with the latest documents.
[0105] The flow chart of the above data preparation stage is as follows Figure 2 shown.
[0106] 4. Data Retrieval
[0107] 1. User query: In the question query interface, the user understands the functions of the intelligent document assistant based on the system prompts or opening remarks, and enters the business question to be queried.
[0108] 2. Preliminary screening of candidate documents, segmentation of the query, and retrieval using the B25 algorithm. The formula is as follows
[0109]
[0110] Among them, q refers to the overall question text of the user's query, q i Refers to each word item that is split into text q using the word segmentation tool THULAC, which does not include modal particles and predicates; C refers to a block in the knowledge base; f(q i , C) refers to the term q i The word frequency TF in the document block C; |C| is the length of the block, counted according to the word segmentation; avg(C) refers to the average length of all blocks; k and b are adjustable parameters, and in this embodiment, k and b are set to 1.2 and 0.75 respectively; IDF(q i ) is the inverse document frequency, which is used to measure the importance of a term in the entire document collection. In this embodiment, the documents are divided into blocks, so IDF(q i ) is the weight of the term in the block set, and the formula is as follows:
[0111]
[0112] Where N is the total number of blocks, n(q i ) is the term containing the term q i The number of blocks indicates the frequency of occurrence of the term in the block set.
[0113] The relevance score between the query text and all blocks is calculated through BM25. A higher score indicates a higher relevance between the query text and the corresponding block, while a negative score indicates a lower relevance. i The BM25 scores of all blocks are ranked, and after removing the negative scores, the top 10 document blocks are taken as preliminary screening candidate documents to participate in the subsequent similarity.
[0114] 3. Text conversion vector
[0115] According to the ID of the candidate document block, the corresponding digital vector is obtained from the vector database; the q input by the user is i The vector model bge-base-zh-v1.5 is extracted and converted into vector expression, and then normalized.
[0116] 4. Similarity retrieval (recall)
[0117] Calculate the cosine similarity between the query vector and the document block vector, that is, calculate the angle between the vectors in space. The formula is as follows:
[0118]
[0119] That is, the dot product of the two vectors divided by the product of the vector modulus. Since all vectors are normalized, the modulus is 1, and the similarity is A·R. The result is 10 similarity scores. The value range of cosine similarity is [-1, 1]. The closer the similarity is to 1, the more relevant the query and document block are. The document block with the highest similarity is taken as the relevant knowledge to participate in the subsequent prompt word fusion.
[0120] The above data retrieval process to obtain the best relevant knowledge is as follows Figure 3 shown.
[0121] 5. Prompt word design and content generation
[0122] As the input of the big model, the prompt words directly determine the quality of the content output by the model. Combining relevant knowledge can generate more reliable and controllable response content. The designed prompt words are input into the open source model qwen2, combined with relevant business knowledge, and finally output the fixed format response results.
[0123] Specifically, the prompt words include the following three contents:
[0124] 1. Task description, used to inform the big model of its identity and role, and to refuse to answer irrelevant questions, such as "You are an intelligent robot that can understand complex user questions and generate accurate responses. You only answer questions related to the business product line. The product line range is: {product}. The content of the answer refers to relevant business knowledge: {knowledge}".
[0125] Among them, {product} is a static configurable parameter. The business product lines designed in this embodiment include: cloud communication, cloud store, capital integration, asset integration, cloud leasing, chain communication, cloud factoring, cloud investment, asset securitization, cloud order, new generation of bills, standardized bills, cloud insurance, cloud second posting, cloud evidence storage, cloud business posting, BCP, Zheng Exin, cloud signature, cloud certificate, cloud data, and cloud intelligence.
[0126] Among them, {knowledge} is a dynamically passed parameter. Each time, according to the question requested by the user, after data retrieval, the most relevant document block is selected from the knowledge base and injected into the prompt word.
[0127] 2. User questions. Finally, the user’s query question q is integrated into the prompt and input into the large language model.
[0128] 3. Output specifications require the large language model to output JSON format messages, carrying the product line name and content, to facilitate upstream processing of response results.
[0129] The flowchart of combining the best relevant knowledge and user query questions, integrating prompt words and generating content is as follows: Figure 4 shown.
[0130] 6. Dynamically update the knowledge base
[0131] This embodiment can quickly realize real-time update of the knowledge base. By establishing a feedback loop mechanism, the knowledge base is continuously updated according to user feedback or system performance monitoring. For example, the feedback loop mechanism is a mechanism for dynamically adjusting documents according to user needs (which documents or knowledge of which product line are expected) or reporting outdated or erroneous knowledge.
[0132] The knowledge preparation process of the feedback loop mechanism includes: under the establishment of the feedback loop mechanism, high-quality documents are added to the knowledge base. After deduplication, the text can be directly divided into blocks according to the upper limit length of 512, and continuous spaces, line breaks and tabs are replaced, and the URL and email format are retained.
[0133] Each block is automatically assigned a globally unique number, the block ID.
[0134] Automatically update the inverted index table, that is, add the ID of each block and the term frequency TF number of the term involved in the block to the index corresponding to the product line term where the supplementary content is located.
[0135] The block ID and document block content are stored in the database. At the same time, the document block is converted into a vector expression by extracting the vector model bge-base-zh-v1.5, and stored in the vector database after normalization.
[0136] The above dynamic update knowledge base process reuses the logic in document screening and data preparation to complete the automatic update operation. At this point, during subsequent data retrieval and content generation, the updated content can be detected by the system. Figure 5 shown.
[0137] In summary, the present invention provides a method and system for intelligent document query of an enterprise knowledge base, the method comprising: deploying a large language model and an extraction vector model in an enterprise server. Preprocessing the screened enterprise documents to form standardized documents and constructing a knowledge base. Blocking the documents to generate document blocks, constructing an inverted index table, and using the extraction vector model to convert each document block into a document block vector and store it. Receive a user query request, calculate the correlation between the user query request and all document blocks, and screen out a preset number of candidate document blocks. Find the document block vector corresponding to the candidate document block, convert the user query request into a query vector, calculate the similarity between the query vector and the document block vector corresponding to the candidate document block, and select the candidate document block with the highest similarity. The candidate document block with the highest similarity, the user query request, and the preset configuration parameters are integrated to generate prompt words, which are input into the large language model and the response results are output. The present invention provides an intelligent query method with higher professionalism and accuracy for enterprise document query.
[0138] Corresponding to the above method, the present invention also provides a system, which includes a computer device, the computer device includes a processor and a memory, the memory stores computer instructions, the processor is used to execute the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the system implements the steps of the method described above.
[0139] The embodiment of the present invention also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the aforementioned edge computing server deployment method are implemented. The computer-readable storage medium can be a tangible storage medium, such as a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a floppy disk, a hard disk, a removable storage disk, a CD-ROM, or any other form of storage medium known in the technical field.
[0140] It should be understood by those skilled in the art that the exemplary components, systems and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software or a combination of the two. Whether it is performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present invention are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link via a data signal carried in a carrier.
[0141] It should be clear that the present invention is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present invention.
[0142] In the present invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with features of other embodiments or replace features of other embodiments.
[0143] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for intelligent document query in an enterprise knowledge base, characterized in that: The method comprises the following steps: Deploy large language models and extracted vector models in enterprise servers for query response tasks; Screening documents that meet preset format standards from enterprise documents, preprocessing the documents to form standardized documents to construct a knowledge base as an external knowledge source for the large language model; The standardized documents in the knowledge base are divided into blocks to generate document blocks, each document block is numbered and the word frequency of each document block is calculated to construct an inverted index table; each document block is converted into a document block vector in vector form using the extraction vector model, and stored in a vector database of the knowledge base; the knowledge base responds to the received feedback information based on a feedback loop mechanism to continuously update; Receive a user query request, calculate the relevance scores of the user query request in text form and all document blocks, and rank them to screen out a preset number of candidate document blocks according to preset rules; Searching for a corresponding document block vector according to the number of the candidate document block, and converting the user query request into a query vector in vector form using the extraction vector model; Calculating the cosine similarity between the query vector and the document block vectors corresponding to the candidate document blocks, and selecting the candidate document block with the highest similarity; The candidate document block with the highest similarity, the user query request and preset configuration parameters are integrated to generate prompt words, the prompt words are input into the large language model, and a response result in a preset format is output.
2. The enterprise knowledge base intelligent document query method according to claim 1, characterized in that: The preprocessing of the document includes: cleaning and unifying the format of the document, deduplicating the document, and randomly sampling and checking the document.
3. The enterprise knowledge base intelligent document query method according to claim 1, characterized in that: The knowledge base responds to the received feedback information based on a feedback loop mechanism to continuously update, wherein the feedback information includes: feedback information based on user needs and feedback information based on system performance monitoring.
4. The enterprise knowledge base intelligent document query method according to claim 1, characterized in that: The knowledge base responds to the received feedback information based on a feedback loop mechanism to continuously update, and the updated content includes: the number of each document block, the word frequency of each document block, the inverted index table and the document vector block.
5. The enterprise knowledge base intelligent document query method according to claim 1, characterized in that: The calculation formula for calculating the relevance scores of the user query request and all document blocks and ranking them is: Wherein, q represents the user query request, q i represents each term split by the user query request q, C represents the document block, f(q i , C) represents the term q i The frequency of words appearing in the document block C, |C| represents the length of the document block C, avg(C) represents the average length of all document blocks, k and b represent adjustable parameters, IDF(q i ) represents the inverse document frequency, so IDF(q i ) is the term q i The weight among all document blocks is calculated as follows: Where N is the total number of all document blocks, n(q i ) is the term containing the term q i The number of blocks indicates the frequency of occurrence of the term in the block set.
6. The enterprise knowledge base intelligent document query method according to claim 1, characterized in that: The preset configuration parameters include: a task description for informing the large language model of the identity role, static configurable parameters of the large language model set based on the query task, and an output specification of the response result.
7. The enterprise knowledge base intelligent document query method according to claim 1, characterized in that: The extraction vector model is bge-base-zh-v1.5, and the vector database is Elasticsearch.
8. An enterprise knowledge base intelligent document query system, comprising a processor, a memory and a computer program stored in the memory, characterized in that: The processor is used to execute the computer program / instructions, and when the computer program is executed, the system implements the steps of the method according to any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the steps of the method as claimed in any one of claims 1 to 7 are implemented.
10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Information extraction method and field selection method
CN119226498A
Enterprise suitability information retrieval system based on RAG technology
CN119474249A
Data security document generation method and system based on RAG technology
CN119475436A
System and method for constructing business and data fusion knowledge based on enterprise architecture
CN119622627A
Large model knowledge base retrieval method based on multi-granularity retrieval
CN119646201A
