Answer generation method and device, computer equipment, storage medium and program product

By obtaining academic reasoning questions and selecting matching reference questions and answers in a question-and-answer system in a specific academic field, optimizing and splicing to generate target answers, the problem of poor answer quality in the existing technology is solved, and answer generation that is more accurate and meets academic requirements is achieved.

CN119918666APending Publication Date: 2025-05-02TENCENT TECHNOLOGY (SHENZHEN) CO LTD +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411977033.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

The prior art has poor quality of generating answers when dealing with question-and-answer tasks in specific fields, especially in academic fields such as mathematics, physics, and chemistry.

Method used

Provide an answer generation method, by obtaining academic reasoning questions, selecting reference questions and answers that match the questions, optimizing the processing of reasoning steps or false reasoning results from the question and answer library, splicing questions and reference questions and answers, and generating target answers.

Benefits of technology

The quality of generated answers is improved to make them more accurate and in line with academic requirements. By optimizing the quality of answers in the Q&A library, the accuracy of answer generation is further improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119918666A_ABST
    Figure CN119918666A_ABST
Patent Text Reader

Abstract

The invention relates to an answer generation method and device, computer equipment, a storage medium and a program product. The method comprises the following steps: in response to a question query request, obtaining a to-be-processed academic reasoning question; selecting a reference question and answer matched with the academic reasoning question from a question and answer library of a field to which the academic reasoning question belongs; the question and answer library is obtained by optimizing at least one of reasoning steps or error reasoning results of questions and answers in an original question and answer library; splicing the academic reasoning question and the reference question and answer to obtain a spliced question and answer; and generating a target answer of the academic reasoning question based on the spliced question and answer. By adopting the method, the quality of the generated answers can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an answer generation method, apparatus, computer device, storage medium and program product. Background Art

[0002] In the field of natural language processing (NLP), question answering is one of the important research directions, especially the open domain question answering (ODQA) task. The open domain question answering system can handle a wide range of domain problems and answer various types of questions raised by users. The pre-trained language model directly generates answers by processing the input questions.

[0003] However, for question-answering tasks in specific fields, such as mathematics, physics, and chemistry, the quality of answers generated by existing answer generation schemes is poor. Summary of the invention

[0004] Based on this, it is necessary to provide an answer generation method, apparatus, computer device, computer-readable storage medium and computer program product that can improve the quality of generated answers in response to the above technical problems.

[0005] In a first aspect, the present application provides a method for generating an answer. The method comprises:

[0006] Responding to a question query request, obtaining pending academic reasoning questions;

[0007] Selecting reference questions and answers matching the academic reasoning question from a question and answer database in the field to which the academic reasoning question belongs; the question and answer database is obtained by optimizing at least one of the reasoning steps or erroneous reasoning results of the questions and answers in the original question and answer database;

[0008] Splicing the academic reasoning question and the reference question and answer to obtain a spliced ​​question and answer;

[0009] A target answer to the academic reasoning question is generated based on the concatenated question and answer.

[0010] In a second aspect, the present application also provides an answer generation device. The device comprises:

[0011] An academic reasoning question acquisition module, used to respond to a question query request and acquire an academic reasoning question to be processed;

[0012] A reference question and answer selection module is used to select reference questions and answers matching the academic reasoning question from a question and answer library in the field to which the academic reasoning question belongs; the question and answer library is obtained by optimizing at least one of the reasoning steps or erroneous reasoning results of the questions and answers in the original question and answer library;

[0013] A question-answer splicing module, used for splicing the academic reasoning question with the reference question and answer to obtain a spliced ​​question and answer;

[0014] An answer generation module is used to generate a target answer to the academic reasoning question based on the spliced ​​question and answer.

[0015] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.

[0016] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a processor.

[0017] In a fifth aspect, the present application also provides a computer program product, including a computer program, which implements the steps of the above method when executed by a processor.

[0018] The above-mentioned answer generation method, device, computer equipment, storage medium and computer program product, after responding to a question query request and obtaining the academic reasoning question to be processed, selects a reference question and answer matching the academic reasoning question from the question and answer library in the field to which the academic reasoning question belongs, and splices the academic reasoning question and the reference question and answer to obtain a spliced ​​question and answer. The reference question and answer in the spliced ​​question and answer provides additional background knowledge and reasoning steps for the academic reasoning question, so that when the target answer to the academic reasoning question is generated based on the spliced ​​question and answer, the target answer can be made more accurate and meet the academic requirements of the field to which the academic reasoning question belongs, thereby improving the quality of the generated answer; in addition, the question and answer library is obtained by optimizing at least one of the reasoning steps or erroneous reasoning results of the questions and answers in the original question and answer library. By optimizing the reasoning steps or correcting the erroneous reasoning results, a higher quality reference question and answer can be selected from the question and answer library in the future, and then when the target answer to the academic reasoning question is generated based on the reference question and answer, the quality of the generated answer can be further improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 An application environment diagram of an answer generation method in one embodiment;

[0020] Figure 2 A schematic diagram of a flow chart of an answer generation method in one embodiment;

[0021] Figure 3 A schematic flow chart of a method for generating an answer in another embodiment;

[0022] Figure 4 A schematic diagram of a process for generating answers by a target answer generation model in one embodiment;

[0023] Figure 5 A schematic diagram of a process for generating answers by an initial answer generation model in one embodiment;

[0024] Figure 6 A schematic diagram of training a target answer generation model in one embodiment;

[0025] Figure 7 A schematic diagram of a test result in one embodiment;

[0026] Figure 8 is a schematic diagram of test results in another embodiment;

[0027] Fig. 9 A flowchart of a method for generating an answer in another embodiment;

[0028] Fig.10 is a schematic diagram of test results in another embodiment;

[0029] Fig.11 is a schematic diagram of test results in another embodiment;

[0030] Fig.12 is a schematic diagram of test results in another embodiment;

[0031] Fig.13 It is a structural block diagram of an answer generating device in one embodiment;

[0032] Fig.14 It is a structural block diagram of an answer generating device in another embodiment;

[0033] Fig.15 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0034] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0035] The answer generation method provided in the embodiment of the present application can be applied to Figure 1In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other servers. The answer generation method can be executed by the terminal 102 or the server 104 alone, or by the terminal 102 and the server 104 in collaboration. In some embodiments, the answer generation method is executed by the terminal 102, and the terminal 102 responds to the question query request to obtain the academic reasoning problem to be processed; in the question and answer library in the field to which the academic reasoning problem belongs, a reference question and answer matching the academic reasoning problem is selected; the question and answer library is obtained by optimizing at least one of the reasoning steps or erroneous reasoning results of the questions and answers in the original question and answer library; the academic reasoning problem and the reference question and answer are spliced ​​to obtain a spliced ​​question and answer; the target answer to the academic reasoning problem is generated based on the spliced ​​question and answer.

[0036] Among them, the terminal 102 can be, but is not limited to, various desktop computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal 102 and the server 104 can be directly or indirectly connected via wired or wireless communications, and this application does not limit this.

[0037] In one embodiment, Figure 2 As shown, a method for generating an answer is provided, which is applied to Figure 1 The computer device in the example is used to illustrate, including the following steps:

[0038] S202, in response to a question query request, obtaining an academic reasoning question to be processed.

[0039] Among them, the question query request is a request for querying the answer to an academic reasoning question. An academic reasoning question refers to a question that requires systematic and logical reasoning and deduction based on known facts, theorems, laws or formulas to reach a conclusion or answer. It can be understood that academic reasoning questions can specifically be questions in different academic fields, such as mathematics, physics, chemistry, biology, etc. For example, an academic reasoning question in the field of mathematics is "to query the answer to an academic reasoning question". The solution".

