Method and device for searching sensitive words of a user, storage medium and program product
By generating approximate query vectors and using similarity and angle to obtain the initial retrieval set, the efficiency reduction problem caused by hidden query methods is solved, and privacy protection and retrieval accuracy of user sensitive words are achieved in large model technology.
Patent Information
- Application Number
- CN202510838080.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-20
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2045-06-20
AI Technical Summary
In large model technology, while existing hidden query methods enhance security, they reduce query efficiency and cannot effectively protect the privacy of users' sensitive words during the retrieval process.
By generating approximate query vectors, and using the first cosine similarity and the first angle to obtain the initial retrieval set, the original query vectors are avoided from being sent directly. Approximate query vectors are generated by combining sensitive word replacement, obfuscation processing, and language modeling for retrieval.
While protecting user privacy, we aim to maintain the accuracy and efficiency of searches, avoid the leakage of sensitive words, and provide a better user experience.
Smart Images

Figure CN120408719B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of privacy protection technology, and in particular to a method, apparatus, storage medium, and program product for protecting users' sensitive words during retrieval. Background Technology
[0002] With the rapid development of large model technology, various reasoning services and applications are emerging, such as search, question answering, and assisted programming. During the operation of these services, user-submitted prompts contain questions and contextual information, which may involve sensitive data, thus posing a risk of data leakage. Especially when Retrieval Augmentation (RAG) becomes a commonly used reasoning method, these sensitive words may be leaked to the knowledge base holders during the retrieval process.
[0003] To address the privacy concerns surrounding sensitive words during queries, numerous technical methods exist. For instance, a common approach is to employ covert queries to retrieve knowledge base data, thereby protecting user data. However, covert queries typically utilize cryptographic algorithms such as unintended transmission and homomorphic encryption. While these algorithms significantly enhance security, they can reduce query efficiency, ultimately impacting the overall performance of large-scale model services. Summary of the Invention
[0004] In view of this, the present disclosure provides a method, apparatus, storage medium, and program product for protecting user sensitive words in retrieval. It can obtain an initial retrieval set by acquiring a query vector that is similar to the original query vector, and then perform a secondary retrieval based on the initial retrieval set, which not only ensures the accuracy of retrieval but also protects user privacy.
[0005] Firstly, this disclosure provides a method for protecting user-sensitive words during retrieval, employing the following technical solution:
[0006] Obtain user input data, and based on the input data, obtain the original query vector and the approximate query vector;
[0007] Obtain a first cosine similarity, and obtain a first angle based on the first cosine similarity; wherein, the first cosine similarity is the cosine similarity between the original query vector and the approximate query vector;
[0008] The first included angle, the preset first threshold, and the approximate query vector are sent to the knowledge base retrieval platform for retrieval to obtain an initial retrieval set;
[0009] The initial retrieval set is sent to the user terminal, and the target retrieval set is obtained based on the user terminal's original query vector and the received initial retrieval set.
[0010] Optionally, obtaining the original query vector and the approximate query vector based on the input data includes:
[0011] The input data is then converted into a raw query vector.
[0012] The sensitive words in the input data are replaced with safe words to generate de-identified data;
[0013] The de-identified data is converted into an approximate query vector.
[0014] Optionally, obtaining the original query vector and the approximate query vector based on the input data includes:
[0015] Based on the input data, a vocabulary is constructed; wherein the vocabulary contains all unique words in the input data;
[0016] Based on the vocabulary, construct the original query vector;
[0017] Identify sensitive words in the input data and obtain the corresponding positions of the sensitive words in the original query vector;
[0018] The sensitive words are converted into sensitive word vectors, and the sensitive word vectors are then obfuscated to generate obfuscated vectors.
[0019] Based on the location, the obfuscation vector and the original query vector are fused into an approximate query vector.
[0020] Optionally, obtaining the original query vector and the approximate query vector based on the input data includes:
[0021] Obtain sensitive and non-sensitive words from the input data, and convert the sensitive words and non-sensitive words into sensitive word vectors and non-sensitive word vectors, respectively.
[0022] The sensitive word vectors and the non-sensitive word vectors are aggregated to generate the original query vector;
[0023] The sensitive word vectors are obfuscated to generate obfuscated vectors;
[0024] The obfuscation vector and the non-sensitive word vector are aggregated to generate an approximate query vector.
[0025] Optionally, obtaining the original query vector and the approximate query vector based on the input data includes:
[0026] The input data is then converted into a raw query vector.
[0027] Obtain sensitive data and non-sensitive data from the input data; wherein, the sensitive data includes at least one of sensitive words and sensitive word context information, and the non-sensitive data includes at least one of non-sensitive words and non-sensitive word context information;
[0028] Based on the sensitive data, the non-sensitive data, and the preset language model, an approximate query vector is obtained.
[0029] Optionally, sending the first included angle, the preset first threshold, and the approximate query vector to the knowledge base retrieval platform for retrieval to obtain an initial retrieval set includes:
[0030] Obtain the second cosine similarity; wherein, the second cosine similarity is the cosine similarity between the approximate query vector and the knowledge fragment in the knowledge base retrieval platform;
[0031] Based on the first included angle and the first threshold, obtain the second threshold;
[0032] The knowledge fragments with a second cosine similarity greater than or equal to the second threshold are used to form the initial retrieval set.
[0033] Optionally, the formula for calculating the second threshold is:
[0034] ;
[0035] in, The second threshold; The first threshold; This is the first included angle.
[0036] Optionally, the formula for calculating the second threshold is:
[0037] ;
[0038] in, The second threshold; The first threshold; This is the first included angle.
[0039] Optionally, obtaining the target retrieval set based on the user terminal's original query vector and the received initial retrieval set includes:
[0040] Obtain the third cosine similarity; wherein, the third cosine similarity is the cosine similarity between the original query vector and the knowledge fragment in the initial retrieval set;
[0041] The knowledge fragments whose third cosine similarity is greater than or equal to the first threshold are used to form a target retrieval set.
[0042] Secondly, this disclosure also provides a retrieval system for protecting user-sensitive words, employing the following technical solution:
[0043] The query vector acquisition module is used to acquire user input data and, based on the input data, acquire the original query vector and the approximate query vector.
[0044] The first angle acquisition module is used to acquire a first cosine similarity and acquire a first angle based on the first cosine similarity; wherein, the first cosine similarity is the cosine similarity between the original query vector and the approximate query vector;
[0045] The initial retrieval set acquisition module is used to send the first included angle, the preset first threshold and the approximate query vector to the knowledge base retrieval platform for retrieval and to obtain the initial retrieval set.
[0046] The target retrieval set acquisition module is used to send the initial retrieval set to the user terminal and acquire the target retrieval set based on the user terminal's original query vector and the received initial retrieval set.
[0047] Thirdly, this disclosure also provides a computer device, which adopts the following technical solution:
[0048] The computer device includes:
[0049] At least one processor; and,
[0050] A memory communicatively connected to the at least one processor; wherein,
[0051] The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform any of the above-described methods for protecting user-sensitive words.
[0052] Fourthly, embodiments of this disclosure also provide a computer-readable storage medium storing computer instructions for causing a computer to execute any of the above-described methods for protecting user-sensitive words.
[0053] Fifthly, embodiments of this disclosure also provide a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of any of the methods described above.
[0054] The retrieval method for protecting sensitive words provided in this disclosure generates an approximate query vector. In subsequent retrieval processes, the original query vector containing sensitive words is not directly used. The approximate query vector retains the semantic information of the original query to a certain extent, while avoiding direct exposure of sensitive words to external knowledge base retrieval platforms, thus effectively protecting the security of users' sensitive information. The first cosine similarity and the first angle quantify the similarity between the original query vector and the approximate query vector. By calculating these indicators, the approximate degree of similarity between the approximate query vector and the original query vector can be understood, providing important reference for subsequent retrieval. Only the approximate query vector, the first angle, and the first threshold are sent to the knowledge base retrieval platform, without sending the original query vector. This avoids the leakage of sensitive words during transmission and retrieval. The knowledge base retrieval platform can process the approximate query vector based on the first angle and the first threshold, filtering out potentially relevant retrieval results without accessing the user's sensitive information. The user terminal uses the original query vector for retrieval, selecting the results that best meet the user's needs from the initial retrieval set based on the precise semantics of the original query. Since the original query vector contains the complete user intent, the selected target retrieval set is more accurate and relevant.
[0055] The above description is merely an overview of the technical solution disclosed herein. In order to better understand the technical means of this disclosure and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0056] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0057] Figure 1 A flowchart illustrating the method for protecting user-sensitive words in an embodiment of this disclosure;
[0058] Figure 2 A schematic diagram of the first process for obtaining the original query vector and the approximate query vector provided in an embodiment of this disclosure;
[0059] Figure 3 A schematic diagram of the second process for obtaining the original query vector and the approximate query vector provided in the embodiments of this disclosure;
[0060] Figure 4 A third flowchart illustrating the method for obtaining the original query vector and the approximate query vector provided in this embodiment of the disclosure;
[0061] Figure 5 A schematic diagram of the fourth process for the method of obtaining the original query vector and the approximate query vector provided in the embodiments of this disclosure;
[0062] Figure 6 A flowchart illustrating the initial retrieval set acquisition method provided in this embodiment of the disclosure;
[0063] Figure 7 A schematic diagram of a retrieval system for protecting user-sensitive words provided in an embodiment of this disclosure;
[0064] Figure 8 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present disclosure. Detailed Implementation
[0065] The embodiments of this disclosure will now be described in detail with reference to the accompanying drawings.
[0066] It should be understood that the following specific examples illustrate the implementation of this disclosure, and those skilled in the art can easily understand other advantages and effects of this disclosure from the content disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. This disclosure can also be implemented or applied through other different specific implementation methods, and the details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this disclosure. It should be noted that, in the absence of conflict, the following embodiments and features in the embodiments can be combined with each other. Based on the embodiments in this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0067] It should be noted that various aspects of embodiments within the scope of the appended claims are described below. It will be apparent that the aspects described herein can be embodied in a wide variety of forms, and any particular structure and / or function described herein is merely illustrative. Based on this disclosure, those skilled in the art will understand that one aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number of aspects set forth herein can be used to implement the device and / or practice the method. Additionally, this device and / or method can be implemented using structures and / or functionalities other than one or more of the aspects set forth herein.
[0068] It should also be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of this disclosure. The drawings only show the components related to this disclosure and are not drawn according to the number, shape and size of the components in actual implementation. In actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.
[0069] Furthermore, specific details are provided in the following description to facilitate a thorough understanding of the examples. However, those skilled in the art will understand that the described aspects can be practiced without these specific details.
[0070] Reference Figure 1 This disclosure provides a method for protecting users' sensitive words during retrieval, including the following steps:
[0071] S1: Obtain user input data, and based on the input data, obtain the original query vector and the approximate query vector;
[0072] S2: Obtain the first cosine similarity, and obtain the first angle based on the first cosine similarity; where the first cosine similarity is the cosine similarity between the original query vector and the approximate query vector;
[0073] S3: Send the first included angle, the preset first threshold, and the approximate query vector to the knowledge base retrieval platform for retrieval to obtain the initial retrieval set;
[0074] S4: Send the initial search set to the user terminal, and obtain the target search set based on the user terminal's original query vector and the received initial search set.
[0075] The retrieval method for protecting sensitive words provided in this disclosure generates approximate query vectors. In subsequent retrieval processes, the original query vector containing sensitive words is not directly used. The approximate query vector retains the semantic information of the original query to a certain extent, while avoiding direct exposure of sensitive words to external knowledge base retrieval platforms, thus effectively protecting the security of users' sensitive information. The first cosine similarity and the first angle quantify the similarity between the original query vector and the approximate query vector. By calculating these indicators, the approximate query vector's approximation to the original query vector can be understood, providing important reference for subsequent retrieval. Only the approximate query vector, the first angle, and the first threshold are sent to the knowledge base retrieval platform, without sending the original query vector, avoiding the leakage of sensitive words during transmission and retrieval. The knowledge base retrieval platform can process the approximate query vector based on the first angle and the first threshold, filtering out potentially relevant retrieval results without accessing the user's sensitive information. The user terminal uses the original query vector for retrieval, selecting the results that best meet the user's needs from the initial retrieval set based on the precise semantics of the original query. Because the original query vector contains the complete user intent, the selected target retrieval set is more accurate and relevant.
[0076] In summary, this method for protecting sensitive user keywords achieves efficient and accurate retrieval while protecting sensitive user information through a series of steps, including generating approximate query vectors, quantifying similarity, controlling information transmission, and performing the final retrieval locally. On the one hand, it effectively reduces the risk of sensitive information leakage during the retrieval process, ensuring user privacy and security; on the other hand, through a reasonable retrieval mechanism, it improves retrieval efficiency and the accuracy of results, providing users with a better retrieval experience. This method has significant application value in handling retrieval scenarios involving sensitive information.
[0077] In S1, when acquiring user input data, the user, as the querying party, provides input data containing information such as questions and prompts. This input data often contains sensitive words, which must not be exposed to the knowledge base retrieval platform during the retrieval process to avoid leaking the querying party's privacy. To achieve this goal, sensitive word detection and obfuscation are performed on the input data to generate an approximate query vector that can replace the input data for retrieval on the knowledge base retrieval platform. Through these measures, user privacy is protected without affecting the accuracy and efficiency of the retrieval.
[0078] There are many methods to obtain the original query vector and the approximate query vector. This application provides four such methods. In the first specific implementation scheme, refer to... Figure 2The diagram illustrates the first step of the method for obtaining the original query vector and the approximate query vector. "Obtaining the original query vector and the approximate query vector based on the input data" includes the following steps:
[0079] S101: Transform the input data into the raw query vector;
[0080] S102: Replace sensitive words in the input data with safe words to generate de-identified data;
[0081] S103: Convert the de-identified data into an approximate query vector.
[0082] In S101, natural language processing techniques, such as word embeddings or pre-trained language models (like BERT), are used to convert the input data into high-dimensional vectors. For example, by mapping each word in the input data to a pre-trained word vector space and aggregating these word vectors (e.g., averaging or weighted averaging), a raw query vector that can represent the semantics of the input data is generated. This method can preserve the core semantic information of the input data.
[0083] In step S102, sensitive words in the input data are identified using a predefined list of sensitive words or a context-based sensitive word detection algorithm. Once identified, these sensitive words are replaced with predefined safe words. Safe words can be general, non-sensitive terms, or words that are semantically similar to the original sensitive words but not sensitive, generated through synonym replacement algorithms or dynamic desensitization. For example, some digits of an ID number can be replaced while retaining its structure and length. In this way, the generated desensitized data retains most of the semantics of the original input data while avoiding the leakage of sensitive information, thus protecting user privacy and providing a data foundation for subsequent retrieval.
[0084] In S103, the anonymized data is further processed into an approximate query vector. Similar to S101, natural language processing techniques can be used to convert the anonymized data into vector form. Since sensitive words have been removed from the anonymized data, the generated approximate query vector is semantically similar to the original query vector but does not contain sensitive information. This method ensures that sensitive information is not exposed to the knowledge base retrieval platform during the retrieval process, while still enabling effective retrieval using the anonymized semantic information.
[0085] The above method achieves desensitization by directly replacing sensitive words with safe words. It is simple to operate, has low computational cost, effectively hides sensitive information, avoids privacy leaks during the retrieval process, and retains the semantic information of the original input data as much as possible by selecting safe words with similar meanings.
[0086] In the second specific implementation scheme, refer to Figure 3 The second flowchart illustrating the method for obtaining the original query vector and approximate query vector, "Obtaining the original query vector and approximate query vector based on input data," includes the following steps:
[0087] S104: Construct a vocabulary based on the input data; wherein the vocabulary contains all unique words in the input data;
[0088] S105: Construct the original query vector based on the vocabulary;
[0089] S106: Identify sensitive words in the input data and obtain the corresponding positions of the sensitive words in the original query vector;
[0090] S107: Convert sensitive words into sensitive word vectors, obfuscate the sensitive word vectors, and generate obfuscated vectors;
[0091] S108: Based on location, merge the confusion vector and the original query vector into an approximate query vector.
[0092] In S104, text preprocessing is performed on the input data, including word segmentation, stop word removal, and other operations. All unique words are extracted from the preprocessed input data and stored in a vocabulary table, with a unique index assigned to each word in the vocabulary table.
[0093] In S105, using a vocabulary and a pre-trained word embedding model (such as Word2Vec, GloVe, or bag-of-words model), each word in the input data is mapped to a predefined vector space, and a corresponding vector is assigned to each word in the vocabulary. By aggregating these word vectors (e.g., by averaging or weighted averaging), a raw query vector that can represent the semantics of the entire input data is generated.
[0094] In S106, by tracking the index position of sensitive words in the vocabulary, the position of the sensitive words in the original query vector is determined, ensuring that subsequent processing of sensitive words can accurately act on the corresponding part of the original query vector.
[0095] In S107, for the identified sensitive words, the same method as in S105 is used to convert them into corresponding sensitive word vectors. The sensitive word vectors are then obfuscated to hide their original information. The generated obfuscated vectors are difficult to directly restore to the original sensitive word vectors, thus protecting privacy.
[0096] In S108, based on the position of the sensitive words obtained in S106 in the original query vector, the obfuscation vector is replaced with the corresponding position in the original query vector to generate an approximate query vector. This vector retains most of the semantic information of the original query vector while hiding the information of the sensitive words through obfuscation, thereby protecting the user's privacy during the retrieval process.
[0097] The above method achieves a balance between privacy protection and semantic preservation by constructing a vocabulary and accurately locating the position of sensitive words in the original query vector, combined with obfuscation processing, while ensuring the accuracy and controllability of the processing.
[0098] In the third specific implementation scheme, refer to Figure 4 The diagram illustrates the third step in the method for obtaining the original query vector and the approximate query vector. "Obtaining the original query vector and the approximate query vector based on the input data" includes the following steps:
[0099] S109: Obtain sensitive words and non-sensitive words from the input data, and convert the sensitive words and non-sensitive words into sensitive word vectors and non-sensitive word vectors respectively;
[0100] S110: Aggregate the sensitive word vectors and non-sensitive word vectors to generate the original query vector;
[0101] S111: Obfuscate the sensitive word vectors to generate obfuscated vectors;
[0102] S112: Aggregate the obfuscation vector and the non-sensitive word vector to generate an approximate query vector.
[0103] In S109, sensitive and non-sensitive words in the input data are identified and extracted using a predefined list of sensitive words or natural language processing techniques (such as text classification models). A pre-trained word embedding model is then used to convert the sensitive and non-sensitive words into corresponding vector representations. Each word is mapped to a vector in a high-dimensional space, and these vectors capture the semantic information of the word, providing a foundation for subsequent vector aggregation and obfuscation processing.
[0104] In S110, the obtained sensitive word vectors and non-sensitive word vectors are aggregated to generate a raw query vector that can represent the semantics of the entire input data. The aggregation method can be a simple average, which adds all word vectors and divides by the total number of word vectors; or a weighted average, which assigns different weights based on word importance, multiplies each word vector by its corresponding weight, sums all the multiplication results along their respective dimensions, and finally divides the sum by the total weights to obtain the raw query vector representing the semantics of the entire input data; or a simple summation, which directly adds all sensitive word vectors and non-sensitive word vectors along their respective dimensions; or a weighted summation, which assigns a weight to each word vector, multiplies each word vector by its corresponding weight, and then sums them along their respective dimensions.
[0105] In S111, in order to protect user privacy, the sensitive word vectors are obfuscated to hide the original information of the sensitive words and generate obfuscated vectors.
[0106] In S112, the aggregation method for aggregating the confusion vector and the non-sensitive word vector is similar to that in S110, and can be a simple average, weighted average, summation, or weighted summation, etc.
[0107] The above methods handle sensitive words and non-sensitive words separately, enabling more precise control over how sensitive information is processed. By aggregating the obfuscated sensitive word vectors and non-sensitive word vectors, privacy is protected while most semantic information is preserved. This approach is suitable for scenarios with high privacy protection requirements and can flexibly adapt to different data structures and needs.
[0108] There are several methods for obfuscation, including adding small perturbations, constraint optimization, latent space interpolation, and orthogonal decomposition. These methods are described in detail below:
[0109] The expression for generating the confusion vector using the small perturbation method is as follows:
[0110] ;(Formula 1)
[0111] In Formula 1, This is a confusion vector; Vectors of sensitive words; This is a random perturbation vector, where each element is drawn from a Gaussian, normal, or other distribution, such as a normal distribution. Where 0 is the mean, The standard deviation is used to control the intensity of noise.
[0112] The expression for generating the confusion vector using the constrained optimization method is as follows:
[0113] ;(Formula 2)
[0114] In Formula 2, For norm types (such as) or ); The element difference threshold represents the minimum distance between the confusion vector and the sensitive word vector. Equation 2 is solved iteratively using optimization algorithms such as projected gradient descent (PCD), and adjustments are made. Balancing similarity and difference, this method gradually adjusts the confusion vector to maximize its cosine similarity with the sensitive word vector, while ensuring that the distance between the confusion vector and the sensitive word vector is at least [value missing]. .
[0115] The expression for generating a confusion vector using the latent space interpolation method is as follows:
[0116] ;(Formula 3)
[0117] In formula 3, A parameter between 0 and 1, used to control the relative position of the confusion vector between the sensitive word vector and the non-sensitive word vector; These are non-sensitive word vectors.
[0118] The expression for generating the confusion vector using the orthogonal decomposition method is as follows:
[0119] ;(Formula 4)
[0120] In Formula 4, , These are preset coefficients used to control the similarity and element differences between the generated confusion vector and the sensitive word vector; These are the parallel components decomposed from the sensitive word vectors; These are the orthogonal components derived from the sensitive word vectors. and Orthogonal.
[0121] For different needs and scenarios, the four methods for generating obfuscation vectors each have their advantages. If rapid obfuscation vector generation is required, adding small perturbations is a simple and fast method; it generates obfuscation vectors quickly by adding random noise to sensitive word vectors. If precise control of the similarity and difference between the obfuscation vector and the original vector is needed, constrained optimization is a better choice. By defining explicit optimization objectives and constraints, the generated obfuscation vector can be precisely controlled to achieve specific privacy protection and information preservation requirements. In language models, latent space interpolation is a suitable choice for generating obfuscation vectors. This method generates a series of intermediate vectors between two vectors, thereby reducing the leakage of sensitive information while maintaining semantic consistency. It is particularly suitable for scenarios where privacy protection and semantic preservation need to be balanced in natural language processing tasks. If multiple factors (such as similarity, difference, and semantic consistency) need to be considered simultaneously when generating obfuscation vectors, orthogonal decomposition-based methods offer a flexible solution. By decomposing sensitive word vectors and controlling parallel and orthogonal components, the characteristics of the obfuscation vector can be precisely controlled in different dimensions.
[0122] To ensure that the aggregated approximate query vector maintains structural consistency with the original query vector, before aggregating the obfuscation vector and the non-sensitive word vector, the obfuscation vector is first subjected to a magnitude transformation. This involves dividing the obfuscation vector by its own length (i.e., normalizing it) and then multiplying it by the length of the sensitive word vector. This ensures that the obfuscation vector and the sensitive word vector have the same magnitude.
[0123] In the fourth specific implementation scheme, refer to Figure 5 The fourth flowchart illustrating the method for obtaining the original query vector and approximate query vector, "Obtaining the original query vector and approximate query vector based on input data," includes the following steps:
[0124] S113: Transform the input data into the raw query vector;
[0125] S114: Obtain sensitive and non-sensitive data from the input data;
[0126] S115: Obtain an approximate query vector based on sensitive data, non-sensitive data, and a preset language model.
[0127] In S113-S115, a pre-defined language model (such as BERT or other deep learning models) is used to convert the input data into a vector form that can represent its semantics, i.e., the original query vector. At the same time, sensitive data and non-sensitive data are identified and separated from the input data. Sensitive data may contain only sensitive words or both sensitive words and their contextual information. Similarly, non-sensitive data may contain only non-sensitive words or both non-sensitive words and their contextual information.
[0128] In S115, a pre-defined language model is used to generate an approximate query vector by combining sensitive and non-sensitive data. Specifically, sensitive and non-sensitive data are vectorized separately, and the sensitive data vector is obfuscated to hide its sensitive information. Then, a fusion strategy, such as max pooling or an attention mechanism, is used to capture key information. The non-sensitive data vector is then merged with the obfuscated vector into a unified vector, which is the approximate query vector. The final approximate query vector can be used in retrieval or other natural language processing tasks without revealing sensitive information.
[0129] By utilizing a pre-defined language model, sensitive words and even their contextual information can be processed to better understand the semantic background and capture the semantic information of the input data more comprehensively. This allows sensitive words in the input data to be hidden, generating approximate query vectors with good privacy protection.
[0130] Furthermore, sensitive information detection is performed by analyzing the semantic content of the approximate query vector using sensitive word detection algorithms or lists, as well as natural language processing techniques, to identify whether it contains sensitive words or information. A reconstruction capability test is conducted by attempting to reconstruct the approximate query vector through reverse operations or algorithms, and comparing the similarity between the reconstructed vector and the original query vector using methods such as cosine similarity. It is then checked whether the reconstructed approximate query vector still contains sensitive information, ensuring that other important information is preserved. The verification result is evaluated. If the approximate query vector cannot be reconstructed or does not contain sensitive information after reconstruction, the verification is considered successful; otherwise, the approximate query vector needs to be regenerated. The obfuscation processing method or parameters are adjusted according to the reason for the verification failure, and the verification steps are repeated until an approximate query vector that meets privacy protection requirements is generated, thus finding an appropriate balance between protecting user privacy and maintaining query utility.
[0131] In S2, the formula for calculating the first cosine similarity is as follows:
[0132] ;(Formula 5)
[0133] In Formula 5, The first cosine similarity; The first included angle; This is the original query vector; This is an approximate query vector.
[0134] In S3, refer to Figure 6 The flowchart illustrating the method for obtaining the initial search set shows that "sending the first included angle, the preset first threshold, and the approximate query vector to the knowledge base retrieval platform for retrieval to obtain the initial search set" includes the following steps:
[0135] S301: Obtain the second cosine similarity; where the second cosine similarity is the cosine similarity between the approximate query vector and the knowledge fragment in the knowledge base retrieval platform;
[0136] S302: Obtain the second threshold based on the first included angle and the first threshold;
[0137] S303: The knowledge fragments with a second cosine similarity greater than or equal to the second threshold are used to form the initial retrieval set.
[0138] In S301, the knowledge base retrieval platform has pre-set knowledge fragments, which include various types of information. These information are intended to cover a wide range of topics and fields, such as articles, reports, manuals, and guides. After converting the knowledge fragments into vectors, the similarity between the knowledge fragment vectors and the approximate query vectors is calculated, which is the second cosine similarity.
[0139] In S302, sensitive word vectors are converted into obfuscated vectors, thus removing sensitive information while maintaining a high degree of similarity between the original query vector and the approximate query vector, ensuring that their cosine similarity is close to 1. This allows the approximate query vector to be used instead of the original query vector for semantic matching and retrieval of the knowledge base. To achieve this, the cosine similarity threshold is appropriately lowered, i.e., a suitable second threshold is determined, so that the initial retrieval set retrieved using the approximate query vector can cover the target retrieval set retrieved using the original query vector. This method protects user privacy while ensuring the effectiveness of the retrieval.
[0140] There are two methods to obtain the second threshold. The first method is to calculate the vector difference between the original query vector and the approximate query vector to obtain the threshold difference. Subtracting the threshold difference from the first threshold will give you the second threshold. The second method is to directly calculate the cosine similarity threshold when searching with the approximate query vector to obtain the second threshold.
[0141] In Method 1, the calculation process for the second threshold is as follows:
[0142] The difference is obtained by subtracting the cosine similarity between the original query vector and any knowledge fragment from the cosine similarity between the approximate query vector and that knowledge fragment. The threshold difference is then calculated using the Cauchy-Schwarz inequality. The formula for calculating the difference is as follows:
[0143] ;(Formula 6)
[0144] In Formula 6, The difference; , These are the cosine similarities between the original query vector, the approximate query vector, and any knowledge fragment, respectively. This represents a knowledge fragment vector. Typically, during vector preprocessing, query vectors obtained through word embeddings (such as Word2Vec, GloVe) or language models (such as BERT) are normalized to have a modulus (norm) of 1. Therefore, both the original query vector and the approximate query vector have a modulus of 1. .
[0145] According to the Cauchy-Schwarz inequality ,therefore, ,in, This is the threshold difference. Because... and It is a unit vector, therefore , combined ,get ,therefore, .
[0146] Based on the above, the formula for calculating the second threshold is as follows:
[0147] ;(Formula 7)
[0148] In Formula 7, The second threshold; This is the first threshold.
[0149] In Method 2, the calculation process for the second threshold is as follows:
[0150] Assumption The modulus (norm) is 1. Decomposed into The component in the direction and its orthogonal complement component, i.e. ,in, for exist Components in direction (projection). for exist The components in the orthogonal complement space, satisfy and Similarly, Decomposed into The component in the direction and its orthogonal complement component, i.e. ,in, To be perpendicular to unit vectors, introduced In order to It is represented as the sum of two orthogonal components, one of which is... Parallel, another component with Orthogonal structures facilitate subsequent formula derivation.
[0151] Expand the inner product using the decomposition formula. ,because and Simplifying the inner product yields According to the Cauchy-Schwarz inequality, ,therefore, .
[0152] Known , ,therefore, Therefore, the formula for calculating the second threshold is as follows:
[0153] ;(Formula 8)
[0154] In Formula 8, The maximum value of is the second threshold. Even if The modulus is not 1, but it will be eliminated during the derivation process, and the calculation formula for the second threshold remains unchanged.
[0155] In S303, if the method of calculating the second threshold using the threshold difference in S302 is adopted, the expression for the initial retrieval set is as follows:
[0156] ;(Formula 9)
[0157] In Formula 9, This is the initial search set.
[0158] If the method of directly calculating the second threshold in S302 is used, the expression for the initial retrieval set is as follows:
[0159] ;(Formula 10)
[0160] In Formula 10, by comparing the second cosine similarity with the second threshold, knowledge fragments with a second cosine similarity greater than or equal to the second threshold are identified. These knowledge fragments are then combined to obtain the initial retrieval set.
[0161] In S4, the knowledge base retrieval platform sends the acquired initial retrieval set to the user terminal. After receiving the initial retrieval set, the user terminal calculates the cosine similarity (i.e., the third cosine similarity) between the original query vector and the knowledge fragments in the initial retrieval set. The third cosine similarity is compared with a first threshold to identify knowledge fragments whose third cosine similarity is greater than or equal to the first threshold. These knowledge fragments are then combined to obtain the target retrieval set.
[0162] The above scheme is illustrated with an example:
[0163] Construct a 24-dimensional vector In this case, the first 8 dimensions are all 0, and the last 16 dimensions are all 0. ,verify The L2 norm is 1. Assume... The four consecutive non-zero components from the 9th to the 12th dimension are the sensitive words, forming the sensitive word vector. ,therefore, .
[0164] Preserving the norm through orthogonal transformations (such as planar rotations), for Apply two rotation transformations: apply rotation angles to the first two dimensions. Apply rotation angle to the last two dimensions ,get , , , . and Their L2 norms are equal, both being 0.5.
[0165] calculate and The dot product is 0.2447. Calculate... and The cosine similarity between them is 0.9787. In Partial replacement To obtain an approximate query vector ,because and The squares of the L2 norms are all 0.25, therefore, The square of the L2 norm is 1, that is... The L2 norm is 1, and The L2 norm remains consistent. Because and The L2 norm of all are 1, and the first cosine similarity is 1. ,in, Indicates the position of a vector element. Indicating the original query vector The element at position, Indicating approximate query vector The element at a given position. , The value of is and The dot product, therefore .
[0166] Select a randomly generated 24-dimensional unit vector Its first 8 dimensions are all 0, while the last 16 dimensions contain different values. ,calculate The L2 norm is 1.5. Calculate... and The dot product is 1.1875. Calculate... and The dot product is 1.217. We can calculate it by dividing 1.1875 by 1.5. and The cosine similarity is 0.7917. By dividing 1.217 by 1.5, we can calculate... and The cosine similarity is 0.8113, and the difference between 0.7917 and 0.8113 is 0.0196. According to Formula 7 above, the theoretical maximum difference is... The value is 0.103, and 0.0196 is less than 0.103, so the condition is met. Assume... Taking values of 0.9, 0.8, 0.75, and 0.7 respectively, according to formula 8 above, The values were 0.79033, 0.66936, 0.58953, and 0.52069 respectively. and Subtracting these values, we obtain the theoretical maximum differences of 0.10967, 0.13064, 0.16047, and 0.17931. 0.0196 is smaller than these theoretical maximum differences, therefore, the condition is met.
[0167] In summary, this solution replaces the original query vector with an approximate query vector that does not contain sensitive word information for retrieval, ensuring that the knowledge base retrieval platform cannot deduce the user's sensitive words from the approximate query vector, thus protecting user privacy. Simultaneously, because the approximate query vector and the original query vector are extremely similar in cosine similarity, the angle between them is very small, guaranteeing high query efficiency—that is, minimal query redundancy, controllable excess computational consumption, and controllable user filtering of results. Furthermore, by distributing the computational load across user terminals, the bottleneck of overall computational load in RAG retrieval for the knowledge base retrieval platform is effectively alleviated.
[0168] Reference Figure 7 This disclosure provides a retrieval system for protecting user-sensitive words, including:
[0169] The query vector acquisition module 101 is used to acquire user input data and, based on the input data, acquire the original query vector and the approximate query vector.
[0170] The first angle acquisition module 102 is used to acquire the first cosine similarity and acquire the first angle based on the first cosine similarity; wherein, the first cosine similarity is the cosine similarity between the original query vector and the approximate query vector;
[0171] The initial retrieval set acquisition module 103 is used to send the first included angle, the preset first threshold and the approximate query vector to the knowledge base retrieval platform for retrieval and to obtain the initial retrieval set.
[0172] The target retrieval set acquisition module 104 is used to send the initial retrieval set to the user terminal and acquire the target retrieval set based on the user terminal's original query vector and the received initial retrieval set.
[0173] The various variations and specific examples of the above-described methods for retrieving sensitive user words are also applicable to the retrieval system for protecting sensitive user words provided in this disclosure. Through the foregoing detailed description of the methods for retrieving sensitive user words, those skilled in the art can clearly understand the implementation method of the retrieval system for protecting sensitive user words. For the sake of brevity, these details will not be elaborated here.
[0174] A computer device according to embodiments of the present disclosure includes a memory and a processor. The memory is used to store non-transitory computer-readable instructions. Specifically, the memory may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may, for example, include random access memory (RAM) and / or cache memory. The non-volatile memory may, for example, include read-only memory (ROM), hard disk, flash memory, etc.
[0175] The processor may be a central processing unit (CPU) or other processing unit with data processing capabilities and / or instruction execution capabilities, and may control other components in the computer device to perform desired functions. In one embodiment of this disclosure, the processor is used to execute computer-readable instructions stored in the memory, causing the computer device to perform all or part of the steps of the foregoing embodiments of this disclosure for the retrieval method of protecting user sensitive words.
[0176] Those skilled in the art will understand that, in order to solve the technical problem of how to achieve a good user experience, this embodiment may also include well-known structures such as communication buses and interfaces, and these well-known structures should also be included within the protection scope of this disclosure.
[0177] like Figure 8 This is a schematic diagram of a computer device provided for an embodiment of the present disclosure. It illustrates a structural schematic diagram suitable for implementing the computer device in the embodiments of the present disclosure. Figure 8 The computer device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0178] like Figure 8As shown, a computer device may include a processor (such as a central processing unit, graphics processing unit, etc.), which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) or programs loaded from storage devices into random access memory (RAM). The RAM also stores various programs and data required for the operation of the computer device. The processor, ROM, and RAM are interconnected via a bus. Input / output (I / O) interfaces are also connected to the bus.
[0179] Typically, the following devices can be connected to the I / O interface: input devices, such as sensors or visual information acquisition devices; output devices, such as displays; storage devices, such as magnetic tapes or hard drives; and communication devices. Communication devices allow the computer device to communicate wirelessly or wiredly with other devices (such as edge computing devices) to exchange data. Although Figure 8 A computer apparatus with various devices is shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or included alternatively.
[0180] 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 non-transitory 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 processor, all or part of the steps of the method for protecting user-sensitive words according to embodiments of this disclosure are performed.
[0181] For a detailed description of this embodiment, please refer to the corresponding descriptions in the foregoing embodiments, which will not be repeated here.
[0182] A computer-readable storage medium according to embodiments of the present disclosure stores non-transitory computer-readable instructions. When the non-transitory computer-readable instructions are executed by a processor, all or part of the steps of the foregoing methods for retrieving user-protected sensitive words according to embodiments of the present disclosure are performed.
[0183] The aforementioned computer-readable storage media include, but are not limited to: optical storage media (e.g., CD-ROM and DVD), magneto-optical storage media (e.g., MO), magnetic storage media (e.g., magnetic tape or portable hard drive), media with built-in rewritable non-volatile memory (e.g., memory card), and media with built-in ROM (e.g., ROM cartridge).
[0184] For a detailed description of this embodiment, please refer to the corresponding descriptions in the foregoing embodiments, which will not be repeated here.
[0185] The basic principles of this disclosure have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this disclosure are merely examples and not limitations, and should not be considered as essential features of each embodiment of this disclosure. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the scope of this disclosure to the necessity of employing the aforementioned specific details for implementation.
[0186] In this disclosure, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. The block diagrams of devices, apparatuses, devices, and systems involved in this disclosure are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as "comprising," "including," "having," etc., are open-ended terms meaning "including but not limited to," and are used interchangeably with them. The terms "or" and "and" as used herein refer to the terms "and / or," and are used interchangeably with them unless the context clearly indicates otherwise. The term "such as" as used herein refers to the phrase "such as but not limited to," and is used interchangeably with it.
[0187] Additionally, as used herein, the "or" used in a list of items beginning with "at least one" indicates a separate list, such that a list of, for example, "at least one of A, B, or C" means A or B or C, or AB or AC or BC, or ABC (i.e., A and B and C). Furthermore, the word "exemplary" does not imply that the described example is preferred or better than other examples.
[0188] It should also be noted that in the systems and methods of this disclosure, the components or steps can be decomposed and / or recombined. These decompositions and / or recombinations should be considered as equivalent solutions to this disclosure.
[0189] Various changes, substitutions, and modifications can be made to the technology described herein without departing from the teachings defined by the appended claims. Furthermore, the scope of the claims of this disclosure is not limited to the specific aspects of the processes, machines, manufactures, events, means, methods, and actions described above. Currently existing or later-developed processes, machines, manufactures, events, means, methods, or actions that perform substantially the same function or achieve substantially the same result as the corresponding aspects described herein can be utilized. Therefore, the appended claims include such processes, machines, manufactures, events, means, methods, or actions within their scope.
[0190] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of this disclosure. Therefore, this disclosure is not intended to be limited to the aspects shown herein, but rather to be carried out within the widest scope consistent with the principles and novel features disclosed herein.
[0191] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this disclosure to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations therein.
Claims
1. A method for protecting users' sensitive words during retrieval, characterized in that, include: Obtain user input data, and based on the input data, obtain the original query vector and the approximate query vector; Obtain a first cosine similarity, and obtain a first angle based on the first cosine similarity; wherein, the first cosine similarity is the cosine similarity between the original query vector and the approximate query vector; The first included angle, the preset first threshold, and the approximate query vector are sent to the knowledge base retrieval platform for retrieval to obtain an initial retrieval set; The step of sending the first included angle, the preset first threshold, and the approximate query vector to the knowledge base retrieval platform for retrieval to obtain an initial retrieval set includes: Obtain the second cosine similarity; wherein, the second cosine similarity is the cosine similarity between the approximate query vector and the knowledge fragment in the knowledge base retrieval platform; Based on the first included angle and the first threshold, obtain the second threshold; The knowledge fragments whose second cosine similarity is greater than or equal to the second threshold are used to form the initial retrieval set; The formula for calculating the second threshold is as follows: ; in, The second threshold; The first threshold; The first included angle; or, The formula for calculating the second threshold is: ; in, The second threshold; The first threshold; The first included angle; The initial retrieval set is sent to the user terminal, and the target retrieval set is obtained based on the user terminal's original query vector and the received initial retrieval set.
2. The retrieval method for protecting user-sensitive words according to claim 1, characterized in that, The step of obtaining the original query vector and the approximate query vector based on the input data includes: The input data is then converted into a raw query vector. The sensitive words in the input data are replaced with safe words to generate de-identified data; The de-identified data is converted into an approximate query vector.
3. The retrieval method for protecting user-sensitive words according to claim 1, characterized in that, The step of obtaining the original query vector and the approximate query vector based on the input data includes: Based on the input data, a vocabulary is constructed; wherein the vocabulary contains all unique words in the input data; Based on the vocabulary, construct the original query vector; Identify sensitive words in the input data and obtain the corresponding positions of the sensitive words in the original query vector; The sensitive words are converted into sensitive word vectors, and the sensitive word vectors are then obfuscated to generate obfuscated vectors. Based on the location, the obfuscation vector and the original query vector are fused into an approximate query vector.
4. The retrieval method for protecting user-sensitive words according to claim 1, characterized in that, The step of obtaining the original query vector and the approximate query vector based on the input data includes: Obtain sensitive and non-sensitive words from the input data, and convert the sensitive words and non-sensitive words into sensitive word vectors and non-sensitive word vectors, respectively. The sensitive word vectors and the non-sensitive word vectors are aggregated to generate the original query vector; The sensitive word vectors are obfuscated to generate obfuscated vectors; The obfuscation vector and the non-sensitive word vector are aggregated to generate an approximate query vector.
5. The retrieval method for protecting user-sensitive words according to claim 1, characterized in that, The step of obtaining the original query vector and the approximate query vector based on the input data includes: The input data is then converted into a raw query vector. Obtain sensitive data and non-sensitive data from the input data; wherein, the sensitive data includes at least one of sensitive words and sensitive word context information, and the non-sensitive data includes at least one of non-sensitive words and non-sensitive word context information; Based on the sensitive data, the non-sensitive data, and the preset language model, an approximate query vector is obtained.
6. The retrieval method for protecting user-sensitive words according to claim 1, characterized in that, The process of obtaining the target retrieval set based on the user terminal's original query vector and the received initial retrieval set includes: Obtain the third cosine similarity; wherein, the third cosine similarity is the cosine similarity between the original query vector and the knowledge fragment in the initial retrieval set; The knowledge fragments whose third cosine similarity is greater than or equal to the first threshold are used to form a target retrieval set.
7. A computer device, characterized in that, The computer 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 retrieval method for protecting user sensitive words as described in any one of claims 1-6.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a computer to perform the retrieval method for protecting user-sensitive words as described in any one of claims 1-6.
9. A computer program product comprising computer instructions, characterized in that, When executed by a processor, the computer instructions implement the steps of the method according to any one of claims 1-6.
Citation Information
Patent Citations
Information retrieval method and system for small data set
CN115248807A
Large-scale embedded index data desensitization method suitable for forestry database
CN119538311A