Retrieval method and device for protecting sensitive words of user, storage medium and program product

By generating approximate query vectors and cosine similarity processing, the problem of sensitive word leakage in large model technology is solved, and the balance between privacy protection and retrieval efficiency is achieved, ensuring user information security and the accuracy of retrieval results.

CN120408719AActive Publication Date: 2025-08-01BEIJING ELECTRONIC DIGITAL INTELLIGENCE TECHNOLOGY CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510838080.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-20
Publication Date
2025-08-01
Estimated Expiration
2045-06-20

AI Technical Summary

Technical Problem

In the inference service of big model technology, users' sensitive words are easily leaked during the retrieval process. Although the existing hidden query methods enhance security, they reduce query efficiency.

Method used

By generating an approximate query vector, the initial search set is obtained using the first cosine similarity and angle, and the user terminal performs the final search to avoid sending sensitive words directly and protecting user privacy.

Benefits of technology

It realizes that while protecting user privacy, the accuracy and efficiency of searches are maintained, the risk of sensitive information leakage is reduced, and the relevance of search results is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120408719A_ABST
    Figure CN120408719A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a retrieval method and device for protecting sensitive words of a user, a storage medium and a program product. The method comprises the following steps: acquiring input data of a user, and acquiring an original query vector and an approximate query vector based on the input data; obtaining a first cosine similarity, and obtaining a first included 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, a preset first threshold value and the approximate query vector are sent to a knowledge base retrieval platform for retrieval, and an initial retrieval set is obtained; and sending the initial retrieval set to the user terminal, and obtaining a target retrieval set based on the original query vector of the user terminal and the received initial retrieval set. According to the method, the initial retrieval set can be obtained by obtaining the query vector approximate to the original query vector, and then secondary retrieval is performed based on the initial retrieval set, so that the retrieval accuracy is guaranteed, and the privacy of the user is protected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of privacy protection technologies, and in particular, to a method, apparatus, storage medium, and program product for protecting user sensitive words in retrieval. Background Art

[0002] With the rapid development of large model technologies, various inference services and applications have emerged continuously, such as search, knowledge Q&A, assisted programming, etc. During the operation of these services, the prompt words submitted by users contain questions and context information, which may involve sensitive data, thus posing a risk of data leakage. Especially when Retrieval-Augmented Generation (RAG) becomes a commonly used inference method, during the retrieval query process, these sensitive words may be leaked to the holders of the knowledge base.

[0003] To solve the problem of privacy protection of sensitive words during query, there are many existing technical methods. For example, a conventional approach is to use oblivious query to retrieve the knowledge base to protect user data. However, oblivious query usually uses cryptographic algorithms such as oblivious transfer and homomorphic encryption. Although these algorithms can greatly enhance security, they will lead to a decrease in query efficiency, thereby affecting the overall performance of large model services. Summary of the Invention

[0004] In view of this, embodiments of the present disclosure provide a method, apparatus, storage medium, and program product for protecting user sensitive words in retrieval, which can obtain an initial retrieval set by obtaining a query vector approximate to the original query vector, and then perform a secondary retrieval based on the initial retrieval set, thus ensuring both retrieval accuracy and user privacy protection.

[0005] In a first aspect, embodiments of the present disclosure provide a method for protecting user sensitive words in retrieval, adopting the following technical solution: Obtain the input data of the user, and based on the input data, obtain an original query vector and an approximate query vector; Obtain a first cosine similarity, and obtain a first included 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; Send the first included angle, a preset first threshold, and the approximate query vector to a knowledge base retrieval platform for retrieval to obtain an initial retrieval set; Send the initial retrieval set to the user terminal, and based on the original query vector of the user terminal and the received initial retrieval set, obtain a target retrieval set.

[0006] Optionally, the obtaining the original query vector and the approximate query vector based on the input data includes: Convert the input data into an original query vector; Replace the sensitive words in the input data with safe words to generate de-sensitized data; Convert the de-sensitized data into an approximate query vector.

[0007] Optionally, obtaining the original query vector and the approximate query vector based on the input data includes: Construct a vocabulary based on the input data; wherein, the vocabulary contains all unique words in the input data; Construct an original query vector based on the vocabulary; Identify the sensitive words in the input data and obtain the positions corresponding to the sensitive words in the original query vector; Convert the sensitive words into sensitive word vectors, perform confusion processing on the sensitive word vectors to generate confusion vectors; Based on the positions, fuse the confusion vectors and the original query vector into an approximate query vector.

[0008] Optionally, obtaining the original query vector and the approximate query vector based on the input data includes: Obtain the sensitive words and non-sensitive words in the input data, and convert the sensitive words and the non-sensitive words into sensitive word vectors and non-sensitive word vectors respectively; Aggregate the sensitive word vectors and the non-sensitive word vectors to generate an original query vector; Perform confusion processing on the sensitive word vectors to generate confusion vectors; Aggregate the confusion vectors and the non-sensitive word vectors to generate an approximate query vector.

[0009] Optionally, obtaining the original query vector and the approximate query vector based on the input data includes: Convert the input data into an original query vector; Obtain the sensitive data and non-sensitive data in 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 a preset language model, obtain an approximate query vector.

[0010] Optionally, sending the first included angle, a preset first threshold and the approximate query vector to a knowledge base retrieval platform for retrieval to obtain an initial retrieval set includes: Obtain a second cosine similarity; wherein, the second cosine similarity is the cosine similarity between the approximate query vector and the knowledge fragments in the knowledge base retrieval platform; Obtain a second threshold based on the first included angle and the first threshold; Form an initial retrieval set with the knowledge segments whose second cosine similarity is greater than or equal to the second threshold.