[0040] Specifically, the terminal can display a user interface, and the user can input the academic reasoning problem to be processed in the user interface and trigger a question query operation. The terminal generates a question query request in response to the question query operation, and sends the generated question query request to the server. After receiving the question query request, the server responds to the received question query request, parses the question query request, obtains the parsing result, and extracts the academic reasoning problem to be processed from the parsing result.

[0041] S204, selecting reference questions and answers matching the academic reasoning question from the question and answer database in the field to which the academic reasoning question belongs.

[0042] Among them, the question-and-answer database in the field of academic reasoning problems is a database or knowledge base that specifically stores and manages various questions and their answers in a specific academic field, and is designed to help answer questions in a specific academic field, especially complex questions involving reasoning and deduction. For example, the mathematics field has a mathematics question-and-answer database, the physics field has a physics question-and-answer database, the biology field has a biology question-and-answer database, and the chemistry field has a chemistry question-and-answer database.

[0043] It is understandable that there may be some questions and answers in the original question and answer database with low quality answers, for example, the reasoning steps of the answers are unclear or not rigorous, there are erroneous reasoning or logical errors, the steps are incomplete or not detailed enough, etc. By optimizing the answers to the questions and answers with low quality answers in the original answer database, the quality of the answers in the questions and answers can be improved. The question and answer database is the result of optimizing the questions and answers in the original question and answer database. The optimization processing can specifically be optimizing at least one of the reasoning steps or erroneous reasoning results of the answers in the original question and answer database. The optimization processing can improve the accuracy, logic and practicality of the answers in the question and answer database, especially in the solution of academic reasoning problems, to ensure the correctness of the reasoning steps and the high quality of the results.

[0044] Reference questions and answers refer to known solutions or question-answer pairs used to assist in generating target answers in solving academic reasoning problems. Specifically, they can provide at least one piece of information including relevant reasoning steps, background knowledge, or known conclusions for the academic reasoning problems to be solved.

[0045] Specifically, after obtaining the academic reasoning problem to be processed, the computer device can determine the field to which the academic reasoning problem to be processed belongs, obtain the question and answer library corresponding to the field, and select reference questions and answers that match the academic reasoning problem from the obtained question and answer library.

[0046] In one embodiment, the question query request carries domain information, and the process of the computer device determining the domain to which the academic reasoning problem to be processed belongs includes the following steps: extracting the domain information from the question query request, and determining the domain to which the academic reasoning problem to be processed belongs based on the domain information.

[0047] Specifically, after receiving the question query request, the computer device responds to the received question query request, parses the question query request, obtains the parsing result, extracts the domain information from the parsing result, and determines the academic domain represented by the domain information as the domain to which the academic reasoning problem to be processed belongs.

[0048] In one embodiment, the process of a computer device determining the field to which the academic reasoning problem to be processed belongs includes the following steps: extracting reasoning keywords from the academic reasoning problem to be processed, and determining the field to which the academic reasoning problem to be processed belongs based on the reasoning keywords.

[0049] Among them, the number of extracted reasoning keywords can be at least one, for example, for academic reasoning question 1, the extracted reasoning keywords are "theorem" and "proof", for academic reasoning question 2, the extracted reasoning keywords are "force" and "energy", and for academic reasoning question 3, the extracted reasoning keywords are "molecules" and "reaction rate".

[0050] In one embodiment, keyword sets corresponding to different academic fields can be established in advance, and the process of a computer device determining the field to which the academic reasoning problem to be processed belongs based on the reasoning keywords includes the following steps: after extracting the reasoning keywords of the academic reasoning problem to be processed, the target keyword set to which the extracted reasoning keywords are located can be directly determined, and the academic field corresponding to the target keyword set can be determined as the field to which the academic reasoning problem to be processed belongs.

[0051] It is understandable that different academic fields may directly overlap. When the number of reasoning keywords for a certain academic reasoning problem to be processed is at least two, the reasoning keywords of the academic reasoning problem to be processed may appear in multiple keyword sets at the same time. Therefore, it is impossible to accurately judge the field to which the academic reasoning problem to be processed belongs directly based on the keyword set in which the reasoning keywords are located. Based on this, the following embodiments are also provided to achieve accurate identification of the field to which the academic reasoning problem to be processed belongs.

[0052] In another embodiment, the process of a computer device determining the field to which an academic reasoning problem to be processed belongs based on reasoning keywords includes the following steps: when the number of reasoning keywords is at least two, the reasoning keywords are input into a pre-trained field determination model, and a relationship analysis is performed on at least two reasoning keywords through the field determination model to obtain predicted academic fields corresponding to at least two reasoning keywords, and the predicted academic field is determined as the field to which the academic reasoning problem to be processed belongs.

[0053] Among them, the domain determination model is a machine learning or deep learning model used to analyze and predict the academic field to which academic reasoning problems belong. The main goal of this model is to automatically infer which academic field (such as mathematics, physics, chemistry, etc.) the problem belongs to based on the reasoning keywords in the input question.

[0054] S206, splicing the academic reasoning questions and reference questions and answers to obtain spliced ​​questions and answers.

[0055] Splicing is the process of combining two or more texts, data, elements, etc. in a certain order. In the embodiments of the present application, splicing can specifically be sequential splicing or structured splicing. Sequential splicing refers to directly connecting the academic reasoning questions and reference questions and answers to be processed in sequence into a long text. For example, structured splicing refers to structuring the questions and reference questions and answers by using tags or segmentation in the spliced ​​text.

[0056] S208, generating target answers to academic reasoning questions based on concatenated question and answer.

[0057] Specifically, after obtaining the spliced ​​question and answer, the spliced ​​question and answer can be input into the target answer generation model. Through the target answer generation model, the context, reasoning steps, relevant formulas, theorems, etc. of the academic reasoning question are automatically extracted from the input spliced ​​question and answer, and reasoning and summarization are performed to finally generate the target answer. After generating the target answer, the computer device can also output the generated target answer as a result, and the user can view the output target answer. The understandable target answer includes both the reasoning result and the reasoning process of the academic reasoning question, so that the user can intuitively understand the generation method and reasoning path of the answer. This answer makes the answer to the academic question more accurate, clear, and user-friendly.

[0058] The target answer generation model is a pre-trained natural language generation model, which may adopt architectures such as Transformer, BERT, GPT, etc. These models can generate natural language text based on given input. The target answer generation model in the embodiment of the present application can be specifically llama3.1-8b-instruct

[0059] In the above-mentioned answer generation method, after responding to the question query request and obtaining the academic reasoning question to be processed, a reference question and answer matching the academic reasoning question is selected from the question and answer library in the field to which the academic reasoning question belongs, and the academic reasoning question and the reference question and answer are spliced ​​to obtain a spliced ​​question and answer. The reference question and answer in the spliced ​​question and answer provides additional background knowledge and reasoning steps for the academic reasoning question, so that when the target answer to the academic reasoning question is generated based on the spliced ​​question and answer, the target answer can be made more accurate and meet the academic requirements of the field to which the academic reasoning question belongs, thereby improving the quality of the generated answer; in addition, the question and answer library is obtained by optimizing at least one of the reasoning steps or erroneous reasoning results of the question and answer in the original question and answer library. By optimizing the reasoning steps or correcting the erroneous reasoning results, a higher quality reference question and answer can be selected from the question and answer library in the future, and then when the target answer to the academic reasoning question is generated based on the reference question and answer, the quality of the generated answer can be further improved.

