Model question and answer method and device, electronic equipment and nonvolatile storage medium

By combining correlation and diversity parameters in the search enhancement generation technology, document selection and adjustment are optimized, and the problem of poor model inference results caused by only considering correlation in the prior art is solved, and a more efficient and accurate multi-step question-and-answer task is achieved.

CN120508613APending Publication Date: 2025-08-19CHINA TELECOM ARTIFICIAL INTELLIGENCE TECHNOLOGY (BEIJING) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510526860.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-24
Publication Date
2025-08-19

AI Technical Summary

Technical Problem

Retrieval enhancement generation techniques in related technologies usually only consider the relevance of knowledge text, resulting in poor model inference effectiveness, especially in complex multi-step question-and-answer tasks, where redundant information leads to performance degradation.

Method used

By combining correlation parameters and diversity parameters, selecting the target document collection from the knowledge base, using a question-and-answer model for analysis, optimizing document selection and adjustment, introducing document weighting and answer quality scoring mechanisms, and using a stochastic gradient algorithm to optimize diversity and correlation.

Benefits of technology

It significantly improves the efficiency and accuracy of multi-hop question-and-answer tasks, avoids information redundancy, and improves the comprehensiveness and accuracy of answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120508613A_ABST
    Figure CN120508613A_ABST
Patent Text Reader

Abstract

The invention discloses a model question and answer method and device, electronic equipment and a nonvolatile storage medium. The method comprises the following steps: acquiring a question text; according to the correlation parameters and the diversity parameters, a target document set corresponding to the question text is determined from a knowledge base, the knowledge base comprises a plurality of knowledge documents, and the correlation parameters are used for representing the correlation degree between the knowledge documents in the target document set and the question text; the diversity parameters are used for representing the difference degree between the knowledge documents in the target document set; and analyzing the question text by adopting a question and answer model according to the content of the knowledge document in the target document set to obtain an answer result corresponding to the question text. According to the method and the device, the technical problem that the model reasoning effect is poor due to the fact that only correlation of knowledge texts is generally considered in a retrieval enhancement generation technology in related technologies is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and more specifically, to a model question-answering method, device, electronic device, and non-volatile storage medium. Background Art

[0002] Retrieval-Augmented Generation (RAG) enhances large language models for domain-specific question answering tasks by leveraging external knowledge bases. For example, the model can be enabled to answer specialized questions by retrieving relevant information from external sources outside the training set.

[0003] In complex multi-step question-answering tasks, obtaining external knowledge from multiple different perspectives is crucial to correctly answering questions. However, RAG technology in related technologies mainly focuses on relevance-based retrieval. When it is necessary to connect information from multiple sources for reasoning, redundancy often occurs, resulting in technical problems such as decreased model reasoning performance and poor answering results.

[0004] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention

[0005] The embodiments of the present application provide a model question answering method, device, electronic device and non-volatile storage medium to at least solve the technical problem that the model reasoning effect is poor because the retrieval enhancement generation technology in the related technology usually only considers the relevance of the knowledge text.

[0006] According to one aspect of an embodiment of the present application, a model question-answering method is provided, including: obtaining a question text; determining a target document set corresponding to the question text from a knowledge base based on a relevance parameter and a diversity parameter, wherein the knowledge base contains multiple knowledge documents, the relevance parameter is used to characterize the degree of relevance between the knowledge documents in the target document set and the question text, and the diversity parameter is used to characterize the degree of difference between each knowledge document in the target document set; using a question-answering model, the question text is analyzed based on the content of the knowledge documents in the target document set to obtain an answer result corresponding to the question text.

[0007] Optionally, based on the relevance parameter and the diversity parameter, determining the target document set corresponding to the question text from the knowledge base includes: obtaining a preset number of knowledge documents from multiple knowledge documents in the knowledge base to form an initial document set; determining a target optimization function, wherein the target optimization function includes: a first sub-item and a second sub-item, the first sub-item is used to calculate the relevance parameter between the question text and the initial document set, the larger the value of the relevance parameter, the higher the degree of relevance between the knowledge documents in the initial document set and the question text, the second sub-item is used to calculate the diversity parameter corresponding to the initial document set, the larger the value of the diversity parameter, the greater the degree of difference between the knowledge documents in the initial document set; by adjusting the knowledge documents in the initial document set, the function value of the target optimization function is maximized, and when the function value of the target optimization function converges to the maximum value, the initial document set is determined as the target document set.

