Question and answer method and device, electronic equipment, storage medium and program product

By generating prompt word templates and using reversible adversarial network to process Q&A results, avoiding direct sending of user question texts, the problem of data leakage in existing Q&A methods is solved, and data security guarantees and security enhancement of large language model calls are achieved.

CN119203967APending Publication Date: 2024-12-27CHINA MOBILE GROUP ZHEJIANG +3
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411268605.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-11
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

Existing question-and-answer methods can easily lead to private data stored on local devices, which poses a risk of data leakage, and is difficult to ensure data security.

Method used

A question-and-answer method is adopted to obtain the user's question text, generate a prompt word template, and use a pre-trained reversible adversarial network to generate pseudo-semantic text, input the pseudo-semantic text into the large language model of the remote server, and obtain the initial question-and-answer result. Then use the reversible adversarial network to perform semantic restoration to generate the final answer text, avoiding directly sending the user's question text to the large language model, and reducing the risk of data leakage.

Benefits of technology

It effectively reduces the risk of data leakage, ensures data security, and at the same time enhances the security of large language model calls, which is suitable for different text processing tasks and privacy protection needs, and is highly universal.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119203967A_ABST
    Figure CN119203967A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, and provides a question and answer method and device, electronic equipment, a storage medium and a program product. The method comprises the steps of obtaining a question text of a user; generating a prompt word template based on the question text; inputting the cue word template into a pre-trained reversible adversarial network to obtain a pseudo-semantic text output by the reversible adversarial network; inputting the pseudo-semantic text into a pre-trained large language model to obtain an initial question and answer result output by the large language model; the large language model is deployed in a far-end server; inputting the initial question and answer result into a reversible adversarial network to obtain a semantic restoration text output by the reversible adversarial network; and generating an answer text based on the semantic restoration text. By means of the mode, in the question answering process of the user, the question text of the user is not directly sent to the large language model, direct calling of the large language model is avoided, the data leakage risk is reduced, and data safety can be guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a question-answering method, device, electronic device, storage medium, and program product. Background Art

[0002] With the advancement of artificial intelligence (AI) technology, the application of large language models (LLMs) has attracted increasing attention. Large language models are mostly used as general-purpose question-answering tools, but may not be fully applicable in some specific domains. Therefore, how to combine large language models with private data in specific domains has become a pressing issue.

[0003] To train a large language model suitable for a specific vertical domain, it is necessary to fine-tune the large language model using private data from that domain. If local device performance is low and the large language model cannot be deployed, the large language model can be deployed on a remote server. The locally stored private data for the specific vertical domain can then be sent to the large language model. The large language model can then perform model training and data processing on the remote server. When users need to use the large language model for vertical domain Q&A, they can remotely call the large language model.

[0004] However, existing question-and-answer methods are prone to leaking private data stored in local devices, posing a risk of data leakage and making it difficult to ensure data security. Summary of the Invention

[0005] The embodiments of the present application provide a question-and-answer method, device, electronic device, storage medium, and program product to solve the technical problem that existing question-and-answer methods have the risk of data leakage and are difficult to ensure data security.

[0006] In a first aspect, an embodiment of the present application provides a question-answering method, including: obtaining a user's question text; generating a prompt word template based on the question text; inputting the prompt word template into a pre-trained reversible adversarial network to obtain a pseudo-semantic text output by the reversible adversarial network; inputting the pseudo-semantic text into a pre-trained large language model to obtain an initial question-answering result output by the large language model; deploying the large language model on a remote server; inputting the initial question-answering result into a reversible adversarial network to obtain a semantically restored text output by the reversible adversarial network; and generating an answer text based on the semantically restored text.

[0007] In one embodiment, the reversible adversarial network includes a text feature extractor, a first generator, a second generator, and a discriminator; wherein the text feature extractor is used to extract features from a prompt word template to obtain a first text feature; the first generator is used to generate pseudo-semantic text based on the first text feature; the text feature extractor is also used to extract features from an initial question-and-answer result to obtain a second text feature; and the second generator is used to generate semantically restored text based on the second text feature.