[0060] In one embodiment, the process of a computer device selecting a reference question and answer that matches an academic reasoning question from a question and answer library in the field to which the academic reasoning question belongs includes the following steps: obtaining each question and answer in the question and answer library in the field to which the academic reasoning question belongs; determining the question similarity between the academic reasoning question and each question and answer respectively; and selecting a reference question and answer for the academic reasoning question based on the question similarity among the questions and answers.

[0061] Among them, question similarity refers to the degree of similarity between the academic reasoning questions to be processed and the questions in the question and answer database in terms of semantics, grammar, structure, etc.

[0062] Specifically, the computer device obtains questions in each question and answer in the question and answer library in the field to which the academic reasoning question to be processed belongs, and calculates the question similarity between the academic reasoning question to be processed and each question respectively, and selects reference questions and answers of the academic reasoning question based on the question similarity in the question and answer.

[0063] In one embodiment, the process of a computer device separately determining the problem similarity between an academic reasoning question and each question and answer includes the following steps: vectorizing the academic reasoning question to obtain an academic reasoning question vector; vectorizing the question in each question and answer to obtain a question vector; separately determining the cosine distance between the academic reasoning question vector and each question vector; and using the cosine distance to determine the problem similarity between the academic reasoning question and the corresponding question and answer.

[0064] Among them, vectorization processing refers to the process of converting text data into numerical vectors.

[0065] Specifically, the computer device can input the academic reasoning question into a pre-trained embedding model, vectorize the academic reasoning question through the embedding model, and obtain the academic reasoning question vector. In addition, the computer device can also input the question in each question and answer into a pre-trained embedding model respectively, vectorize the input question through the embedding model, obtain the question vector corresponding to each question, and determine the cosine distance between the academic reasoning question vector and each question vector respectively; use the cosine distance to determine the problem similarity between the academic reasoning question and the corresponding question and answer.

[0066] Among them, the embedding model is a deep learning model used to convert text into a dense numerical vector representation, which can be Word2Vec, GloVe, BERT, all-mpnet-base-v2, etc. In the embodiment of the present application, the embedding model used can be all-mpnet-base-v2. All-mpnet-base-v2 is a pre-trained embedding model based on the MPNet architecture, which is optimized for generating high-quality sentence embeddings and is therefore more suitable for vectorizing problems.

[0067] In one embodiment, the process of selecting reference questions and answers of academic reasoning questions based on question similarity in a question and answer session by a computer device includes the following steps: selecting questions and answers whose question similarity meets a selection condition as reference questions and answers of academic reasoning questions in a question and answer session. The selection condition may specifically be at least one of a similarity threshold condition and a similarity ranking condition.

[0068] In one embodiment, the selection condition is a similarity threshold condition. After obtaining the problem similarity between the academic reasoning problem and each question and answer, the computer device can compare the problem similarity corresponding to each question with the similarity threshold specified by the similarity threshold condition. For any question, if the problem similarity corresponding to the question is greater than or equal to the similarity threshold, then the question is used as a reference question and answer corresponding to the academic reasoning problem. By comparing each question with the similarity threshold, the question and answer whose question similarity meets the similarity threshold condition can be selected as the reference question and answer for the academic reasoning problem.

[0069] In one embodiment, the selection condition is a similarity sorting condition. After obtaining the question similarity between the academic reasoning question and each question and answer, the computer device can sort each question and answer in descending order of question similarity to obtain sorted questions and answers, and select questions and answers with a sorting value less than or equal to a sorting threshold specified by the similarity sorting condition from the sorted questions and answers as reference questions and answers for the academic reasoning question. For example, the previous K questions and answers are selected as reference questions and answers.

[0070] In the above embodiment, the computer device obtains each question and answer in the question and answer library of the field to which the academic reasoning question belongs; determines the question similarity between the academic reasoning question and each question and answer respectively; and selects the reference question and answer of the academic reasoning question based on the question similarity among the questions and answers. The reference question and answer provides additional background knowledge and reasoning steps for the academic reasoning question, so that when the target answer of the academic reasoning question is subsequently generated based on the reference question and answer, the target answer can be made more accurate and meet the academic requirements of the field to which the academic reasoning question belongs, thereby improving the quality of the generated answer.

[0071] In one embodiment, the process of selecting reference questions and answers of academic reasoning questions based on question similarity in a question and answer comprises the following steps: determining candidate reference questions and answers whose question similarity satisfies a candidate condition in the question and answer; displaying the candidate reference questions and answers; and in response to a selection operation on the candidate reference questions and answers, determining the candidate reference questions and answers specified by the selection operation as reference questions and answers of the academic reasoning questions. Specifically, the candidate condition may be at least one of a threshold candidate condition and a ranking candidate condition.

[0072] Specifically, after determining the source of candidate reference questions and answers, the computer device can display each candidate reference question and answer in an interactive interface for the user to select. The computer device responds to the selection operation of the candidate reference question and answer, determines the candidate reference question and answer specified by the selection operation, and determines the candidate reference question and answer specified by the selection operation as the reference question and answer for the academic reasoning question.

[0073] In one embodiment, the candidate condition is a threshold candidate condition. After obtaining the question similarity between the academic reasoning question and each question and answer, the computer device can compare the question similarity corresponding to each question with the similarity threshold specified by the threshold candidate condition. For any question, if the question similarity corresponding to the question is greater than or equal to the similarity threshold, the question will be used as a candidate reference question and answer corresponding to the academic reasoning question.

[0074] In one embodiment, the candidate condition is a sorting candidate condition. After obtaining the question similarity between the academic reasoning question and each question and answer, the computer device can sort the questions and answers in descending order of question similarity to obtain sorted questions and answers, and select questions and answers with a sorting sequence value less than or equal to a sorting threshold specified by the sorting candidate condition from the sorted questions and answers as reference questions and answers for the academic reasoning question. For example, select the previous N questions and answers as reference questions and answers.

[0075] In the above embodiment, the computer device selects and displays candidate reference questions and answers and allows the user to participate in the final selection process. The user can quickly browse and select the reference questions and answers that best meet the needs. When the target answers to academic reasoning questions are subsequently generated based on the reference questions and answers, the target answers can be made more accurate and meet the user's needs, thereby improving the quality of the generated answers.

[0076] In one embodiment, the target answer is generated by a target answer generation model, and the above-mentioned answer generation method also includes the following steps: obtaining training samples, the training samples include sample questions and sample answers; selecting sample reference questions and answers that match the sample questions in the question and answer library; splicing the sample questions and the sample reference questions and answers to obtain sample spliced ​​questions and answers; fine-tuning the initial answer generation model based on the sample spliced ​​questions and answers and the sample answers to obtain the target answer generation model.

[0077] Among them, the initial answer generation model is an answer generation model pre-trained by using a traditional solution. Specifically, the training samples can be directly input into the answer generation model to be trained for training, so as to obtain the initial answer generation model.

[0078] It is understandable that each sample data in the training sample includes a question-answer pair consisting of a sample question and a sample answer. The sample question is a question that requires reasoning and answering, and the sample answer is the correct answer corresponding to the sample question, which can specifically be the reasoning process, solution steps, and final reasoning result of the sample question. It is understandable that during the training process, the sample answer in each question-answer pair participates in the training of the model as a true label.

[0079] Specifically, after obtaining the sample question and sample answer, the computer device can determine the field to which the sample question belongs, obtain the question and answer library corresponding to the field, and determine the similarity between the questions of each question and answer in the sample question and answer library, and select the sample reference question and answer that matches the sample question in the question and answer library based on the similarity, and compare the sample question with the sample reference question and answer to obtain a sample spliced ​​question and answer, and input the sample spliced ​​question and answer and the sample answer into the initial answer generation model to train the initial answer generation model until the target answer generation model is obtained.