[0008] Optionally, by adjusting the knowledge documents in the initial document set, maximizing the function value of the target optimization function includes: determining the weight vector corresponding to the knowledge base, wherein the weight vector is used to represent the first weight coefficient corresponding to each knowledge document in the knowledge base; forming an initial document set with a preset number of knowledge documents with the largest first weight coefficient in the knowledge base; determining the diversity parameter and the diversity parameter based on the question text and the initial document set, and calculating the function value of the target optimization function based on the diversity parameter and the diversity parameter; determining the first gradient value of the target optimization function relative to the weight vector, and updating the first weight coefficient corresponding to the knowledge document based on the first gradient value; re-determining the initial document set from the knowledge base based on the updated first weight coefficient, and repeating the above steps of calculating the function value of the target optimization function based on the new initial document set, until the function value of the target optimization function converges to a maximum value or the number of iterations reaches a preset threshold.

[0009] Optionally, the objective optimization function also includes: a second weight coefficient corresponding to the first sub-item, and a third weight coefficient corresponding to the second sub-item, wherein the sum of the second weight coefficient and the third weight coefficient is one; after calculating the function value of the objective optimization function, the method also includes: determining a second gradient value of the objective optimization function relative to the second weight coefficient, and updating the second weight coefficient and the third weight coefficient based on the second gradient value.

[0010] Optionally, the method also includes: using a question-answering model to analyze the question text based on the content of the knowledge documents in the initial document set to obtain an initial answer corresponding to the question text; determining a quality score corresponding to the initial answer, wherein the quality score is used to characterize the quality of the initial answer to the question text; when the quality score is less than a preset score threshold, reducing the value of the second weight coefficient and increasing the value of the third weight coefficient; when the quality score is not less than the preset score threshold, increasing the value of the second weight coefficient and reducing the value of the third weight coefficient.

[0011] Optionally, the step of determining the diversity parameter includes: determining the first semantic representation vector corresponding to each knowledge document in the target document set or the initial document set; obtaining the similarity matrix corresponding to the target document set or the initial document set by calculating the similarity scores between the first semantic representation vectors; normalizing the similarity matrix to obtain the kernel matrix, and determining the eigenvalues corresponding to the kernel matrix; determining the diversity parameter based on the eigenvalue, wherein the diversity parameter includes at least one of the following: Vendi score.

[0012] Optionally, the step of determining the relevance parameter includes: determining a second semantic representation vector corresponding to the question text; determining a similarity score between the second semantic representation vector and the first semantic representation vector corresponding to the knowledge document in the target document set or the initial document set; determining a weighting coefficient corresponding to each knowledge document in the target document set or the initial document set, and determining the relevance parameter based on the weighting coefficient and the similarity score.

[0013] According to another aspect of an embodiment of the present application, a model question-answering device is also provided, including: a question acquisition module for acquiring question text; a retrieval analysis module for determining a target document set corresponding to the question text from a knowledge base based on a relevance parameter and a diversity parameter, wherein the knowledge base contains multiple knowledge documents, the relevance parameter is used to characterize the degree of relevance between the knowledge documents in the target document set and the question text, and the diversity parameter is used to characterize the degree of difference between each knowledge document in the target document set; an answer generation module for adopting a question-answering model to analyze the question text based on the content of the knowledge documents in the target document set to obtain an answer result corresponding to the question text.

[0014] According to another aspect of an embodiment of the present application, an electronic device is provided, including: a memory and a processor, wherein the processor is configured to run a program stored in the memory, wherein the model question-answering method is executed when the program is run.

[0015] According to another aspect of an embodiment of the present application, a non-volatile storage medium is further provided, wherein the non-volatile storage medium includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the model question-answering method by running the computer program.

[0016] According to another aspect of the embodiments of the present application, a computer program product is also provided, including a computer program, which implements the steps of the model question-answering method when executed by a processor.

[0017] In an embodiment of the present application, a question text is obtained; a target document set corresponding to the question text is determined from a knowledge base based on a relevance parameter and a diversity parameter, wherein the knowledge base contains multiple knowledge documents, the relevance parameter is used to characterize the degree of relevance between the knowledge documents in the target document set and the question text, and the diversity parameter is used to characterize the degree of difference between each knowledge document in the target document set; a question-answering model is used to analyze the question text based on the content of the knowledge documents in the target document set to obtain an answer result corresponding to the question text, and by combining the diversity parameter and the relevance parameter, the selection and adjustment of the knowledge documents in the retrieval enhancement generation method are realized, thereby achieving the purpose of improving the efficiency and accuracy of the multi-hop question-answering task, thereby solving the technical problem of poor model reasoning effect caused by the fact that the retrieval enhancement generation technology in the related technology usually only considers the relevance of the knowledge text. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0019] Figure 1 This is a hardware structure block diagram of a computer terminal (or electronic device) for implementing a model question-answering method provided in an embodiment of the present application;

[0020] Figure 2 This is a schematic diagram of a model question-answering method flow according to an embodiment of the present application;

