Model fine tuning method and device, equipment and storage medium
By constructing a password book, the plain text fine-tuned data is replaced with cipher text data and fine-tuned the language model, the problem of fine-tuning data privacy protection in vertical scenarios is solved, and data privacy protection and model effect matching is achieved. Reduces resource waste.
Patent Information
- Application Number
- CN202411061072.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-02
- Publication Date
- 2024-11-29
Smart Images

Figure CN119047531A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of computer computing and data encryption, and in particular to a model fine-tuning method, device, equipment and storage medium. Background Art
[0002] With the rapid development of artificial intelligence technology, large language models (LLM) play an important role in a variety of application scenarios. With the continuous expansion of large language model application scenarios, fine-tuning the model based on the basic large language model using the business data of vertical scenarios, and then applying the fine-tuned model to vertical scenarios to solve business problems in vertical scenarios has become the preferred solution for businesses.
[0003] Converting the business data of application scenarios into fine-tuning data and then further training the large language model becomes a key step to improve business results. However, the business data of application scenarios generally contains some commercial secrets and is unwilling to be disclosed or provided to third parties. Therefore, the privacy protection of fine-tuning data becomes a key issue, especially in medical, social, military and other scenarios. The privacy protection of fine-tuning data becomes a challenge for the continued development of large language models.
[0004] At present, many companies have LLM technical capabilities but no business data; and many companies have business data, such as hospitals, but do not have LLM technology and cannot use LLM to mine the value of business data; the two are contradictory. And many business data have privacy requirements and cannot be easily provided to external companies. Therefore, when companies with technology cooperate with companies with data, there will be many restrictions and they cannot effectively use data based on LLM. When using the original open source model, the business effects and vertical scenarios cannot be fully matched, affecting the user experience.
[0005] Therefore, a model fine-tuning solution is needed that can solve the fine-tuning data privacy issue. Summary of the invention
[0006] A technical problem to be solved by the present disclosure is how to solve the privacy problem of fine-tuning data.
[0007] According to a first aspect of the present disclosure, a model fine-tuning method is provided, comprising: obtaining at least one ciphertext fine-tuning data; the ciphertext fine-tuning data is ciphertext data obtained by replacing plaintext fine-tuning data by a data party using a code book; each of the plaintext fine-tuning data comprises a first plaintext input and a first plaintext output, and each of the ciphertext fine-tuning data comprises a first ciphertext input obtained by replacing the first plaintext input by using the code book and a first ciphertext output obtained by replacing the first plaintext output by using the code book; fine-tuning the language model using the at least one ciphertext fine-tuning data; wherein the language model is adjusted with the goal of reducing the difference between the output obtained by the language model processing the first ciphertext input and the first ciphertext output.
[0008] Optionally, the codebook includes a first codebook, which is used to represent the correspondence between each word in the word list of the language model and the first ciphertext, the first ciphertext input is composed of the first ciphertext corresponding to each word in the first plaintext input, and the first ciphertext output is composed of the first ciphertext corresponding to each word in the first plaintext output; or the codebook includes a second codebook, which is used to represent the correspondence between each word encoding in the word encoding list of the language model and the second ciphertext, the first ciphertext input is composed of the second ciphertext corresponding to the word encoding of each word in the first plaintext input, and the first ciphertext output is composed of the second ciphertext corresponding to the word encoding of each word in the first plaintext output.
[0009] Optionally, for any word-unit in the word-unit list, the first ciphertext corresponding to the word-unit is a word-unit in the word-unit list that is different from the word-unit.
[0010] Optionally, the first codebook is obtained in an artificially defined manner; or the first codebook is obtained by iteratively executing the following process: traversing the word-unit list, and for the currently traversed word-unit, randomly selecting a word-unit in the word-unit list that has not been selected and is different from the word-unit as the first ciphertext corresponding to the word-unit.
[0011] Optionally, for any word in the word list, the first ciphertext corresponding to the word is a hash value obtained by hashing the word using a hash algorithm, or the first ciphertext corresponding to the word is an encryption result obtained by encrypting the word using an encryption algorithm.
[0012] Optionally, for any word unit code in the word unit code list, the second ciphertext corresponding to the word unit code is a word unit code different from the word unit code among all word unit codes.
[0013] Optionally, the second codebook is obtained in an artificially defined manner; or the second codebook is obtained by iteratively executing the following process: traversing the word unit encoding list, and for the word unit encoding currently traversed, randomly selecting a word unit encoding in the word unit encoding list that has not been selected and is different from the word unit encoding as the second ciphertext corresponding to the word unit encoding.
[0014] Optionally, for any word unit code in the word unit code list, the second ciphertext corresponding to the word unit code is a hash value obtained by hashing the word unit code using a hash algorithm, or the second ciphertext corresponding to the word unit code is an encryption result obtained by encrypting the word unit code using an encryption algorithm.
[0015] Optionally, the method also includes: obtaining a second ciphertext input, the second ciphertext input being ciphertext data obtained by the data party replacing a second plaintext input with the first codebook or the second codebook; the second ciphertext input being composed of first ciphertexts corresponding to each word unit in the second plaintext input, or the second ciphertext input being composed of second ciphertexts corresponding to word unit encodings of each word unit in the second plaintext input; processing the second ciphertext input using a fine-tuned language model to obtain a second ciphertext output corresponding to the second ciphertext input; and sending the second ciphertext output to the data party.
[0016] According to a second aspect of the present disclosure, a model fine-tuning method is provided, comprising: constructing a code book for a language model; replacing at least one piece of plaintext fine-tuning data with corresponding ciphertext fine-tuning data using the code book; each piece of the plaintext fine-tuning data comprises a first plaintext input and a first plaintext output, and each piece of the ciphertext fine-tuning data comprises a first ciphertext input obtained by replacing the first plaintext input with the code book and a first ciphertext output obtained by replacing the first plaintext output with the code book; sending the ciphertext fine-tuning data to a model party, so that the model party fine-tunes the language model based on the ciphertext fine-tuning data.
[0017] Optionally, the codebook includes a first codebook, which is used to represent the correspondence between each word in the word list of the language model and the first ciphertext, the first ciphertext input is composed of the first ciphertext corresponding to each word in the first plaintext input, and the first ciphertext output is composed of the first ciphertext corresponding to each word in the first plaintext output; or, the codebook includes a second codebook, which is used to represent the correspondence between each word encoding in the word encoding list of the language model and the second ciphertext, the first ciphertext input is composed of the second ciphertext corresponding to the word encoding of each word in the first plaintext input, and the first ciphertext output is composed of the second ciphertext corresponding to the word encoding of each word in the first plaintext output.
[0018] Optionally, for any word-unit in the word-unit list, the first ciphertext corresponding to the word-unit is a word-unit in the word-unit list that is different from the word-unit.
[0019] Optionally, the step of constructing a codebook for the language model includes: obtaining the first codebook by an artificially defined method; or obtaining the first codebook by iteratively executing the following process: traversing the word-unit list, and for a currently traversed word-unit, randomly selecting a word-unit in the word-unit list that has not been selected and is different from the word-unit as the first ciphertext corresponding to the word-unit.
[0020] Optionally, the step of constructing a codebook for the language model includes: for any word in the word list, using a hash value obtained by hashing the word using a hash algorithm as the first ciphertext corresponding to the word, or using an encryption result obtained by encrypting the word using an encryption algorithm as the first ciphertext corresponding to the word.
[0021] Optionally, for any word unit code in the word unit code list, the second ciphertext corresponding to the word unit code is a word unit code different from the word unit code among all word unit codes.
[0022] Optionally, the step of constructing a codebook for the language model includes: obtaining the second codebook by an artificially defined method; or obtaining the second codebook by iteratively executing the following process: traversing the word unit encoding list, and for the word unit encoding currently traversed, randomly selecting a word unit encoding in the word unit encoding list that has not been selected and is different from the word unit encoding as the second ciphertext corresponding to the word unit encoding.
[0023] Optionally, the step of constructing a codebook for the language model includes: for any word unit code in the word unit code list, using a hash value obtained by hashing the word unit code using a hash algorithm as the second ciphertext corresponding to the word unit code, or using an encryption result obtained by encrypting the word unit code using an encryption algorithm as the second ciphertext corresponding to the word unit code.
[0024] Optionally, the method also includes: replacing the second plaintext input with a second ciphertext input using the first codebook or the second codebook; the second ciphertext input is composed of the first ciphertext corresponding to each word in the second plaintext input, or the second ciphertext input is composed of the second ciphertext corresponding to the word encoding of each word in the second plaintext input; sending the second ciphertext input to the model party, so that the model party processes the second ciphertext input using the fine-tuned language model to obtain a second ciphertext output corresponding to the second ciphertext input; receiving the second ciphertext output sent by the model party; and replacing the second ciphertext output with the second plaintext output using the first codebook or the second codebook.
[0025] Optionally, the ciphertext fine-tuning data and the second ciphertext input are both obtained using the first codebook, the second ciphertext output includes one or more first ciphertexts, and the step of using the first codebook or the second codebook to obtain a second plaintext output corresponding to the second ciphertext output includes: using the first codebook to replace each first ciphertext in the second ciphertext output with a corresponding word element to obtain the second plaintext output.
[0026] Optionally, the ciphertext fine-tuning data and the second ciphertext input are both obtained using the second codebook, the second ciphertext output includes one or more second ciphertexts, and the step of using the first codebook or the second codebook to obtain a second plaintext output corresponding to the second ciphertext output includes: using the second codebook to replace each second ciphertext in the second ciphertext output with a corresponding word element code; based on the correspondence between the word element code in the word element code list and the word elements in the word element list, further replacing the replaced word element code with the corresponding word element to obtain the second plaintext output.
[0027] According to a third aspect of the present disclosure, a model fine-tuning device is provided, comprising: a first acquisition module, used to acquire at least one ciphertext fine-tuning data; the ciphertext fine-tuning data is ciphertext data obtained by replacing plaintext fine-tuning data with a code book by a data party; each of the plaintext fine-tuning data comprises a first plaintext input and a first plaintext output, and each of the ciphertext fine-tuning data comprises a first ciphertext input obtained by replacing the first plaintext input with the code book and a first ciphertext output obtained by replacing the first plaintext output with the code book; a fine-tuning module, used to fine-tune the language model using the at least one ciphertext fine-tuning data; wherein the fine-tuning module adjusts the language model with the goal of reducing the difference between the output obtained by the language model processing the first ciphertext input and the first ciphertext output.
[0028] Optionally, the codebook includes a first codebook, which is used to represent the correspondence between each word in the word list of the language model and the first ciphertext, the first ciphertext input is composed of the first ciphertext corresponding to each word in the first plaintext input, and the first ciphertext output is composed of the first ciphertext corresponding to each word in the first plaintext output; or the codebook includes a second codebook, which is used to represent the correspondence between each word encoding in the word encoding list of the language model and the second ciphertext, the first ciphertext input is composed of the second ciphertext corresponding to the word encoding of each word in the first plaintext input, and the first ciphertext output is composed of the second ciphertext corresponding to the word encoding of each word in the first plaintext output.
[0029] Optionally, for any word-unit in the word-unit list, the first ciphertext corresponding to the word-unit is a word-unit in the word-unit list that is different from the word-unit.
[0030] Optionally, the first codebook is obtained in an artificially defined manner; or the first codebook is obtained by iteratively executing the following process: traversing the word-unit list, and for the currently traversed word-unit, randomly selecting a word-unit in the word-unit list that has not been selected and is different from the word-unit as the first ciphertext corresponding to the word-unit.
[0031] Optionally, for any word in the word list, the first ciphertext corresponding to the word is a hash value obtained by hashing the word using a hash algorithm, or the first ciphertext corresponding to the word is an encryption result obtained by encrypting the word using an encryption algorithm.
[0032] Optionally, for any word unit code in the word unit code list, the second ciphertext corresponding to the word unit code is a word unit code different from the word unit code among all word unit codes.
[0033] Optionally, the second codebook is obtained in an artificially defined manner; or the second codebook is obtained by iteratively executing the following process: traversing the word unit encoding list, and for the word unit encoding currently traversed, randomly selecting a word unit encoding in the word unit encoding list that has not been selected and is different from the word unit encoding as the second ciphertext corresponding to the word unit encoding.
[0034] Optionally, for any word unit code in the word unit code list, the second ciphertext corresponding to the word unit code is a hash value obtained by hashing the word unit code using a hash algorithm, or the second ciphertext corresponding to the word unit code is an encryption result obtained by encrypting the word unit code using an encryption algorithm.
[0035] Optionally, the device also includes: a second acquisition module, used to obtain a second ciphertext input, where the second ciphertext input is ciphertext data obtained by the data party replacing the second plaintext input with the first code book or the second code book; the second ciphertext input is composed of the first ciphertext corresponding to each word element in the second plaintext input, or the second ciphertext input is composed of the second ciphertext corresponding to the word element encoding of each word element in the second plaintext input; a processing module, used to process the second ciphertext input using the fine-tuned language model to obtain a second ciphertext output corresponding to the second ciphertext input; and a sending module, used to send the second ciphertext output to the data party.
[0036] According to a fourth aspect of the present disclosure, a model fine-tuning device is provided, comprising: a construction module, configured to construct a code book for a language model; a first replacement module, configured to replace at least one piece of plaintext fine-tuning data with corresponding ciphertext fine-tuning data using the code book; each piece of the plaintext fine-tuning data comprises a first plaintext input and a first plaintext output, and each piece of the ciphertext fine-tuning data comprises a first ciphertext input obtained by replacing the first plaintext input with the code book and a first ciphertext output obtained by replacing the first plaintext output with the code book; and a sending module, configured to send the ciphertext fine-tuning data to a model party, so that the model party fine-tunes the language model based on the ciphertext fine-tuning data.
[0037] Optionally, the codebook includes a first codebook, which is used to represent the correspondence between each word in the word list of the language model and the first ciphertext, the first ciphertext input is composed of the first ciphertext corresponding to each word in the first plaintext input, and the first ciphertext output is composed of the first ciphertext corresponding to each word in the first plaintext output; or, the codebook includes a second codebook, which is used to represent the correspondence between each word encoding in the word encoding list of the language model and the second ciphertext, the first ciphertext input is composed of the second ciphertext corresponding to the word encoding of each word in the first plaintext input, and the first ciphertext output is composed of the second ciphertext corresponding to the word encoding of each word in the first plaintext output.
[0038] Optionally, for any word-unit in the word-unit list, the first ciphertext corresponding to the word-unit is a word-unit in the word-unit list that is different from the word-unit.
[0039] Optionally, the construction module obtains the first codebook in an artificially defined manner; or the construction module obtains the first codebook by iteratively executing the following process: traversing the word-element list, and for the currently traversed word-element, randomly selecting a word-element in the word-element list that has not been selected and is different from the word-element as the first ciphertext corresponding to the word-element.
[0040] Optionally, the construction module uses, for any word in the word list, a hash value obtained by hashing the word using a hash algorithm as the first ciphertext corresponding to the word, or uses an encryption result obtained by encrypting the word using an encryption algorithm as the first ciphertext corresponding to the word.
[0041] Optionally, for any word unit code in the word unit code list, the second ciphertext corresponding to the word unit code is a word unit code different from the word unit code among all word unit codes.
[0042] Optionally, the construction module obtains the second codebook in an artificially defined manner; or the construction module obtains the second codebook by iteratively executing the following process: traversing the word-unit encoding list, and for the word-unit encoding currently traversed, randomly selecting a word-unit encoding in the word-unit encoding list that has not been selected and is different from the word-unit encoding as the second ciphertext corresponding to the word-unit encoding.
[0043] Optionally, the construction module uses, for any word code in the word code list, a hash value obtained by hashing the word code using a hash algorithm as the second ciphertext corresponding to the word code, or uses an encryption result obtained by encrypting the word code using an encryption algorithm as the second ciphertext corresponding to the word code.
[0044] Optionally, the device also includes: a second replacement module, used to replace the second plaintext input with a second ciphertext input using the first codebook or the second codebook; the second ciphertext input is composed of the first ciphertext corresponding to each word in the second plaintext input, or the second ciphertext input is composed of the second ciphertext corresponding to the word encoding of each word in the second plaintext input; the sending module sends the second ciphertext input to the model party, so that the model party processes the second ciphertext input using the fine-tuned language model to obtain a second ciphertext output corresponding to the second ciphertext input; the device also includes: a receiving module, used to receive the second ciphertext output sent by the model party; a third replacement module, used to replace the second ciphertext output with a second plaintext output using the first codebook or the second codebook.
[0045] Optionally, the ciphertext fine-tuning data and the second ciphertext input are both obtained using the first codebook, the second ciphertext output includes one or more first ciphertexts, and the third replacement module uses the first codebook to replace each first ciphertext in the second ciphertext output with a corresponding word element to obtain the second plaintext output.
[0046] Optionally, the ciphertext fine-tuning data and the second ciphertext input are both obtained using the second codebook, the second ciphertext output includes one or more second ciphertexts, and the third replacement module uses the second codebook to replace each second ciphertext in the second ciphertext output with a corresponding word element code, and based on the correspondence between the word element codes in the word element code list and the words in the word element list, the replaced word element codes are further replaced with corresponding words to obtain the second plaintext output.
[0047] According to a fifth aspect of the present disclosure, a computing device is provided, comprising: a processor; and a memory on which executable code is stored, and when the executable code is executed by the processor, the processor executes the method described in the first aspect or the second aspect above.
[0048] According to a sixth aspect of the present disclosure, a computer program product is provided, comprising an executable code. When the executable code is executed by a processor of an electronic device, the processor is caused to execute the method described in the first aspect or the second aspect above.
[0049] According to a seventh aspect of the present disclosure, a non-temporary machine-readable storage medium is provided, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor executes the method described in the first aspect or the second aspect above.
[0050] The present disclosure uses a codebook to replace plaintext fine-tuning data with ciphertext fine-tuning data, and fine-tunes the language model based on the ciphertext fine-tuning data, so that the model party can achieve fine-tuning without contacting the plaintext fine-tuning data of the data party, thereby protecting data privacy while making the fine-tuned model match the vertical scenario of the data party. In addition, the codebook is applicable to various types of language models, has no restrictions on model use, and can be well compatible with existing basic language models. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] The above and other objects, features and advantages of the present disclosure will become more apparent through a more detailed description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, wherein like reference numerals generally represent like components in the exemplary embodiments of the present disclosure.
[0052] Figure 1 is a schematic flowchart showing a model fine-tuning method according to an embodiment of the present disclosure.
[0053] Figure 2 is a schematic flow chart showing a model fine-tuning method according to another embodiment of the present disclosure.
[0054] Figure 3 It is a schematic diagram showing the structure of a model fine-tuning device according to an embodiment of the present disclosure.
[0055] Figure 4 is a schematic diagram showing the structure of a model fine-tuning device according to another embodiment of the present disclosure.
[0056] Figure 5 A schematic diagram of the structure of a computing device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0057] The preferred embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the preferred embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.
[0058] Building and training your own LLM from scratch for your own use can certainly avoid the problem of leaking user privacy and property, but the cost is extremely expensive and unacceptable. In addition, when developing your own LLM, you will repeat the results that have already been achieved in the industry, resulting in a waste of resources. This is also the reason why there are only a handful of manufacturers in the market that have the ability to develop their own LLMs, and other smaller users are unable to develop their own LLMs.
[0059] There are some open source LLMs in the open source community, such as Meta's Llama, xAI's Grok, and China's Qwen. The existence of open source models effectively lowers the threshold, allowing users who do not have sufficient computing resources and professional knowledge to easily obtain, use, and modify these models to solve their own problems. However, it is undeniable that in most cases, the capabilities of open source models are generally inferior to closed source commercial models.
[0060] In most cases, users prefer to use LLMs with stronger capabilities to better complete tasks, that is, they choose to use a closed-source business model, but this causes users to put their data privacy at risk.
[0061] Homomorphic encryption (e.g., fully homomorphic encryption) is an innovative encryption technology that provides a unique ability to perform computations while data is encrypted, which is critical for protecting data privacy while allowing data processing. Homomorphic encryption has a wide range of applications, especially in the field of cloud computing and privacy-preserving data processing, as users can use cloud computing resources for data processing without trusting the service provider. Homomorphic encryption can be divided into partial homomorphic encryption and hierarchical homomorphic encryption, which support an unlimited number of operations of a single type (e.g., only addition or only multiplication) or a limited number of addition and multiplication operations on encrypted data, respectively. However, these forms of homomorphic encryption have certain limitations in practical applications because they do not support arbitrarily complex computations. In other words, when using homomorphic encryption technology, there are many requirements for model and business restrictions, which cannot adapt well to the rapid iteration and development of the industry.
[0062] In view of this, the present disclosure proposes that the data party replaces the plaintext fine-tuning data with the ciphertext fine-tuning data based on the codebook constructed for the language model, and sends the ciphertext fine-tuning data to the model party, and the model party fine-tunes the language model based on the ciphertext fine-tuning data. The codebook represents the replacement rules between plaintext data and ciphertext data. The codebook is applicable to various language models, does not require any technical changes to the language model, and can be well compatible with the existing basic models. In terms of resource waste, it can also solve the problem of concurrent investment in the basic model to a large extent. In terms of model effect, according to the existing fine-tuning data, the accuracy of ciphertext fine-tuning and plaintext fine-tuning is basically close. Ciphertext fine-tuning affects the initial accuracy and prompts, and plaintext fine-tuning can have a higher initial accuracy and good prompts compatibility. Therefore, by increasing the amount of data for ciphertext fine-tuning, an effect basically close to that of plaintext fine-tuning can be achieved.
[0063] It should be noted that prompts can be called prompt words, and their function is to help the model "recall" what it has "learned" during pre-training. For the large language model, the prompt is the user's input, which can be a simple question, a long text, or a set of instructions, depending on the user's specific needs. When the large language model generates content, it will first process the prompt and then output it based on its understanding of it.
[0064] The details involved in the present disclosure are further described below.
[0065] Figure 1 is a schematic flowchart showing a model fine-tuning method according to an embodiment of the present disclosure. Figure 1 The execution subject of the method shown may be a model party or a business party. A model party or a business party refers to a party that has language model technical capabilities. The model party or the business party has the ability to fine-tune the model and may have a basic language model, which may be self-developed and may be a closed-source business model with strong capabilities. The model party may provide the data party with a model fine-tuning service based on business data in vertical scenarios, so that the fine-tuned language model is suitable for the vertical scenarios of the data party. Among them, the data party refers to the party that provides the data, which may be a party that owns the data but usually does not have language model technology. For example, the data party may be, but is not limited to, an enterprise party such as medical, banking, and social that has business data and has strong data privacy protection needs. Vertical scenarios, that is, vertical scenarios, refer to scenarios that focus on a specific application field or industry segment. The language model in the present disclosure may refer to a large language model LLM.
[0066] See also Figure 1 , in step S110, at least one ciphertext fine-tuning data is obtained.
[0067] The ciphertext fine-tuning data is the ciphertext data obtained by replacing the plaintext fine-tuning data with the code book by the data party.
[0068] In order to protect data privacy, the data party's data, namely the plaintext fine-tuning data, is not directly provided to the model party. What is provided to the model party is the ciphertext fine-tuning data obtained after processing the original plaintext fine-tuning data. Specifically, the data party uses the code book to replace the plaintext fine-tuning data to obtain the ciphertext data, thereby effectively protecting the privacy of the data.
[0069] Each plaintext fine-tuning data includes a first plaintext input and a first plaintext output. The first plaintext input is used to represent the question (i.e., query) that the model is expected to process, and the first plaintext output is used to represent the standard answer (i.e., response) corresponding to the question. The first plaintext input and the first plaintext output form a plaintext query / response pair. The first plaintext input can be regarded as a sample input, and the second plaintext output can be regarded as a sample mark or sample label.
[0070] Each ciphertext fine-tuning data includes a first ciphertext input and a first ciphertext output. The first ciphertext input is obtained by replacing the first plaintext input by the data party using the cipher book. The first ciphertext output is obtained by replacing the first plaintext output by the data party using the cipher book. That is, the first ciphertext input and the first ciphertext output constitute a ciphertext query / response pair.
[0071] The ciphertext fine-tuning data can be prepared by the data party and provided to the model party. That is, the model party can obtain the ciphertext fine-tuning data from the data party. That is, the model party can receive the ciphertext fine-tuning data sent by the data party.
[0072] A language model usually has a list of tokens and a list of token encodings. A token represents the smallest semantic unit. A token can be a single character or a sequence of multiple characters. The token encoding (rank) is a unique index assigned to a token inside the model. The token encoding is usually an integer value that uniquely identifies a token in the token list. The token encoding is usually the actual representation used by the model when processing and generating text. The token encoding is usually invisible to the user.
[0073] For a piece of text input, the input text is usually first divided into tokens using a tokenizer, and then these tokens are mapped to corresponding token codes. The token codes are then converted into embedded representations (i.e., Embeddings), and then these embedded representations are processed by the language model to obtain the generated token codes. The generated token codes are converted into corresponding tokens and displayed to the user as the final model output.
[0074] The present disclosure proposes two types of codebooks, namely, a first codebook and a second codebook, in combination with the characteristics of the language model.
[0075] The first codebook is used to characterize the correspondence between each word in the word list of the language model and the first ciphertext. Taking the data party using the first codebook to replace the plaintext fine-tuning data to obtain the ciphertext fine-tuning data as an example, the first ciphertext input is composed of the first ciphertext corresponding to each word in the first plaintext input, and the first ciphertext output is composed of the first ciphertext corresponding to each word in the first plaintext output. For example, assume that the codebook is defined as: I-you; of-place; desktop-shop; computer-plane; host-sky; need-what; install-washing machine; cable-nonsense. Among them, the word before the symbol "-" is the word, and the word after the symbol "-" is the corresponding ciphertext. Then, the plaintext fine-tuning data "My desktop computer host needs to install cable" (such as plaintext input or plaintext output) can be replaced by the ciphertext fine-tuning data "Your shop, plane, sky, what washing machine, nonsense" according to the codebook, and the replaced sentence "Your shop, plane, sky, what washing machine, nonsense" is provided to the model party for model fine-tuning without leaking the plaintext fine-tuning data.
[0076] The data provider can construct a first codebook for the word list of the language model. There are many specific construction methods.
[0077] Exemplarily, the data party may obtain the first codebook in an artificially defined manner. That is, the first codebook may be obtained in an artificially defined manner. For example, for the language model to be fine-tuned, the word list of the language model may be first obtained, and then for each word in the word list, the first ciphertext corresponding to the word may be artificially defined, so that the first codebook may be obtained. Among them, the first ciphertext defined for a certain word may be other words in the word list that are different from the word. That is, for any word in the word list, the first ciphertext corresponding to the word may be a word in the word list that is different from the word. In other words, all first ciphertexts may be words taken from the word list.
[0078] Exemplarily, the data party may also use a random algorithm to construct the first codebook. Specifically, the word list of the language model may be traversed, and for the currently traversed word, a word in the word list that has not been selected and is different from the word is randomly selected as the first ciphertext corresponding to the word. In this way, the first codebook can be obtained.
[0079] When the first codebook is constructed by the above two exemplary construction methods, if the first ciphertexts in the first codebook are all taken from the word elements in the word element list, then for the language model, the first ciphertext can still be identified based on the existing word element encoding list, so the existing word element encoding list of the model can be directly used without constructing a new word element encoding list for the first ciphertext.
[0080] Exemplarily, the data party may also use a hash algorithm or an encryption algorithm to construct the first code book. That is to say, for any word in the word list, the hash value obtained by hashing the word using the hash algorithm can be used as the first ciphertext corresponding to the word, or the encryption result obtained by encrypting the word using the encryption algorithm can be used as the first ciphertext corresponding to the word. The encryption algorithm may use but is not limited to the DES / AES function. When using a hash algorithm or an encryption algorithm to construct the first code book, a hash conflict resolution method or an encryption conflict resolution method may be used to ensure that there is a unique correspondence between the word and the first ciphertext, thereby avoiding the situation where one first ciphertext corresponds to multiple word elements.
[0081] When the data party uses a hash algorithm or an encryption algorithm to construct the first codebook, the first ciphertext is usually a string of words that do not belong to the word list. Therefore, the model party can regard the first ciphertext as a new word and design a new word encoding for the first ciphertext.
[0082] The second codebook is used to characterize the correspondence between each word unit code in the word unit code list of the language model and the second ciphertext. Each word unit in the word unit list of the language model has a corresponding word unit code. The word unit code list is a list composed of the codes of all words in the word unit list (i.e., a token code list). Generally, the word unit code rank corresponding to a token is an integer value. For example, the token code list corresponding to the token list {my; desktop; computer; host; need; install; row; line} can be {97611; 53938,; 28330; 104145; 110293; 85106; 103956; 59956; 43268}. Taking the example of the data party using the second code book to replace the plaintext fine-tuning data to obtain the ciphertext fine-tuning data, the first ciphertext input is composed of the second ciphertext corresponding to the word-element encoding of each word-element in the first plaintext input, and the first ciphertext output is composed of the second ciphertext corresponding to the word-element encoding of each word-element in the first plaintext output.
[0083] The data provider can construct a second codebook for the word encoding list of the language model. The construction method of the second codebook is similar to the construction method of the first codebook, and there are also multiple construction methods.
[0084] Exemplarily, the data party may obtain the second codebook in a manually defined manner. That is, the second codebook may be obtained in a manually defined manner. For example, for a language model to be fine-tuned, the word unit encoding list of the language model may be first obtained, and then for each word unit encoding in the word unit encoding list, the second ciphertext corresponding to the word unit encoding may be manually defined, so as to obtain the second codebook. Among them, the second ciphertext defined for a certain word unit encoding may be other word unit encodings in the word unit encoding list that are different from the word unit encoding.
[0085] Exemplarily, the data party may also use a random algorithm to construct the second codebook. Specifically, the word unit encoding list of the language model may be traversed, and for the word unit encoding currently traversed, a word unit encoding that has not been selected in the word unit encoding list and is different from the word unit encoding may be randomly selected using a random algorithm as the second ciphertext corresponding to the word unit encoding. In this way, the second codebook may be obtained.
[0086] Exemplarily, the data party may also use a hash algorithm or an encryption algorithm to construct a second codebook. That is to say, for any word meta code in the word meta code list, the hash value obtained by hashing the word meta code using the hash algorithm can be used as the second ciphertext corresponding to the word meta code, or the encryption result obtained by encrypting the word meta code using the encryption algorithm can be used as the second ciphertext corresponding to the word meta code. The encryption algorithm may use but is not limited to the DES / AES function. When using a hash algorithm or an encryption algorithm to construct the second codebook, a hash conflict resolution method or an encryption conflict resolution method may be used to ensure that the word meta code and the second ciphertext have a unique correspondence, thereby avoiding the situation where one second ciphertext corresponds to multiple word meta codes.
[0087] In step S120, the language model is fine-tuned using at least one piece of ciphertext fine-tuning data.
[0088] During the fine-tuning process, the language model may be adjusted with the goal of reducing the difference between the output obtained by the language model processing the first ciphertext input and the first ciphertext output. For example, a loss function may be constructed based on the difference between the output obtained by the language model processing the first ciphertext input and the first ciphertext output, and the model parameters of the language model may be adjusted with the goal of making the function value of the loss function as small as possible. The function value of the loss function is positively correlated with the difference.
[0089] By using a codebook to replace the plaintext fine-tuning data with the ciphertext fine-tuning data and fine-tuning the model accordingly, the model party can achieve fine-tuning without contacting the plaintext fine-tuning data of the data party, so that the fine-tuned model can match the vertical scenarios of the data party.
[0090] After the fine-tuning phase is over, the model party can also use the fine-tuned language model to provide model services to the data party. For example, the model party can provide the data party with a calling interface for the fine-tuned language model, so that the data party can provide model question-and-answer services in vertical scenarios based on the calling interface.
[0091] Since the model fine-tuning stage uses ciphertext fine-tuning data for training, the application stage (i.e., model inference stage) also needs to be consistent with the model fine-tuning stage in inference of the ciphertext data and obtain the ciphertext output (i.e., the ciphertext inference result). For the ciphertext output, the data party can use the codebook to convert it into plaintext output.
[0092] Specifically, the model party can also obtain a second ciphertext input, process the second ciphertext input using the fine-tuned language model, obtain a second ciphertext output corresponding to the second ciphertext input, and send the second ciphertext output to the data party, which replaces the second ciphertext output with the corresponding plaintext output.
[0093] The second ciphertext input is the ciphertext data obtained by replacing the second plaintext input with the same codebook (such as the first codebook or the second codebook) as the codebook used in the model fine-tuning stage. The second plaintext input is used to represent the question raised by the user. Taking the second ciphertext input obtained by replacing the second plaintext input with the first codebook as an example, the second ciphertext input can be composed of the first ciphertext corresponding to each word unit in the second plaintext input. Taking the second ciphertext input obtained by replacing the second plaintext input with the first codebook as an example, the second ciphertext input can be composed of the second ciphertext corresponding to the word unit encoding of each word unit in the second plaintext input.
[0094] Figure 2 is a schematic flow chart showing a model fine-tuning method according to another embodiment of the present disclosure. Figure 2 The execution subject of the method shown is the data party. The data party refers to the party that provides the data, which may be the party that owns the data but usually does not have the language model technology. For example, the data party may be, but is not limited to, an enterprise party that owns business data and has strong data privacy protection needs, such as medical, banking, and social networking. The following is a brief description of the operation process that the data party can perform. For the details involved, please refer to the relevant description above, which will not be repeated here.
[0095] See also Figure 2 , in step S210, a codebook is constructed for the language model.
[0096] The code book is used to replace the plaintext data to obtain the ciphertext data. The code book may include a first code book or a second code book. For the first code book, the second code book and their construction principles, please refer to the relevant description above.
[0097] Taking the language model as a large model A as an example, we can first obtain the token list (i.e., word list) and rank list (i.e., word encoding list) of the large model A. Among them, each token has a unique corresponding rank. The token list and rank list can be provided directly by the model party, or obtained by the data party by parsing the relevant model files. For example, the token file of the large model A can be parsed, and this file is divided into two columns: token and rank. The token can be obtained by space splitting, and then a readable token list can be obtained by base64 decoding. After obtaining the word list and word encoding list of the language model, the codebook can be constructed according to the various methods mentioned above.
[0098] In step S220, at least one piece of plaintext fine-tuning data is replaced with corresponding ciphertext fine-tuning data using the code book.
[0099] Plain text fine-tuning data refers to question-answer pairs that meet the vertical scenarios of the data party, that is, query / response pairs.
[0100] Taking the intelligent customer service scenario as an example, a query can be defined as the problem described by the customer when he calls, and a response can be defined as the answer given by the customer service. For example, query: My desktop computer host needs to be installed with cables. Response: Desktop assembly. Another example, query: Are you in Liangxi District, Wuxi? I need a faucet repair at home. Response: Water and electricity repair. Among them, the response in these two examples represents the user intent corresponding to the query, and the response can be used by the model to further provide services that match the user intent. In other words, for user problems, the big model can be used to process the problem first to obtain the user intent, and then the big model or other models or other applications can call the corresponding plug-in service according to the user intent to provide the user with the corresponding service, so as to finally solve the user problem.
[0101] By defining a query / response pair, one or more plaintext fine-tuning data can be obtained.
[0102] After obtaining the plaintext fine-tuning data, the plaintext fine-tuning data can first be preprocessed to cut the query / response (corresponding to the first plaintext input / first plaintext output mentioned above) in the plaintext fine-tuning data into tokens, and the word unit encoding corresponding to the token can be statistically obtained.
[0103] Data preprocessing is to segment the query / response based on the token list to ensure that all words are in the token list. For words in the query / response that are not in the token list, you can set them as default tokens. In this way, you can get the token list corresponding to the query / response.
[0104] For example, "My desktop computer host needs to install a cable" can be divided into the following token list: my, desktop, computer, host, needs, to, install, cable. The corresponding rank value is the encoding list: 97611, 53938, 28330, 104145, 110293, 85106, 103956, 59956, 43268.
[0105] The core of converting plaintext query / response to ciphertext query / response is encryption or replacement. According to the input information, it can be divided into plaintext query / response replacement and token encoding replacement. According to the replacement method, it can be divided into codebook replacement, hash algorithm replacement, encryption algorithm replacement, and random algorithm replacement. The following describes them respectively.
[0106] 1) Password replacement for plaintext query / response
[0107] For example, the codebook can be defined as: I—you, your—place, desktop—shop, computer—plane, host—sky, need—what, install—washing machine, cable—nonsense. That is, "My desktop computer host needs to install a cable" is replaced with "your place shop plane sky what washing machine nonsense" according to the codebook, and the replaced sentence "your place shop plane sky what washing machine nonsense" is provided to the outside for model fine-tuning.
[0108] 2) Hash replacement of plaintext query / response
[0109] The processes of hash replacement and codebook replacement are similar, except that the codebook is generated in different ways. In the codebook replacement method, the codebook is generated by manually constructed plaintext / ciphertext matching pairs, while the codebook in hash replacement is generated by hash algorithm and hash conflict resolution. For example, the codebook hash can be automatically generated in the manner of md5sum(query / response)%N.
[0110] 3) Replace the encryption algorithm of plaintext query / response
[0111] The process and logic of encryption algorithm replacement and hash replacement are similar. The only difference is that the hash function is replaced with the encryption algorithm DES / AES function, and the codebook is obtained by using the encryption conflict resolution method to realize the encryption algorithm generation of the codebook.
[0112] 4) Random algorithm replacement of plaintext query / response
[0113] The process and logic of random algorithm replacement and encryption algorithm replacement are similar. The only difference is that a random one is selected from the remaining replaceable tokens to obtain a complete codebook, which can realize the random algorithm generation of the codebook.
[0114] The above methods 1) to 4) refer to plaintext query / response replacement, and the codebook mentioned corresponds to the first codebook mentioned above. When using method 2) or method 3) to replace the plaintext query / response, you can first use a hash algorithm or an encryption algorithm to generate corresponding ciphertexts for each token in the token list to obtain a codebook, and then use the codebook to replace the plaintext query / response with the ciphertext query / response by looking up a table. You can also directly execute a hash algorithm or an encryption algorithm on each token in the plaintext query / response to obtain the ciphertext query / response.
[0115] 5) Token Coded Codebook Replacement
[0116] Using the codebook between token codes, replace the token code list "97611, 53938, 28330, 104145, 110293, 85106, 103956, 59956, 43268" with the new token code list "97600, 53927, 28329, 104134, 110282, 85195, 103945, 59945, 43257".
[0117] The codebook between token encodings can be generated by manually specifying it.
[0118] 6) Token code hash replacement. That is, ciphertext token code = hash (token code) % N.
[0119] 7) Replace the encryption algorithm of the token code, that is, the ciphertext token code = DES (token code) % N.
[0120] 8) Token code is replaced by a random algorithm. That is, the ciphertext token code is randomly extracted from the current remaining token codes.
[0121] The above methods 1) to 4) refer to the replacement of the token code corresponding to the plaintext query / response, and the codebook mentioned corresponds to the second codebook mentioned above. When using method 6) or method 7) to replace the token code of the plaintext query / response, you can first use a hash algorithm or an encryption algorithm to generate the corresponding ciphertext for the token code corresponding to each token in the token list to obtain a codebook, and then use the codebook to replace the plaintext token code with the ciphertext token code by looking up the table. You can also directly execute a hash algorithm or an encryption algorithm on the token code corresponding to each token in the plaintext query / response to obtain the ciphertext token code.
[0122] In step S230, the ciphertext fine-tuning data is sent to the model party, so that the model party can fine-tune the language model based on the ciphertext fine-tuning data. After fine-tuning, the fine-tuned language model can be deployed for reasoning. The present disclosure does not impose any special restrictions on the model fine-tuning or model deployment process. It should be noted that the amount of fine-tuning data required during the fine-tuning stage will increase. For example, in the case of plaintext fine-tuning, 50,000 pieces of data are required, while in the case of ciphertext fine-tuning, the data may be expanded several to dozens of times depending on different business scenarios. Among them, the replacement of plaintext query / response is more commonly used, which is simple and direct to protect private data. The token encoding replacement operation is more complicated and requires direct modification of the model token encoding.
[0123] After the deployment is completed, that is, after the model is online, the data party can also use the codebook (such as the first codebook or the second codebook) to replace the second plaintext input with the second ciphertext input. For the second plaintext input and the second ciphertext input, please refer to the relevant description above. It can be a token replacement or a token encoding replacement. The replacement method or encryption method is consistent with the model fine-tuning stage. Then, the data party can send the second ciphertext input to the model party, so that the model party can use the fine-tuned language model to process the second ciphertext input to obtain the second ciphertext output corresponding to the second ciphertext input. Then, the data party can receive the second ciphertext output sent by the model party. Finally, the data party can use the codebook (such as the first codebook or the second codebook) to replace (i.e., decrypt) the second ciphertext output with the second plaintext output.
[0124] Taking the case where both the ciphertext fine-tuning data and the second ciphertext input are obtained using the first codebook, the first codebook can be used to replace each first ciphertext in the second ciphertext output with a corresponding word element to obtain the second plaintext output. For example, for the ciphertext output "Your store, airplane, sky, what washing machine, nonsense", it can be decrypted according to the codebook (i.e., the first codebook) into the plaintext output "My desktop computer host needs to install a cable".
[0125] Taking the example that both the ciphertext fine-tuning data and the second ciphertext input are obtained using the second codebook, the second codebook can be used to first replace each second ciphertext in the second ciphertext output with the corresponding word-unit code, and then based on the correspondence between the word-unit codes in the word-unit code list and the words in the word-unit list, the replaced word-unit codes can be further replaced with the corresponding words to obtain the second plaintext output.
[0126] In summary, the present disclosure as a whole may involve two stages, namely, a fine-tuning stage and an application stage.
[0127] The fine-tuning phase (i.e., training phase) can be expressed as: ciphertext fine-tuning data = encryption method (plaintext fine-tuning data); ciphertext model = training (ciphertext fine-tuning data). That is, the plaintext fine-tuning data is converted into ciphertext fine-tuning data using the codebook, and then the ciphertext fine-tuning data is used to train the basic model to obtain a ciphertext model suitable for processing ciphertext data.
[0128] The application phase (i.e., the reasoning phase) can be expressed as: deployment (ciphertext model); ciphertext input = encryption method (plaintext input); ciphertext response = reasoning (ciphertext input); plaintext response = decryption method (ciphertext response). That is, the fine-tuned ciphertext model is deployed as an online application, and the user's plaintext input is converted into ciphertext input using the same encryption method (i.e., the same codebook) as in the fine-tuning phase. Then, the deployed ciphertext model is used for reasoning to obtain the ciphertext response (i.e., ciphertext output), and then the ciphertext response is converted into a plaintext response (i.e., plaintext output) using the decryption method (i.e., the same codebook) that is consistent with the encryption method in the fine-tuning phase. The final plaintext response can be provided to the user.
[0129] By testing the model with or without encryption logic, we found that the inference effect can be slightly reduced or basically the same, thus proving the effectiveness of the disclosed method. It should be noted that the amount of data required for the encryption method will increase. If the effect is not good, you can consider increasing the amount of data for more in-depth fine-tuning.
[0130] The model fine-tuning method disclosed in the present invention can also be implemented as a model fine-tuning device. The functional units of the model fine-tuning device can be implemented by hardware, software, or a combination of hardware and software that implements the principles of the present invention. The following is a brief description of the functional units that the model fine-tuning device can have and the operations that each functional unit can perform. For the details involved, please refer to the relevant description above, which will not be repeated here. It can be understood by those skilled in the art that the functional units described in this article can be combined or divided into sub-units to implement the principles of the above invention. Therefore, the description herein can support any possible combination, or division, or further limitation of the functional units described herein.
[0131] Figure 3 It is a schematic diagram showing the structure of a model fine-tuning device according to an embodiment of the present disclosure. Figure 3 The model fine-tuning device shown can be applied to the model side.
[0132] See also Figure 3 The model fine-tuning device 300 may include a first acquisition module 310 and a fine-tuning module 320 .
[0133] The first acquisition module 310 is used to obtain at least one ciphertext fine-tuning data. For the ciphertext fine-tuning data, please refer to the relevant description above. The fine-tuning module 320 is used to fine-tune the language model using at least one ciphertext fine-tuning data; wherein the fine-tuning module 320 can adjust the language model with the goal of reducing the difference between the output obtained by the language model processing the first ciphertext input and the first ciphertext output. For example, the fine-tuning module 320 can construct a loss function based on the difference between the output obtained by the language model processing the first ciphertext input and the first ciphertext output, and adjust the model parameters of the language model with the goal of making the function value of the loss function as small as possible.
[0134] The model fine-tuning device 300 may also include a second acquisition module, a processing module, and a sending module. The second acquisition module is used to obtain a second ciphertext input. For the second ciphertext input, please refer to the relevant description above. The processing module is used to process the second ciphertext input using the fine-tuned language model to obtain a second ciphertext output corresponding to the second ciphertext input. The sending module is used to send the second ciphertext output to the data party.
[0135] Figure 4 is a schematic diagram showing the structure of a model fine-tuning device according to another embodiment of the present disclosure. Figure 4 The model fine-tuning apparatus shown can be applied to the data cube.
[0136] See also Figure 4 The model fine-tuning device 400 may include a construction module 410 , a first replacement module 420 , and a sending module 430 .
[0137] The construction module 410 is used to construct a codebook for the language model, and the codebook is used to replace the plaintext data to obtain the ciphertext data. The codebook may include a first codebook or a second codebook. The construction process of the first codebook or the second codebook can refer to the above description.
[0138] The first replacement module 420 is used to replace at least one plaintext fine-tuning data with corresponding ciphertext fine-tuning data using the code book. The specific process of replacing the plaintext fine-tuning data with the ciphertext fine-tuning data can be found in the above related description.
[0139] The sending module 430 is used to send the ciphertext fine-tuning data to the model party, so that the model party can fine-tune the language model based on the ciphertext fine-tuning data.
[0140] The model fine-tuning device 400 may also include a second replacement module, a receiving module, and a third replacement module. The second replacement module is used to replace the second plaintext input with the second ciphertext input using the first codebook or the second codebook. The sending module sends the second ciphertext input to the model side, so that the model side processes the second ciphertext input using the fine-tuned language model to obtain a second ciphertext output corresponding to the second ciphertext input. The receiving module is used to receive the second ciphertext output sent by the model side. The third replacement module is used to replace the second ciphertext output with the second plaintext output using the first codebook or the second codebook.
[0141] Figure 5 A schematic diagram of the structure of a computing device that can be used to implement the above-mentioned model fine-tuning method according to an embodiment of the present disclosure is shown.
[0142] See also Figure 5 , the computing device 500 includes a memory 510 and a processor 520 .
[0143] The processor 520 may be a multi-core processor or may include multiple processors. In some embodiments, the processor 520 may include a general-purpose main processor and one or more special coprocessors, such as a graphics processing unit (GPU), a digital signal processor (DSP), etc. In some embodiments, the processor 520 may be implemented using a customized circuit, such as an application-specific integrated circuit (ASIC) or a field programmable gate array (FPGA).
[0144] The memory 510 may include various types of storage units, such as system memory, read-only memory (ROM), and permanent storage devices. Among them, ROM can store static data or instructions required by the processor 520 or other modules of the computer. The permanent storage device may be a readable and writable storage device. The permanent storage device may be a non-volatile storage device that does not lose the stored instructions and data even after the computer is powered off. In some embodiments, the permanent storage device uses a large-capacity storage device (such as a magnetic or optical disk, flash memory) as a permanent storage device. In some other embodiments, the permanent storage device may be a removable storage device (such as a floppy disk, optical drive). The system memory may be a readable and writable storage device or a volatile readable and writable storage device, such as a dynamic random access memory. The system memory may store some or all instructions and data required by the processor at runtime. In addition, the memory 510 may include any combination of computer-readable storage media, including various types of semiconductor memory chips (DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), and disks and / or optical disks may also be used. In some embodiments, the memory 510 may include a readable and / or writable removable storage device, such as a laser disc (CD), a read-only digital versatile disc (e.g., DVD-ROM, double-layer DVD-ROM), a read-only Blu-ray disc, an ultra-density optical disc, a flash memory card (e.g., SD card, mini SD card, Micro-SD card, etc.), a magnetic floppy disk, etc. The computer-readable storage medium does not include carrier waves and transient electronic signals transmitted wirelessly or wired.
[0145] The memory 510 stores executable codes, and when the executable codes are processed by the processor 520 , the processor 520 can execute the model fine-tuning method mentioned above.
[0146] The model fine-tuning method, device and apparatus according to the present disclosure have been described above in detail with reference to the accompanying drawings.
[0147] In addition, the method according to the present disclosure may also be implemented as a computer program or a computer program product, which includes computer program code instructions for executing the above steps defined in the above method of the present disclosure.
[0148] Alternatively, the present disclosure may also be implemented as a non-temporary machine-readable storage medium (or computer-readable storage medium, or machine-readable storage medium) on which executable code (or computer program, or computer instruction code) is stored. When the executable code (or computer program, or computer instruction code) is executed by a processor of an electronic device (or computing device, server, etc.), the processor executes the various steps of the above-mentioned method according to the present disclosure.
[0149] Those skilled in the art will further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or a combination of both.
[0150] The flow charts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the system and method according to multiple embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0151] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A model fine-tuning method, characterized in that: include: Obtain at least one piece of ciphertext fine-tuning data; The ciphertext fine-tuning data is the ciphertext data obtained by replacing the plaintext fine-tuning data with the code book by the data party; Each of the plaintext fine-tuning data includes a first plaintext input and a first plaintext output, and each of the ciphertext fine-tuning data includes a first ciphertext input obtained by replacing the first plaintext input with the cipher book and a first ciphertext output obtained by replacing the first plaintext output with the cipher book; The language model is fine-tuned using the at least one ciphertext fine-tuning data; wherein the language model is adjusted with the goal of reducing the difference between an output obtained by the language model processing the first ciphertext input and the first ciphertext output.
2. The method according to claim 1, characterized in that The codebook includes a first codebook, the first codebook is used to represent the correspondence between each word in the word list of the language model and the first ciphertext, the first ciphertext input is composed of the first ciphertext corresponding to each word in the first plaintext input, and the first ciphertext output is composed of the first ciphertext corresponding to each word in the first plaintext output; or The codebook includes a second codebook, which is used to represent the correspondence between each word element encoding in the word element encoding list of the language model and the second ciphertext, the first ciphertext input is composed of the second ciphertext corresponding to the word element encoding of each word element in the first plaintext input, and the first ciphertext output is composed of the second ciphertext corresponding to the word element encoding of each word element in the first plaintext output.
3. A model fine-tuning method, characterized in that: include: Construct a codebook for the language model; Using the code book, replacing at least one piece of plaintext fine-tuning data with corresponding ciphertext fine-tuning data; Each of the plaintext fine-tuning data includes a first plaintext input and a first plaintext output, and each of the ciphertext fine-tuning data includes a first ciphertext input obtained by replacing the first plaintext input with the cipher book and a first ciphertext output obtained by replacing the first plaintext output with the cipher book; The ciphertext fine-tuning data is sent to a model party, so that the model party fine-tunes the language model based on the ciphertext fine-tuning data.
4. The method according to claim 3, characterized in that The codebook includes a first codebook, the first codebook is used to represent the correspondence between each word in the word list of the language model and the first ciphertext, the first ciphertext input is composed of the first ciphertext corresponding to each word in the first plaintext input, and the first ciphertext output is composed of the first ciphertext corresponding to each word in the first plaintext output; or, The codebook includes a second codebook, which is used to represent the correspondence between each word element encoding in the word element encoding list of the language model and the second ciphertext, the first ciphertext input is composed of the second ciphertext corresponding to the word element encoding of each word element in the first plaintext input, and the first ciphertext output is composed of the second ciphertext corresponding to the word element encoding of each word element in the first plaintext output.
5. The method according to claim 4, characterized in that Also includes: Using the first codebook or the second codebook to replace the second plaintext input with the second ciphertext input; The second ciphertext input consists of the first ciphertext corresponding to each word unit in the second plaintext input, or the second ciphertext input consists of the second ciphertext corresponding to the word unit encoding of each word unit in the second plaintext input; Sending the second ciphertext input to the model side, so that the model side processes the second ciphertext input using the fine-tuned language model to obtain a second ciphertext output corresponding to the second ciphertext input; Receiving a second ciphertext output sent by the model party; The second ciphertext output is replaced with a second plaintext output using the first cipherbook or the second cipherbook.
6. A model fine-tuning device, characterized in that: include: A first acquisition module, used to acquire at least one piece of ciphertext fine-tuning data; The ciphertext fine-tuning data is the ciphertext data obtained by replacing the plaintext fine-tuning data with the code book by the data party; Each of the plaintext fine-tuning data includes a first plaintext input and a first plaintext output, and each of the ciphertext fine-tuning data includes a first ciphertext input obtained by replacing the first plaintext input with the cipher book and a first ciphertext output obtained by replacing the first plaintext output with the cipher book; A fine-tuning module is used to fine-tune the language model using the at least one ciphertext fine-tuning data; wherein the fine-tuning module adjusts the language model with the goal of reducing the difference between the output obtained by the language model processing the first ciphertext input and the first ciphertext output.
7. A model fine-tuning device, characterized in that: include: A construction module, used to construct a codebook for a language model; A first replacement module, used to replace at least one plaintext fine-tuning data with corresponding ciphertext fine-tuning data using the code book; Each of the plaintext fine-tuning data includes a first plaintext input and a first plaintext output, and each of the ciphertext fine-tuning data includes a first ciphertext input obtained by replacing the first plaintext input with the cipher book and a first ciphertext output obtained by replacing the first plaintext output with the cipher book; A sending module is used to send the ciphertext fine-tuning data to a model party, so that the model party can fine-tune the language model based on the ciphertext fine-tuning data.
8. A computing device comprising: processor; as well as A memory having executable codes stored thereon, which, when executed by the processor, causes the processor to execute the method according to any one of claims 1 to 5.
9. A computer program product, comprising executable codes, which, when executed by a processor of an electronic device, causes the processor to perform the method according to any one of claims 1 to 5.
10. A non-transitory machine-readable storage medium having executable codes stored thereon, which, when executed by a processor of an electronic device, causes the processor to execute the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Privacy protection proxy method for third-party large language model
CN117725610A
Data processing method and device based on large language model
CN117909471A
Method, system and device for jointly training large language model based on privacy protection
CN117910042A
Method, system and device for jointly training large language model based on privacy protection
CN118153088A
Method, system and equipment for protecting data privacy in big language model training
CN118171325A
