Large model key value type knowledge learning method based on Hash codes

By introducing hash code optimization training sets in key-value knowledge learning of large models, and generating and using hash code as a prompt word, the problem of the reduction in accuracy of large models in key-value question-and-answer tasks is solved, significantly improving different scales and language Q&A accuracy.

CN119026677AActive Publication Date: 2024-11-26NANJING UNIV OF AERONAUTICS & ASTRONAUTICS
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202410994137.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-24
Publication Date
2024-11-26
Estimated Expiration
2044-07-24

AI Technical Summary

Technical Problem

The existing large model has room for improvement in the accuracy of the key-value question-and-answer task when the data set is small in size, but it is significantly reduced when the data set is large in size, and the effect is limited to small-scale knowledge, which cannot effectively alleviate keys. Value pairs conflict to improve the accuracy of Q&A.

Method used

The hash code-based optimization training set method is adopted to generate the hash code of each key-value pair through the encryption algorithm, and add it to the training set, supervised full fine-tuning is performed, and the hash code is used as a prompt word input model for decoding. , optimize the training set format to regularize the hash code representation.

Benefits of technology

The accuracy of the large model in key-value question-and-answer tasks of different scales and languages ​​is improved, and the effectiveness of the hash code method is verified, which is better than the traditional full-quantity fine-tuning method.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119026677A_ABST
    Figure CN119026677A_ABST
Patent Text Reader

Abstract

The invention discloses a large model key value type knowledge learning method based on hash codes, and aims to improve the accuracy of a pre-trained large language model in key value type questions and answers. The method comprises the following steps: in an original key value question and answer training set, calculating and generating a hash code corresponding to each key value pair based on a key through a specific algorithm; before the Hash codes are added into the keys and the values of the corresponding key-value pairs in the training set, the improved data set with the Hash codes added is used for conducting full-amount fine adjustment on the model; during reasoning, the same algorithm is used for calculating and recovering the hash codes on the keys needing to serve as input, splicing the hash codes in front of the keys and inputting the model, and a reasoning decoding result is obtained. According to the method, the Hash code obtained based on key calculation is introduced into the data set, so that the problem that the accuracy rate of supervised fine tuning of a current large model on key value questions and answers is reduced along with the increase of the scale of the data set is solved, and a fine tuning algorithm which is more generally suitable for the large model on key value type questions and answers is provided; and the fine tuning effect on a plurality of related data sets is remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a large model key-value type knowledge learning method based on hash code, belonging to the field of natural language processing in the computer field. Background Art

[0002] In recent years, large language models (LLMs) have developed rapidly. LLMs are generally believed to have the potential to become knowledge bases. Knowledge-based Question Answering (KBQA) has also become a hot research field. At the same time, large model technologies related to knowledge question answering have also been born, such as retrieval generation, knowledge enhancement, and knowledge editing.

[0003] The existing mainstream knowledge question answering big model technologies, such as retrieval generation, need to rely on pre-built knowledge bases, which contain a large amount of structured or semi-structured data and are divided into blocks. The system first parses the user's question and identifies key information, such as entities, attributes, and relationships. Then, based on the parsed key information, it retrieves relevant data or facts from the knowledge base and splices them together with the question as prompt words to input the model, and finally the big model outputs a clear and accurate answer. Although these mainstream knowledge question answering big model technologies have improved the accuracy of knowledge question answering, they still rely on knowledge stored in external knowledge bases or other types of additional modules. Therefore, exploring a method that does not rely on external knowledge bases or additional modules is of great research significance for big model knowledge question answering.

[0004] In addition, supervised fine-tuning, as a commonly used means to improve the effect of large models in downstream, can improve the accuracy of models in knowledge question-answering tasks without relying on external databases. However, the evaluation results of full-scale fine-tuning of large models on key-value question-answering show that the accuracy of key-value question-answering decreases significantly with the increase of the size of the data set when full-scale fine-tuning is performed directly. At the same time, the evaluation results show that even after sufficient fine-tuning on a small-scale data set, the accuracy of large models in key-value question-answering still has a lot of room for improvement. In key-value knowledge question-answering tasks, the existing full-scale fine-tuning method can only be applied to a smaller knowledge scale, and has obvious limitations in effect. Therefore, a large-model key-value knowledge learning method is needed to alleviate conflicts between key-value pairs and improve the accuracy of question-answering. Summary of the invention

[0005] The present invention aims to solve the following technical problems:

[0006] The purpose of the present invention is to design a large-model key-value knowledge learning method based on hash codes. The existing large-model full-scale fine-tuning method for key-value question and answer still has room for improvement in accuracy when the data set size is small. However, when the data set size is large, the accuracy decreases significantly with the increase of the data set size, which has obvious limitations. The goal of the present invention is to overcome the above-mentioned existing defects and construct a large-model key-value knowledge learning method that introduces hash code optimization training sets.

