Problem processing method and device based on large language model, equipment and medium
By introducing a reviewer to determine the matching degree between candidate answers and questions in large language models, the questions that are not related to answers in open domain questions and answers are solved, more accurate and fast answers are achieved, and new knowledge processing capabilities are improved.
Patent Information
- Application Number
- CN202410991927.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-07-23
AI Technical Summary
Large language models have sensitivity and reasoning delays to new knowledge in open domain question-and-answer tasks, and existing architectures have low QA capabilities when processing new knowledge, which are prone to irrelevant or meaningless answers.
By introducing a reviewer into a large language model, we can obtain the candidate answers generated by the generator and judge the degree of matching with the target problem, and determine the generation method of the final answer based on the matching result. If the degree of matching is high, the candidate answer will be used directly. If the degree of matching is low, the candidate answer will be used directly. Regenerate answers through searchers and generators.
It improves the accuracy and speed of open domain Q&A answers, reduces the "illusion" phenomenon, and improves the processing ability and user experience of new knowledge.
Smart Images

Figure CN119047570A_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, device, equipment 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, but LLMs in open-domain question answering (ODQA) tasks have shown sensitivity to "hallucinations", that is, LLMs' 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. Due to the addition of the retrieval information, the reasoning delay will be increased 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 question processing method, apparatus, device and medium based on a large language model, which can accurately and quickly answer questions in an open domain question and answer scenario.
[0006] According to one aspect of the present invention, a problem processing method 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, there is provided a problem processing device based on a large language model, comprising:
[0011] A candidate answer acquisition module is used to obtain candidate answers for target questions generated by the generator in the large language model;
[0012] A matching degree determination module, used to determine the matching degree between the candidate answer and the target question based on the reviewer;
[0013] The final answer determination module is used to determine the generation method of the 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, there is provided an electronic device, the electronic device 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 a 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 the 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; determining the generation method of the 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. The technical solution determines the degree of match of the candidate answers output by the generator of the large language model through a reviewer, thereby determining 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 contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily 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 drawings required for use in the description of the embodiments will be briefly introduced below. 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 1is a flowchart of a problem processing method based on a large language model provided according to Embodiment 1 of the present application;
[0023] Figure 2 is a flowchart of a problem processing method based on a large language model provided according to Embodiment 2 of the present application;
[0024] Figure 3 This is an architecture diagram provided according to Embodiment 2 of the present application;
[0025] Figure 4 is a schematic diagram of a reviewer provided according to Embodiment 2 of the present application;
[0026] Figure 5 This is an architecture diagram for false news detection provided according to Embodiment 2 of the present application;
[0027] Figure 6 It is a structural diagram of a problem processing device based on a large language model provided according to the third embodiment of the present application;
[0028] Figure 7 It is a structural diagram of an electronic device for implementing 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 scheme of the present invention, the technical scheme 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 described embodiments are only embodiments of a part of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work 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 specification 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 data 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] Embodiment 1
[0032] Figure 1A flowchart of a method for processing a question based on a large language model is provided for the first embodiment of the present application. The embodiment of the present application can be applied to 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 the response content corresponding to the target question, that is, the candidate answer. The specific type of the generator is not limited in the embodiment of the present 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 the candidate answer according to 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, determining the matching degree between the candidate answer and the target question based on the reviewer.
[0037] Among them, the reviewer is used to determine 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 determining the degree of match between the target question and the candidate answers.
[0038] Exemplarily, the degree of match between the 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, the value 1 can be set to represent a complete match, and the value 0 can represent a mismatch. For example, if the target question is: what is 1+1, 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 is 1+1, and the candidate answer is: 3, then in this case, the candidate answer does not match the target question at all, and the specific degree of match can be 0; if the target question is: give a one-day tour 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 of question and answer quality, correct probability, and the like.
[0039] Specifically, after obtaining the candidate answers, the target question and the candidate answers are input into the reviewer to obtain the matching degree between the candidate answers and the target question output by the reviewer.
[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 generating 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 determines whether the candidate answer meets the requirements of being the final answer based on the degree of match. If so, the final answer is determined according to the first generation method; otherwise, the final answer is determined according to the second generation method. The first generation method is to directly determine the candidate answer as the final answer. The second generation method is to regenerate 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 the 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; determining the generation method of the 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. The technical solution determines the degree of match of the candidate answers output by the generator of the large language model through a reviewer, thereby determining 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] Embodiment 2
[0045] Figure 2 A flowchart of a problem handling method based on a large language model is provided in Example 2 of the present application. The 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, determining 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 a reviewer includes: inputting the candidate answer and the target question into a bidirectional encoder to obtain a hidden state of a 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 may be a bidirectional encoder based on a Transformer, and exemplarily, the bidirectional encoder is a BERT (Bidirectional Encoder Representations from Transformers) encoder. Exemplarily, the hidden state of the classification mark of the last layer of the bidirectional encoder is the hidden state of the special mark (CLS) in the last layer of the BERT encoder. The classifier may 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 tag (the classification tag 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 match 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 an output value of the classifier, and the degree of match 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 an objective function to obtain the degree of match 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 may be a SoftMax function.
[0054] Exemplarily, a pre-trained BERT encoder is used to learn information about the target question and candidate answers. Here, a nonlinear transformation is performed through a feedforward neural network, and the hidden state of the classification mark of the last layer of the BERT encoder is input into the FCL fully connected classification layer, and the output value is normalized by the SoftMax function to convert it into the final matching degree. It should be noted that the matching degree can be called a probability, that is, the above step of determining the matching degree is: normalizing the output value by the SoftMax function to convert it into the final probability.
[0055] In the embodiment of the present application, the BERT encoder has a small number of parameters and can quickly and accurately process candidate answers and target questions, 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, and for each question-answer sample pair, the degree of match between its answer and the question is marked, and the degree of match is determined as the label of the question-answer sample pair, and then the reviewer to be trained is 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 match 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 match between the answer and the question in the question and answer sample pair as the 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 and answer sample pairs are respectively the questions input into the large language model and the answers output by the large language model; such question and answer sample pairs have various characteristics, 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 and 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 match between the answer in the question and answer sample pair and the question 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), and 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 the 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 sample 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 the questions and answers of the large language model.
[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 means that the candidate answer is relatively reliable and S240 can be executed; otherwise, it means 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 a retriever of a large language model, including: determining the similarity between each corpus item and the target question in a 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 a final answer based on the target question and the retrieval content by a generator based on a 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 problem of "hallucination" in the existing large language model.
[0071] In a specific example, see Figure 3 The architecture diagram shown in the figure gives the problem q i After that, it is concatenated 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 get 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, the candidate answer is output regardless of whether it is correct or wrong. In this process, the candidate answer is intercepted, and if the candidate answer is a wrong answer, the relevant context is retrieved to correct it.
[0074] It should be noted that when using the LLM (Large Language Model) generator to generate candidate answers, there is no need to access external knowledge when generating candidate answers.
[0075] After obtaining the candidate answers, the reviewer f reviewer Determine whether the candidate answer is correct. Figure 4 As shown in the figure, 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 as well as the top-k information extracted by the retriever series connection.
[0081] Here our prompt word p is: Please use short answers to answer my questions. For example, if I ask you "What 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 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 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 as "False" (set the label to 0). We then use these labeled answers to train the reviewer, and 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] When the matching degree is lower than the preset threshold, the retriever is used. For the retriever, a dual encoder DPR can be selected, denoted as 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, a new RMS Norm normalization function is 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, as shown below
[0090] In position coding, the rotation position embedding RoPE method is used to replace the original absolute position coding, 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 word units at the level of 100 words are trained, and the data used include CommonCrawl, C4, GitHub, Wikipedia, Books, ArXiv and StackExchange. AdamW is used as the optimizer during training, and the corresponding hyperparameters are β1=0.9, β2=0.95; cosine learning rateschedule is used, and the final learning rate is 10% of the maximum learning rate; weight decay of 0.1 and gradient clipping of size 1.0 are used; warmup of 2000 steps is used; for the problem that 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 questions, prompts and retrievals, 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] Exemplarily, three common benchmark datasets for open domain question answering are used to evaluate the effect of this technology. The data are shown in Table 1.
[0096] Table 1 Detailed information of open domain question answering data
[0097]
[0098] For the retriever, DPR and BM25 are used. For the large language model, LLaMA-7B, LLaMA-13B and gpt-3.5-turbo are used. Other methods compared include Ge and ReGe type methods. For Ge methods, they include GPT-NeoX-20B, GPT-3-175B and InstructGPT-175B. For ReGe methods, they include GenRead, Retriever-then-Read and REFEED.
[0099] Experimental Results: The present application is compared with some typical LLM benchmarks, and the results are shown in Table 2. Obviously, the present 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 fully enhanced 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 benchmark pipelines Ge, ReGe, and GRR. The results are shown in Table 3. In general, we can see that all GRR-based models win the best MS and F1 scores on each dataset (GRR has positive gains in both MS and F1). Compared with GRR, the GRR-based LLaMA model improves MS by a large margin (+1.33% to +14.32%), while improving F1 by +0.32% to +3.61%; the GRR-based gpt-3.5-turbo model improves MS by +3.16% on NQ and performs similarly to the Ge baseline model on TQA and WQ. We believe that the negligible gain on the gpt-3.5-turbo model is due 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 are indeed able to control the quality of the output answers to some extent by intercepting some wrong answers and correcting them through document retrieval. Compared with GRR, we observe that the GRR model of the LLaMA baseline has almost no performance improvement on NQ, with an improvement of +1% to +2% for F1. We attribute this to the relatively low coverage (less than 30%), meaning that most questions in NQ still require document retrieval. Encouragingly, all GRR models achieve significant performance improvements on the other two datasets (+1.47%~+8.09% for MS and +5.28%~+11.69% for F1). At the same time, we notice that the inference time of each GRR baseline model is significantly reduced compared to the ReGe baseline model, especially on TQA and WQ. This shows that our proposed method can significantly improve the overall question answering efficiency of large models without harming 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 content with arrows (i.e. +14.32←40.64→+0.14) represents Ge←GRR→ReGe. The value in the middle is the metric of GRR, and the values on the left / right represent the metric gain of GRR relative to Ge / ReGe. Since the gpt-3.5-turbo model does not run on the local device, its inference time is not provided.
[0107] In the present application embodiment, optionally, refer to Figure 5 , Figure 5 This is an architecture diagram for fake news detection. The fake news detection samples are input into the generator and judged by the reviewer. If they pass the reviewer, they are directly output. If they fail, the real news is obtained through the retriever and the generator.
[0108] Embodiment 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 comprises:
[0110] A candidate answer acquisition module 310 is used to acquire candidate answers for a target question generated by a generator in a large language model;
[0111] A matching degree determination module 320, for determining 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 a target question generated by a generator in a large language model; a matching degree determination module 320, which is used to determine the matching degree between the candidate answer and the target question based on a reviewer; a final answer determination module 330, which is used to determine the generation method of the 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. This technical solution determines the matching degree of the candidate answers output by the generator of the large language model through the reviewer, and thus determines the generation method of the final answer according to 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 judging unit, used to judge whether the matching degree is greater than a preset threshold;
[0116] If yes, the candidate answer is determined as the final answer;
[0117] Otherwise, the retrieval content is determined by the retriever of the large language model, and the final answer is generated according to the target question and the retrieval 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, used for 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;
[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, used for inputting 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, optionally, the device further includes: a training module of the reviewer, 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 matching degree 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 comprises:
[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 used to determine the matching degree between the answer and the question in the question-answer sample pair as a label if yes;
[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 and answer sample pair according to the basic content.
[0134] In the embodiment of the present application, optionally, the second label determination subunit is specifically used to:
[0135] If the answer to the question-answer sample pair includes basic content, the label of the question-answer sample pair is determined to be 1;
[0136] Otherwise, the label of the question-answer sample 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] Embodiment 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 required herein.
[0140] like Figure 7 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and 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 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0141] A number of 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 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 through a computer network such as the Internet and / or various telecommunication networks.
[0142] The processor 11 may be a variety of general and / or special processing components 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 dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 11 executes the various methods and processes described above, such as a problem processing method based on a large language model.
[0143] In some embodiments, the problem processing method based on the large language model can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a 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 problem processing method based on the large language model described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to execute the problem processing method based on the large language model in any other appropriate manner (for example, by means of firmware).
[0144] Various implementations of the systems and techniques described above herein 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), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including 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, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0146] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0147] To provide interaction with a user, the systems and techniques described herein may 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 a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0148] The systems and techniques described herein may be implemented in a computing system that includes backend 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 frontend components (e.g., a user computer with a graphical user interface or a 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 backend components, middleware components, or frontend components. The components of the system may 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 a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0150] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0151] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A problem-solving method based on a large language model, It is 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; 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.
2. The method according to claim 1, It is characterized in that 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, including: Determining whether the matching degree is greater than a preset threshold; If yes, the candidate answer is determined as the final answer; Otherwise, the retrieval content is determined by the retriever of the large language model, and the final answer is generated according to the target question and the retrieval content by the generator based on the large language model.
3. The method according to claim 1, It is characterized in that The degree of matching between the candidate answer and the target question is determined based on the reviewer, including: 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; The hidden state is input into a classifier to obtain an output value of the classifier, and the matching degree between the candidate answer and the target question is determined according to the output value.
4. The method according to claim 3, It is 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 according to 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 matching degree between the candidate answer and the target question.
5. The method according to claim 1, It is characterized in that The training process of the reviewer includes: Obtain a set of question-answer sample pairs; For each question-answer sample pair, the degree of match between its 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.
6. The method according to claim 5, It is 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 its answer and the question is determined as a label, including: Determine whether the questions in the question-answer sample pairs are open questions; If yes, the matching degree between the answer and the question in the question-answer sample pair is determined as the label; otherwise, Determining basic content corresponding to the questions in the question-answer sample pair; the basic content reflects the correct answer corresponding to the question; Determine labels for question-answer sample pairs based on the basic content.
7. The method according to claim 6, It is characterized in that Determining labels of question-answer sample pairs according to the basic content includes: If the answer to the question-answer sample pair includes basic content, the label of the question-answer sample pair is determined to be 1; Otherwise, the label of the question-answer sample pair is determined to be 0.
8. A problem processing device based on a large language model, It is characterized in that include: A candidate answer acquisition module is used to obtain candidate answers for target questions generated by the generator in the large language model; A matching degree determination module, used to determine the matching degree between the candidate answer and the target question based on the reviewer; The final answer determination module is used to determine the generation method of the 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.
9. An electronic device, It is 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 executable 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 a large language model according to any one of claims 1 to 7.
10. A computer-readable storage medium, It is 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 7 when executed.
Citation Information
Patent Citations
Intelligent questioning and answering method and system
CN108153876A
Question and answer processing method, electronic equipment and computer readable medium
CN112182180A
Question and answer matching method and device based on attention mechanism, equipment and storage medium
CN113886550A
Question and answer matching method and device based on K-means clustering algorithm, equipment and medium
CN113918696A
Intelligent question and answer method and system
CN114637760A
