Question and answer optimization method and device, equipment, storage medium and product
By perturbing the prompts in the large model and iteratively updating the answer prediction model, the risk of privacy leakage during the reasoning process of the large model is resolved, achieving a balance between privacy protection and reasoning accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WEBANK (CHINA)
- Filing Date
- 2024-03-05
- Publication Date
- 2026-05-29
AI Technical Summary
Existing technologies pose a high risk of privacy breaches when using large models for inference, especially since user privacy information may be stolen during communication and inference. Existing encryption technologies are computationally intensive or have reduced inference performance, and therefore cannot effectively protect privacy.
By perturbing the initial training prompts to generate perturbed prompts, and then using the answer prediction model for iterative updates, we can ensure that private information cannot be accurately obtained during communication transmission, while maintaining the accuracy of the reasoning results.
It effectively protects user privacy information, reduces the risk of privacy leakage, and maintains the performance and accuracy of large model inference, avoiding the problems of large computational load or performance reduction caused by encryption in existing technologies.
Smart Images

Figure CN118052288B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology in financial technology (Fintech), and more particularly to a question-answering optimization method, apparatus, device, storage medium, and program product. Background Technology
[0002] With the continuous development of fintech, especially internet fintech, more and more technologies (such as distributed systems and artificial intelligence) are being applied in the financial field, but the financial industry is also placing higher demands on technology.
[0003] The emergence of large-scale models has brought about technological revolution and opportunities to various industries. However, powerful large-scale models, such as ChatGPT (Chat Generative Pre-trained Transformer), are typically deployed on cloud servers. Users need to send their prompts to the cloud server, which then uses the large model for inference. However, prompts often contain users' private information, which may be stolen during communication and inference, posing a high risk of privacy breaches. Summary of the Invention
[0004] The main purpose of this application is to provide a question-answering optimization method, apparatus, device, storage medium, and program product, which aims to solve the technical problem of high privacy leakage risk in the process of reasoning using large models in the prior art.
[0005] To achieve the above objectives, this application provides a question-answering optimization method, which is applied to a first device on which an answer prediction model to be trained is deployed; the question-answering optimization method includes the following steps:
[0006] Obtain initial training prompts and a first target answer, wherein the first target answer is generated by a large model deployed on a second device based on the initial training prompts;
[0007] The initial training prompts are perturbed to obtain perturbed training prompts;
[0008] The training perturbation prompt is sent to the second device, so that the second device can generate the training perturbation answer corresponding to the training perturbation prompt using its own deployed large model;
[0009] Receive the training perturbation answer returned by the second device, input the training perturbation answer and the initial training prompt word into the answer prediction model to obtain the training prediction answer;
[0010] Based on the difference between the trained predicted answer and the first target answer, the answer prediction model is iteratively updated.
[0011] This application also provides a question-answering optimization method, which is applied to a third device, on which a trained answer prediction model is deployed; the question-answering optimization method includes the following steps:
[0012] Obtain the initial prompt word, and perturb the initial prompt word to obtain the perturbed prompt word;
[0013] The perturbation prompt is sent to the second device, which then generates the perturbation answer corresponding to the perturbation prompt using its own deployed large model;
[0014] The perturbation answer returned by the second device is received, and the perturbation answer and the initial prompt word are input into the answer prediction model. The model is then used to predict the first target answer generated by the large model based on the initial prompt word to obtain the predicted answer.
[0015] This application also provides a question-answering optimization device, which is applied to a first device, on which an answer prediction model to be trained is deployed; the question-answering optimization device includes:
[0016] The acquisition module is used to acquire the initial training prompts and the first target answer, wherein the first target answer is generated by a large model deployed on the second device based on the initial training prompts.
[0017] The first perturbation module is used to perturb the initial training prompt words to obtain training perturbation prompt words;
[0018] The first sending module is used to send the training perturbation prompt words to the second device, so that the second device can generate the training perturbation answer corresponding to the training perturbation prompt words through its own deployed large model;
[0019] The first prediction module is used to receive the training perturbation answer returned by the second device, input the training perturbation answer and the initial training prompt word into the answer prediction model, and obtain the training prediction answer;
[0020] An update module is used to iteratively update the answer prediction model based on the difference between the trained predicted answer and the first target answer.
[0021] This application also provides a question-answering optimization device, which is applied to a third device, the third device having a trained answer prediction model deployed thereon; the question-answering optimization device includes:
[0022] The second perturbation module is used to obtain the initial prompt word to be inferred, and to perturb the initial prompt word to be inferred to obtain the perturbation prompt word to be inferred.
[0023] The second sending module is used to send the inference perturbation prompt word to the second device, so that the second device can generate the inference perturbation answer corresponding to the inference perturbation prompt word through its own deployed large model;
[0024] The second prediction module is used to receive the inference perturbation answer returned by the second device, input the inference perturbation answer and the initial prompt word to be inferred into the answer prediction model, and predict the second target answer generated by the large model based on the initial prompt word to be inferred to obtain the predicted answer.
[0025] This application also provides an electronic device, which is a physical device, comprising: a memory, a processor, and a program of the question-answering optimization method stored in the memory and executable on the processor. When the program of the question-answering optimization method is executed by the processor, it can implement the steps of the question-answering optimization method as described above.
[0026] This application also provides a storage medium, which is a computer-readable storage medium, on which a program implementing a question-answering optimization method is stored. When the program implementing the question-answering optimization method is executed by a processor, it implements the steps of the question-answering optimization method as described above.
[0027] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the question-answering optimization method described above.
[0028] This application provides a question-answering optimization method, apparatus, device, storage medium, and program product. The question-answering optimization method is applied to a first device, on which an answer prediction model to be trained is deployed. The question-answering optimization method is used to train the answer prediction model. First, by obtaining initial training prompts and a first target answer, wherein the first target answer is generated by a large model deployed on a second device based on the initial training prompts, the original text of the prompts used for training and the first target answer inferred by the large model based on the original text of the prompts are obtained. Then, by perturbing the initial training prompts, training perturbed prompts are obtained, thus perturbing the original text of the prompts. Then, by sending the training perturbed prompts to the second device, the second device can generate the training perturbed answer corresponding to the training perturbed prompts using its deployed large model. In this way, since potential attackers cannot know whether the training perturbed prompts transmitted in the communication have been perturbed, let alone what kind of perturbing has been performed, it is difficult to accurately obtain the privacy information contained in the original text of the prompts, thereby achieving the protection against attackers. The protection of privacy information in the initial training prompts overcomes the technical drawback that prompts often contain user privacy information, which may be stolen during communication transmission and inference, thus posing a high risk of privacy leakage. Furthermore, by receiving the training perturbation answer returned by the second device, the training perturbation answer and the initial training prompts are input into the answer prediction model to obtain the training prediction answer. Based on the difference between the training prediction answer and the first target answer, the answer prediction model is iteratively updated. In this way, through model training, the answer prediction model can learn to predict the correct answer generated by the large model based on the undisturbed initial training prompts and training perturbation answers, thereby reducing the risk of privacy leakage while ensuring answer accuracy. Attached Figure Description
[0029] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0030] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0031] Figure 1 This is a flowchart illustrating the first embodiment of the question-answering optimization method of this application;
[0032] Figure 2This is a schematic diagram of the model structure involved in the embodiments of this application;
[0033] Figure 3 This is a flowchart illustrating the second embodiment of the question-answering optimization method of this application;
[0034] Figure 4 This is a schematic diagram of the question-answering optimization device in the embodiments of this application;
[0035] Figure 5 This is a schematic diagram of the device structure of the hardware operating environment involved in the question-answering optimization method in the embodiments of this application.
[0036] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0037] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0038] Example 1
[0039] This application provides a question-answering optimization method. In the first embodiment of the question-answering optimization method of this application, referring to... Figure 1 The question-answering optimization method is applied to a first device, on which an answer prediction model to be trained is deployed; the question-answering optimization method includes the following steps:
[0040] Step S10: Obtain the initial training prompts and the first target answer, wherein the first target answer is generated by the large model deployed on the second device based on the initial training prompts;
[0041] The execution subject of the method in this embodiment can be a question-and-answer optimization device, a question-and-answer optimization terminal device, or a server. This embodiment takes a question-and-answer optimization device as an example. The question-and-answer optimization device can be integrated into terminal devices such as smartphones and computers with data processing functions.
[0042] Large-scale models typically refer to machine learning models with a massive number of parameters, ranging from millions to billions. They offer more powerful and accurate model performance, especially when handling complex and large datasets or tasks. They can capture complex patterns and rules within big data, thereby improving predictive and generalization capabilities. The emergence of large-scale models has brought about technological revolution and opportunities to various industries. However, powerful large-scale models, such as ChatGPT (Chat Generative Pre-trained Transformer), are usually deployed on cloud servers. Users need to send their prompts to the cloud server, which then uses the large-scale model for inference. However, prompts often contain users' private information. For example, in scenarios where large-scale models are used for data analysis, the data provided by users may contain private information. When using large-scale models for imitation generation, they may infer users' preferences, habits, and other personal privacy information. This private information may be stolen during communication and inference, thus posing a high risk of privacy leakage.
[0043] Currently, privacy protection technologies for large-scale model inference mainly rely on encryption techniques, such as multi-party secure computation and homomorphic encryption. However, these encryption techniques either involve massive computational demands or require multiple data transmissions, both of which significantly reduce inference efficiency. This prevents the practical application of encryption-based privacy protection for large-scale model inference. Another privacy protection technique for large-scale model inference is noise perturbation, but this also leads to a substantial reduction in inference performance, resulting in inference results that fail to meet user needs. Therefore, we need a solution that effectively protects user privacy while ensuring that large-scale model inference performance meets user requirements.
[0044] In this embodiment, it should be noted that the question-answering optimization method is applied to a first device, which is equipped with an answer prediction model to be trained. A pre-trained large model is deployed on a second device. This large model can perform reasoning analysis based on input prompts to generate corresponding answers. The first device is communicatively connected to the second device, allowing it to send prompts to the second device. After receiving the prompts, the second device uses the large model to perform reasoning analysis on the prompts and returns the resulting answer to the first device.
[0045] Before training the model, we can first collect the prompt words that are transmitted in plaintext as training sample data, and collect the answers generated and returned by the large model deployed on the second device as the label values of the training sample data, so as to obtain the labeled training sample data and its label values.
[0046] As an example, step S10 includes: acquiring a batch of labeled training sample data and their corresponding label values, wherein the training sample data refers to the initial training prompt words in the text state, and the label values refer to the first target answer generated by the large model deployed on the second device based on the initial training prompt words.
[0047] Step S20: Perturb the initial training prompts to obtain perturbed training prompts;
[0048] In this embodiment, it should be noted that the initial prompt word is in plaintext. If the initial prompt word in plaintext is sent directly to the second device, it can easily be stolen by potential attackers, leading to the leakage of privacy information. Therefore, this embodiment perturbs the initial training prompt word. In this way, subsequent communication transmits the perturbed prompt word. Since potential attackers cannot know whether the perturbed training prompt word transmitted in communication has been perturbed, let alone what kind of perturbation it has undergone, it is difficult for them to accurately obtain the privacy information contained in the original prompt word, thereby achieving the protection of privacy information in the initial training prompt word.
[0049] Perturbation processing refers to the operation of introducing noise. Noise can make it impossible to accurately identify the privacy information or the meaning of privacy information in the perturbed data. For example, noise information can be added alongside the privacy information, so that potential attackers cannot accurately extract the privacy information. Alternatively, important data in the privacy information that does not affect the analysis of the large model can be cropped or encrypted, so that potential attackers cannot obtain this part of the important data. The specific perturbation processing method can be determined according to the actual situation, and this embodiment does not limit it.
[0050] As an example, step S20 includes: after obtaining the initial training prompt in plaintext state, the initial training prompt in plaintext state is perturbed to obtain a perturbed training prompt. The perturbed training prompt obtained after perturbation replaces the initial training prompt in plaintext state for subsequent communication transmission and inference. In this way, even if the perturbed training prompt is stolen by a potential attacker during subsequent communication transmission and inference, the privacy information in it cannot be accurately identified.
[0051] Optionally, the first device is further equipped with an encoder, and the step of perturbing the initial training prompts to obtain perturbed training prompts includes:
[0052] The encoder perturbs the initial training prompts to obtain perturbed training prompts.
[0053] In this embodiment, it should be noted that an encoder may also be deployed on the first device to encode the initial training prompts and generate training perturbation prompts with added noise. The encoder can be trained together with the answer prediction model, or it can be pre-trained and then fine-tuned during the training of the answer prediction model, or a pre-trained encoder can be used directly to perturb the initial training prompts. The specific method can be determined based on the actual situation and training effect, and this embodiment does not impose any restrictions on this.
[0054] As an example, after obtaining the initial training prompts in plaintext, the initial training prompts in plaintext can be input into the encoder deployed on the local end for perturbation processing to train the perturbed prompts.
[0055] Optionally, the first device is further equipped with a word embedding model, and the step of perturbing the initial training prompt words to obtain perturbed training prompt words includes:
[0056] Step S21: Convert the initial training prompt words into initial training prompt word embeddings using the word embedding model;
[0057] Step S22: Perturb the initial training prompt word embedding to obtain the training perturbation prompt word.
[0058] As an example, steps S21-S22 include: before inputting into the model, the initial training prompt words can be converted into meaningful and computable initial training prompt word embeddings through a word embedding model, and then the initial training prompt word embeddings are perturbed to obtain perturbed training prompt words. The obtained perturbed training prompt words are also word embeddings represented by numerical values.
[0059] In one feasible embodiment, the first device is further equipped with a word embedding model and an encoder, and the training perturbation prompt word includes a training perturbation prompt word embedding; the step of perturbing the initial training prompt word to obtain the training perturbation prompt word includes: converting the initial training prompt word into an initial training prompt word embedding through the word embedding model; and perturbing the initial training prompt word embedding through the encoder to obtain the training perturbation prompt word embedding.
[0060] Step S30: Send the training perturbation prompt to the second device so that the second device can generate the training perturbation answer corresponding to the training perturbation prompt using its own deployed large model;
[0061] As an example, step S30 includes: the first device sending the perturbation-processed training perturbation prompt to the second device for inference; after receiving the training perturbation prompt, the second device inputs the training perturbation prompt into a large model deployed on the second device for inference, obtaining the training perturbation answer corresponding to the training perturbation prompt. In this way, privacy information cannot be accurately identified in the training perturbation answer obtained based on the perturbated training perturbation prompt, thereby protecting the privacy information in the training perturbation answer. Specifically, the first device can embed the perturbation-processed training perturbation prompt and send it to the second device for inference; after receiving the embedded training perturbation prompt, the second device inputs the embedded training perturbation prompt into a large model deployed on the second device for inference, obtaining the embedded training perturbation answer corresponding to the training perturbation prompt.
[0062] Step S40: Receive the training perturbation answer returned by the second device, input the training perturbation answer and the initial training prompt word into the answer prediction model to obtain the training prediction answer;
[0063] In this embodiment, it should be noted that the answer prediction model is also a large model with reasoning capabilities. Therefore, it can infer the undisturbed answer that the user actually wants to know based on the perturbed answer and the undisturbed initial prompt. That is, the reasoning process of the answer prediction model is based on the process of decoding the answer from the perturbed answer based on the initial prompt. Therefore, the number of parameters of the answer prediction model is much lower than that of the large model deployed on the second device. Therefore, in practical applications, it can be deployed on the user end. The predicted answer obtained after decoding can be directly output to the user on the user end for viewing. Thus, the initial prompt and predicted answer in plaintext state are only stored on the user end, without worrying about being stolen by potential attackers.
[0064] In one feasible implementation, the answer prediction model may be of the same origin as the large model deployed on the second device, but with a much smaller number of parameters. This allows the answer prediction model to be trained faster and more effectively, resulting in a higher performance and more accurate prediction results.
[0065] As an example, step S40 includes: receiving the training perturbation answer returned by the second device after inference based on the training perturbation prompt; inputting the training perturbation answer and the initial training prompt into the answer prediction model; and using the answer prediction model to infer based on the undisturbed initial training prompt and the training perturbation answer generated by the large model based on the perturbated training perturbation prompt, predicting the correct answer generated by the large model based on the undisturbed initial prompt, and obtaining the training predicted answer. Specifically, the first device receives the training perturbation answer embedding corresponding to the training perturbation prompt from the second device; concatenates the training perturbation prompt embedding and the training perturbation answer embedding; then inputs the concatenated result into the answer prediction model; and using the answer prediction model to infer based on the undisturbed initial training prompt embedding and the training perturbation answer embedding generated by the large model based on the perturbated training perturbation prompt, predicting the correct answer generated by the large model based on the undisturbed initial prompt, and obtaining the training predicted answer.
[0066] Optionally, the step of inputting the training perturbation answer and the initial training prompt word into the answer prediction model to obtain the training predicted answer includes:
[0067] The training perturbation answer is decoded using the answer prediction model based on the initial training prompts to obtain the training prediction answer.
[0068] As an example, the answer prediction model can act as a decoder. The training perturbation answer and the initial training prompt are input into the answer prediction model. Based on the initial training prompt, the answer prediction model decodes the undisturbed training prediction answer from the training perturbation answer. In this way, through model training, the answer prediction model can learn to use the undisturbed prompt text to guide it in decoding the correct answer corresponding to the prompt text from the perturbed training perturbation answer.
[0069] Step S50: Based on the difference between the trained predicted answer and the first target answer, the answer prediction model is iteratively updated.
[0070] As an example, step S50 includes: after obtaining the training predicted answer, calculating the prediction loss based on the difference between the training predicted answer and the first target answer; determining whether the answer prediction model has converged based on the prediction loss; if the answer prediction model has not converged, iteratively updating the answer prediction model and returning to the step of obtaining the initial training prompt and the first target answer to perform a new round of iterative updates on the answer prediction model until the answer prediction model converges, or reaches a preset maximum number of iterations, a preset maximum training time, etc. The specific training termination conditions can be set according to the actual situation, and this embodiment does not limit this.
[0071] Optionally, the step of iteratively updating the answer prediction model based on the difference between the trained predicted answer and the first target answer includes:
[0072] Step S51: Determine the prediction loss based on the difference between the trained predicted answer and the first target answer;
[0073] Step S52: Iteratively update the answer prediction model and the encoder based on the prediction loss.
[0074] In this embodiment, it should be noted that when an encoder is deployed on the first device for perturbation processing, the encoder can be used for model training together. This can improve the overall model performance and make the final prediction results more accurate.
[0075] As an example, steps S51-S52 include: after obtaining the training predicted answer, calculating and determining the prediction loss based on the difference between the training predicted answer and the first target answer; determining whether the answer prediction model and the encoder have converged based on the prediction loss; if the answer prediction model or the encoder has not converged, iteratively updating both the answer prediction model and the encoder, and returning to the step of obtaining the initial training prompt word and the first target answer, performing a new round of iterative updates on the answer prediction model and the encoder until both the answer prediction model and the encoder have converged, or reaching a preset maximum number of iterations, a preset maximum training time, etc. The specific training termination conditions can be set according to the actual situation, and this embodiment does not limit this.
[0076] Optionally, the step of iteratively updating the answer prediction model and the encoder based on the prediction loss includes:
[0077] Step S521: Calculate the first gradient of the prediction loss with respect to the answer prediction model and the second gradient of the prediction loss with respect to the encoder;
[0078] Step S522: Perform differential privacy processing on the second gradient to obtain the third gradient;
[0079] Step S523: Iteratively update the answer prediction model based on the first gradient, and iteratively update the encoder based on the third gradient.
[0080] In this embodiment, it should be noted that while perturbation processing can effectively prevent potential attackers from directly obtaining the initial prompt in plaintext, if a potential attacker guesses or deduces that the perturbed prompt has been perturbed, they may further deduce its perturbation method. Training the encoder and the answer prediction model together can improve the model performance of the answer prediction model, but it also makes the encoder's perturbation processing easier to deduce. Differential privacy is a technique in cryptography, and the specific methods of differential privacy processing can adopt existing differential privacy processing methods, which will not be elaborated on here. Therefore, during the co-training of the encoder and the answer prediction model, differential privacy processing is used to protect the encoder's privacy, reducing the risk of potential attackers deduce the perturbation method of the initial prompt and thus inferring the initial prompt based on the training perturbed prompt. This improves both the accuracy of answer prediction and the privacy protection of the initial prompt.
[0081] As an example, steps S521-S523 include: calculating the first gradient of the prediction loss with respect to the answer prediction model and the second gradient of the prediction loss with respect to the encoder; performing differential privacy processing on the second gradient to obtain a third gradient. After determining the first gradient, the answer prediction model can be iteratively updated based on the first gradient; after determining the third gradient, the encoder can be iteratively updated based on the third gradient.
[0082] Optionally, the step of performing differential privacy processing on the second gradient to obtain the third gradient includes:
[0083] Step S5221: Generate noise data that follows a preset probability distribution, wherein each element in the noise data corresponds one-to-one with each element in the second gradient;
[0084] Step S5222: Add the noise data to the second gradient to obtain the third gradient.
[0085] As an example, steps S5221-S5222 include: randomly generating noise data that follows a preset probability distribution, wherein the noise data can be in the form of a sequence or matrix, and each element in the noise data corresponds one-to-one with each element in the second gradient; then, adding the noise data to the second gradient, such that each element in the first gradient is added to the corresponding element in the noise data, to obtain a perturbation-processed third gradient. The preset probability distribution can be a Gaussian distribution, etc., and can be specifically determined based on the actual situation such as the data distribution of the first gradient; this embodiment does not impose any limitations on this.
[0086] In one feasible implementation, refer to Figure 2 On the server, a large model f is deployed. The large model f can reason based on the input prompt words and generate the corresponding answer. However, the number of parameters and the amount of computation of the large model f are too large, so it can usually only be deployed on the server. On the client and / or training device, a word embedding model m, an encoder e and a large model d are deployed. The large model d is the answer prediction model. The number of parameters and the amount of computation of the large model d are much smaller than those of the large model f, so it can be deployed on the client. The initial prompt word p is first input into the word embedding model m to generate an initial prompt word embedding t. Then, the initial prompt word embedding t is input into the encoder e for perturbation processing, resulting in a perturbed prompt word t' in the form of a perturbed word embedding. The perturbed prompt word t' is then sent to the server, which inputs it into the large model f for inference and generates a perturbed answer r' in the form of a word embedding, and returns the perturbed answer r'. The client and / or the training end input the received perturbed answer r' and the initial prompt word embedding t together into the large model d to predict the target answer generated by the large model f based on the initial prompt word p. The predicted answer is then decoded from the perturbed answer r' based on the initial prompt word embedding t. Furthermore, based on the predicted answer The difference between the target answer r and the actual answer r is calculated, where the target answer r is the true answer generated by the large model f based on the initial prompt word embedding t. The large model d and encoder e are updated by backpropagation based on the loss L. When updating encoder e, the gradient of loss L with respect to encoder e is first calculated, and then noise δ is added to the gradient. The encoder e is updated based on the gradient after adding noise δ.
[0087] In this embodiment, the question-answering optimization method is applied to a first device, on which an answer prediction model to be trained is deployed. The question-answering optimization method is used to train the answer prediction model. First, by obtaining initial training prompts and a first target answer, wherein the first target answer is generated by a large model deployed on a second device based on the initial training prompts, the original text of the prompts used for training and the first target answer inferred by the large model based on the original text of the prompts are obtained. Then, by perturbing the initial training prompts, training perturbed prompts are obtained, thus perturbing the original text of the prompts. Then, by sending the training perturbed prompts to the second device, the second device can generate the training perturbed answer corresponding to the training perturbed prompts using its deployed large model. In this way, since potential attackers cannot know whether the training perturbed prompts transmitted in the communication have been perturbed, let alone what kind of perturbing has been done, it is difficult to accurately obtain the privacy information contained in the original text of the prompts, thereby achieving the protection against attackers. The protection of privacy information in the initial training prompts overcomes the technical drawback that prompts often contain user privacy information, which may be stolen during communication transmission and inference, thus posing a high risk of privacy leakage. Furthermore, by receiving the training perturbation answer returned by the second device, the training perturbation answer and the initial training prompts are input into the answer prediction model to obtain the training prediction answer. Based on the difference between the training prediction answer and the first target answer, the answer prediction model is iteratively updated. In this way, through model training, the answer prediction model can learn to predict the correct answer generated by the large model based on the undisturbed initial training prompts and training perturbation answers, thereby reducing the risk of privacy leakage while ensuring answer accuracy.
[0088] Example 2
[0089] Furthermore, referring to Figure 3 The second embodiment of this application provides a question-answering optimization method. Based on the above embodiments of this application, content that is the same as or similar to the above embodiments can be referred to the above description and will not be repeated hereafter. On this basis, the question-answering optimization method is applied to a third device, on which a trained answer prediction model is deployed; the question-answering optimization method includes the following steps:
[0090] Step A10: Obtain the initial prompt word to be reasoned, and perturb the initial prompt word to be reasoned to obtain the perturbed prompt word to be reasoned;
[0091] The execution subject of the method in this embodiment can be a question-and-answer optimization device, a question-and-answer optimization terminal device, or a server. This embodiment takes a question-and-answer optimization device as an example. The question-and-answer optimization device can be integrated into terminal devices such as smartphones and computers with data processing functions.
[0092] In this embodiment, it should be noted that the question-answering optimization method is applied to a third device. The third device and the first device may be the same or different. That is, the model can be trained on the first device and then deployed on the third device for application. Alternatively, the model can be trained and applied on the same device. The specific method can be determined according to the actual situation, and this embodiment does not impose any restrictions on it.
[0093] As an example, step A10 includes: obtaining the initial prompt word to be inferred input by the user. At this time, the initial prompt word to be inferred is in plaintext. Therefore, the initial prompt word to be inferred in plaintext is first perturbed to obtain the perturbed prompt word to be inferred. The perturbed prompt word to be inferred after perturbing replaces the initial prompt word to be inferred in plaintext for subsequent communication transmission and inference. In this way, even if the perturbed prompt word to be inferred is stolen by a potential attacker during subsequent communication transmission and inference, the privacy information therein cannot be accurately identified.
[0094] In one feasible implementation, the third device may also be equipped with a trained encoder, which can be used to perturb the initial prompt word to be inferred to obtain a perturbed prompt word to be inferred.
[0095] In one feasible implementation, the third device may also be equipped with a trained word embedding model, which can be used to first convert the initial prompt word to be reasoned into an initial prompt word embedding, and then perturb the initial prompt word embedding to be reasoned to obtain a perturbed prompt word to be reasoned in the form of a word embedding.
[0096] Step A20: Send the inference perturbation prompt to the second device so that the second device can generate the inference perturbation answer corresponding to the inference perturbation prompt through its own deployed large model;
[0097] As an example, step A20 includes: the third device sending the perturbation prompt word to be inferred obtained after perturbation processing to the second device for inference; after receiving the perturbation prompt word to be inferred, the second device inputs the perturbation prompt word to be inferred into the large model deployed on the second device for inference, and obtains the inference perturbation answer corresponding to the perturbation prompt word to be inferred. In this way, privacy information cannot be accurately identified in the inference perturbation answer obtained based on the perturbation prompt word to be inferred, thereby achieving the protection of privacy information in the inference perturbation answer.
[0098] Step A30: Receive the inference perturbation answer returned by the second device, input the inference perturbation answer and the initial prompt word to be inferred into the answer prediction model, and predict the second target answer generated by the large model based on the initial prompt word to be inferred to obtain the predicted answer.
[0099] As an example, step A30 includes: receiving the reasoning perturbation answer returned by the second device after reasoning based on the perturbation prompt word to be reasoned; inputting the reasoning perturbation answer and the initial prompt word to be reasoned into the answer prediction model; predicting the second target answer generated by the large model based on the initial prompt word to be reasoned through the answer prediction model; and decoding the predicted answer from the reasoning perturbation answer based on the unperturbed initial prompt word to be reasoned.
[0100] In this embodiment, perturbation processing effectively protects the privacy information in the initial prompts for inference, overcoming the technical drawback that prompts often contain users' private information, which may be stolen during communication and inference, thus posing a high risk of privacy leakage. Simultaneously, since both the plaintext initial prompts and the answer prediction model are located locally, the answer prediction model decodes and predicts the answer from the perturbed answer based on the perturbed initial prompts. This ensures that the plaintext data remains solely on the local end and is not transmitted externally, eliminating concerns about potential attackers stealing the plaintext data and inferring the privacy information within. Furthermore, the plaintext initial prompts guide the model to accurately infer the required answer from the perturbed answer, preventing the final answer from failing to meet the user's actual needs due to perturbed data input to the large model, thus effectively improving the accuracy of question answering.
[0101] Example 3
[0102] Furthermore, embodiments of this application also provide a question-answering optimization device, referring to... Figure 4 The question-answering optimization device is applied to a first device, on which an answer prediction model to be trained is deployed; the question-answering optimization device includes:
[0103] The first acquisition module 10 is used to acquire the initial training prompt words and the first target answer, wherein the first target answer is generated by a large model deployed on the second device based on the initial training prompt words;
[0104] The first perturbation module 20 is used to perturb the initial training prompt words to obtain training perturbation prompt words;
[0105] The first sending module 30 is used to send the training perturbation prompt words to the second device, so that the second device can generate the training perturbation answer corresponding to the training perturbation prompt words through its own deployed large model;
[0106] The first prediction module 40 is used to receive the training perturbation answer returned by the second device, input the training perturbation answer and the initial training prompt word into the answer prediction model to obtain the training prediction answer;
[0107] The update module 50 is used to iteratively update the answer prediction model based on the difference between the training predicted answer and the first target answer.
[0108] Optionally, the first device is further equipped with an encoder, and the first disturbance module 20 is further configured to:
[0109] The encoder perturbs the initial training prompts to obtain perturbed training prompts.
[0110] The update module 50 is also used for:
[0111] Based on the difference between the trained predicted answer and the first target answer, the prediction loss is determined;
[0112] The answer prediction model and the encoder are iteratively updated based on the prediction loss.
[0113] Optionally, the update module 50 is further configured to:
[0114] Calculate the first gradient of the prediction loss with respect to the answer prediction model and the second gradient of the prediction loss with respect to the encoder;
[0115] The second gradient is processed using differential privacy techniques to obtain the third gradient;
[0116] The answer prediction model is iteratively updated based on the first gradient, and the encoder is iteratively updated based on the third gradient.
[0117] Optionally, the update module 50 is further configured to:
[0118] Noise data that follows a preset probability distribution is generated, wherein each element in the noise data corresponds one-to-one with each element in the second gradient;
[0119] The noise data is added to the second gradient to obtain the third gradient.
[0120] Optionally, the first device is further equipped with a word embedding model, and the first perturbation module 20 is further configured to:
[0121] The initial training prompt words are converted into initial training prompt word embeddings using the word embedding model.
[0122] The initial training prompt word embedding is perturbed to obtain the perturbed training prompt word.
[0123] Optionally, the first prediction module 40 is further configured to:
[0124] The training perturbation answer is decoded using the answer prediction model based on the initial training prompts to obtain the training prediction answer.
[0125] The question-answering optimization device provided by this invention employs the question-answering optimization method in the above embodiments, solving the technical problem of high privacy leakage risk during reasoning using large models in the prior art. Compared with the prior art, the advantages of the question-answering optimization device provided by this invention are the same as those of the question-answering optimization method provided in the above embodiments, and other technical features in this question-answering optimization device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0126] Example 4
[0127] Furthermore, embodiments of this application also provide a question-answering optimization device, which is applied to a first device on which an answer prediction model to be trained is deployed; the question-answering optimization device includes:
[0128] The acquisition module is used to acquire the initial training prompts and the first target answer, wherein the first target answer is generated by a large model deployed on the second device based on the initial training prompts.
[0129] The first perturbation module is used to perturb the initial training prompt words to obtain training perturbation prompt words;
[0130] The first sending module is used to send the training perturbation prompt words to the second device, so that the second device can generate the training perturbation answer corresponding to the training perturbation prompt words through its own deployed large model;
[0131] The first prediction module is used to receive the training perturbation answer returned by the second device, input the training perturbation answer and the initial training prompt word into the answer prediction model, and obtain the training prediction answer;
[0132] An update module is used to iteratively update the answer prediction model based on the difference between the trained predicted answer and the first target answer.
[0133] The question-answering optimization device provided by this invention employs the question-answering optimization method in the above embodiments, solving the technical problem of high privacy leakage risk during reasoning using large models in the prior art. Compared with the prior art, the advantages of the question-answering optimization device provided by this invention are the same as those of the question-answering optimization method provided in the above embodiments, and other technical features in this question-answering optimization device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0134] Example 5
[0135] Furthermore, embodiments of the present invention provide an electronic device, the electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the question-answering optimization method in the above embodiments.
[0136] The following is for reference. Figure 5 The diagram illustrates a structural schematic of an electronic device suitable for implementing embodiments of the present disclosure. The electronic devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as Bluetooth headsets, mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0137] like Figure 5 As shown, an electronic device may include a processing unit (such as a central processing unit, graphics processing unit, etc.) that can perform various appropriate actions and processes based on a program stored in read-only memory (ROM) or a program loaded from a storage device into random access memory (RAM). The RAM also stores various programs and arrays required for the operation of the electronic device. The processing unit, ROM, and RAM are interconnected via a bus. Input / output (I / O) interfaces are also connected to the bus.
[0138] Typically, the following systems can be connected to the I / O interface: input devices including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices including, for example, magnetic tapes, hard disks, etc.; and communication devices. Communication devices allow electronic devices to communicate wirelessly or wiredly with other devices to exchange arrays. Although electronic devices with various systems are shown in the figures, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems may be implemented alternatively.
[0139] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processing device, it performs the functions defined above in the methods of embodiments of this disclosure.
[0140] The electronic device provided by this invention employs the question-answering optimization method in the above embodiments, solving the technical problem of high privacy leakage risk during reasoning using large models in the prior art. Compared with the prior art, the electronic device provided by this invention has the same advantages as the question-answering optimization method provided in the above embodiments, and other technical features in this electronic device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0141] It should be understood that various parts of this disclosure can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics may be combined in any suitable manner in one or more embodiments or examples.
[0142] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
[0143] Example 6
[0144] Furthermore, this embodiment provides a computer-readable storage medium having computer-readable program instructions stored thereon, which are used to execute the question-answering optimization method in the above embodiment.
[0145] The computer-readable storage medium provided in this embodiment of the invention may be, for example, a USB flash drive, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0146] The aforementioned computer-readable storage medium may be included in an electronic device or may exist independently without being assembled into an electronic device.
[0147] The aforementioned computer-readable storage medium carries one or more programs that, when executed by an electronic device, cause the electronic device to: acquire initial training prompts and a first target answer, wherein the first target answer is generated by a large model deployed on a second device based on the initial training prompts; perturb the initial training prompts to obtain perturbed training prompts; send the perturbed training prompts to the second device so that the second device can generate a training perturbed answer corresponding to the perturbed training prompts using its own deployed large model; receive the training perturbed answer returned by the second device; input the training perturbed answer and the initial training prompts into the answer prediction model to obtain a training predicted answer; and iteratively update the answer prediction model based on the difference between the training predicted answer and the first target answer.
[0148] Alternatively, the aforementioned computer-readable storage medium carries one or more programs that, when executed by an electronic device, cause the electronic device to: acquire an initial prompt word to be inferred; perturb the initial prompt word to be inferred to obtain a perturbed prompt word to be inferred; send the perturbed prompt word to be inferred to a second device, so that the second device can generate a perturbed answer corresponding to the perturbed prompt word to be inferred using a large model deployed thereon; receive the perturbed answer returned by the second device; input the perturbed answer and the initial prompt word to be inferred into the answer prediction model; predict the second target answer generated by the large model based on the initial prompt word to be inferred; and obtain a predicted answer.
[0149] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0150] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0151] The modules described in the embodiments of this disclosure can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0152] The computer-readable storage medium provided by this invention stores computer-readable program instructions for executing the above-described question-answering optimization method, thus solving the technical problem of high privacy leakage risk during inference using large models in the prior art. Compared with the prior art, the advantages of the computer-readable storage medium provided in the embodiments of this invention are the same as those of the question-answering optimization method provided in the above embodiments, and will not be repeated here.
[0153] Example 7
[0154] Furthermore, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the question-answering optimization method described above.
[0155] The computer program product provided in this application solves the technical problem of high privacy leakage risk during reasoning using large models in existing technologies. Compared with the prior art, the advantages of the computer program product provided in the embodiments of this invention are the same as those of the question-answering optimization method provided in the above embodiments, and will not be repeated here.
[0156] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent scope of this application.
Claims
1. A question-answering optimization method, characterized in that, The question-answering optimization method is applied to a first device, on which an answer prediction model to be trained is deployed; the question-answering optimization method includes the following steps: Obtain initial training prompts and a first target answer, wherein the first target answer is generated by a large model deployed on a second device based on the initial training prompts; The initial training prompts are perturbed to obtain perturbed training prompts; The training perturbation prompt is sent to the second device, so that the second device can generate the training perturbation answer corresponding to the training perturbation prompt using its own deployed large model; Receive the training perturbation answer returned by the second device, input the training perturbation answer and the initial training prompt word into the answer prediction model to obtain the training prediction answer; Based on the difference between the trained predicted answer and the first target answer, the answer prediction model is iteratively updated; The first device is also equipped with an encoder, and the step of perturbing the initial training prompts to obtain perturbed training prompts includes: The encoder is used to perturb the initial training prompts to obtain perturbed training prompts. The step of iteratively updating the answer prediction model based on the difference between the trained predicted answer and the first target answer includes: Based on the difference between the trained predicted answer and the first target answer, the prediction loss is determined; The answer prediction model and the encoder are iteratively updated based on the prediction loss. The step of iteratively updating the answer prediction model and the encoder based on the prediction loss includes: Calculate the first gradient of the prediction loss with respect to the answer prediction model and the second gradient of the prediction loss with respect to the encoder; The second gradient is processed using differential privacy techniques to obtain the third gradient; The answer prediction model is iteratively updated based on the first gradient, and the encoder is iteratively updated based on the third gradient.
2. The question-answering optimization method as described in claim 1, characterized in that, The step of performing differential privacy processing on the second gradient to obtain the third gradient includes: Noise data that follows a preset probability distribution is generated, wherein each element in the noise data corresponds one-to-one with each element in the second gradient; The noise data is added to the second gradient to obtain the third gradient.
3. The question-answering optimization method as described in claim 1, characterized in that, The first device is also equipped with a word embedding model, and the step of perturbing the initial training prompt words to obtain perturbed training prompt words includes: The initial training prompt words are converted into initial training prompt word embeddings using the word embedding model. The initial training prompt word embedding is perturbed to obtain the perturbed training prompt word.
4. The question-answering optimization method as described in claim 1, characterized in that, The step of inputting the training perturbation answer and the initial training prompt words into the answer prediction model to obtain the training predicted answer includes: The training perturbation answer is decoded using the answer prediction model based on the initial training prompts to obtain the training prediction answer.
5. A question-answering optimization device, characterized in that, The question-answering optimization device is applied to a first device, on which an answer prediction model to be trained is deployed; the question-answering optimization device includes: The first acquisition module is used to acquire initial training prompts and a first target answer, wherein the first target answer is generated by a large model deployed on the second device based on the initial training prompts. The first perturbation module is used to perturb the initial training prompt words to obtain training perturbation prompt words; The first sending module is used to send the training perturbation prompt words to the second device, so that the second device can generate the training perturbation answer corresponding to the training perturbation prompt words through its own deployed large model; The first prediction module is used to receive the training perturbation answer returned by the second device, input the training perturbation answer and the initial training prompt word into the answer prediction model, and obtain the training prediction answer; The update module is used to iteratively update the answer prediction model based on the difference between the trained predicted answer and the first target answer; The first device is also equipped with an encoder, and the first disturbance module is further used for: The encoder is used to perturb the initial training prompts to obtain perturbed training prompts. The update module is also used for: Based on the difference between the trained predicted answer and the first target answer, the prediction loss is determined; The answer prediction model and the encoder are iteratively updated based on the prediction loss. Calculate the first gradient of the prediction loss with respect to the answer prediction model and the second gradient of the prediction loss with respect to the encoder; The second gradient is processed using differential privacy techniques to obtain the third gradient; The answer prediction model is iteratively updated based on the first gradient, and the encoder is iteratively updated based on the third gradient.
6. An electronic device, characterized in that, The electronic device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the steps of the question-answering optimization method according to any one of claims 1 to 4.
7. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and the computer-readable storage medium stores a program that implements the question-answering optimization method. The program that implements the question-answering optimization method is executed by a processor to implement the steps of the question-answering optimization method as described in any one of claims 1 to 4.
8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the question-answering optimization method as described in any one of claims 1 to 4.