[0008] In one embodiment, the text feature extractor includes an embedding layer, a self-attention network layer, a first normalization layer, a feedforward neural network layer, and a second normalization layer connected in sequence; the first generator includes a first convolutional layer, a third normalization layer, a first upsampling layer, a second convolutional layer, and a first linear layer connected in sequence; the second generator includes a third convolutional layer, a fourth normalization layer, a second upsampling layer, a fourth convolutional layer, and a second linear layer connected in sequence; the discriminator includes a fifth convolutional layer, a fifth normalization layer, a sixth convolutional layer, and a third linear layer connected in sequence.

[0009] In one embodiment, a reversible adversarial network is trained using a preset loss function; wherein the preset loss function is determined based on a first loss function, a second loss function, and a third loss function; the first loss function is a loss function that measures the semantic consistency of the text conversion process; the second loss function is an adversarial loss function of the first generator; and the third loss function is an adversarial loss function of the second generator.

[0010] In one embodiment, a prompt word template is generated based on the question text, including: obtaining private text; performing text segmentation on the private text to obtain multiple text fragments; performing semantic retrieval on the question text to determine a first text fragment from the multiple text fragments; the first text fragment is the text fragment with the highest similarity to the question text; performing entity recognition on the first text fragment to obtain private data in the first text fragment; replacing the private data in the first text fragment to obtain a second text fragment; and generating a prompt word template based on the question text and the second text fragment.

[0011] In one embodiment, generating a response text based on a semantically restored text includes: obtaining private data; and replacing the semantically restored text based on the private data to obtain the response text.

[0012] In a second aspect, an embodiment of the present application provides a question-and-answer device, comprising: an acquisition module for acquiring a user's question text; a generation module for generating a prompt word template based on the question text; a text conversion module for generating, based on the question text, a prompt word template input into a pre-trained reversible adversarial network to obtain a pseudo-semantic text output by the reversible adversarial network; a remote call module for inputting the pseudo-semantic text into a pre-trained large language model to obtain an initial question-and-answer result output by the large language model; the large language model is deployed on a remote server; the text conversion module is also used to input the initial question-and-answer result into a reversible adversarial network to obtain a semantically restored text output by the reversible adversarial network; and a question-and-answer module for generating an answer text based on the semantically restored text.

[0013] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above-mentioned question-and-answer methods when executing the computer program.

[0014] In a fourth aspect, an embodiment of the present application provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, it implements any of the above-mentioned question-and-answer methods.

[0015] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which implements any of the above-mentioned question-and-answer methods when executed by a processor.

[0016] The question-answering method, device, electronic device, storage medium, and program product provided in the embodiments of the present application first generate a prompt word template based on the user's question text, then use a reversible adversarial network to generate pseudo-semantic text based on the prompt word template, input the pseudo-semantic text into a large language model deployed on a remote server, and after obtaining the initial question-answering result output by the large language model, use a reversible adversarial network to restore the initial question-answering result to obtain a semantically restored text, and finally generate an answer text based on the semantically restored text. During the user question-answering process, the user's question text is not directly sent to the large language model, avoiding direct calling of the large language model, thereby reducing the risk of data leakage and ensuring data security. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the present application or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0018] Figure 1 This is one of the flow charts of the question-answering method provided in the embodiment of the present application.

[0019] Figure 2 This is the second flow chart of the question-and-answer method provided in the embodiment of the present application.

[0020] Figure 3 This is the third flow chart of the question-and-answer method provided in the embodiment of this application.

[0021] Figure 4 It is a schematic diagram of the model structure and operation mechanism of the reversible adversarial network provided in the embodiment of the present application.

[0022] Figure 5 Schematic diagram of the semantic conversion process of the reversible adversarial network provided in an embodiment of the present application.

[0023] Figure 6 It is a structural diagram of the text feature extractor provided in an embodiment of the present application.

[0024] Figure 7 It is a structural diagram of the generator provided in an embodiment of the present application.

[0025] Figure 8 Schematic diagram of the structure of the discriminator provided in an embodiment of the present application.

[0026] Figure 9 This is a schematic diagram of the calculation process of the first loss function provided in an embodiment of the present application.

[0027] Figure 10 It is a structural diagram of the question-answering device provided in an embodiment of the present application.

[0028] Figure 11 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0029] To make the objectives, technical solutions, and advantages of this application more clear, the technical solutions in this application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making any creative efforts are within the scope of protection of this application.