[0021] Figure 3 It is a structural diagram of a model question-answering device provided according to an embodiment of the present application. DETAILED DESCRIPTION

[0022] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.

[0023] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0024] To facilitate those skilled in the art to better understand the embodiments of the present application, some technical terms or nouns involved in the embodiments of the present application are explained as follows:

[0025] Large language models are artificial intelligence models designed to understand and generate human language. They are trained on large amounts of text data and can perform a wide range of tasks, including text summarization, translation, sentiment analysis, and more.

[0026] RAG is a hybrid model framework that combines retrieval and generation capabilities to improve natural language generation tasks. It consists of two main components: a retrieval component that searches a large-scale text database for the most relevant pieces of information for the input query, and a generation component that leverages the retrieved information to produce more accurate and targeted answers or content.

[0027] Vendi score: Perform an exponential transformation on the entropy of the normalized similarity matrix to obtain a scalar that measures the number of distribution equivalents, which can be used to evaluate diversity.

[0028] In related technologies, question answering (QA) systems generally include the following methods:

[0029] 1) Non-retrieval-based question answering methods: directly pass the question to a large language model (LLM) and use its generated output as the answer, without relying on external knowledge sources. Although these methods are efficient, they perform poorly on queries that require external or recent information and are prone to hallucinations on out-of-distribution queries.

[0030] 2) Single-step RAG method: It improves fact accuracy by retrieving external knowledge from the knowledge base, but it performs poorly in complex reasoning tasks due to the limitations of retrieval noise.

[0031] 3) Multi-step RAG methods: These are designed for complex multi-hop queries and solve complex problems through iterative retrieval and reasoning. For example, methods such as Adaptive-RAG and Self-RAG use iterative retrieval and reasoning to improve retrieval accuracy and relevance.

[0032] Relevant RAG methods in the past typically only consider the relevance of retrieved knowledge text, ignoring the importance of diversity. However, in complex multi-step question answering tasks, obtaining multiple perspectives is crucial for correctly answering questions. When reasoning requires connecting information from multiple sources, these RAG methods often suffer from redundancy, resulting in poor performance and affecting the accuracy of the final model's answers.

[0033] In order to solve the above problems, relevant solutions are provided in the embodiments of the present application. In the embodiments of the present application, a multi-information fusion RAG recall optimization algorithm is proposed, which jointly optimizes retrieval diversity and relevance through an iterative process, and introduces document weight and answer quality scoring mechanisms. The document screening and balance parameters are collaboratively optimized using a stochastic gradient algorithm, thereby significantly improving the execution effect of the multi-hop question answering task. A detailed description is given below.

[0034] According to an embodiment of the present application, a method embodiment of a model question and answer is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0035] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG1 shows a hardware structure block diagram of a computer terminal (or electronic device) for implementing the model question answering method. Figure 1 As shown, the computer terminal 10 (or electronic device) may include one or more (illustrated as 102a, 102b, ..., 102n in the figure) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1More or fewer components than shown, or with Figure 1 Different configurations shown.

[0036] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuitry". The data processing circuitry may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuitry may be a single independent processing module, or may be incorporated in whole or in part into any of the other components of the computer terminal 10 (or electronic device). As described in the embodiments of the present application, the data processing circuitry serves as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0037] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the model question-answering method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, realizing the above-mentioned model question-answering method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.

[0038] The transmission device 106 is configured to receive or transmit data via a network. A specific example of the aforementioned network may include a wireless network provided by the communications provider of the computer terminal 10. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.

[0039] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or electronic device).

[0040] In the above operating environment, the embodiment of the present application provides a model question answering method. Figure 2 This is a schematic diagram of a model question-answering method flow according to an embodiment of the present application. Figure 2 As shown, the method includes the following steps:

[0041] Step S202: obtaining a question text, wherein the question text is a text content containing a question raised by the user;

[0042] Step S204: determining a target document set corresponding to the question text from the knowledge base based on a relevance parameter and a diversity parameter, wherein the knowledge base contains multiple knowledge documents, the relevance parameter is used to characterize the degree of relevance between the knowledge documents in the target document set and the question text, and the diversity parameter is used to characterize the degree of difference between the knowledge documents in the target document set;

[0043] Step S206: Using the question-answering model, the question text is analyzed according to the content of the knowledge documents in the target document set to obtain an answer result corresponding to the question text.

[0044] Through the above steps, by combining diversity parameters and relevance parameters, the selection and adjustment of knowledge documents in the retrieval enhancement generation method are realized, thereby achieving the purpose of improving the efficiency and accuracy of multi-hop question answering tasks, and thus solving the technical problem of poor model reasoning effect caused by the fact that the retrieval enhancement generation technology in related technologies usually only considers the relevance of knowledge texts.

