Data encryption and decryption method and device
By generating encrypted vectors through vectorization and matrix transformation of document fragments, and combining this with a large language model to retrieve document fragments to answer user questions, the computational resource consumption and security issues of traditional encryption methods are resolved, achieving a highly efficient data encryption and decryption process.
Patent Information
- Application Number
- CN202511168178.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-20
- Publication Date
- 2025-11-04
AI Technical Summary
Traditional data encryption methods require full decryption during data retrieval, resulting in excessive consumption of server computing resources and difficulty in effectively protecting unstructured document data in private knowledge bases from leakage.
A preset matrix is used to perform matrix transformation on the first-class vector of the document fragment to generate an encrypted first-class vector. The target document fragment is then recalled through similarity calculation. The solution is then obtained by combining a large language model, which reduces CPU computing resource consumption and improves data security.
By using matrix transformation encryption, CPU computing resource consumption is reduced, attackers are prevented from cracking original document fragments, and data security and computing efficiency are improved.
Smart Images

Figure CN120893073A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present specification relates to the technical field of security, and in particular to a data encryption and decryption method and device. BACKGROUND
[0002] A private knowledge base refers to a data storage and management system established by an organization, company or individual for specific purposes, which is internal, proprietary and protective. The private knowledge base usually contains knowledge, information, documents or data within the organization, aiming to provide effective information access, management and query support for users. The private knowledge base is usually designed specifically for a particular field, business needs or workflow, and unlike public knowledge bases such as Wikipedia or open databases, the data and information of the private knowledge base are invisible to external users.
[0003] In today's knowledge answering solutions based on large language models, private knowledge bases play an increasingly important role. Since the private knowledge base is not open to the public, and the core data of the private knowledge base is usually unstructured document data, when the large language model calls the private knowledge base, it is necessary to ensure that the solution link is smooth, and to protect the original unstructured document data from being leaked.
[0004] In related technologies, the traditional data encryption method (such as symmetric encryption algorithm based on AES-CBC or building an encryption chain table, etc.) can be used to encrypt the document data in the private knowledge base, so as to protect the original unstructured document data in the private knowledge base from being leaked.
[0005] However, although the traditional data encryption method has high data security, it needs to decrypt all data every time the data is recalled (i.e., the large language model retrieves relevant document data based on user questions), even if only the top K document data or document fragments related to the user are recalled, the full amount of document data needs to be decrypted, which consumes a lot of server computing resources. SUMMARY
[0006] Therefore, one or more embodiments of the present specification provide a data encryption and decryption method and device, an electronic device and a storage medium to solve the problems in the related art.
[0007] To achieve the above-mentioned purpose, one or more embodiments of the present specification provide technical solutions as follows:
[0008] According to a first aspect of an embodiment of the present specification, a data encryption method is provided, the method comprising:
[0009] obtaining each document fragment segmented from the original knowledge document;
[0010] vectorize each document segment to obtain a first type of vector corresponding to each document segment;
[0011] perform matrix transformation on each first type of vector using a preset matrix to obtain an encrypted first type of vector.
[0012] Optionally, the method further comprises:
[0013] vectorize a question of a user to obtain a second type of vector corresponding to the question in response to the question;
[0014] perform matrix transformation on the second type of vector using the preset matrix to obtain an encrypted second type of vector;
[0015] calculate a similarity between the encrypted second type of vector and each encrypted first type of vector, and recall K number of encrypted target first type of vectors based on the similarity; wherein the K is a positive integer;
[0016] query a target document segment mapped by the target first type of vector, and use the target document segment to answer the question.
[0017] Optionally, the preset matrix comprises an orthogonal matrix or a rotation matrix.
[0018] Optionally, the preset matrix is stored on a serverless service in the form of a webassembly format.
[0019] Optionally, the performing matrix transformation on the second type of vector using the preset matrix can comprise:
[0020] performing identity authentication on the user;
[0021] performing matrix transformation on the second type of vector using the preset matrix after the identity authentication is passed.
[0022] Optionally, each document segment segmented from the original knowledge document is stored in a private knowledge base in a linked list form, and the server locally stores position information of each document segment in the linked list;
[0023] Correspondingly, the querying the target document segment mapped by the target first type of vector comprises:
[0024] querying locally stored position information mapped by the target first type of vector, and obtaining the target document segment at the position information from the private knowledge base based on the position information.
[0025] Optionally, the using the target document segment to answer the question comprises:
[0026] input the target document segment and the question as a prompt word into a large language model to obtain answer information for the question inferred by the large language model based on the target document segment.
[0027] Optionally, the method further comprises:
[0028] further obtaining a context document segment of the target document segment from the original knowledge document;
[0029] splicing each target document segment and context document segment into a new target document segment.
[0030] According to a second aspect of an embodiment of the present specification, a data decryption method is provided, the method comprising:
[0031] in response to a question of a user, performing vectorization processing on the question to obtain a second type vector corresponding to the question;
[0032] performing matrix transformation on the second type vector using a preset matrix to obtain an encrypted second type vector;
[0033] calculating a similarity between the encrypted second type vector and each encrypted first type vector, and recalling K number of encrypted target first type vectors based on the similarity; wherein the each encrypted first type vector comprises an encrypted first type vector obtained by performing the same vectorization processing and matrix transformation on each document segment segmented from an original knowledge document as the question;
[0034] querying a target document segment mapped by the target first type vector, and using the target document segment to answer the question.
[0035] Optionally, the preset matrix comprises an orthogonal matrix or a rotation matrix.
[0036] Optionally, the using the target document segment to answer the question comprises:
[0037] inputting the target document segment and the question as a prompt word into a large language model to obtain answer information for the question inferred by the large language model based on the target document segment.
[0038] According to a third aspect of an embodiment of the present specification, a data encryption apparatus is provided, the apparatus comprising:
[0039] an acquisition unit configured to acquire each document segment segmented from an original knowledge document;
[0040] a vectorization unit configured to perform vectorization processing on each document segment to obtain a first type vector corresponding to each document segment;
[0041] The encryption unit performs matrix transformation on each first type vector using a preset matrix to obtain an encrypted first type vector.
[0042] According to a fourth aspect of the embodiments of the present specification, a data decryption device is provided, the device comprising:
[0043] The vectorization unit performs vectorization processing on the question to obtain a second type vector corresponding to the question.
[0044] The encryption unit performs matrix transformation on the second type vector using a preset matrix to obtain an encrypted second type vector.
[0045] The decryption unit calculates the similarity between the encrypted second type vector and each encrypted first type vector, and recalls K number of encrypted target first type vectors based on the similarity; wherein the each encrypted first type vector includes an encrypted first type vector obtained by performing the same vectorization processing and matrix transformation on each document segment segmented from the original knowledge document as the question.
[0046] The answering unit queries the target document segment mapped by the target first type vector, and answers the question using the target document segment.
[0047] According to a fifth aspect of the embodiments of the present specification, an electronic device is provided, comprising a communication interface, a processor, a memory and a bus, the communication interface, the processor and the memory are connected to each other through the bus;
[0048] The memory stores machine readable instructions, and the processor executes the above method by calling the machine readable instructions.
[0049] According to a sixth aspect of the embodiments of the present specification, a machine readable storage medium is provided, the machine readable storage medium stores machine readable instructions, and the machine readable instructions realize the above method when called and executed by a processor.
[0050] The technical solutions provided by the embodiments of the present specification can include the following beneficial effects:
[0051] By introducing a preset matrix to perform matrix transformation on the first type vector of the document segment to obtain an encrypted first type vector, compared with the existing encryption method using an encryption key:
[0052] On the one hand, it can prevent attackers from reverse engineering the original document segment after knowing the vectorization processing logic.
[0053] On the other hand, compared with the prior art of encrypting the first type of vector using an encryption key, the encryption method with a preset matrix can reduce the consumption of CPU computing resources, because the matrix transformation can be performed on the GPU, while the encryption key encryption needs to be performed on the CPU.
[0054] In another aspect, since the GPU is very good at vector calculation, the GPU resources consumed in matrix transformation are also less than the CPU resources consumed in encryption key encryption.
[0055] In yet another aspect, in the subsequent decryption process (see the subsequent embodiments for details), since all document fragments and user questions are subjected to the same vectorization processing and matrix transformation, when performing knowledge fragment retrieval, the similarity between the encrypted second type of vector corresponding to the question and the encrypted first type of vector corresponding to each document fragment can be directly compared, without the need to decrypt each document fragment in full as in the prior art before similarity calculation.
[0056] In summary, the embodiments of the present specification can greatly reduce the consumption of server computing resources in encryption and decryption methods through a new data encryption method. BRIEF DESCRIPTION OF DRAWINGS
[0057] Figure 1 A system architecture diagram of a large language model based on a private knowledge base is provided for an exemplary embodiment of the present specification;
[0058] Figure 2 A flowchart of a data encryption method is provided for an exemplary embodiment of the present specification;
[0059] Figure 3 A flowchart of a data decryption method is provided for an exemplary embodiment of the present specification;
[0060] Figure 4 A structural schematic diagram of an electronic device in which a data encryption and decryption apparatus is provided for an exemplary embodiment of the present specification;
[0061] Figure 5 A block diagram of a data encryption apparatus is provided for an exemplary embodiment of the present specification;
[0062] Figure 6 A block diagram of a data decryption apparatus is provided for an exemplary embodiment of the present specification. DETAILED DESCRIPTION
[0063] The exemplary embodiments will be described in detail herein with reference to the attached drawings. The description herein relates to the drawings, in which the same numbers represent the same or similar elements, unless otherwise represented. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of the description. Instead, they are merely examples of apparatuses and methods consistent with some aspects of one or more embodiments of the description, as detailed in the appended claims.
[0064] It should be noted that the steps of the methods performed by the respective methods in other embodiments are not necessarily performed in the order shown and described in the description. In some other embodiments, the steps included in the methods can be more or less than described in the description. Furthermore, a single step described in the description can be broken down into multiple steps in other embodiments, and multiple steps described in the description can be combined into a single step in other embodiments.
[0065] Reference is first made to Figure 1 a system architecture diagram of a large language model based on a private knowledge base. In the system architecture diagram, various network nodes can communicate information via the network, thereby completing interaction and data processing. The system architecture diagram can include a server 12 in data communication with one or more clients 11 via a network 13, and a private knowledge base 14 that can be integrated with the server 12 or independent of the server 12.
[0066] The server 12 can store or call a large language model 15 (Large Language Model, LLM) provided by a third party, which can enable the server 12 to have knowledge question and answer capability, for example, to generate relevant answer content based on the question sent by the client 11. Further, in order to enable the large language model 15 to answer professional field questions, the private knowledge base 14 can also be used to provide a material library of professional field knowledge for the large language model 15, so that the large language model 15 can generate professional answer content using the knowledge data provided by the private knowledge base 14.
[0067] In the system architecture diagram, each network 13 can include wired or wireless telecommunication means by which the network means on which the clients 11 are based can exchange data. For example, each network 13 can include a local area network (“LAN”), a wide area network (“WAN”), an intranet, the Internet, a mobile telephone network, a virtual private network (VPN), a cellular or other mobile communication network, Bluetooth, NFC, or any combination thereof. In the discussion of the example embodiments, it will be understood that the terms “data” and “information” can be used interchangeably herein to refer to text, images, audio, video, or any other form of information that can exist in a computer-based environment.
[0068] The network means on which each client 11 is based can include a device having a communication module capable of sending and receiving data via the network 13. For example, the network means on which each client 11 is based can include a server, a desktop computer, a laptop computer, a tablet computer, a smartphone, a handheld computer, a personal digital assistant (“PDA”), or any other wired or wireless processor-driven device.
[0069] In the depicted example, the network means on which the clients 11 are based can be operated by a user who posts the questions. Figure 1 In the depicted example, the network means on which the clients 11 are based can be operated by a user who posts the questions.
[0070] Users (including individuals or organizations) can use applications, such as web browser applications or standalone applications, in order to view, download, upload, or otherwise access files or web pages via the network 13.
[0071] The applications, such as web browser applications or standalone applications, can interact with web servers (or other servers, such as question-and-answer platforms, applets, etc.) connected to the network 13 to complete the knowledge question-and-answer interaction.
[0072] Having introduced the system of large language models based on private knowledge bases, please further refer to Figure 2 , Figure 2 A flowchart of a data encryption method provided for an example embodiment of the present specification. The method can be applied to the server described above and can include the following steps:
[0073] Step 210, obtaining each document segment segmented from the original knowledge document.
[0074] The original knowledge document can refer to a knowledge document in plaintext in the private knowledge base.
[0075] Step 220, performing vectorization processing on each document segment to obtain a first type of vector corresponding to each document segment.
[0076] The vectorization processing can be a processing manner commonly used in the industry, such as a vectorization algorithm such as Word2Vec, TF-IDF (Term Frequency-Inverse Document Frequency), GloVe, and the like.
[0077] For any document segment, different first-class vectors can be obtained using different vectorization algorithms, and under the same vectorization algorithm, each document segment can only obtain a unique corresponding first-class vector. Based on this, in order to enable vectors to be compared, a unified vectorization algorithm needs to be used.
[0078] For example, since the large language model needs to be used subsequently, the vectorization processing here can use an Embedding processing manner. Specifically, an Embedding model can be used to convert the document segment into an Embedding vector (i.e., a first-class vector), thereby facilitating the large language model to understand semantics.
[0079] Through vectorization processing, text information in a natural language can be converted into a digital vector that can be processed by a computer.
[0080] In step 230, a preset matrix is used to perform matrix transformation on each first-class vector to obtain an encrypted first-class vector.
[0081] In this specification, the preset matrix can include an orthogonal matrix (also known as an orthonormal matrix). Further, different orthogonal matrices with different determinants have different forms of representation. For example, when the determinants of the orthogonal matrices are all 1, the orthogonal matrices can represent a rotation transformation in space, and such an orthogonal matrix is called a rotation matrix. For another example, when the determinants of the orthogonal matrices are all -1, the orthogonal matrices can represent a mirror transformation in space, and such an orthogonal matrix is called a reflection matrix.
[0082] The preset matrix can be stored in a server, in a service of a private knowledge base, or on a serverless service in a Webassembly format.
[0083] The Webassembly is a low-level binary instruction format designed for the Web. Through the Webassembly+Serverless manner, the difficulty of solving the preset matrix can be improved, thereby improving the security of the data.
[0084] By introducing the preset matrix to perform matrix transformation on the first-class vector of the document segment to obtain an encrypted first-class vector, the difficulty of data cracking can be improved.
[0085] Compared with the existing encryption manner using an encryption key, the encryption manner based on the preset matrix has the following advantages:
[0086] In one aspect, the attacker can be prevented from reverse engineering the original document fragments after knowing the vectorization logic.
[0087] In another aspect, compared with the prior art of encrypting the first type of vectors using encryption keys, the encryption method with the preset matrix can reduce the consumption of CPU computing resources, because the matrix transformation can be performed on the GPU, while the encryption key encryption needs to be performed on the CPU.
[0088] In still another aspect, since the GPU is very good at vector calculation, the GPU resources consumed in matrix transformation are also less than the CPU resources consumed in encryption key encryption.
[0089] In yet another aspect, in the subsequent decryption process (see the subsequent embodiments for details), since all document fragments and user questions are subjected to the same vectorization processing and matrix transformation, when recalling knowledge fragments, the similarity between the encrypted second type of vector corresponding to the question and the encrypted first type of vector corresponding to each document fragment can be directly compared, without the need to decrypt each document fragment in full as in the prior art before calculating the similarity.
[0090] The following further introduces embodiments of the decryption process, which are based on the above Figure 2 The embodiments shown above can further include:
[0091] In response to a user question, the question is subjected to vectorization processing to obtain a second type of vector corresponding to the question;
[0092] The second type of vector is subjected to matrix transformation using the preset matrix to obtain an encrypted second type of vector;
[0093] The similarity between the encrypted second type of vector and each encrypted first type of vector is calculated, and K number of encrypted target first type of vectors are recalled based on the similarity; wherein K is a positive integer;
[0094] The target document fragment mapped by the target first type of vector is queried, and the target document fragment is used to answer the question.
[0095] In this embodiment, for a user question, the same vectorization processing and matrix transformation as the document fragments are used to obtain a second type of vector corresponding to the question and an encrypted second type of vector after matrix transformation.
[0096] Then, the similarity between the encrypted second type of vector and each encrypted first type of vector can be calculated using a preset similarity calculation method, and K encrypted target first type of vectors are recalled based on the calculated similarity.
[0097] For example, based on the calculated similarity, recalling K encrypted target first-class vectors can refer to sorting the similarity between the calculated encrypted second-class vector and each encrypted first-class vector, and then recalling the K encrypted first-class vectors with the largest similarity as the encrypted target first-class vectors.
[0098] wherein the K can be pre-set based on experience and the number of document segments, for example, when the number of document segments is 100, the K can be set to 10 according to a preset ratio of 10%, that is, 10 encrypted first-class vectors with the largest similarity are recalled.
[0099] In an exemplary embodiment, the similarity calculation method can include any one of cosine similarity, Euclidean distance, and inner product.
[0100] The cosine similarity is used to measure the size of the included angle between the directions of two vectors, and the smaller the included angle, the more similar the vectors, and vice versa, the larger the included angle, the less similar the vectors.
[0101] The Euclidean distance is used to measure the straight-line distance between two vectors, and the smaller the straight-line distance, the more similar the vectors, and vice versa, the larger the straight-line distance, the less similar the vectors.
[0102] The inner product is used to measure the included angle and straight-line distance of two vectors, and the smaller the inner product, the more similar the vectors, and vice versa, the larger the inner product, the less similar the vectors.
[0103] It is worth mentioning that in the embodiments of the present specification, matrix transformation is required for the first-class vectors and the second-class vectors. In order to make the similarity calculation result reliable, a preset matrix that does not affect the vector similarity result before matrix transformation needs to be selected.
[0104] Taking an orthogonal matrix as an example, the orthogonal matrix Q needs to satisfy the following conditions:
[0105] Q T Q=QQ T =I
[0106] wherein Q T represents the transpose matrix of the matrix Q, and I represents the unit matrix.
[0107] The column vectors and row vectors of the orthogonal matrix are all orthogonal unit vectors. The orthogonal transformation has the following properties:
[0108] 1. Keep the vector length unchanged:
[0109] For any non-zero vector v, we have:
[0110] |Qv|=|v|
[0111] 2. Keep the vector included angle unchanged:
[0112] For any two vectors u and v, their included angle remains unchanged after orthogonal transformation, i.e.:
[0113]
[0114] 3. Keep the inner product unchanged:
[0115] For any two vectors u and v, their inner product remains unchanged after orthogonal transformation, i.e.:
[0116] u T v=(Qu) T (Qv)
[0117] Based on the above properties, it is known that when using an orthogonal matrix as a preset matrix, regardless of whether the similarity algorithm uses cosine similarity or Euclidean distance or inner product, the similarity between the same two vectors before and after matrix transformation is not affected. In other words, the similarity between the two vectors before matrix transformation is the same as the similarity between the two vectors after matrix transformation using an orthogonal matrix.
[0118] In an exemplary embodiment, in order to further improve security, the matrix transformation of the second type of vector using the preset matrix can include:
[0119] Identity authentication of the user who raises the question;
[0120] After identity authentication, the matrix transformation of the second type of vector using the preset matrix.
[0121] In this embodiment, the identity authentication can check the identity information of the user (such as fixed password, dynamic verification code, face, fingerprint, etc.), and obtain the execution right of matrix transformation through identity authentication. Once the identity authentication fails, the subsequent process can be terminated to avoid malicious user attacks.
[0122] In an exemplary embodiment, in order to further improve security, each document segment segmented from the original knowledge document is stored in a private knowledge base in the form of a linked list, and the server locally stores the position information of each document segment in the linked list;
[0123] Correspondingly, the target document segment mapped by the target first type of vector is queried, including:
[0124] Query the locally stored position information of the target first type of vector mapping, and obtain the target document segment on the position information from the private knowledge base based on the position information.
[0125] Through the above embodiment, the server only retains the position information of the document fragment in the linked list locally, and finally only the target document fragment can be obtained, thereby preventing an attacker from guessing the complete original knowledge document through a sequential database.
[0126] As described in the foregoing Figure 1 embodiments, the server 12 can store or invoke a third-party provided large language model 15 (Large Language Model, LLM), through which the server 12 can have a knowledge question and answer capability, for example, can perform reasoning based on the question sent by the client 11 to generate relevant answer content. Further, in order to enable the large language model 15 to answer professional field questions, the private knowledge base 14 can also be used to provide a material library of professional field knowledge for the large language model 15, so that the large language model 15 can generate professional answer content by using the knowledge data provided by the private knowledge base 14.
[0127] In an exemplary embodiment, the above using the target document fragment to answer the question can include:
[0128] inputting the target document fragment and the question as a prompt word into a large language model to obtain answer information for the question inferred by the large language model based on the target document fragment.
[0129] Through this embodiment, the large language model is used to infer the input target document fragment to answer the answer information corresponding to the question raised by the user. Since the answer information is generated from the professional knowledge in the target document fragment, the answer information can have relevant professional knowledge, and has high accuracy, persuasiveness and credibility.
[0130] In an exemplary embodiment, before inputting the target document fragment and the question as a prompt word into a large language model, it can further include:
[0131] further obtaining a context document fragment of the target document fragment from the original knowledge document;
[0132] splicing each target document fragment and context document fragment into a new target document fragment.
[0133] For example, the context document fragment can be obtained based on the position information of the target document fragment. For example, assuming that the position information of the target document fragment is fragement_id, the context document fragment can be obtained through pre_fragement_id and next_fragement_id.
[0134] Through the embodiment, the context document segment is added on the basis of the target document segment, and more document segments are input into the large language model to help the large language model generate richer and more reliable answer information.
[0135] After the embodiment of data encryption is completely introduced, the method embodiment of data decryption is further introduced as follows. Figure 3 As shown in the figure, the data decryption method can include the following steps:
[0136] Step 310, in response to the user's question, the question is vectorized to obtain a second type of vector corresponding to the question;
[0137] Step 320, using a preset matrix, the second type of vector is matrix transformed to obtain an encrypted second type of vector;
[0138] Step 330, the similarity between the encrypted second type of vector and each encrypted first type of vector is calculated, and K number of encrypted target first type of vectors are recalled based on the similarity; wherein the each encrypted first type of vector includes an encrypted first type of vector obtained by performing the same vectorization and matrix transformation on each document segment segmented from the original knowledge document as the question;
[0139] Step 340, querying the target document segment mapped by the target first type of vector, using the target document segment to answer the question.
[0140] Steps 310-340 in this embodiment are the same as the data decryption process in the foregoing data encryption embodiment, for example, the preset matrix includes an orthogonal matrix or a rotation matrix; again for example, using the target document segment to answer the question can include inputting the target document segment and the question as a prompt word into a large language model to obtain answer information for the question inferred by the large language model based on the target document segment; all of which can refer to the description of the foregoing embodiments, which will not be repeated here.
[0141] Since all document segments and user questions are subjected to the same vectorization and matrix transformation, when the knowledge segment is recalled, the similarity between the encrypted second type of vector corresponding to the question and the encrypted first type of vector corresponding to each document segment can be directly compared, without the need to decrypt each document segment in full as in the prior art before similarity calculation.
[0142] In the exemplary embodiments of the present specification, a device capable of implementing the above method is also provided.
[0143] Figure 4 is a schematic structural diagram of an electronic device provided by an exemplary embodiment. Please refer toFigure 4 At the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and can also include other hardware required by a business. One or more embodiments of the present specification can be implemented in a software manner, such as reading a corresponding computer program from the non-volatile memory into the memory by the processor and then running. Of course, in addition to the software implementation, one or more embodiments of the present specification do not exclude other implementation manners, such as a logic device or a combination of software and hardware, and the like, that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or a logic device.
[0144] Reference is made to Figure 5 In a software implementation, a data encryption device is provided, and the device includes:
[0145] An acquisition unit 510 acquires each document segment segmented from an original knowledge document;
[0146] A vectorization unit 520 performs vectorization processing on each document segment to obtain a first type of vector corresponding to each document segment;
[0147] An encryption unit 530 performs matrix transformation on each first type of vector using a preset matrix to obtain an encrypted first type of vector.
[0148] In an exemplary embodiment, the vectorization unit 520 is further configured to perform vectorization processing on a question of a user to obtain a second type of vector corresponding to the question;
[0149] The encryption unit 530 is further configured to perform matrix transformation on the second type of vector using the preset matrix to obtain an encrypted second type of vector;
[0150] Correspondingly, the device further includes:
[0151] A calculation unit calculates a similarity between the encrypted second type of vector and each encrypted first type of vector, recalls K encrypted target first type of vectors based on the similarity; the K is a positive integer;
[0152] An answering unit queries a target document segment mapped by the target first type of vector, and answers the question using the target document segment.
[0153] In an exemplary embodiment, the preset matrix includes an orthogonal matrix or a rotation matrix.
[0154] In an exemplary embodiment, the encryption unit 530 performs matrix transformation on the second type of vector using the preset matrix, which can further include:
[0155] Identity authentication is performed on the user, and after identity authentication is passed, the second type of vector is subjected to matrix transformation using the preset matrix.
[0156] In an exemplary embodiment, the original knowledge document is segmented into various document segments, which are stored in a private knowledge base in the form of a linked list, and the server locally stores position information of each document segment in the linked list.
[0157] Correspondingly, the answering unit querying the target document segment mapped by the target first type of vector can further include:
[0158] Querying the locally stored position information of the target first type of vector, and obtaining the target document segment at the position information from the private knowledge base based on the position information.
[0159] In an exemplary embodiment, the answering unit using the target document segment to answer the question further includes:
[0160] Inputting the target document segment and the question as prompt words into a large language model to obtain answer information for the question inferred by the large language model based on the target document segment.
[0161] In an exemplary embodiment, the device further includes:
[0162] A context acquisition unit further acquires a context document segment of the target document segment from the original knowledge document, and splices each target document segment and context document segment into a new target document segment.
[0163] Please refer to Figure 6 In a software implementation, a data decryption device is provided, and the device includes:
[0164] A vectorization unit 610 responds to a user's question to perform vectorization processing on the question to obtain a second type of vector corresponding to the question.
[0165] An encryption unit 620 uses a preset matrix to perform matrix transformation on the second type of vector to obtain an encrypted second type of vector.
[0166] A decryption unit 630 calculates the similarity between the encrypted second type of vector and each encrypted first type of vector, and recalls K number of encrypted target first type of vectors based on the similarity; wherein the each encrypted first type of vector includes an encrypted first type of vector obtained by performing the same vectorization processing and matrix transformation on each document segment segmented from an original knowledge document as the question.
[0167] The answering unit 640 queries a target document segment of the target first-type vector mapping, and answers the question using the target document segment.
[0168] In an exemplary embodiment, the preset matrix includes an orthogonal matrix.
[0169] In an exemplary embodiment, the answering unit 640, when answering the question using the target document segment, can further include:
[0170] inputting the target document segment and the question as a prompt word into a large language model to obtain answer information for the question inferred by the large language model based on the target document segment.
[0171] The implementation process of the functions and roles of each module in the above apparatus is specifically described in the implementation process of the corresponding steps in the above data encryption method, and the related parts are described in the method implementation part. Therefore, it is not repeated here.
[0172] The apparatus implementation described above is only illustrative, and the units described as separate components can or can not be physically separated, and the components displayed as units can or can not be physical modules, i.e., they can be located in one place or distributed on multiple network modules. Some or all units or modules can be selected to achieve the purpose of the scheme of the present specification according to actual needs. Those skilled in the art can understand and implement it without creative labor.
[0173] The system, apparatus, module or unit illustrated in the above embodiments can be specifically implemented by a computer chip or entity, or by a product with certain functions. A typical implementation device is a computer, and the specific form of the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0174] In a typical configuration, a computer includes one or more processors (CPU), input / output interface, network interface and memory.
[0175] The memory can include non-persistent memory in a computer readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM). The memory is an example of a computer readable medium.
[0176] Computer-readable media includes permanent and non-permanent, movable and non-movable media that can implement information storage by any method or technology. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, disk storage, quantum memory, graphene-based storage medium or other magnetic storage device, or any other non-transmission medium that can be used to store information accessible to a computing device. According to the definition herein, computer-readable media does not include transitory media such as modulated data signals and carriers.
[0177] It should also be noted that the terms "comprising", "containing", or any other variant thereof are intended to cover non-exclusive inclusions, so that a process, method, article or apparatus that includes a list of elements not only includes those elements, but also includes other elements not explicitly listed, or inherent to such process, method, article or apparatus. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of additional identical elements in the process, method, article or apparatus that includes the element.
[0178] The above describes specific embodiments of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from the order in the embodiments and still achieve the desired result. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In some embodiments, multi-task processing and parallel processing are possible or can be advantageous.
[0179] The terms used in one or more embodiments of the present specification are merely for the purpose of describing specific embodiments and are not intended to limit one or more embodiments of the present specification. The singular forms "a", "an" and "the" used in one or more embodiments of the present specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein means and includes any or all possible combinations of one or more associated listed items.
[0180] It should be understood that, although the terms first, second, third, etc. can be used herein to describe various information, the information should not be limited to these terms. These terms are only used to differentiate one piece of information from another. For example, a first information can also be termed a second information, similarly, a second information can also be termed a first information without departing from the scope of the one or more embodiments. The word "if' as used herein can be interpreted to mean "when" or "upon" or "in response to the determination" depending on the context.
[0181] The above description is merely illustrative of the exemplary embodiments of the one or more embodiments and is not intended to limit the scope of the one or more embodiments. Whatever modifications and improvements made during the process of implementation, if any, should be included in the protection scope of the one or more embodiments.
Claims
1. A data encryption method, characterized in that, The method includes: Obtain the document fragments segmented from the original knowledge document; Each document fragment is vectorized to obtain a first-class vector corresponding to each document fragment; Using a preset matrix, perform matrix transformation on each first-class vector to obtain encrypted first-class vectors.
2. The method according to claim 1, characterized in that, The method further includes: In response to a user's question, the question is vectorized to obtain a second type of vector corresponding to the question; Using the preset matrix, perform matrix transformation on the second type of vector to obtain the encrypted second type of vector; Calculate the similarity between the encrypted second-class vector and each encrypted first-class vector, and recall K encrypted target first-class vectors based on the similarity; where K is a positive integer; Query the target document fragment mapped to the first type of target vector, and use the target document fragment to answer the question.
3. The method according to claim 1, characterized in that, The preset matrix includes orthogonal matrices.
4. The method according to claim 3, characterized in that, The preset matrix is stored on the serverles service in webassembly format.
5. The method according to claim 2, characterized in that, The step of performing matrix transformation on the second type of vector using the preset matrix includes: Perform identity authentication on the user; After identity authentication is successful, the second type of vector is transformed using the preset matrix.
6. The method according to claim 2, characterized in that, The document fragments segmented from the original knowledge document are stored in a private knowledge base in the form of a linked list, and the server locally stores the position information of each document fragment in the linked list. The query of the target document fragment for the first type vector mapping includes: Query the locally stored location information of the target's first type vector mapping, and obtain the target document fragment at that location from the private knowledge base based on the location information.
7. The method according to claim 2, characterized in that, The step of using the target document fragment to answer the question includes: The target document fragment and the question are used as prompt words and input into the large language model to obtain the answer information for the question inferred by the large language model based on the target document fragment.
8. The method according to claim 2, characterized in that, Also includes: Further obtain the preceding and following document fragments of the target document fragment from the original knowledge document; Each target document fragment and its preceding and following document fragments are concatenated into a new target document fragment.
9. A data decryption method, characterized in that, The method includes: In response to a user's question, the question is vectorized to obtain a second type of vector corresponding to the question; Using a preset matrix, perform matrix transformation on the second type of vector to obtain an encrypted second type of vector; Calculate the similarity between the encrypted second-class vector and each encrypted first-class vector, and recall K encrypted target first-class vectors based on the similarity; wherein, each encrypted first-class vector includes encrypted first-class vectors obtained by performing the same vectorization processing and matrix transformation on each document fragment segmented from the original knowledge document as the problem; Query the target document fragment mapped to the first type of target vector, and use the target document fragment to answer the question.
10. A data encryption device, characterized in that, The device includes: The acquisition unit retrieves the document fragments segmented from the original knowledge document. The vectorization unit performs vectorization processing on each document fragment to obtain a first-class vector corresponding to each document fragment; The encryption unit uses a preset matrix to perform matrix transformation on each first-class vector to obtain the encrypted first-class vector.
11. A data decryption device, characterized in that, The device includes: The vectorization unit, in response to a user's question, performs vectorization processing on the question to obtain a second type of vector corresponding to the question; The encryption unit uses a preset matrix to perform a matrix transformation on the second type of vector to obtain an encrypted second type of vector. The decryption unit calculates the similarity between the encrypted second-class vector and each encrypted first-class vector, and recalls K encrypted target first-class vectors based on the similarity; wherein, each encrypted first-class vector includes encrypted first-class vectors obtained by performing the same vectorization processing and matrix transformation on each document fragment segmented from the original knowledge document as the problem. The solution unit queries the target document fragment mapped by the first type of target vector and uses the target document fragment to answer the question.
12. An electronic device, comprising: processor; Memory used to store processor-executable instructions; The processor implements the method as described in any one of claims 1-9 by executing the executable instructions.
13. A machine-readable storage medium having stored thereon machine-readable instructions that, when executed by a processor, implement the method as claimed in any one of claims 1-9.