[0007] The present invention adopts the following technical solutions to solve the technical problems:

[0008] A large-model key-value knowledge learning method based on hash codes comprises the following steps: in an original key-value question-answering training set, a hash code corresponding to each key-value pair is generated by an encryption algorithm; the hash code corresponding to each key-value pair is added before the key and value of each key-value pair corresponding to the original key-value question-answering training set to obtain an optimized key-value question-answering training set; the optimized key-value question-answering training set is then used to fine-tune the model in full; reasoning is performed on the trained model, the hash code is calculated and restored on the key required as input using the same encryption algorithm, and the hash code is spliced ​​before the key as a prompt word to input the model, and the model decodes according to a decoding strategy and outputs the result.

[0009] Preferably, the generation of the hash code includes the following steps: first converting the characters in the key into Unicode values, then designing a fixed calculation formula S to calculate the encryption result; truncating the encryption result to a length L to obtain the final hash code, and L>log 10 N, where N is the total number of key-value pairs that need to be inserted into hash codes in the original key-value question answering training set.

[0010] Preferably, the fixed calculation formula S adopts a cumulative multiplication calculation formula to multiply each Unicode value in sequence.

[0011] Preferably, optimizing the original key-value question-answering training set includes the following steps: designing special words in a regular format to mark the start and end of the hash code; adding the hash code corresponding to each key-value pair before the key and value of each key-value pair in the original key-value question-answering training set; performing supervised full-scale fine-tuning on the optimized key-value question-answering training set, and using the cross-entropy loss function.

[0012] Preferably, when the trained model is inferred, the characters in the key to be used as input are converted into Unicode values, the encryption result is calculated using the calculation formula S, the final encryption result is truncated to a length of L, the corresponding hash code is added before the key, and input as a prompt word, and decoding is performed according to the decoding strategy of greedy search or beam search to finally obtain the output.

[0013] Compared with the prior art, the present invention adopts the above technical solution and has the following beneficial effects:

[0014] A large-model key-value knowledge learning method based on hash codes is provided, which makes full use of relevant technical achievements in the field of computer natural language processing. Experimental results show that the large-model key-value knowledge learning method after introducing hash codes for optimization is better than the unoptimized full-scale fine-tuning on key-value question-answering datasets of different scales and languages, verifying the effectiveness of the large-model key-value knowledge learning method based on hash codes. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 It is a schematic diagram of the overall flow of the proposed algorithm framework. DETAILED DESCRIPTION

[0016] The present invention is further described in detail below in conjunction with the accompanying drawings.

[0017] In order to overcome the problem that the existing large-model full-scale fine-tuning method for key-value question answering still has room for improvement in accuracy when the data set size is small, but the accuracy is significantly reduced when the data set size is large, the overall framework of the large-model key-value knowledge learning method based on hash code proposed in this invention is as follows: Figure 1 As shown, it is divided into three parts: 1. Hash code generation. 2. Training set optimization. 3. Hash code input.

[0018] (1) Hash code generation

[0019] In this method, considering the versatility of the method, in the original key-value question and answer training set, a specific encryption algorithm is used to calculate based on the key to generate a hash code corresponding to each key-value pair. Among them, the characteristics of key-value question and answer are as follows: all knowledge question and answer data are processed into a key-value pair format, where each key-value pair corresponds to a specific knowledge attribute, the key is the name of the attribute, and the value is the value of the attribute; when the key is input into the model, the expected output is the value corresponding to this key. The hash code generation encryption algorithm generates a hash code for each key-value pair based on the key. It is necessary to minimize collisions, and considering the overhead during training and inference, the length of the hash code needs to be as short as possible. When the hash code is a numeric code, the characters in the key are converted into Unicode values, and a fixed calculation formula S is designed to calculate the encryption result. The final result is truncated to a length L to obtain the final hash code, and L>log 10 N, where N is the total number of key-value pairs in the data set that need to be inserted into the hash code. The logarithm base is 10 because 10 numeric characters are used to form the hash code. If other types of calculation formulas are designed, the number of different characters used is c, then L>log cN. Take a specific case as an example. For example, when a digital code is used and a cumulative calculation formula is used for encryption calculation, for a training set of 1,000 key-value pairs, the selected truncation length needs to be at least greater than 4. In order to reduce collisions and overhead, the hash code length is finally selected as 6. When performing encryption calculations, for the key that needs to calculate the hash code, first split the characters in the key and convert them into corresponding Unicode values, multiply all Unicode values ​​to obtain the calculation result, and retain the first 6 bits of the result as the hash code calculated for this key.

[0020] (2) Training set optimization