[0011] Optionally, the calculation formula for the second threshold is: ; where is the second threshold; is the first threshold; is the first included angle.

[0012] Optionally, the calculation formula for the second threshold is: ; where is the second threshold; is the first threshold; is the first included angle.

[0013] Optionally, the obtaining of the target retrieval set based on the original query vector of the user terminal and the received initial retrieval set includes: Obtain a third cosine similarity; where the third cosine similarity is the cosine similarity between the original query vector and the knowledge segments in the initial retrieval set; Form a target retrieval set with the knowledge segments whose third cosine similarity is greater than or equal to the first threshold.

[0014] In a second aspect, an embodiment of the present disclosure further provides a retrieval system for protecting user sensitive words, adopting the following technical solution: A query vector obtaining module, configured to obtain the input data of the user, and obtain an original query vector and an approximate query vector based on the input data; A first included angle obtaining module, configured to obtain a first cosine similarity, and obtain a first included 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; An initial retrieval set obtaining module, configured to send the first included angle, a preset first threshold, and the approximate query vector to a knowledge base retrieval platform for retrieval, and obtain an initial retrieval set; A target retrieval set obtaining module, configured to send the initial retrieval set to the user terminal, and obtain a target retrieval set based on the original query vector of the user terminal and the received initial retrieval set.

[0015] In a third aspect, an embodiment of the present disclosure further provides a computer device, adopting the following technical solution: The computer device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method for retrieving protected user sensitive words described in any one of the above.

[0016] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium storing computer instructions for causing a computer to execute the method for retrieving protected user sensitive words described in any one of the above.

[0017] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product including a computer program / instructions, and when the computer program / instructions are executed by a processor, the steps of the method described in any one of the above are implemented.

[0018] The method for retrieving protected user sensitive words provided by the embodiment of the present disclosure can generate an approximate query vector, and in the subsequent retrieval process, the original query vector containing sensitive words does not need to be directly used for retrieval. The approximate query vector can retain the semantic information of the original query to a certain extent, and at the same time avoid directly exposing the sensitive words to the external knowledge base retrieval platform, thereby effectively protecting the security of user sensitive information. The first cosine similarity and the first included angle can quantify the similarity between the original query vector and the approximate query vector. By calculating these metrics, it is possible to understand the approximation degree of the approximate query vector to the original query vector, providing an important reference basis for subsequent retrieval. Only the approximate query vector, the first included 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 according to the first included angle and the first threshold to screen out potentially relevant retrieval results without having to access the user's sensitive information. The user terminal uses the original query vector for retrieval and selects the most user-demand-compliant results from the initial retrieval set according to the precise semantics of the original query. Since the original query vector contains the complete user intention, the selected target retrieval set is more accurate and relevant.

[0019] The above description is only an overview of the technical solution of the present disclosure. In order to understand the technical means of the present disclosure more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features, and advantages of the present disclosure more obvious and understandable, the following specifically gives preferred embodiments and, in conjunction with the drawings, details are described as follows. Description of the Drawings

[0020] To more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following will briefly introduce the accompanying drawings required for the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present disclosure. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.

[0021] Figure 1 It is a schematic flowchart of a method for retrieving user-sensitive words provided by an embodiment of the present disclosure; Figure 2 It is a first schematic flowchart of a method for obtaining an original query vector and an approximate query vector provided by an embodiment of the present disclosure; Figure 3 It is a second schematic flowchart of a method for obtaining an original query vector and an approximate query vector provided by an embodiment of the present disclosure; Figure 4 It is a third schematic flowchart of a method for obtaining an original query vector and an approximate query vector provided by an embodiment of the present disclosure; Figure 5 It is a fourth schematic flowchart of a method for obtaining an original query vector and an approximate query vector provided by an embodiment of the present disclosure; Figure 6 It is a schematic flowchart of a method for obtaining an initial retrieval set provided by an embodiment of the present disclosure; Figure 7 It is a principle block diagram of a retrieval system for protecting user-sensitive words provided by an embodiment of the present disclosure; Figure 8 It is a schematic structural diagram of a computer device provided by an embodiment of the present disclosure. Specific embodiments

[0022] The following will describe the embodiments of the present disclosure in detail with reference to the accompanying drawings.

[0023] It should be clear that the following illustrates the embodiments of the present disclosure through specific specific examples. Those skilled in the art can easily understand other advantages and effects of the present disclosure from the content disclosed in this specification. Obviously, the described embodiments are only some embodiments of the present disclosure, rather than all embodiments. The present disclosure can also be implemented or applied through other different specific embodiments. Various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present disclosure. It should be noted that, without conflict, the following embodiments and the features in the embodiments can be combined with each other. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present disclosure without creative efforts belong to the scope of protection of the present disclosure.

[0024] It should be noted that the following description relates to various aspects of embodiments within the scope of the appended claims. It will be apparent that the aspects described herein can be embodied in a wide variety of forms, and any specific structure and / or function described herein is illustrative only. Based on this disclosure, those skilled in the art should 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 the aspects set forth herein can be used to implement an apparatus and / or practice a method. Additionally, this apparatus and / or method can be implemented using other structures and / or functionality in addition to one or more of the aspects set forth herein.

[0025] It should also be noted that the diagrams provided in the following embodiments only illustrate the basic concept of the present disclosure schematically. Only the components related to the present disclosure are shown in the diagrams, rather than being drawn according to the number, shape, and size of the components in actual implementation. The type, quantity, and ratio of each component in actual implementation can be arbitrarily changed, and the component layout type may also be more complex.

