Large language model training data extraction method and system based on neighborhood comparison
Through a neighborhood comparison method, the training data of large language models is split into prefixes and suffixes, and the attack model and generative model are used for processing, which solves the problem of inefficient and low-precision extraction of training data of large language models, and improves the extraction efficiency and precision enhance privacy protection capabilities.
Patent Information
- Application Number
- CN202411046161.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-11-26
AI Technical Summary
Large language models have problems of inefficiency and low precision during training data extraction, resulting in the risk of user privacy leakage. The existing methods are inefficient and low precision, especially in the case of targeted extraction.
Using a large language model based on neighborhood comparison training data extraction method, split the data set into prefix data and suffix data, the attack model generates target samples and performs dropout mask processing, and uses neighborhood samples to generate model prediction mask location , calculate the average loss value, and finally select the final training data sample.
It significantly improves the accuracy and efficiency of training data extraction of large language models, improves the defense capabilities of privacy leakage, and provides a better foundation for subsequent defense work.
Smart Images

Figure CN119025913A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence security technology, and in particular to a method and system for extracting training data of a large language model based on neighborhood comparison. Background Art
[0002] In recent years, large language models have been widely used in various fields. Almost all online services collect our personal data and may use this data to train large language models. However, it is difficult to determine how the model uses this training data. If sensitive data such as geographic location, health records, and identity information are used in model training, attacks on the extraction of private data in the model may cause serious user privacy leakage. This information may involve sensitive data such as personal health records, financial information, etc. Once leaked, it will pose a serious threat to user privacy and may lead to identity theft, financial losses and other problems. A large number of experiments have shown that it is possible to extract training data from large language models.
[0003] With the development of social economy, people are more concerned about privacy protection. The existing methods for extracting training data for large language models mainly include untargeted extraction and targeted extraction. Untargeted extraction refers to letting the model generate a large amount of text without any prompts, and selecting samples that may be model training data from it through certain means. The extraction efficiency of this extraction method is very low, and most of the extracted training data is useless. Targeted extraction refers to extracting suffixes in a targeted manner given a prefix. This extraction method can more efficiently extract the data we want from the training data, and the extraction of privacy is more accurate and more valuable for research. There are relatively few existing studies on targeted training data extraction. At present, a more recognized method is: given a set of prefixes, generate training data samples through a certain method and test the accuracy of the generated text. Some studies have proposed some new suffix generation strategies to improve the accuracy of training data extraction, but the existing training data extraction accuracy is still very low and the speed is slow. The member inference attack method has been proven to be useful in untargeted training data extraction for large language models, but whether the member inference attack method has a good performance in targeted large model training data extraction has not been proven. Member inference attacks are usually divided into reference-based attacks and non-reference-based attacks. Reference-based attacks use shadow models and known data for inference, simulate the behavior of the target model by training multiple shadow models, and analyze the output features for judgment; non-reference-based attacks do not require reference data, and directly analyze the output confidence and entropy of the target model to infer whether the data belongs to the training set, usually relying on the higher confidence and lower output entropy of the training data points. The effect of reference-based attacks has been proven to be better than that of non-reference-based attacks, but requires a large amount of model data.
[0004] Since training data extraction is a tool for evaluating privacy leakage, there is an urgent need for a high-precision large language model training data extraction method as a benchmark for better defense, to solve the current situation of inefficient training data extraction in large language models and to improve the extraction accuracy. Summary of the invention
[0005] The present invention provides a large language model training data extraction method and system based on neighborhood comparison, which solves the current situation of inefficient training data extraction in large language models and improves the extraction accuracy.
[0006] In a first aspect, a method for extracting training data for a large language model based on neighborhood comparison is provided, comprising the following steps:
[0007] Split the data set into prefix data and suffix data;
[0008] Using the attack model to generate a set of target samples from the prefix data through a preset sampling method, and obtaining a loss value corresponding to each of the target samples;
[0009] Performing dropout mask processing on each of the target samples;
[0010] For each of the target samples, a neighborhood sample generation model is used to predict a mask processing position of a target sample, and a prediction word whose prediction value meets the conditions is used to replace the mask part to obtain a domain sample of the target sample;
[0011] Use the attack model to calculate the average loss value of the domain samples for each target sample;
[0012] According to the loss value corresponding to each of the target samples and the average loss value corresponding to the domain samples of each target sample, one of the target samples is selected from a group of target samples generated by the prefix data as the final training data sample.
[0013] According to the first aspect, in a first possible implementation manner of the first aspect, the step of “splitting the data set into prefix data and suffix data” specifically includes the following steps:
[0014] A set of data sets is selected from The Pile data set, and the first preset length data of a set of data sets is used as prefix data, and the remaining length data in each set of data sets is used as suffix data.
[0015] According to the first aspect, in a second possible implementation manner of the first aspect, the step of “using the attack model to generate a group of target samples using a preset sampling method for the prefix data, and obtaining a loss value corresponding to each of the target samples” specifically includes the following steps:
[0016] The attack model is used to autoregressively generate a suffix for the prefix data through a preset sampling method until the sampling iteration end condition is reached, a group of target samples is generated, and this group of target samples is re-input into the attack model for prediction to obtain the loss value of each target sample.
[0017] According to the first aspect, in a third possible implementation manner of the first aspect, the step of “performing dropout mask processing on each of the target samples” specifically includes the following steps:
[0018] Assume that the target sample is:
[0019] {token 0 ,token 1 ,token 2 ,...,token n};
[0020] Then the dropout mask processing is performed on one of the target samples as follows:
[0021] {[mask], token 1 , token 2 ,...,token n}, {token 0 ,[mask],token 2 ,...,token n}, {token 0 , token 1 ,[mask],...,token n}, ..., {token 0 ,token 1 , token 2 , ..., [mask]}
[0022] According to the first aspect, in a fourth possible implementation manner of the first aspect, the step of “predicting a mask processing position of a target sample using a neighborhood sample generation model, replacing the mask part with a prediction vocabulary whose prediction value meets the conditions, and obtaining a domain sample of the target sample” specifically includes the following steps:
[0023] The mask processing position of a target sample is predicted using the neighborhood sample generation model, and the corresponding prediction words with the highest preset prediction probability values are selected as the initial domain samples for each mask processing position;
[0024] The initial domain samples corresponding to all mask processing positions are arranged in order of predicted probability values, and the corresponding initial domain samples with the highest preset predicted probability values are selected as domain samples of the target samples.
[0025] According to the first aspect, in a fifth possible implementation manner of the first aspect, the step of “selecting one of the target samples from a group of target samples generated by the prefix data as the final training data sample according to the loss value corresponding to each of the target samples and the average loss value corresponding to the domain samples of each target sample” specifically includes the following steps:
[0026] The loss value corresponding to each target sample is subtracted from the average loss value corresponding to the domain sample of each target sample to obtain the perplexity corresponding to each target sample, and the target sample corresponding to the minimum perplexity is selected as the final training data sample.
[0027] In a second aspect, a large language model training data extraction system based on neighborhood comparison is provided, comprising:
[0028] Splitting module, used to split the data set into prefix data and suffix data;
[0029] A sampling module, which is in communication with the splitting module and is used to generate a set of target samples from the prefix data by a preset sampling method using an attack model, and obtain a loss value corresponding to each of the target samples;
[0030] A mask module, which is in communication with the sampling module and is used to perform dropout mask processing on each of the target samples;
[0031] A domain module, which is in communication with the mask module, is used to predict the mask processing position of a target sample for each target sample using a neighborhood sample generation model, and replace the mask part with a prediction word whose prediction value meets the conditions to obtain a domain sample of the target sample;
[0032] an average module, which is in communication with the domain module and is used to calculate the average loss value of the domain samples of each target sample using the attack model; and
[0033] The final selection module is communicated with the sampling module and the averaging module, and is used to select one of the target samples from a group of target samples generated by the prefix data as the final training data sample based on the loss value corresponding to each of the target samples and the average loss value corresponding to the domain sample of each target sample.
[0034] In a third aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method for extracting large language model training data based on neighborhood comparison as described above is implemented.
[0035] In a fourth aspect, an electronic device is provided, comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, wherein when the processor runs the computer program, the method for extracting training data from a large language model based on neighborhood comparison as described above is implemented.
[0036] Compared with the prior art, the advantages of the present invention are as follows: it solves the current situation of inefficient extraction of training data in large language models, improves the efficient extraction of training data, and thereby improves the standard of privacy leakage of large language models. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is a schematic diagram of an embodiment of a method for extracting training data of a large language model based on neighborhood comparison according to the present invention;
[0038] Figure 2 It is a schematic diagram of another embodiment of a method for extracting training data of a large language model based on neighborhood comparison of the present invention;
[0039] Figure 3 It is a schematic diagram of another embodiment of a method for extracting training data for a large language model based on neighborhood comparison of the present invention. DETAILED DESCRIPTION
[0040] Reference will now be made in detail to specific embodiments of the present invention, examples of which are illustrated in the accompanying drawings. Although the present invention will be described in conjunction with specific embodiments, it will be understood that it is not intended to limit the present invention to the embodiments described. On the contrary, it is intended to cover changes, modifications and equivalents included in the spirit and scope of the present invention as defined by the appended claims. It should be noted that the method steps described herein can all be implemented by any functional block or functional arrangement, and any functional block or functional arrangement can be implemented as a physical entity or a logical entity, or a combination of the two.
[0041] In order to enable those skilled in the art to better understand the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0042] Note: The example to be introduced below is only a specific example, and is not intended to limit the embodiments of the present invention to the following specific steps, values, conditions, data, sequences, etc. Those skilled in the art can apply the concept of the present invention to construct more embodiments not mentioned in this specification by reading this specification.
[0043] See also Figure 1 and 2 As shown, an embodiment of the present invention provides a method for extracting large language model training data based on neighborhood comparison, comprising the following steps:
[0044] S100, splitting the data set into prefix data and suffix data;
[0045] S200, using the attack model to generate a set of target samples from the prefix data through a preset sampling method, and obtaining a loss value corresponding to each of the target samples;
[0046] S300, performing dropout mask processing on each of the target samples;
[0047] S400, for each of the target samples, predicting the mask processing position of a target sample using a neighborhood sample generation model, replacing the mask part with a prediction word whose prediction value meets the conditions, and obtaining a domain sample of the target sample;
[0048] S500, using the attack model to calculate the average loss value of the domain samples of each target sample;
[0049] S600, selecting one of the target samples from a group of target samples generated by the prefix data as a final training data sample according to the loss value corresponding to each of the target samples and the average loss value corresponding to the domain samples of each target sample.
[0050] Therefore, the present invention proposes a training data extraction method for membership inference attack based on neighborhood comparison, which has an extraction accuracy significantly higher than the existing methods. It solves the current situation of inefficient training data extraction in large language models, improves the efficient extraction of training data, reveals the severity of privacy leakage of large language models, and lays a better foundation for subsequent defense work.
[0051] Preferably, in another embodiment of the present application, the step of "S100, splitting the data set into prefix data and suffix data" specifically includes the following steps:
[0052] A set of data sets is selected from The Pile data set, and the first preset length data of this set of data sets is used as prefix data, and the remaining length data in this set of data sets is used as suffix data.
[0053] Specifically, in this embodiment, multiple sets of data sets (i.e., N training data samples) are selected from The Pile data set. There are N sets of data sets in total. The length of each training data sample is 100 tokens, and the i-th sample is represented as: Z i =(x i , z i ), x i Indicates a prefix, Z i Indicates suffix, the length of prefix and suffix is 50 tokens. Each sample in the training data sample is split into prefix data sets as follows:
[0054]
[0055] The suffix datasets are as follows:
[0056]
[0057] See also Figure 3 As shown, for example, 1000 training data samples of length 100 are selected from ThePile dataset and segmented, the first fifty tokens are used as prefixes for subsequent generation, and the last 50 tokens are used as suffixes for comparison and verification of the generated suffixes.
[0058] Preferably, in another embodiment of the present application, the step of "S200, using the attack model to generate a set of target samples from the prefix data through a preset sampling method, and obtaining a loss value corresponding to each of the target samples" specifically includes the following steps:
[0059] The attack model is used to autoregressively generate a suffix for the prefix data through a preset sampling method until the sampling iteration end condition is reached, a group of target samples is generated, and this group of target samples is re-input into the attack model for prediction to obtain the loss value of each target sample.
[0060] Specifically, in this embodiment, the prefix is input into the attack model, and the attack model (large language model) can be sampled iteratively (possibly with certain prefixes as conditions x 1 , ..., x i ) Generate new text Then Re-enter the model sampling to obtain This process is repeated until the end condition is met. There are different sampling strategies for sampling. The sampling strategies used in this invention include: top-k, top-p, typical-p, beam-search, temperature, and repetition_penalty. The optimal generation strategy is achieved by combining different sampling strategies and tuning parameters. Therefore, a group of target samples can be generated by sampling through a prefix, and these target samples can be re-input into the attack model for prediction to obtain their respective loss values L(f θ , x).
[0061] Taking the sampling strategy temperature = 0.8, beam-search = 3 as an example, the specific steps are as follows:
[0062] First, prefix the dataset The attack model GPT-Neo 1.3B is fed with temperature = 0.8, beam-search = 3, and generate_len (output length) = 100. i For example (the operation for all prefixes is the same. In actual operation, the present invention sets batch_size to 32 for input). i Input the attack model, the attack model will generate samples by autoregression, and a set of M target sample groups can be generated through M different sampling method experiments
[0063] To generate sample groups For each target sample in , the perplexity of each target sample is determined by the membership inference attack method based on neighborhood comparison, and the target sample with the lowest perplexity is finally selected as the recognized training data sample. i For example, y i Re-enter the attack model GPT-Neo 1.3B to get its loss value L y .
[0064] Preferably, in another embodiment of the present application, the step of “S300, performing dropout mask processing on each of the target samples” specifically includes the following steps:
[0065] Assume that the target sample is:
[0066] {token 0 , token 1 ,token 2 ,...,token n};
[0067] Then the dropout mask processing is performed on one of the target samples as follows:
[0068] {[mask],token 1 , token 2 ,...,token n}, {token 0 ,[mask],token 2 ,...,token n}, {token 0 , token 1 ,[mask],..,token n}, ..., {token 0 , token 1 , token 2, ..., [mask]}.
[0069] Specifically, in this embodiment, a group of generated samples A target sample y in i For example, y i It can be expressed as:
[0070] y i ={token 0 , token 1 , token 2 ,...,token 99};
[0071] By i Perform dropout, that is, replace one of the tokens with [mask], and get 100 target samples with masks at different positions as follows:
[0072] N mask ={{[mask],token 1 ,token 2 ,...,token 99}, {token 0 ,[mask],token 2 ,...,token 99}, token 2 ,...,token 99}, {token 0 ,[mask],token 2 ,...,token 99}, {token 0 , token 1 , [mask], ..., tokeb 99},...,{token 0 ,token 1 , token 2 , ..., [mask]}}
[0073] Preferably, in another embodiment of the present application, the step of "S400, predicting a mask processing position of a target sample using a neighborhood sample generation model, replacing the mask part with a prediction word whose prediction value meets the conditions, and obtaining a domain sample of the target sample" specifically includes the following steps:
[0074] The mask processing position of a target sample is predicted using the neighborhood sample generation model, and the corresponding prediction words with the highest preset prediction probability values are selected as the initial domain samples for each mask processing position;
[0075] The initial domain samples corresponding to all mask processing positions are arranged in order of predicted probability values, and the corresponding initial domain samples with the highest preset predicted probability values are selected as domain samples of the target samples.
[0076] Specifically, in this embodiment, the 100 target samples with masks at different positions obtained above are input into the neighborhood sample generation model (Bert), and the mask positions are predicted, that is, Bert is used to fill the missing words of [mask], so that the initial neighborhood samples are obtained as follows:
[0077]
[0078] The specific word filling method is to select the five predicted words with the highest probability for each mask position to fill in, so as to obtain neighborhood samples, that is, a total of 500 initial neighborhood samples are obtained. Then the 500 initial neighborhood samples obtained above are sorted from large to small according to their probability values, and then the 50 samples with the largest probability values are selected as the neighborhood samples of the target sample. This group of neighborhood samples is input into the attack model to obtain the average loss value of this group of neighborhood samples. The average loss value L N The calculation formula is as follows:
[0079]
[0080] Preferably, in another embodiment of the present application, the step of “S600, selecting one of the target samples from a group of target samples generated by the prefix data as the final training data sample according to the loss value corresponding to each of the target samples and the average loss value corresponding to the domain samples of each target sample” specifically includes the following steps:
[0081] The loss value corresponding to each target sample is subtracted from the average loss value corresponding to the domain sample of each target sample to obtain the perplexity corresponding to each target sample, and the target sample corresponding to the minimum perplexity is selected as the final training data sample.
[0082] Specifically, in this embodiment, the large language model tends to overfit its own training data, so if a sample is training data, its Loss value should be smaller than the Loss value of its neighboring samples (non-training data). In the present invention, let: γ = L y -L N , for a group of M target samples Each sample in the i Value, from which to choose the perplexity γ i The target sample y with the smallest value i As the training data sample of this prefix. So, for all prefixes In the same way, a target sample can be selected as a training data sample, so a sample group can be obtained. Finally, you can and By comparison, we can get the accuracy of training data extraction.
[0083] The embodiment of the present invention also provides a large language model training data extraction system based on neighborhood comparison, including:
[0084] Splitting module, used to split the data set into prefix data and suffix data;
[0085] A sampling module, which is in communication with the splitting module and is used to generate a set of target samples from the prefix data by a preset sampling method using an attack model, and obtain a loss value corresponding to each of the target samples;
[0086] A mask module, which is in communication with the sampling module and is used to perform dropout mask processing on each of the target samples;
[0087] A domain module, which is in communication with the mask module, is used to predict the mask processing position of a target sample for each target sample using a neighborhood sample generation model, and replace the mask part with a prediction word whose prediction value meets the conditions to obtain a domain sample of the target sample;
[0088] an average module, which is in communication with the domain module and is used to calculate the average loss value of the domain samples of each target sample using the attack model; and
[0089] The final selection module is communicated with the sampling module and the averaging module, and is used to select one of the target samples from a group of target samples generated by the prefix data as the final training data sample based on the loss value corresponding to each of the target samples and the average loss value corresponding to the domain sample of each target sample.
[0090] Therefore, the present invention improves the method of membership inference attack based on neighborhood comparison and uses it in the process of extracting training data for a large oracle model. At the same time, the present invention performs hyperparameter tuning on a variety of suffix generation strategies in the suffix generation process, and adjusts the number of experiments to the maximum under the premise that computing power conditions permit, so as to achieve efficient training data extraction.
[0091] Specifically, this embodiment corresponds one-to-one to the above method embodiment, and the functions of each module have been described in detail in the corresponding method embodiment, so they will not be repeated here.
[0092] Based on the same inventive concept, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, all or part of the method steps of the above method are implemented.
[0093] The present invention implements all or part of the process in the above method, and can also be completed by instructing related hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of each of the above method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, USB flash drive, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.
[0094] Based on the same inventive concept, an embodiment of the present application also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program running on the processor, and when the processor executes the computer program, all or part of the method steps in the above method are implemented.
[0095] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of a computer device, and uses various interfaces and lines to connect various parts of the entire computer device.
[0096] The memory can be used to store computer programs and / or modules. The processor realizes various functions of the computer device by running or executing the computer programs and / or modules stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and at least one application required for a function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created according to the use of the mobile phone (such as audio data, video data, etc.). In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0097] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, servers or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program codes.
[0098] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), servers, and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as a combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0099] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0100] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0101] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A method for extracting training data for a large language model based on neighborhood comparison, characterized in that: The following steps are involved: Split the data set into prefix data and suffix data; Using the attack model to generate a set of target samples from the prefix data through a preset sampling method, and obtaining a loss value corresponding to each of the target samples; Performing dropout mask processing on each of the target samples; For each of the target samples, a neighborhood sample generation model is used to predict a mask processing position of a target sample, and a prediction word whose prediction value meets the conditions is used to replace the mask part to obtain a domain sample of the target sample; Use the attack model to calculate the average loss value of the domain samples for each target sample; According to the loss value corresponding to each of the target samples and the average loss value corresponding to the domain samples of each target sample, one of the target samples is selected from a group of target samples generated by the prefix data as the final training data sample.
2. The method for extracting large language model training data based on neighborhood comparison according to claim 1, characterized in that: The step of "splitting the data set into prefix data and suffix data" specifically includes the following steps: A set of data sets is selected from The Pile data set, and the first preset length data of a set of data sets is used as prefix data, and the remaining length data in each set of data sets is used as suffix data.
3. The method for extracting large language model training data based on neighborhood comparison according to claim 1, characterized in that: The step of "using the attack model to generate a set of target samples from the prefix data through a preset sampling method, and obtaining a loss value corresponding to each of the target samples" specifically includes the following steps: The attack model is used to autoregressively generate a suffix for the prefix data through a preset sampling method until the sampling iteration end condition is reached, a group of target samples is generated, and this group of target samples is re-input into the attack model for prediction to obtain the loss value of each target sample.
4. The method for extracting large language model training data based on neighborhood comparison according to claim 1, characterized in that: The step of "performing dropout mask processing on each of the target samples" specifically includes the following steps: Assume that the target sample is: {token0, token1, token2, ..., token n }; Then the dropout mask processing is performed on one of the target samples as follows: {[mask],token1,token2,...,token n },{token0,[mask],token2,...,token n }, {tOken0,token1,[mask],...,token n },...,{token0,token1,token2,...,[mask]}。 5. The method for extracting large language model training data based on neighborhood comparison according to claim 1, characterized in that: The step of "predicting the mask processing position of a target sample by using the neighborhood sample generation model, replacing the mask part with the prediction vocabulary whose prediction value meets the conditions, and obtaining the domain sample of the target sample" specifically includes the following steps: The mask processing position of a target sample is predicted using the neighborhood sample generation model, and the corresponding prediction words with the highest preset prediction probability values are selected as the initial domain samples for each mask processing position; The initial domain samples corresponding to all mask processing positions are arranged in order of predicted probability values, and the corresponding initial domain samples with the highest preset predicted probability values are selected as domain samples of the target samples.
6. The method for extracting large language model training data based on neighborhood comparison according to claim 1, characterized in that: The step of "selecting one of the target samples from a group of target samples generated by the prefix data as the final training data sample according to the loss value corresponding to each of the target samples and the average loss value corresponding to the domain samples of each target sample" specifically includes the following steps: The loss value corresponding to each target sample is subtracted from the average loss value corresponding to the domain sample of each target sample to obtain the perplexity corresponding to each target sample, and the target sample corresponding to the minimum perplexity is selected as the final training data sample.
7. A large language model training data extraction system based on neighborhood comparison, characterized in that: include: Splitting module, used to split the data set into prefix data and suffix data; A sampling module, which is in communication with the splitting module and is used to generate a set of target samples from the prefix data by a preset sampling method using an attack model, and obtain a loss value corresponding to each of the target samples; A mask module, which is in communication with the sampling module and is used to perform dropout mask processing on each of the target samples; A domain module, which is in communication with the mask module, is used to predict the mask processing position of a target sample for each target sample using a neighborhood sample generation model, and replace the mask part with a prediction word whose prediction value meets the conditions to obtain a domain sample of the target sample; An average module, which is in communication with the domain module and is used to calculate the average loss value of the domain samples of each target sample using the attack model; as well as, The final selection module is communicated with the sampling module and the averaging module, and is used to select one of the target samples from a group of target samples generated by the prefix data as the final training data sample based on the loss value corresponding to each of the target samples and the average loss value corresponding to the domain sample of each target sample.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for extracting large language model training data based on neighborhood comparison according to any one of claims 1 to 6 is implemented.
9. An electronic device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor runs the computer program, the large language model training data extraction method based on neighborhood comparison is implemented as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Method for reducing speckle noises of SAR image based on neighborhood directivity information
CN101566688A
Training data extraction method and device
CN116821678A
Hardening branch hardware against speculation vulnerabilities
EP4020192A1
Cited By
Context learning example-based infringement detection method, system and device, and medium
CN120930630A
