Intelligent document question and answer method, device and equipment and storage medium
By combining a hybrid retrieval method of keyword matching and vector matching in an intelligent document question-answering system, the problem of inaccurate information retrieval in the existing technology is solved, and more accurate and comprehensive answer generation is achieved.
Patent Information
- Application Number
- CN202510744606.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2025-09-26
AI Technical Summary
When the existing intelligent document question-answering system is based on RAG technology, there are problems such as failure to retrieve relevant information or inaccurate information retrieved, which affects the quality of the answer.
A hybrid retrieval method of keyword matching and vector matching is used to retrieve keyword document fragments and vector document fragments from the target document knowledge base, generate recall block information, and generate answers through a large model.
It improves the retrieval accuracy of document fragments, enriches the semantic coverage of retrieval results, and makes the answers more accurate and comprehensive.
Smart Images

Figure CN120706544A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of intelligent question-answering technology, and in particular to intelligent document question-answering methods, devices, equipment, and storage media. Background Art
[0002] Intelligent document question-answering systems are gradually gaining widespread application. For example, some companies use large-scale model-based question-answering systems to handle daily employee inquiries, such as those regarding attendance policies, benefits systems, and training courses, in order to improve work efficiency and employee satisfaction. However, existing intelligent document question-answering systems primarily use Retrieval Augmented Generation (RAG) technology for retrieval. While RAG technology has improved the performance of question-answering systems to a certain extent, it may also have some limitations. For example, the system may fail to retrieve relevant information, or the retrieved information may be inaccurate, thus affecting the quality of the generated answers.
[0003] The above content is only used to assist in understanding the technical solution of this application and does not constitute an admission that the above content is prior art. Summary of the Invention
[0004] The main purpose of this application is to provide an intelligent document question-answering method, device, equipment and storage medium, aiming to solve the technical problem that when performing information retrieval based on RAG technology, relevant information cannot be retrieved or the retrieved information is inaccurate, which affects the quality of the answer.
[0005] To achieve the above objectives, this application proposes an intelligent document question-answering method, which includes:
[0006] Obtain the target query questions of the target users;
[0007] Based on keyword matching and vector matching, keyword document fragments and vector document fragments related to the target query question are retrieved from the target document knowledge base;
[0008] generating recall block information according to the keyword document fragment and the vector document fragment;
[0009] A large model prompt word is generated according to the recall block information, and target answer information for the target query question is output according to the large model prompt word through the large model.
[0010] In one embodiment, the step of obtaining the target query question of the target user includes:
[0011] Obtaining the target user's initial query question;
[0012] Based on the historical query information of the target user, the initial query question is rewritten to obtain a target query question, wherein the question rewriting includes at least one of typo correction, reference disambiguation, and context missing supplementation.
[0013] In one embodiment, the step of rewriting the initial query question to obtain the target query question includes:
[0014] Rewriting the initial query question to obtain a first query question;
[0015] Outputting initial answer information for the first query question through the large model;
[0016] Analyzing the initial answer information to obtain relevant question and answer information for the first query question, wherein the relevant question and answer information includes at least one of keyword information, similar semantic information, hypothetical information, and intent recognition information;
[0017] Based on the relevant question and answer information, the first query question is expanded to obtain a target query question.
[0018] In one embodiment, the step of generating recall block information according to the keyword document segment and the vector document segment includes:
[0019] Determining a first similarity score between the target query and the keyword document segment;
[0020] Determining a second similarity score between the target query and the keyword document fragment;
[0021] Based on the first similarity score, sort all keyword document fragments in descending order to obtain a first sorted document;
[0022] Based on the second similarity score, sorting all vector document segments in ascending order to obtain second sorted documents;
[0023] Recall block information is generated according to the first sorted document and the second sorted document.
[0024] In one embodiment, the step of generating a large model prompt word according to the recall block information includes:
[0025] Determine the task requirements of the target user and use the task requirements as the beginning;
[0026] The recall block information is written after the beginning portion to obtain a large model prompt word.
[0027] In one embodiment, before the step of retrieving keyword document segments and vector document segments related to the target query question from the target document knowledge base based on keyword matching and vector matching, the step further includes:
[0028] Determining the query intent of the target query question, and determining a target query scenario based on the query intent;
[0029] Determine a document knowledge base to be searched corresponding to the target query question according to the target query scenario;
[0030] Determining the knowledge base authority information of the target user according to the identity information of the target user;
[0031] Based on the knowledge base authority information, a target document knowledge base is determined from the document knowledge bases to be searched.
[0032] In one embodiment, before the step of obtaining the target query question of the target user, the method further includes:
[0033] Obtain documents of the target user's company in different query scenarios;
[0034] When the document is a structured document, segmenting the document according to the chapter titles to obtain a first document segment;
[0035] When the document is an unstructured document, segmenting the document according to topics or keywords to obtain second document segments;
[0036] When the document is a short document, segmenting the document according to the paragraph information to obtain third document information;
[0037] The first document fragment, the second document fragment, and the third document fragment are stored in a document knowledge base corresponding to the query scenario.
[0038] In addition, to achieve the above-mentioned purpose, the present application also proposes an intelligent document question-answering device, which includes:
[0039] An acquisition module is used to obtain the target query questions of the target users;
[0040] A retrieval module is used to retrieve keyword document fragments and vector document fragments related to the target query question from the target document knowledge base based on keyword matching and vector matching;
[0041] A generating module, configured to generate recall block information according to the keyword document fragment and the vector document fragment;
[0042] An output module is used to generate a large model prompt word according to the recall block information, and output target answer information for the target query question according to the large model prompt word through the large model.
[0043] In addition, to achieve the above-mentioned purpose, the present application also proposes an intelligent document question-and-answer device, which includes: a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the computer program is configured to implement the steps of the intelligent document question-and-answer method as described above.
[0044] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the intelligent document question and answer method described above are implemented.
[0045] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of the intelligent document question and answer method as described above.
[0046] One or more technical solutions proposed in this application have at least the following technical effects:
[0047] The intelligent document question-answering method, apparatus, device and storage medium proposed in this application obtains the target query question of the target user; retrieves the keyword document fragment and the vector document fragment related to the target query question from the target document knowledge base based on keyword matching and vector matching; generates recall block information based on the keyword document fragment and the vector document fragment; generates a large model prompt word based on the recall block information, and outputs the target answer information for the target query question based on the large model prompt word through the large model. It solves the technical problem that when performing information retrieval based on RAG technology, relevant information cannot be retrieved or the retrieved information is inaccurate, which affects the answer quality. Compared with the existing technology, this application performs hybrid retrieval through keyword matching and vector matching, thereby improving the retrieval accuracy of document fragments. In addition, this application combines keyword document fragments and vector document fragments to jointly generate recall block information, further enriching the semantic coverage of the retrieval results, making the generated answers more accurate and comprehensive. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0049] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0050] Figure 1 A flowchart of the first embodiment of the intelligent document question-and-answer method of this application is provided;
[0051] Figure 2 A flowchart of the second embodiment of the intelligent document question-answering method of this application is provided;
[0052] Figure 3 This is a schematic diagram of the module structure of the intelligent document question-and-answer device according to an embodiment of the present application;
[0053] Figure 4 This is a schematic diagram of the device structure of the hardware operating environment involved in the intelligent document question-and-answer method in the embodiment of this application.
[0054] The purpose, features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0055] It should be understood that the specific embodiments described herein are merely used to explain the technical solutions of the present application and are not intended to limit the present application.
[0056] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0057] The main solution of the embodiment of the present application is: obtaining the target query question of the target user; based on keyword matching and vector matching, retrieving keyword document fragments and vector document fragments related to the target query question from the target document knowledge base; generating recall block information according to the keyword document fragments and the vector document fragments; generating a large model prompt word according to the recall block information, and outputting the target answer information for the target query question according to the large model prompt word through the large model.
[0058] As can be seen from the above embodiments, the intelligent document question-answering method, apparatus, device and storage medium proposed in this application obtains the target query question of the target user; retrieves the keyword document fragment and the vector document fragment related to the target query question from the target document knowledge base based on keyword matching and vector matching; generates recall block information based on the keyword document fragment and the vector document fragment; generates a large model prompt word based on the recall block information, and outputs the target answer information for the target query question based on the large model prompt word through the large model. It solves the technical problem that when performing information retrieval based on RAG technology, relevant information cannot be retrieved or the retrieved information is inaccurate, which affects the answer quality. Compared with the existing technology, this application performs hybrid retrieval through keyword matching and vector matching, thereby improving the retrieval accuracy of document fragments. In addition, this application combines keyword document fragments and vector document fragments to jointly generate recall block information, further enriching the semantic coverage of the retrieval results, making the generated answers more accurate and comprehensive.
[0059] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, mobile phone, etc., or an electronic device capable of implementing the above functions, such as an intelligent document question-and-answer device. The following uses the intelligent document question-and-answer device as an example to illustrate this embodiment and the following embodiments.
[0060] Based on this, the embodiment of the present application provides an intelligent document question-answering method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the intelligent document question-and-answer method of this application.
[0061] In this embodiment, the intelligent document question-answering method includes steps S10 to S40:
[0062] Step S10, obtaining the target query question of the target user;
[0063] It should be noted that the target user can enter questions through voice input, text input, or multimodal methods (such as through images, charts, videos, etc.). The target query questions can be pre-processed, such as removing extra spaces and punctuation marks in the input text to ensure neat input.
[0064] Step S20: Retrieve keyword document segments and vector document segments related to the target query question from the target document knowledge base based on keyword matching and vector matching;
[0065] It should be noted that keyword matching involves identifying keywords in the target query and searching for document fragments containing these keywords in the target document knowledge base. Vector matching involves converting the target query and document fragments into vector representations and calculating the semantic similarity between them. The target document knowledge base contains a variety of scenarios in the human resources field, such as recruitment processes, employee onboarding guides, attendance policies, benefits systems, training courses, performance evaluations, and the resignation process. These documents have been carefully organized and segmented into appropriately sized fragments to cover the issues employees may encounter at different stages of their careers. By segmenting documents and storing them in the knowledge base, the system can quickly locate specific information related to the user's query without having to conduct a full-text search within the massive original documents. This structured storage method improves retrieval efficiency and accuracy.
[0066] In specific implementations, keyword matching can utilize ES (Elasticsearch) keyword matching technology, while vector matching can utilize Milvus vector matching. ES keyword matching can quickly locate specific keywords, making it suitable for handling precise queries. Milvus vector matching can supplement semantic relevance and handle ambiguous or incomplete queries. Combining these two approaches enables a more comprehensive retrieval of document fragments relevant to the user's query, thereby improving search accuracy and recall, reducing omissions or misjudgments caused by a single search method, and ultimately providing users with higher-quality answers.
[0067] In a feasible implementation manner, before the step of retrieving keyword document fragments and vector document fragments related to the target query question from the target document knowledge base based on keyword matching and vector matching, it also includes: before the step of retrieving keyword document fragments and vector document fragments related to the target query question from the target document knowledge base based on keyword matching and vector matching, it also includes: determining the query intent of the target query question, and determining the target query scenario based on the query intent; determining the document knowledge base to be queried corresponding to the target query question based on the target query scenario; determining the knowledge base authority information of the target user based on the identity information of the target user; and determining the target document knowledge base from the document knowledge base to be queried based on the knowledge base authority information.
[0068] It's important to note that the query intent, determined by the target query question, can be used to select appropriate and authorized document knowledge bases for querying. For example, when management employees and general employees submit queries, the system dynamically selects the appropriate document knowledge base based on their roles and permissions, as well as the specific content of the query (query scenario). Specifically, if a general employee wants to learn about the company's annual leave policy, the system will first analyze their query intent and determine that they are looking for information about it. Since general employees' permissions are typically limited to publicly available company policies and procedures, the system automatically selects the "public knowledge base" for querying. This knowledge base stores general information accessible to all employees, such as company rules and regulations and benefits policies. Therefore, the system retrieves document snippets related to the annual leave policy from this knowledge base, such as "Company annual leave policy stipulates that employees are entitled to 10 days of paid annual leave each year..." and presents them to the general employee. Management employees, on the other hand, may need to query more sensitive or specific information, such as employee performance evaluation reports or the company's strategic plan. When a management employee submits a query, the system also analyzes the query intent. However, because management employees have higher permissions and can access internal or sensitive information, the system selects the "Internal Knowledge Base" or "Sensitive Knowledge Base" for the query. For example, if a management employee wants to view Employee A's performance evaluation report, the system will retrieve detailed document fragments related to Employee A's performance evaluation from the "Internal Knowledge Base," such as "Employee A's performance rating for this quarter is..." This information is usually inaccessible to ordinary employees.
[0069] In this embodiment, the system accurately selects the appropriate document knowledge base for querying based on query intent and user permissions, meeting user query needs while ensuring information security and compliance. This strategy is particularly important in internal enterprise information management systems, as it helps employees at all levels quickly access information appropriate to their responsibilities and permissions, while preventing inappropriate access and leakage of sensitive information.
[0070] In a feasible implementation, before the step of obtaining the target query question of the target user, it also includes: obtaining documents of the target user's company in different query scenarios; when the document is a structured document, segmenting the document according to the chapter title to obtain a first document fragment; when the document is an unstructured document, segmenting the document according to the subject or keyword to obtain a second document fragment; when the document is a short document, segmenting the document according to paragraph information to obtain third document information; storing the first document fragment, the second document fragment and the third document fragment in the document knowledge base corresponding to the query scenario.
[0071] It should be noted that for structured documents (such as employee handbooks and training materials), they can be segmented according to chapter titles. For example, the employee handbook can be segmented into chapters such as "Onboarding Process", "Salary and Benefits", and "Performance Appraisal". For unstructured documents (such as recruitment materials and performance evaluation reports), they can be segmented according to topics or keywords. For example, recruitment materials can be segmented according to topics such as "Job Requirements", "Interview Process", and "Salary and Benefits". For some short documents, they can be segmented by paragraphs to ensure that each segment contains a complete meaning unit, which can avoid information fragmentation while maintaining the semantic integrity of the document. Specifically, NLP tools (such as NLTK and spaCy) can be used for text analysis and segmentation. These tools can perform intelligent segmentation based on sentence structure, keywords, etc.
[0072] It's understandable that all documents within the same query scenario can be segmented and stored in the document knowledge base corresponding to that query scenario. For example, all document fragments related to "recruitment process" can be stored in the "recruitment process" knowledge base, while document fragments related to "employee training" can be stored in the "employee training" knowledge base. The benefit of this approach is that when a user initiates a query request, the system can determine the corresponding query scenario based on the user's query intent, quickly locate the corresponding knowledge base, and retrieve the most relevant document fragments from it. Furthermore, by configuring query permissions for each user, users can only access content they are authorized to view, thereby ensuring information security and compliance. For example, ordinary employees may only have access to a public policy and procedure knowledge base, while HR administrators have access to a broader internal document knowledge base. This scenario- and permission-based document management and retrieval mechanism not only improves the efficiency and accuracy of information retrieval, but also enhances the security and flexibility of the system.
[0073] Step S30, generating recall block information according to the keyword document fragment and the vector document fragment;
[0074] It should be noted that keyword document fragments refer to document fragments retrieved from the target document knowledge base through keyword matching, while vector document fragments refer to document fragments retrieved from the target document knowledge base through vector matching. These documents can be sorted in sequence to generate the final recall block information.
[0075] In a feasible implementation, the step of generating recall block information based on the keyword document fragment and the vector document fragment includes: determining a first similarity score between the target query question and the keyword document fragment; determining a second similarity score between the target query question and the keyword document fragment; based on the first similarity score, sorting all keyword document fragments in descending order to obtain a first sorted document; based on the second similarity score, sorting all vector document fragments in ascending order to obtain a second sorted document; and generating recall block information based on the first sorted document and the second sorted document.
[0076] It should be noted that the first similarity score refers to the similarity score between the target query and each keyword document fragment; the second similarity score refers to the similarity score between the target query and each vector document fragment. Specifically, keyword matching algorithms (such as TF-IDF, BM25, etc.) can be used to calculate the first similarity scores, which reflect the relevance of the keyword document fragments to the query. Vector similarity calculation methods (such as cosine similarity, Euclidean distance, etc.) can also be used to calculate the second similarity scores, which reflect the semantic relevance of the vector document fragments to the query.
[0077] In a specific implementation, all keyword document segments can be sorted in descending order based on the first similarity score (i.e., all keyword document segments are sorted in descending order according to the first similarity score) to obtain a first ranked document. By sorting the keyword document segments in descending order, it is ensured that the most relevant keyword document segments are placed before the first ranked document. All vector document segments can be sorted in ascending order based on the second similarity score (i.e., all vector document segments are sorted in ascending order according to the second similarity score) to obtain a second ranked document. By sorting the vector document segments in ascending order, it is ensured that the most semantically relevant vector document segments are placed after the second ranked document.
[0078] In a specific implementation, before sorting all keyword document fragments, a contextual relevance analysis can be performed on all keyword document fragments. For example, if multiple keyword document fragments come from the same document and are adjacent in the document, they can be sorted as a whole. For example, if keyword document A and keyword document segment B come from the same document, and keyword document B follows keyword document A, the system can merge them into a larger keyword document fragment before sorting. This merging operation preserves the semantic connection between keyword document fragments, making the generated recall block information more coherent.
[0079] In a specific implementation, before sorting all vector document segments, a contextual relevance analysis can be performed on all vector document segments. For example, if multiple vector document segments come from the same document and are adjacent in the document, they can be sorted as a whole. For example, if vector document A and vector document segment B come from the same document, and vector document B follows vector document A, the system can merge them into a larger keyword document segment before sorting. This merging operation preserves the semantic connection between vector document segments, making the generated recall block information more coherent.
[0080] It is understandable that when generating recall block information, we place keyword document fragments with high similarity scores at the beginning of the recall block and vector document fragments with high scores at the end of the recall block. Since large models pay more attention to these two places, they usually give more accurate answers.
[0081] Step S40: Generate a large model prompt word according to the recalled block information, and output target answer information for the target query question according to the large model prompt word through the large model.
[0082] It is understandable that the large model prompt words can be used to guide the model to generate output that meets user needs, that is, the large model prompt words can be used to clearly specify the theme, style, length, etc. of the generated content.
[0083] In a feasible implementation, the step of generating a large model prompt word based on the recall block information includes: determining the task requirements of the target user and using the task requirements as the beginning part; writing the recall block information after the beginning part to obtain a large model prompt word.
[0084] It should be noted that the target user's task requirements can be some output formats or output requirements; the task requirements are used as the beginning of the large model prompt word, followed by the recall block information. In this way, the task requirements at the beginning of the large model prompt word can be used to constrain the large model's answer, thereby reducing the large model's dependence on the task requirements. The keyword document fragments with high similarity scores are placed at the beginning of the recall block, and the vector document fragments with high scores are placed at the end of the recall block. Since the large model pays more attention to these two places, it usually has a more accurate answer.
[0085] In this example, the target user's task requirements are determined and used as the initial part, combined with the recall block information to generate large model prompts. These large model prompts provide the large language model with clear instructions and rich contextual information, guiding the model to generate high-quality responses. By optimizing prompt generation and large model responses, the system can better meet user needs, improving user experience and answer accuracy.
[0086] The intelligent document question-answering method, apparatus, device and storage medium proposed in this application obtains the target query question of the target user; retrieves the keyword document fragment and the vector document fragment related to the target query question from the target document knowledge base based on keyword matching and vector matching; generates recall block information based on the keyword document fragment and the vector document fragment; generates a large model prompt word based on the recall block information, and outputs the target answer information for the target query question based on the large model prompt word through the large model. It solves the technical problem that when performing information retrieval based on RAG technology, relevant information cannot be retrieved or the retrieved information is inaccurate, which affects the answer quality. Compared with the existing technology, this application performs hybrid retrieval through keyword matching and vector matching, thereby improving the retrieval accuracy of document fragments. In addition, this application combines keyword document fragments and vector document fragments to jointly generate recall block information, further enriching the semantic coverage of the retrieval results, making the generated answers more accurate and comprehensive.
[0087] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the first embodiment can be referred to the above introduction and will not be described in detail later. Figure 2 , step S10 further includes steps S101 to S102:
[0088] Step S101, obtaining the target user's initial query question;
[0089] It should be noted that the initial query question refers to the question that the user first enters; since the initial query question may contain typos, semantic ambiguity, unclear references or missing context, these problems may affect the accuracy and relevance of the query results, so the initial query question needs to be rewritten.
[0090] Step S102 : rewriting the initial query question based on the historical query information of the target user to obtain a target query question, wherein the question rewriting includes at least one of typo correction, reference disambiguation, and context missing supplementation.
[0091] It's important to note that historical query information refers to the user's previous queries and their responses. This information reflects the user's interests, query habits, and potential language patterns. By analyzing historical query information, the system can better understand the intent and context of the initial query, allowing for more precise rephrasing of the initial query, improving query accuracy and user experience.
[0092] Understandably, users may make typos when entering queries due to spelling errors, keyboard misuse, or unfamiliarity with certain vocabulary. For example, a user might mistakenly write "smartphone" as "smart notes." Therefore, spelling checking and error correction algorithms within natural language processing (NLP) can be used to correct typos in initial queries, combined with the user's commonly used vocabulary and expressions from historical query information. By correcting typos, the system can more accurately understand the user's true intent and avoid irrelevant or no results due to spelling errors.
[0093] It is understandable that in natural language, pronouns (such as "he", "she", "it", "this", and "that") are very commonly used, but their referents may not be clear. For example, when a user queries, he may say "I want to know its price", and "it" may refer to the goods or services mentioned previously. Therefore, by analyzing the context in the historical query information and combining the user's previous query content and interaction records, the specific referent of the pronoun can be clarified. For example, if the user has previously searched for "Model A mobile phone", then "it" may refer to "Model A mobile phone". Through reference disambiguation, the system can more accurately understand the specific content of the user's question and avoid inaccurate query results due to unclear reference.
[0094] It's understandable that when users enter queries, they may omit important contextual information due to brevity of language or unfamiliarity with system functionality. For example, a user might simply enter "nearest restaurant" without specifying a specific location or time. Therefore, by analyzing the user's historical query information, combined with the user's geographic location, query time, and previous interactions, the system can automatically supplement the missing contextual information. For example, if a user has previously searched for "nearby coffee shops," it can be inferred that the user may be asking about restaurants near their current location. By supplementing this contextual information, the system can provide more accurate query results, avoiding irrelevant or inaccurate results due to incomplete information.
[0095] In a feasible implementation, the step of rewriting the initial query question to obtain a target query question includes: rewriting the initial query question to obtain a first query question; outputting initial answer information for the first query question through the large model; analyzing the initial answer information to obtain relevant question and answer information of the first query question, wherein the relevant question and answer information includes at least one of keyword information, similar semantic information, hypothetical information, and intent recognition information; based on the relevant question and answer information, expanding the first query question to obtain a target query question.
[0096] It should be noted that the large model can first give a brief answer to the user's question based on its own knowledge. The answer of the large model usually includes the keywords of the real answer or sentences with similar semantics. Therefore, using the initial answer of the large model can help recall the article fragment where the real answer is located, thereby improving the recall and answer accuracy.
[0097] It can be understood that the first query question refers to a query question obtained by rewriting the initial query question; and the target query question refers to a query question obtained by expanding the first query question.
[0098] It should be noted that the initial answer information generated by the large model can be deeply analyzed to extract question and answer information related to the first query question (i.e., relevant question and answer information). This information includes at least the following:
[0099] Keyword Information: Extract keywords related to the core content of the question from the initial answer information. These keywords directly reflect the question's theme and focus and are crucial for query optimization. Specifically, keywords can be extracted from the initial answer information based on word frequency statistics. For example, in the initial answer information for the question "Does the company's annual leave policy vary depending on years of service and position?", terms such as "annual leave," "policy," "years of service," and "position" appear frequently and are likely keywords. Semantic analysis of the initial answer information can also be used to identify terms directly related to the question topic using natural language processing techniques (such as part-of-speech tagging and dependency parsing). For example, "annual leave" is typically associated with vacation policies, while "years of service" relates to an employee's tenure. When expanding the question, these keywords can be added to make it more specific. For example, expanding "I would like to know the company's annual leave policy" to "I would like to know the annual leave policy for employees who have been employed for three years or more."
[0100] Similar semantic information: This identifies expressions in the initial answer that are semantically similar to the query, helping the system understand different query expressions. For example, "vacation" and "annual leave" are semantically similar. Specifically, word embedding technology can be used to calculate semantic similarity between words using pre-trained word vector models (such as Word2Vec and BERT). For example, "vacation" and "annual leave" are close in word vector space and have similar semantics. Synonym libraries can also be used to search for words with similar semantics to keywords using synonym dictionaries (such as WordNet). For example, words like "holiday," "vacation system," and "paid vacation" are semantically similar to "annual leave." When expanding questions, these semantically similar words can be used as alternatives to make the question more consistent with the user's expression habits. For example, expanding "I want to know about the company's annual leave policy" to "I want to know about the company's paid vacation policy."
[0101] Hypothetical Information: Based on the initial answer, you can generate some possible hypotheses or supplementary information to enrich the context and details of the question. For example, assume that the user may be interested in the benefits policy for a specific type of employee. Specifically, you can combine the user's previous query history and the context of the current question to infer the specific content the user may be interested in. For example, if the user has previously searched for "new employee training process," then when answering "company benefits policy," you can assume that the user may be interested in "new employee benefits policy." You can also leverage entity relationships in the knowledge graph to generate supplementary information related to the question. For example, if the question involves "benefits policy," you can assume that the user may be interested in information such as "benefits types," "benefits application process," and "benefits differences between different positions." When expanding the question, you can use this hypothetical information as supplementary context to make the question more complete. For example, you can expand "I want to know the company's benefits policy" to "I want to know the benefits policy for new employees."
[0102] Intent recognition information: By analyzing the initial answer information, the user's true intent can be further clarified. For example, the user may want to understand the specific content of the company's benefits policy, or compare the benefits of different positions. Specifically, machine learning or deep learning models (such as BERT classifiers) can be used to classify the intent of the initial answer information. For example, "the company's benefits policy" can be classified as the intent of "querying benefits policy." The user's true intent can also be inferred by combining the user's historical query records and the context of the current question. For example, if the user has previously searched for "the training process for new employees," then when answering "the company's benefits policy," it can be inferred that the user may want to understand "the benefits policy for new employees." When expanding the question, the question wording can be adjusted based on the intent recognition information to make it more in line with the user's true needs. For example, "I want to know the company's benefits policy" can be expanded to "I want to know the content and application process of the benefits policy for new employees."
[0103] In a specific implementation, sentiment analysis can be performed on the user's initial query question (for example, the initial query question is input into a sentiment analysis model to identify the user's emotions), identify the user's emotional tendencies (such as eagerness, curiosity, confusion, etc.), and adjust the question expansion strategy based on the emotional tendencies. For example, if the user is anxious, a more concise and direct question can be generated (that is, the initial query question is slightly expanded, and only one type of relevant question and answer information is used for expansion during the slight expansion); if the user is curious, a more detailed and exploratory question can be generated (that is, the initial query question is deeply expanded, and the deep expansion needs to be expanded based on all relevant question and answer information). By introducing a sentiment analysis model into the intelligent document question and answer system and dynamically adjusting the question expansion strategy based on the user's emotional tendencies, the user experience and interaction efficiency can be significantly improved.
[0104] This embodiment obtains the target user's initial query; based on the target user's historical query information, the initial query is rewritten to obtain a target query. The rewriting includes at least one of correcting typos, resolving references, and supplementing missing context. Analyzing historical query information allows for a better understanding of the intent and context of the initial query, enabling more precise rewriting of the initial query, improving query accuracy and user experience.
[0105] It should be noted that the above examples are only used to understand this application and do not constitute a limitation on the intelligent document question-and-answer method of this application. More simple transformations based on this technical concept are all within the scope of protection of this application.
[0106] This application also provides an intelligent document question-answering device, please refer to Figure 3 , the intelligent document question-answering device includes:
[0107] An acquisition module 10 is used to acquire a target query question of a target user;
[0108] A retrieval module 20 is configured to retrieve keyword document segments and vector document segments related to the target query from a target document knowledge base based on keyword matching and vector matching;
[0109] A generating module 30, configured to generate recall block information according to the keyword document fragment and the vector document fragment;
[0110] The output module 40 is configured to generate a large model prompt word according to the recall block information, and output target answer information for the target query question according to the large model prompt word through the large model.
[0111] The intelligent document question-and-answer device provided in this application, which employs the intelligent document question-and-answer method of the aforementioned embodiment, can resolve the technical problem of failing to retrieve relevant information or inaccurate information retrieved, which affects the quality of answers, when performing information retrieval based on RAG technology. Compared to the prior art, the beneficial effects of the intelligent document question-and-answer device provided in this application are the same as those of the intelligent document question-and-answer method provided in the aforementioned embodiment, and the other technical features of the intelligent document question-and-answer device are the same as those disclosed in the aforementioned embodiment method, and are not further elaborated here.
[0112] The present application provides an intelligent document question-and-answer device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the intelligent document question-and-answer method in the above-mentioned embodiment one.
[0113] Reference below Figure 4 , which shows a schematic diagram of the structure of an intelligent document question-and-answer device suitable for implementing an embodiment of the present application. The intelligent document question-and-answer device in the embodiment of the present application may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 4 The intelligent document question-and-answer device shown is merely an example and should not limit the functions and scope of use of the embodiments of the present application.
[0114] like Figure 4 As shown, the intelligent document question-answering device may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes based on programs stored in a read-only memory 1002 or programs loaded from a storage device 1003 into a random access memory 1004. Random access memory 1004 also stores various programs and data required for the operation of the intelligent document question-answering device. The processing device 1001, the read-only memory 1002, and the random access memory 1004 are interconnected via a bus 1005. An input / output interface 1006 is also connected to the bus. Typically, the following systems can be connected to the input / output interface 1006: an input device 1007 including, for example, a touch screen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, hard disk, etc.; and a communication device 1009. Communication device 1009 can allow the intelligent document question-and-answer device to communicate with other devices wirelessly or wired to exchange data. Although the figure shows an intelligent document question-and-answer device with various systems, it should be understood that it is not required to implement or have all of the systems shown. More or fewer systems may be implemented or provided instead.
[0115] In particular, according to the embodiments disclosed in the present application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program comprising program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device 1003, or installed from a read-only memory 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are performed.
[0116] The intelligent document question-and-answer device provided in this application, employing the intelligent document question-and-answer method of the aforementioned embodiment, can resolve the technical problem of RAG-based information retrieval, which can affect the quality of answers due to a failure to retrieve relevant information or inaccurate information retrieved. Compared to the prior art, the beneficial effects of the intelligent document question-and-answer device provided in this application are the same as those of the intelligent document question-and-answer method provided in the aforementioned embodiment. Other technical features of this intelligent document question-and-answer device are the same as those disclosed in the method of the aforementioned embodiment and are not further elaborated here.
[0117] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0118] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
[0119] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer program) stored thereon, and the computer-readable program instructions are used to execute the intelligent document question-answering method in the above-mentioned embodiment.
[0120] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0121] The computer-readable storage medium may be included in the intelligent document question-answering device; or it may exist independently without being assembled into the intelligent document question-answering device.
[0122] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the intelligent document question and answer device, the intelligent document question and answer device: obtains the target query question of the target user; based on keyword matching and vector matching, retrieves keyword document fragments and vector document fragments related to the target query question from the target document knowledge base; generates recall block information according to the keyword document fragments and the vector document fragments; generates a large model prompt word according to the recall block information, and outputs the target answer information for the target query question according to the large model prompt word through the large model.
[0123] Computer program code for performing the operations of the present application may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0124] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, program segment or a part of code, and the module, program segment or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions.
[0125] The modules described in the embodiments of the present application may be implemented in software or hardware, wherein the name of a module does not necessarily limit the unit itself.
[0126] The readable storage medium provided in this application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., a computer program) for executing the above-mentioned intelligent document question-and-answer method. It can solve the technical problem of failing to retrieve relevant information or inaccurate information retrieved during information retrieval based on RAG technology, thereby affecting the quality of answers. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the intelligent document question-and-answer method provided in the above-mentioned embodiment, and will not be elaborated here.
[0127] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned intelligent document question-answering method when executed by a processor.
[0128] The computer program product provided in this application can solve the technical problem of failing to retrieve relevant information or inaccurate information when performing information retrieval based on RAG technology, which affects the quality of answers. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the intelligent document question-and-answer method provided in the above-mentioned embodiment, and will not be elaborated here.
[0129] The above description is only part of the embodiments of the present application and does not limit the patent scope of the present application. All equivalent structural transformations made by using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect application in other related technical fields are included in the patent protection scope of the present application.
Claims
1. An intelligent document question-answering method, characterized in that: The intelligent document question-answering method comprises: Obtain the target query questions of the target users; Based on keyword matching and vector matching, keyword document fragments and vector document fragments related to the target query question are retrieved from the target document knowledge base; generating recall block information according to the keyword document fragment and the vector document fragment; A large model prompt word is generated according to the recall block information, and target answer information for the target query question is output according to the large model prompt word through the large model.
2. The intelligent document question-answering method according to claim 1, wherein: The step of obtaining the target query question of the target user includes: Obtaining the target user's initial query question; Based on the historical query information of the target user, the initial query question is rewritten to obtain a target query question, wherein the question rewriting includes at least one of typo correction, reference disambiguation, and context missing supplementation.
3. The intelligent document question-answering method according to claim 2, wherein: The step of rewriting the initial query question to obtain the target query question includes: Rewriting the initial query question to obtain a first query question; Outputting initial answer information for the first query question through the large model; Analyzing the initial answer information to obtain relevant question and answer information for the first query question, wherein the relevant question and answer information includes at least one of keyword information, similar semantic information, hypothetical information, and intent recognition information; Based on the relevant question and answer information, the first query question is expanded to obtain a target query question.
4. The intelligent document question-answering method according to claim 1, wherein: The step of generating recall block information according to the keyword document fragment and the vector document fragment includes: Determining a first similarity score between the target query and the keyword document segment; Determining a second similarity score between the target query and the keyword document fragment; Based on the first similarity score, sort all keyword document fragments in descending order to obtain a first sorted document; Based on the second similarity score, sorting all vector document segments in ascending order to obtain second sorted documents; Recall block information is generated according to the first sorted document and the second sorted document.
5. The intelligent document question-answering method according to claim 1 or 4, wherein: The step of generating a large model prompt word according to the recall block information includes: Determine the task requirements of the target user and use the task requirements as the beginning; The recall block information is written after the beginning portion to obtain a large model prompt word.
6. The intelligent document question-answering method according to claim 1, wherein: Before the step of retrieving keyword document segments and vector document segments related to the target query question from the target document knowledge base based on keyword matching and vector matching, the method further includes: Determining the query intent of the target query question, and determining a target query scenario based on the query intent; Determine a document knowledge base to be searched corresponding to the target query question according to the target query scenario; Determining the knowledge base authority information of the target user according to the identity information of the target user; Based on the knowledge base authority information, a target document knowledge base is determined from the document knowledge bases to be searched.
7. The intelligent document question-answering method according to claim 1, wherein: Before the step of obtaining the target query question of the target user, the method further includes: Obtain documents of the target user's company in different query scenarios; When the document is a structured document, segmenting the document according to the chapter titles to obtain a first document segment; When the document is an unstructured document, segmenting the document according to topics or keywords to obtain second document segments; When the document is a short document, segmenting the document according to the paragraph information to obtain third document information; The first document fragment, the second document fragment, and the third document fragment are stored in a document knowledge base corresponding to the query scenario.
8. An intelligent document question-answering device, characterized in that: The intelligent document question-answering device comprises: An acquisition module is used to obtain the target query questions of the target users; A retrieval module is used to retrieve keyword document fragments and vector document fragments related to the target query question from the target document knowledge base based on keyword matching and vector matching; A generating module, configured to generate recall block information according to the keyword document fragment and the vector document fragment; An output module is used to generate a large model prompt word according to the recall block information, and output target answer information for the target query question according to the large model prompt word through the large model.
9. An intelligent document question-answering device, characterized in that: The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the intelligent document question-answering method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the intelligent document question-and-answer method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Knowledge retrieval enhancement-based large language model question and answer method and device
CN118113836A
Information retrieval method and device, storage medium and computer program product
CN118939763A
Question and answer processing method and device, electronic equipment and storage medium
CN119202151A
Large language model-oriented database segmentation and subproblem-based enhanced retrieval method
CN119226538A
Knowledge response method and device, equipment, storage medium and program product
CN120067270A
Cited By
Intelligent question and answer processing method and device, electronic equipment and storage medium
CN120873151A
An intelligent question and answer processing method and device, an electronic device, and a storage medium
CN120873151B
Hybrid RAG retrieval method and device based on constraint keyword extraction
CN121092725A
Hierarchical answering method, electronic equipment and computer readable storage medium
CN121279451A
Question and answer method and system, storage medium and computer equipment
CN121413781A