[0045] The following further introduces the model question-answering method in steps S202 to S206 of the embodiment of the present application.

[0046] First, the question text input by the user can be obtained, and then the target document set corresponding to the question text can be determined by jointly analyzing relevance and diversity. The specific steps are as follows.

[0047] In some embodiments of the present application, determining a target document set corresponding to a question text from a knowledge base based on a relevance parameter and a diversity parameter includes the following steps: obtaining a preset number of knowledge documents from a plurality of knowledge documents in the knowledge base to form an initial document set; determining a target optimization function, wherein the target optimization function includes: a first sub-item and a second sub-item, the first sub-item being used to calculate a relevance parameter between the question text and the initial document set, a larger value of the relevance parameter indicates a higher degree of relevance between the knowledge documents in the initial document set and the question text, the second sub-item being used to calculate a diversity parameter corresponding to the initial document set, a larger value of the diversity parameter indicates a greater degree of difference between the knowledge documents in the initial document set; maximizing the function value of the target optimization function by adjusting the knowledge documents in the initial document set, and determining the initial document set as the target document set when the function value of the target optimization function converges to a maximum value.

[0048] Assuming that there are T knowledge documents in the knowledge base (in this embodiment, the first T knowledge documents with the highest relevance scores to the question text can be taken to form the knowledge base), N (i.e. the above preset number) knowledge documents need to be selected from the T knowledge documents to form the target document set.

[0049] In this embodiment, the above requirements can be abstracted into a combinatorial optimization problem. The optimization goal is to select a subset of N documents from T candidate knowledge documents so that the VRS score of the subset (Vendi RetrievalScore, i.e., the function value of the target optimization function) is as follows:

[0050]

[0051] Among them, SS(q,D) is the first sub-item mentioned above, VS k (D) is the second sub-item above, D * The N document subsets (i.e., target document set) represented by D are the initial document set, which contains d1, d2, ..., d T There are N knowledge documents among these knowledge documents, q represents the query content (i.e., question text), and α (i.e., the third weight coefficient) is an adjustable parameter between [0, 1], which is used to control the trade-off between diversity and similarity.

[0052] In this embodiment, the diversity parameter is described by taking the Vendi Score (VS) as an example. The second sub-item VS k (D) represents the Vendi score of the initial document set D. Specifically, the present embodiment introduces a new retrieval method, called Vendi retrieval, based on the RAG method in related art. This method effectively measures the semantic diversity of retrieved documents and explicitly evaluates the diversity of retrieval results using the Vendi Score (VS). The steps for calculating the diversity parameter (Vendi score) are as follows.

[0053] In some embodiments of the present application, the step of determining the diversity parameter includes: determining the first semantic representation vector corresponding to each knowledge document in the target document set or the initial document set; obtaining the similarity matrix corresponding to the target document set or the initial document set by calculating the similarity scores between the first semantic representation vectors; normalizing the similarity matrix to obtain the kernel matrix, and determining the eigenvalues corresponding to the kernel matrix; determining the diversity parameter based on the eigenvalue, wherein the diversity parameter includes at least one of the following: Vendi score.

[0054] Specifically, the calculation formula of the Vendi score is as follows:

[0055]

[0056] Among them, λ1,…,λ n is the eigenvalue of the normalized kernel matrix K. The Vendi score represents the number of effectively unique documents in the initial document set D, which is 1 when all documents are identical and n when all documents are different and semantically independent.

[0057] The first sub-item SS(q,D) represents the relevance parameter (taking the relevance score as an example) of the query content (question text) and the initial document D. In this embodiment, a vector representation model can be used to calculate the relevance parameter (score), and the specific steps are as follows.

[0058] In some embodiments of the present application, the step of determining the relevance parameter includes: determining a second semantic representation vector corresponding to the question text; determining a similarity score between the second semantic representation vector and the first semantic representation vector corresponding to the knowledge document in the target document set or the initial document set; determining a weighting coefficient corresponding to each knowledge document in the target document set or the initial document set, and determining the relevance parameter based on the weighting coefficient and the similarity score.

[0059] By calculating the similarity of semantic representation vectors to determine the relevance parameters, the system can deeply understand the essence of the problem and accurately match it with the documents in the knowledge base.

[0060] The design of this objective optimization function is the core of this technical solution. It skillfully balances the relevance and diversity of documents, ensuring that the final document collection accurately answers the question while also encompassing diverse perspectives. This design addresses the problem of biased responses that can result from a single evaluation criterion. By dynamically adjusting the document collection, the system gradually approaches the optimal solution, providing high-quality answers even to complex and ever-changing queries.