[0030] See also Figure 1 , Figure 1 This is one of the flow charts of the question-answering method provided in the embodiment of the present application. In the embodiment of the present application, the question-answering method is applied to the local device, and the question-answering method includes steps S110 to S160, each of which is as follows: S110: Obtain the user's question text.

[0031] S120: Generate a prompt word template based on the question text.

[0032] See also Figure 2 and Figure 3 , Figure 2 This is the second flow chart of the question-answering method provided in the embodiment of the present application. Figure 3 This is the third flow chart of the question-and-answer method provided in the embodiment of this application.

[0033] like Figure 2 and Figure 3 As shown, the local device stores private data in vertical fields, and most of the private data is stored in text form, that is, private text.

[0034] Optionally, the text format of the private text includes but is not limited to doc, docx, txt, md, csv, json, etc.

[0035] Specifically, the file loading process is first performed to load the locally stored private text into the local device to complete the acquisition of the local private text; the private text is segmented to obtain multiple text segments to adapt to subsequent processing.

[0036] Furthermore, semantic retrieval is performed on the question text to determine a first text segment from multiple text segments. The first text segment is the text segment with the highest similarity to the question text (i.e. Figure 2 similar text in ); perform entity recognition on the first text segment to obtain private data in the first text segment, and replace the private data in the first text segment to obtain a second text segment.

[0037] Specifically, text vectorization processing is performed, and the user's question text is encoded into a question vector through the embedding model, and each text fragment is encoded into a corresponding high-dimensional text vector through the embedding model for semantic retrieval.

[0038] After obtaining the question vector and each high-dimensional text vector, semantic retrieval can be performed. In the vector repository, the high-dimensional text vector with the highest similarity to the question vector is retrieved; the text segment corresponding to the high-dimensional text vector with the highest similarity to the question vector is used as the first text segment, that is, the text segment with the highest similarity to the question text.

[0039] After determining the first text segment, entity recognition is performed on the first text segment through entity recognition technology to obtain the private data (i.e., key data) in the first text segment; the private data in the first text segment is replaced to obtain the second text segment, thereby avoiding the leakage of key data and completing the privacy processing of the data.

[0040] Furthermore, a prompt word template is generated based on the question text and the second text segment.

[0041] Specifically, the retrieved second text segment and the user's question text are merged to generate a prompt word template.

[0042] S130: Inputting the prompt word template into the pre-trained reversible adversarial network to obtain the pseudo semantic text output by the reversible adversarial network.

[0043] S140: Input the pseudo-semantic text into the pre-trained large language model to obtain the initial question-answering result output by the large language model.

[0044] The large language model is deployed on a remote server, and a question-answering mechanism based on the large language model can be implemented on the basis of a local ordinary performance server, avoiding excessive occupation of local resources by the large language model and reducing the cost of using local equipment.

[0045] Specifically, the API (Application Programming Interface) interface is called to send the pseudo-semantic text to the remote server, and the pseudo-semantic text is input into the pre-trained large language model deployed on the remote server. The large language model can perform model inference based on the pseudo-semantic text to generate and output the initial question and answer results.

[0046] After obtaining the initial question and answer result, the remote server may send the initial question and answer result to the local device.

[0047] S150: Input the initial question-answering result into the reversible adversarial network to obtain the semantically restored text output by the reversible adversarial network.

[0048] Specifically, the local device can input the initial question-and-answer results into the reversible adversarial network to obtain the text output by the reversible adversarial network. The process of generating semantically restored text can be understood as the inverse process of generating pseudo-semantic text.

[0049] S160: Generate a response text based on semantically restored text.

[0050] After completing semantic restoration and obtaining the semantically restored text, the private data is obtained, that is, the key data in the first text segment identified by the entity recognition technology.

[0051] The semantically restored text is replaced based on the private data, and the private data is replaced into the semantically restored text converted by the reversible adversarial network to obtain the answer text.

[0052] By hiding or replacing private data, the possibility of private data leakage during text processing can be effectively prevented. At the same time, the pseudo-semantic text generated by the reversible adversarial network adds an additional layer of security, protecting the original data from being identified even under adversarial attacks. Therefore, this question-answering method can adapt to different text processing tasks and different privacy protection needs and has good versatility. In addition, if the text generated by the reversible adversarial network is reversible, privacy can be protected without losing the original information, which is very important for application scenarios that require retaining the original data. By generating pseudo-semantic text with similar structure, the system can resist potential adversarial attacks and enhance the security of large language model calls. Moreover, the text processing process of the reversible adversarial network can be integrated into the existing data processing process as a module or middleware without making large-scale changes to the entire system architecture. It is applicable to a variety of industries and application scenarios and has high universality.