[0080] In one embodiment, the selection of sample reference questions can be characterized as follows:

[0081]

[0082] in, represents a sample problem, represents the questions and answers in the question-answer database, D represents the entire question-answer database, Represents the sample removal problem All the question and answer sets after that, S is a subset, representing K questions selected from the question and answer database related to the sample question The most similar sample reference questions and answers, Indicates that the K questions and answers with the largest sum of similarities to the sample questions are selected as reference questions and answers through the arg max operation. represents the kth reference question and answer selected, represents the kth reference question, The answer to the kth reference question. ⊕ indicates concatenation.

[0083] In one embodiment, the sample answer corresponding to the sample question may be obtained by optimizing at least one of the reasoning steps or the erroneous reasoning results of the original answer. The training data including the sample concatenated question and answer and the sample answer for fine-tuning training may be characterized as follows:

[0084]

[0085] in, represents sample splicing question and answer, Represents the sample answer obtained by optimizing the original answer.

[0086] In the above embodiment, the computer device is trained by using reference questions and answers that are closely related to the sample questions, so that the model can learn how to generate more accurate answers with more complete and detailed steps, thereby improving the effect of model training.

[0087] In one embodiment, a computer device fine-tunes an initial answer generation model based on sample concatenated questions and answers and sample answers to obtain a target answer generation model, the process comprising the following steps: processing the sample concatenated questions and answers through the initial answer generation model to obtain a predicted answer; determining a training loss value based on the predicted answer and the sample answer; and optimizing the parameters of the initial answer generation model based on the training loss value to obtain a target answer generation model.

[0088] Specifically, the computer device vectorizes the sample splicing question to obtain a sample splicing question and answer vector, and inputs the sample splicing question and answer vector into the initial answer generation model, encodes the sample splicing question and answer vector through the encoder of the initial answer generation model to obtain a sample encoding vector, and processes the sample encoding vector through the decoder of the initial answer generation model to obtain a predicted answer, and determines a training loss value based on the predicted answer and the sample answer, and optimizes the parameters of the encoder and the decoder of the initial answer generation model based on the training loss value until the convergence condition is reached to obtain the target answer generation model.

[0089] The encoder is used to understand the input data and convert the output data into a vector identifier that can be processed by the decoder. The decoder is used to generate the final result based on the output of the encoder. The convergence condition refers to the stopping standard of the training process, which means that after multiple updates, the parameters of the model have reached a stable state and no longer change significantly or their changes are small enough. The convergence condition can be specifically that the training loss no longer decreases significantly or the maximum number of iterations is reached.

[0090] In the above embodiment, the computer device processes the sample splicing question and answer through the initial answer generation model to obtain a predicted answer; determines the training loss value based on the predicted answer and the sample answer; and optimizes the parameters of the initial answer generation model based on the training loss value. The model can continuously improve its performance based on new data or feedback, thereby improving the effect of model training.

[0091] In one embodiment, the above-mentioned answer generation method also includes the following steps: generating an initial answer based on the academic reasoning question; determining the answer quality score of the initial answer; when the answer quality score does not meet the scoring conditions, executing the step of selecting a reference question and answer that matches the academic reasoning question from the question and answer library in the field to which the academic reasoning question belongs.

[0092] Among them, the answer quality score is the result of evaluating the generated initial answer, which is used to measure the quality of the initial answer in terms of accuracy, completeness, logic and clarity.

[0093] Specifically, after obtaining the academic reasoning problem to be processed, the computer device can first input the academic reasoning problem to be processed into the initial answer generation model, process the academic reasoning problem through the initial answer generation model to obtain an initial answer, and perform a quality assessment on the generated initial answer to determine the answer quality score of the initial answer, and compare the obtained answer quality score with the scoring threshold specified by the scoring condition. If the answer quality score is less than the scoring threshold, it is determined that the answer quality score does not meet the scoring condition. Then, in the question and answer library of the field to which the academic reasoning problem belongs, a reference question and answer that matches the academic reasoning problem is selected, and the academic reasoning problem and the reference question and answer are spliced ​​to obtain a spliced ​​question and answer; and a target answer to the academic reasoning problem is generated based on the spliced ​​question and answer through the target answer generation model.

[0094] In the above embodiment, the computer device generates an initial answer and evaluates its quality. When the quality of the initial answer does not meet the standard, a more in-depth answer generation scheme is called to generate an enhanced answer, thereby improving the quality of the final output answer.

[0095] In one embodiment, the process of a computer device determining an answer quality score for an initial answer includes the following steps: inputting an academic reasoning question and an initial answer into a pre-trained answer evaluation model; performing feature processing on the academic reasoning question and the initial answer through a feature processing layer of the answer evaluation model to obtain fused features; and performing quality score prediction on the fused features through a regression layer of the answer evaluation model to obtain an answer quality score for the initial answer.

[0096] Among them, the pre-trained answer evaluation model is a model that has been trained with large-scale data and is specifically used for evaluation and scoring of high-quality answers. For example, when the field of the academic reasoning problem to be processed is mathematics, the answer evaluation model used can be the qwen2.5-math-RM-72B model, which is a pre-trained large-scale language model (LLM) optimized for problems in the mathematics field.

[0097] The feature processing layer of the answer evaluation model refers to the part of the model responsible for extracting and processing features of the input academic reasoning questions and initial answers. The purpose of this layer is to convert the original text (i.e., academic reasoning questions and initial answers) into feature representations suitable for further analysis and prediction, so that subsequent model layers can effectively evaluate the quality of the answer.

[0098] Fusion features usually refer to combining the feature information of academic reasoning questions and initial answers to generate a new feature representation. The fusion features contain the relationship and interaction information between the question and the answer, thereby helping the model to better judge the quality of the answer.

[0099] The regression layer of the answer evaluation model is used to predict a continuous value as the answer quality score based on the fused features. This score represents the quality of the generated answer and can be a real number. The higher the score, the better the answer quality, and the lower the score, the worse the quality.

[0100] It is understandable that the scoring threshold can be determined based on the test results on different data sets, such as allowing the model to get the answer on the training set, inputting it into the qwen2.5-math-RM-72B model for evaluation, and using the ROC curve to evaluate the optimal scoring threshold.

[0101] In the above embodiment, the computer device inputs the academic reasoning question and the initial answer into a pre-trained answer evaluation model; performs feature processing on the academic reasoning question and the initial answer through the feature processing layer of the answer evaluation model to obtain fused features; and performs quality score prediction on the fused features through the regression layer of the answer evaluation model, thereby achieving accurate quality evaluation of the initial answer and obtaining a more accurate answer quality score.

[0102] In one embodiment, the above-mentioned answer generation method also includes the following steps: when the answer quality score meets the scoring conditions, the initial answer is displayed on the interactive page; when a replacement instruction for the initial answer is received, the step of returning to execute in the question and answer library in the field to which the academic reasoning question belongs, and selecting a reference question and answer that matches the academic reasoning question until the target answer to the academic reasoning question is obtained; and the initial answer displayed on the interactive page is updated to the target answer.