[0061] The optimization process is further introduced below.

[0062] In some embodiments of the present application, maximizing the function value of the target optimization function by adjusting the knowledge documents in the initial document set includes the following steps: determining a weight vector corresponding to the knowledge base, wherein the weight vector is used to characterize the first weight coefficient corresponding to each knowledge document in the knowledge base; forming an initial document set with a preset number of knowledge documents with the largest first weight coefficient in the knowledge base; determining the diversity parameter and the diversity parameter based on the question text and the initial document set, and calculating the function value of the target optimization function based on the diversity parameter and the diversity parameter; determining the first gradient value of the target optimization function relative to the weight vector, and updating the first weight coefficient corresponding to the knowledge document based on the first gradient value; re-determining the initial document set from the knowledge base based on the updated first weight coefficient, and repeating the above steps of calculating the function value of the target optimization function based on the new initial document set, until the function value of the target optimization function converges to the maximum value or the number of iterations reaches a preset threshold.

[0063] In some embodiments of the present application, the objective optimization function also includes: a second weight coefficient (1-α) corresponding to the first sub-item, and a third weight coefficient (α) corresponding to the second sub-item, wherein the sum of the second weight coefficient and the third weight coefficient is one; after calculating the function value of the objective optimization function, the method also includes the following steps: determining a second gradient value of the objective optimization function relative to the second weight coefficient, and updating the second weight coefficient and the third weight coefficient based on the second gradient value.

[0064] Specifically, we can first define the weight vector w=[w1,w2,…,w T ] T , where w i Represents knowledge document d i The corresponding first weight coefficient. After that, the stochastic gradient ascent algorithm can be used to optimize the weight vector w, while dynamically adjusting the parameter α (i.e., the third weight coefficient) to maximize the target optimization function. The specific steps are as follows:

[0065] Step 1: Randomly initialize the weight vector w and parameter α, and select an initial document set D0 (for example, the first N knowledge documents in the knowledge base can be directly taken, or the N knowledge documents with the largest first weight coefficients in the knowledge base can be taken);

[0066] Step 2: For the current initial document set, calculate the target optimization function f(w,α)=αVS k (D)+(1-α)SS(q,D); Then, calculate the gradient of the target optimization function f with respect to the weight vector w (i.e. the first gradient value mentioned above) and the gradient relative to the parameter α (i.e. the second gradient value mentioned above), which is specifically shown in the following formula.

[0067]

[0068] Step 3: Update the weight vector w, the second weight coefficient 1-α, and the third weight coefficient α according to the first gradient value and the second gradient value, as shown in the following formula:

[0069]

[0070] Where η is the learning rate, w new is the updated weight vector, α new is the updated third weight coefficient;

[0071] Step 4: After that, the updated weight vector w can be used to select the N documents with the highest first weight coefficient from the knowledge base as the new initial document set D. new .

[0072] Step 5. Further, in an embodiment of the present application, a question-answering model can also be used to determine the initial answer corresponding to the question text based on the knowledge documents in the initial document set, and further adjust the parameter α by evaluating the answer quality of the generated initial answer. The specific steps are as follows.

[0073] In some embodiments of the present application, the method also includes the following steps: using a question-answering model to analyze the question text based on the content of the knowledge documents in the initial document set to obtain an initial answer corresponding to the question text; determining a quality score corresponding to the initial answer, wherein the quality score is used to characterize the quality of the initial answer to the question text; when the quality score is less than a preset score threshold, reducing the value of the second weight coefficient and increasing the value of the third weight coefficient; when the quality score is not less than the preset score threshold, increasing the value of the second weight coefficient and reducing the value of the third weight coefficient.

[0074] Specifically, a question-answering model is used to generate an initial answer based on the knowledge documents in the initial document set, and then the quality of the initial answer is scored. For example, the quality of the answer can be evaluated by experts to obtain a quality score Q(D new ).

[0075] According to the answer quality score Q(D new ) can dynamically adjust α, as shown in the following formula:

[0076]

[0077] The introduction of quality scores allows the system to self-assess the quality of responses and adjust optimization strategies accordingly. This closed-loop feedback mechanism not only improves the accuracy of responses but also promotes the self-improvement and evolution of the system.

[0078] By repeating the above steps 1-5 for iterative optimization until the target optimization function converges or reaches the preset number of iterations, the target document set can be obtained. The knowledge documents in the target document set provide the question-answering model (such as a large language model) with a knowledge source related to the question to assist the large model in reasoning and generating answers.

