Vector retrieval method and device, medium, electronic equipment and program product
By conducting a linear transformation and rotation operation of the target vector to generate a ciphertext vector, and retrieve similar ciphertext vectors in the knowledge vector library, the problem of being unable to protect the Embedding during the search process of the existing technology, and realizes the support vector retrieval At the same time, effectively resist VEC2Text attacks to protect user privacy.
Patent Information
- Application Number
- CN202411472727.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2025-01-24
AI Technical Summary
While supporting vector retrieval, the prior art cannot effectively protect the embedding stored in the knowledge vector library, resulting in attackers being able to counter-solve plaintext through vec2text attacks and leak user privacy.
By obtaining the target vector and target key, the target random number is used for linear transformation, and the target orthogonal matrix is used for rotating operations to generate the first ciphertext vector. Then, send the ciphertext vector to the server, and retrieve similar ciphertext vectors from the knowledge vector library to ensure that the formation of the ciphertext vector is consistent with the first ciphertext vector.
The ciphertext vector generated by linear transformation and rotation operation can support vector retrieval with the consistency of maintaining the vector distance, and effectively resist the VEC2Text attack to prevent the privacy of the user.
Smart Images

Figure CN119363335A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular, to a vector retrieval method, device, medium, electronic device and program product. Background Art
[0002] Embedding vectors can be used to support vector retrieval, clustering, recommendations, and other applications. A typical application is retrieval-augmented generation (RAG), which plays a role in the entire process of large language models. Figure 1 As shown. Figure 1 As shown in the figure, there are two key stages of RAG: the first stage is the retrieval stage, which is used to encode the text corresponding to the user's input request to generate a query embedding, and then compare the query embedding with the embedding in the knowledge vector library (for example, completed based on dense vector retrieval), obtain a similar vector similar to the query embedding vector, and obtain the plain text corresponding to the similar vector; the second stage is the generation stage, that is, the plain text corresponding to the similar vector retrieved in the retrieval stage is used as prompt information, and is input into the large language model together with the text corresponding to the input request to obtain the response text of the text corresponding to the input request.
[0003] Generally speaking, embedding is considered to be indecipherable from the original plaintext, so it is not protected (otherwise it cannot be retrieved). Figure 2 As shown in the figure, even if the attacker does not have an embedding model, he can still use the vector-to-text (vec2text) attack to decrypt the plaintext from the embedding (i.e., attack to restore the text). The similarity between the decrypted plaintext and the original text is close to 1, which may leak user privacy. Therefore, it is necessary to protect the embedding stored in the knowledge vector library while supporting vector retrieval. Summary of the invention
[0004] This summary is provided to introduce concepts in a brief form that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0005] In a first aspect, the present disclosure provides a vector retrieval method, comprising:
[0006] Obtaining a target vector and a target key to be retrieved, wherein the target key includes a target random number and a target orthogonal matrix;
[0007] Performing a linear transformation on the target vector using the target random number;
[0008] Using the target orthogonal matrix, a rotation operation is performed on the target vector obtained after the linear transformation to obtain a first ciphertext vector;
[0009] The first ciphertext vector is sent to a first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from a knowledge vector library; wherein the ciphertext vectors in the knowledge vector library are generated based on the target key and a reference vector, and the generation method is the same as the generation method of the first ciphertext vector.
[0010] In a second aspect, the present disclosure provides a vector search device, comprising:
[0011] An acquisition module, used for acquiring a target vector and a target key to be retrieved, wherein the target key includes a target random number and a target orthogonal matrix;
[0012] A linear transformation module, used for performing a linear transformation on the target vector using the target random number;
[0013] A rotation module, used to perform a rotation operation on a target vector obtained after linear transformation of the target orthogonal matrix to obtain a first ciphertext vector;
[0014] A first sending module is used to send the first ciphertext vector to a first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from a knowledge vector library; wherein the ciphertext vector in the knowledge vector library is generated based on the target key and the reference vector, and the generation method is the same as the generation method of the first ciphertext vector.
[0015] In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the vector retrieval method provided in the first aspect of the present disclosure.
[0016] In a fourth aspect, the present disclosure provides an electronic device, including:
[0017] a storage device having a computer program stored thereon;
[0018] A processing device is used to execute the computer program in the storage device to implement the steps of the vector retrieval method provided in the first aspect of the present disclosure.
[0019] In a fifth aspect, the present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the vector retrieval method provided in the first aspect of the present disclosure.
[0020] In the above technical solution, before performing vector retrieval on the target vector, the target vector is firstly linearly transformed using the target random number, and then the target vector obtained after the linear transformation is rotated using the target orthogonal matrix to obtain the first ciphertext vector of the target vector; finally, the first ciphertext vector is sent to the first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from the knowledge vector library, wherein the ciphertext vector in the knowledge vector library is generated based on the target random number, the target orthogonal matrix and the reference vector, and the generation method is the same as the generation method of the first ciphertext vector. Since the multiplication of the orthogonal matrix and the vector has the characteristic of maintaining the distance between the vectors, the target vector obtained after the linear transformation and the reference vector obtained after the linear transformation are rotated using the orthogonal matrix, so that the distance between the first ciphertext vector and the second ciphertext vector can be close to the distance between the original plaintext vectors, so as to approximately maintain the distance between the plaintext vectors, so that it can support retrieval on the ciphertext vector just like the plaintext vector supports retrieval, and ensure that the recall rate remains basically unchanged. In addition, the target vector and each reference vector in the knowledge vector library are encrypted using target random numbers and target orthogonal matrices, which can mask the information of the original plaintext vector from both the horizontal (linear transformation) and vertical (orthogonal matrix) directions. This allows us to resist vec2text attacks in language model service scenarios while supporting vector retrieval, thereby avoiding user privacy leakage.
[0021] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale. In the drawings:
[0023] Figure 1 It is a process diagram of a retrieval enhancement generation method in related technology.
[0024] Figure 2 This is a schematic diagram of the vec2text attack in the related art.
[0025] Figure 3 The figure is a flowchart of a vector search method according to an exemplary embodiment.
[0026] Figure 4 is a schematic diagram of a vec2text attack according to an exemplary embodiment.
[0027] Figure 5 is a flowchart of a vector retrieval method according to another exemplary embodiment.
[0028] Figure 6 is a flowchart of a vector retrieval method according to yet another exemplary embodiment.
[0029] Figure 7 It is a block diagram of a vector retrieval device according to an exemplary embodiment.
[0030] Figure 8 The diagram is a schematic structural diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0031] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0032] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0033] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0034] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0035] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0036] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0037] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0038] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.
[0039] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0040] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0041] At the same time, it is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0042] Figure 3 FIG. 1 is a flow chart of a vector search method according to an exemplary embodiment. Figure 3 As shown, the vector search method may include the following S101 to S104.
[0043] In S101, a target vector and a target key to be retrieved are obtained, where the target key includes a target random number and a target orthogonal matrix.
[0044] In the present disclosure, the above-mentioned vector retrieval method can be applied to the client. For the question-answering scenario, the user can input a request to the client, and the client can encode the text corresponding to the input request in response to receiving the input request to obtain the target vector to be retrieved. The target key can be pre-generated by the client, for example, a random number is pre-generated as the target random number, and an orthogonal matrix of d dimensions is randomly generated as the target orthogonal matrix, where d is the dimension of the target vector and d is a natural number greater than 0.
[0045] In S102, a target vector is linearly transformed using a target random number.
[0046] For example, the target vector c'=s·m obtained after the linear transformation, wherein s is the target random number and m is the target vector.
[0047] In S103, a target vector obtained after the linear transformation is rotated using a target orthogonal matrix to obtain a first ciphertext vector.
[0048] For example, the target vector obtained after the linear transformation can be rotated by the following equation (1) to obtain the first ciphertext vector c:
[0049] c=Μ·c' (1)
[0050] Where M is the target orthogonal vector.
[0051] In S104, the first ciphertext vector is sent to the first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from a knowledge vector library, where the ciphertext vectors in the knowledge vector library are generated based on the target key and the reference vector, and the generation method is the same as the generation method of the first ciphertext vector.
[0052] In the present disclosure, a knowledge vector library is stored on the first server, and the knowledge vector library includes multiple ciphertext vectors and ciphertext texts corresponding to each ciphertext vector, wherein the ciphertext vector in the knowledge vector library is obtained by the client performing linear transformation and rotation operations on the reference vector based on the target key, and the reference vector can be a vector obtained by the client after word segmentation and encoding of the text in the corpus, and the ciphertext text corresponding to the ciphertext vector is obtained by the client performing symmetric encryption on the corresponding text in the corpus, for example, using the Advanced Encryption Standard (AES) to encrypt the text, and the client stores the ciphertext vector and its corresponding ciphertext text in the knowledge vector library after obtaining it. The generation method of the ciphertext vector in the knowledge vector library is the same as the generation method of the first ciphertext vector, that is, first using the target random number to perform linear transformation on the reference vector, and then using the target orthogonal matrix to perform rotation operations on the reference vector obtained after the linear transformation to obtain the ciphertext vector of the reference vector, that is, the ciphertext vector in the knowledge vector library.
[0053] After encrypting the target vector through linear transformation and rotation operations, the client sends the encrypted first ciphertext vector to the first server; after receiving the first ciphertext vector sent by the client, the first server can use the Approximate Nearest Neighbors (ANN) algorithm to retrieve at least one second ciphertext vector similar to the first ciphertext vector from the knowledge vector library, and feed back the at least one similar second ciphertext vector to the client. The first server can measure the similarity between the first ciphertext vector and each ciphertext vector in the knowledge vector library by Euclidean distance, cosine similarity, etc., and determine the ciphertext vector whose similarity with the first ciphertext vector is greater than a preset similarity threshold as a vector similar to the first ciphertext vector.
[0054] like Figure 4 As shown, the target vector and each reference vector in the knowledge vector library are encrypted using a target random number and a target orthogonal matrix, which can mask the information of the original plaintext vector from both the horizontal (linear transformation) and vertical (orthogonal matrix) directions. In this way, the similarity between the plaintext obtained by the vec2text attack (i.e., the attack restored text) and the original text (for example, the text corresponding to the input request) is reduced, thereby resisting the vec2text attack in the language model service scenario and avoiding user privacy leakage.
[0055] In the above technical solution, before performing vector retrieval on the target vector, the target vector is firstly linearly transformed using the target random number, and then the target vector obtained after the linear transformation is rotated using the target orthogonal matrix to obtain the first ciphertext vector of the target vector; finally, the first ciphertext vector is sent to the first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from the knowledge vector library, wherein the ciphertext vector in the knowledge vector library is generated based on the target random number, the target orthogonal matrix and the reference vector, and the generation method is the same as the generation method of the first ciphertext vector. Since the multiplication of the orthogonal matrix and the vector has the characteristic of maintaining the distance between the vectors, the target vector obtained after the linear transformation and the reference vector obtained after the linear transformation are rotated using the orthogonal matrix, so that the distance between the first ciphertext vector and the second ciphertext vector can be close to the distance between the original plaintext vectors, so as to approximately maintain the distance between the plaintext vectors, so that it can support retrieval on the ciphertext vector just like the plaintext vector supports retrieval, and ensure that the recall rate remains basically unchanged. In addition, the target vector and each reference vector in the knowledge vector library are encrypted using target random numbers and target orthogonal matrices, which can mask the information of the original plaintext vector from both the horizontal (linear transformation) and vertical (orthogonal matrix) directions. This allows us to resist vec2text attacks in language model service scenarios while supporting vector retrieval, thereby avoiding user privacy leakage.
[0056] Since the target orthogonal matrix is fixed, if the first server obtains multiple original plaintext vectors and the ciphertext vectors corresponding to each original plaintext vector, the target orthogonal matrix can be inferred, thereby inversely solving the plaintext vectors corresponding to other ciphertext vectors, and then using the vec2text attack to obtain the original text corresponding to the plaintext vector. To this end, the target vector can be noised to enhance the privacy of the ciphertext vector, wherein the introduction of noise can make the ciphertext vector and the original plaintext vector no longer a simple linear relationship, so that it is difficult to solve the noise in the ciphertext vector without knowing the key, and then it is difficult to solve the plaintext vector corresponding to the ciphertext vector, so as to resist the vec2text attack in the language model service scenario. Specifically, the above-mentioned target key can also include a first bit string of a first preset length, wherein the client can randomly generate a bit string of a first preset length consisting of 0 and 1 as the first bit string.
[0057] At this time, if Figure 5 As shown, before the above S103, the above vector search method may further include the following S105 to S108.
[0058] In S105 , a second bit string of a second preset length is randomly generated.
[0059] In the present disclosure, the second bit string is a bit string of a second preset length consisting of 0s and 1s.
[0060] In S106, the first bit string is used as a key of a preset pseudo-random function, and the second bit string is used as an input of the preset pseudo-random function to obtain a third bit string.
[0061] In S107 , Gaussian noise is generated according to the third bit string, a preset approximation factor, and a target random number.
[0062] In S108, Gaussian noise is used to perform noise processing on the target vector obtained after the linear transformation to obtain a noise vector.
[0063] For example, Gaussian noise can be used to add noise to the target vector obtained after linear transformation through the following equation (2) to obtain a noise vector:
[0064] z=c'+λ m (2)
[0065] Where z is the noise vector; λ m is Gaussian noise.
[0066] At this time, the above S103 can use the target orthogonal matrix to perform a rotation operation on the noise vector to obtain the first ciphertext vector.
[0067] For example, the noise vector may be rotated by the following equation (3) to obtain the first ciphertext vector c:
[0068] c=M·z (3)
[0069] The specific implementation method of generating Gaussian noise according to the third bit string, the preset approximation factor and the target random number in S107 is described in detail below. Specifically, it can be achieved by the following steps (a1) to (a3):
[0070] Step (a1): based on a preset splitting rule, split the third bit string into a fourth bit string and a fifth bit string.
[0071] In the present disclosure, the preset splitting rule may be to divide the third bit string into two bit strings of equal length, or to divide the third bit string according to other ratios (e.g., 3:7), which is not specifically limited in the present disclosure. In addition, when encrypting the reference vector, it is also based on the preset splitting rule.
[0072] Step (a2): using the fourth bit string, generate a Gaussian vector of dimension d that conforms to the standard normal distribution, and using the fifth bit string, generate a pseudo-random number that conforms to the (0, 1) uniform distribution.
[0073] In the present disclosure, a Gaussian distribution algorithm can be used to generate a standard normal distribution N(0,I d ) of the Gaussian vector, where I d is the d-dimensional identity matrix and is the standard deviation.
[0074] Step (a3): Generate Gaussian noise using a Gaussian vector, a pseudo-random number, a preset approximation factor, and a target random number.
[0075] For example, Gaussian noise can be generated by using a Gaussian vector, a pseudo-random number, a preset approximation factor, and a target random number through the following equation (4):
[0076]
[0077] Among them, γ is a scaling factor, which is a real number. When the Euclidean distance is used to measure the similarity between the first ciphertext vector and each ciphertext vector in the knowledge vector library, the value range of γ is (0,0.25]; when the cosine similarity is used to measure the similarity between the first ciphertext vector and each ciphertext vector in the knowledge vector library, the value range of γ is β is a preset approximation factor, and, The d-dimensional vector space to which the target vector belongs is α=[-W,W] d, the range of elements in the target vector belongs to [-W,W]; x′ is a pseudo-random number; u is a Gaussian vector; ||u|| is the bi-norm of the Gaussian vector.
[0078] The smaller the privacy factor β is, the higher the recall rate of the nearest neighbor retrieval is, but the privacy protection of the original vector will be worse. The larger the privacy factor β is, the lower the recall rate of the nearest neighbor retrieval is, but the privacy protection of the original vector will be better. Therefore, the size of the privacy factor β can be adjusted to achieve a balance between the recall rate of the nearest neighbor retrieval and the privacy protection of the original vector.
[0079] In order to further improve the privacy of the ciphertext vector, after obtaining the first ciphertext vector, it can be masked using a masking vector. Specifically, the above target key can also include a masking vector, such as Figure 6 As shown, before the above S104, the above vector search method may further include the following S109.
[0080] In S109, the first ciphertext vector is masked using the masking vector.
[0081] At this time, the above S104 may send the first ciphertext vector obtained after the masking process to the first server, so that the first server can retrieve at least one second ciphertext vector similar to the first ciphertext vector obtained after the masking process from the knowledge vector library.
[0082] In addition, a d-dimensional vector may be selected from the d-dimensional vector space α to which the target vector belongs as a masking vector for masking the first ciphertext vector.
[0083] For example, the masking vector may be used to mask the first ciphertext vector using the following equation (5):
[0084] h=c+t (5)
[0085] Wherein, h is the first ciphertext vector obtained after masking; t is the masking vector.
[0086] In a possible implementation manner, the above vector retrieval method may further include the following steps:
[0087] In response to receiving the at least one second ciphertext vector sent by the first server, the at least one second ciphertext vector is decrypted using the target key.
[0088] In one implementation, when the target key includes a target random number and a target orthogonal matrix, the target key may be used to decrypt at least one second ciphertext vector in the following manner:
[0089] For each second ciphertext vector, first, the second ciphertext vector is rotated using the transpose matrix of the target orthogonal matrix to obtain a third ciphertext vector; then, the third ciphertext vector is linearly transformed using the inverse of the target random number to obtain a plaintext vector corresponding to the second ciphertext vector.
[0090] For example, the transposed matrix M of the target orthogonal matrix can be used first T Rotate the second ciphertext vector c1 to obtain the third ciphertext vector M T c1, then, using the inverse of the target random number For the third ciphertext vector M T c1 performs a linear transformation to obtain the plaintext vector corresponding to the second ciphertext vector
[0091] In another implementation, when the target key includes a target random number, a target orthogonal matrix, and a first bit string, the target key may be used to decrypt at least one second ciphertext vector in the following manner:
[0092] For each second ciphertext vector, first, the second ciphertext vector is rotated using the transpose matrix of the target orthogonal matrix to obtain a third ciphertext vector; then, Gaussian noise is removed from the third ciphertext vector to obtain a fourth ciphertext vector; next, the fourth ciphertext vector is linearly transformed using the inverse of the target random number to obtain a plaintext vector corresponding to the second ciphertext vector.
[0093] For example, the transposed matrix M of the target orthogonal matrix can be used first T Rotate the second ciphertext vector c1 to obtain the third ciphertext vector M T c1, then, from the third ciphertext vector M T Remove Gaussian noise λ from c1 m , get the fourth ciphertext vector Μ T c1-λ m ; Finally, use the inverse of the target random number Perform a linear transformation on the fourth ciphertext vector to obtain the plaintext vector corresponding to the second ciphertext vector
[0094] In yet another embodiment, when the target key includes a target random number, a target orthogonal matrix, a first bit string, and a masking vector, the target key may be used to decrypt at least one second ciphertext vector in the following manner:
[0095] For each second ciphertext vector, first, the second ciphertext vector is de-masked using the mask vector to obtain the fifth ciphertext vector; then, the fifth ciphertext vector is rotated using the transpose matrix of the target orthogonal matrix to obtain the sixth ciphertext vector; next, Gaussian noise is removed from the sixth ciphertext vector to obtain the seventh ciphertext vector; finally, the seventh ciphertext vector is linearly transformed using the inverse of the target random number to obtain the plaintext vector corresponding to the second ciphertext vector.
[0096] For example, the second ciphertext vector c1 may be demasked using the masking vector t to obtain the fifth ciphertext vector c1-t; then, the transposed matrix M of the target orthogonal matrix may be used to demask the second ciphertext vector c1-t. T Rotate the fifth ciphertext vector c1-t to obtain the sixth ciphertext vector M T (c1-t); Next, from the sixth ciphertext vector M T Remove Gaussian noise λ from (c1-t) m , get the seventh ciphertext vector Μ T (c1-t)-λ m ; Finally, the inverse of the target random number Linearly perform the seventh ciphertext vector
[0097] Transform to obtain the plaintext vector corresponding to the second ciphertext vector
[0098] When the Euclidean distance is used to measure the similarity between the first ciphertext vector and each ciphertext vector in the knowledge vector library, the Euclidean distance search of the plaintext is approximately converted to the Euclidean distance search of the ciphertext. Assuming that x and z are two plaintext vectors in the knowledge vector library, and satisfy ||xm||<||zm||-β, and the value range of γ is (0,0.25], it can be proved that the inner product ||c x -c||<||c z -c||, where ||xm|| represents the Euclidean distance between x and m, ||zm|| represents the Euclidean distance between z and m, and c x is the ciphertext of x, c z is the ciphertext of z, ||c x -c||Characterization c x The Euclidean distance from c, ||c z -c||Characterization c z The Euclidean distance between x and c, where x and z are encrypted using the same encryption method as the target vector.
[0099] When cosine similarity is used to measure the similarity between the first ciphertext vector and each ciphertext vector in the knowledge vector library, the cosine similarity search of the plaintext is approximately converted into the inner product search of the ciphertext. Assume that x and z are two plaintext vectors in the knowledge vector library, m is the target vector, and cos(x,m)<cos(z,m)-β, ||x||=||m||=||z||=1, and the value range of γ is And, t is a zero vector, then we can prove that the inner product in, is the transposed vector of the ciphertext vector of x, is the transposed vector of the ciphertext vector of z, cos(x,m) represents the cosine similarity between x and m, cos(z,m) represents the cosine similarity between z and m, ||x|| represents the binary norm of x, ||m|| represents the binary norm of m, and ||z|| represents the binary norm of z.
[0100] When the above-mentioned vector retrieval method is applied to a client, the above-mentioned S101 may include, in response to receiving the text corresponding to the input request, encoding the text corresponding to the input request to obtain a target vector; at this time, the above-mentioned S104 may include: sending the first ciphertext vector to the first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from the knowledge vector library, obtains the ciphertext text corresponding to the at least one second ciphertext vector, and sends the at least one second ciphertext vector and the at least one ciphertext text to the client; the above-mentioned vector retrieval method may also include the following two steps:
[0101] In response to receiving at least one ciphertext text sent by the first server, the text corresponding to the input request and the at least one ciphertext text are sent to the large language model server, so that the large language model server uses the at least one ciphertext text as prompt information to generate a response text of the text corresponding to the input request, and sends the response text to the client;
[0102] Receive and display the response text sent by the large language model server.
[0103] In the present disclosure, a large language model is deployed on a large language model server. For the question-answering scenario, after the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from the knowledge vector library, it can obtain the ciphertext text corresponding to the at least one second ciphertext vector, and then send the at least one second ciphertext vector and the at least one ciphertext text to the client; after receiving the at least one ciphertext text sent by the first server, the client sends the text corresponding to the input request and the at least one ciphertext text to the large language model server; after receiving the text corresponding to the input request and the at least one ciphertext text, the large language model server can first decrypt the at least one ciphertext text, and then, using the plaintext text corresponding to the ciphertext text as a prompt word, generate a response text of the text corresponding to the input request through the question-answering model (i.e., the large language model), and send the response text to the client; after receiving the response text, the client displays the response text.
[0104] The large language model server can perform decryption operations on ciphertext in a trusted execution environment, and the client synchronizes the encryption key of the ciphertext to the trusted execution environment of the large language model server. The trusted execution environment can prevent the target key from being leaked.
[0105] Figure 7 FIG. 1 is a block diagram of a vector search device according to an exemplary embodiment. Figure 7 As shown, the vector search device 200 includes:
[0106] An acquisition module 201 is used to acquire a target vector and a target key to be retrieved, wherein the target key includes a target random number and a target orthogonal matrix;
[0107] A linear transformation module 202, configured to perform a linear transformation on the target vector using the target random number;
[0108] A rotation module 203 is used to perform a rotation operation on a target vector obtained after linear transformation of the target orthogonal matrix to obtain a first ciphertext vector;
[0109] The first sending module 204 is used to send the first ciphertext vector to a first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from a knowledge vector library; wherein the ciphertext vectors in the knowledge vector library are generated based on the target key and the reference vector, and the generation method is the same as the generation method of the first ciphertext vector.
[0110] In the above technical solution, before performing vector retrieval on the target vector, the target vector is firstly linearly transformed using the target random number, and then the target vector obtained after the linear transformation is rotated using the target orthogonal matrix to obtain the first ciphertext vector of the target vector; finally, the first ciphertext vector is sent to the first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from the knowledge vector library, wherein the ciphertext vector in the knowledge vector library is generated based on the target random number, the target orthogonal matrix and the reference vector, and the generation method is the same as the generation method of the first ciphertext vector. Since the multiplication of the orthogonal matrix and the vector has the characteristic of maintaining the distance between the vectors, the target vector obtained after the linear transformation and the reference vector obtained after the linear transformation are rotated using the orthogonal matrix, so that the distance between the first ciphertext vector and the second ciphertext vector can be close to the distance between the original plaintext vectors, so as to approximately maintain the distance between the plaintext vectors, so that it can support retrieval on the ciphertext vector just like the plaintext vector supports retrieval, and ensure that the recall rate remains basically unchanged. In addition, the target vector and each reference vector in the knowledge vector library are encrypted using target random numbers and target orthogonal matrices, which can mask the information of the original plaintext vector from both the horizontal (linear transformation) and vertical (orthogonal matrix) directions. This allows us to resist vec2text attacks in language model service scenarios while supporting vector retrieval, thereby avoiding user privacy leakage.
[0111] Optionally, the target key further includes a first bit string of a first preset length;
[0112] The vector search device 200 further includes:
[0113] A first generating module, configured to randomly generate a second bit string of a second preset length before the rotation module 203 uses the target orthogonal matrix to perform a rotation operation on the target vector obtained after the linear transformation;
[0114] A second generating module, configured to use the first bit string as a key of a preset pseudo-random function and the second bit string as an input of the preset pseudo-random function to obtain a third bit string;
[0115] A third generating module, used for generating Gaussian noise according to the third bit string, a preset approximation factor and the target random number;
[0116] A noise adding module, used for performing noise adding processing on the target vector obtained after the linear transformation by using the Gaussian noise to obtain a noise vector;
[0117] The rotation module 203 is used to perform a rotation operation on the noise vector using the target orthogonal matrix.
[0118] Optionally, the third generating module includes:
[0119] a splitting submodule, configured to split the third bit string into a fourth bit string and a fifth bit string based on a preset splitting rule;
[0120] A first generating submodule is used to generate a Gaussian vector of dimension d that conforms to a standard normal distribution using the fourth bit string, and to generate a pseudo-random number that conforms to a (0, 1) uniform distribution using the fifth bit string, wherein d is the dimension of the target vector and d is a natural number greater than 0;
[0121] The second generating submodule is used to generate Gaussian noise by using the Gaussian vector, the pseudo-random number, a preset approximation factor and the target random number.
[0122] Optionally, the second generating submodule is used to generate Gaussian noise by using the Gaussian vector, the pseudo-random number, a preset approximation factor and the target random number through the following formula:
[0123]
[0124] Among them, λ m is the Gaussian noise; γ is the scaling factor; β is the preset approximation factor; s is the target random number; x′ is the pseudo-random number; u is the Gaussian vector; ||u|| is the bi-norm of the Gaussian vector.
[0125] Optionally, the target key further comprises a masking vector;
[0126] The vector search device 200 further includes: a masking module, configured to perform masking processing on the first ciphertext vector using the masking vector before the first sending module 204 sends the first ciphertext vector to the first server;
[0127] The first sending module 204 is used to send the first ciphertext vector obtained after masking to the first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector obtained after masking from the knowledge vector library.
[0128] Optionally, the vector search device 200 further includes:
[0129] A decryption module is configured to, in response to receiving the at least one second ciphertext vector sent by the first server, decrypt the at least one second ciphertext vector using the target key.
[0130] Optionally, the decryption module includes:
[0131] a rotation submodule, configured to perform a rotation operation on each of the second ciphertext vectors using a transposed matrix of the target orthogonal matrix to obtain a third ciphertext vector;
[0132] The linear transformation submodule is used to perform a linear transformation on the third ciphertext vector using the reciprocal of the target random number to obtain a plaintext vector corresponding to the second ciphertext vector.
[0133] Optionally, the vector retrieval device 200 is applied to a client;
[0134] The acquisition module is used for encoding the text corresponding to the input request in response to receiving the text to obtain the target vector;
[0135] The first sending module 204 is used to send the first ciphertext vector to the first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from the knowledge vector library, obtains a ciphertext text corresponding to at least one second ciphertext vector, and sends the at least one second ciphertext vector and the at least one ciphertext text to the client;
[0136] The vector search device 200 further includes:
[0137] a second sending module, configured to send the text and at least one of the ciphertext texts to a large language model server in response to receiving at least one of the ciphertext texts sent by the first server, so that the large language model server generates a response text of the text using at least one of the ciphertext texts as prompt information, and sends the response text to the client;
[0138] A receiving module is used to receive and display the response text sent by the large language model server.
[0139] In addition, the present disclosure also provides a computer-readable medium on which a computer program is stored. When the computer program is executed by a processing device, the steps of the above-mentioned vector retrieval method provided by the present disclosure are implemented.
[0140] In addition, the present disclosure also provides a computer program product, including a computer program, which implements the steps of the above-mentioned vector retrieval method provided by the present disclosure when the computer program is executed by a processor.
[0141] Reference below Figure 8, which shows a schematic diagram of the structure of an electronic device (e.g., terminal device) 600 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (e.g., vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0142] like Figure 8 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0143] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 8 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0144] In particular, according to an embodiment 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 contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0145] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0146] In some embodiments, the client can communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0147] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0148] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains a target vector and a target key to be retrieved, wherein the target key includes a target random number and a target orthogonal matrix; performs a linear transformation on the target vector using the target random number; performs a rotation operation on the target vector obtained after the linear transformation using the target orthogonal matrix to obtain a first ciphertext vector; sends the first ciphertext vector to a first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from a knowledge vector library; wherein the ciphertext vectors in the knowledge vector library are generated based on the target key and the reference vector, and the generation method is the same as the generation method of the first ciphertext vector.
[0149] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0150] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0151] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a module does not limit the module itself in some cases. For example, an acquisition module may also be described as a "module for acquiring a target vector and a target key to be retrieved".
[0152] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0153] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0154] According to one or more embodiments of the present disclosure, Example 1 provides a vector retrieval method, including:
[0155] Obtaining a target vector and a target key to be retrieved, wherein the target key includes a target random number and a target orthogonal matrix;
[0156] Performing a linear transformation on the target vector using the target random number;
[0157] Using the target orthogonal matrix, a rotation operation is performed on the target vector obtained after the linear transformation to obtain a first ciphertext vector;
[0158] The first ciphertext vector is sent to a first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from a knowledge vector library; wherein the ciphertext vectors in the knowledge vector library are generated based on the target key and a reference vector, and the generation method is the same as the generation method of the first ciphertext vector.
[0159] According to one or more embodiments of the present disclosure, Example 2 provides the method of Example 1, wherein the target key further includes a first bit string of a first preset length;
[0160] Before the step of performing a rotation operation on the target vector obtained after the linear transformation using the target orthogonal matrix, the method further includes:
[0161] Randomly generating a second bit string of a second preset length;
[0162] Using the first bit string as a key of a preset pseudo-random function and using the second bit string as an input of the preset pseudo-random function to obtain a third bit string;
[0163] Generate Gaussian noise according to the third bit string, a preset approximation factor and the target random number;
[0164] Using the Gaussian noise to perform noise processing on the target vector obtained after the linear transformation to obtain a noise vector;
[0165] The step of performing a rotation operation on the target vector obtained after the linear transformation by using the target orthogonal matrix comprises:
[0166] The noise vector is rotated using the target orthogonal matrix.
[0167] According to one or more embodiments of the present disclosure, Example 3 provides the method of Example 2, wherein generating Gaussian noise according to the third bit string, a preset approximation factor, and the target random number includes:
[0168] Based on a preset splitting rule, splitting the third bit string into a fourth bit string and a fifth bit string;
[0169] Using the fourth bit string, a Gaussian vector of dimension d that conforms to a standard normal distribution is generated, and using the fifth bit string, a pseudo-random number that conforms to a (0, 1) uniform distribution is generated, wherein d is the dimension of the target vector and d is a natural number greater than 0;
[0170] Gaussian noise is generated by using the Gaussian vector, the pseudo-random number, a preset approximation factor and the target random number.
[0171] According to one or more embodiments of the present disclosure, Example 4 provides the method of Example 3, wherein the step of generating Gaussian noise by using the Gaussian vector, the pseudo-random number, a preset approximation factor, and the target random number includes:
[0172] The Gaussian noise is generated by using the Gaussian vector, the pseudo-random number, the preset approximation factor and the target random number through the following formula:
[0173]
[0174] Among them, λ m is the Gaussian noise; γ is the scaling factor; β is the preset approximation factor; s is the target random number; x′ is the pseudo-random number; u is the Gaussian vector; ||u|| is the bi-norm of the Gaussian vector.
[0175] According to one or more embodiments of the present disclosure, Example 5 provides the method of any one of Examples 1-4, wherein the target key further includes a masking vector;
[0176] Before the step of sending the first ciphertext vector to the first server, the method further includes:
[0177] Using the masking vector to mask the first ciphertext vector;
[0178] The sending the first ciphertext vector to a first server so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from a knowledge vector library includes:
[0179] The first ciphertext vector obtained after the masking process is sent to the first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector obtained after the masking process from the knowledge vector library.
[0180] According to one or more embodiments of the present disclosure, Example 6 provides the method of Example 1, wherein the method further includes:
[0181] In response to receiving the at least one second ciphertext vector sent by the first server, decrypting the at least one second ciphertext vector using the target key.
[0182] According to one or more embodiments of the present disclosure, Example 7 provides the method of Example 6, wherein decrypting the at least one second ciphertext vector using the target key includes:
[0183] For each of the second ciphertext vectors, use the transposed matrix of the target orthogonal matrix to perform a rotation operation on the second ciphertext vector to obtain a third ciphertext vector;
[0184] The third ciphertext vector is linearly transformed using the reciprocal of the target random number to obtain a plaintext vector corresponding to the second ciphertext vector.
[0185] According to one or more embodiments of the present disclosure, Example 8 provides a method of any one of Examples 1-4, wherein the method is applied to a client;
[0186] The step of obtaining the target vector to be retrieved includes:
[0187] In response to receiving text corresponding to the input request, encoding the text to obtain the target vector;
[0188] The sending the first ciphertext vector to a first server so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from a knowledge vector library includes:
[0189] Sending the first ciphertext vector to a first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from a knowledge vector library, obtains a ciphertext text corresponding to at least one second ciphertext vector, and sends the at least one second ciphertext vector and the at least one ciphertext text to the client;
[0190] The method further comprises:
[0191] In response to receiving at least one of the ciphertext texts sent by the first server, sending the text and at least one of the ciphertext texts to the large language model server, so that the large language model server generates a response text of the text using at least one of the ciphertext texts as prompt information, and sends the response text to the client;
[0192] Receive and display the response text sent by the large language model server.
[0193] According to one or more embodiments of the present disclosure, Example 9 provides a vector retrieval device, including:
[0194] An acquisition module, used for acquiring a target vector and a target key to be retrieved, wherein the target key includes a target random number and a target orthogonal matrix;
[0195] A linear transformation module, used for performing a linear transformation on the target vector using the target random number;
[0196] A rotation module, used to use the target orthogonal matrix to perform a rotation operation on the target vector obtained after the linear transformation to obtain a first ciphertext vector;
[0197] A first sending module is used to send the first ciphertext vector to a first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from a knowledge vector library; wherein the ciphertext vector included in the knowledge vector library is generated based on the target key and the reference vector, and the generation method is the same as the generation method of the first ciphertext vector.
[0198] According to one or more embodiments of the present disclosure, Example 10 provides a computer-readable medium having a computer program stored thereon, and when the computer program is executed by a processing device, the steps of the method described in any one of Examples 1-8 are implemented.
[0199] According to one or more embodiments of the present disclosure, Example 11 provides an electronic device, including:
[0200] a storage device having a computer program stored thereon;
[0201] A processing device is used to execute the computer program in the storage device to implement the steps of any one of the methods described in Examples 1-8.
[0202] According to one or more embodiments of the present disclosure, Example 12 provides a computer program product, including a computer program, which implements the steps of any one of the methods of Examples 1 to 8 when executed by a processor.
[0203] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0204] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0205] Although the subject matter has been described in language specific to structural features and / or method logic actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims. Regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Claims
1. A vector retrieval method, characterized in that: include: Obtaining a target vector and a target key to be retrieved, wherein the target key includes a target random number and a target orthogonal matrix; Performing a linear transformation on the target vector using the target random number; Using the target orthogonal matrix, a rotation operation is performed on the target vector obtained after the linear transformation to obtain a first ciphertext vector; The first ciphertext vector is sent to a first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from a knowledge vector library; wherein the ciphertext vectors in the knowledge vector library are generated based on the target key and a reference vector, and the generation method is the same as the generation method of the first ciphertext vector.
2. The method according to claim 1, characterized in that The target key also includes a first bit string of a first preset length; Before the step of performing a rotation operation on the target vector obtained after the linear transformation using the target orthogonal matrix, the method further includes: Randomly generating a second bit string of a second preset length; Using the first bit string as a key of a preset pseudo-random function and using the second bit string as an input of the preset pseudo-random function to obtain a third bit string; Generate Gaussian noise according to the third bit string, a preset approximation factor and the target random number; Using the Gaussian noise to perform noise processing on the target vector obtained after the linear transformation to obtain a noise vector; The step of performing a rotation operation on the target vector obtained after the linear transformation by using the target orthogonal matrix comprises: The noise vector is rotated using the target orthogonal matrix.
3. The method according to claim 2, characterized in that The step of generating Gaussian noise according to the third bit string, a preset approximation factor and the target random number includes: Based on a preset splitting rule, splitting the third bit string into a fourth bit string and a fifth bit string; Using the fourth bit string, a Gaussian vector of dimension d that conforms to a standard normal distribution is generated, and using the fifth bit string, a pseudo-random number that conforms to a (0, 1) uniform distribution is generated, wherein d is the dimension of the target vector and d is a natural number greater than 0; Gaussian noise is generated by using the Gaussian vector, the pseudo-random number, a preset approximation factor and the target random number.
4. The method according to claim 3, characterized in that The step of generating Gaussian noise by using the Gaussian vector, the pseudo-random number, a preset approximation factor and the target random number includes: The Gaussian noise is generated by using the Gaussian vector, the pseudo-random number, the preset approximation factor and the target random number through the following formula: Among them, λ m is the Gaussian noise; γ is the scaling factor; β is the preset approximation factor; s is the target random number; x′ is the pseudo-random number; u is the Gaussian vector; ||u|| is the bi-norm of the Gaussian vector.
5. The method according to any one of claims 1 to 4, characterized in that The target key also includes a masking vector; Before the step of sending the first ciphertext vector to the first server, the method further includes: Using the masking vector to mask the first ciphertext vector; The sending the first ciphertext vector to a first server so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from a knowledge vector library includes: The first ciphertext vector obtained after the masking process is sent to the first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector obtained after the masking process from the knowledge vector library.
6. The method according to claim 1, characterized in that The method further comprises: In response to receiving the at least one second ciphertext vector sent by the first server, decrypting the at least one second ciphertext vector using the target key.
7. The method according to claim 6, characterized in that The decrypting the at least one second ciphertext vector by using the target key includes: For each of the second ciphertext vectors, use the transposed matrix of the target orthogonal matrix to perform a rotation operation on the second ciphertext vector to obtain a third ciphertext vector; The third ciphertext vector is linearly transformed using the reciprocal of the target random number to obtain a plaintext vector corresponding to the second ciphertext vector.
8. The method according to any one of claims 1 to 4, characterized in that The method is applied to the client; The step of obtaining the target vector to be retrieved includes: In response to receiving text corresponding to the input request, encoding the text to obtain the target vector; The sending the first ciphertext vector to a first server so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from a knowledge vector library includes: Sending the first ciphertext vector to a first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from a knowledge vector library, obtains a ciphertext text corresponding to at least one second ciphertext vector, and sends the at least one second ciphertext vector and the at least one ciphertext text to the client; The method further comprises: In response to receiving at least one of the ciphertext texts sent by the first server, sending the text and at least one of the ciphertext texts to the large language model server, so that the large language model server generates a response text of the text using at least one of the ciphertext texts as prompt information, and sends the response text to the client; Receive and display the response text sent by the large language model server.
9. A vector search device, characterized in that: include: An acquisition module, used for acquiring a target vector and a target key to be retrieved, wherein the target key includes a target random number and a target orthogonal matrix; A linear transformation module, used for performing a linear transformation on the target vector using the target random number; A rotation module, used to use the target orthogonal matrix to perform a rotation operation on the target vector obtained after the linear transformation to obtain a first ciphertext vector; A first sending module is used to send the first ciphertext vector to a first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from a knowledge vector library; wherein the ciphertext vector in the knowledge vector library is generated based on the target key and the reference vector, and the generation method is the same as the generation method of the first ciphertext vector.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processing device, the steps of the method according to any one of claims 1 to 8 are implemented.
11. An electronic device, characterized in that: include: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 8.
12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.