[0026] In addition, in the following description, specific details are provided to facilitate a thorough understanding of the examples. However, those skilled in the art will understand that the aspects described can be practiced without these specific details.

[0027] Referring to Figure 1 , the present disclosure provides a retrieval method for protecting user sensitive words, including the following steps: S1: Obtain the input data of the user, and based on the input data, obtain the original query vector and the approximate query vector; S2: Obtain the first cosine similarity, and obtain the first included 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; S3: Send the first included angle, a preset first threshold, and the approximate query vector to the knowledge base retrieval platform for retrieval to obtain an initial retrieval set; S4: Send the initial retrieval set to the user terminal, and based on the original query vector of the user terminal and the received initial retrieval set, obtain the target retrieval set.

[0028] The retrieval method for protecting user sensitive words provided by the present disclosure generates an approximate query vector, so that in the subsequent retrieval process, the original query vector containing sensitive words does not need to be directly used for retrieval. The approximate query vector can retain the semantic information of the original query to a certain extent, while avoiding directly exposing sensitive words to the external knowledge base retrieval platform, thus effectively protecting the security of user sensitive information. The first cosine similarity and the first included angle can quantify the similarity between the original query vector and the approximate query vector. By calculating these metrics, the approximation degree of the approximate query vector to the original query vector can be understood, providing an important reference basis for subsequent retrieval. Only the approximate query vector, the first included 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 according to the first included angle and the first threshold to screen out possible relevant retrieval results without having to access the user's sensitive information. The user terminal uses the original query vector for retrieval and selects the result that best meets the user's needs from the initial retrieval set according to the precise semantics of the original query. Since the original query vector contains the complete user intention, the selected target retrieval set is more accurate and relevant.

[0029] In summary, the retrieval method for protecting user sensitive words realizes efficient and accurate retrieval while protecting user sensitive information through a series of steps such as generating an approximate query vector, quantifying similarity, controlling information transmission, and performing the final retrieval locally. On the one hand, it effectively reduces the leakage risk of sensitive information during the retrieval process and safeguards the privacy security of users; on the other hand, through a reasonable retrieval mechanism, it improves the retrieval efficiency and the accuracy of results, providing a better retrieval experience for users. This method has important application value in processing retrieval scenarios involving sensitive information.

[0030] In S1, when obtaining user input data, as the query party, the user will provide input data containing information such as questions and prompt words. These input data usually contain sensitive words, and during the retrieval process, these sensitive words cannot be exposed to the knowledge base retrieval platform to avoid leaking the privacy of the query party. To achieve this goal, the input data is subjected to sensitive word detection, obfuscation processing, etc. to generate an approximate query vector that can replace the input data for retrieval on the knowledge base retrieval platform. Through these measures, both the privacy of users is protected and the accuracy and efficiency of retrieval are not affected.

[0031] There are many ways to obtain the original query vector and the approximate query vector. The present application exemplarily provides four acquisition methods. Among them, in the first specific implementation scheme, referring to Figure 2The first process schematic diagram of the method for obtaining the original query vector and the approximate query vector shown, "obtaining the original query vector and the approximate query vector based on the input data" includes the following steps: S101: Convert the input data into an original query vector; S102: Replace the sensitive words in the input data with safe words to generate desensitized data; S103: Convert the desensitized data into an approximate query vector.

[0032] In S101, using natural language processing techniques such as word embeddings or pre-trained language models (such as BERT), etc., the input data is converted into a high-dimensional vector by encoding methods. For example, by mapping each word in the input data to a pre-trained word vector space and aggregating these word vectors (such as averaging or weighted averaging), an original query vector that can represent the semantics of the input data is generated. This method can retain the core semantic information of the input data.

[0033] In S102, the sensitive words in the input data are identified through a predefined list of sensitive words or a context-based sensitive word detection algorithm. Once the sensitive words are identified, these sensitive words are replaced with predefined safe words. The safe words can be general, non-sensitive words, or words that are generated by a synonym replacement algorithm, dynamic desensitization, etc., and are semantically similar to the original sensitive words but not sensitive. For example, some digits of the ID number are 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 providing a data basis for subsequent retrieval while protecting user privacy.

[0034] In S103, the desensitized data is further processed into an approximate query vector. Similar to S101, natural language processing techniques can be used to convert the desensitized data into vector form. Since the desensitized data has removed sensitive words, the generated approximate query vector is semantically similar to the original query vector but does not contain sensitive information. This method can ensure that sensitive information is not exposed to the knowledge base retrieval platform during the retrieval process, while still being able to use the desensitized semantic information for effective retrieval.

[0035] The above-mentioned desensitization process is achieved by directly replacing sensitive words with safe words, which is simple in operation and low in computational cost. It can effectively hide sensitive information, avoid privacy leakage during the retrieval process, and by selecting safe words with similar semantics, it tries to retain the semantic information of the original input data.

[0036] In the second specific implementation scheme, refer to Figure 3The second process schematic diagram of the method for obtaining the original query vector and the approximate query vector shown, "obtaining the original query vector and the approximate query vector based on the input data" includes the following steps: S104: Based on the input data, construct a vocabulary; wherein, the vocabulary contains all unique words in the input data; S105: Based on the vocabulary, construct the original query vector; S106: Identify the sensitive words in the input data and obtain the positions corresponding to the sensitive words in the original query vector; S107: Convert the sensitive words into sensitive word vectors, perform confusion processing on the sensitive word vectors, and generate confusion vectors; S108: Based on the positions, fuse the confusion vectors and the original query vector into an approximate query vector.