[0053] The question-answering method provided in the embodiment of the present application first generates a prompt word template based on the user's question text, then generates pseudo-semantic text based on the prompt word template using a reversible adversarial network, inputs the pseudo-semantic text into a large language model deployed on a remote server, and after obtaining the initial question-answering result output by the large language model, uses the reversible adversarial network to restore the initial question-answering result to obtain a semantically restored text, and finally generates an answer text based on the semantically restored text. During the user question-answering process, the user's question text is not directly sent to the large language model, avoiding direct calling of the large language model, thereby reducing the risk of data leakage and ensuring data security.

[0054] In one embodiment, the reversible adversarial network includes a text feature extractor, a first generator, a second generator, and a discriminator; wherein the text feature extractor is used to extract features from a prompt word template to obtain a first text feature; the first generator is used to generate pseudo-semantic text based on the first text feature; the text feature extractor is also used to extract features from an initial question-and-answer result to obtain a second text feature; and the second generator is used to generate semantically restored text based on the second text feature.

[0055] See also Figure 4 , Figure 4 It is a schematic diagram of the model structure and operation mechanism of the reversible adversarial network provided in the embodiment of the present application.

[0056] like Figure 4 As shown, in this embodiment, the operation mechanism of the reversible adversarial network includes three parts: pseudo-semantic text generation, semantic discrimination and pseudo-semantic text restoration.

[0057] Specifically, the reversible adversarial network includes a text feature extractor, a first generator, a second generator and a discriminator.

[0058] The text feature extractor is used to extract features from the prompt word template to obtain a first text feature.

[0059] The first generator is used to generate pseudo semantic text based on the first text feature.

[0060] The process of pseudo-semantic text generation is implemented by the text feature extractor and the first generator.

[0061] See also Figure 5 , Figure 5 Schematic diagram of the semantic conversion process of the reversible adversarial network provided in an embodiment of the present application.

[0062] Specifically, if Figure 5 As shown in the figure, after obtaining the prompt word template, the prompt word template is used as the input text data X of the reversible adversarial network. The input text data X is obtained by retrieving the local text segment with the highest similarity with the question vector, and the private data has been preliminarily identified using entity recognition technology to complete the data replacement process.

[0063] The text feature extractor performs feature extraction on the input text data X to obtain a first text feature; the first text feature is input into the first generator Gab, and the pseudo semantic text is generated by the first generator Gab.

[0064] The text feature extractor is also used to extract features from the initial question and answer results to obtain the second text feature.

[0065] The second generator is used to generate semantically restored text based on the second text feature.

[0066] The process of pseudo-semantic text restoration is implemented by the text feature extractor and the second generator.

[0067] Specifically, after obtaining the initial question-answer result, the text feature extractor is used to extract the feature of the initial question-answer result to obtain the second text feature; the second text feature is input into the second generator Gba, and the semantic restoration text is generated by the second generator Gba. .

[0068] The semantic discrimination process is implemented by the discriminator D.

[0069] In one embodiment, the text feature extractor includes an embedding layer, a self-attention network layer, a first normalization layer, a feedforward neural network layer, and a second normalization layer connected in sequence; the first generator includes a first convolutional layer, a third normalization layer, a first upsampling layer, a second convolutional layer, and a first linear layer connected in sequence; the second generator includes a third convolutional layer, a fourth normalization layer, a second upsampling layer, a fourth convolutional layer, and a second linear layer connected in sequence; the discriminator includes a fifth convolutional layer, a fifth normalization layer, a sixth convolutional layer, and a third linear layer connected in sequence.

[0070] See also Figure 6 , Figure 6 It is a structural diagram of the text feature extractor provided in an embodiment of the present application.

[0071] like Figure 6 As shown in the figure, the text feature extractor is used to realize feature extraction of text data. The text feature extractor includes an embedding layer (i.e., Embed), a self-attention network layer (i.e., multi-head attention), a first normalization layer (i.e., Add&Norm), a feedforward neural network layer (i.e., Feed Forward), and a second normalization layer (i.e., Add&Norm) connected in sequence.