[0021] In this method, considering the unidirectionality of the language model, when the hash code is added to the training set for training set optimization, the corresponding hash code derived from the key is added before the key and value of each key-value pair, rather than at other positions. At the same time, in order to regularize the improved format, special tokens are designed to mark the beginning and end of the hash code, for example, using <codebos>Mark the start of the hash code, using <codeeos>Mark the end of the hash code and add special tokens to both ends of the hash code. For example, a question-answer key-value pair before the improvement is [instruction: "key", output:

[0022] "value"], the hash code calculated based on the key is represented by "code", and the result after adding special word optimization is [instruction:" <codebos>code <codeeos>key”,output:" <codebos>code <codeeos>

[0023] value”]. In addition, the experimental results show that the improvement is still effective when no special words are added. The optimization result when no special words are added is [instruction:"code key",output:"code value"].

[0024] After the training set is optimized, the model is fine-tuned in a supervised manner using the optimized dataset, using the cross entropy loss function. The loss function for supervised fine-tuning is L:

[0025]

[0026] Where N is the number of samples, C is the number of categories (vocabulary size), and y i,j is the true label of sample i, p i,j is the model's predicted probability for the jth category in sample i.

[0027] (3) Hash code input

[0028] After fine-tuning with the optimized training set, in order to let the model answer the key-value questions in the training set, it is necessary to calculate the hash code in the same way based on the key that needs to be used as input, and restore the hash code corresponding to the key, that is, convert the characters in the key into Unicode values, and use the calculation formula S consistent with the training set optimization step to calculate the encryption result, and truncate the final result to the same length L. For example, in the previous training set optimization, digital codes are used and encrypted using the cumulative calculation formula, and the hash code length is selected as 6. Then, when performing encryption calculations, for the key that needs to calculate the hash code, first split the characters in the key and convert them into corresponding Unicode values, multiply all Unicode values, and after obtaining the result, retain the first 6 bits of the result as the hash code calculated for this key. The restored hash code is spliced ​​before the key. If special words are used in the training set optimization step, the special words are added in the same format. If not, they are directly added before the key. For example, when using special tokens, for the original key-value pair [instruction: "key", output: "value"], when testing input, there is only the key "key". First, the hash code is restored based on "key" and the resulting hash code is "code". The final input is " <codebos>code <codeeos>key". The concatenated result is input into the model as the prompt word, and decoded according to the decoding strategy of greedy search or beam search to finally get the output.

[0029] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.< / codeeos> < / codebos> < / codeeos> < / codebos> < / codeeos> < / codebos> < / codeeos> < / codebos>

Claims

1. A large model key-value knowledge learning method based on hash code, characterized in that: The following steps are involved: In the original key-value question-answering training set, the hash code corresponding to each key-value pair is generated through an encryption algorithm; The hash code corresponding to each key-value pair is added before the key and value of each key-value pair in the original key-value question and answer training set to obtain the optimized key-value question and answer training set; then the optimized key-value question and answer training set is used to fully fine-tune the model; reasoning is performed on the trained model, and the same encryption algorithm is used to calculate and restore the hash code on the key that needs to be used as input, and it is spliced ​​before the key as a prompt word to input the model. The model decodes according to the decoding strategy and outputs the result.

2. A large model key-value knowledge learning method based on hash code as claimed in claim 1, characterized in that: The generation of hash codes includes the following steps: first convert the characters in the key into Unicode values, then design a fixed calculation formula S to calculate the encryption result; truncate the encryption result to length L to obtain the final hash code, and L>log 10 N, where N is the total number of key-value pairs that need to be inserted into hash codes in the original key-value question answering training set.

3. A large model key-value knowledge learning method based on hash code as described in claim 2, characterized in that: The fixed calculation formula S uses a cumulative calculation formula to multiply each Unicode value in sequence.

4. A large model key-value knowledge learning method based on hash code as described in claim 2 or 3, characterized in that: Optimizing the original key-value question-answering training set includes the following steps: designing special tokens in a regular format to mark the start and end of the hash code; adding the hash code corresponding to each key-value pair before the key and value of each key-value pair in the original key-value question-answering training set; performing supervised full-scale fine-tuning on the optimized key-value question-answering training set, and using the cross-entropy loss function.

5. A large model key-value knowledge learning method based on hash code as described in claim 2 or 3, characterized in that: When inferring the trained model, convert the characters in the key that needs to be used as input into Unicode values, calculate the encryption result using the calculation formula S, truncate the final encryption result to length L, add the corresponding hash code before the key as the prompt word input, and decode it according to the decoding strategy of greedy search or beam search to finally get the output.

Citation Information

Patent Citations

  • Multi-modal thinking chain reasoning method and device based on knowledge distillation

    CN118014077A

  • Model training method and question answering method for question answering system

    CN118093841A

  • Intelligent questioning and answering method for government affairs

    CN118153686A

  • A method and a system for securely sharing datasets via glyphs

    US20240107318A1