[0037] In S104, perform text preprocessing on the input data, including operations such as word segmentation and stop word removal, extract all unique words from the preprocessed input data, store these words in a vocabulary, and assign a unique index to each word in the vocabulary.

[0038] In S105, utilize the vocabulary and use a pre-trained word embedding model (such as Word2Vec, GloVe, or the bag-of-words model) to map each word in the input data into a predefined vector space, assign a corresponding vector to each word in the vocabulary, and generate an original query vector that can represent the semantics of the entire input data by aggregating these word vectors (for example, by averaging or weighted averaging).

[0039] In S106, by tracing the index positions of the sensitive words in the vocabulary, determine the positions of the sensitive words in the original query vector to ensure that subsequent processing of the sensitive words can accurately act on the corresponding parts of the original query vector.

[0040] In S107, for the identified sensitive words, use the same method as in S105 to convert them into corresponding sensitive word vectors, perform confusion processing on the sensitive word vectors to hide their original information, and the generated confusion vectors are difficult to directly restore to the original sensitive word vectors, thereby protecting privacy.

[0041] In S108, according to the positions of the sensitive words in the original query vector obtained in S106, replace the confusion vectors with the corresponding positions in the original query vector to generate an approximate query vector, which not only retains most of the semantic information of the original query vector but also hides the information of the sensitive words through confusion processing, thereby protecting the privacy of users during the retrieval process.

[0042] The above method realizes the balance between privacy protection and semantic retention by constructing a vocabulary and accurately locating the positions of sensitive words in the original query vector, combined with obfuscation processing, while ensuring the accuracy and controllability of the processing process.

[0043] In the third specific implementation solution, referring to Figure 4 the third process schematic diagram of the method for obtaining the original query vector and the approximate query vector shown, "obtaining the original query vector and the approximate query vector based on the input data" includes the following steps: S109: Obtain the sensitive words and non-sensitive words in the input data, and convert the sensitive words and non-sensitive words into sensitive word vectors and non-sensitive word vectors respectively; S110: Aggregate the sensitive word vectors and non-sensitive word vectors to generate the original query vector; S111: Perform obfuscation processing on the sensitive word vectors to generate obfuscated vectors; S112: Aggregate the obfuscated vectors and non-sensitive word vectors to generate the approximate query vector.

[0044] In S109, by using a predefined sensitive word list or natural language processing techniques (such as text classification models), the sensitive words and non-sensitive words in the input data are identified and extracted. The pre-trained word embedding model is used to convert the sensitive words and non-sensitive words into corresponding vector representations respectively. Each word will be mapped to a vector in a high-dimensional space, and these vectors can capture the semantic information of the words, providing a basis for subsequent vector aggregation and obfuscation processing.

[0045] In S110, the obtained sensitive word vectors and non-sensitive word vectors are aggregated to generate an original query vector that can represent the semantics of the entire input data. Among them, the aggregation method can be simple averaging, that is, adding all the word vectors and then dividing by the total number of word vectors; it can also be weighted averaging, giving different weights according to the importance of the words, multiplying each word vector by its corresponding weight, then adding all the multiplication results according to the corresponding dimensions, and finally dividing the added result by the sum of the weights to obtain the original query vector representing the semantics of the entire input data; it can also be simple summation, that is, directly adding all the sensitive word vectors and non-sensitive word vectors according to the corresponding dimensions; it can also be weighted summation, assigning a weight to each word vector, and then adding each word vector multiplied by its corresponding weight according to the corresponding dimensions.

[0046] In S111, in order to protect the privacy of users, obfuscation processing is performed on the sensitive word vectors to hide the original information of the sensitive words and generate obfuscated vectors.

[0047] In S112, the aggregation method for aggregating the obfuscated vectors and non-sensitive word vectors is similar to that in S110, and can be simple averaging, weighted averaging, summation or weighted summation, etc.

[0048] The above method processes sensitive words and non-sensitive words separately, and can more precisely control the processing method of sensitive information. By aggregating the confused sensitive word vectors and non-sensitive word vectors, it not only protects privacy but also retains most of the semantic information. It is applicable to scenarios with high requirements for privacy protection and can flexibly handle different data structures and requirements.

[0049] Among them, there are various ways of confusion processing, including adding small perturbations, constrained optimization, latent space difference, and orthogonal decomposition-based methods. The following details these methods: Among them, the expression for generating a confused vector using the small perturbation method is as follows: ; (Formula 1) In Formula 1, is the confused vector; is the sensitive word vector; is the random perturbation vector, and each element in the random perturbation vector is drawn from a Gaussian distribution, a normal distribution, or other distributions. For example, from a normal distribution , where 0 is the mean, is the standard deviation, which is used to control the intensity of the noise.

[0050] The expression for generating a confused vector using the constrained optimization method is as follows: ; (Formula 2) In Formula 2, is the norm type (such as or ); is the element difference threshold, which represents the minimum distance between the confused vector and the sensitive word vector, . Use optimization algorithms such as projected gradient descent (PCD) to iteratively solve Formula 2 and adjust to balance similarity and difference. This method gradually adjusts the confused vector to maximize its cosine similarity with the sensitive word vector, while ensuring that the distance between the confused vector and the sensitive word vector is at least .

