Vector retrieval method and device based on reversible matrix, medium, equipment and product

By using invertible matrices for encryption and transformation in vector retrieval, the problem of anti-solving of vector library embedding in the prior art is solved, and the effect of preventing privacy leakage in vector retrieval is achieved.

CN119441458APending Publication Date: 2025-02-14BEIJING VOLCANO ENGINE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411472707.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-21
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

The prior art cannot effectively protect embedding in the knowledge vector library while supporting vector retrieval, resulting in attackers being able to counter-solve plaintext through vec2text attacks and leaking user privacy.

Method used

The vector search method based on the inverse matrix is ​​adopted to perform linear transformation of the target vector through the target random number, and the transformed vector is encrypted using the inverse matrix of the target inverse matrix to generate the first ciphertext vector. Then, the ciphertext vector is sent to the server for similarity search, ensuring that the similarity of the encrypted vector is close to the similarity of the original plaintext vector.

Benefits of technology

Under the premise of support vector retrieval, it effectively resists vec2text attacks, prevents user privacy leakage, and keeps the recall rate basically unchanged.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119441458A_ABST
    Figure CN119441458A_ABST
Patent Text Reader

Abstract

The invention discloses a vector retrieval method and device based on a reversible matrix, a medium, equipment and a product. The method comprises the following steps: acquiring a to-be-retrieved target vector and a target key (a target random number and a target reversible matrix); performing linear transformation on the target vector by using the target random number; encrypting a target vector obtained after linear transformation by using an inverse matrix of the target reversible matrix to obtain a first ciphertext vector; sending the first ciphertext vector to a first server, so that the first server retrieves a second ciphertext vector similar to the first ciphertext vector from a knowledge vector library; the ciphertext vector in the knowledge vector library is obtained by performing linear transformation on a reference vector by using the target random number and encrypting the reference vector obtained after the linear transformation by using a transpose matrix of the target reversible matrix. According to the method, information of an original plaintext vector can be masked in the transverse direction and the longitudinal direction, under the premise of supporting vector retrieval, the vec2text attack in a language model service scene is resisted, and user privacy leakage is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular, to a vector retrieval method, device, medium, equipment and product based on a reversible matrix. 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 based on a reversible matrix, 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 reversible matrix;

[0007] Performing a linear transformation on the target vector using the target random number;

[0008] Encrypting the target vector obtained after the linear transformation using the inverse matrix of the target reversible matrix 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 vector in the knowledge vector library is obtained by linearly transforming a reference vector using the target random number and encrypting the reference vector obtained after the linear transformation using the transpose matrix of the target reversible matrix.

[0010] In a second aspect, the present disclosure provides a vector retrieval device based on a reversible matrix, 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 reversible matrix;

[0012] A first linear transformation module, used for performing a linear transformation on the target vector using the target random number;

[0013] An encryption module, used to encrypt the target vector obtained after the linear transformation by using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector;

[0014] The 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 obtained by linearly transforming a reference vector using the target random number and encrypting the reference vector obtained after the linear transformation using the transpose matrix of the target reversible matrix.