[0103] Specifically, the computer device compares the obtained answer quality score with the scoring threshold specified by the scoring condition. If the obtained answer quality score is greater than or equal to the scoring threshold, it is determined that the answer quality score meets the scoring condition, and the generated initial answer is displayed on the interactive page for the user to view. An answer replacement button is also displayed on the interactive page. The user can view the initial answer on the interactive page. If the user is not satisfied with the generated initial answer, the user can click the answer replacement button. The computer device generates a replacement instruction for the initial answer in response to the triggering operation of the answer replacement button, and selects a reference question and answer matching the academic reasoning question from the question and answer library in the field to which the academic reasoning question belongs according to the replacement instruction for the initial answer, and splices the academic reasoning question and the reference question and answer to obtain a spliced ​​question and answer; generates a target answer to the academic reasoning question based on the spliced ​​question and answer through the target answer generation model, and updates the initial answer displayed on the interactive page to the generated target answer.

[0104] In the above embodiment, when the answer quality score meets the scoring conditions, the computer device displays the initial answer on the interactive page, and the user can view the initial answer on the interactive page. If the user is not satisfied with the generated initial answer, the user can trigger a replacement instruction for the initial answer to call a more in-depth answer generation solution to generate an enhanced answer, thereby improving the quality of the final output answer.

[0105] In one embodiment, the above-mentioned answer generation method also includes the following steps: obtaining the questions and answers to be optimized and the optimization indication information in the original question and answer library; inputting the questions and answers to be optimized and the optimization indication information into a pre-trained answer optimization model, so that the answer optimization model performs inference optimization processing on the answers to the questions and answers to be optimized according to the optimization indication information to obtain the optimized questions and answers.

[0106] Among them, the optimization instruction information is the guidance information provided to the optimization model when optimizing the question to be optimized, which helps the model understand the aspects that need to be improved and the direction of optimization. For example, the optimization instruction information is "You are a math teacher. Please rewrite the answer to the above question to make the steps and calculations clearer. Please use {} to surround the answer in the final answer." The reasoning optimization processing includes optimizing at least one of the reasoning steps or erroneous reasoning results of the question to be optimized.

[0107] The pre-trained answer optimization model is a deep learning model trained with large-scale data. It is specifically used to optimize based on a given answer, improve its reasoning process, logical structure or calculation steps, so as to generate a more accurate, clear and compliant answer. The pre-trained answer optimization model can be a gpt-4omini model, which is a small variant model based on the GPT-4 architecture. Compared with the original GPT-4, the GPT-4 Omini model provides a lighter reasoning capability by reducing the number of parameters and optimizing computing efficiency.

[0108] In the above embodiment, the computer device obtains the questions and answers to be optimized and the optimization indication information in the original question and answer library; inputs the questions and answers to be optimized and the optimization indication information into a pre-trained answer optimization model, so that the answer optimization model performs inference optimization processing on the answers to the questions and answers to be optimized according to the optimization indication information, and obtains the optimized questions and answers, thereby enhancing the detail level, logical structure or comprehensiveness of information of the answers in the question and answer library, providing more accurate and detailed reference information for subsequent auxiliary answer generation, thereby improving the quality of the generated answers.

[0109] In one embodiment, a computer device performs inference optimization processing on the answer to the question and answer to be optimized according to the optimization indication information, and the process of obtaining the optimized question and answer includes the following steps: performing at least two inference optimization processings on the answer to the question and answer to be optimized based on the optimization indication information to obtain at least two candidate answers; and selecting a candidate answer that meets the optimization conditions from among the at least two candidate answers as the optimized question and answer.

[0110] It can be understood that, by performing each reasoning optimization process on the answer to the optimization question and answer based on the optimization indication information, a candidate answer can be obtained, and by performing m reasoning optimization processes on the answer to the optimization question and answer based on the optimization indication information, m candidate answers can be obtained.

[0111] Among them, optimization conditions refer to optimization selection conditions, which are used to evaluate and select the final optimization answers. The optimization conditions include requirements for accuracy, clarity, completeness, and compliance with optimization instruction information.

[0112] Specifically, the computer device performs at least two reasoning optimization processes on the answer to the optimized question and answer based on the optimization indication information to obtain at least two candidate answers, and selects the candidate answer that meets the optimization conditions from the at least two candidate answers as the optimized answer. The optimized answer and the corresponding question constitute the optimized question and answer. For example, five reasoning optimization processes are performed to obtain five candidate answers, and the candidate answer that is consistent with the reasoning result of the original answer and has the most detailed reasoning process is selected from the five answers as the optimized answer.

[0113] In one embodiment, after the computer device performs at least two inference optimization processes on the answer to the question and answer to be optimized based on the optimization indication information and obtains at least two candidate answers, the computer device can also input the sample question and the corresponding candidate answers into a pre-trained answer evaluation model, output the answer quality score corresponding to each candidate answer through the pre-trained answer evaluation model, and select the candidate answer with the highest answer quality score from each candidate answer as the optimized answer. The optimized answer and the corresponding question constitute the optimized question and answer.

[0114] In the above embodiment, the computer device performs at least two reasoning optimization processes on the answer to the question and answer to be optimized based on the optimization indication information to obtain at least two candidate answers; among the at least two candidate answers, the candidate answer that meets the optimization conditions is selected as the optimized question and answer, so that a higher quality optimized question and answer can be obtained, thereby enhancing the detail level, logical structure or comprehensiveness of information of the answers in the question and answer library, providing more accurate and detailed reference information for subsequent auxiliary answer generation, thereby improving the quality of the generated answers.

[0115] In one embodiment, the process of a computer device generating a target answer to an academic reasoning question based on a spliced ​​question and answer includes the following steps: vectorizing the spliced ​​question and answer to obtain a spliced ​​question and answer vector; encoding the spliced ​​question and answer vector to obtain an encoded vector; and generating a target answer to the academic reasoning question based on the encoded vector.

[0116] Among them, vectorization processing refers to the process of converting text data into numerical vectors.

[0117] Specifically, the computer device can input the concatenated question and answer into a pre-trained embedding model, vectorize the concatenated question and answer through the embedding model to obtain a concatenated question and answer vector, and then input the concatenated question and answer vector into the target answer generation model, encode the concatenated question and answer vector through the encoder of the target answer generation model to obtain an encoded vector, input the encoded vector into the decoder of the target answer generation model, and process the encoded vector through the decoder to generate the target answer to the academic reasoning question. The generation process of the decoder can be generated token-by-token, and each step is based on the previous generation content and the context provided by the encoder for reasoning.

[0118] In the above embodiment, the computer device vectorizes the spliced ​​question and answer to obtain a spliced ​​question and answer vector, and encodes the spliced ​​question and answer vector to obtain an encoded vector. The encoded vector can better reflect the semantic characteristics and internal structure of the spliced ​​question and answer. Generating a target answer to an academic reasoning question based on the encoded vector can make the generated target answer more accurate and relevant, thereby improving the quality of the generated answer.

[0119] In one embodiment, Figure 3 As shown, a method for generating an answer is also provided, which is applied to Figure 1 The computer device in the example is used to illustrate, including the following steps:

[0120] S302, in response to a question query request, obtaining an academic reasoning question to be processed.

[0121] S304, generating an initial answer by processing the academic reasoning question through the initial answer generation model.

[0122] S306, determining the answer quality score of the initial answer.

[0123] S308, when the answer quality score does not meet the scoring conditions, obtain each question and answer in the question and answer library of the field to which the academic reasoning question belongs.

[0124] The question-and-answer database is obtained by optimizing at least one of the reasoning steps or erroneous reasoning results of the questions and answers in the original question-and-answer database.

[0125] In one embodiment, the process of optimizing questions and answers in an original question and answer library by a computer device includes the following steps: obtaining questions and answers to be optimized and optimization indication information in the original question and answer library; inputting the questions and answers to be optimized and the optimization indication information into a pre-trained answer optimization model, so that the answer optimization model performs reasoning optimization processing on the answers to the questions and answers to be optimized according to the optimization indication information to obtain optimized questions and answers; the reasoning optimization processing includes optimizing at least one of the reasoning steps or erroneous reasoning results of the questions and answers to be optimized.

