Large language model self-improvement method and device
By retrieving and updating reflective sample information and improved sample information in large language models, the problems of high computing resources and low output quality are solved, the output quality and responsiveness of the model are improved, and the knowledge base is enriched and self-improved.
Patent Information
- Application Number
- CN202410287285.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-13
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-03-13
AI Technical Summary
The existing large language model fine-tuning process requires high computing resources and low output quality. It needs to be continuously updated to respond to changes in the external environment. How to improve the model output quality and responsiveness.
By retrieving reflection sample information and improvement sample information in the large language model, the knowledge base is updated to improve the output quality, and the reflection sample information is used for self-reflection and improvement, optimizing the quality, accuracy and readability of the output information.
It improves the output quality and responsiveness of large language models, reduces computing resource requirements, enriches the content of the knowledge base, and enhances the self-improvement capabilities of the model.
Smart Images

Figure CN118093823B
Abstract
Description
Technical Field
[0001] The present disclosure belongs to the field of deep learning technology, and more specifically, to a method and device for self-improvement of a large language model. Background Art
[0002] Fine-tuning a large language model is usually accompanied by significant computational resource requirements, which involves not only the computational cost during training, but also the resources required to store, maintain, and update the model. In addition, as the external environment changes, the large language model may need to be continuously updated, further increasing the dependence on computing resources. The output quality of existing retrieval-enhanced large language model methods is relatively low, so how to improve the output quality of large language model methods is particularly important. Summary of the invention
[0003] The purpose of the present disclosure is to provide a large language model self-improvement method and device to enhance the model's ability to iteratively improve output responses and output quality.
[0004] According to a first aspect of the embodiments of the present disclosure, a large language model self-improvement method is provided, comprising:
[0005] Retrieving the reflection sample information corresponding to the first input information in the first knowledge base;
[0006] The first knowledge base is a database used for searching when the large language model generates output information; the first input information includes a first question and a first reply, and the first reply is reply information output by the large language model according to the first question; the reflection sample information is an evaluation and criticism of a specific question and model output by a generative language model or a human;
[0007] Inputting the reflection sample information and the first input information into a large language model to obtain target reflection information corresponding to the first input information; updating the first knowledge base based on the first input information and the target reflection information;
[0008] Retrieving improved sample information corresponding to the second input information in a second knowledge base;
[0009] The second knowledge base is a database used by the large language model to search when self-improving the generated output information; the second input information includes the first input information and target reflection information; the improved sample information refers to processing, arranging and optimizing the original information to improve the quality, accuracy and readability of the information;
[0010] The second input information and the improved sample information are input into the large language model to obtain target improved information corresponding to the second input information; and the second knowledge base is updated based on the second input information and the target improved information.
[0011] A second aspect of the embodiments of the present disclosure provides a large language model self-improvement device, including:
[0012] A reflection information acquisition module is used to retrieve reflection sample information corresponding to the first input information in the first knowledge base; input the reflection sample information and the first input information into the large language model to obtain target reflection information corresponding to the first input information; update the first knowledge base based on the first input information and the target reflection information; the reflection sample information is an evaluation and criticism of a generative language model or a human on a specific problem and model output;
[0013] An improved information acquisition module is used to retrieve improved sample information corresponding to the second input information in the second knowledge base; the improved sample information refers to processing, organizing and optimizing the original information to improve the quality, accuracy and readability of the information; the second input information and the improved sample information are input into the large language model to obtain target improved information corresponding to the second input information; the second knowledge base is updated based on the second input information and the target improved information.
[0014] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of the above-mentioned large language model self-improvement method when executing the computer program.
[0015] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned large language model self-improvement method are implemented.
[0016] The beneficial effects of the large language model self-improvement method and device provided by the embodiments of the present disclosure are:
[0017] First, the knowledge base in the present disclosure includes a first knowledge base and a second knowledge base, the first knowledge base includes a plurality of predetermined question-answer pairs and reflection sample information corresponding to each question-answer pair, and the second knowledge base includes a plurality of predetermined question-answer pairs and improved sample information corresponding to each question-answer pair. The first input information includes a first question and a first reply. The reflection sample information corresponding to the first input information is retrieved in the first knowledge base, and the reflection sample information and the first input information are input into the large language model to obtain the target reflection information. The second input information includes the first input information and the target reflection information. The improved sample information corresponding to the second input information is retrieved in the second knowledge base, and the improved sample information and the second input information are input into the large language model to obtain the target improved information. Through two-step retrieval and judgment, the output quality of the large language model is improved.
[0018] Secondly, the present disclosure will update the first input information and the target reflection information corresponding to the first input information to the first knowledge base, and update the second input information and the target improvement information corresponding to the second input information to the second knowledge base, enriching the contents of the first knowledge base and the second knowledge base, and improving the output quality of the large language model. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 A flowchart of a large language model self-improvement method provided by an embodiment of the present disclosure;
[0021] Figure 2 A structural block diagram of a large language model self-improvement device provided by an embodiment of the present disclosure;
[0022] Figure 3 A schematic block diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0023] In the following description, specific details such as specific system structures and technologies are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present disclosure. However, it should be clear to those skilled in the art that the present disclosure may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obstructing the description of the present disclosure with unnecessary details.
[0024] In order to make the purpose, technical solutions and advantages of the present disclosure more clear, specific embodiments will be described below in conjunction with the accompanying drawings.
[0025] Please refer to Figure 1 , Figure 1 A flowchart of a large language model self-improvement method provided by an embodiment of the present disclosure, the method comprising:
[0026] S101: Retrieving reflection sample information corresponding to first input information in a first knowledge base;
[0027] The first knowledge base is a database used for retrieval when the large language model generates output information. The first input information includes a first question and a first reply. The first reply is reply information output by the large language model according to the first question.
[0028] In this embodiment, the first input information includes a first question and a first reply, and the first reply is an answer to the first question, that is, the first input information is a set of question-answer pairs. The reflective sample information is the evaluation and criticism of a specific question and model output by a generative language model or a human. The first knowledge base is a database used for retrieval when the large language model generates output information. The first knowledge base contains a plurality of predetermined question-answer pairs and reflective sample information corresponding to each question-answer pair. The first reply is the reply information output by the large language model based on the first question. For example, a question "Who is the current President of the United States?" is input into the large language model, and the large language model outputs the corresponding reply information "A".
[0029] In this embodiment, the content in the first knowledge base can be obtained by manually inputting questions, corresponding answers, and corresponding reflection results; crawling relevant information from the Internet or other data sources; or extracting relevant information from text through natural language processing technology. The first knowledge base can help the large language model understand the limitations of its answering questions and how to improve it.
[0030] In this embodiment, a set of target question-answer pairs is input to the retriever, and the retriever retrieves multiple question-answer pairs in the first knowledge base, and outputs reflection sample information corresponding to the target question-answer pairs. For example, the target question-answer pair is "Question: Who is the current president of the United States? Answer: A.", and the question-answer pair A1 retrieved in the first knowledge base is "Question: Who is the current president of France: Answer: B." The reflection sample information corresponding to the question-answer pair A1 is "The answer gives the name of a person who once served as president of France, but ignores the current time."
[0031] S102: Inputting the reflection sample information and the first input information into the large language model to obtain target reflection information corresponding to the first input information; and updating the first knowledge base based on the first input information and the target reflection information.
[0032] In this embodiment, when the reflection sample information and the first input information are input into the large language model, the self-reflection instruction also needs to be input into the large language model. The large language model judges the answer to the first question based on the reflection sample information and determines the target reflection information corresponding to the target question-answer pair.
[0033] For example, the target question-answer pair is "Question: Who is the current president of the United States? Answer: A." The self-reflection instruction is "Please check this question-answer pair and propose possible questions and suggestions." Question-answer pair A1 in the first knowledge base: "Question: Who is the current president of France: Answer: B", the reflection sample information corresponding to question-answer pair A1: The answer mentions the historical French president, but does not consider the current situation. The large language model performs self-reflection and outputs the target reflection information, which may be "The answer mentions the historical president of the United States, not the current president."
[0034] After obtaining the target reflection information of the target question and answer pair, the target question and answer pair and the corresponding target reflection information may be updated to the first knowledge base to improve the output quality of the large language model.
[0035] S103: Retrieving improved sample information corresponding to the second input information in the second knowledge base;
[0036] The second knowledge base is a database used for retrieval when the large language model performs self-improvement on the generated output information; the second input information includes the first input information and the target reflection information.
[0037] In this embodiment, the second knowledge base includes a plurality of predetermined question-answer pairs and improved sample information corresponding to each question-answer pair. Improved sample information refers to processing, organizing and optimizing original information to improve the quality, accuracy and readability of the information. The purpose of improving sample information is to make it easier for users to understand and obtain the required information. In this embodiment, the content in the second knowledge base may be manually input. The content in the second knowledge base overlaps with the content in the first knowledge base, and the content in the second knowledge base focuses on providing output improvement reference information for the large language model in order to improve the matching degree of the target question-answer pair.
[0038] In this embodiment, second input information is input to the retriever, and the retriever retrieves question-answer pairs in the second knowledge base that match the target question-answer pairs of the second input information, and determines improved sample information corresponding to the question-answer pairs based on the retrieved question-answer pairs.
[0039] For example, the target question-answer pair may be “Question: Who is the current president of the United States? Answer: A”, and the question-answer pair B1 in the second knowledge base may be “Question: Who is the current president of France? Answer: B”. The reflection sample information corresponding to the question-answer pair B1 is “The answer mentions the historical president of France, not the current president.” The improved sample information corresponding to the question-answer pair B1 may be “C”.
[0040] S104: Input the second input information and the improved sample information into the large language model to obtain target improved information corresponding to the second input information; and update the second knowledge base based on the second input information and the target improved information.
[0041] In this embodiment, the second input information includes the first input information (target question and answer pair) and target reflection information. The first input information may be “Question: Who is the current president of the United States? Answer: A”, and the target reflection information may be “This answer mentions a historical president of the United States, not the current president”.
[0042] Input the target question and answer pair and the target reflection information corresponding to the target question and answer pair into the large language model, and the self-improvement instruction "Please improve the answer based on the question and answer pair and its existing problems". The large language model determines that the target improvement information corresponding to the target question and answer pair is "D" based on the question and answer pair B1 in the second knowledge base, the reflection sample information corresponding to the question and answer pair B1, and the improvement sample information corresponding to the question and answer pair B1. The large language model updates the second knowledge base with the target question and answer pair, the target reflection information corresponding to the target question and answer pair, and the target improvement information corresponding to the target question and answer pair.
[0043] From the above, it can be concluded that, first, the knowledge base in the present disclosure includes a first knowledge base and a second knowledge base, the first knowledge base includes a plurality of predetermined question-answer pairs and reflection sample information corresponding to each question-answer pair, and the second knowledge base includes a plurality of predetermined question-answer pairs and improved sample information corresponding to each question-answer pair. The target question-answer pair is input into the large language model, and the large language model reflects on the problems existing in the target question-answer pair according to the reflection sample information in the first knowledge base retrieved by the retriever, and obtains the target reflection information; then the target question-answer pair and the target reflection information corresponding to the target question-answer pair are input into the large language model, and the large language model improves the problems existing in the target question-answer pair according to the improved sample information in the second knowledge base retrieved by the retriever, and obtains the target improvement information. Through two-step retrieval and judgment, the output quality of the large language model is improved.
[0044] Secondly, the present disclosure will update the target question and answer pairs and the target reflection information corresponding to the target question and answer pairs to the first knowledge base, and update the target question and answer pairs and the target improvement information corresponding to the target question and answer pairs to the second knowledge base, enriching the contents of the first knowledge base and the second knowledge base, and improving the output quality of the large language model.
[0045] In one embodiment of the present disclosure, retrieving the reflection sample information corresponding to the first input information in the first knowledge base includes:
[0046] Calculating the similarity between the first input information and each question-answer pair in the first knowledge base;
[0047] Sort by similarity from high to low, and select the reflection sample information corresponding to the first K question-answer pairs from the first knowledge base based on the similarity sorting result.
[0048] In this embodiment, the first input information (target question-answer pair) and each question-answer pair in the first knowledge base are vectorized, the vector distances between the target question-answer pair and each question-answer pair are calculated, and the magnitudes of the vector distances are compared to obtain the semantic relevance between the target question-answer pair and each question-answer pair in the first knowledge base. Clustering is performed on the target question-answer pair and each question-answer pair in the first knowledge base based on the semantic relevance, and the top K question-answer pairs in the first knowledge base with high semantic similarity to the target question-answer pair are determined based on the clustering results, and the reflection sample information corresponding to the top K question-answer pairs is used as the target reflection information of the target question-answer pair.
[0049] In this embodiment, semantic relevance is used to represent the degree of association between two question-answer pairs in terms of natural semantics. The target question-answer pair and each question-answer pair in the first knowledge base can be vectorized first, and then the vector distance can be used to characterize the semantic relevance between the question-answer pairs. When the vector distance between the two question-answer pairs is small, it means that the semantic relevance between the two is high; if the vector distance between the two question-answer pairs is large, it means that the semantic relevance between the two is low. Clustering the target question-answer pair and each question-answer pair in the first knowledge base based on semantic relevance mainly includes:
[0050] First, a question-answer pair is segmented to obtain one or more words. For example, the question-answer pair "Question: Who is the current president of the United States? Answer: A" is segmented to obtain "United States", "President", and "A". For the multiple words obtained from the question-answer pair segmentation, word vectors in the form of digital vectors that can be directly calculated by computers can be obtained through embedding processing.
[0051] Secondly, the semantic weight of each word is determined according to the frequency of the word in the question-answer pair. The higher the semantic weight, the more important the word is in the corresponding question-answer pair; the lower the semantic weight, the less important the word is in the corresponding question-answer pair.
[0052] Then, the word vectors of the words are weighted mapped according to the semantic weights to obtain the semantic vectors of each question-answer pair.
[0053] Finally, the question-answer pairs are clustered according to the vector similarity between the semantic vectors.
[0054] According to the clustering processing results, the first K question-answer pairs with high semantic similarity to the target question-answer pair in the first knowledge base are determined, and the reflection sample information corresponding to the first K question-answer pairs is used as the target reflection information of the target question-answer pair. For example, the target question-answer pair is "Question: Who is the current president of the United States? Answer: A." The first three question-answer pairs with high semantic similarity are "Question: Who is the current president of France? Answer: B", "Question: Who is the current director-general of the World Health Organization? Answer: E", and "Question: Who is the current minister of education? Answer: F".
[0055] In one embodiment of the present disclosure, updating the first knowledge base based on the first input information and the target reflection information includes:
[0056] The first input information and the target reflection information form a first key-value pair, and the first key-value pair is updated to the first knowledge base. In this embodiment, a plurality of predetermined question-answer pairs are used as "keys", and the reflection sample information corresponding to each question-answer pair is stored in the first knowledge base as "values". The key-value pair exists as a whole in the first knowledge base, and the "key" and "value" are in a one-to-one correspondence. For example, the "key" is "Question: Who is the current president of France? Answer: B", and the "value" is "The answer gives the name of a person who once served as president of France, but ignores the current time".
[0057] In this embodiment, for example, the target question-answer pair is “Question: Who is the current Secretary-General of the United Nations? Answer: G”, and the self-reflection instruction is “Please check this question-answer pair, and raise possible questions and suggestions”. The target question-answer pair is input into the retriever, and the retriever retrieves the key-value pairs in the first knowledge base to obtain: “Key” is question-answer pair A2: “Question: Who is the current President of the European Commission? Answer: H”, and “Value” is the reflection sample information corresponding to question-answer pair A2: “The answer mentions the historical President of the European Commission, without considering the current situation”. Based on the retrieved key-value pairs, the large language model outputs the target reflection information: “The answer mentions the historical Secretary-General of the United Nations, not the current Secretary-General”.
[0058] The target question-answer pair and the target reflection information are combined into a first key-value pair, which is updated into the first knowledge base, thereby enriching the content of the first knowledge base.
[0059] In one embodiment of the present disclosure, according to the target question-answer pair and the target reflection information, retrieving improved sample information corresponding to the second input information in the second knowledge base includes:
[0060] Calculating the similarity between the second input information and each question-answer pair in the second knowledge base;
[0061] Sort by similarity from high to low, and select improved sample information corresponding to the first K question-answer pairs from the second knowledge base based on the similarity sorting result.
[0062] In this embodiment, the target question-answer pair in the second input information and each question-answer pair in the second knowledge base are vectorized, the vector distance between the target question-answer pair and each question-answer pair is calculated, and the magnitude of each vector distance is compared to obtain the semantic relevance between the target question-answer pair and each question-answer pair in the second knowledge base. Clustering is performed on the target question-answer pair and each question-answer pair in the second knowledge base based on the semantic relevance, and the top K question-answer pairs in the second knowledge base with high semantic similarity to the target question-answer pair are determined based on the clustering results, and the improved sample information corresponding to the top K question-answer pairs is used as the target improved information of the target question-answer pair.
[0063] In this embodiment, semantic relevance is used to indicate the degree of association between two question-answer pairs in terms of natural semantics. The target question-answer pair and each question-answer pair in the second knowledge base can be vectorized first, and then the vector distance can be used to characterize the semantic relevance between the question-answer pairs. When the vector distance between the two question-answer pairs is small, it means that the semantic relevance between the two is high; if the vector distance between the two question-answer pairs is large, it means that the semantic relevance between the two is low. Clustering the target question-answer pair and each question-answer pair in the second knowledge base based on semantic relevance mainly includes:
[0064] First, a question-answer pair is segmented to obtain one or more words. For example, the question-answer pair "Question: Who is the current president of the United States? Answer: A" is segmented to obtain "United States", "President", and "A". For the multiple words obtained from the question-answer pair segmentation, word vectors in the form of digital vectors that can be directly calculated by computers can be obtained through embedding processing.
[0065] Secondly, the semantic weight of each word is determined according to the frequency of the word in the question-answer pair. The higher the semantic weight, the more important the word is in the corresponding question-answer pair; the lower the semantic weight, the less important the word is in the corresponding question-answer pair.
[0066] Then, the word vectors of the words are weighted mapped according to the semantic weights to obtain the semantic vectors of each question-answer pair.
[0067] Finally, the question-answer pairs are clustered according to the vector similarity between the semantic vectors.
[0068] According to the clustering processing results, the first K question-answer pairs with high semantic similarity to the target question-answer pair in the second knowledge base are determined, and the improved sample information corresponding to the first K question-answer pairs is used as the target improved information of the target question-answer pair. For example, the target question-answer pair is "Question: Who is the current president of the United States? Answer: A." The first three question-answer pairs with high semantic similarity are "Question: Who is the current president of France? Answer: B", "Question: Who is the current director-general of the World Health Organization? Answer: E", and "Question: Who is the current minister of education? Answer: F".
[0069] In one embodiment of the present disclosure, updating the second knowledge base based on the second input information and the target improvement information includes:
[0070] The second input information and the target improvement information are combined into a second key-value pair, and the second key-value pair is updated to the second knowledge base.
[0071] In this embodiment, a plurality of predetermined question-answer pairs and the reflection sample information corresponding to the question-answer pairs are used as "keys", and the improved sample information corresponding to each question-answer pair is used as "values", and the key-value pairs are stored as a whole in the second knowledge base. For example, the "key" is "Question: Who is the current president of France? Answer: B. Reflection sample information: This answer gives the name of a person who once served as president of France, but ignores the current time"; the "value" is "Improved sample information: C".
[0072] In this embodiment, for example, the target question and answer pair is “Question: Who is the current Secretary-General of the United Nations? Answer: G”, the target reflection information corresponding to the target question and answer pair is “The answer mentions the historical Secretary-General of the United Nations, not the current Secretary-General”, and the self-improvement instruction is “Improve the answer based on the question and answer pair and its existing problems”.
[0073] The target question-answer pair, target reflection information, and self-improvement instructions are input into the retriever, and the retriever retrieves the key-value pairs in the second knowledge base and obtains: "Key" is "Question: Who is the current Director-General of the World Health Organization? Answer: E. Reflection sample information: The answer mentions the historical Director-General of the WHO, not the current Director-General", and "Value" is "I". The large language model determines that the target improvement information corresponding to the target question-answer pair is "J" based on the retrieved key-value pairs.
[0074] The target question and answer pairs, target reflection information, and target improvement information are combined into a second key-value pair, which is updated into the second knowledge base, thereby enriching the content of the second knowledge base.
[0075] In one embodiment of the present disclosure, the large language model self-improvement method further includes:
[0076] The first knowledge base and the second knowledge base are updated based on the large language model, and the above updating steps are repeated until the number of updates reaches a preset number of iterations.
[0077] In this embodiment, the large language model can understand and generate human language by learning a large amount of text data. Continuously training and optimizing the large language model can enrich the content in the first knowledge base and the second knowledge base. After reaching the preset number of iterations, the large language model has reached a certain performance level and can be applied to actual scenarios, thereby achieving self-improvement of the large language model.
[0078] In one embodiment of the present disclosure, the large language model further includes a third knowledge base related to the target question-answer pair.
[0079] In this embodiment, the third knowledge base contains some socially relevant knowledge. When a question and an answer instruction are input to the large language model, the large language model retrieves the knowledge in the third knowledge base to obtain the output of the question. For example, if the input question is "Who is the current president of the United States?" and the answer instruction is "Please answer the following question", the knowledge retrieved by the large language model may be "A announced his candidacy for president in June 2015, was elected in November 2016, and took office in January 2017. D took office in January 2021 and became the nth president of the United States." Based on this, the output of the large language model may be "A".
[0080] For example, if the input question is "Who is the current Secretary-General of the United Nations?" and the answer instruction is "Please answer the following questions", the knowledge retrieved by the large language model may be "G served as Secretary-General of the United Nations from 2007 to 2016, and J has served as Secretary-General of the United Nations since 2017." Based on this, the output of the large language model may be "G".
[0081] The question and the answer output by the large language model can form a question-answer pair, and the question-answer pair can be saved as a "key" in the first knowledge base of the large language model.
[0082] Corresponding to the large language model self-improvement method in the above embodiment, Figure 2 This is a structural block diagram of a large language model self-improvement device provided by an embodiment of the present disclosure. For ease of explanation, only the parts related to the embodiment of the present disclosure are shown. Figure 2 The large language model self-improvement device 20 includes: a reflection information acquisition module 21 and an improvement information acquisition module 22.
[0083] Among them, the reflection information acquisition module 21 is used to retrieve reflection sample information corresponding to the first input information in the first knowledge base; the reflection sample information is the evaluation and criticism of the generative language model or humans on specific problems and model outputs; the reflection sample information and the first input information are input into the large language model to obtain the target reflection information corresponding to the first input information; the first knowledge base is updated based on the first input information and the target reflection information.
[0084] The improved information acquisition module 22 is used to retrieve improved sample information corresponding to the second input information in the second knowledge base; the improved sample information refers to the processing, organization and optimization of the original information to improve the quality, accuracy and readability of the information; the second input information and the improved sample information are input into the large language model to obtain the target improved information corresponding to the second input information; the second knowledge base is updated based on the second input information and the target improved information.
[0085] In one embodiment of the present disclosure, the reflection information acquisition module 21 is specifically used to:
[0086] Calculating the similarity between the first input information and each question-answer pair in the first knowledge base;
[0087] Sort by similarity from high to low, and select the reflection sample information corresponding to the first K question-answer pairs from the first knowledge base based on the similarity sorting result.
[0088] In one embodiment of the present disclosure, the reflection information acquisition module 21 is specifically used to:
[0089] The first input information and the target reflection information are combined into a first key-value pair, and the first key-value pair is updated to the first knowledge base.
[0090] In one embodiment of the present disclosure, the improved information acquisition module 22 is specifically used to:
[0091] Calculating the similarity between the second input information and each question-answer pair in the second knowledge base;
[0092] Sort by similarity from high to low, and select improved sample information corresponding to the first K question-answer pairs from the second knowledge base based on the similarity sorting result.
[0093] In one embodiment of the present disclosure, the improved information acquisition module 22 is specifically used to:
[0094] The second input information and the target improvement information are combined into a second key-value pair, and the second key-value pair is updated to the second knowledge base.
[0095] In one embodiment of the present disclosure, the device 20 further includes:
[0096] The first knowledge base and the second knowledge base are updated based on the large language model, and the above updating steps are repeated until the number of updates reaches a preset number of iterations.
[0097] In one embodiment of the present disclosure, the large language model further includes a third knowledge base related to the target question-answer pair.
[0098] See also Figure 3 , Figure 3Schematic block diagram of an electronic device provided by an embodiment of the present disclosure. Figure 3 The electronic device 300 in the embodiment shown may include: one or more processors 301, one or more input devices 302, one or more output devices 303 and one or more memories 304. The processors 301, input devices 302, output devices 303 and memories 304 communicate with each other via a communication bus 305. The memory 304 is used to store computer programs, which include program instructions. The processor 301 is used to execute the program instructions stored in the memory 304. The processor 301 is configured to call the program instructions to execute the functions of each module / unit in the above-mentioned device embodiments, such as Figure 2 The functions of modules 21 to 22 are shown.
[0099] It should be understood that in the embodiment of the present disclosure, the processor 301 may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0100] The input device 302 may include a touch panel, a fingerprint sensor (for collecting fingerprint information of the user and fingerprint direction information), a microphone, etc. The output device 303 may include a display (LCD, etc.), a speaker, etc.
[0101] The memory 304 may include a read-only memory and a random access memory, and provide instructions and data to the processor 301. A portion of the memory 304 may also include a non-volatile random access memory. For example, the memory 304 may also store information about the device type.
[0102] In a specific implementation, the processor 301, input device 302, and output device 303 described in the embodiments of the present disclosure can execute the implementation methods described in the first and second embodiments of the large language model self-improvement method provided in the embodiments of the present disclosure, and can also execute the implementation methods of the electronic device described in the embodiments of the present disclosure, which will not be repeated here.
[0103] In another embodiment of the present disclosure, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, wherein the program instructions are executed by a processor to implement all or part of the processes in the above-mentioned embodiment method, and may also be completed by instructing the relevant hardware through the computer program, wherein the computer program may be stored in a computer-readable storage medium, and wherein the computer program may be executed by the processor to implement the steps of the above-mentioned various method embodiments. Among them, the computer program includes computer program code, and the computer program code may be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the contents contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electric carrier signal and telecommunication signal.
[0104] The computer-readable storage medium may be an internal storage unit of the electronic device of any of the aforementioned embodiments, such as a hard disk or memory of the electronic device. The computer-readable storage medium may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Furthermore, the computer-readable storage medium may also include both an internal storage unit of the electronic device and an external storage device. The computer-readable storage medium is used to store computer programs and other programs and data required by the electronic device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
[0105] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this disclosure.
[0106] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the electronic devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0107] In the several embodiments provided in the present application, it should be understood that the disclosed electronic devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces or units, or it can be an electrical, mechanical or other form of connection.
[0108] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present disclosure.
[0109] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0110] The above are only specific embodiments of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present disclosure, and these modifications or replacements should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A large language model self-improvement method, characterized in that: include: Retrieving the reflection sample information corresponding to the first input information in the first knowledge base; The first knowledge base is a database used for searching when the large language model generates output information; the first input information includes a first question and a first reply, and the first reply is reply information output by the large language model according to the first question; the reflection sample information is an evaluation and criticism of a specific question and model output by a generative language model or a human; Inputting the reflection sample information and the first input information into a large language model to obtain target reflection information corresponding to the first input information; updating the first knowledge base based on the first input information and the target reflection information; Retrieving improved sample information corresponding to the second input information in a second knowledge base; The second knowledge base is a database used by the large language model to search when self-improving the generated output information; the second input information includes the first input information and target reflection information; the improved sample information refers to processing, arranging and optimizing the original information to improve the quality, accuracy and readability of the information; Inputting the second input information and the improved sample information into the large language model to obtain target improved information corresponding to the second input information; The second knowledge base is updated based on the second input information and the target improvement information.
2. The large language model self-improvement method according to claim 1, characterized in that: The step of retrieving the reflection sample information corresponding to the first input information from the first knowledge base includes: Calculating the similarity between the first input information and each question-answer pair in the first knowledge base; Sort by similarity from high to low, and select reflection sample information corresponding to the first K question-answer pairs from the first knowledge base based on the similarity sorting result.
3. The large language model self-improvement method according to claim 1, characterized in that: The updating of the first knowledge base based on the first input information and the target reflection information includes: The first input information and the target reflection information are combined into a first key-value pair, and the first key-value pair is updated to the first knowledge base.
4. The large language model self-improvement method according to claim 1, characterized in that: The retrieving the improved sample information corresponding to the second input information from the second knowledge base includes: Calculating the similarity between the second input information and each question-answer pair in the second knowledge base; Sort by similarity from high to low, and select improved sample information corresponding to the first K question-answer pairs from the second knowledge base according to the similarity sorting result.
5. The large language model self-improvement method according to claim 1, characterized in that: The updating of the second knowledge base based on the second input information and the target improvement information includes: The second input information and the target improvement information are combined into a second key-value pair, and the second key-value pair is updated to the second knowledge base.
6. The large language model self-improvement method according to any one of claims 1 to 5, characterized in that: Also includes: The first knowledge base and the second knowledge base are updated based on the large language model, and the above updating steps are repeated until the number of updates reaches a preset number of iterations.
7. The large language model self-improvement method according to claim 1, characterized in that: The large language model also includes a third knowledge base related to the first question.
8. A large language model self-improvement device, characterized in that: include: A reflection information acquisition module, used to retrieve reflection sample information corresponding to the first input information in the first knowledge base; The first knowledge base is a database used for searching when the large language model generates output information, the first input information includes a first question and a first reply, and the first reply is reply information output by the large language model according to the first question; the reflection sample information and the first input information are input into the large language model to obtain target reflection information corresponding to the first input information; updating the first knowledge base based on the first input information and the target reflection information; The reflection sample information is evaluation and criticism of specific questions and model outputs by the generative language model or humans; An improved information acquisition module, used to retrieve improved sample information corresponding to the second input information in the second knowledge base; The second knowledge base is a database used by the large language model to search when self-improving the generated output information; the second input information includes the first input information and target reflection information; the improved sample information refers to processing, arranging and optimizing the original information to improve the quality, accuracy and readability of the information; Inputting the second input information and the improved sample information into the large language model to obtain target improved information corresponding to the second input information; The second knowledge base is updated based on the second input information and the target improvement information.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