[0079] For example, suppose there are T = 5 recalled documents in the knowledge base, and N = 3 documents need to be screened out, and the parameter α needs to be dynamically adjusted. First, initialize the parameter α and the weight vector w. For example, α0 = 0.5; w0 = [0.1, 0.2, 0.3, 0.4, 0.5] T ; Then, according to the weight vector w0, select the three documents with the highest weights, that is, select the 5th, 4th, and 3rd documents to form the initial document set;

[0080] Assuming that the Vendi score VSk corresponding to the current initial document set is 1.2 and the similarity score SS is 0.8, the function value of the target optimization function is: f(0.5,w0)=0.5*1.2+0.5*0.8=1.0. Further calculate the gradient value, for example, =VSk-SS=1.2-0.8=0.4; is [0.05, 0.1, 0.15, 0.2, 0.25]T; weights and parameters are updated according to the gradient value. Assuming that the learning rate η is 0.1, then:

[0081] Update parameter α:

[0082] Update the weight vector w:

[0083] After that, we can use the new weight vector w1=[0.105,0.21,0.315,0.42,0.525] T , select the three documents with the highest weights, namely the 5th, 4th, and 3rd documents to form a new initial document set; based on the new initial document set, further generate candidate answers. Assuming that the answer quality score Q = 0.7 (lower than the threshold 0.8), adjust the parameter α: α adjusted =α new +Δα=0.54+0.1=0.64. Repeat the above steps until the objective function converges or the preset number of iterations is reached.

[0084] The stochastic gradient ascent algorithm allows for simultaneous document screening and parameter α optimization, maximizing the VRS score and dynamically adjusting parameter α without increasing computational complexity. This approach allows for rapid convergence to a near-optimal solution while maintaining a certain level of accuracy.

[0085] Finally, a question-answering model can be used to analyze the question text based on the content of the knowledge documents in the target document set to obtain the answer corresponding to the question text.

[0086] The model question-answering method of this application significantly improves the performance of the question-answering system by optimizing the selection of document collections by combining two key parameters: relevance and diversity. Specifically, by maximizing the objective optimization function, it ensures that the selected documents are both highly relevant to the question being asked and maintain sufficient diversity, avoiding information redundancy and improving the comprehensiveness and accuracy of the answers. In addition, by dynamically adjusting the weight coefficients, the system can automatically optimize the document selection strategy based on the quality of the answers, further enhancing the system's intelligence and adaptability.

[0087] According to an embodiment of the present application, an embodiment of a model question-answering device is also provided. Figure 3 This is a structural diagram of a model question-answering device provided according to an embodiment of the present application. Figure 3 As shown, the device includes:

[0088] The question acquisition module 30 is used to obtain the question text;

[0089] A retrieval analysis module 32 is configured to determine a target document set corresponding to the question text from a knowledge base based on a relevance parameter and a diversity parameter, wherein the knowledge base contains multiple knowledge documents, the relevance parameter is used to characterize the degree of relevance between the knowledge documents in the target document set and the question text, and the diversity parameter is used to characterize the degree of difference between the knowledge documents in the target document set;

[0090] The answer generation module 34 is used to adopt a question-answering model to analyze the question text according to the content of the knowledge documents in the target document set, and obtain an answer result corresponding to the question text.

[0091] Optionally, based on the relevance parameter and the diversity parameter, determining the target document set corresponding to the question text from the knowledge base includes: obtaining a preset number of knowledge documents from multiple knowledge documents in the knowledge base to form an initial document set; determining a target optimization function, wherein the target optimization function includes: a first sub-item and a second sub-item, the first sub-item is used to calculate the relevance parameter between the question text and the initial document set, the larger the value of the relevance parameter, the higher the degree of relevance between the knowledge documents in the initial document set and the question text, the second sub-item is used to calculate the diversity parameter corresponding to the initial document set, the larger the value of the diversity parameter, the greater the degree of difference between the knowledge documents in the initial document set; by adjusting the knowledge documents in the initial document set, the function value of the target optimization function is maximized, and when the function value of the target optimization function converges to the maximum value, the initial document set is determined as the target document set.

[0092] Optionally, by adjusting the knowledge documents in the initial document set, maximizing the function value of the target optimization function includes: determining the weight vector corresponding to the knowledge base, wherein the weight vector is used to represent the first weight coefficient corresponding to each knowledge document in the knowledge base; forming an initial document set with a preset number of knowledge documents with the largest first weight coefficient in the knowledge base; determining the diversity parameter and the diversity parameter based on the question text and the initial document set, and calculating the function value of the target optimization function based on the diversity parameter and the diversity parameter; determining the first gradient value of the target optimization function relative to the weight vector, and updating the first weight coefficient corresponding to the knowledge document based on the first gradient value; re-determining the initial document set from the knowledge base based on the updated first weight coefficient, and repeating the above steps of calculating the function value of the target optimization function based on the new initial document set, until the function value of the target optimization function converges to a maximum value or the number of iterations reaches a preset threshold.