[0072] Specifically, taking the prompt word template as the input text data X as an example, the input text data X will be converted into a word embedding vector by the embedding layer, and each word or token in the input text data X can be mapped to a fixed-length vector space.

[0073] Preferably, position encoding is introduced into the text feature extractor to provide the position information of each word in the input text data X. The position encoding is usually a fixed vector added to the word embedding vector, and its value changes with the position of the word.

[0074] Furthermore, a multi-head attention mechanism is introduced in the text feature extractor, allowing the model to focus on different parts of the input in different representation subspaces.

[0075] Assume that the input data of the multi-head attention layer is , after linear transformation, we can obtain the query vector sequence Q, key vector sequence K and value vector sequence V respectively: ; ; ; in, is the weight matrix of the query vector sequence, is the weight matrix of the key vector sequence, is the weight matrix of the sequence of value vectors.

[0076] The attention mechanism formula is:

[0077] in, is the i-th network layer, att is the attention function, is the i-th parameter in the query vector sequence, is the jth parameter in the sequence of value vectors, are model parameters, is the jth parameter in the key vector sequence, is the activation function and s is the model parameter.

[0078] The multi-head attention mechanism can concatenate the outputs of a single attention layer into vectors to finally obtain the output of the multi-head attention layer, where the symbol Represents vector concatenation. This embodiment adopts a three-head attention mechanism. The formula of the three-head attention mechanism is as follows: ; in, is the output of the three-head attention layer, 、 、 They are the first attention layer, the second attention layer, and the third attention layer respectively.

[0079] The multi-head attention mechanism can enhance the ability of reversible adversarial networks to capture information.

[0080] Furthermore, residual links are introduced in the text feature extractor, that is, the output of each sublayer (including the self-attention network layer and the feedforward neural network layer) is added to its input, and then layer normalization is performed. Residual links help avoid the possibility of gradient vanishing in deep networks.

[0081] See also Figure 7 , Figure 7 It is a structural diagram of the generator provided in an embodiment of the present application.

[0082] It should be noted that, in this embodiment, the reversible adversarial network includes two generators, namely a first generator Gab and a second generator Gba, and the network structures of the first generator Gab and the second generator Gba are the same.

[0083] Among them, the first generator Gab is used to convert the prompt word template into pseudo-semantic text (i.e. text data -> pseudo-semantic text data), and the second generator Gba is used to convert the initial question and answer results into semantically restored text (i.e. pseudo-semantic text data -> text data).

[0084] Figure 7 Take the first generator Gab as an example, Figure 7 As shown in the figure, the first generator includes the first convolutional layer (i.e., Convolutional layer -> Activation (LeakyReLU)), the third normalization layer (i.e., Add&Norm), the first upsampling layer (i.e., Upsampling layer -> Activation (ReLU)), the second convolutional layer (i.e., Convolutional layer -> Activation (tanh)), and the first linear layer (i.e., Linear layer -> Softmax), which are connected in sequence. The first linear layer uses a softmax structure because text data is discrete category probabilities rather than continuous data like images.

[0085] Specifically, the first convolutional layer is used to capture the high-level feature representation of the input data and activate the convolution features through the LeakyReLU function. The expression of the LeakyReLU function is as follows: ; Its derivative function is as follows:

[0086] Using the LeakyReLU function helps the gradient flow during training, reduces the risk of overfitting, and allows the network to learn more complex features.

[0087] The third normalization layer introduces a residual connection (Add), allowing signals in the network to bypass some layers and propagate directly, helping to address the vanishing gradient problem in deep networks. Normalization (Norm) stabilizes the training process by normalizing the layer input, accelerating convergence and helping to reduce internal covariate shift.

[0088] The first upsampling layer is used to increase the spatial resolution of the feature map.

[0089] After upsampling, the second convolutional layer is used to further refine the features and activated by the tanh function.

[0090] Furthermore, the output of the convolutional layer is mapped to the final output space through the first linear layer and mapped to the discrete space.

[0091] The text processing process of the first generator Gab and the second generator Gba is a reverse process. The structures of the first generator Gab and the second generator Gba are consistent, so the structure of the second generator Gba is not repeated here.

[0092] See also Figure 8 , Figure 8 Schematic diagram of the structure of the discriminator provided in an embodiment of the present application.