[0126] S310, respectively determining the question similarity between the academic reasoning question and each question and answer.

[0127] S312, in question and answer, reference questions and answers for academic reasoning questions are selected based on question similarity.

[0128] S314, splicing the academic reasoning questions and reference questions and answers to obtain spliced ​​questions and answers.

[0129] S316, processing the concatenated question and answer through the target answer generation model to generate the target answer to the academic reasoning question.

[0130] Among them, the target answer generation model is obtained by fine-tuning the initial answer generation model, and the fine-tuning training process includes the following steps: obtaining training samples, the training samples include sample questions and sample answers; selecting sample reference questions and answers that match the sample questions in the question and answer library; splicing the sample questions and sample reference questions and answers to obtain sample spliced ​​questions and answers; fine-tuning the initial answer generation model based on the sample spliced ​​questions and answers and the sample answers to obtain the target answer generation model.

[0131] In one embodiment, a computer device fine-tunes an initial answer generation model based on sample concatenated questions and answers and sample answers to obtain a target answer generation model, the process comprising the following steps: processing the sample concatenated questions and answers through the initial answer generation model to obtain a predicted answer; determining a training loss value based on the predicted answer and the sample answer; and optimizing the parameters of the initial answer generation model based on the training loss value to obtain a target answer generation model.

[0132] The present application also provides an application scenario, which can specifically be an educational scenario. The above-mentioned answer generation method can be applied in the educational scenario, and the learning or teaching effect can be improved in problem solving, homework tutoring, online learning, test evaluation, etc. For example, in problem solving, students and teachers can submit question query requests for academic reasoning problems through a conversational interface, and through the above-mentioned answer generation method, a target answer containing a detailed solution process and correct reasoning results can be generated; in homework tutoring, students can submit question query requests for academic reasoning problems in the process of handling homework, and through the above-mentioned answer generation method, a target answer containing a detailed solution process and correct reasoning results can be generated, and the target answer can help students understand the questions and provide ideas for solving the questions. It can even correct mistakes and provide students with personalized learning support; in terms of online learning, the online learning platform can apply the above-mentioned answer generation method. During the learning process through the online learning platform, users can submit question query requests for academic reasoning problems. Through the above-mentioned answer generation method, a target answer containing a detailed solution process and correct reasoning results can be generated. The target answer can help users improve their learning efficiency and effectiveness; in terms of exam evaluation, the evaluation tool can apply the above-mentioned answer generation method to generate target answers corresponding to exam questions, and compare the target answers with the candidates' answers extracted from the exam papers, so as to achieve more accurate and automated scoring and feedback, help teachers quickly review exam papers, provide detailed scoring basis and analysis, and improve the accuracy and efficiency of evaluation.

[0133] The present application also provides an application scenario, which can specifically be an answer generation scenario in the field of mathematics. When the above answer generation method is applied to the application scenario, the target answer is generated by a target answer generation model, referring to Figure 4 As shown in the flowchart, after obtaining the math problem, the computer device selects reference questions and answers that match the math problem from the question and answer library in the math field through the RAG (retrieval enhancement) module, and splices the math problem with the reference questions and answers to obtain a spliced ​​math question and answer, which is then input into the target answer generation model, and processed by the target answer generation model to generate a target answer to the math problem.

[0134] The target answer generation model is obtained by fine-tuning the initial answer generation model, and the initial answer generation model is an answer generation model trained using traditional schemes, such as Figure 5 As shown, when the initial answer generation model is used to generate an answer, the math problem is directly input into the initial answer generation model, and the math problem is processed by the initial answer generation model to generate an initial answer to the math problem.

[0135] The target answer generation model is obtained by fine-tuning the initial answer generation model using the RAG-target SFT (supervised fine-tuning) technique. Figure 6 As shown, the fine-tuning training process includes the following steps: after the initial answer generation model is obtained by training with the traditional scheme, training samples can also be obtained, and the training samples include sample questions and sample answers, and the RAG module is called to select sample reference questions and answers that match the sample questions in the question and answer library in the field of mathematics through the RAG module; the sample questions and sample reference questions and answers are spliced ​​to obtain sample spliced ​​questions and answers; based on the sample spliced ​​questions and answers and the sample answers, the initial answer generation model is fine-tuned to obtain the target answer generation model.

[0136] In order to verify the effect of the target answer generation model, the target answer generation model, the initial answer generation model trained by the traditional scheme, the comparative answer generation model 1 and the answer generation model 2 were experimented on the mathematical reasoning datasets GSM8k and MATH respectively. The comparative answer generation model 1 was obtained by fine-tuning the initial answer generation model using the standard sft (standard fine-tuning) technology, that is, the sample questions and sample answers were directly used to fine-tune the initial answer generation model; the answer generation model 2 was obtained by fine-tuning the initial answer generation model using the random-example sft (random example fine-tuning) technology, that is, in the question and answer library, sample reference questions and answers were randomly selected, and the mathematical questions were spliced ​​with the sample reference questions and answers to obtain sample spliced ​​questions and answers, and the initial answer generation model was fine-tuned based on the sample spliced ​​questions and answers and the sample answers. The base model of the initial answer generation model is llama3.1-8b-instruct; refer to Figure 7The evaluation results shown in the figure are based on the accuracy of the answers output by the model. The brackets next to all the results indicate the number of sample reference questions and answers. The target answer generation model has the highest accuracy on the mathematical reasoning datasets GSM8k and MATH, that is, the target answer generation models MATH and gsm8k have achieved the best results. Standard fine-tuning and random example fine-tuning also have certain improvement effects, but they are not as obvious as RAG example fine-tuning. In the case where the initial answer generation model is not fine-tuned, direct reasoning may be more effective than using RAG technology. The reasoning performance of the model after standard fine-tuning has improved, indicating that standard fine-tuning improves the basic performance of the model, but does not improve the adaptability (ICL) of the model. The performance of random example fine-tuning is slightly lower than that of RAG-target fine-tuning, which seems to only improve the adaptability (ICL) of the model. The model cannot extract effective information from random examples to help reasoning.

[0137] refer to Figure 8 The test results shown in the figure, the inner circle represents the test results on the GSM8k dataset, the outer circle represents the test results under the MATH dataset, rag represents the test results based on the target answer generation model that calls the RAG module, zs represents the test results based on the initial answer generation model that does not call the RAG module, 1 represents the generated answer is correct, 0 represents the generated answer is wrong, zs1_rag0 represents the answer generated by the initial answer generation model is correct and the answer generated by the target answer generation model is wrong, zs0_rag1 represents the answer generated by the initial answer generation model is wrong and the answer generated by the target answer generation model is correct, zs1_rag1 represents the answers generated by both models are correct, zs0_rag0 represents the answers generated by both models are wrong, through Figure 8 It can be seen that the correctness of the target answer generated by the target answer generation model is not completely overlapping with the correctness of the initial answer generated by the initial answer generation model. That is to say, for a certain math problem, the initial answer generated by the initial answer generation model is correct, while the target answer generated by the target answer generation model is wrong. Figure 8 As can be seen in the figure, in the GSM8k dataset, the probability of this happening is 5.998%, and in the MATH dataset, the probability of this happening is 10.42%.