[0093] Optionally, the target optimization function also includes: a second weight coefficient corresponding to the first sub-item, and a third weight coefficient corresponding to the second sub-item, wherein the sum of the second weight coefficient and the third weight coefficient is one; after calculating the function value of the target optimization function, the retrieval analysis module 32 is also used to: determine the second gradient value of the target optimization function relative to the second weight coefficient, and update the second weight coefficient and the third weight coefficient based on the second gradient value.

[0094] Optionally, the model question-answering device is also used to: use a question-answering model to analyze the question text based on the content of the knowledge documents in the initial document set to obtain an initial answer corresponding to the question text; determine a quality score corresponding to the initial answer, wherein the quality score is used to characterize the quality of the initial answer to the question text; when the quality score is less than a preset score threshold, reduce the value of the second weight coefficient and increase the value of the third weight coefficient; when the quality score is not less than the preset score threshold, increase the value of the second weight coefficient and reduce the value of the third weight coefficient.

[0095] Optionally, the step of determining the diversity parameter includes: determining the first semantic representation vector corresponding to each knowledge document in the target document set or the initial document set; obtaining the similarity matrix corresponding to the target document set or the initial document set by calculating the similarity scores between the first semantic representation vectors; normalizing the similarity matrix to obtain the kernel matrix, and determining the eigenvalues corresponding to the kernel matrix; determining the diversity parameter based on the eigenvalue, wherein the diversity parameter includes at least one of the following: Vendi score.

[0096] Optionally, the step of determining the relevance parameter includes: determining a second semantic representation vector corresponding to the question text; determining a similarity score between the second semantic representation vector and the first semantic representation vector corresponding to the knowledge document in the target document set or the initial document set; determining a weighting coefficient corresponding to each knowledge document in the target document set or the initial document set, and determining the relevance parameter based on the weighting coefficient and the similarity score.

[0097] It should be noted that the various modules in the above-mentioned model question-answering device can be program modules (for example, a set of program instructions that implement a certain specific function) or hardware modules. For the latter, it can be expressed in the following forms, but is not limited to this: the expression form of each of the above-mentioned modules is a processor, or the functions of each of the above-mentioned modules are implemented by a processor.

[0098] It should be noted that the model question-answering device provided in this embodiment can be used to perform Figure 2 The model question-answering method shown, therefore, the relevant explanations and descriptions of the above-mentioned model question-answering method are also applicable to the embodiments of this application and will not be repeated here.

[0099] An embodiment of the present application also provides a non-volatile storage medium, which includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the following model question-answering method by running the computer program: obtaining a question text; determining a target document set corresponding to the question text from a knowledge base based on a relevance parameter and a diversity parameter, wherein the knowledge base contains multiple knowledge documents, the relevance parameter is used to characterize the degree of relevance between the knowledge documents in the target document set and the question text, and the diversity parameter is used to characterize the degree of difference between each knowledge document in the target document set; using a question-answering model, the question text is analyzed based on the content of the knowledge documents in the target document set to obtain an answer result corresponding to the question text.

[0100] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the model question-answering method described in each embodiment of the present application: obtaining a question text; determining a target document set corresponding to the question text from a knowledge base based on a relevance parameter and a diversity parameter, wherein the knowledge base contains multiple knowledge documents, the relevance parameter is used to characterize the degree of relevance between the knowledge documents in the target document set and the question text, and the diversity parameter is used to characterize the degree of difference between each knowledge document in the target document set; using a question-answering model, the question text is analyzed based on the content of the knowledge documents in the target document set to obtain an answer result corresponding to the question text.

[0101] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0102] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0103] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only exemplary. For example, the division of the units can be a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0104] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0105] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0106] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0107] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A model question answering method, characterized in that: include: Get the question text; Determining a target document set corresponding to the question text from a knowledge base based on a relevance parameter and a diversity parameter, wherein the knowledge base includes a plurality of knowledge documents, the relevance parameter is used to characterize the degree of relevance between the knowledge documents in the target document set and the question text, and the diversity parameter is used to characterize the degree of difference between the knowledge documents in the target document set; A question-answering model is used to analyze the question text according to the content of the knowledge document in the target document set to obtain an answer result corresponding to the question text.