[0093] The discriminator (D) distinguishes whether newly generated text originates from its corresponding data domain. This distinction provides feedback to the generator during training, prompting it to learn how to produce more realistic pseudo-semantic text. Furthermore, the discriminator helps prevent the generator from experiencing mode collapse, thereby improving the quality and diversity of generated text.

[0094] like Figure 8 As shown in the figure, the discriminator includes the fifth convolutional layer (i.e. Convolutional layer ->Activation (LeakyReLU)), the fifth normalization layer (i.e. Add&Norm), the sixth convolutional layer (i.e. Convolutionallayer) and the third linear layer (i.e. Linear layer) connected in sequence.

[0095] In one embodiment, the reversible adversarial network is trained using a preset loss function.

[0096] Among them, the preset loss function is determined based on the first loss function, the second loss function and the third loss function; the first loss function is a loss function for measuring the semantic consistency of the text conversion process; the second loss function is the adversarial loss function of the first generator; the third loss function is the adversarial loss function of the second generator.

[0097] See also Figure 9 , Figure 9 This is a schematic diagram of the calculation process of the first loss function provided in an embodiment of the present application.

[0098] In this embodiment, two loss functions are designed for the reversible adversarial network training process, namely, a loss function for measuring the semantic consistency of the text conversion process (i.e., the first loss function, Consistency loss) and a loss function of the conventional adversarial network, LSGAN loss.

[0099] like Figure 9 As shown, assuming X is the text data to be processed, is the data converted by the reversible adversarial network, and Y is the text data converted back by the reversible adversarial network, then there are two mapping functions and , respectively represent the mapping relationship between the first generator Gab and the second generator Gba. The first loss function, Consistency loss, is used to ensure that the text data is After the transformation, the original semantics can still be maintained. Therefore, the expression of the first loss function Consistencyloss is as follows: ; Among them, G is the mapping function from domain X to domain Y; F is the mapping function from domain Y to domain X; is the feature distribution after feature extraction in the source domain X; is the feature distribution after feature extraction in the target domain Y; is the L1 norm, which is used to measure the difference between two data.

[0100] The loss function of the conventional adversarial network, LSGAN loss, is used to train the generator and discriminator. The expression of the training loss function of the generator is as follows: ; in, is the input noise distribution, is the data generated by the generator, is the judgment of the discriminator on the generated data.

[0101] It should be noted that the training loss function of the first generator Gab (i.e., the second loss function) and the training loss function of the second generator Gba (i.e., the third loss function) can both be calculated using the above formula and are respectively recorded as the second loss function And the third loss function .

[0102] The expression of the discriminator training loss function is as follows: ; Comprehensive consideration, preset loss function The expression is as follows: ; in, is the weight of the first loss function.

[0103] In one embodiment, a prompt word template is generated based on the question text, including: obtaining private text; performing text segmentation on the private text to obtain multiple text fragments; performing semantic retrieval on the question text to determine a first text fragment from the multiple text fragments; the first text fragment is the text fragment with the highest similarity to the question text; performing entity recognition on the first text fragment to obtain private data in the first text fragment; replacing the private data in the first text fragment to obtain a second text fragment; and generating a prompt word template based on the question text and the second text fragment.

[0104] Specifically, the file loading process is first performed to load the locally stored private text into the local device to complete the acquisition of the local private text; the private text is segmented to obtain multiple text segments to adapt to subsequent processing.

[0105] Furthermore, semantic retrieval is performed on the question text to determine a first text segment from multiple text segments. The first text segment is the text segment with the highest similarity to the question text (i.e. Figure 2 similar text in ); perform entity recognition on the first text segment to obtain private data in the first text segment, and replace the private data in the first text segment to obtain a second text segment.

[0106] Specifically, text vectorization processing is performed, and the user's question text is encoded into a question vector through the embedding model, and each text fragment is encoded into a corresponding high-dimensional text vector through the embedding model for semantic retrieval.

[0107] After obtaining the question vector and each high-dimensional text vector, semantic retrieval can be performed. In the vector repository, the high-dimensional text vector with the highest similarity to the question vector is retrieved; the text segment corresponding to the high-dimensional text vector with the highest similarity to the question vector is used as the first text segment, that is, the text segment with the highest similarity to the question text.

