A problem processing method, device, equipment and medium based on large language model
By introducing a reviewer into the large language model to judge the degree of match between candidate answers and questions, and flexibly determining how the final answer is generated, the problem of irrelevant answers from the large language model in open-domain question answering is solved, and more accurate and faster answer generation is achieved.
Patent Information
- Application Number
- CN202410991927.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2044-07-23
AI Technical Summary
Large language models are sensitive to irrelevant or meaningless content in open-domain question answering tasks, and generator-based architectures have low QA capabilities when faced with new knowledge.
The reviewer judges the degree of match between the candidate answers generated by the large language model and the target question, and determines the method for generating the final answer based on the matching results. The generator is used to generate candidate answers, or the final answer is generated by combining the retriever and the generator.
It improves the accuracy and speed of open-domain question answering, reduces hallucinations, and enhances user experience.
Smart Images

Figure CN119047570B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of large language models, and in particular to a problem processing method, apparatus, device and medium based on a large language model. Background Art
[0002] Large language models (LLMs) such as ChatGPT and LLaMA have achieved breakthroughs in natural language processing due to their advanced knowledge storage capabilities. However, LLMs in open-domain question answering (ODQA) tasks have shown sensitivity to "hallucinations", that is, the LLM's answers include irrelevant or meaningless content.
[0003] Among the existing large language model architectures, one is based on the Retriever-Generator (ReGe) architecture, which provides rich context for the generator by adding retrieval information. However, the addition of retrieval information will increase the inference delay to a certain extent.
[0004] The other is a generator (Ge)-based architecture, which does not require any task-specific fine-tuning or external knowledge access. However, LLM has low QA capability when faced with some tasks with newer knowledge. Summary of the Invention
[0005] The present invention provides a large language model-based question processing method, apparatus, device, and medium, which can accurately and quickly answer questions in an open domain question-answering scenario.
[0006] According to one aspect of the present invention, a method for processing a question based on a large language model is provided, the method comprising:
[0007] Get the candidate answers for the target question generated by the generator in the large language model;
[0008] Determining, based on a reviewer, how well the candidate answer matches the target question;
[0009] According to the matching results determined by the reviewer, a method for generating a final answer to the target question is determined, and the final answer is determined based on the generation method.
[0010] According to another aspect of the present invention, a question processing apparatus based on a large language model is provided, comprising:
[0011] The candidate answer acquisition module is used to obtain candidate answers for the target question generated by the generator in the large language model;
[0012] A matching degree determination module, configured to determine a matching degree between the candidate answer and the target question based on a reviewer;
[0013] The final answer determination module is used to determine a method for generating a final answer to the target question according to the matching result determined by the reviewer, and determine the final answer based on the generation method.
[0014] According to another aspect of the present invention, an electronic device is provided, comprising:
[0015] at least one processor; and
[0016] a memory communicatively connected to the at least one processor; wherein,
[0017] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the problem processing method based on the large language model described in any embodiment of the present invention.
[0018] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the problem processing method based on a large language model described in any embodiment of the present invention when executed.
[0019] The technical solution of an embodiment of the present application includes: obtaining candidate answers for a target question generated by a generator in a large language model; determining the degree of match between the candidate answers and the target question based on a reviewer; and determining a method for generating a final answer to the target question based on the matching result determined by the reviewer, and determining the final answer based on the generation method. This technical solution uses a reviewer to determine the degree of match between the candidate answers output by the generator of the large language model, and then determines the generation method of the final answer based on the matching result. That is, the generation method of the final answer can be different, making the determination of the final answer more flexible.
[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0022] Figure 1This is a flowchart of a problem processing method based on a large language model provided according to the first embodiment of the present application;
[0023] Figure 2 This is a flowchart of a problem processing method based on a large language model provided in Example 2 of the present application;
[0024] Figure 3 This is an architecture diagram provided according to the second embodiment of the present application;
[0025] Figure 4 This is a schematic diagram of a reviewer provided according to the second embodiment of the present application;
[0026] Figure 5 This is an architecture diagram for false news detection according to the second embodiment of the present application;
[0027] Figure 6 This is a structural diagram of a problem processing device based on a large language model provided in accordance with the third embodiment of the present application;
[0028] Figure 7 It is a structural diagram of an electronic device that implements a problem processing method based on a large language model according to an embodiment of the present application. DETAILED DESCRIPTION
[0029] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0030] It should be noted that the terms "first", "second", "target", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0031] Example 1
[0032] Figure 1A flowchart of a method for processing questions based on a large language model is provided for the first embodiment of the present application. The embodiment of the present application is applicable to the case of answering questions in an open domain. The method can be executed by a question processing device based on a large language model. The question processing device based on a large language model can be implemented in the form of hardware and / or software. The question processing device based on a large language model can be configured in an electronic device with data processing capabilities. Figure 1 As shown, the method includes:
[0033] S110, obtaining candidate answers for the target question generated by the generator in the large language model.
[0034] The generator in the large language model is used to generate responses corresponding to the target question, i.e., candidate answers. The specific type of the generator is not limited in this embodiment of the application. The target question can be the content input by the user into the large language model, and the generator of the large language model will generate candidate answers based on the target question.
[0035] Specifically, in an open-domain question-answering scenario, the user's target questions cover a wide range. Some questions can get relatively accurate answers through the generator of a large language model, while the answers to some questions obtained only through the generator of a large language model may have "hallucinations". After obtaining the target question, the embodiment of the present application first processes the target question through the generator of a large language model to obtain candidate answers, and in subsequent steps determines whether the candidate answer can be used as the final answer to the target question.
[0036] S120: Determine the degree of matching between the candidate answer and the target question based on the reviewer.
[0037] Among them, the reviewer is used to judge the degree of match between the target question and the candidate answers. The degree of match can be expressed by a numerical value (for example, a value between 0-1, 0 corresponds to no match and 1 corresponds to a complete match). The reviewer can be a pre-trained model for judging the degree of match between the target question and the candidate answers.
[0038] For example, the degree of match between a candidate answer and the target question reflects whether the response to the target question is appropriate. If a numerical value is used to reflect the degree of match, a value of 1 can be set to represent a complete match, and a value of 0 can represent a mismatch. For example, if the target question is: What does 1+1 equal?, and the candidate answer is: 2, then in this case, the candidate answer completely matches the target question, and the specific degree of match can be 1; if the target question is: What does 1+1 equal?, and the candidate answer is: 3, then in this case, the candidate answer completely mismatches the target question, and the specific degree of match can be 0; if the target question is: Give a one-day trip plan, and the candidate answer is: Travel plans for today and tomorrow, then in this case, the candidate answer only partially matches the target question, and the specific degree of match can be 0.3. It should be noted that the degree of match reflects the appropriateness of the candidate answer, and can also be expressed in terms such as question-answering quality and correctness probability.
[0039] Specifically, after obtaining the candidate answers, the target question and the candidate answers are input into the reviewer, and the matching degree between the candidate answers and the target question output by the reviewer is obtained.
[0040] S130, determining a method for generating a final answer to the target question according to the matching result determined by the reviewer, and determining the final answer based on the generation method.
[0041] Among them, the final answer is the final response corresponding to the target question. In a specific scenario, if the user enters the target question in the input box, the content that needs to be fed back to the user end is the final answer.
[0042] Specifically, after the reviewer determines the degree of match between the candidate answer and the target question, it then determines whether the candidate answer meets the requirements for being the final answer based on the degree of match. If so, the final answer is determined using the first generation method; otherwise, the final answer is determined using the second generation method. The first generation method directly determines the candidate answer as the final answer. The second generation method regenerates the final answer based on the target question. When regenerating the final answer based on the target question, a more accurate answer can be obtained through the retriever and generator of the large language model.
[0043] The technical solution of an embodiment of the present application includes: obtaining candidate answers for a target question generated by a generator in a large language model; determining the degree of match between the candidate answers and the target question based on a reviewer; and determining a method for generating a final answer to the target question based on the matching result determined by the reviewer, and determining the final answer based on the generation method. This technical solution uses a reviewer to determine the degree of match between the candidate answers output by the generator of the large language model, and then determines the generation method of the final answer based on the matching result. That is, the generation method of the final answer can be different, making the determination of the final answer more flexible.
[0044] Example 2
[0045] Figure 2 This is a flowchart of a problem-solving method based on a large language model provided in Example 2 of the present application. This embodiment of the present application is optimized based on the above embodiment.
[0046] like Figure 2 As shown, the method of the embodiment of the present application specifically includes the following steps:
[0047] S210, obtaining candidate answers for the target question generated by the generator in the large language model.
[0048] S220: Determine the degree of matching between the candidate answer and the target question based on the reviewer.
[0049] In an embodiment of the present application, optionally, determining the degree of match between the candidate answer and the target question based on the reviewer includes: inputting the candidate answer and the target question into a bidirectional encoder to obtain a hidden state of the classification label of the last layer of the bidirectional encoder; inputting the hidden state into a classifier to obtain an output value of the classifier, and determining the degree of match between the candidate answer and the target question based on the output value.
[0050] The bidirectional encoder can be a Transformer-based bidirectional encoder, exemplarily a BERT (Bidirectional Encoder Representations from Transformers) encoder. Exemplarily, the hidden state of the classification tag in the last layer of the bidirectional encoder is the hidden state of the special tag (CLS) in the last layer of the BERT encoder. The classifier can be a fully connected layer.
[0051] Specifically, the candidate answer and the target question are input into the BERT encoder in the reviewer to obtain the hidden state of the classification token (the classification token is CLS (Classification Token)) of the last layer of the BERT encoder, and the hidden state is input into the fully connected layer to obtain the output value of the fully connected layer, and the degree of matching between the candidate answer and the target question is determined based on the output value.
[0052] In an embodiment of the present application, optionally, the hidden state is input into a classifier to obtain the output value of the classifier, and the degree of matching between the candidate answer and the target question is determined based on the output value, including: inputting the hidden state into a fully connected layer to obtain the output value of the fully connected layer; normalizing the output value based on the objective function to obtain the degree of matching between the candidate answer and the target question.
[0053] The objective function is used to normalize the output value of the fully connected layer. Exemplarily, the objective function can be a SoftMax function.
[0054] For example, a pre-trained BERT encoder is used to learn information about the target question and candidate answers. A feedforward neural network performs a nonlinear transformation, inputting the hidden state of the classification labels in the last layer of the BERT encoder into the fully connected classification layer of the FCL. The output value is then normalized using the SoftMax function to convert it into the final degree of match. It should be noted that the degree of match can be referred to as a probability, meaning that the above steps for determining the degree of match involve normalizing the output value using the SoftMax function to convert it into the final probability.
[0055] In an embodiment of the present application, the BERT encoder has a small number of parameters and can process candidate answers and target questions quickly and accurately, so that the reviewer can quickly obtain the degree of matching between the candidate answer and the target question, shortening the time interval from obtaining the target question to outputting the final answer, thereby improving the user experience.
[0056] In an embodiment of the present application, optionally, the training process of the reviewer includes: obtaining a set of question-answer sample pairs; for each question-answer sample pair, determining the degree of matching between its answer and the question as a label; training the reviewer to be trained based on the question-answer sample pairs and the labels of each question-answer sample pair to obtain a trained reviewer.
[0057] Specifically, when training the reviewer, a first preset number of question-answer sample pairs can be obtained. For each question-answer sample pair, the degree of matching between the answer and the question is marked, and the matching degree is determined as the label of the question-answer sample pair. The reviewer to be trained is then trained based on the question-answer sample pairs and the corresponding labels.
[0058] In an embodiment of the present application, optionally, for each question-and-answer sample pair, the degree of matching between its answer and the question is determined as a label, including: determining whether the question in the question-and-answer sample pair is an open question; if so, determining the degree of matching between the answer and the question in the question-and-answer sample pair as a label; otherwise, determining the basic content corresponding to the question in the question-and-answer sample pair; the basic content reflects the correct answer corresponding to the question; and determining the label of the question-and-answer sample pair based on the basic content.
[0059] In the embodiment of the present application, since the questions and answers in some question-answer sample pairs are respectively the questions input into the large language model and the answers output by the large language model; such question-answer sample pairs have various forms. For example, if the question is where is the capital of China, the correct answer is Beijing, but the answer given by the large language model may be very long, for example: The capital of China is Beijing; in this case, although the answer is not the direct correct answer, it includes the correct answer, and the label of the question-answer sample pair is still determined to be 1.
[0060] Specifically, if the question in the question-and-answer sample pair is an open-ended question, the degree of matching between the answer and the question in the question-and-answer sample pair is directly determined as the label; if the question is not an open-ended question, the basic content corresponding to the question in the question-and-answer sample pair is determined, and the basic content is a brief correct answer to the question (for example, the question is: Where is the capital of China, and the basic content is: Beijing). Then, it is determined whether the answer to the question-and-answer sample pair includes the basic content, and the label of the question-and-answer sample pair is determined based on the judgment result.
[0061] In an embodiment of the present application, optionally, the label of the question and answer sample pair is determined based on the basic content, including: if the answer to the question and answer sample pair includes basic content, then the label of the question and answer sample pair is determined to be 1; otherwise, the label of the question and answer sample pair is determined to be 0.
[0062] Specifically, if the answer to the question-answer sample pair includes basic content, it means that the answer matches the question, and the label of the question-answer sample pair is determined to be 1; otherwise, it means that the answer is abnormal, and the label of the question-answer sample pair is determined to be 0.
[0063] This solution sets the label of a question-answer pair to 1 if the answer contains basic content; otherwise, the label is set to 0. This setting enables the reviewer to make more accurate judgments on questions and answers from large language models.
[0064] S230, determine whether the matching degree is greater than a preset threshold; if so, execute S240; otherwise, execute S250.
[0065] Among them, the numerical value of the matching degree is between 0 and 1, and the preset threshold can be set to any value between 0 and 1. The embodiment of the present application does not limit the specific numerical value of the preset threshold.
[0066] Specifically, after obtaining the matching degree, it is determined whether the matching degree is greater than a preset threshold. If so, it indicates that the candidate answer is relatively reliable and S240 can be executed; otherwise, it indicates that the candidate answer does not match the target question to a certain extent and S250 can be executed.
[0067] S240: Determine the candidate answer as the final answer.
[0068] S250, determining the retrieval content through the retriever of the large language model, and generating a final answer based on the target question and the retrieval content by the generator based on the large language model.
[0069] In an embodiment of the present application, optionally, the retrieval content is determined by the retriever of the large language model, including: determining the similarity between each corpus item and the target question in the corpus through the retriever of the large language model; after sorting the similarities, determining the first preset number of corpus items as the retrieval content, and then generating the final answer based on the target question and the retrieval content by the generator based on the large language model.
[0070] The technical solution of the embodiment of the present application determines the degree of match between the candidate answer and the target question through a pre-trained reviewer, and then uses the candidate answer as the final answer when the degree of match is greater than a preset threshold. At this time, since the candidate answer is generated by the generator of the large language model, its generation speed is relatively fast, and it has the characteristics of being fast and accurate. If the degree of match is less than the preset threshold, the final answer is obtained through the retriever and the generator. At this time, the final answer obtained is more matched with the target question, which largely avoids the "hallucination" problem of the existing large language model.
[0071] In a specific example, refer to Figure 3 The architecture diagram shown in the figure, we get the problem q i After that, it is connected with the prompt word p and fed into the LLM to generate the answer, where i∈[i,N], N is the number of questions. Specifically, q i Combined with p, it is [p,q i ] can be designed as “please answer the following question with a phrase no morethan 20words: [Question]q i [Answer]:". We try to limit the length of the generated text by the prompt word to obtain a shorter and more concise answer. The predicted candidate answer a is:
[0072] a=f llm ([p,q i ]);
[0073] where f llm Represents the mapping function of the adopted LLM. In this method, a candidate answer is output regardless of whether it is correct or incorrect. During this process, the candidate answer is intercepted. If the candidate answer is incorrect, the relevant context is retrieved to correct it.
[0074] It should be noted that the generator using the LLM (Large Language Model) generates candidate answers without accessing external knowledge when generating candidate answers.
[0075] After getting the candidate answer, the reviewer f reviewer Determine whether the candidate answer is correct. Figure 4 As shown. The reviewer includes: BERT (pre-trained language model based on Transformer architecture), FCL (fully connected layer) and SoftMax (normalization function). Specifically, it can be a pre-trained BERT encoder f bert To learn the information of q and a, a nonlinear transformation is performed through a feedforward neural network. The output of the FCL fully connected classification layer is normalized and converted into the final probability through the SoftMax function:
[0076] h qa =f bert ([q i :a i ]);
[0077] p a =SoftMax(f FCL (h qa ));
[0078] where [q i :a i ] is the sequential concatenation of the answers to q and a. Specifically, we use the hidden state of the special token [CLS] in the last layer of the BERT encoder as the final QA information h qa , then pass [CLS] through the fully connected layer FCL to obtain the logits of the specific category, and then normalize it through SoftMax to obtain the final probability p a . Then, we will generate the final probability p a Compare with the threshold t to get the final predicted answer a′, as shown below:
[0079]
[0080] in ] is q and the prompt word p and the top-k information extracted by the retriever series connection.
[0081] Here our prompt word p is: Please use a short answer to answer my question. For example, if I ask you "Where is the capital of China?", I hope you will answer "Beijing" instead of "The capital of China is Beijing."
[0082] Context: {c j};
[0083] Question: {q j}.
[0084] The reviewer is trained to more accurately determine whether the answer generated by the LLM is the correct answer. The Natural Question (NQ) dataset, a commonly used dataset in open-domain question answering, is used as the reviewer training data. It should be noted that the answers provided by NQ are short and precise, while the answers generated by LLM are often long and contain other words. For example, a sentence contains the answer. Based on this phenomenon, we first use LLM to generate answers to the questions in the NQ training set and use the exact matching method to label the generated answers. If the generated answer contains the correct answer, we label it as "True" (that is, set the label to 1), otherwise it is labeled "False" (set the label to 0). We then use these labeled answers to train the reviewer. The training goal is that the correct answer will be assigned a higher probability score close to 1, while the wrong answer will be assigned a lower score close to 0. Therefore, we use the mean squared error (MSE) to optimize the reviewer.
[0085] The retriever is used when the matching degree is lower than the preset threshold. For the retriever, a dual encoder DPR can be selected, which is represented by E q and E d , to learn the problem (q i ,i∈[1,N]) and document d j ,j∈[1,M] is represented in the corpus C (N is the number of questions in the dataset and M is the size of the corpus). We can then obtain the question q by i and document d j The similarity score s(q i ,d j ):
[0086] s(q i ,d j )=E q (q i )·E d (d j );
[0087] Then use the generator to generate answers,
[0088] Regarding the generator, taking LlaMA as an example, compared with the traditional Transformer architecture, the RMSNorm normalization function is newly added to LlaMA, as shown in the following formula: s(q i ,d j )=E q (q i )·E d (d j );
[0089] In addition, the fully connected layer in LlaMA also uses the new SwiGLU activation function, see the following formula
[0090] In position encoding, the rotation position embedding RoPE method is used to replace the original absolute position encoding, as shown in the following formula:
[0091] FFN swiGLU (x,W,V,W2)=SwiGLU(x,W,V)W2;
[0092] q m =f(q,m),k n =f(k,n);
[0093] In addition, when training LlaMA, 10 12 The training is done on word-units at the level of 100 words. The data used includes CommonCrawl, C4, GitHub, Wikipedia, Books, ArXiv, and StackExchange. AdamW is used as the optimizer during training, with corresponding hyperparameters β1=0.9 and β2=0.95. The cosine learning rateschedule is used, and the final learning rate is 10% of the maximum learning rate. A weight decay of 0.1 and a gradient clipping size of 1.0 are used. A warmup of 2000 steps is used. For questions where the initial answer a does not bypass the reviewer, we need to correct a based on the top-k retrieval information. Therefore, the input text of LLM is a concatenation of the question, prompt, and retrieval, that is, "please answer the following question with a phrase no more than 20words: [Question]q i [Context] Here, multiple Contexts are concatenated sequentially. Similarly, the final answer can be obtained, namely:
[0094]
[0095] For example, three commonly used benchmark datasets for open-domain question answering are used to evaluate the effectiveness of this technique. The data are shown in Table 1.
[0096] Table 1 Detailed information of open domain question answering data
[0097]
[0098] For the retriever, we used DPR and BM25. For the large language model, we used LLaMA-7B, LLaMA-13B, and GPT-3.5-turbo. Other methods compared included Ge and ReGe methods. Ge methods included GPT-NeoX-20B, GPT-3-175B, and InstructGPT-175B. ReGe methods included GenRead, Retriever-then-Read, and REFEED.
[0099] Experimental results: This application is compared with some typical LLM baselines, and the results are shown in Table 2. Obviously, this application outperforms all baseline methods that do not rely on contextual retrieval, especially for GPT-based methods. Although GenRead, Retriever-then-Read, and REFEED are all enhanced entirely by document retrieval, our method is still comparable to them. Moreover, these are based on multiple retrieved documents, while our method only receives one retrieved document. In addition, we also compare three LLM baseline pipelines Ge, ReGe, and GRR. The results are shown in Table 3. In general, we can see that all GRR-based models won the best MS and F1 scores on each dataset (GRR has positive gains in both MS and F1). Compared to GRR, the GRR-based LLaMA model significantly improved MS (+1.33% to +14.32%) and F1 (+0.32% to +3.61%). The GRR-based gpt-3.5-turbo model improved MS by +3.16% on NQ and performed similarly to the Ge baseline model on TQA and WQ. We attribute the negligible gain of the gpt-3.5-turbo model to its higher coverage (less than 50% for the LLaMA baseline model and over 90% for the gpt-3.5-turbo model). This suggests that our answer reviewers were able to control the quality of the output answers to some extent by intercepting some incorrect answers and correcting them through document retrieval. Compared to GRR, we observed little performance improvement on NQ for the GRR model based on the LLaMA baseline, with an F1 improvement of +1% to +2%. We attribute this to the relatively low coverage (less than 30%), which means that most questions in NQ still require document retrieval. Encouragingly, all GRR models achieve significant performance improvements on the other two datasets (MS +1.47% to +8.09%, F1 +5.28% to +11.69%). We also note that the inference time of each GRR baseline model is significantly reduced compared to the ReGe baseline model, especially on TQA and WQ. This demonstrates that our proposed method can significantly improve the overall question answering efficiency of large models without compromising or even improving question answering performance.
[0100] Table 2 Comparison results of the proposed method and some baseline methods on F1.
[0101]
[0102] “Re” indicates full integration with the retriever. Bold values indicate the best values in each group and column. All results are tested in the zero-shot setting.
[0103] Table 3 Comparison of the proposed method GRR with the classic ODQA methods Ge and ReGe on the LLaMA benchmark model and gpt-3.5-turbo.
[0104]
[0105]
[0106] The arrows (i.e., +14.32 ← 40.64 → +0.14) represent Ge ← GRR → ReGe. The values in the middle are the GRR metrics, and the values on the left and right represent the GRR metric gain relative to Ge / ReGe. Because the GPT-3.5-Turbo model does not run on a local device, its inference time is not provided.
[0107] In the embodiment of the present application, optionally, reference Figure 5 , Figure 5 This is an architecture diagram for fake news detection. Fake news detection samples are input into the generator and judged by the reviewer. If the reviewer passes, it is directly output. If it fails, the real news is obtained through the retriever and generator.
[0108] Example 3
[0109] Figure 6 This is a schematic diagram of the structure of a problem processing device based on a large language model provided in the third embodiment of the present application. The device can execute the problem processing method based on a large language model provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. Figure 6 As shown, the device includes:
[0110] A candidate answer acquisition module 310 is used to obtain candidate answers for the target question generated by the generator in the large language model;
[0111] A matching degree determination module 320 is configured to determine a matching degree between the candidate answer and the target question based on a reviewer;
[0112] The final answer determination module 330 is used to determine a method for generating a final answer to the target question according to the matching result determined by the reviewer, and determine the final answer based on the generation method.
[0113] The technical solution of the embodiment of the present application includes: a candidate answer acquisition module 310, which is used to obtain candidate answers for the target question generated by the generator in the large language model; a matching degree determination module 320, which is used to determine the matching degree between the candidate answers and the target question based on the reviewer; and a final answer determination module 330, which is used to determine the generation method of the final answer to the target question based on the matching result determined by the reviewer, and determine the final answer based on the generation method. This technical solution uses the reviewer to determine the matching degree of the candidate answers output by the generator of the large language model, and then determines the generation method of the final answer based on the matching result. That is, the generation method of the final answer can be different, making the determination of the final answer more flexible.
[0114] In the embodiment of the present application, optionally, the final answer determination module 330 includes:
[0115] a matching degree determination unit, configured to determine whether the matching degree is greater than a preset threshold;
[0116] If so, the candidate answer is determined as the final answer;
[0117] Otherwise, the retrieved content is determined by the retriever of the large language model, and the final answer is generated according to the target question and the retrieved content by the generator based on the large language model.
[0118] In the embodiment of the present application, optionally, the matching degree determination module 320 includes:
[0119] a hidden state determination unit, configured to input the candidate answer and the target question into a bidirectional encoder to obtain a hidden state of the classification label of the last layer of the bidirectional encoder;
[0120] A matching degree determination unit is used to input the hidden state into a classifier to obtain an output value of the classifier, and determine the matching degree between the candidate answer and the target question according to the output value.
[0121] In the embodiment of the present application, optionally, the matching degree determination unit includes:
[0122] an output value determination subunit of the fully connected layer, configured to input the hidden state into the fully connected layer to obtain an output value of the fully connected layer;
[0123] The matching degree determination subunit is used to normalize the output value based on the objective function to obtain the matching degree between the candidate answer and the target question.
[0124] In the embodiment of the present application, the apparatus may optionally further include: a reviewer training module, specifically including:
[0125] A question-answer sample pair acquisition unit, used to acquire a set of question-answer sample pairs;
[0126] A label determination unit is used to determine the degree of match between the answer and the question as a label for each question-answer sample pair;
[0127] The reviewer training unit is used to train the reviewer to be trained based on the question-answer sample pairs and the labels of each question-answer sample pair to obtain a trained reviewer.
[0128] In an embodiment of the present application, optionally, the question and answer in the question-answer sample pair are respectively the question input into the large language model and the answer output by the large language model;
[0129] The label determination unit includes:
[0130] The question judgment subunit is used to judge whether the question in the question-answer sample pair is an open question;
[0131] A first label determination subunit is configured to determine the matching degree between the answer and the question in the question-answer sample pair as a label;
[0132] A basic content determination subunit is used to determine the basic content corresponding to the question in the question-answer sample pair; the basic content reflects the correct answer corresponding to the question;
[0133] The second label determination subunit is used to determine the label of the question-answer sample pair based on the basic content.
[0134] In the embodiment of the present application, optionally, the second label determination subunit is specifically configured to:
[0135] If the answer to the question-answer sample pair contains basic content, the label of the question-answer sample pair is determined to be 1;
[0136] Otherwise, the label of the question-answer pair is determined to be 0.
[0137] A problem processing device based on a large language model provided in an embodiment of the present application can execute a problem processing method based on a large language model provided in any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.
[0138] Example 4
[0139] Figure 7A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.
[0140] like Figure 7 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., which is communicatively connected to the at least one processor 11. The memory stores a computer program that can be executed by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. Various programs and data required for the operation of the electronic device 10 can also be stored in the RAM 13. The processor 11, ROM 12, and RAM 13 are connected to each other via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0141] Multiple components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0142] The processor 11 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors that run machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the problem processing method based on the large language model.
[0143] In some embodiments, the large language model-based question processing method can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the large language model-based question processing method described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to execute the large language model-based question processing method in any other appropriate manner (for example, by means of firmware).
[0144] Various embodiments of the systems and techniques described above can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0145] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0146] In the context of the present invention, computer-readable storage media can be tangible media that can contain or store a computer program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Computer-readable storage media can include but are not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, computer-readable storage media can be machine-readable signal media. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0147] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0148] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0149] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.
[0150] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.
[0151] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. A problem-solving method based on a large language model, characterized in that: include: Get the candidate answers for the target question generated by the generator in the large language model; Determining, based on a reviewer, how well the candidate answer matches the target question; Determining a method for generating a final answer to the target question based on the matching results determined by the reviewer, and determining the final answer based on the generation method; Wherein, determining a method for generating a final answer to the target question according to the matching result determined by the reviewer, and determining the final answer based on the generation method includes: Determining whether the matching degree is greater than a preset threshold; If so, the candidate answer is determined as the final answer; Otherwise, the large language model's retriever determines the similarity between each corpus item and the target question in the corpus; after sorting the similarities, the first preset number of corpus items are determined as search content, and the large language model-based generator generates a final answer based on the target question and the search content; The reviewer includes: BERT, FCL and SoftMax; the BERT is a pre-trained language model based on the Transformer architecture, the FCL is a fully connected layer, and the SoftMax is a normalization function; the BERT encoder f bert The information used to learn q and a is used to get h qa , a nonlinear transformation is performed through a feedforward neural network, and the output of the FCL is normalized by the SoftMax function and converted into a matching degree P a : h qa =f bert ([q i :a i ]); p a =SoftMax(f FCL (h qa )); Among them, [q i :a i ] is the sequential concatenation of q and a, i∈[1,N], N is the number of questions.
2. The method according to claim 1, characterized in that The reviewer determines how well the candidate answer matches the target question, including: Input the candidate answer and the target question into a bidirectional encoder to obtain the hidden state of the classification label of the last layer of the bidirectional encoder; The hidden state is input into a classifier to obtain an output value of the classifier, and the degree of matching between the candidate answer and the target question is determined based on the output value.
3. The method according to claim 2, characterized in that Inputting the hidden state into a classifier to obtain an output value of the classifier, and determining the degree of matching between the candidate answer and the target question based on the output value, including: Inputting the hidden state into a fully connected layer to obtain an output value of the fully connected layer; The output value is normalized based on the objective function to obtain the degree of matching between the candidate answer and the target question.
4. The method according to claim 1, wherein The training process of the reviewer includes: Obtain a set of question-answer sample pairs; For each question-answer pair, the degree of match between the answer and the question is determined as the label; The reviewer to be trained is trained based on the question-answer sample pairs and the labels of each question-answer sample pair to obtain a trained reviewer.
5. The method according to claim 4, characterized in that The question and answer in the question-answer sample pair are the question input into the large language model and the answer output by the large language model respectively; For each question-answer sample pair, the degree of match between the answer and the question is determined as a label, including: Determine whether the questions in the question-answer sample pairs are open questions; If so, the matching degree between the answer and the question in the question-answer pair is determined as the label; otherwise, Determining basic content corresponding to the questions in the question-answer sample pairs; the basic content reflects the correct answers corresponding to the questions; Determine labels for question-answer sample pairs based on the basic content.
6. The method according to claim 5, characterized in that Determining labels for question-answer sample pairs based on the basic content includes: If the answer to the question-answer sample pair contains basic content, the label of the question-answer sample pair is determined to be 1; Otherwise, the label of the question-answer pair is determined to be 0.
7. A problem processing device based on a large language model, characterized in that: include: The candidate answer acquisition module is used to obtain candidate answers for the target question generated by the generator in the large language model; A matching degree determination module, configured to determine a matching degree between the candidate answer and the target question based on a reviewer; A final answer determination module, configured to determine a method for generating a final answer to the target question based on the matching result determined by the reviewer, and determine the final answer based on the generation method; Among them, the final answer determination module includes: a matching degree determination unit, configured to determine whether the matching degree is greater than a preset threshold; If so, the candidate answer is determined as the final answer; Otherwise, the large language model's retriever determines the similarity between each corpus item and the target question in the corpus; after sorting the similarities, the first preset number of corpus items are determined as search content, and the large language model-based generator generates a final answer based on the target question and the search content; The reviewer includes: BERT, FCL and SoftMax; the BERT is a pre-trained language model based on the Transformer architecture, the FCL is a fully connected layer, and the SoftMax is a normalization function; the BERT encoder f bert The information used to learn q and a is used to get h qa , a nonlinear transformation is performed through a feedforward neural network, and the output of the FCL is normalized by the SoftMax function and converted into a matching degree P a : h qa =f bert ([q i :a i ]); p a =SoftMax(f FCL (h qa )); Among them, [q i :a i ] is the sequential concatenation of q and a, i∈[1,N], N is the number of questions.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the large language model-based question processing method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the problem processing method based on a large language model according to any one of claims 1 to 6 when executed.
Citation Information
Patent Citations
Question and answer matching method and device based on K-means clustering algorithm, equipment and medium
CN113918696A
Question and answer method and device, electronic equipment and readable storage medium
CN116662518A