[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 reversible matrix-based 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 reversible matrix-based 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 reversible matrix-based 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 encrypted using the inverse matrix of the target reversible 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 obtained by linearly transforming the reference vector using the target random number and encrypting the reference vector obtained after the linear transformation using the transpose matrix of the target reversible matrix. The reference vector obtained after the linear transformation is encrypted using the transpose matrix of the target reversible matrix, and correspondingly, the target vector obtained after the linear transformation is encrypted using the inverse matrix of the target reversible matrix, so that the distance between the first ciphertext vector obtained after encryption and the second ciphertext vector is close to the distance between the original plaintext vectors, so as to approximately maintain the distance between the plaintext vectors, so as to 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 the correlation matrix of the target random number and the target reversible matrix, which can mask the information of the original plaintext vector from both the horizontal (linear transformation) and vertical (correlation matrix of the reversible 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 2This is a schematic diagram of the vec2text attack in the related art.

[0025] Figure 3 The present invention is a flowchart of a vector search method based on a reversible matrix according to an exemplary embodiment.

[0026] Figure 4 is a schematic diagram of a vec2text attack according to an exemplary embodiment.

[0027] Figure 5 The figure is a flow chart showing a vector search method based on a reversible matrix according to another exemplary embodiment.

[0028] Figure 6 is a flowchart of a vector retrieval method based on a reversible matrix according to yet another exemplary embodiment.

[0029] Figure 7 It is a block diagram of a vector retrieval device based on a reversible matrix 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 showing a vector search method based on a reversible matrix according to an exemplary embodiment. Figure 3 As shown, the vector retrieval method based on the reversible matrix 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 reversible matrix.

[0044] In the present disclosure, the above-mentioned vector retrieval method based on a reversible matrix can be applied to a client. For a question-and-answer scenario, a user can input a request to a client, and in response to receiving the input request, the client can encode the text corresponding to the input request to obtain a target vector to be retrieved. The target key can be pre-generated by the client, for example, a random number is pre-generated as a target random number, and a d×d reversible matrix or a (d+1)×(d+1) reversible matrix is ​​randomly generated as a target reversible matrix, where d is the dimension of the target vector, and d is a natural number greater than 0, and the target vector is a d-dimensional column vector.

[0045] In S102, a target vector is linearly transformed using a target random number.

[0046] For example, the target vector obtained after linear transformation is Among them, s is the target random number and m is the target vector.

[0047] In S103, the target vector obtained after the linear transformation is encrypted using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector.

[0048] 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, and the ciphertext vector in the knowledge vector library is obtained by linearly transforming a reference vector using a target random number and encrypting the reference vector obtained after the linear transformation using a transpose matrix of a target reversible matrix.

[0049] In the present disclosure, a knowledge vector library is stored on the first server, and the ciphertext vector in the knowledge vector library is obtained by linearly transforming a reference vector using a target random number and encrypting the reference vector obtained after the linear transformation using the transpose matrix of a target reversible matrix.

[0050] After encrypting the target vector, 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.

[0051] 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 reversible matrix, which can mask the information of the original plaintext vector from both the horizontal (linear transformation) and vertical (reversible 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.

[0052] 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 encrypted using the inverse matrix of the target reversible 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 obtained by linearly transforming the reference vector using the target random number and encrypting the reference vector obtained after the linear transformation using the transpose matrix of the target reversible matrix. The reference vector obtained after the linear transformation is encrypted using the transpose matrix of the target reversible matrix, and correspondingly, the target vector obtained after the linear transformation is encrypted using the inverse matrix of the target reversible matrix, so that the distance between the first ciphertext vector obtained after encryption and the second ciphertext vector is close to the distance between the original plaintext vectors, so as to approximately maintain the distance between the plaintext vectors, so as to 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 the correlation matrix of the target random number and the target reversible matrix, which can mask the information of the original plaintext vector from both the horizontal (linear transformation) and vertical (correlation matrix of the reversible matrix) directions. This allows us to resist vec2text attacks in language model service scenarios while supporting vector retrieval, thereby avoiding user privacy leakage.

[0053] In one implementation, the target vector search method may be fixed, and specifically, the target vector may be searched using Euclidean distance search. In this case, the knowledge vector library includes a first sub-vector library corresponding to the Euclidean distance search.

[0054] The first sub-vector library includes multiple ciphertext vectors and ciphertext text corresponding to each ciphertext vector, wherein the ciphertext vector in the first sub-vector library is obtained by the client performing linear transformation and encryption on the reference vector based on the target key (including the target random number and the target reversible matrix of (d+1)×(d+1)), the reference vector can be a vector obtained by the client after word segmentation and encoding of the text in the corpus, 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 after obtaining the ciphertext vector and the corresponding ciphertext text, the client stores them in the first sub-vector library.

[0055] Specifically, the ciphertext vector in the first sub-vector library can be obtained by following the steps (a1) to (a3):

[0056] Step (a1): Use the target random number to perform a linear transformation on the reference vector.

[0057] In the present disclosure, a similar method to the above-mentioned S102 of using a target random number to linearly transform a target vector may be used to linearly transform a reference vector using a target random number, and the present disclosure will not elaborate on this.

[0058] Step (a2): Add the element at the end of the reference vector obtained after the linear transformation The reference vector obtained after the linear transformation is expanded into a d+1-dimensional column vector to obtain a second extended vector, wherein the reference vector is a d-dimensional column vector, and the target reversible matrix is ​​a (d+1)×(d+1) reversible matrix. is the reference vector obtained after linear transformation The second norm of .

[0059] The reference vector obtained after linear transformation Add elements to the end of The reference vector obtained after linear transformation can be Expand to a d+1-dimensional column vector, thereby obtaining the second expanded vector

[0060] Step (a3): Use the transpose matrix of the target reversible matrix to perform a rotation operation on the second extended vector to obtain a ciphertext vector of the reference vector.

[0061] For example, the transposed matrix of the target reversible matrix may be used to perform a rotation operation on the second extended vector by the following equation (1) to obtain a ciphertext vector c' of the reference vector:

[0062]

[0063] Among them, Μ is the target reversible matrix; Μ Τ is the transposed matrix of the target invertible matrix.

[0064] In this implementation, the target key used when encrypting the target vector is completely consistent with the target key used when generating each ciphertext vector in the first sub-vector library.

[0065] In another embodiment, the target vector retrieval method is fixed, and specifically, cosine similarity retrieval may be used to perform vector retrieval on the target vector. In this case, the knowledge vector library includes a second sub-vector library corresponding to the cosine similarity retrieval.

[0066] The second sub-vector library includes multiple ciphertext vectors and ciphertext text corresponding to each ciphertext vector, wherein the ciphertext vector in the second sub-vector library is obtained by the client performing linear transformation and encryption on the reference vector based on the target key (including the target random number and the d×d target reversible matrix), the reference vector can be a vector obtained by the client after word segmentation and encoding of the text in the corpus, 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 AES for text encryption, and after obtaining the ciphertext vector and its corresponding ciphertext text, the client stores them in the second sub-vector library.

[0067] Specifically, the ciphertext vector in the second sub-vector library can be obtained by following the steps (b1) to (b3):

[0068] Step (b1): Normalize the reference vector.

[0069] In the present disclosure, the reference vector is normalized so that the binary norm of the normalized reference vector is equal to 1.

[0070] For example, the reference vector can be normalized by the following equation (2):

[0071] m1'=m1 / ||m1|| (2)

[0072] Among them, m1' is the reference vector obtained after normalization; m1 is the reference vector; ||m1|| is the second norm of the reference vector m1.

[0073] Step (b2): Use the target random number to perform a linear transformation on the reference vector obtained after normalization.

[0074] In the present disclosure, a similar method to the linear transformation of the target vector using the target random number in the above S102 can be adopted to linearly transform the reference vector obtained after normalization using the target random number, which will not be repeated in the present disclosure.

[0075] Step (b3): ​​Use the transpose matrix of the target reversible matrix to perform a rotation operation on the reference vector obtained after the linear transformation to obtain the ciphertext vector of the reference vector.

[0076] In the present disclosure, a rotation operation can be performed on the reference vector obtained after linear transformation using the transpose matrix of the target reversible matrix in a similar manner to the above step (a3) ​​of using the transpose matrix of the target reversible matrix to rotate the second extended vector, and this disclosure will not go into details.

[0077] In this implementation, the target key used when encrypting the target vector is completely consistent with the target key used when generating each ciphertext vector in the second sub-vector library.

[0078] In another embodiment, a variety of search methods can be provided for users to choose from to enhance the user's vector search experience. Specifically, the search request for the target vector input by the user can include the search method indicated by the user, and the dimensions of the target reversible matrix used by different search methods are different. When the search method indicated by the search request is Euclidean distance search, the target reversible matrix is ​​a (d+1)×(d+1) reversible matrix, and when the search method indicated by the search request is cosine similarity search, the target reversible matrix is ​​a d×d reversible matrix. Accordingly, a knowledge vector library is stored on the first server, and the knowledge vector library includes a first sub-vector library corresponding to Euclidean distance search and a second sub-vector library corresponding to cosine similarity search. Among them, the above steps (a1) to (a3) ​​can be used to generate the ciphertext vectors in the first sub-vector library, and the above steps (b1) to (b3) can be used to generate the ciphertext vectors in the second sub-vector library. In addition, the target random number used to generate the ciphertext vectors in the first sub-vector library can be the same as or different from the target random number used to generate the ciphertext vectors in the second sub-vector library, and the present disclosure does not make specific limitations.

[0079] In this embodiment, different target keys corresponding to different search methods are different. When searching for a target vector, the target key used to encrypt the target vector is the key corresponding to the search method, that is, obtaining the target key in the above S101 may include: obtaining the target key corresponding to the search method indicated by the search request for the target vector. That is, the target key used when encrypting the target vector is completely consistent with the target key used when generating each ciphertext vector in the sub-vector library corresponding to the search method indicated by the search request.

[0080] For example, the retrieval method indicated by the retrieval request is Euclidean distance retrieval, and the target key used to encrypt the target vector is completely consistent with the target key used when generating each ciphertext vector in the first sub-vector library; the retrieval method indicated by the retrieval request is cosine similarity retrieval, and the target key used to encrypt the target vector is completely consistent with the target key used when generating each ciphertext vector in the second sub-vector library.

[0081] The following describes in detail a specific implementation method of encrypting the target vector obtained after the linear transformation by using the inverse matrix of the target reversible matrix in the above S103 to obtain the first ciphertext vector.

[0082] In one embodiment, the target vector retrieval method may be fixed, and specifically, the target vector may be retrieved by using Euclidean distance retrieval. At this time, the target vector may be encrypted in a manner similar to the method of generating the ciphertext vector in the first sub-vector library to obtain the first ciphertext vector. Specifically, the target vector obtained after the linear transformation may be encrypted by using the inverse matrix of the target reversible matrix through the following steps (c1) and (c2):

[0083] Step (c1): Add element 1 at the end of the target vector obtained after the linear transformation to expand the target vector obtained after the linear transformation into a d+1-dimensional column vector to obtain a first extended vector, where the target reversible matrix is ​​a (d+1)×(d+1) reversible matrix.

[0084] The target vector obtained after linear transformation By adding element 1 to the end of , the target vector c obtained after the linear transformation can be expanded to a d+1-dimensional column vector, thereby obtaining the first expanded vector

[0085] Step (c2): using the inverse matrix of the target reversible matrix to perform a rotation operation on the first extended vector to obtain a first ciphertext vector.

[0086] In the present disclosure, the first extended vector can be rotated using the inverse matrix of the target reversible matrix in a manner similar to the method of using the transposed matrix of the target reversible matrix to rotate the second extended vector in the above step (a3), and this disclosure will not repeat it.

[0087] In another embodiment, the target vector is retrieved in a fixed manner, and specifically, the target vector can be retrieved by using cosine similarity retrieval. In this case, the target vector can be encrypted in a manner similar to the method of generating the ciphertext vector in the second sub-vector library to obtain the first ciphertext vector. Specifically, the target vector obtained after the linear transformation can be encrypted by using the inverse matrix of the target reversible matrix in the following manner:

[0088] The target vector obtained after the linear transformation is rotated using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector, wherein the target reversible matrix is ​​a d×d reversible matrix.

[0089] For example, the inverse matrix of the target reversible matrix can be used to perform a rotation operation on the target vector obtained after the linear transformation through the following equation (3) to obtain the first ciphertext vector c:

[0090]

[0091] Among them, -1 is the inverse matrix of the target invertible matrix.

[0092] In another embodiment, multiple search methods may be provided for the user to choose from, so as to enhance the user's vector search experience. Specifically, the above-mentioned vector search method based on the reversible matrix may also include the following steps:

[0093] In response to receiving a search request for a target vector, a search mode indicated by the search request is determined.

[0094] At this time, the above S101 can obtain the target key indicated by the search request, and the above S103 can encrypt the target vector obtained after the linear transformation using the inverse matrix of the target reversible matrix according to the search method indicated by the search request to obtain the first ciphertext vector. The search request includes the target vector and the search method indicated by it.

[0095] Specifically, if the retrieval method indicated by the retrieval request is Euclidean distance retrieval, an element 1 is added to the end of the target vector obtained after the linear transformation to expand the target vector obtained after the linear transformation to a d+1-dimensional column vector to obtain a first extended vector, where the target reversible matrix is ​​a (d+1)×(d+1) reversible matrix; then, the first extended vector is rotated using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector.

[0096] If the search method indicated by the search request is cosine similarity search, the target vector obtained after the linear transformation is rotated using the inverse matrix of the target reversible matrix to obtain the first ciphertext vector, wherein the target reversible matrix is ​​a d×d reversible matrix.

[0097] In a possible implementation, the search method indicated by the search request is Euclidean distance search or cosine similarity search, and the knowledge vector library includes a first sub-vector library corresponding to the Euclidean distance search and a second sub-vector library corresponding to the cosine similarity search. In this case, the above S104 may include: sending the first ciphertext vector and the search method indicated by the search request to the first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from the sub-vector library corresponding to the search method.

[0098] Specifically, when the retrieval method indicated by the retrieval request is Euclidean distance retrieval, the first server can retrieve at least one second ciphertext vector similar to the first ciphertext vector from the first sub-vector library; when the retrieval method indicated by the retrieval request is cosine similarity retrieval, the first server can retrieve at least one second ciphertext vector similar to the first ciphertext vector from the second sub-vector library.

[0099] In a possible implementation, when the search method indicated by the search request is a cosine similarity search, before the above S102, the vector search method based on the reversible matrix further includes the following steps:

[0100] Normalize the target vector.

[0101] At this time, the above S102 can use the target random number to perform a linear transformation on the target vector obtained after the normalization process.

[0102] In the present disclosure, the target vector is normalized so that the bi-norm of the target vector obtained after normalization is equal to 1. In addition, the target vector can be normalized in a manner similar to the normalization of the reference vector in the above step (b1), which will not be described in detail in the present disclosure.

[0103] Since the target reversible matrix is ​​fixed, if the first server obtains multiple original plaintext vectors and the ciphertext vectors corresponding to each original plaintext vector, the target reversible 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.

[0104] At this time, if Figure 5 As shown, before the above S103, the above vector search method based on the reversible matrix may further include the following S105 to S108.

[0105] In S105 , a second bit string of a second preset length is randomly generated.

[0106] In the present disclosure, the second bit string is a bit string of a second preset length consisting of 0s and 1s.

[0107] 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.

[0108] In S107 , a first Gaussian noise is generated according to the third bit string, a preset approximation factor, and a target random number.

[0109] In S108, the target vector obtained after the linear transformation is subjected to noise adding processing using the first Gaussian noise to obtain a noise vector.

[0110] For example, the first Gaussian noise may be used to perform noise processing on the target vector obtained after the linear transformation through the following equation (4) to obtain a noise vector:

[0111]

[0112] Where z is the noise vector obtained by adding noise to the target vector obtained after linear transformation; λ m is the first Gaussian noise.

[0113] At this time, the above S103 can use the inverse matrix of the target reversible matrix to encrypt the noise vector to obtain the first ciphertext vector.

[0114] In the present disclosure, the noise vector can be encrypted using the inverse matrix of the target reversible matrix in a similar manner to the above-mentioned method of encrypting the target vector obtained after linear transformation using the inverse matrix of the target reversible matrix, and the disclosure will not repeat it.

[0115] The specific implementation method of generating the first 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 (d1) to (d3):

[0116] Step (d1): based on a preset splitting rule, split the third bit string into a fourth bit string and a fifth bit string.

[0117] 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.

[0118] Step (d2): 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.

[0119] 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.

[0120] Step (d3): Generate a first Gaussian noise using a Gaussian vector, a pseudo-random number, a preset approximation factor and a target random number.

[0121] For example, the first Gaussian noise may be generated by using the Gaussian vector, a pseudo-random number, a preset approximation factor, and a target random number through the following equation (5):

[0122]

[0123] Where γ is a scaling factor, which is a real number. When the search method indicated by the search request is Euclidean distance search, the value range of γ is (0, 0.25]; when the search method indicated by the search request is cosine similarity search, the value range of γ is β is the preset approximation factor. When the search method indicated by the search request is Euclidean distance search, When the search request indicates a cosine similarity search, And β<1, the d-dimensional vector space to which the target vector belongs α=[-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.

[0124] 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.

[0125] In a possible implementation, Figure 6 As shown, the above-mentioned vector retrieval method based on the reversible matrix may include the following S201 to S208.

[0126] In S201, a target vector and a target key to be retrieved are obtained, where the target key includes a target random number, a target reversible matrix, and a first bit string of a first preset length.

[0127] In S202, a target vector is linearly transformed using a target random number.

[0128] In S203, a second bit string of a second preset length is randomly generated.

[0129] In S204, 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.

[0130] In 205 , a first Gaussian noise is generated according to the third bit string, a preset approximation factor, and a target random number.

[0131] In S206, the target vector obtained after the linear transformation is subjected to noise processing using the first Gaussian noise to obtain a noise vector.

[0132] In S207, the noise vector is encrypted using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector.

[0133] In S208, 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, and the ciphertext vector in the knowledge vector library is obtained by linearly transforming a reference vector using a target random number, noise-adding the reference vector obtained after the linear transformation using a second Gaussian noise or a third Gaussian noise, and encrypting the reference vector obtained after the noise-adding using a transpose matrix of a target reversible matrix.

[0134] At this time, the ciphertext vector in the first sub-vector library can be obtained by following the steps (e1) to (e7):

[0135] Step (e1): Use the target random number to perform a linear transformation on the reference vector.

[0136] Step (e2): randomly generating a sixth bit string of a second preset length.

[0137] Step (e3): using the first bit string as a key of a preset pseudo-random function and using the sixth bit string as an input of the preset pseudo-random function to obtain a seventh bit string.

[0138] Step (e4): Generate a second Gaussian noise according to the seventh bit string, a preset approximation factor and a target random number.

[0139] Step (e5): Use the second Gaussian noise to perform noise processing on the reference vector obtained after the linear transformation.

[0140] Step (e6): The reference vector obtained after noise addition Add elements to the end of The reference vector obtained after the noise addition process is expanded into a d+1-dimensional column vector to obtain a third extended vector, wherein the reference vector is a d-dimensional column vector, and the target reversible matrix is ​​a (d+1)×(d+1) reversible matrix. λ2 is the second Gaussian noise, is the reference vector obtained after noise processing The second norm of .

[0141] The reference vector obtained after noise processing Add elements to the end of The reference vector obtained after the noise addition process can be expanded into a column vector of d+1 dimensions, thereby obtaining a third expanded vector

[0142] Step (e7): using the transposed matrix of the target reversible matrix to perform a rotation operation on the third extended vector to obtain a ciphertext vector of the reference vector.

[0143] At this time, the ciphertext vector in the first sub-vector library can be obtained by following the steps (f1) to (f6):

[0144] Step (f1): linearly transform the reference vector using the target random number.

[0145] Step (f2): randomly generating an eighth bit string of a second preset length.

[0146] Step (f3): using the first bit string as a key of a preset pseudo-random function and using the eighth bit string as an input of the preset pseudo-random function to obtain a ninth bit string.

[0147] Step (f4): Generate a third Gaussian noise according to the ninth bit string, a preset approximation factor and a target random number.

[0148] Step (f5): Use the third Gaussian noise to perform noise processing on the reference vector obtained after the linear transformation.

[0149] Step (f6): Use the transpose matrix of the target reversible matrix to rotate the reference vector obtained after the noise addition process to obtain the ciphertext vector of the reference vector.

[0150] In a possible implementation manner, the above-mentioned vector retrieval method based on a reversible matrix may further include the following steps:

[0151] 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 according to the retrieval method indicated by the retrieval request.

[0152] In the present disclosure, the second ciphertext vector may be decrypted using the target key used when each ciphertext vector in the sub-vector library corresponding to the retrieval method indicated by the retrieval request is generated.

[0153] For example, the retrieval method indicated by the retrieval request is Euclidean distance retrieval, the target key used to decrypt the second ciphertext vector is completely consistent with the target key used when generating each ciphertext vector in the first sub-vector library, and the decryption process of the second ciphertext vector is the inverse process of the generation process of each ciphertext vector in the first sub-vector library; the retrieval method indicated by the retrieval request is cosine similarity retrieval, the target key used to decrypt the second ciphertext vector is completely consistent with the target key used when generating each ciphertext vector in the second sub-vector library, and the decryption process of the second ciphertext vector is the inverse process of the generation process of each ciphertext vector in the second sub-vector library.

[0154] In one implementation, when the target key includes a target random number and a target reversible matrix, the at least one second ciphertext vector may be decrypted using the target key in the following manner according to the retrieval method indicated by the retrieval request:

[0155] For each second ciphertext vector, first, the second ciphertext vector is rotated using the transposed matrix of the inverse matrix of the target reversible matrix to obtain a third ciphertext vector; then, different decryption strategies are adopted according to different retrieval methods indicated by the retrieval request.

[0156] Specifically, if the search method indicated by the search request is Euclidean distance search, the first d rows of the third ciphertext vector are first extracted as the fourth ciphertext vector; then, the fourth ciphertext vector is linearly transformed using the inverse of the target random number to obtain the plaintext vector corresponding to the second ciphertext vector.

[0157] If the search method indicated by the search request is cosine similarity search, the third ciphertext vector is directly linearly transformed using the reciprocal of the target random number to obtain the plaintext vector corresponding to the second ciphertext vector.

[0158] For example, when the search method indicated by the search request is Euclidean distance search, the inverse matrix M of the target reversible matrix may be used first. -1 The transposed matrix (Μ -1 ) T The second ciphertext vector c1 is rotated to obtain the third ciphertext vector (Μ -1 ) T c1; then, extract the first d rows of the third ciphertext vector as the fourth ciphertext vector c2; finally, use the inverse of the target random number Perform a linear transformation on the fourth ciphertext vector c2 to obtain the plaintext vector corresponding to the second ciphertext vector

[0159] For example, when the search method indicated by the search request is cosine similarity search, the inverse matrix M of the target reversible matrix can be used first. -1 The transposed matrix (Μ-1 ) T The second ciphertext vector c1 is rotated to obtain the third ciphertext vector (Μ -1 ) T c1, then, using the inverse of the target random number For the third ciphertext vector (Μ -1 ) T c1 performs a linear transformation to obtain the plaintext vector corresponding to the second ciphertext vector

[0160] In another implementation, when the target key includes a target random number, a target reversible matrix, and a first bit string, the at least one second ciphertext vector may be decrypted using the target key in the following manner according to the retrieval method indicated by the retrieval request:

[0161] For each second ciphertext vector, first, the second ciphertext vector is rotated using the transposed matrix of the inverse matrix of the target reversible matrix to obtain a third ciphertext vector; then, different decryption strategies are adopted according to different retrieval methods indicated by the retrieval request.

[0162] Specifically, if the retrieval method indicated by the retrieval request is Euclidean distance retrieval, the first d rows of the third ciphertext vector are first extracted as the fourth ciphertext vector; then, the second Gaussian noise is removed from the fourth ciphertext vector to obtain the fifth ciphertext vector; next, the fifth ciphertext vector is linearly transformed using the inverse of the target random number to obtain the plaintext vector corresponding to the second ciphertext vector.

[0163] If the retrieval method indicated by the retrieval request is cosine similarity retrieval, the third Gaussian noise is directly removed from the third ciphertext vector to obtain the sixth ciphertext vector, and then the sixth ciphertext vector is linearly transformed using the inverse of the target random number to obtain the plaintext vector corresponding to the second ciphertext vector.

[0164] For example, when the search method indicated by the search request is Euclidean distance search, the inverse matrix M of the target reversible matrix may be used first. -1 The transposed matrix (Μ -1 ) T The second ciphertext vector c1 is rotated to obtain the third ciphertext vector (Μ -1 ) T c1; then, extract the first d rows of the third ciphertext vector as the fourth ciphertext vector c2; next, remove the second Gaussian noise λ2 from the fourth ciphertext vector c2 to obtain the fifth ciphertext vector c2-λ2; finally, use the inverse of the target random number Perform a linear transformation on the fifth ciphertext vector c2-λ2 to obtain the plaintext vector corresponding to the second ciphertext vector

[0165] For example, when the search method indicated by the search request is cosine similarity search, the inverse matrix M of the target reversible matrix can be used first. -1 The transposed matrix (Μ -1 ) T The second ciphertext vector c1 is rotated to obtain the third ciphertext vector (Μ -1 ) T c1, then, from the third ciphertext vector (Μ -1 ) T · Remove the third Gaussian noise λ3 from c1 to obtain the sixth ciphertext vector (Μ -1 ) T c1-λ3; Finally, use the inverse of the target random number Perform a linear transformation on the sixth ciphertext vector to obtain the plaintext vector corresponding to the second ciphertext vector

[0166] When the search method indicated by the search request is Euclidean distance search, the Euclidean distance search of the plaintext can be approximately converted into the inner product search of the ciphertext. Assuming that x and z are two plaintext vectors in the first sub-vector library, and satisfy ||xm||<||zm||-β, and the value range of γ is (0,0.25], it can be proved that the inner product Among them, ||xm|| represents the Euclidean distance between x and m, ||zm|| represents the Euclidean distance between z and m, The ciphertext vector c of x x The transposed vector of The ciphertext vector c of z z The transposed vector of Characterization The inner product with c, Characterization The inner product of .

[0167] When the search method indicated by the search request is cosine similarity search, the cosine similarity search of the plaintext can be approximately converted into the inner product search of the ciphertext. Assume that p and q are two plaintext vectors in the second sub-vector library and satisfy cos(p,m)<cos(q,m)-β, and the value range of γ is It can be proved that the inner product in, is the ciphertext vector of p The transposed vector of The ciphertext vector c of q q The transposed vector of , cos(p,m) represents the cosine similarity between p and m, and cos(q,m) represents the cosine similarity between q and m. Characterization The inner product with c, Characterization The inner product of .

[0168] When the above-mentioned vector retrieval method based on a reversible matrix 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 based on a reversible matrix may also include the following two steps:

[0169] 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;

[0170] Receive and display the response text sent by the large language model server.

[0171] 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.

[0172] 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.

[0173] Figure 7 FIG. 1 is a block diagram of a vector search device based on a reversible matrix according to an exemplary embodiment. Figure 7 As shown, the vector search device 300 based on the reversible matrix includes:

[0174] An acquisition module 301 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 reversible matrix;

[0175] A first linear transformation module 302, configured to perform a linear transformation on the target vector using the target random number;

[0176] An encryption module 303 is used to encrypt the target vector obtained after the linear transformation by using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector;

[0177] The first sending module 304 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 a knowledge vector library; wherein the ciphertext vector in the knowledge vector library is obtained by linearly transforming a reference vector using the target random number and encrypting the reference vector obtained after the linear transformation using the transpose matrix of the target reversible matrix.

[0178] 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 encrypted using the inverse matrix of the target reversible 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 obtained by linearly transforming the reference vector using the target random number and encrypting the reference vector obtained after the linear transformation using the transpose matrix of the target reversible matrix. The reference vector obtained after the linear transformation is encrypted using the transpose matrix of the target reversible matrix, and correspondingly, the target vector obtained after the linear transformation is encrypted using the inverse matrix of the target reversible matrix, so that the distance between the first ciphertext vector obtained after encryption and the second ciphertext vector is close to the distance between the original plaintext vectors, so as to approximately maintain the distance between the plaintext vectors, so as to 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 the correlation matrix of the target random number and the target reversible matrix, which can mask the information of the original plaintext vector from both the horizontal (linear transformation) and vertical (correlation matrix of the reversible matrix) directions. This allows us to resist vec2text attacks in language model service scenarios while supporting vector retrieval, thereby avoiding user privacy leakage.

[0179] Optionally, the target key further includes a first bit string of a first preset length;

[0180] The reversible matrix-based vector search device 300 further includes:

[0181] A first generating module, configured to randomly generate a second bit string of a second preset length before the encryption module 303 encrypts the target vector obtained after the linear transformation using the inverse matrix of the target reversible matrix to obtain the first ciphertext vector;

[0182] 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;

[0183] A third generating module, configured to generate a first Gaussian noise according to the third bit string, a preset approximation factor and the target random number;

[0184] A noise adding module, used for performing noise adding processing on the target vector obtained after the linear transformation by using the first Gaussian noise to obtain a noise vector;

[0185] The encryption module 303 is used to encrypt the noise vector using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector.

[0186] Optionally, the third generating module includes:

[0187] 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;

[0188] 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;

[0189] The second generating submodule is used to generate a first Gaussian noise by using the Gaussian vector, the pseudo-random number, a preset approximation factor and the target random number.

[0190] Optionally, the second generating submodule is used to generate a first Gaussian noise by using the Gaussian vector, the pseudo-random number, a preset approximation factor and the target random number through the following formula:

[0191]

[0192] Among them, λ m is the first 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 second norm of the Gaussian vector.

[0193] Optionally, the reversible matrix-based vector search device 300 further includes:

[0194] a determination module, configured to, in response to receiving a search request for the target vector, determine a search mode indicated by the search request;

[0195] The acquisition module 301 is used to acquire the target key corresponding to the retrieval method;

[0196] The encryption module 303 is used to encrypt the target vector obtained after the linear transformation using the inverse matrix of the target reversible matrix according to the retrieval method to obtain a first ciphertext vector.

[0197] Optionally, the encryption module 303 includes:

[0198] An adding submodule, for adding an element 1 at the end of the target vector obtained after the linear transformation if the search method is a Euclidean distance search, so as to expand the target vector obtained after the linear transformation into a d+1-dimensional column vector to obtain a first extended vector, wherein the target vector is a d-dimensional column vector, and the target reversible matrix is ​​a (d+1)×(d+1) reversible matrix;

[0199] The first rotation submodule is used to perform a rotation operation on the first extended vector using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector.

[0200] Optionally, the encryption module 303 further includes:

[0201] The second rotation submodule is used to rotate the target vector obtained after linear transformation using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector if the retrieval method is cosine similarity retrieval, and the target reversible matrix is ​​a d×d reversible matrix.

[0202] Optionally, the search method is Euclidean distance search or cosine similarity search, and the knowledge vector library includes a first sub-vector library corresponding to the Euclidean distance search and a second sub-vector library corresponding to the cosine similarity search;

[0203] The first sending module 304 is used to send the first ciphertext vector and the retrieval method to the first server, so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from the sub-vector library corresponding to the retrieval method.

[0204] Optionally, the ciphertext vectors in the first sub-vector library are constructed by a first sub-vector library construction device, wherein the first sub-vector library construction device includes:

[0205] A second linear transformation module, used to perform a linear transformation on the reference vector using the target random number;

[0206] Add module, used to add elements to the end of the reference vector obtained after linear transformation The reference vector obtained after the linear transformation is expanded into a d+1-dimensional column vector to obtain a second extended vector, wherein the reference vector is a d-dimensional column vector, and the target reversible matrix is ​​a (d+1)×(d+1) reversible matrix. is the bi-norm of the reference vector c' obtained after the linear transformation;

[0207] The first rotation module is used to perform a rotation operation on the second extended vector using the transposed matrix of the target reversible matrix to obtain a ciphertext vector of the reference vector.

[0208] Optionally, the second ciphertext vector in the second sub-vector library is obtained by a second sub-vector library construction device, wherein the second sub-vector library construction device includes:

[0209] A first normalization module, used for performing normalization processing on the reference vector;

[0210] A third linear transformation module, used for performing a linear transformation on the reference vector obtained after the normalization process using the target random number;

[0211] The second rotation module is used to use the transposed matrix of the target reversible matrix to perform a rotation operation on the reference vector obtained after the linear transformation to obtain a ciphertext vector of the reference vector.

[0212] Optionally, when the retrieval method is the cosine similarity retrieval, the reversible matrix-based vector retrieval device 300 further includes:

[0213] a second normalization module, configured to perform normalization processing on the target vector before the first linear transformation module 302 uses the target random number to perform linear transformation on the target vector;

[0214] The first linear transformation module 302 is used to use the target random number to perform a linear transformation on the target vector obtained after the normalization process.

[0215] Optionally, the reversible matrix-based vector search device 300 further includes:

[0216] 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 according to the retrieval method.

[0217] Optionally, the decryption module includes:

[0218] A third rotation submodule is used to perform a rotation operation on each of the second ciphertext vectors using a transposed matrix of the inverse matrix of the target reversible matrix to obtain a third ciphertext vector;

[0219] An extraction submodule is used to extract the first d rows of the third ciphertext vector as the fourth ciphertext vector if the retrieval method is Euclidean distance retrieval; a first linear transformation submodule is used to perform a linear transformation on the fourth ciphertext vector using the inverse of the target random number to obtain a plaintext vector corresponding to the second ciphertext vector.

[0220] Optionally, the decryption module further includes:

[0221] The second 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 if the retrieval method is a cosine similarity retrieval.

[0222] Optionally, the reversible matrix-based vector retrieval device 300 is applied to a client;

[0223] The acquisition module 301 is used for encoding the text corresponding to the input request in response to receiving the text to obtain the target vector;

[0224] The first sending module 304 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 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;

[0225] The reversible matrix-based vector search device 300 further includes:

[0226] 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;

[0227] A receiving module is used to receive and display the response text sent by the large language model server.

[0228] 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 based on a reversible matrix provided by the present disclosure are implemented.

[0229] In addition, the present disclosure also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the above-mentioned reversible matrix-based vector retrieval method provided by the present disclosure.

[0230] 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.

[0231] 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.

[0232] 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.

[0233] 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.

[0234] 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.

[0235] 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.

[0236] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0237] 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 reversible matrix; performs a linear transformation on the target vector using the target random number; encrypts the target vector obtained after the linear transformation using the inverse matrix of the target reversible 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 vector in the knowledge vector library is obtained by performing a linear transformation on a reference vector using the target random number and encrypting the reference vector obtained after the linear transformation using the transposed matrix of the target reversible matrix.

[0238] 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).

[0239] 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.

[0240] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of the module does not limit the module itself in some cases. For example, the acquisition module may also be described as a "module for acquiring a target key corresponding to the retrieval method".

[0241] 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.

[0242] 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.

[0243] According to one or more embodiments of the present disclosure, Example 1 provides a vector retrieval method based on a reversible matrix, including: obtaining a target vector and a target key to be retrieved, wherein the target key includes a target random number and a target reversible matrix; performing a linear transformation on the target vector using the target random number; encrypting the target vector obtained after the linear transformation using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector; 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; wherein the ciphertext vector in the knowledge vector library is obtained by performing a linear transformation on a reference vector using the target random number and encrypting the reference vector obtained after the linear transformation using the transpose matrix of the target reversible matrix.

[0244] According to one or more embodiments of the present disclosure, Example 2 provides the method of Example 1, which further includes: in response to receiving a retrieval request for the target vector, determining a retrieval method indicated by the retrieval request; obtaining a target key, including: obtaining a target key corresponding to the retrieval method; encrypting the target vector obtained after linear transformation using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector, including: according to the retrieval method, encrypting the target vector obtained after linear transformation using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector.

[0245] According to one or more embodiments of the present disclosure, Example 3 provides the method of Example 2, which, according to the retrieval method, uses the inverse matrix of the target reversible matrix to encrypt the target vector obtained after the linear transformation to obtain a first ciphertext vector, including: if the retrieval method is Euclidean distance retrieval, then add element 1 to the end of the target vector obtained after the linear transformation to expand the target vector obtained after the linear transformation to a d+1-dimensional column vector to obtain a first extended vector, wherein the target vector is a d-dimensional column vector and the target reversible matrix is ​​a (d+1)×(d+1) reversible matrix; use the inverse matrix of the target reversible matrix to perform a rotation operation on the first extended vector to obtain a first ciphertext vector.

[0246] According to one or more embodiments of the present disclosure, Example 4 provides the method of Example 3, wherein according to the retrieval method, the target vector obtained after the linear transformation is encrypted using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector, and further includes: if the retrieval method is cosine similarity retrieval, the target vector obtained after the linear transformation is rotated using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector, and the target reversible matrix is ​​a d×d reversible matrix.

[0247] According to one or more embodiments of the present disclosure, Example 5 provides the method of Example 2, wherein the retrieval method is Euclidean distance retrieval or cosine similarity retrieval, and the knowledge vector library includes a first sub-vector library corresponding to the Euclidean distance retrieval and a second sub-vector library corresponding to the cosine similarity retrieval; 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, includes: sending the first ciphertext vector and the retrieval method to the first server so that the first server retrieves at least one second ciphertext vector similar to the first ciphertext vector from the sub-vector library corresponding to the retrieval method.

[0248] According to one or more embodiments of the present disclosure, Example 6 provides the method of Example 5, wherein the ciphertext vector in the first sub-vector library is obtained by: performing a linear transformation on the reference vector using the target random number; adding an element at the end of the reference vector obtained after the linear transformation. The reference vector obtained after the linear transformation is expanded into a d+1-dimensional column vector to obtain a second extended vector, wherein the reference vector is a d-dimensional column vector, and the target reversible matrix is ​​a (d+1)×(d+1) reversible matrix. is the reference vector obtained after the linear transformation The second norm of the reference vector is obtained by rotating the second extended vector using the transposed matrix of the target reversible matrix.

[0249] According to one or more embodiments of the present disclosure, Example 7 provides the method of Example 5, and the second ciphertext vector in the second sub-vector library is obtained in the following manner: normalizing the reference vector; performing a linear transformation on the reference vector obtained after the normalization using the target random number; and performing a rotation operation on the reference vector obtained after the linear transformation using the transpose matrix of the target reversible matrix to obtain a ciphertext vector of the reference vector.

[0250] According to one or more embodiments of the present disclosure, Example 8 provides the method of Example 5, and when the retrieval method is the cosine similarity retrieval, before the step of linearly transforming the target vector using the target random number, the method also includes: normalizing the target vector; the step of linearly transforming the target vector using the target random number includes: linearly transforming the target vector obtained after normalization using the target random number.

[0251] According to one or more embodiments of the present disclosure, Example 9 provides a method of any one of Examples 2-8, wherein the method further includes: 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 according to the retrieval method.

[0252] According to one or more embodiments of the present disclosure, Example 10 provides the method of Example 9, which decrypts the at least one second ciphertext vector using the target key according to the retrieval method, including: for each of the second ciphertext vectors, using the transpose matrix of the inverse matrix of the target reversible matrix to perform a rotation operation on the second ciphertext vector to obtain a third ciphertext vector; if the retrieval method is Euclidean distance retrieval, extracting the first d rows of the third ciphertext vector as a fourth ciphertext vector; using the inverse of the target random number to perform a linear transformation on the fourth ciphertext vector to obtain a plaintext vector corresponding to the second ciphertext vector.

[0253] According to one or more embodiments of the present disclosure, Example 11 provides the method of Example 10, wherein according to the retrieval method, the at least one second ciphertext vector is decrypted using the target key, and further includes: if the retrieval method is cosine similarity retrieval, 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.

[0254] According to one or more embodiments of the present disclosure, Example 12 provides the method of Example 1, wherein the target key also includes a first bit string of a first preset length; before the step of encrypting the target vector obtained after the linear transformation using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector, the method also includes: randomly generating a second bit string of a second preset length; using the first bit string as the key of a preset pseudo-random function, and using the second bit string as the input of the preset pseudo-random function to obtain a third bit string; generating a first Gaussian noise according to the third bit string, a preset approximation factor and the target random number; performing noise processing on the target vector obtained after the linear transformation using the first Gaussian noise to obtain a noise vector; encrypting the target vector obtained after the linear transformation using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector includes: encrypting the noise vector using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector.

[0255] According to one or more embodiments of the present disclosure, Example 13 provides the method of Example 12, which generates a first Gaussian noise based on the third bit string, a preset approximation factor and the target random number, including: splitting the third bit string into a fourth bit string and a fifth bit string based on a preset splitting rule; using the fourth bit string to generate a d-dimensional Gaussian vector that conforms to a standard normal distribution, and using the fifth bit string to generate a pseudo-random number that conforms to a (0, 1) uniform distribution, wherein d is the dimension of the target vector and d is a natural number greater than 0; using the Gaussian vector, the pseudo-random number, a preset approximation factor and the target random number to generate a first Gaussian noise.

[0256] According to one or more embodiments of the present disclosure, Example 14 provides the method of Example 13, wherein the step of generating a first Gaussian noise using the Gaussian vector, the pseudo-random number, the preset approximation factor, and the target random number comprises: generating the first Gaussian noise using the Gaussian vector, the pseudo-random number, the preset approximation factor, and the target random number by the following formula:

[0257]

[0258] Among them, λ m is the first 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 second norm of the Gaussian vector.

[0259] According to one or more embodiments of the present disclosure, Example 15 provides the method of Example 1, which is applied to a client; the obtaining of the target vector to be retrieved includes: in response to receiving text corresponding to an input request, encoding the text to obtain the target vector; the sending of 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 a knowledge vector library, includes: 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, and obtains a ciphertext text corresponding to at least one second ciphertext vector, and sends the at least one second ciphertext vector and at least one ciphertext text to the client; the method also includes: in response to receiving at least one ciphertext text sent by the first server, sending the text and at least one ciphertext text to a large language model server, so that the large language model server generates a response text of the text with at least one ciphertext text as prompt information, and sends the response text to the client; receiving and displaying the response text sent by the large language model server.

[0260] According to one or more embodiments of the present disclosure, Example 16 provides a vector retrieval device based on a reversible matrix, comprising: an acquisition module, 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 reversible matrix; a linear transformation module, used to perform a linear transformation on the target vector using the target random number; an encryption module, used to encrypt the target vector obtained after the linear transformation using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector; a first sending module, 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 obtained by performing a linear transformation on a reference vector using the target random number and encrypting the reference vector obtained after the linear transformation using the transpose matrix of the target reversible matrix.

[0261] According to one or more embodiments of the present disclosure, Example 17 provides a computer-readable medium having a computer program stored thereon, which implements the steps of any of the methods described in Examples 1-15 when executed by a processing device.

[0262] According to one or more embodiments of the present disclosure, Example 18 provides an electronic device, comprising: a storage device on which a computer program is stored; and a processing device for executing the computer program in the storage device to implement the steps of any one of the methods described in Examples 1-15.

[0263] According to one or more embodiments of the present disclosure, Example 19 provides a computer program product, including a computer program, which implements the steps of any one of the methods of Examples 1-15 when executed by a processor.

[0264] 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.

[0265] 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.

[0266] 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 based on a reversible matrix, characterized in that: include: Acquire a target vector and a target key to be retrieved, wherein the target key includes a target random number and a target reversible matrix; Performing a linear transformation on the target vector using the target random number; Encrypting the target vector obtained after the linear transformation using the inverse matrix of the target reversible matrix 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 vector in the knowledge vector library is obtained by linearly transforming a reference vector using the target random number and encrypting the reference vector obtained after the linear transformation using the transpose matrix of the target reversible matrix.

2. The method according to claim 1, characterized in that The method further comprises: In response to receiving a search request for the target vector, determining a search mode indicated by the search request; Get the target key, including: Obtaining a target key corresponding to the retrieval method; The step of encrypting the target vector obtained after the linear transformation by using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector includes: According to the retrieval method, the target vector obtained after the linear transformation is encrypted using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector.

3. The method according to claim 2, wherein according to the retrieval method, the target vector obtained after the linear transformation is encrypted using the inverse matrix of the target reversible matrix to obtain the first ciphertext vector, comprising: If the search method is a Euclidean distance search, an element 1 is added to the end of the target vector obtained after the linear transformation to expand the target vector obtained after the linear transformation into a d+1-dimensional column vector to obtain a first extended vector, wherein the target vector is a d-dimensional column vector, and the target reversible matrix is ​​a (d+1)×(d+1) reversible matrix; The first extended vector is rotated using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector.

4. The method according to claim 3, characterized in that According to the retrieval method, the target vector obtained after the linear transformation is encrypted using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector, and further includes: If the retrieval method is cosine similarity retrieval, the target vector obtained after the linear transformation is rotated using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector, and the target reversible matrix is ​​a d×d reversible matrix.

5. The method according to claim 2, characterized in that: The search method is Euclidean distance search or cosine similarity search, and the knowledge vector library includes a first sub-vector library corresponding to the Euclidean distance search and a second sub-vector library corresponding to the cosine similarity search; 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 and the retrieval method are 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 sub-vector library corresponding to the retrieval method.

6. The method according to claim 5, characterized in that The ciphertext vectors in the first sub-vector library are obtained in the following way: Using the target random number to perform a linear transformation on a reference vector; Add an element to the end of the reference vector obtained after the linear transformation The reference vector obtained after the linear transformation is expanded into a d+1-dimensional column vector to obtain a second extended vector, wherein the reference vector is a d-dimensional column vector, and the target reversible matrix is ​​a (d+1)×(d+1) reversible matrix. is the reference vector obtained after the linear transformation The second norm of ; The second extended vector is rotated by using the transposed matrix of the target reversible matrix to obtain a ciphertext vector of the reference vector.

7. The method according to claim 5, characterized in that The second ciphertext vector in the second sub-vector library is obtained in the following manner: Normalizing the reference vector; Using the target random number to perform a linear transformation on the reference vector obtained after the normalization process; The reference vector obtained after the linear transformation is rotated using the transposed matrix of the target reversible matrix to obtain a ciphertext vector of the reference vector.

8. The method according to claim 5, characterized in that When the retrieval method is the cosine similarity retrieval, before the step of using the target random number to perform a linear transformation on the target vector, the method further includes: Normalizing the target vector; The linear transformation of the target vector by using the target random number includes: The target random number is used to perform a linear transformation on the target vector obtained after the normalization process.

9. The method according to any one of claims 2 to 8, characterized in that: The method further comprises: 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 according to the retrieval method.

10. The method according to claim 9, characterized in that Decrypting the at least one second ciphertext vector using the target key according to the retrieval method includes: For each of the second ciphertext vectors, use the transposed matrix of the inverse matrix of the target reversible matrix to perform a rotation operation on the second ciphertext vector to obtain a third ciphertext vector; If the retrieval method is Euclidean distance retrieval, the first d rows of the third ciphertext vector are extracted as the fourth ciphertext vector; 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.

11. The method according to claim 10, characterized in that The decrypting the at least one second ciphertext vector using the target key according to the retrieval method also includes: If the retrieval method is cosine similarity retrieval, 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.

12. 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 encrypting the target vector obtained after the linear transformation by using the inverse matrix of the target reversible matrix to obtain the first ciphertext vector, 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 a first Gaussian noise according to the third bit string, a preset approximation factor and the target random number; Using the first Gaussian noise to perform noise processing on the target vector obtained after the linear transformation to obtain a noise vector; The step of encrypting the target vector obtained after the linear transformation by using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector includes: The noise vector is encrypted using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector.

13. The method according to claim 12, characterized in that The step of generating a first 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; A first Gaussian noise is generated by using the Gaussian vector, the pseudo-random number, a preset approximation factor and the target random number.

14. The method according to claim 13, characterized in that The step of generating a first Gaussian noise by using the Gaussian vector, the pseudo-random number, a preset approximation factor, and the target random number includes: The first Gaussian noise is generated by using the Gaussian vector, the pseudo-random number, a preset approximation factor and the target random number through the following formula: Among them, λ m is the first 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 second norm of the Gaussian vector.

15. The method according to claim 1, 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.

16. A vector retrieval device based on a reversible matrix, 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 reversible matrix; A first linear transformation module, used for performing a linear transformation on the target vector using the target random number; An encryption module, used to encrypt the target vector obtained after the linear transformation by using the inverse matrix of the target reversible matrix to obtain a first ciphertext vector; The 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 obtained by linearly transforming a reference vector using the target random number and encrypting the reference vector obtained after the linear transformation using the transpose matrix of the target reversible matrix.

17. 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 15 are implemented.

18. 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 15.

19. 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 15 are implemented.