Processing method and device for adjusting answer text based on adaptive retrieval enhancement mechanism
Through the adaptive retrieval enhancement mechanism, the appropriate text adjustment mode is selected based on the complexity of the question and the answer quality evaluation results, which solves the problem of hallucination and inefficiency in the intelligent question-and-answer task, and achieves more efficient and accurate answer text generation.
Patent Information
- Application Number
- CN202410965481.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2044-07-18
AI Technical Summary
Existing LLM models are prone to hallucination problems when dealing with intelligent question-and-answer tasks, and conventional retrieval enhances operation efficiency and depends on the professionalism of the question text, making it difficult to improve the accuracy of the answer text.
Adaptive search enhancement mechanism is adopted to create the first answer text after receiving the question text, and three text adjustment modes are selected according to the question complexity and answer quality evaluation results: direct mode, single-round search enhancement mode and multiple-round search enhancement mode to adjust the answer text.
The average processing efficiency of the LLM model and the accuracy of the answer text are improved, and the answer quality can be improved through multiple rounds of iteration when the answer quality is poor, adapting to the complexity and professionalism of different question texts.
Smart Images

Figure CN118939766B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a processing method and device for adjusting answer text based on an adaptive retrieval enhancement mechanism. Background Art
[0002] Large language models (LLMs) can handle many types of complex language understanding tasks, and intelligent question-answering tasks are one of the typical tasks. Before processing intelligent question-answering tasks, it is necessary to pre-train the LLM model based on one or more large question-answering datasets with high coverage of knowledge fields, and then fine-tune the model based on one or more refined question-answering datasets in specific knowledge fields; the trained LLM model can generate the corresponding answer text for the question text input by the user based on its own model parameters. However, due to the limitations of the breadth and depth of the knowledge fields of the pre- / fine-tuning training datasets, the probability of the LLM model generating illusion problems is not low. The so-called illusion problem is that the answer text output by the model is not highly correlated with the question text or even does not match it at all.
[0003] Some scholars have proposed a retrieval augmented generation (RAG) mechanism to reduce the probability of hallucination in the LLM model. The specific details can be found in the technical document "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks". From this technical document, we can know that the RAG mechanism consists of two parts: the recaller processing mechanism and the generator processing mechanism; the recaller processing mechanism refers to the retrieval operation of the knowledge text similar to the question text in the external knowledge base before the LLM model generates the answer text each time. This retrieval operation is also called the retrieval augmentation operation; the generator processing mechanism refers to the use of the retrieved knowledge text set as the reference context, and the question text + reference context generates the input text of the LLM model. Because the reference context input to the LLM model is similar to the question text, the accuracy of the answer text generated by the LLM model will also be effectively improved, which naturally reduces the probability of hallucination in the LLM model.
[0004] However, we also found two problems in the process of applying the RAG mechanism: 1) The LLM model does not produce hallucinations (i.e., output incorrect answer texts) for questions in all knowledge fields. If a search enhancement operation is performed before each answer text is generated, it will undoubtedly reduce the average processing efficiency of the LLM model; 2) Conventional search enhancement operations will only search the external knowledge base based on the question text. If the questioner's professionalism is low, the professionalism of the question text will also be poor, the matching degree of the reference context will also be biased, and the accuracy of the answer text generated by the LLM model will not be effectively improved. Summary of the invention
[0005] The purpose of the present invention is to provide a processing method, device, electronic device and computer-readable storage medium for adjusting answer text based on an adaptive retrieval enhancement mechanism in view of the defects of the prior art. After receiving the question text, the present invention first directly inputs the question text into the LLM model to generate the answer text to obtain the corresponding initial answer text; then uses the LLM model to evaluate the problem complexity of the question text and the answer quality of the initial answer text; then confirms three types of text adjustment modes (first mode, second mode, third mode) based on the evaluation results of the problem complexity and the answer quality; then adaptively adjusts the initial answer text based on the text adjustment mode: 1) First mode: directly use the initial answer text as the adjusted answer text; 2) Second mode: adjust the initial answer text based on one round of retrieval enhancement operation to obtain the adjusted answer text; 3) Third mode: perform multiple rounds of iterative adjustments on the initial answer text based on multiple rounds of retrieval enhancement operations to obtain the adjusted answer text. The present invention cancels the search enhancement operation in the first mode, which can improve the processing efficiency while ensuring the accuracy of the answer; the present invention improves the accuracy of the answer through single or multiple rounds of search enhancement operation in the second and third modes; the present invention uses the question text + the previous answer text as the basis for knowledge retrieval in each round of search enhancement operation, because the logic and professionalism of the answer text generated by the LLM model are higher than the question text input by non-professional questioners under normal circumstances, so adding the previous answer text during retrieval can improve the knowledge retrieval accuracy of the current round, reduce the reference context deviation of the current round, and improve the accuracy of the answer text of the current round. The present invention can not only improve the average processing efficiency of the LLM model, but also effectively improve the accuracy of the answer text, and can also continuously improve the answer quality through multiple rounds of iteration when the answer quality is poor.
[0006] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present invention provides a processing method for adjusting an answer text based on an adaptive retrieval enhancement mechanism, the method comprising:
[0007] Receive a first question text; and use a preset LLM model for processing intelligent question-answering tasks as the corresponding first model; and use a preset external knowledge base as the corresponding first knowledge base; the first model provides a plurality of preset instruction interfaces, including a first answer text generation instruction interface, a second answer text generation instruction interface, a question complexity evaluation instruction interface, and an answer quality evaluation instruction interface;
[0008] Input the first question text into the first answer text generation instruction interface of the first model for processing to obtain the corresponding first answer text; input the first question text into the question complexity evaluation instruction interface of the first model for processing to obtain the corresponding first complexity evaluation result; input the first question text and the first answer text into the answer quality evaluation instruction interface of the first model for processing to obtain the corresponding first quality evaluation result; the first complexity evaluation result includes three levels: low, medium and high; the first quality evaluation result includes three levels: low, medium and high;
[0009] According to the first complexity assessment result and the first quality assessment result, a text adjustment mode is confirmed to obtain a corresponding first adjustment mode; the first adjustment mode includes a first mode, a second mode and a third mode;
[0010] When the first adjustment mode is the first mode, using the first answer text as the corresponding adjusted answer text;
[0011] When the first adjustment mode is the second mode, a single round of retrieval enhancement and answer text adjustment processing is performed according to the first question text, the first answer text, the first knowledge base and the first model to obtain the corresponding adjusted answer text;
[0012] When the first adjustment mode is the third mode, multiple rounds of retrieval enhancement and answer text adjustment processing are performed according to the first question text, the first answer text, the first knowledge base and the first model to obtain the corresponding adjusted answer text;
[0013] The obtained adjusted answer text is displayed.
[0014] Preferably, the first model has completed model pre-training and model fine-tuning;
[0015] The first model includes at least Wenxinyiyan series models, ChatGPT series models, and ChatGLM series models.
[0016] Preferably, it is characterized in that
[0017] The first answer text generation instruction interface is used to use the question text input by the interface as the corresponding current question text; and to perform answer text generation processing according to the current question text and output the corresponding answer text;
[0018] The second answer text generation instruction interface is used to use the question text and knowledge text set input into the interface at this time as the corresponding current question text and current reference context; and use the current reference context as the prompt text in the answer generation process, perform answer text generation processing according to the current question text and output the corresponding answer text;
[0019] The question complexity evaluation instruction interface is used to take the question text input by the interface as the corresponding current question text; and identify the question text length, question knowledge domain breadth and question knowledge domain depth of the current question text; and based on the identified question text length, question knowledge domain breadth and question knowledge domain depth, evaluate the question complexity of the current question text and output the corresponding complexity evaluation result; the complexity evaluation result includes low, medium and high;
[0020] The answer quality assessment instruction interface is used to use the question text and answer text input at the interface as the corresponding current question text and current answer text; and to identify the answer text credibility according to the current answer text and the current question text to obtain the corresponding answer credibility; and to identify the text semantic integrity of the current answer text to obtain the corresponding answer semantic integrity; and to evaluate the answer quality of the current answer text based on the identified answer credibility and answer semantic integrity and output the corresponding quality assessment result; the quality assessment result includes low, medium and high;
[0021] The first knowledge base includes multiple first knowledge records; the first knowledge record includes a first knowledge text and a first text vector; the first text vector is a word embedding encoding vector corresponding to the first knowledge text.
[0022] Preferably, the confirming the text adjustment mode according to the first complexity assessment result and the first quality assessment result to obtain the corresponding first adjustment mode specifically includes:
[0023] When the first complexity evaluation result is low, if the first quality evaluation result is high, the corresponding first adjustment mode is set to the first mode; if the first quality evaluation result is medium, the corresponding first adjustment mode is set to the second mode; if the first quality evaluation result is low, the corresponding first adjustment mode is set to the third mode;
[0024] When the first complexity evaluation result is medium, if the first quality evaluation result is high or medium, the corresponding first adjustment mode is set to the second mode, and if the first quality evaluation result is low, the corresponding first adjustment mode is set to the third mode;
[0025] When the first complexity evaluation result is high, if the first quality evaluation result is high, the corresponding first adjustment mode is set to the second mode, and if the first quality evaluation result is medium or low, the corresponding first adjustment mode is set to the third mode.
[0026] Preferably, performing single-round retrieval enhancement and answer text adjustment processing according to the first question text, the first answer text, the first knowledge base and the first model to obtain the corresponding adjusted answer text specifically includes:
[0027] The first question text and the first answer text form a corresponding first combined text; and the first combined text is word-embedded and encoded to obtain a corresponding first encoding vector;
[0028] Referring to the processing principle of the RAG mechanism, the vector similarity between the first coding vector and the first text vector of each first knowledge record of the first knowledge base is calculated to obtain the corresponding first similarity; and the first knowledge text corresponding to the first text vector whose first similarity exceeds a preset similarity threshold is used as the corresponding first search text; and all the first search texts are sorted in descending order according to the first similarity to obtain the corresponding first search text sequence; and the first number K of the first search texts at the head of the sequence in the first search text sequence are extracted to form the corresponding first knowledge text set; the first number K is a preset positive integer;
[0029] Input the first question text and the first knowledge text set into the second answer text generation instruction interface of the first model for processing to obtain the corresponding second answer text; and use the obtained second answer text as the corresponding adjusted answer text.
[0030] Preferably, performing multiple rounds of retrieval enhancement and answer text adjustment processing according to the first question text, the first answer text, the first knowledge base and the first model to obtain the corresponding adjusted answer text specifically includes:
[0031] Step 61, taking the first answer text as the corresponding current answer text; and identifying the preset multi-round cycle mode, and if the multi-round cycle mode is the first cycle mode, initializing the corresponding first counter to 1;
[0032] Wherein, the multi-cycle mode includes a first cycle mode and a second cycle mode;
[0033] Step 62, forming a corresponding second combined text from the first question text and the current answer text; and performing word embedding encoding on the second combined text to obtain a corresponding second encoding vector;
[0034] Step 63, referring to the processing principle of the RAG mechanism, the vector similarity between the second coding vector and each of the first text vectors of the first knowledge base is calculated to obtain the corresponding second similarity; and the first knowledge text corresponding to the first text vector whose second similarity exceeds the similarity threshold is used as the corresponding second search text; and all the second search texts are sorted in descending order according to the second similarity to obtain the corresponding second search text sequence; and the first number K of the second search texts arranged at the head of the sequence in the second search text sequence are extracted to form the corresponding second knowledge text set;
[0035] Step 64, inputting the first question text and the second knowledge text set into the second answer text generation instruction interface for processing to obtain a corresponding third answer text;
[0036] Step 66, inputting the first question text and the third answer text into the answer quality assessment instruction interface for processing to obtain a corresponding second quality assessment result;
[0037] Wherein, the second quality assessment result includes low, medium and high;
[0038] Step 65, identifying the multi-cycle mode; if the multi-cycle mode is the first cycle mode, go to step 67; if the multi-cycle mode is the second cycle mode, go to step 68;
[0039] Step 67, identifying whether the first counter exceeds a preset counter threshold; if the first counter does not exceed the counter threshold, adding 1 to the first counter, taking the third answer text as the new current answer text, and returning to step 62; if the first counter exceeds the counter threshold, going to step 69;
[0040] Step 68, identifying whether the second quality evaluation result is high; if the second quality evaluation result is not high, taking the third answer text as the new current answer text and returning to step 62; if the second quality evaluation result is high, going to step 69;
[0041] Step 69, taking the latest third answer text as the corresponding adjusted answer text.
[0042] A second aspect of an embodiment of the present invention provides a device for implementing the processing method for adjusting answer text based on an adaptive retrieval enhancement mechanism as described in the first aspect, the device comprising: a question receiving module, an answer generating and evaluating module, an adjustment mode confirming module, a first answer adjusting module, a second answer adjusting module, a third answer adjusting module and an answer displaying module;
[0043] The question receiving module is used to receive a first question text; and use a preset LLM model for processing intelligent question-answering tasks as the corresponding first model; and use a preset external knowledge base as the corresponding first knowledge base; the first model provides a plurality of preset instruction interfaces, including a first answer text generation instruction interface, a second answer text generation instruction interface, a question complexity evaluation instruction interface, and an answer quality evaluation instruction interface;
[0044] The answer generation and evaluation module is used to input the first question text into the first answer text generation instruction interface of the first model for processing to obtain the corresponding first answer text; and input the first question text into the question complexity evaluation instruction interface of the first model for processing to obtain the corresponding first complexity evaluation result; and input the first question text and the first answer text into the answer quality evaluation instruction interface of the first model for processing to obtain the corresponding first quality evaluation result; the first complexity evaluation result includes three levels: low, medium and high; the first quality evaluation result includes three levels: low, medium and high;
[0045] The adjustment mode confirmation module is used to confirm the text adjustment mode according to the first complexity assessment result and the first quality assessment result to obtain a corresponding first adjustment mode; the first adjustment mode includes a first mode, a second mode and a third mode;
[0046] The first answer adjustment module is used for using the first answer text as the corresponding adjusted answer text when the first adjustment mode is the first mode;
[0047] The second answer adjustment module is used for performing single-round retrieval enhancement and answer text adjustment processing according to the first question text, the first answer text, the first knowledge base and the first model to obtain the corresponding adjusted answer text when the first adjustment mode is the second mode;
[0048] The third answer adjustment module is used for performing multiple rounds of retrieval enhancement and answer text adjustment processing according to the first question text, the first answer text, the first knowledge base and the first model to obtain the corresponding adjusted answer text when the first adjustment mode is the second mode;
[0049] The answer display module is used to display the obtained adjusted answer text.
[0050] A third aspect of an embodiment of the present invention provides an electronic device, including: a memory, a processor, and a transceiver;
[0051] The processor is used to be coupled to the memory, read and execute instructions in the memory, so as to implement the method steps described in the first aspect above;
[0052] The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.
[0053] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions. When the computer instructions are executed by a computer, the computer executes the instructions of the method described in the first aspect above.
[0054] The embodiment of the present invention provides a processing method, device, electronic device and computer-readable storage medium for adjusting answer text based on an adaptive retrieval enhancement mechanism. As can be seen from the above content, the LLM model of the embodiment of the present invention provides four types of instruction interfaces (first and second answer text generation instruction interfaces, question complexity evaluation instruction interface, answer quality evaluation instruction interface), wherein the first answer text generation instruction interface is used to generate a corresponding answer text according to an input question text, the second answer text generation instruction interface is used to generate a corresponding answer text according to an input question text and a knowledge text set as prompt information, the question complexity evaluation instruction interface is used to evaluate the complexity of the input question text, and the answer quality evaluation instruction interface is used to evaluate the quality of the answer text according to the input question text + answer text. After receiving any question text, the embodiment of the present invention directly inputs the question text into the first answer text generation instruction interface to generate the answer text without performing any search enhancement operation to obtain the corresponding initial answer text; then uses the question complexity evaluation instruction interface and the answer quality evaluation instruction interface to evaluate the question complexity of the question text and the answer quality of the initial answer text; then confirms three types of text adjustment modes (first mode, second mode, third mode) according to the evaluation results of the question complexity and the answer quality; then adaptively adjusts the initial answer text based on the text adjustment mode: 1) First mode: directly uses the initial answer text as the adjusted answer text; 2) Second mode: adjusts the initial answer text based on one round of search enhancement operation to obtain the adjusted answer text; 3) Third mode: performs multiple rounds of iterative adjustments on the initial answer text based on multiple rounds of search enhancement operations to obtain the adjusted answer text. The embodiment of the present invention cancels the search enhancement operation in the first mode, which can improve the processing efficiency while ensuring the accuracy of the answer; the embodiment of the present invention improves the accuracy of the answer through a single or multiple rounds of search enhancement operation in the second and third modes; the embodiment of the present invention uses the question text + the previous answer text (the previous answer text is the initial answer text in the first round of the single or multiple rounds of search enhancement operation, and the previous answer text is the answer text obtained in the previous round in the second to the last round of the multiple rounds of search enhancement operation) as the basis for knowledge retrieval in each round of search enhancement operation, because the logic and professionalism of the answer text generated by the LLM model are higher than the question text input by non-professional questioners under normal circumstances, so adding the previous answer text during retrieval can improve the knowledge retrieval accuracy of the current round, reduce the reference context deviation of the current round, and improve the accuracy of the answer text of the current round. The embodiment of the present invention not only improves the average processing efficiency of the LLM model, but also improves the accuracy of the answer text, and can also continuously improve the accuracy of the answer text with poor quality through multiple rounds of iteration. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 A schematic diagram of a processing method for adjusting answer text based on an adaptive retrieval enhancement mechanism provided in Embodiment 1 of the present invention;
[0056] Figure 2 A module structure diagram of a processing device for adjusting answer text based on an adaptive retrieval enhancement mechanism provided in Embodiment 2 of the present invention;
[0057] Figure 3 A schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0058] In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0059] Embodiment 1 of the present invention provides a processing method for adjusting answer text based on an adaptive retrieval enhancement mechanism, such as Figure 1 As shown in the schematic diagram of a processing method for adjusting answer text based on an adaptive retrieval enhancement mechanism provided in the first embodiment of the present invention, the method mainly includes the following steps:
[0060] Step 1, receiving a first question text; and using a preset LLM model for processing intelligent question-answering tasks as a corresponding first model; and using a preset external knowledge base as a corresponding first knowledge base.
[0061] Here, the first model of the embodiment of the present invention is an LLM model for processing intelligent question and answer tasks, and model pre-training and model fine-tuning have been completed; the first model includes at least Wenxin Yiyan series models, ChatGPT series models, and ChatGLM series models.
[0062] Most LLM models that can handle intelligent question-answering tasks, such as the Wenxinyiyan series of models, the ChatGPT series of models, or the ChatGLM series of models, provide a rich set of functions. Similar to these LLM models, the first model of the embodiment of the present invention also provides a rich set of model functions and provides a corresponding instruction interface for each model function in the set, which includes at least the following four types of instruction interfaces: a first answer text generation instruction interface, a second answer text generation instruction interface, a question complexity evaluation instruction interface, and an answer quality evaluation instruction interface. The functions of these four types of preset instruction interfaces are briefly described below.
[0063] The first answer text generation instruction interface of the embodiment of the present invention is used to use the question text input into the interface at this time as the corresponding current question text; and perform answer text generation processing according to the current question text and output the corresponding answer text.
[0064] The second answer text generation instruction interface of the embodiment of the present invention is used to use the question text and knowledge text set input into the interface at this time as the corresponding current question text and current reference context; and use the current reference context as the prompt text in the current answer generation process, perform answer text generation processing according to the current question text, and output the corresponding answer text. It should be noted that the first model of the embodiment of the present invention supports at least two question-answering modes: question-answering mode without / with prompt text (knowledge text set). The first answer text generation instruction interface implements the former function, and the second answer text generation instruction interface implements the latter function. Under normal circumstances, the accuracy of the answer text generated by the second answer text generation instruction interface will be higher than that of the first answer text generation instruction interface.
[0065] The question complexity assessment instruction interface of the embodiment of the present invention is used to take the question text input by the interface at this time as the corresponding current question text; and identify the question text length, question knowledge domain breadth and question knowledge domain depth of the current question text; and based on the identified question text length, question knowledge domain breadth and question knowledge domain depth, evaluate the question complexity of the current question text and output the corresponding complexity assessment result; wherein the complexity assessment results include low, medium and high.
[0066] The answer quality assessment instruction interface of the embodiment of the present invention is used to use the question text and answer text input into the interface as the corresponding current question text and current answer text; and to identify the answer text credibility based on the current answer text and the current question text to obtain the corresponding answer credibility; and to identify the text semantic completeness of the current answer text to obtain the corresponding answer semantic completeness; and to evaluate the answer quality of the current answer text based on the identified answer credibility and answer semantic completeness and output the corresponding quality assessment result; wherein the quality assessment results include low, medium and high.
[0067] The external knowledge base of the embodiment of the present invention, that is, the first knowledge base, includes multiple first knowledge records; each first knowledge record includes a first knowledge text and a first text vector; the first text vector is a word embedding encoding vector of the corresponding first knowledge text.
[0068] Step 2: Input the first question text into the first answer text generation instruction interface of the first model for processing to obtain the corresponding first answer text; input the first question text into the question complexity evaluation instruction interface of the first model for processing to obtain the corresponding first complexity evaluation result; input the first question text and the first answer text into the answer quality evaluation instruction interface of the first model for processing to obtain the corresponding first quality evaluation result;
[0069] Specifically, it includes: step 21, inputting the first question text into the first answer text generation instruction interface of the first model for processing to obtain the corresponding first answer text;
[0070] Here, after the first question text is input into the first answer text generation instruction interface of the first model, the first answer text generation instruction interface of the embodiment of the present invention will use the first answer text input into the interface as the corresponding current question text, and perform answer text generation processing according to the current question text and output the corresponding first answer text;
[0071] Step 22, inputting the first question text into the question complexity evaluation instruction interface of the first model for processing to obtain a corresponding first complexity evaluation result;
[0072] Among them, the first complexity assessment results include low, medium and high levels;
[0073] Here, after the first question text is input into the question complexity evaluation instruction interface of the first model, the question complexity evaluation instruction interface of the embodiment of the present invention will take the first question text input into the interface as the corresponding current question text, and identify the question text length, question knowledge domain breadth and question knowledge domain depth of the current question text, and evaluate the question complexity of the current question text based on the identified question text length, question knowledge domain breadth and question knowledge domain depth, and output the corresponding first complexity evaluation result;
[0074] It should be noted that, when the problem complexity evaluation instruction interface of the embodiment of the present invention identifies the problem text length, the problem knowledge domain breadth and the problem knowledge domain depth of the current problem text, the corresponding problem text length is obtained by counting the text length of the current problem text; and based on the preset keyword extraction rules, the current problem text is subjected to keyword extraction to obtain the corresponding current text keyword set; and the knowledge subject node with the highest matching degree with each keyword in the current text keyword set on the preset knowledge subject tree is marked as the corresponding keyword subject node; and the path from the root node of the knowledge subject tree to each keyword subject node is identified to obtain the corresponding keyword path; and the path depth of all keyword paths is counted to obtain the corresponding keyword path depth, and the mean of all the obtained keyword path depths is calculated and the calculation result is used as the corresponding problem knowledge domain depth; and the knowledge field corresponding to each keyword path is identified to obtain the corresponding keyword knowledge field, and all the obtained keyword knowledge fields are deduplicated, and the total number of the deduplicated keyword knowledge fields is counted and the statistical result is used as the corresponding problem knowledge domain breadth;
[0075] The knowledge subject tree mentioned here is a subject tree object used to store knowledge categories; the knowledge subject tree consists of a root node and multiple levels of knowledge subject nodes. The first-level knowledge subject nodes below the root node are used to distinguish knowledge domains, and the subtree structure below each first-level knowledge subject node can be regarded as a sub-subject tree of a knowledge domain;
[0076] It should be noted that when the problem complexity evaluation instruction interface of the embodiment of the present invention evaluates the problem complexity of the current problem text based on the identified problem text length, problem knowledge domain breadth and problem knowledge domain depth and outputs the corresponding first complexity evaluation result, the problem text length, problem knowledge domain breadth and problem knowledge domain depth are first normalized, and then the three normalized data are weighted summed to obtain a corresponding weighted sum data, and then the current weighted sum data is compared based on the preset high, medium and low weighted sum value ranges, and the one of the high, medium and low value ranges that satisfies the current weighted sum data is used as the adaptation grade, and finally the corresponding first complexity evaluation result is set based on the adaptation grade (if the adaptation grade is high, the first complexity evaluation result is high, if the adaptation grade is medium, the first complexity evaluation result is medium, and if the adaptation grade is low, the first complexity evaluation result is low);
[0077] Step 23, inputting the first question text and the first answer text into the answer quality evaluation instruction interface of the first model for processing to obtain a corresponding first quality evaluation result;
[0078] Among them, the first quality assessment results include low, medium and high levels;
[0079] Here, after the first question text and the first answer text are input into the answer quality assessment instruction interface of the first model, the answer quality assessment instruction interface of the embodiment of the present invention will use the first question text and the first answer text input into the interface at that time as the corresponding current question text and the current answer text, and perform answer text credibility recognition based on the current answer text and the current question text to obtain the corresponding answer credibility, and recognize the text semantic completeness of the current answer text to obtain the corresponding answer semantic completeness, and evaluate the answer quality of the current answer text based on the recognized answer credibility and answer semantic completeness and output the corresponding first quality assessment result;
[0080] It should be noted that the answer quality assessment instruction interface of the embodiment of the present invention can calculate the answer credibility based on multiple methods when performing answer text credibility identification according to the current answer text and the current question text to obtain the corresponding answer credibility; one of the methods is: based on a preset text vector encoding rule, the current answer text and the current question text are respectively converted into text vectors, and the similarity of the two text vectors is calculated based on a vector similarity algorithm, and the corresponding answer text credibility is set based on the similarity;
[0081] It should be noted that the answer quality assessment instruction interface of the embodiment of the present invention can calculate the answer semantic completeness based on a variety of conventional semantic completeness statistical methods when identifying the text semantic completeness of the current answer text to obtain the corresponding answer semantic completeness; one of the methods is: based on a preset multi-category text semantic template (such as subject-predicate-object template, subject-predicate template, attributive clause template, etc.) to match the semantic structure similarity of the current answer text, and use the text semantic template with the most similar structure as the current semantic template; and count the total number of semantic objects of the current semantic template to obtain a corresponding first total number, and based on the current semantic template, count the total number of missing semantic objects of the current answer text to obtain a corresponding second total number, and use the difference between the first and second total numbers as the corresponding first total number difference, and use the ratio of the first total number difference to the first total number as the corresponding answer semantic completeness;
[0082] It should be noted that when the answer quality assessment instruction interface of the embodiment of the present invention evaluates the answer quality of the current answer text based on the identified answer credibility and answer semantic completeness and outputs the corresponding first quality assessment result, a weighted sum calculation is performed on the answer credibility and the answer semantic completeness to obtain a corresponding weighted sum data, and then the current weighted sum data is compared based on the preset high, medium and low weighted sum value ranges, and the grade in the high, medium and low value ranges that satisfies the current weighted sum data is used as the adaptation grade, and finally the corresponding first quality assessment result is set based on the adaptation grade (if the adaptation grade is high, the first quality assessment result is high, if the adaptation grade is medium, the first quality assessment result is medium, and if the adaptation grade is low, the first quality assessment result is low).
[0083] Step 3, confirming the text adjustment mode according to the first complexity assessment result and the first quality assessment result to obtain a corresponding first adjustment mode;
[0084] Wherein, the first adjustment mode includes a first mode, a second mode and a third mode;
[0085] Specifically comprising: step 31, when the first complexity evaluation result is low, if the first quality evaluation result is high, the corresponding first adjustment mode is set to the first mode, if the first quality evaluation result is medium, the corresponding first adjustment mode is set to the second mode, if the first quality evaluation result is low, the corresponding first adjustment mode is set to the third mode;
[0086] Step 32, when the first complexity evaluation result is medium, if the first quality evaluation result is high or medium, the corresponding first adjustment mode is set to the second mode, and if the first quality evaluation result is low, the corresponding first adjustment mode is set to the third mode;
[0087] Step 33, when the first complexity evaluation result is high, if the first quality evaluation result is high, the corresponding first adjustment mode is set to the second mode, and if the first quality evaluation result is medium or low, the corresponding first adjustment mode is set to the third mode.
[0088] Step 4, when the first adjustment mode is the first mode, taking the first answer text as the corresponding adjusted answer text;
[0089] Step 5, when the first adjustment mode is the second mode, performing single-round retrieval enhancement and answer text adjustment processing according to the first question text, the first answer text, the first knowledge base and the first model to obtain a corresponding adjusted answer text;
[0090] Specifically, it includes: step 51, forming a corresponding first combined text from a first question text and a first answer text; and performing word embedding encoding on the first combined text to obtain a corresponding first encoding vector;
[0091] Step 52, referring to the processing principle of the RAG mechanism, the vector similarity between the first coding vector and the first text vector of each first knowledge record of the first knowledge base is calculated to obtain the corresponding first similarity; and the first knowledge text corresponding to the first text vector whose first similarity exceeds the preset similarity threshold is used as the corresponding first search text; and all the first search texts are sorted in descending order according to the first similarity to obtain the corresponding first search text sequence; and the first number K of first search texts arranged at the head of the sequence in the first search text sequence are extracted to form the corresponding first knowledge text set;
[0092] Wherein, the similarity threshold is a preset similarity parameter; the first number K is a preset positive integer;
[0093] Here, the processing principle related to retrieval enhancement in the RAG mechanism can be understood by referring to the technical document "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks"; its essence is to search the external knowledge base through vector comparison as shown in the current step 332;
[0094] Step 53, input the first question text and the first knowledge text set into the second answer text generation instruction interface of the first model for processing to obtain the corresponding second answer text; and use the obtained second answer text as the corresponding adjusted answer text.
[0095] Here, after the first question text and the first knowledge text set are input into the second answer text generation instruction interface of the first model, the second answer text generation instruction interface of the embodiment of the present invention uses the first question text and the first knowledge text set input at the interface as the corresponding current question text and current reference context, and uses the current reference context as the prompt text in this answer generation process, performs answer text generation processing according to the current question text, and outputs the corresponding second answer text.
[0096] Step 6, when the first adjustment mode is the third mode, multiple rounds of retrieval enhancement and answer text adjustment processing are performed according to the first question text, the first answer text, the first knowledge base and the first model to obtain the corresponding adjusted answer text;
[0097] Specifically, it includes: step 61, taking the first answer text as the corresponding current answer text; and identifying the preset multi-round cycle mode, and if the multi-round cycle mode is the first cycle mode, initializing the corresponding first counter to 1;
[0098] The multi-cycle mode includes a first cycle mode and a second cycle mode;
[0099] Here, if the multi-round cycle mode is the first cycle mode, it means that the end mark of the cycle is that the number of cycles exceeds a preset threshold parameter, i.e., the counter threshold; if it is the second cycle mode, it means that the end mark of the cycle is that the text quality of the latest answer text reaches a preset quality level, which is usually set to high;
[0100] Step 62, forming a corresponding second combined text from the first question text and the current answer text; and performing word embedding encoding on the second combined text to obtain a corresponding second encoding vector;
[0101] Step 63, referring to the processing principle of the RAG mechanism, the vector similarity between the second encoding vector and each first text vector of the first knowledge base is calculated to obtain the corresponding second similarity; and the first knowledge text corresponding to the first text vector whose second similarity exceeds the similarity threshold is used as the corresponding second search text; and all the second search texts are sorted in descending order according to the second similarity to obtain the corresponding second search text sequence; and the first number K of second search texts arranged at the head of the sequence in the second search text sequence are extracted to form the corresponding second knowledge text set;
[0102] Step 64, inputting the first question text and the second knowledge text set into the second answer text generation instruction interface for processing to obtain a corresponding third answer text;
[0103] Step 65, inputting the first question text and the third answer text into the answer quality evaluation instruction interface for processing to obtain a corresponding second quality evaluation result;
[0104] Among them, the second quality assessment results include low, medium and high;
[0105] Step 66, identifying the multi-cycle mode; if the multi-cycle mode is the first cycle mode, go to step 67; if the multi-cycle mode is the second cycle mode, go to step 68;
[0106] Step 67, identifying whether the first counter exceeds a preset counter threshold; if the first counter does not exceed the counter threshold, then adding 1 to the first counter, and taking the third answer text as the new current answer text, and returning to step 62; if the first counter has exceeded the counter threshold, then going to step 69;
[0107] Step 68, identifying whether the second quality evaluation result is high; if the second quality evaluation result is not high, taking the third answer text as the new current answer text and returning to step 62; if the second quality evaluation result is high, going to step 69;
[0108] Step 69, taking the latest third answer text as the corresponding adjusted answer text.
[0109] Step 7, display the adjusted answer text.
[0110] Figure 2 The module structure diagram of a processing device for adjusting answer text based on an adaptive search enhancement mechanism provided in the second embodiment of the present invention, the device is a terminal device or server that implements the aforementioned method embodiment, and can also be a device that enables the aforementioned terminal device or server to implement the aforementioned method embodiment, for example, the device can be a device or chip system of the aforementioned terminal device or server. Figure 2 As shown, the device includes: a question receiving module 201, an answer generating and evaluating module 202, an adjustment mode confirming module 203, a first answer adjusting module 204, a second answer adjusting module 205, a third answer adjusting module 206 and an answer displaying module 207.
[0111] The question receiving module 201 is used to receive a first question text; and use the preset LLM model for processing intelligent question and answer tasks as the corresponding first model; and use the preset external knowledge base as the corresponding first knowledge base; the first model provides multiple preset instruction interfaces, including a first answer text generation instruction interface, a second answer text generation instruction interface, a question complexity evaluation instruction interface and an answer quality evaluation instruction interface.
[0112] The answer generation and evaluation module 202 is used to input the first question text into the first answer text generation instruction interface of the first model for processing to obtain the corresponding first answer text; and input the first question text into the question complexity evaluation instruction interface of the first model for processing to obtain the corresponding first complexity evaluation result; and input the first question text and the first answer text into the answer quality evaluation instruction interface of the first model for processing to obtain the corresponding first quality evaluation result; the first complexity evaluation result includes three levels: low, medium and high; the first quality evaluation result includes three levels: low, medium and high.
[0113] The adjustment mode confirmation module 203 is used to confirm the text adjustment mode according to the first complexity evaluation result and the first quality evaluation result to obtain the corresponding first adjustment mode; the first adjustment mode includes a first mode, a second mode and a third mode.
[0114] The first answer adjustment module 204 is configured to use the first answer text as the corresponding adjusted answer text when the first adjustment mode is the first mode.
[0115] The second answer adjustment module 205 is used to perform single-round retrieval enhancement and answer text adjustment processing according to the first question text, the first answer text, the first knowledge base and the first model to obtain the corresponding adjusted answer text when the first adjustment mode is the second mode.
[0116] The third answer adjustment module 206 is used to perform multiple rounds of retrieval enhancement and answer text adjustment processing according to the first question text, the first answer text, the first knowledge base and the first model to obtain the corresponding adjusted answer text when the first adjustment mode is the second mode.
[0117] The answer display module 207 is used to display the obtained adjusted answer text.
[0118] An embodiment of the present invention provides a processing device for adjusting answer text based on an adaptive retrieval enhancement mechanism, which can execute the method steps in the above method embodiment. Its implementation principle and technical effects are similar and will not be repeated here.
[0119] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. For example, the question receiving module can be a separately established processing element, or it can be integrated in a chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a processing element of the above device. The function of the above determination module. The implementation of other modules is similar. In addition, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in software form.
[0120] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more digital signal processors (DSP), or one or more field programmable gate arrays (FPGA). For another example, when a module above is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0121] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the above method embodiments are generated. The above computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The above-mentioned computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the above-mentioned computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, Bluetooth, microwave, etc.) methods. The above-mentioned computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated. The above-mentioned available medium can be a magnetic medium (such as a floppy disk, a hard disk, a tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.
[0122] Figure 3 This is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present invention. The electronic device may be a terminal device or a server for implementing the method of the aforementioned embodiment, or may be a terminal device or a server for implementing the method of the aforementioned embodiment connected to the aforementioned terminal device or server. Figure 3 As shown, the electronic device may include: a processor 301 (such as a CPU), a memory 302, and a transceiver 303; the transceiver 303 is coupled to the processor 301, and the processor 301 controls the transceiver 303. Various instructions may be stored in the memory 302 to complete various processing functions and implement the processing steps described in the aforementioned embodiment method. Preferably, the electronic device involved in the embodiment of the present invention also includes: a power supply 304, a system bus 305 and a communication port 306. The system bus 305 is used to realize the communication connection between components. The above-mentioned communication port 306 is used for connecting and communicating between the electronic device and other peripherals.
[0123] exist Figure 3The system bus 305 mentioned in the figure can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface is used to realize the communication between the database access device and other devices (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM), and may also include non-volatile memory (Non-Volatile Memory), such as at least one disk storage.
[0124] The above-mentioned processor can be a general-purpose processor, including a central processing unit CPU, a network processor (Network Processor, NP), a graphics processing unit (Graphics Processing Unit, GPU), etc.; it can also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0125] It should be noted that an embodiment of the present invention further provides a computer-readable storage medium, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the method and processing process provided in the above embodiments.
[0126] An embodiment of the present invention further provides a chip for executing instructions, wherein the chip is used to execute the processing steps described in the aforementioned method embodiment.
[0127] The embodiment of the present invention provides a processing method, device, electronic device and computer-readable storage medium for adjusting answer text based on an adaptive retrieval enhancement mechanism. As can be seen from the above content, the LLM model of the embodiment of the present invention provides four types of instruction interfaces (first and second answer text generation instruction interfaces, question complexity evaluation instruction interface, answer quality evaluation instruction interface), wherein the first answer text generation instruction interface is used to generate a corresponding answer text according to an input question text, the second answer text generation instruction interface is used to generate a corresponding answer text according to an input question text and a knowledge text set as prompt information, the question complexity evaluation instruction interface is used to evaluate the complexity of the input question text, and the answer quality evaluation instruction interface is used to evaluate the quality of the answer text according to the input question text + answer text. After receiving any question text, the embodiment of the present invention directly inputs the question text into the first answer text generation instruction interface to generate the answer text without performing any search enhancement operation to obtain the corresponding initial answer text; then uses the question complexity evaluation instruction interface and the answer quality evaluation instruction interface to evaluate the question complexity of the question text and the answer quality of the initial answer text; then confirms three types of text adjustment modes (first mode, second mode, third mode) according to the evaluation results of the question complexity and the answer quality; then adaptively adjusts the initial answer text based on the text adjustment mode: 1) First mode: directly uses the initial answer text as the adjusted answer text; 2) Second mode: adjusts the initial answer text based on one round of search enhancement operation to obtain the adjusted answer text; 3) Third mode: performs multiple rounds of iterative adjustments on the initial answer text based on multiple rounds of search enhancement operations to obtain the adjusted answer text. The embodiment of the present invention cancels the search enhancement operation in the first mode, which can improve the processing efficiency while ensuring the accuracy of the answer; the embodiment of the present invention improves the accuracy of the answer through a single or multiple rounds of search enhancement operation in the second and third modes; the embodiment of the present invention uses the question text + the previous answer text (the previous answer text is the initial answer text in the first round of the single or multiple rounds of search enhancement operation, and the previous answer text is the answer text obtained in the previous round in the second to the last round of the multiple rounds of search enhancement operation) as the basis for knowledge retrieval in each round of search enhancement operation, because the logic and professionalism of the answer text generated by the LLM model are higher than the question text input by non-professional questioners under normal circumstances, so adding the previous answer text during retrieval can improve the knowledge retrieval accuracy of the current round, reduce the reference context deviation of the current round, and improve the accuracy of the answer text of the current round. The embodiment of the present invention not only improves the average processing efficiency of the LLM model, but also improves the accuracy of the answer text, and can also continuously improve the accuracy of the answer text with poor quality through multiple rounds of iteration.
[0128] The professionals should further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0129] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0130] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A processing method for adjusting answer text based on an adaptive retrieval enhancement mechanism, characterized in that: The method comprises: Receive a first question text; and use a preset LLM model for processing intelligent question-answering tasks as the corresponding first model; and use a preset external knowledge base as the corresponding first knowledge base; the first model provides a plurality of preset instruction interfaces, including a first answer text generation instruction interface, a second answer text generation instruction interface, a question complexity evaluation instruction interface, and an answer quality evaluation instruction interface; Input the first question text into the first answer text generation instruction interface of the first model for processing to obtain the corresponding first answer text; input the first question text into the question complexity evaluation instruction interface of the first model for processing to obtain the corresponding first complexity evaluation result; input the first question text and the first answer text into the answer quality evaluation instruction interface of the first model for processing to obtain the corresponding first quality evaluation result; the first complexity evaluation result includes three levels: low, medium and high; the first quality evaluation result includes three levels: low, medium and high; According to the first complexity assessment result and the first quality assessment result, a text adjustment mode is confirmed to obtain a corresponding first adjustment mode; the first adjustment mode includes a first mode, a second mode and a third mode; When the first adjustment mode is the first mode, using the first answer text as the corresponding adjusted answer text; When the first adjustment mode is the second mode, a single round of retrieval enhancement and answer text adjustment processing is performed according to the first question text, the first answer text, the first knowledge base and the first model to obtain the corresponding adjusted answer text; When the first adjustment mode is the third mode, multiple rounds of retrieval enhancement and answer text adjustment processing are performed according to the first question text, the first answer text, the first knowledge base and the first model to obtain the corresponding adjusted answer text; Displaying the obtained adjusted answer text; Wherein, the first answer text generation instruction interface is used to take the question text input by the interface at the time as the corresponding current question text; and perform answer text generation processing according to the current question text and output the corresponding answer text; The second answer text generation instruction interface is used to use the question text and knowledge text set input into the interface at this time as the corresponding current question text and current reference context; and use the current reference context as the prompt text in the answer generation process, perform answer text generation processing according to the current question text and output the corresponding answer text; The question complexity evaluation instruction interface is used to take the question text input by the interface as the corresponding current question text; and identify the question text length, question knowledge domain breadth and question knowledge domain depth of the current question text; and based on the identified question text length, question knowledge domain breadth and question knowledge domain depth, evaluate the question complexity of the current question text and output the corresponding complexity evaluation result; the complexity evaluation result includes low, medium and high; The answer quality assessment instruction interface is used to use the question text and answer text input at the interface as the corresponding current question text and current answer text; and to identify the answer text credibility according to the current answer text and the current question text to obtain the corresponding answer credibility; and to identify the text semantic integrity of the current answer text to obtain the corresponding answer semantic integrity; and to evaluate the answer quality of the current answer text based on the identified answer credibility and answer semantic integrity and output the corresponding quality assessment result; the quality assessment result includes low, medium and high; The first knowledge base includes a plurality of first knowledge records; the first knowledge record includes a first knowledge text and a first text vector; the first text vector is a word embedding encoding vector corresponding to the first knowledge text; The step of confirming the text adjustment mode according to the first complexity assessment result and the first quality assessment result to obtain the corresponding first adjustment mode specifically includes: When the first complexity evaluation result is low, if the first quality evaluation result is high, the corresponding first adjustment mode is set to the first mode; if the first quality evaluation result is medium, the corresponding first adjustment mode is set to the second mode; if the first quality evaluation result is low, the corresponding first adjustment mode is set to the third mode; When the first complexity evaluation result is medium, if the first quality evaluation result is high or medium, the corresponding first adjustment mode is set to the second mode, and if the first quality evaluation result is low, the corresponding first adjustment mode is set to the third mode; When the first complexity evaluation result is high, if the first quality evaluation result is high, the corresponding first adjustment mode is set to the second mode, and if the first quality evaluation result is medium or low, the corresponding first adjustment mode is set to the third mode; The step of performing single-round retrieval enhancement and answer text adjustment processing according to the first question text, the first answer text, the first knowledge base and the first model to obtain the corresponding adjusted answer text specifically includes: The first question text and the first answer text form a corresponding first combined text; and the first combined text is word-embedded and encoded to obtain a corresponding first encoding vector; Referring to the processing principle of the RAG mechanism, the vector similarity between the first coding vector and the first text vector of each first knowledge record of the first knowledge base is calculated to obtain the corresponding first similarity; and the first knowledge text corresponding to the first text vector whose first similarity exceeds a preset similarity threshold is used as the corresponding first search text; and all the first search texts are sorted in descending order according to the first similarity to obtain the corresponding first search text sequence; and the first number K of the first search texts at the head of the sequence in the first search text sequence are extracted to form the corresponding first knowledge text set; the first number K is a preset positive integer; Inputting the first question text and the first knowledge text set into the second answer text generation instruction interface of the first model for processing to obtain a corresponding second answer text; and using the obtained second answer text as the corresponding adjusted answer text; The step of performing multiple rounds of retrieval enhancement and answer text adjustment processing according to the first question text, the first answer text, the first knowledge base, and the first model to obtain the corresponding adjusted answer text specifically includes: Step 61, taking the first answer text as the corresponding current answer text; and identifying the preset multi-round cycle mode, and if the multi-round cycle mode is the first cycle mode, initializing the corresponding first counter to 1; Wherein, the multi-cycle mode includes a first cycle mode and a second cycle mode; Step 62, forming a corresponding second combined text from the first question text and the current answer text; and performing word embedding encoding on the second combined text to obtain a corresponding second encoding vector; Step 63, referring to the processing principle of the RAG mechanism, the vector similarity between the second coding vector and each of the first text vectors of the first knowledge base is calculated to obtain the corresponding second similarity; and the first knowledge text corresponding to the first text vector whose second similarity exceeds the similarity threshold is used as the corresponding second search text; and all the second search texts are sorted in descending order according to the second similarity to obtain the corresponding second search text sequence; and the first number K of the second search texts arranged at the head of the sequence in the second search text sequence are extracted to form the corresponding second knowledge text set; Step 64, inputting the first question text and the second knowledge text set into the second answer text generation instruction interface for processing to obtain a corresponding third answer text; Step 66, inputting the first question text and the third answer text into the answer quality assessment instruction interface for processing to obtain a corresponding second quality assessment result; Wherein, the second quality assessment result includes low, medium and high; Step 65, identifying the multi-cycle mode; if the multi-cycle mode is the first cycle mode, go to step 67; if the multi-cycle mode is the second cycle mode, go to step 68; Step 67, identifying whether the first counter exceeds a preset counter threshold; if the first counter does not exceed the counter threshold, adding 1 to the first counter, taking the third answer text as the new current answer text, and returning to step 62; if the first counter exceeds the counter threshold, going to step 69; Step 68, identifying whether the second quality evaluation result is high; if the second quality evaluation result is not high, taking the third answer text as the new current answer text and returning to step 62; if the second quality evaluation result is high, going to step 69; Step 69, taking the latest third answer text as the corresponding adjusted answer text.
2. The processing method for adjusting answer text based on adaptive retrieval enhancement mechanism according to claim 1 is characterized in that: The first model has completed model pre-training and model fine-tuning; The first model includes at least Wenxinyiyan series models, ChatGPT series models, and ChatGLM series models.
3. A device for executing the processing method for adjusting answer text based on an adaptive retrieval enhancement mechanism as described in any one of claims 1-2, characterized in that: The device comprises: a question receiving module, an answer generating and evaluating module, an adjustment mode confirming module, a first answer adjusting module, a second answer adjusting module, a third answer adjusting module and an answer displaying module; The question receiving module is used to receive a first question text; and use a preset LLM model for processing intelligent question-answering tasks as the corresponding first model; and use a preset external knowledge base as the corresponding first knowledge base; the first model provides a plurality of preset instruction interfaces, including a first answer text generation instruction interface, a second answer text generation instruction interface, a question complexity evaluation instruction interface, and an answer quality evaluation instruction interface; The answer generation and evaluation module is used to input the first question text into the first answer text generation instruction interface of the first model for processing to obtain the corresponding first answer text; and input the first question text into the question complexity evaluation instruction interface of the first model for processing to obtain the corresponding first complexity evaluation result; and input the first question text and the first answer text into the answer quality evaluation instruction interface of the first model for processing to obtain the corresponding first quality evaluation result; the first complexity evaluation result includes three levels: low, medium and high; the first quality evaluation result includes three levels: low, medium and high; The adjustment mode confirmation module is used to confirm the text adjustment mode according to the first complexity assessment result and the first quality assessment result to obtain a corresponding first adjustment mode; the first adjustment mode includes a first mode, a second mode and a third mode; The first answer adjustment module is used for using the first answer text as the corresponding adjusted answer text when the first adjustment mode is the first mode; The second answer adjustment module is used for performing single-round retrieval enhancement and answer text adjustment processing according to the first question text, the first answer text, the first knowledge base and the first model to obtain the corresponding adjusted answer text when the first adjustment mode is the second mode; The third answer adjustment module is used for performing multiple rounds of retrieval enhancement and answer text adjustment processing according to the first question text, the first answer text, the first knowledge base and the first model to obtain the corresponding adjusted answer text when the first adjustment mode is the second mode; The answer display module is used to display the obtained adjusted answer text.
4. An electronic device, characterized in that: include: memory, processors, and transceivers; The processor is used to couple with the memory, read and execute instructions in the memory, so as to implement the method according to any one of claims 1 to 2; The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.
5. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a computer, the computer executes the method according to any one of claims 1 to 2.
Citation Information
Patent Citations
Complexity-controllable diversified problem generation method based on hybrid expert model
CN112668344A
Integral intelligent quality inspection device and method based on large model
CN118349678A