[0138] Therefore, in order to further improve the accuracy of the answer, the present application also provides an application scenario, which combines the initial answer generation model and the target answer generation model to generate the answer, referring to Fig. 9As shown in the flowchart, after obtaining the math problem, the computer device inputs the math problem into the initial answer generation model, processes the math problem through the initial answer generation model, generates an initial answer to the math problem, and uses the RAG Inference Trigger to evaluate the quality of the initial answer. If the quality of the initial answer meets the conditions, the RAG module is triggered to re-infer the answer. The RAG module selects a reference question and answer matching the math problem from the question and answer library in the field of mathematics, and splices the math problem with the reference question and answer to obtain a spliced ​​math question and answer. The spliced ​​math question and answer is input into the target answer generation model, and the spliced ​​math question and answer is processed by the target answer generation model to generate a target answer to the math problem. The target answer is the obtained enhanced answer.

[0139] The reasoning strategy of directly using the initial answer generation model to generate answers is defined as zero-shot reasoning (zeroshot), the reasoning strategy of directly using the target answer generation model to generate answers is defined as standard fine-tuning sample reasoning (RAG-target sft), and the reasoning strategy of using the initial answer generation model and the target answer generation model to generate answers is defined as composite reasoning (RAG-target sft +RAG Inference Trigger). The above three reasoning strategies are experimented on the mathematical reasoning datasets GSM8k and MATH, and the results are obtained. Fig.10 The results shown are evaluated by the accuracy of the answers output by the model. Zero-shot reasoning represents the basic ability of the model without additional examples or information. The model fine-tuned with RAG-target sft technology can understand and answer questions more effectively with the help of examples. Since the correctness of zero-shot reasoning and standard fine-tuning sample reasoning (RAG-target sft) are not overlapping, that is, the two methods are good at different topics, there is a certain trade-off when using standard fine-tuning sample reasoning (RAG-target sft). Combining zero-shot reasoning and standard fine-tuning sample reasoning (RAG-targetsft), that is, composite reasoning (RAG-target sft +RAG Inference Trigger), can achieve an accuracy of 58.70% on MATH and 89.15% on gsm8k.

[0140] In addition, optimizing at least one of the reasoning steps or mis-reasoning results of the questions and answers in the original question-and-answer database can also improve the accuracy of the generated answers. For this, a test was conducted on the MATH dataset. The test results are as follows: Fig.11As shown in the figure, RAG means retrieving reference questions and answers of mathematical problems in the original question and answer library, and concatenating the mathematical problems with the reference questions and answers into the initial answer generation model, and generating answers through the initial answer generation model; RAG+RP means retrieving reference questions and answers of mathematical problems in the optimized question and answer library, and concatenating the mathematical problems with the reference questions and answers into the initial answer generation model, and generating answers through the initial answer generation model; SftRAG means retrieving reference questions and answers of mathematical problems in the original question and answer library, and concatenating the mathematical problems with the reference questions and answers into the target answer generation model, and generating answers through the target answer generation model; SftRAG+RP means retrieving reference questions and answers of mathematical problems in the optimized question and answer library, and concatenating the mathematical problems with the reference questions and answers into the target answer generation model, and generating answers through the target answer generation model. As can be seen from the figure, the reference questions and answers of the question and answer library obtained by optimizing the answers in the original question and answer library are used to retrieve the reference questions and answers, which helps the model better understand the problems, thereby improving the accuracy of the generated answers.

[0141] In addition, the base model of the initial answer generation model is changed to deepseek-math-7b-instruct, and the following is obtained: Fig.12 The evaluation results shown are based on the accuracy of the model output answers. The brackets next to all the results indicate the number of sample reference questions and answers. Figure 7 and Fig.12 It can be seen that when the base model is deepseek-math-7b-instruct, a similar evaluation conclusion can be obtained as when the base model is llama3.1-8b-instruct. This shows that the answer generation method proposed in this application has good robustness.

[0142] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0143] Based on the same inventive concept, the embodiment of the present application also provides an answer generation device for implementing the answer generation method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more answer generation device embodiments provided below can refer to the limitations of the answer generation method above, and will not be repeated here.

[0144] In one embodiment, Fig.13 As shown, an answer generation device is provided, including: an academic reasoning question acquisition module 1302, a reference question and answer selection module 1304, a question and answer splicing module 1306 and an answer generation module 1308, wherein:

[0145] The academic reasoning question acquisition module 1302 is used to obtain the academic reasoning question to be processed in response to the question query request;

[0146] The reference question and answer selection module 1304 is used to select reference questions and answers matching the academic reasoning questions from the question and answer library in the field to which the academic reasoning questions belong; the question and answer library is obtained by optimizing at least one of the reasoning steps or erroneous reasoning results of the questions and answers in the original question and answer library;

[0147] A question-answer splicing module 1306 is used to splice the academic reasoning question and the reference question and answer to obtain a spliced ​​question and answer;

[0148] The answer generation module 1308 is used to generate target answers to academic reasoning questions based on the spliced ​​questions and answers.

[0149] In the above embodiment, after obtaining the academic reasoning question to be processed in response to the question query request, a reference question and answer matching the academic reasoning question is selected from the question and answer library in the field to which the academic reasoning question belongs, and the academic reasoning question and the reference question and answer are spliced ​​to obtain a spliced ​​question and answer. The reference question and answer in the spliced ​​question and answer provides additional background knowledge and reasoning steps for the academic reasoning question, so that when the target answer to the academic reasoning question is generated based on the spliced ​​question and answer, the target answer can be made more accurate and meet the academic requirements of the field to which the academic reasoning question belongs, thereby improving the quality of the generated answer; in addition, the question and answer library is obtained by optimizing at least one of the reasoning steps or erroneous reasoning results of the question and answer in the original question and answer library. By optimizing the reasoning steps or correcting the erroneous reasoning results, a higher quality reference question and answer can be selected from the question and answer library in the future, and then when the target answer to the academic reasoning question is generated based on the reference question and answer, the quality of the generated answer can be further improved.

[0150] In one embodiment, the reference question and answer selection module 1304 is also used to: obtain each question and answer in the question and answer library of the field to which the academic reasoning question belongs; determine the question similarity between the academic reasoning question and each question and answer respectively; and select reference questions and answers for the academic reasoning question based on the question similarity among the questions and answers.

[0151] In one embodiment, the reference question and answer selection module 1304 is also used to: determine, among the questions and answers, candidate reference questions and answers whose question similarity meets the candidate conditions; display the candidate reference questions and answers; and in response to a selection operation on the candidate reference questions and answers, determine the candidate reference questions and answers specified by the selection operation as reference questions and answers for academic reasoning questions.

[0152] In one embodiment, the target answer is generated by a target answer generation model, such as Fig.14 As shown, the device also includes a model training module 1310, which is used to: obtain training samples, the training samples include sample questions and sample answers; select sample reference questions and answers that match the sample questions in the question and answer library; splice the sample questions and the sample reference questions and answers to obtain sample spliced ​​questions and answers; fine-tune the initial answer generation model based on the sample spliced ​​questions and answers and the sample answers to obtain the target answer generation model.

[0153] In one embodiment, the model training module 1310 is also used to: process the sample spliced ​​question and answer through the initial answer generation model to obtain a predicted answer; determine the training loss value based on the predicted answer and the sample answer; optimize the parameters of the initial answer generation model based on the training loss value to obtain a target answer generation model.

[0154] In one embodiment, Fig.14 As shown, the device also includes an answer quality assessment module 1312, which is used to: generate an initial answer based on the academic reasoning question; determine the answer quality score of the initial answer; when the answer quality score does not meet the scoring conditions, execute the step of selecting a reference question and answer that matches the academic reasoning question in the question and answer library in the field to which the academic reasoning question belongs.