[0051] The expression for generating a confused vector using the latent space difference method is as follows: ; (Formula 3) In Formula 3, is a parameter between 0 and 1, which is used to control the relative position of the confused vector between the sensitive word vector and the non-sensitive word vector; is the non-sensitive word vector.

[0052] The expression for generating the obfuscation vector using the orthogonal decomposition method is as follows: ; (Formula 4) In Formula 4, and are preset coefficients used to control the similarity and element differences between the generated obfuscation vector and the sensitive word vector; is the parallel component decomposed from the sensitive word vector; is the orthogonal component decomposed from the sensitive word vector, is orthogonal to .

[0053] For different requirements and scenarios, the four methods for generating obfuscation vectors each have their advantages. If you need to quickly generate an obfuscation vector, adding a small perturbation is a simple and fast method. By adding random noise to the sensitive word vector, an obfuscation vector can be quickly generated. If you need to precisely control the similarity and differences between the obfuscation vector and the original vector, constrained optimization is a better choice. By defining clear optimization objectives and constraints, the generated obfuscation vector can be precisely controlled to meet specific privacy protection and information retention requirements. When generating an obfuscation vector in a language model, the latent space difference is a suitable choice. This method can generate a series of intermediate vectors between two vectors, thereby reducing the leakage of sensitive information while maintaining semantic consistency, and is particularly suitable for scenarios that require balancing privacy protection and semantic retention in natural language processing tasks. If you need to consider multiple factors (such as similarity, differences, and semantic consistency) when generating an obfuscation vector, the method based on orthogonal decomposition provides a flexible solution. By decomposing the sensitive word vector and controlling the parallel and orthogonal components, the characteristics of the obfuscation vector can be precisely controlled in different dimensions.

[0054] To ensure that the aggregated approximate query vector is consistent with the original query vector in structure, before aggregating the obfuscation vector and the non-sensitive word vector, first perform a magnitude transformation on the obfuscation vector, that is, divide the obfuscation vector by its own length (i.e., perform normalization), and then multiply it by the length of the sensitive word vector, which can ensure that the magnitudes of the obfuscation vector and the sensitive word vector are equal.

[0055] In the fourth specific implementation solution, referring to Figure 5 the fourth process schematic diagram of the method for obtaining the original query vector and the approximate query vector shown, "obtaining the original query vector and the approximate query vector based on the input data" includes the following steps: S113: Convert the input data into the original query vector; S114: Obtain the sensitive data and non-sensitive data in the input data; S115: Obtain an approximate query vector based on sensitive data, non-sensitive data, and a preset language model.

[0056] In S113 - S115, using a preset language model (such as BERT or other deep learning models), the input data is converted into a vector form that can represent its semantics, namely the original query vector. At the same time, sensitive data and non-sensitive data are identified and separated from the input data. Among them, sensitive data can only contain sensitive words, or can also contain sensitive words and their context information; similarly, non-sensitive data can only contain non-sensitive words, or can also contain non-sensitive words and their context information.

[0057] In S115, use the preset language model to combine sensitive data and non-sensitive data to generate an approximate query vector. Specifically, it is necessary to perform vectorization processing on sensitive data and non-sensitive data respectively, perform obfuscation processing on the sensitive data vector to hide its sensitive information, and then through a fusion strategy, such as max pooling or attention mechanism, capture key information, and merge the non-sensitive data vector with the vector obtained through obfuscation processing into a unified vector, which is the approximate query vector. The finally generated approximate query vector can be used in retrieval or other natural language processing tasks without leaking sensitive information.

[0058] Using the preset language model can handle sensitive words and even their context information to better understand the semantic background, more comprehensively capture the semantic information of the input data, thereby hiding the sensitive words in the input data and generating an approximate query vector with good privacy protection.

[0059] Furthermore, perform sensitive information detection, analyze the semantic content of the approximate query vector through sensitive word detection algorithms or lists, and natural language processing techniques to identify whether it contains sensitive vocabulary or information; perform a restoration ability test, try to restore the approximate query vector through reverse operations or algorithms, and use methods such as cosine similarity to compare the similarity between the restored vector and the original query vector; check whether even if the approximate query vector can be restored, the restored vector still contains sensitive information, and ensure that other important information is retained; evaluate the verification result. If the approximate query vector cannot be restored or does not contain sensitive information after restoration, it is considered that the verification is successful, otherwise it is necessary to regenerate the approximate query vector, adjust the obfuscation processing method or parameters according to the reasons for the verification failure, and repeat the verification steps until an approximate query vector that meets the privacy protection requirements is generated, so as to find an appropriate balance between protecting user privacy and maintaining query utility.

[0060] In S2, the calculation formula of the first cosine similarity is as follows: ; (Formula 5) In Formula 5, is the first cosine similarity; is the first included angle; is the original query vector; is the approximate query vector.

[0061] In S3, referring to Figure 6 the flow schematic diagram of the initial retrieval set acquisition method shown, "sending the first included angle, a preset first threshold, and the approximate query vector to the knowledge base retrieval platform for retrieval to obtain the initial retrieval set" includes the following steps: S301: Obtain the second cosine similarity; wherein, the second cosine similarity is the cosine similarity between the approximate query vector and the knowledge fragments in the knowledge base retrieval platform; S302: Based on the first included angle and the first threshold, obtain the second threshold; S303: Compose the knowledge fragments with the second cosine similarity greater than or equal to the second threshold into the initial retrieval set.