[0108] After determining the first text segment, entity recognition is performed on the first text segment through entity recognition technology to obtain the private data (i.e., key data) in the first text segment; the private data in the first text segment is replaced to obtain the second text segment, thereby avoiding the leakage of key data and completing the privacy processing of the data.

[0109] Furthermore, a prompt word template is generated based on the question text and the second text segment.

[0110] Specifically, the retrieved second text segment and the user's question text are merged to generate a prompt word template.

[0111] In one embodiment, generating a response text based on a semantically restored text includes: obtaining private data; and replacing the semantically restored text based on the private data to obtain the response text.

[0112] After completing semantic restoration and obtaining the semantically restored text, the private data is obtained, that is, the key data in the first text segment identified by the entity recognition technology.

[0113] The semantically restored text is replaced based on the private data, and the private data is replaced into the semantically restored text converted by the reversible adversarial network to obtain the answer text.

[0114] This embodiment of the application also provides a question-answering device. Figure 10 , Figure 1010 is a schematic diagram of the structure of the question-answering device provided in the embodiment of the present application. In the embodiment of the present application, the question-answering device includes an acquisition module 1010, a generation module 1020, a text conversion module 1030, a remote call module 1040 and a question-answering module 1050.

[0115] The acquisition module 1010 is used to acquire the user's question text.

[0116] The generating module 1020 is used to generate a prompt word template based on the question text.

[0117] The text conversion module 1030 is used to generate a prompt word template based on the question text and input it into a pre-trained reversible adversarial network to obtain a pseudo semantic text output by the reversible adversarial network.

[0118] The remote calling module 1040 is used to input the pseudo-semantic text into the pre-trained large language model to obtain the initial question-answering result output by the large language model.

[0119] The large language model is deployed on a remote server.

[0120] The text conversion module 1030 is also used to input the initial question-answering results into the reversible adversarial network to obtain the semantically restored text output by the reversible adversarial network.

[0121] The question-answering module 1050 is used to restore the text based on semantics and generate answer text.

[0122] In one embodiment, the reversible adversarial network includes a text feature extractor, a first generator, a second generator, and a discriminator; wherein the text feature extractor is used to extract features from a prompt word template to obtain a first text feature; the first generator is used to generate pseudo-semantic text based on the first text feature; the text feature extractor is also used to extract features from an initial question-and-answer result to obtain a second text feature; and the second generator is used to generate semantically restored text based on the second text feature.

[0123] In one embodiment, the text feature extractor includes an embedding layer, a self-attention network layer, a first normalization layer, a feedforward neural network layer, and a second normalization layer connected in sequence; the first generator includes a first convolutional layer, a third normalization layer, a first upsampling layer, a second convolutional layer, and a first linear layer connected in sequence; the second generator includes a third convolutional layer, a fourth normalization layer, a second upsampling layer, a fourth convolutional layer, and a second linear layer connected in sequence; the discriminator includes a fifth convolutional layer, a fifth normalization layer, a sixth convolutional layer, and a third linear layer connected in sequence.

[0124] In one embodiment, a reversible adversarial network is trained using a preset loss function; wherein the preset loss function is determined based on a first loss function, a second loss function, and a third loss function; the first loss function is a loss function that measures the semantic consistency of the text conversion process; the second loss function is an adversarial loss function of the first generator; and the third loss function is an adversarial loss function of the second generator.

[0125] In one embodiment, a generation module 1020 is used to obtain private text; perform text segmentation on the private text to obtain multiple text fragments; perform semantic retrieval on the question text to determine a first text fragment from the multiple text fragments; the first text fragment is the text fragment with the highest similarity to the question text; perform entity recognition on the first text fragment to obtain private data in the first text fragment; replace the private data in the first text fragment to obtain a second text fragment; and generate a prompt word template based on the question text and the second text fragment.

[0126] In one embodiment, the question-answering module 1050 is configured to obtain private data and replace the semantically restored text based on the private data to obtain the answer text.

[0127] The embodiment of the present application also provides an electronic device, Figure 11 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, such as Figure 11 As shown, the electronic device may include: a processor 1110, a communication interface 1120, a memory 1130, and a communication bus 1140, wherein the processor 1110, the communication interface 1120, and the memory 1130 communicate with each other via the communication bus 1140. The processor 1110 may call logic instructions in the memory 1130 to execute the question-answering method.