[0155] In one embodiment, the answer quality assessment module 1312 is also used to: input the academic reasoning question and the initial answer into a pre-trained answer assessment model; perform feature processing on the academic reasoning question and the initial answer through the feature processing layer of the answer assessment model to obtain fused features; perform quality score prediction on the fused features through the regression layer of the answer assessment model to obtain an answer quality score for the initial answer.

[0156] In one embodiment, Fig.14As shown, the device also includes an answer display module 1314, which is used to: when the answer quality score meets the scoring conditions, display the initial answer on the interactive page; when a replacement instruction for the initial answer is received, return to execute the steps of selecting a reference question and answer matching the academic reasoning question from the question and answer library in the field to which the academic reasoning question belongs, until the target answer to the academic reasoning question is obtained; and update the initial answer displayed on the interactive page to the target answer.

[0157] In one embodiment, Fig.14 As shown, the device also includes an answer optimization module 1316, which is used to: obtain the questions and answers to be optimized and the optimization indication information in the original question and answer library; input the questions and answers to be optimized and the optimization indication information into a pre-trained answer optimization model, so that the answer optimization model performs reasoning optimization processing on the answers to the questions and answers to be optimized according to the optimization indication information to obtain the optimized questions and answers; the reasoning optimization processing includes optimizing at least one of the reasoning steps or erroneous reasoning results of the questions and answers to be optimized.

[0158] In one embodiment, the answer optimization module 1316 is further used to: perform at least two reasoning optimization processes on the answer to the question and answer to be optimized based on the optimization indication information to obtain at least two candidate answers; and select the candidate answer that meets the optimization conditions from the at least two candidate answers as the optimized question and answer.

[0159] In one embodiment, the answer generation module 1308 is further used to: vectorize the concatenated question and answer to obtain a concatenated question and answer vector; encode the concatenated question and answer vector to obtain an encoded vector; and generate a target answer to the academic reasoning question based on the encoded vector.

[0160] Each module in the above-mentioned answer generation device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module above.

[0161] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.15As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store a question and answer library. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, an answer generation method is implemented.

[0162] Those skilled in the art will understand that Fig.15 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0163] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0164] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0165] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0166] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0167] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0168] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0169] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method for generating an answer, characterized in that: The method comprises: Responding to a question query request, obtaining pending academic reasoning questions; Selecting reference questions and answers matching the academic reasoning question from a question and answer database in the field to which the academic reasoning question belongs; the question and answer database is obtained by optimizing at least one of the reasoning steps or erroneous reasoning results of the questions and answers in the original question and answer database; Splicing the academic reasoning question and the reference question and answer to obtain a spliced ​​question and answer; A target answer to the academic reasoning question is generated based on the concatenated question and answer.

2. The method according to claim 1, characterized in that The reference questions and answers matching the academic reasoning question are selected from the question and answer database in the field to which the academic reasoning question belongs, including: Obtain each question and answer in a question and answer library in the field to which the academic reasoning question belongs; respectively determining the question similarity between the academic reasoning question and each of the questions and answers; In the question and answer, reference questions and answers of the academic reasoning questions are selected based on the question similarity.

3. The method according to claim 2, characterized in that In the question and answer, selecting the reference question and answer of the academic reasoning question based on the question similarity includes: Among the questions and answers, determining candidate reference questions and answers whose question similarity satisfies a candidate condition; Displaying the candidate reference questions and answers; In response to a selection operation on the candidate reference question and answer, the candidate reference question and answer specified by the selection operation is determined as the reference question and answer of the academic reasoning question.

4. The method according to claim 1, characterized in that The target answer is generated by a target answer generation model, and the method further includes: Obtaining a training sample, wherein the training sample includes a sample question and a sample answer; Selecting a sample reference question and answer that matches the sample question from the question and answer database; Splicing the sample question and the sample reference question and answer to obtain a sample spliced ​​question and answer; The initial answer generation model is fine-tuned and trained based on the sample concatenated questions and answers and the sample answers to obtain the target answer generation model.

5. The method according to claim 4, characterized in that The fine-tuning training of the initial answer generation model based on the sample concatenated question and answer and the sample answer to obtain the target answer generation model includes: The sample spliced ​​question and answer are processed by an initial answer generation model to obtain a predicted answer; Determine a training loss value based on the predicted answer and the sample answer; The parameters of the initial answer generation model are optimized based on the training loss value to obtain the target answer generation model.

6. The method according to claim 1, characterized in that The method further comprises: generating an initial answer based on the academic reasoning question; determining an answer quality score for the initial answer; When the answer quality score does not meet the scoring conditions, the step of selecting a reference question and answer matching the academic reasoning question from the question and answer library in the field to which the academic reasoning question belongs is executed.

7. The method according to claim 6, characterized in that The step of determining the answer quality score of the initial answer comprises: Inputting the academic reasoning question and the initial answer into a pre-trained answer evaluation model; Performing feature processing on the academic reasoning question and the initial answer through the feature processing layer of the answer evaluation model to obtain a fusion feature; The quality score of the fused feature is predicted through the regression layer of the answer evaluation model to obtain the answer quality score of the initial answer.

8. The method according to claim 6, characterized in that The method further comprises: When the answer quality score meets the score condition, displaying the initial answer on the interactive page; When receiving a replacement instruction for the initial answer, returning to the step of selecting a reference question and answer matching the academic reasoning question from the question and answer library in the field to which the academic reasoning question belongs, until a target answer to the academic reasoning question is obtained; The initial answer displayed on the interactive page is updated to the target answer.

9. The method according to any one of claims 1 to 8, characterized in that The method further comprises: Obtaining the questions and answers to be optimized and optimization indication information in the original question and answer database; The question and answer to be optimized and the optimization indication information are input into a pre-trained answer optimization model, so that the answer optimization model performs reasoning optimization processing on the answer to the question and answer to be optimized according to the optimization indication information to obtain the optimized question and answer; the reasoning optimization processing includes optimizing at least one of the reasoning steps or erroneous reasoning results of the question and answer to be optimized.

10. The method according to claim 9, characterized in that The performing reasoning and optimization processing on the answer to the question to be optimized according to the optimization instruction information to obtain the optimized question and answer includes: Based on the optimization indication information, the answer to the question to be optimized is subjected to at least two reasoning optimization processes to obtain at least two candidate answers; Among the at least two candidate answers, a candidate answer that meets the optimization condition is selected as the optimized question and answer.

11. The method according to any one of claims 1 to 8, characterized in that Generating a target answer to the academic reasoning question based on the spliced ​​question and answer includes: Vectorizing the concatenated question and answer to obtain a concatenated question and answer vector; Encoding the concatenated question-answer vector to obtain an encoded vector; A target answer to the academic reasoning question is generated based on the encoded vector.

12. An answer generation device, characterized in that: The device comprises: An academic reasoning question acquisition module, used to respond to a question query request and acquire an academic reasoning question to be processed; A reference question and answer selection module is used to select reference questions and answers matching the academic reasoning question from a question and answer library in the field to which the academic reasoning question belongs; the question and answer library is obtained by optimizing at least one of the reasoning steps or erroneous reasoning results of the questions and answers in the original question and answer library; A question-answer splicing module, used for splicing the academic reasoning question with the reference question and answer to obtain a spliced ​​question and answer; An answer generation module is used to generate a target answer to the academic reasoning question based on the spliced ​​question and answer.

13. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 11 are implemented.

14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.

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

Citation Information

Cited By

  • Data processing method, device and system, computing equipment and storage medium

    CN120317380A