[0062] In S301, the knowledge base retrieval platform presets knowledge fragments, and the knowledge fragments include various types of information, which are designed to cover a wide range of topics and fields, such as articles, reports, manuals, guides, etc. After converting the knowledge fragments into vectors, calculate the similarity between the knowledge fragment vectors and the approximate query vector, that is, the second cosine similarity.

[0063] In S302, by converting the sensitive word vector into a confusion vector, while removing sensitive information and keeping the original query vector highly similar to the approximate query vector, ensuring that the cosine similarity between them is close to 1. In this way, the approximate query vector can be used to replace the original query vector for semantic matching and retrieval of the knowledge base. To achieve this goal, appropriately reduce the threshold of the cosine similarity, that is, determine the appropriate second threshold, 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 also ensuring the effectiveness of the retrieval.

[0064] There are two methods to obtain the second threshold. Method one is to calculate the vector difference between the original query vector and the approximate query vector to obtain the threshold difference, and subtract the threshold difference from the first threshold to obtain the second threshold; Method two is to directly calculate the cosine similarity threshold when retrieving using the approximate query vector to obtain the second threshold.

[0065] In method one, the calculation process of the second threshold is as follows: The cosine similarity between the original query vector and any knowledge fragment minus the cosine similarity between the approximate query vector and the same knowledge fragment yields a difference. The difference is presented according to the Cauchy - Schwarz inequality to obtain the threshold difference. The calculation formula for the difference is as follows: ; (Formula 6) In Formula 6, is the difference; 、 are the cosine similarities between the original query vector, the approximate query vector, and any knowledge fragment respectively; is the knowledge fragment vector. Usually, in the vector preprocessing stage, the query vectors obtained through word embeddings (such as Word2Vec, GloVe) or language models (such as BERT) are normalized so that their norms are 1. Therefore, the norms of both the original query vector and the approximate query vector are 1, so .

[0066] According to the Cauchy - Schwarz inequality, , so, , where, is the threshold difference. Since and are unit vectors, so , combined with , we get , so, .

[0067] Based on the above, the calculation formula for the second threshold is as follows: ; (Formula 7) In Formula 7, is the second threshold; is the first threshold.

[0068] In Method Two, the calculation process of the second threshold is as follows: Assume has a norm of 1. Decompose into the component in the direction of and the component in its orthogonal complement space, that is, , where, is the component (projection) of in the direction of , is the component of in the orthogonal complement space of , satisfies and . Similarly, decompose into The components in the direction and the components in its orthogonal complement space, namely where is a unit vector perpendicular to is introduced to express as the sum of two orthogonal components, one component parallel to and the other component orthogonal to , which is beneficial to subsequent formula derivation.

[0069] Expand the inner product using the decomposition formula , since and , simplify the inner product to obtain . According to the Cauchy-Schwarz inequality , therefore .

[0070] Given that , , therefore , furthermore, the calculation formula for the second threshold is as follows: ; (Formula 8) In Formula 8, the maximum value is the second threshold. Even if the modulus length of

[0071] In S303, if the method of calculating the second threshold using the threshold difference in S302 is adopted, the expression of the initial retrieval set is as follows: ; (Formula 9) In Formula 9, is the initial retrieval set.

[0072] If the method of directly calculating the second threshold in S302 is adopted, the expression of the initial retrieval set is as follows: ; (Formula 10) In Formula 10, by comparing the second cosine similarity with the second threshold, the knowledge fragments with the second cosine similarity greater than or equal to the second threshold are determined, and these knowledge fragments are combined to obtain the initial retrieval set.

[0073] In S4, the knowledge base retrieval platform sends the obtained initial retrieval set to the user terminal. After receiving the initial retrieval set, the user terminal calculates the cosine similarity between the original query vector and the knowledge fragments in the initial retrieval set, that is, the third cosine similarity. Compare the third cosine similarity with the first threshold, and determine the knowledge fragments for which the third cosine similarity is greater than or equal to the first threshold. Combine these knowledge fragments to obtain the target retrieval set.

[0074] An example of the above solution is given below: Construct a 24-dimensional vector , where the first 8 dimensions are all 0, and the last 16 dimensions are all , verify that The L2 norm of is 1. Assume that The continuous 4 non-zero components from the 9th to the 12th dimensions in are sensitive words, forming a sensitive word vector , so .

[0075] Keep the norm through orthogonal transformation (such as plane rotation). Apply two rotation transformations to : Apply a rotation angle to the first two dimensions, and apply a rotation angle to the last two dimensions, obtaining , , , . And The L2 norms of are equal, both 0.5.

[0076] Calculate And The dot product of is 0.2447. Calculate And The cosine similarity between is 0.9787. Replace the in with to obtain an approximate query vector . Since And The squares of the L2 norms of are both 0.25, so The square of the L2 norm of is 1, that is The L2 norm of is 1, which is consistent with The L2 norm of. Since The L2 norms of and And Are both 1, the first cosine similarity , where Represents the position of the vector element, Represents the element at the position in the original query vector, Represents the The element at the position. , The value of is and the dot product of, so, .

[0077] Select a randomly generated 24-dimensional unit vector , the first 8 dimensions are all 0, and the last 16 dimensions contain different values, , calculate The L2 norm of is 1.5, calculate and The dot product of is 1.1875, calculate and The dot product of is 1.217, by dividing 1.1875 by 1.5, calculate and The cosine similarity of is 0.7917, by dividing 1.217 by 1.5, calculate and The cosine similarity of is 0.8113, the difference between 0.7917 and 0.8113 is 0.0196. According to the above formula 7, the theoretical maximum difference is 0.103, and 0.0196 is less than 0.103, meeting the condition. Assume Take values of 0.9, 0.8, 0.75, 0.7 respectively. According to the above formula 8, Take values of 0.79033, 0.66936, 0.58953, 0.52069 respectively. Subtract from to get the theoretical maximum differences of 0.10967, 0.13064, 0.16047, 0.17931 respectively. 0.0196 is smaller than these theoretical maximum differences, so, it meets the condition.

