Question and answer agent construction method for expanding to-be-retrieved text and user questions
By dynamically segmenting and expanding the knowledge blocks of the document and processing user questions by the large language model, the search failure and answering wrong questions by existing question-and-answer agents when dealing with complex problems are solved, and efficient and automatic question answering capabilities are achieved.
Patent Information
- Application Number
- CN202411915631.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-04-25
AI Technical Summary
When existing question-and-answer agents deal with uncommon questions, questions with vague key concepts, or questions in multiple reasoning links, they are prone to search failures and answer errors, and manual debugging is expensive and cannot achieve efficient and automatic goals.
The field knowledge blocks are dynamically segmented for a given document through the offline part, expanding key information and related information, and establishing an index; the online part extracts and expands keywords and synonyms for user questions, calculates verbal intention vectors, finds knowledge fragments in the knowledge base of different granularity, uses a large language model to answer questions and reorder candidate answers.
It realizes the dynamic expansion of key missing information and related information in text in different contexts, dynamically compress information, dynamically select compression levels, efficiently complete question answering tasks, and improves the ability to handle uncommon questions and multi-inference problems.
Smart Images

Figure CN119884310A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method for constructing a question-answering intelligent agent that expands text to be retrieved and user questions. Background Art
[0002] With the release of ChatGPT at the end of November 2022, the emergence of the ability of the big model, including reasoning ability, mathematical logic ability, writing generation ability, common sense comprehension ability, and professional field comprehension ability, has triggered a new wave of artificial intelligence. At the same time, in the field of knowledge retrieval, the intelligent agent relies on the reasoning and comprehension ability of the large language model to accurately match questions and candidate answers. The intelligent agent introduces relevant knowledge in a more targeted manner from the perspective of solution design, avoiding the illusion of the big model and unstable responses.
[0003] Traditional retrieval agent solutions mostly use retrieval enhancement and customized instructions to guide large models to complete question answering tasks. For common questions and questions with a high degree of partial match with the answer, optimized and customized instructions can answer questions with high accuracy. However, for uncommon questions (for example, special cases), questions with vague key concepts (for example, inconsistent terminology), and questions with multiple reasoning links (for example, terms belonging to different business scopes), the current solution will cause retrieval failures and then wrong answers. Manual debugging of Q&A can only solve individual cases, and the cost is high, and it cannot achieve the goal of efficient and automatic.
[0004] Therefore, a method for constructing a question-answering agent that expands the text to be retrieved and the questions asked by users is provided. Summary of the invention
[0005] The purpose of the present invention is to overcome the existing defects and provide a method for constructing a question-answering intelligent agent that expands the text to be retrieved and the user's questions, thereby efficiently completing the question answering task.
[0006] The technical solution to achieve the above purpose is:
[0007] A method for constructing a question-answering agent that expands the text to be retrieved and the user's question, comprising:
[0008] Offline part:
[0009] Step S1, dynamically segmenting a given document into domain knowledge blocks, expanding key information and related information of the knowledge blocks according to a larger context, and compressing the knowledge blocks;
[0010] Step S2, indexing the expanded different knowledge granularities;
[0011] Online section:
[0012] Step S3, extracting and expanding keywords and synonyms and the most likely cause of the question for the question input by the user;
[0013] Step S4, calculating the semantic vector of the expanded question;
[0014] Step S5, searching for knowledge fragments in knowledge bases of different granularities for the expanded questions;
[0015] Step S6, after concatenating the question and the sorted best candidate knowledge fragment, use the large language model to answer the question, reflect on the rationality of the answer, re-sort the multiple candidate answers, and polish the best answer.
[0016] Preferably, the step S1 comprises:
[0017] Step S11, firstly, the domain knowledge in a given document is divided into knowledge blocks with a length less than a certain length according to natural paragraphs and chapters;
[0018] Step S12, then calling the vector encoder large model to obtain the vector semantic representation of the knowledge block;
[0019] Step S13, indexing and saving the knowledge block into a vector database according to the vector representation;
[0020] Step S14, importing all parent chapter information in the processed document;
[0021] Step S15, introducing the key terms and their definitions introduced in the above processed documents;
[0022] Step S16, introducing a description of the key conclusions or assumptions introduced in the above processed document;
[0023] Step S17, compressing the expanded knowledge to different levels of granularity.
[0024] Preferably, in step S14, all upper-level chapter information is introduced, including but not limited to: from the title to the first-level chapter title and description, the second-level chapter title and description; the description content is the problem, reason, and function discussed in this chapter;
[0025] The large language model generates description content according to the agent's instructions, which describes the problem to be solved or the task to be completed based on the given text, including: describing the relationship and reasons between this chapter and the overall goal, and describing the effect of this chapter on the overall goal.
[0026] Preferably, in step S15, the characteristics of the terms to be found, the characteristics of the concepts, and the characteristics of the indicators are described. After the terms, concepts, and indicators are obtained, the large language model generates descriptions of the terms, concepts, and indicators according to the agent instructions. The instructions are to generate specific descriptions of the relevant terms, concepts, and indicators based on a given document.
[0027] Preferably, in step S16, the large language model obtains the conclusion or hypothesis according to the agent instruction recognition, and the instruction is to describe the characteristics of the conclusion or hypothesis to be found based on the given text. After obtaining the conclusion or hypothesis, the large language model generates a description of the conclusion or hypothesis according to the agent instruction, and the instruction is to generate a specific description of the relevant conclusion or hypothesis based on the given text.
[0028] Preferably, in step S17, based on the obtained extended information and the original knowledge block, this part of the information is compressed according to 5 granularities, the first granularity is the text left after removing 40% of unimportant sentences, the second granularity is 25 key conclusions, the third granularity is a 200-word summary, the fourth granularity is a 20-word summary, and the fifth granularity is 25 keywords in the text. The above compression process is completed by the large language model according to different instructions; the instructions are descriptions of the above 5 granularities, respectively.
[0029] Preferably, in step S2, for a given document, the text remaining after deleting 40% of unimportant sentences, 25 key conclusions, a 200-word summary, a 20-word summary, and 25 keywords are respectively calculated as embedded vectors;
[0030] The input is text and the output is a 1024-dimensional vector;
[0031] The vector, original text, and compressed text are saved in the vector database.
[0032] Among them, vector calculation is completed by a large language model.
[0033] Preferably, in step S3, the expansion process is completed by the large language model according to different instructions, and the instructions are respectively the descriptions of the expansion in the above keywords and synonyms.
[0034] Preferably, in step S5, 10 knowledge fragments closest to the vector of the expanded question are searched in the vector database; the degree of closeness can be the cos i ne distance or dot product distance of the two vectors.
[0035] Preferably, step S6 comprises:
[0036] Step S61, using the large language model and question-answering instructions to answer the extended questions and candidate knowledge fragments;
[0037] Step S62, the question-answering instruction requires the model to find the answer to the question from the candidate knowledge, and if there is no answer, then the answer is no;
[0038] Step S63, then using the large language model and verification instructions to verify whether the answer is reasonable and the reason;
[0039] Step S64, if it is unreasonable, regenerate the answer with reference to the given reason, and if it is still unreasonable, give up;
[0040] Step S65, putting the candidate answers processed above together, and then using the large language model and the optimal selection instruction to select the best answer from the candidate answers;
[0041] Step S66: The optimal selection instruction is to select an answer that best fits the question from the total candidate answers.
[0042] The beneficial effects of the present invention are as follows: the present invention dynamically expands key missing information and related information in the text according to different contexts, dynamically compresses the expanded information, dynamically selects the compression level, and expands key information in response to user questions, thereby efficiently completing the question answering task. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 It is a flow chart of a method for constructing a question-answering intelligent agent for expanding the text to be retrieved and the user's question of the present invention;
[0044] Figure 2 It is a specific flow chart of the present invention for dynamically segmenting a given document into domain knowledge blocks, expanding key information and related information of the knowledge blocks according to a larger context, and compressing the knowledge blocks;
[0045] Figure 3 It is a specific flow chart of the present invention, which includes concatenating the question and the best candidate knowledge fragments after sorting, answering the question using a large language model, reflecting on the rationality of the answer, re-sorting multiple candidate answers, and polishing the best answer. DETAILED DESCRIPTION
[0046] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. In the description of the present invention, it should be noted that the terms "center", "up", "down", "left", "right", "vertical", "horizontal", "inside", "outside" and the like indicate directions or positional relationships based on the directions or positional relationships shown in the accompanying drawings, which are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore cannot be understood as a limitation on the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance.
[0047] The present invention will be further described below in conjunction with the accompanying drawings.
[0048] like Figure 1 As shown, a method for constructing a question-answering agent that expands the text to be retrieved and the user's question includes:
[0049] Offline part:
[0050] Step S1, dynamically segmenting a given document into domain knowledge blocks, expanding key information and related information of the knowledge blocks according to a larger context, and compressing the knowledge blocks.
[0051] like Figure 2 As shown, step S1 includes:
[0052] Step S11, firstly, the domain knowledge in a given document is divided into knowledge blocks with a length less than a certain length according to natural paragraphs and chapters.
[0053] Step S12, then call the vector encoder large model to obtain the vector semantic representation of the knowledge block.
[0054] In the embodiment, the vector dimension can be a common 1024, 2048, etc.
[0055] Step S13, indexing according to the vector representation and saving the knowledge block into the vector database.
[0056] Step S14, importing all parent chapter information in the processed document.
[0057] In the embodiment, all upper-level chapter information is introduced, including but not limited to: from the title to the first-level chapter title and description, the second-level chapter title and description; the description content is the problem, reason, and function discussed in this chapter;
[0058] The large language model generates description content according to the agent's instructions, which describes the problem to be solved or the task to be completed based on the given text, including: describing the relationship and reasons between this chapter and the overall goal, and describing the effect of this chapter on the overall goal.
[0059] Step S15, importing the key terms and their definitions introduced in the above-mentioned processed documents.
[0060] In the embodiment, the characteristics of the terms, concepts and indicators to be found are described. After the terms, concepts and indicators are obtained, the large language model generates descriptions of the terms, concepts and indicators according to the agent instructions. The instructions are to generate specific descriptions of the relevant terms, concepts and indicators based on the given documents.
[0061] Step S16, introducing the description of the key conclusions or assumptions introduced in the above processed documents.
[0062] In the embodiment, the large language model obtains a conclusion or hypothesis based on the agent instruction recognition, and the instruction is to describe the characteristics of the conclusion or hypothesis to be found based on the given text. After the conclusion or hypothesis is obtained, the large language model generates a description of the conclusion or hypothesis based on the agent instruction, and the instruction is to generate a specific description of the relevant conclusion or hypothesis based on the given text.
[0063] Step S17, compressing the expanded knowledge to different levels of granularity.
[0064] In the embodiment, based on the obtained extended information and the original knowledge block, this part of the information is compressed according to five granularities. The first granularity is the text left after removing 40% of unimportant sentences, the second granularity is 25 key conclusions, the third granularity is a 200-word summary, the fourth granularity is a 20-word summary, and the fifth granularity is 25 keywords in the text. The above compression process is completed by a large language model according to different instructions; the instructions are descriptions of the above five granularities, respectively.
[0065] Step S2, indexing the expanded different knowledge granularities.
[0066] In the embodiment, for a given document, the text remaining after deleting 40% of unimportant sentences, 25 key conclusions, a 200-word summary, a 20-word summary, and 25 keywords are respectively calculated for embedded vectors;
[0067] The input is text and the output is a 1024-dimensional vector;
[0068] The vector, original text, and compressed text are saved in the vector database.
[0069] Among them, vector calculation is completed by the large language model.
[0070] Online section:
[0071] Step S3, extracting and expanding keywords and synonyms and the most likely cause of the question for the question input by the user.
[0072] In the embodiment, the expansion process is completed by the large language model according to different instructions, and the instructions are respectively the descriptions of the expansion in the above keywords and synonyms.
[0073] Step S4, calculating the semantic vector for the expanded question.
[0074] In the embodiment, the vector calculation is performed by a large language model. Typically, the input is text, the model can be a BERT model, and the output vector is the average of all token vectors output by the last layer of the model, or the vector of the first token (such as cls). The common dimension of the output vector is 1024 dimensions.
[0075] Step S5, searching for knowledge fragments in the knowledge base of different granularities for the expanded questions.
[0076] In an embodiment, 10 knowledge fragments closest to the vector of the expanded question are searched in a vector database; the degree of closeness may be the cos i ne distance or the dot product distance of the two vectors.
[0077] Step S6, after concatenating the question and the sorted best candidate knowledge fragment, use the large language model to answer the question, reflect on the rationality of the answer, re-sort the multiple candidate answers, and polish the best answer.
[0078] like Figure 3 As shown, step S6 includes:
[0079] Step S61, using the large language model and question-answering instructions to answer the extended questions and candidate knowledge fragments.
[0080] Step S62, the question-answering instruction requires the model to find the answer to the question from the candidate knowledge, and if there is no answer, it answers no.
[0081] Step S63, then use the large language model and verification instructions to verify whether the answer is reasonable and the reason.
[0082] Step S64: if the answer is not reasonable, regenerate the answer with reference to the given reasons; if the answer is still not reasonable, give up the answer.
[0083] Step S65, put the candidate answers processed above together, and then use the large language model and the optimal selection instruction to select the best answer from the candidate answers.
[0084] Step S66: The optimal selection instruction is to select an answer that best fits the question from the total candidate answers.
[0085] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that the technical solutions described in the above embodiments may still be modified, or some or all of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for constructing a question-answering agent that expands the text to be retrieved and the user's question, characterized in that: include: Offline part: Step S1, dynamically segmenting a given document into domain knowledge blocks, expanding key information and related information of the knowledge blocks according to a larger context, and compressing the knowledge blocks; Step S2, indexing the expanded different knowledge granularities; Online section: Step S3, extracting and expanding keywords and synonyms and the most likely cause of the question for the question input by the user; Step S4, calculating the semantic vector of the expanded question; Step S5, searching for knowledge fragments in knowledge bases of different granularities for the expanded questions; Step S6, after concatenating the question and the sorted best candidate knowledge fragment, use the large language model to answer the question, reflect on the rationality of the answer, re-sort the multiple candidate answers, and polish the best answer.
2. A method for constructing a question-answering agent for expanding the text to be retrieved and the user's question according to claim 1, characterized in that: The step S1 comprises: Step S11, firstly, the domain knowledge in a given document is divided into knowledge blocks with a length less than a certain length according to natural paragraphs and chapters; Step S12, then calling the vector encoder large model to obtain the vector semantic representation of the knowledge block; Step S13, indexing and saving the knowledge block into a vector database according to the vector representation; Step S14, importing all parent chapter information in the processed document; Step S15, introducing the key terms and their definitions introduced in the above processed documents; Step S16, introducing a description of the key conclusions or assumptions introduced in the above processed document; Step S17, compressing the expanded knowledge to different levels of granularity.
3. A method for constructing a question-answering agent for expanding the text to be retrieved and the user's question according to claim 2, characterized in that: In step S14, all upper-level chapter information is introduced, including but not limited to: from the title to the first-level chapter title and description, the second-level chapter title and description; the description content is the issue, reason, and function discussed in this chapter; The large language model generates description content according to the agent's instructions, which describes the problem to be solved or the task to be completed based on the given text, including: describing the relationship and reasons between this chapter and the overall goal, and describing the effect of this chapter on the overall goal.
4. A method for constructing a question-answering agent for expanding the text to be retrieved and the user's question according to claim 2, characterized in that: In step S15, the characteristics of the terms to be found, the characteristics of the concepts, and the characteristics of the indicators are described. After the terms, concepts, and indicators are obtained, the large language model generates descriptions of the terms, concepts, and indicators according to the agent instructions. The instructions are to generate specific descriptions of the relevant terms, concepts, and indicators based on the given document.
5. A method for constructing a question-answering agent for expanding the text to be retrieved and the user's question according to claim 2, characterized in that: In step S16, the large language model obtains a conclusion or hypothesis based on the agent's instruction recognition, and the instruction is to describe the characteristics of the conclusion or hypothesis to be found based on the given text. After obtaining the conclusion or hypothesis, the large language model generates a description of the conclusion or hypothesis based on the agent's instruction, and the instruction is to generate a specific description of the relevant conclusion or hypothesis based on the given text.
6. A method for constructing a question-answering agent for expanding the text to be retrieved and the user's question according to claim 2, characterized in that: In the step S17, based on the obtained extended information and the original knowledge block, this part of the information is compressed according to five granularities. The first granularity is the text left after removing 40% of unimportant sentences, the second granularity is 25 key conclusions, the third granularity is a 200-word summary, the fourth granularity is a 20-word summary, and the fifth granularity is 25 keywords in the text. The above compression process is completed by the large language model according to different instructions; the instructions are descriptions of the above five granularities respectively.
7. A method for constructing a question-answering agent for expanding the text to be retrieved and the user's question according to claim 1, characterized in that: In step S2, for a given document, the text remaining after deleting 40% of unimportant sentences, 25 key conclusions, a 200-word summary, a 20-word summary, and 25 keywords are respectively calculated with embedded vectors; The input is text and the output is a 1024-dimensional vector; The vector, original text, and compressed text are saved in the vector database. Among them, vector calculation is completed by the large language model.
8. A method for constructing a question-answering agent for expanding the text to be retrieved and the user's question according to claim 1, characterized in that: In step S3, the expansion process is completed by the large language model according to different instructions, and the instructions are the descriptions of the expansion in the above keywords and synonyms.
9. A method for constructing a question-answering agent for expanding the text to be retrieved and the user's question according to claim 1, characterized in that: In step S5, the 10 knowledge fragments closest to the vector of the expanded question are searched in the vector database; the degree of closeness can be the cosine distance or dot product distance of the two vectors.
10. A method for constructing a question-answering agent for expanding the text to be retrieved and the user's question according to claim 1, characterized in that: The step S6 comprises: Step S61, using the large language model and question-answering instructions to answer the extended questions and candidate knowledge fragments; Step S62, the question-answering instruction requires the model to find the answer to the question from the candidate knowledge, and if there is no answer, then the answer is no; Step S63, then using the large language model and verification instructions to verify whether the answer is reasonable and the reason; Step S64, if it is unreasonable, regenerate the answer with reference to the given reason, and if it is still unreasonable, give up; Step S65, putting the candidate answers processed above together, and then using the large language model and the optimal selection instruction to select the best answer from the candidate answers; Step S66: The optimal selection instruction is to select an answer that best fits the question from the total candidate answers.
Citation Information
Cited By
Policy knowledge question and answer method and device, electronic equipment and storage medium
CN120744069A
Intelligent matching algorithm based on multi-dimensional knowledge fusion and large model deep thinking
CN122155807A