[0128] Furthermore, the logic instructions in the aforementioned memory 1130 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product, stored in a storage medium, includes instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0129] An embodiment of the present application also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, it is implemented to execute the question-and-answer method provided by the above methods.

[0130] An embodiment of the present application also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the question-and-answer methods provided by the above methods.

[0131] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.

[0132] Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented using software plus a necessary general-purpose hardware platform, or of course, hardware. Based on this understanding, the essence of the above technical solution, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for causing a computer device (such as a personal computer, server, or network device) to execute the methods described in each embodiment or certain portions of the embodiments.

[0133] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A question-answering method, characterized in that: include: Get the user's question text; Based on the question text, generate a prompt word template; Inputting the prompt word template into a pre-trained reversible adversarial network to obtain a pseudo semantic text output by the reversible adversarial network; Inputting the pseudo semantic text into a pre-trained large language model to obtain an initial question-answering result output by the large language model; The large language model is deployed on a remote server; Inputting the initial question-answering result into the reversible adversarial network to obtain a semantically restored text output by the reversible adversarial network; Based on the semantically restored text, a reply text is generated.

2. The question-answering method according to claim 1, characterized in that: The reversible adversarial network includes a text feature extractor, a first generator, a second generator and a discriminator; The text feature extractor is used to extract features from the prompt word template to obtain a first text feature; The first generator is used to generate the pseudo semantic text based on the first text feature; The text feature extractor is further used to extract features from the initial question and answer result to obtain a second text feature; The second generator is used to generate the semantically restored text based on the second text feature.

3. The question-answering method according to claim 2, characterized in that: The text feature extractor comprises an embedding layer, a self-attention network layer, a first normalization layer, a feedforward neural network layer and a second normalization layer connected in sequence; The first generator includes a first convolutional layer, a third normalization layer, a first upsampling layer, a second convolutional layer, and a first linear layer connected in sequence; The second generator includes a third convolutional layer, a fourth normalization layer, a second upsampling layer, a fourth convolutional layer, and a second linear layer connected in sequence; The discriminator includes a fifth convolutional layer, a fifth normalization layer, a sixth convolutional layer and a third linear layer which are connected in sequence.

4. The question-answering method according to claim 2, characterized in that: The reversible adversarial network is trained using a preset loss function; Wherein, the preset loss function is determined based on the first loss function, the second loss function and the third loss function; The first loss function is a loss function for measuring the semantic consistency of the text conversion process; The second loss function is an adversarial loss function of the first generator; The third loss function is the adversarial loss function of the second generator.

5. The question-answering method according to claim 1, characterized in that: The step of generating a prompt word template based on the question text includes: Get private text; Performing text segmentation on the private text to obtain multiple text segments; Performing semantic retrieval on the question text, and determining a first text segment from the multiple text segments; the first text segment is the text segment with the highest similarity to the question text; Performing entity recognition on the first text segment to obtain private data in the first text segment; Replacing the private data in the first text segment to obtain a second text segment; A prompt word template is generated based on the question text and the second text segment.

6. The question-answering method according to claim 5, characterized in that: The step of generating a reply text based on the semantically restored text comprises: Acquiring the private data; Based on the privacy data, the semantically restored text is replaced to obtain the answer text.

7. A question-answering device, characterized in that: include: The acquisition module is used to obtain the user's question text; A generation module, used for generating a prompt word template based on the question text; A text conversion module, for generating, based on the question text, a pseudo semantic text output by inputting the prompt word template into a pre-trained reversible adversarial network to obtain the pseudo semantic text output by the reversible adversarial network; A remote calling module, used for inputting the pseudo semantic text into a pre-trained large language model to obtain an initial question-answering result output by the large language model; the large language model is deployed on a remote server; The text conversion module is further used to input the initial question-answering result into the reversible adversarial network to obtain the semantically restored text output by the reversible adversarial network; The question-answering module is used to restore the text based on the semantics and generate an answer text.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the question-answering method according to any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the question-answering method according to any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the question-answering method according to any one of claims 1 to 6 is implemented.

Citation Information

Cited By

  • Method and system for safe question and answer and computer readable storage medium

    CN120611019A

  • Model risk assessment method and device, electronic equipment and storage medium

    CN120744415A