[0078] In summary, this solution ensures the security of user privacy by using an approximate query vector without sensitive word information to replace the original query vector for retrieval, so that the knowledge base retrieval platform cannot reverse-infer the user's sensitive words from the approximate query vector; at the same time, since the approximate query vector is very similar to the original query vector in terms of cosine similarity, the angle between them is very small, ensuring the efficiency of the query, that is, the query redundancy is extremely small, the redundant computing consumption is controllable, and the user's screening of the results is also controllable; in addition, through the sharing of the computing amount by the user terminal, the bottleneck of the overall computing amount of the knowledge base retrieval platform in RAG retrieval is effectively alleviated.

[0079] Referring to Figure 7 , the present disclosure provides a retrieval system for protecting user sensitive words, including: The query vector acquisition module 101 is configured to acquire the input data of the user, and based on the input data, acquire the original query vector and the approximate query vector; The first angle acquisition module 102 is configured 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; The initial retrieval set acquisition module 103 is configured to send the first angle, a preset first threshold, and the approximate query vector to the knowledge base retrieval platform for retrieval, and acquire the initial retrieval set; The target retrieval set acquisition module 104 is configured to send the initial retrieval set to the user terminal, and based on the original query vector of the user terminal and the received initial retrieval set, acquire the target retrieval set.

[0080] The various variation methods and specific examples in the above-provided retrieval method for protecting user sensitive words are equally applicable to the retrieval system for protecting user sensitive words provided in this disclosure. Through the foregoing detailed description of the retrieval method for protecting user sensitive words, those skilled in the art can clearly know the implementation method of the retrieval system for protecting user sensitive words. For the sake of brevity of the specification, it will not be elaborated herein.

[0081] The computer device according to an embodiment of the present disclosure includes a memory and a processor. The memory is used to store non-temporary computer-readable instructions. Specifically, the memory may include one or more computer program products, and the computer program products may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory, etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc.

[0082] The processor may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the computer device to perform desired functions. In an embodiment of the present disclosure, the processor is used to run the computer-readable instructions stored in the memory, so that the computer device executes all or part of the steps of the retrieval method for protecting user sensitive words in the foregoing embodiments of the present disclosure.

[0083] Those skilled in the art should understand that, in order to solve the technical problem of how to obtain a good user experience effect, this embodiment may also include well-known structures such as communication buses, interfaces, etc., and these well-known structures should also be included in the protection scope of the present disclosure.

[0084] Such as Figure 8A schematic structural diagram of a computer device provided by an embodiment of the present disclosure. It shows a schematic structural diagram of a computer device 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 impose any limitations on the functions and usage scope of the embodiments of the present disclosure.

[0085] As Figure 8 shown, the computer device may include a processor (such as a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) or a program loaded from a storage device into a random access memory (RAM). In the RAM, various programs and data required for the operation of the computer device are also stored. The processor, ROM, and RAM are connected to each other through a bus. An input / output (I / O) interface is also connected to the bus.

[0086] Generally, the following devices may be connected to the I / O interface: an input device including, for example, a sensor or a visual information acquisition device; an output device including, for example, a display screen; a storage device including, for example, a magnetic tape, a hard disk, etc.; and a communication device. The communication device may allow the computer device to communicate wirelessly or wirelessly with other devices (such as edge computing devices) to exchange data. Although Figure 8 a computer device with various devices is shown, it should be understood that it is not required to implement or have all the shown devices. Instead, more or fewer devices may be implemented or had.

[0087] Specifically, according to the embodiments of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes program codes for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device, or installed from the storage device, or installed from the ROM. When the computer program is executed by the processor, all or part of the steps of the method for retrieving protected user sensitive words in the embodiments of the present disclosure are executed. [[ID=Q16]]

[0088] For a detailed description of this embodiment, reference may be made to the corresponding descriptions in the foregoing embodiments, and details will not be repeated here.

[0089] According to the computer-readable storage medium of the embodiments of the present disclosure, non-transitory computer-readable instructions are stored thereon. When the non-transitory computer-readable instructions are run by a processor, all or part of the steps of the method for retrieving protected user sensitive words in the foregoing embodiments of the present disclosure are executed.

[0090] The above 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 removable hard disk), media with built-in rewritable non-volatile memory (e.g., memory card), and media with built-in ROM (e.g., ROM cartridge).

[0091] For a detailed description of this embodiment, reference may be made to the corresponding descriptions in the foregoing embodiments, which will not be elaborated herein.

[0092] The basic principles of the present disclosure have been described above in conjunction with specific embodiments. However, it should be noted that the advantages, benefits, effects, etc. mentioned in the present disclosure are only examples and not limitations, and it cannot be considered that these advantages, benefits, effects, etc. are essential for each embodiment of the present disclosure. In addition, the above-mentioned specific details of the disclosure are only for illustrative purposes and for ease of understanding, rather than limitations. The above details do not limit the present disclosure to necessarily adopt the above specific details for implementation.