2. The model question answering method according to claim 1, characterized in that: Determining a target document set corresponding to the question text from the knowledge base based on the relevance parameter and the diversity parameter includes: Acquire a preset number of the knowledge documents from the plurality of the knowledge documents in the knowledge base to form an initial document set; Determine a target optimization function, wherein the target optimization function includes: a first sub-item and a second sub-item, the first sub-item is used to calculate the correlation parameter between the question text and the initial document set, a larger value of the correlation parameter indicates a higher degree of correlation between the knowledge documents in the initial document set and the question text, and the second sub-item is used to calculate the diversity parameter corresponding to the initial document set, a larger value of the diversity parameter indicates a greater degree of difference between the knowledge documents in the initial document set; The function value of the target optimization function is maximized by adjusting the knowledge documents in the initial document set, and when the function value of the target optimization function converges to a maximum value, the initial document set is determined as the target document set.

3. The model question answering method according to claim 2, characterized in that: Maximizing the function value of the target optimization function by adjusting the knowledge documents in the initial document set includes: Determining a weight vector corresponding to the knowledge base, wherein the weight vector is used to represent a first weight coefficient corresponding to each of the knowledge documents in the knowledge base; The preset number of knowledge documents with the largest first weight coefficients in the knowledge base form the initial document set; Determining the diversity parameter and the diversity parameter based on the question text and the initial document set, and calculating a function value of the target optimization function based on the diversity parameter and the diversity parameter; Determining a first gradient value of the target optimization function relative to the weight vector, and updating the first weight coefficient corresponding to the knowledge document according to the first gradient value; Based on the updated first weight coefficient, the initial document set is re-determined from the knowledge base, and based on the new initial document set, the above steps of calculating the function value of the target optimization function are repeated until the function value of the target optimization function converges to a maximum value or the number of iterations reaches a preset threshold.

4. The model question answering method according to claim 3, characterized in that: The objective optimization function further includes: a second weight coefficient corresponding to the first sub-item, and a third weight coefficient corresponding to the second sub-item, wherein the sum of the second weight coefficient and the third weight coefficient is one; after calculating the function value of the objective optimization function, the method further includes: A second gradient value of the target optimization function relative to the second weight coefficient is determined, and the second weight coefficient and the third weight coefficient are updated according to the second gradient value.

5. The model question answering method according to claim 4, characterized in that: The method further comprises: Using the question-answering model, the question text is analyzed according to the content of the knowledge document in the initial document set to obtain an initial answer corresponding to the question text; Determining a quality score corresponding to the initial answer, wherein the quality score is used to represent the quality of the initial answer in answering the question text; When the quality score is less than a preset score threshold, reducing the value of the second weight coefficient and increasing the value of the third weight coefficient; When the quality score is not less than a preset score threshold, the value of the second weight coefficient is increased, and the value of the third weight coefficient is decreased.

6. The model question answering method according to claim 1, characterized in that: The step of determining the diversity parameter comprises: Determining a first semantic representation vector corresponding to each of the knowledge documents in the target document set or the initial document set; Obtaining a similarity matrix corresponding to the target document set or the initial document set by calculating similarity scores between each of the first semantic representation vectors; Normalizing the similarity matrix to obtain a kernel matrix, and determining eigenvalues corresponding to the kernel matrix; The diversity parameter is determined based on the feature value, wherein the diversity parameter includes at least one of the following: a Vendi score.

7. The model question answering method according to claim 6, characterized in that: The step of determining the correlation parameter includes: Determining a second semantic representation vector corresponding to the question text; Determining a similarity score between the second semantic representation vector and a knowledge document in the target document set or the initial document set corresponding to the first semantic representation vector; A weighting coefficient corresponding to each of the knowledge documents in the target document set or the initial document set is determined, and the relevance parameter is determined based on the weighting coefficient and the similarity score.

8. A model question-answering device, characterized in that: include: Question acquisition module, used to obtain question text; a retrieval analysis module, configured to determine a target document set corresponding to the question text from a knowledge base based on a relevance parameter and a diversity parameter, wherein the knowledge base includes a plurality of knowledge documents, the relevance parameter being used to characterize the degree of relevance between the knowledge documents in the target document set and the question text, and the diversity parameter being used to characterize the degree of difference between the knowledge documents in the target document set; The answer generation module is used to adopt a question-answering model to analyze the question text according to the content of the knowledge document in the target document set to obtain an answer result corresponding to the question text.

9. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is used to run a program stored in the memory, wherein the program executes the model question answering method according to any one of claims 1 to 7 when running.

10. A non-volatile storage medium, characterized in that: The non-volatile storage medium includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the model question-answering method described in any one of claims 1 to 7 by running the computer program.

11. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the model question-answering method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Document-based intelligent question and answer model training method and device and application thereof

    CN116910210A

  • Teaching data classification method, system and device for retrieval enhancement generation and medium

    CN117688424A

  • Method and device for improving large model verbal skill generation quality, storage medium and electronic equipment

    CN118152537A

  • Knowledge graph question and answer method, device and system, electronic equipment and storage medium

    CN118820435A