[0093] In the present disclosure, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. The block diagrams of the devices, apparatuses, equipment, and systems involved in the present disclosure are only illustrative examples and do not intend to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open-ended words, meaning "including but not limited to", and can be used interchangeably with them. The words "or" and "and" used herein refer to the word "and / or", and can be used interchangeably with it, unless the context clearly indicates otherwise. The word "such as" used herein refers to the phrase "such as but not limited to", and can be used interchangeably with it.

[0094] In addition, as used herein, the "or" used in the listing of items starting with "at least one" indicates a separate listing, so that for example, the listing of "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). In addition, the term "exemplary" does not mean that the described examples are preferred or better than other examples.

[0095] It should also be noted that in the systems and methods of the present disclosure, each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent solutions of the present disclosure.

[0096] Various changes, substitutions, and alterations to the technology described herein can be made without departing from the teachings defined by the appended claims. Additionally, the scope of the claims of this disclosure is not limited to the specific aspects of the processes, machines, manufactures, compositions of events, means, methods, and acts described above. Processes, machines, manufactures, compositions of events, means, methods, or acts that are currently available or later to be developed that perform substantially the same function or achieve substantially the same result as the corresponding aspects described herein can be utilized. Accordingly, the appended claims include such processes, machines, manufactures, compositions of events, means, methods, or acts within their scope.

[0097] The foregoing description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein can be applied to other aspects without departing from the scope of the present disclosure. Thus, the present disclosure is not intended to be limited to the aspects shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

[0098] The foregoing description has been presented for purposes of illustration and description. Additionally, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although numerous example aspects and embodiments have been discussed above, those skilled in the art will recognize some of their variations, modifications, alterations, additions, and subcombinations.

Claims

1. A retrieval method for protecting user sensitive words, characterized in that, Including: Obtain the input data of the user, and based on the input data, obtain the original query vector and the approximate query vector; Obtain the first cosine similarity, and obtain the first included 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; 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; Send the initial retrieval set to the user terminal, and based on the original query vector of the user terminal and the received initial retrieval set, obtain the target retrieval set.

2. The retrieval method for protecting user sensitive words according to claim 1, wherein The obtaining the original query vector and the approximate query vector based on the input data includes: Convert the input data into the original query vector; Replace the sensitive words in the input data with safe vocabulary to generate desensitized data; Convert the desensitized data into the approximate query vector.

3. The retrieval method for protecting user sensitive words according to claim 1, characterized in that, The obtaining the original query vector and the approximate query vector based on the input data includes: Based on the input data, construct a vocabulary; wherein, the vocabulary contains all unique words in the input data; Based on the vocabulary, construct the original query vector; Identify the sensitive words in the input data, and obtain the positions corresponding to the sensitive words in the original query vector; Convert the sensitive words into sensitive word vectors, and perform confusion processing on the sensitive word vectors to generate confusion vectors; Based on the positions, fuse the confusion vectors and the original query vector into the approximate query vector.

4. The retrieval method for protecting user sensitive words according to claim 1, wherein The obtaining the original query vector and the approximate query vector based on the input data includes: Obtain the sensitive words and non-sensitive words in the input data, and convert the sensitive words and the non-sensitive words into sensitive word vectors and non-sensitive word vectors respectively; Aggregate the sensitive word vectors and the non-sensitive word vectors to generate the original query vector; Perform confusion processing on the sensitive word vectors to generate confusion vectors; Aggregate the confusion vectors and the non-sensitive word vectors to generate the approximate query vector.

5. The retrieval method for protecting user sensitive words according to claim 1, wherein The obtaining the original query vector and the approximate query vector based on the input data includes: Convert the input data into the original query vector; Obtain the sensitive data and non-sensitive data in 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 a preset language model, obtain the approximate query vector.

6. The retrieval method for protecting user-sensitive words according to claim 1, wherein The 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 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 fragments in the knowledge base retrieval platform; Based on the first included angle and the first threshold, obtain the second threshold; Form the initial retrieval set with the knowledge fragments whose second cosine similarity is greater than or equal to the second threshold.

7. The retrieval method for protecting user-sensitive words according to claim 6, characterized in that, The calculation formula of the second threshold is: ; Wherein, is the second threshold value; is the first threshold value; is the first included angle.

8. The retrieval method for protecting user sensitive words according to claim 6, wherein The calculation formula of the second threshold is: ; Wherein, is the second threshold value; is the first threshold value; is the first included angle.

9. The retrieval method for protecting user-sensitive words according to claim 6, characterized in that, Obtaining a target retrieval set based on the original query vector of the user terminal and the received initial retrieval set includes: Obtaining a third cosine similarity; wherein, the third cosine similarity is the cosine similarity between the original query vector and the knowledge fragments in the initial retrieval set; Forming a target retrieval set with the knowledge fragments whose third cosine similarity is greater than or equal to the first threshold.

10. 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 executable by the at least one processor, and when the instructions are executed by the at least one processor, the at least one processor is enabled to execute the retrieval method for protecting user sensitive words according to any one of claims 1-9.

11. A computer-readable storage medium, characterized in that, This computer-readable storage medium stores computer instructions for causing a computer to execute the retrieval method for protecting user sensitive words according to any one of claims 1-9.

12. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by a processor, the steps of the method according to any one of claims 1-9 are implemented.

Citation Information

Patent Citations

  • Information retrieval method and system for small data set

    CN115248807A

  • Text similarity retrieval analysis method and system based on big data

    CN119046303A

  • Large-scale embedded index data desensitization method suitable for forestry database

    CN119538311A

  • Retrieval enhancement method and device based on large model and storage medium

    CN119988602A

  • Method and system for providing semantics based technical support

    US20170132210A1