Data retrieval methods, devices, terminals and systems
By generating a hash table on the terminal and performing local data retrieval, combined with hash value block partitioning and HMAC blinding processing, the problems of user privacy leakage and insufficient data retrieval security are solved, achieving more efficient and secure data retrieval.
Patent Information
- Application Number
- CN202510626000.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-14
- Publication Date
- 2026-11-17
AI Technical Summary
In existing technologies, user query data/high-dimensional vectors are easily leaked when transmitted to cloud servers, leading to the exposure of user privacy, and the security and accuracy of data retrieval are insufficient.
Hash tables are generated and deployed on the terminal, and data is retrieved locally using hash values. Hash message CAPTCHA blinding processing and hash value block technology are used, combined with the Locality Sensitive Hash (LSH) model, to reduce the computational burden on cloud servers and improve data security and accuracy.
It effectively protects user data privacy, prevents data leakage, improves the security and accuracy of data retrieval, and reduces the computing burden on cloud servers.
Smart Images

Figure CN123116309A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of semantic retrieval technology, and in particular to a data retrieval method, apparatus, terminal and system. Background Technology
[0002] A vector database is a database system used to store, manage, and query high-dimensional vector data. Its core function is to process unstructured data (such as images, audio, and text) through vectorization techniques, transforming unstructured data into high-dimensional vector representations, thereby enabling efficient similarity search and data analysis. Therefore, high-dimensional vectors are widely used in the field of semantic retrieval technology.
[0003] Based on this, the data retrieval methods provided by related technologies include: 1) the terminal sends query data such as text, images or audio to the cloud server, and the cloud server converts the query data into a high-dimensional vector; or 2) the terminal directly processes the query data into a high-dimensional vector, and then compares the vector with the vector in the vector database. By comparing the "distance" between the vectors, the data most similar to the query data is found. However, in this way, the user's query data / dimensional vector will be revealed to the cloud server, and the user's privacy will be leaked. Summary of the Invention
[0004] This application provides a data retrieval method, apparatus, terminal, and system, which effectively improves the security of data retrieval. The technical solution is as follows.
[0005] Firstly, a data retrieval method is provided, which is applied to a terminal. The method includes: obtaining a first hash value corresponding to the feature vector of the first data; and determining that the first data belongs to the second data corresponding to the target hash value if the similarity between the first hash value and the target hash value in the hash table is greater than or equal to a first threshold. The hash table is obtained from a cloud server.
[0006] In this application, a hash table is generated via a cloud server and deployed on the terminal, effectively protecting the data corresponding to the hash table and ensuring data security. Furthermore, performing data retrieval on the terminal effectively prevents the risk of data leakage to the cloud server and the risk of data leakage during data transmission, thus improving the security of data retrieval. Additionally, the terminal uses a first hash value to search the hash table for second data with a similarity greater than or equal to a first threshold to determine if the first data is identical or similar. This allows for subsequent analysis; if the second data is sensitive, the first data can be identified as sensitive, effectively improving the accuracy of data analysis.
[0007] In one possible implementation, the method further includes: generating a search result indicating no data was found when the similarity between the first hash value and all hash values in the hash table is less than a first threshold. The terminal searches the hash table using the first hash value, finding hash values in the hash table with similarity values less than the first threshold. This determines that no second data is identical or similar to the first data, facilitating subsequent analysis. If the data corresponding to the hash table is sensitive data, the analysis can determine that the first data is non-sensitive data, effectively improving the accuracy of data analysis.
[0008] In one possible implementation, before determining that the first data belongs to the second data corresponding to the target hash value, the method further includes: comparing the first hash value with each hash value in the hash table based on similarity, and retrieving the target hash value. It is evident that the comparison step can be implemented on the terminal. By implementing the comparison between the first hash value and each hash value in the hash table through the terminal, the computational burden on the cloud server can be reduced. Of course, the comparison step is not limited to implementation on the terminal; it can also be implemented on the cloud server. Implementing the comparison between the first hash value and each hash value in the hash table through the cloud server can reduce the computational burden on the terminal.
[0009] In one possible implementation, the hash value is blinded using a hash-based message CAPTCHA (Hash Message Authentication Code) to obtain a blinded hash value. By blinding each hash value using HMAC, the security of the hash value is effectively improved, making the data retrieval process more secure and further enhancing the overall security of data retrieval.
[0010] In one possible implementation, the hash table further includes multiple hash value blocks corresponding to each hash value; after obtaining the first hash value corresponding to the feature vector of the first data, the method further includes: dividing the first hash value into blocks according to the number of reference blocks to obtain multiple hash value blocks corresponding to the first hash value; comparing the hash value of the first data with each hash value in the hash table, including: comparing the multiple hash value blocks corresponding to the first hash value with the multiple hash value blocks in the hash table, wherein the number of multiple hash value blocks corresponding to the target hash value that are equal to the number of multiple hash value blocks corresponding to the first hash value is greater than or equal to a second threshold.
[0011] Since the hash table also contains multiple hash value blocks corresponding to each hash value, the terminal also performs block processing on the first hash value of the first data to obtain multiple hash value blocks for the first hash value. The terminal compares these multiple hash value blocks with the multiple hash value blocks for each hash value in the hash table. If the number of equal hash value blocks corresponding to the target hash value and the first hash value is greater than or equal to a threshold, then the data corresponding to the target hash value is determined to be the retrieved data for the first data. It is evident that hash value block segmentation divides sensitive hash values into blocks and compares them one by one, making the comparison more refined and ensuring more comprehensive retrieved data. Furthermore, since the number of reference blocks is adjustable, it greatly enhances adaptability and flexibility in different application scenarios.
[0012] In one possible implementation, multiple hash value blocks in the hash table are blinded using a Hash Message Authentication Code (HMAC). The first hash value is divided into blocks according to the number of reference blocks, resulting in multiple hash value blocks corresponding to the first hash value. This includes: dividing the first hash value into blocks according to the number of reference blocks to obtain multiple initial hash value blocks; and then blinding these initial hash value blocks using HMAC, with the HMAC key protected by white-box cryptography. By blinding each initial hash value block using HMAC, the security of the hash value is effectively improved, making the data retrieval process more secure and further enhancing the security of data retrieval.
[0013] In one possible implementation, multiple initial hash value blocks are subjected to HMAC blinding processing to obtain multiple hash value blocks corresponding to the first hash value. This includes: within the trusted execution space of the terminal, applying HMAC blinding processing to multiple initial hash value blocks to obtain multiple hash value blocks corresponding to the first hash value. By applying HMAC blinding processing to the initial hash value corresponding to the first data within the trusted execution space of the terminal, the security of the hash value is further improved.
[0014] In one possible implementation, before comparing the first hash value with the hash values in the hash table, the method further includes receiving the hash table sent by the cloud server. By distributing the hash table to the terminal via the cloud server, it's clear that the cloud server distributes sample data to the terminal in the form of a hash table, effectively protecting data security. Furthermore, the generation of the hash table is implemented on the cloud server, effectively reducing the computational and storage burden on the terminal.
[0015] In one possible implementation, the hash values in the hash table are obtained by the cloud server based on the LSH model, which is trained by the cloud server.
[0016] In one possible implementation, the cloud server trains the LSH model, including: obtaining a set of feature vectors for a reference number of sample data; obtaining a set of irrelevant vectors based on the set of feature vectors and a first specified cosine similarity; obtaining a set of similar vectors based on the set of feature vectors and a second specified cosine similarity, wherein the second specified cosine similarity is greater than the first specified cosine similarity; encoding the set of feature vectors, the set of irrelevant vectors, and the set of similar vectors to obtain a first hash value set corresponding to the set of feature vectors, a second hash value set corresponding to the set of irrelevant vectors, and a third hash value set corresponding to the set of similar vectors; comparing the first hash value set, the second hash value set, and the third hash value set to obtain the Hamming distance between the first hash value set and the second hash value set or the third hash value set; for example, training the LSH model based on the set of irrelevant vectors and the set of similar vectors, specifically, the training needs to maximize the Hamming distance between the first hash value set and the second hash value set, and minimize the Hamming distance between the first hash value set and the third hash value set; and obtaining the LSH model when the Hamming distance meets a threshold range.
[0017] By using the feature vector set of a reference number of sample data, irrelevant vector sets and similar vector sets are derived. Then, the feature vector sets, irrelevant vector sets, and similar vector sets are encoded to obtain the hash value sets corresponding to each vector set. These hash value sets serve as training data for the LSH model, making the training data more comprehensive and thus improving the accuracy of the LSH model.
[0018] In one possible implementation, before obtaining the first hash value corresponding to the feature vector of the first data, the method further includes: receiving parameters of the LSH model within a reference time period sent by the cloud server, adjusting the LSH model, and using the adjusted LSH model to output the first hash value based on the feature vector of the first data. The reference time period can be understood as the period most recent to the present time. That is to say, the cloud server can send the latest parameters of the LSH model to the terminal in real time, enabling the terminal to update the LSH model in real time, effectively ensuring the accuracy of converting the query data into hash values, and laying a solid foundation for subsequently retrieving accurate data.
[0019] Secondly, a data retrieval method is provided, which is applied to a cloud server. The method includes: sending a hash table to the terminal, wherein each hash value in the hash table is obtained by the cloud server based on the Locality Sensitive Hash (LSH) model, and the LSH model is trained by the cloud server; the hash table is used to assist the terminal in determining that the first data belongs to the second data corresponding to the target hash value when the similarity between the first hash value corresponding to the feature vector of the first data and the target hash value in the hash table is greater than or equal to a first threshold.
[0020] In this application, a hash table is generated via a cloud server and sent to the terminal, effectively protecting the data corresponding to the hash table and ensuring data security. Furthermore, performing data retrieval on the terminal effectively prevents the risk of data leakage to the cloud server and the risk of data leakage during data transmission, thus improving the security of data retrieval.
[0021] In one possible implementation, the cloud server trains the LSH model, including: obtaining a set of feature vectors for a reference number of sample data; obtaining a set of irrelevant vectors based on the set of feature vectors and a first specified cosine similarity; obtaining a set of similar vectors based on the set of feature vectors and a second specified cosine similarity, wherein the second specified cosine similarity is greater than the first specified cosine similarity; encoding the set of feature vectors, the set of irrelevant vectors, and the set of similar vectors to obtain a first hash value set corresponding to the set of feature vectors, a second hash value set corresponding to the set of irrelevant vectors, and a third hash value set corresponding to the set of similar vectors; comparing the first hash value set, the second hash value set, and the third hash value set to obtain the Hamming distance between the first hash value set and the second hash value set or the third hash value set; and obtaining the LSH model if the Hamming distance meets a threshold interval.
[0022] By using the feature vector set of a reference number of sample data, irrelevant vector sets and similar vector sets are derived. Then, the feature vector sets, irrelevant vector sets, and similar vector sets are encoded to obtain the hash value sets corresponding to each vector set. These hash value sets serve as training data for the LSH model, making the training data more comprehensive and thus improving the accuracy of the LSH model.
[0023] Thirdly, a data retrieval device is provided, which is applied to a terminal, and the device includes:
[0024] The acquisition module is used to acquire the first hash value corresponding to the feature vector of the first data.
[0025] The determination module is used to determine that the first data belongs to the second data corresponding to the target hash value when the similarity between the first hash value and the target hash value in the hash table is greater than or equal to a first threshold. The hash table is obtained from the cloud server.
[0026] In one possible implementation, the apparatus further includes a generation module for generating retrieval results for which no data was retrieved, provided that the similarity between the first hash value and each hash value in the hash table is less than a threshold.
[0027] In one possible implementation, the apparatus further includes a comparison module for comparing the first hash value with each hash value in the hash table to retrieve the target hash value.
[0028] In one possible implementation, the hash table further includes multiple hash value blocks corresponding to each hash value; the apparatus further includes: a block segmentation module, used to segment the first hash value according to the reference block number to obtain multiple hash value blocks corresponding to the first hash value; and a comparison module, used to: compare the multiple hash value blocks corresponding to the first hash value with the multiple hash value blocks in the hash table, wherein the number of equal hash value blocks corresponding to the target hash value and the multiple hash value blocks corresponding to the first hash value is greater than or equal to a second threshold.
[0029] In one possible implementation, multiple hash value blocks in the hash table are blinded using the HMAC message verification code; the block segmentation module is used to segment the first hash value according to the reference block number to obtain multiple initial hash value blocks; the multiple initial hash value blocks are blinded using HMAC to obtain multiple hash value blocks corresponding to the first hash value.
[0030] In one possible implementation, a block-splitting module is used to perform HMAC blinding processing on multiple initial hash value blocks within the trusted execution space of the terminal to obtain multiple hash value blocks corresponding to the first hash value.
[0031] In one possible implementation, the apparatus further includes a receiving module for receiving a hash table sent by a cloud server.
[0032] In one possible implementation, the hash values in the hash table are obtained by the cloud server based on the LSH model, which is trained by the cloud server.
[0033] In one possible implementation, the cloud server is used to: obtain a set of feature vectors for a reference number of sample data; obtain a set of irrelevant vectors based on the set of feature vectors and a first specified cosine similarity; obtain a set of similar vectors based on the set of feature vectors and a second specified cosine similarity, wherein the second specified cosine similarity is greater than the first specified cosine similarity; encode the set of feature vectors, the set of irrelevant vectors, and the set of similar vectors to obtain a first hash value set corresponding to the set of feature vectors, a second hash value set corresponding to the set of irrelevant vectors, and a third hash value set corresponding to the set of similar vectors; compare the first hash value set, the second hash value set, and the third hash value set to obtain the Hamming distance between the first hash value set and the second hash value set or the third hash value set; and obtain the LSH model if the Hamming distance meets a threshold interval.
[0034] In one possible implementation, the receiving module is further configured to receive parameters of the LSH model within a reference time period sent by the cloud server, adjust the LSH model, and use the adjusted LSH model to output a first hash value based on the feature vector of the first data.
[0035] Fourthly, a data retrieval device is provided, which is applied to a cloud server. The device includes:
[0036] The sending module is used to send a hash table to the terminal. Each hash value in the hash table is obtained by the cloud server based on the LSH model, which is trained by the cloud server. The hash table is used to assist the terminal in determining that the first data belongs to the second data corresponding to the target hash value when the similarity between the first hash value corresponding to the feature vector of the first data and the target hash value in the hash table is greater than or equal to a first threshold.
[0037] In one possible implementation, the apparatus further includes: a training module, configured to: obtain a set of feature vectors for a reference number of sample data; obtain a set of irrelevant vectors based on the set of feature vectors and a first specified cosine similarity; obtain a set of similar vectors based on the set of feature vectors and a second specified cosine similarity, wherein the second specified cosine similarity is greater than the first specified cosine similarity; encode the set of feature vectors, the set of irrelevant vectors, and the set of similar vectors to obtain a first hash value set corresponding to the set of feature vectors, a second hash value set corresponding to the set of irrelevant vectors, and a third hash value set corresponding to the set of similar vectors; compare the first hash value set, the second hash value set, and the third hash value set to obtain the Hamming distance between the first hash value set and the second hash value set or the third hash value set; and obtain an LSH model if the Hamming distance satisfies a threshold interval.
[0038] Fifthly, a data retrieval system is provided, the system comprising:
[0039] A terminal for executing the method described in the first aspect;
[0040] A cloud server is used to execute the method described in the second aspect.
[0041] In a sixth aspect, a terminal is provided, the terminal including a processor coupled to a memory; the memory storing at least one instruction, the at least one instruction being loaded and executed by the processor to enable the terminal to implement the method described in the first aspect.
[0042] In a seventh aspect, a computer program (product) is provided, comprising: computer program code, which, when executed by a computer, causes the computer to perform the methods described in the foregoing aspects.
[0043] In an eighth aspect, a computer-readable storage medium is provided that stores a program or instructions, wherein when the program or instructions are run on a computer, the methods in the above aspects are performed.
[0044] In a ninth aspect, a chip is provided, including a processor for retrieving and executing instructions stored in a memory, causing a computer equipped with the chip to perform the methods described in the preceding aspects.
[0045] In a tenth aspect, another chip is provided, comprising: an input interface, an output interface, a processor, and a memory, wherein the input interface, the output interface, the processor, and the memory are connected via an internal connection path, the processor is used to execute code in the memory, and when the code is executed, a computer with the chip installed performs the methods in the above aspects.
[0046] It should be understood that the beneficial effects achieved by the technical solutions and corresponding possible implementations of the third to tenth aspects of this application can be found in the technical effects of the first and second aspects and their corresponding possible implementations described above, and will not be repeated here. Furthermore, the data retrieval device mentioned in the third aspect can be the chip mentioned in the ninth or tenth aspect, or the data retrieval device can also be the device mentioned in the sixth aspect. Attached Figure Description
[0047] Figure 1 This application provides a schematic diagram of the structure of a terminal according to an embodiment of the present application;
[0048] Figure 2 A schematic diagram of the structure of a data retrieval system provided in an embodiment of this application;
[0049] Figure 3 This is another schematic diagram of the structure of a data retrieval system provided in an embodiment of this application;
[0050] Figure 4 A flowchart illustrating a data retrieval method provided in an embodiment of this application;
[0051] Figure 5 A flowchart illustrating another data retrieval method provided in this application embodiment;
[0052] Figure 6 A schematic diagram of a data retrieval device provided in an embodiment of this application;
[0053] Figure 7 This is another schematic diagram of a data retrieval device provided in an embodiment of this application;
[0054] Figure 8 This is another structural schematic diagram of a terminal provided in an embodiment of this application. Detailed Implementation
[0055] The terminology used in the implementation section of this application is for the purpose of explaining specific embodiments of this application only, and is not intended to limit this application.
[0056] With the rapid development of large language models (LLMs), the data in these models has become increasingly complex. Vector data transformation has become a key technology for processing complex data. This technology can transform various types of data, such as text, images, audio, and video, into high-dimensional vector representations, thereby enabling efficient similarity search and data analysis. This technology has shown great potential in large-scale data storage and retrieval, and is particularly widely used in the field of semantic retrieval.
[0057] Based on this, the data retrieval methods provided by related technologies include: 1) the terminal sends query data such as text, images or audio to the cloud server, and the cloud server converts the query data into a high-dimensional vector; or 2) the terminal directly processes the query data into a high-dimensional vector, and then compares the vector with the vector in the vector database. By comparing the "distance" between the vectors, the data most similar to the query data is found. However, in this way, the user's query data / high-dimensional vector will be revealed to the cloud server, and the user's privacy will be leaked.
[0058] To address the aforementioned technical problems, this application provides a data retrieval method applied to a terminal. The method includes: obtaining a first hash value corresponding to a feature vector of first data; and determining that the first data belongs to second data corresponding to the target hash value if the similarity between the first hash value and a target hash value in a hash table is greater than or equal to a first threshold. The hash table is obtained from a cloud server. It is evident that generating the hash table through a cloud server and sending it to the terminal effectively protects the data corresponding to the hash table, ensuring data security. Furthermore, performing data retrieval on the terminal effectively prevents the risk of data leakage to the cloud server and the risk of data leakage during data transmission, improving the security of data retrieval. Additionally, the terminal uses the first hash value to find second data in the hash table with a similarity greater than or equal to the first threshold to determine if the first data is the same as or similar to the first data. This facilitates subsequent analysis, if the second data is sensitive data, confirming that the first data is also sensitive data, effectively improving the accuracy of data analysis.
[0059] The data retrieval method provided in this application embodiment can be applied to scenarios including, but not limited to, compliance detection of images in a terminal's image library, such as detecting whether an image in the image library is a sensitive image. Alternatively, the application scenario can include image classification scenarios, such as detecting the category to which an image in the image library belongs in order to classify the images. Furthermore, the application scenario can include search application scenarios, such as search applications searching for similar or identical images, information, and products based on an input image. Of course, this application embodiment is not limited to the above application scenarios and may include other application scenarios, which will not be listed here.
[0060] The aforementioned terminals may include mobile phones, personal computers (PCs), laptops, tablets, handheld computers, smart home devices (such as smart TVs, smart screens, large screens, and other devices with displays), in-vehicle computers, etc., and this application embodiment does not impose any limitations on them.
[0061] In one example, the terminal described above may include, for example: Figure 1 The structure of terminal 100 shown.
[0062] Terminal 100 includes a processor 110, a memory 120, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, a display screen 150, an antenna, a wireless communication module 160, etc.
[0063] Processor 110 may include one or more processing units, such as an application processor (AP), graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), and / or neural network processing unit (NPU). These different processing units may be independent devices or integrated into one or more processors.
[0064] The controller can generate operation control signals based on the instruction opcode and timing signals to complete the control of instruction fetching and execution.
[0065] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0066] The charging management module 140 receives charging input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 receives charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 receives wireless charging input via the wireless charging coil of the terminal 100. While charging the battery 142, the charging management module 140 can also supply power to the terminal 100 via the power management module 141.
[0067] The power management module 141 connects the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, providing power to the processor 110, memory 120, external memory, display 150, and wireless communication module 160, etc. The power management module 141 can also monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be located in the same device.
[0068] Terminal 100 implements display functions through a GPU, display screen 150, and application processor. The GPU is a microprocessor for image processing, connected to the display screen 150 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0069] The display screen 150 is used to display images, videos, etc. The display screen 150 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a minimized display, a microLED, a quantum dot light-emitting diode (QLED), etc. In this embodiment, the display screen 150 is also referred to as a screen.
[0070] The wireless communication function of terminal 100 can be implemented through antennas, wireless communication module 160, etc. The antenna is used to transmit and receive electromagnetic wave signals. Each antenna in terminal 100 can be used to cover one or more communication frequency bands. Different antennas can also be reused to improve antenna utilization. Wireless communication module 160 can provide solutions for wireless communication applications on terminal 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), and other wireless communication technologies. Wireless communication module 160 can be one or more devices integrating at least one communication processing module. Wireless communication module 160 receives electromagnetic waves via the antenna, frequency-modulates and filters the electromagnetic wave signals, and sends the processed signal to processor 110. Wireless communication module 160 can also receive signals to be transmitted from processor 110, frequency-modulate and amplify them, and then convert them into electromagnetic waves for radiation via the antenna.
[0071] In some embodiments, the antenna of terminal 100 is coupled to wireless communication module 160, enabling terminal 100 to communicate with networks and other devices via wireless communication technology.
[0072] A digital signal processor (DSP) is used to process digital signals. Besides digital image signals, it can also process other digital signals. For example, when terminal 100 selects a frequency point, the DSP can perform Fourier transforms on the frequency energy.
[0073] Video codecs are used to compress or decompress digital video. Terminal 100 may support one or more video codecs. Thus, terminal 100 can play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG 2, MPEG 3, MPEG 4, etc.
[0074] NPU stands for Neural Network (NN) Computing Processor. By borrowing the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it can rapidly process input information and continuously learn on its own. NPUs can enable intelligent cognitive applications in terminals, such as image recognition, facial recognition, speech recognition, and text understanding.
[0075] The memory 120 can be used to store computer executable program code, which includes instructions. The processor 110 executes various functional applications and data processing of the terminal 100 by running the instructions stored in the memory 120. The memory 120 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc. The data storage area may store data created during the use of the terminal 100 (such as audio data, phonebook, etc.). In addition, the memory 120 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0076] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the terminal. In other embodiments of this application, the terminal may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0077] Of course, the data retrieval method provided in this application embodiment can also be applied to a data retrieval system, such as... Figure 2As shown, the system 10 may include a terminal 100 and a cloud server 200. The cloud server 200 may be used to send a hash table to the terminal 100. The terminal 100 may be used to obtain a first hash value corresponding to the feature vector of the first data, and determine that the first data belongs to the second data corresponding to the target hash value if the similarity between the first hash value and the target hash value in the hash table is greater than or equal to a first threshold. Figure 3 This is a schematic diagram of the structure of another data retrieval system provided in an embodiment of this application, as shown below. Figure 3 As shown, with Figure 2 The difference lies in that a cloud server can at least include a feature vector library, an LSH model training module, a testing module, a block-splitting module, and a blinded LSH library. The feature vector library stores the set of feature vectors. The LSH model training module trains the LSH model. The testing module tests the parameters of the LSH model based on test data. The block-splitting module divides the hash values into blocks. The blinded LSH library stores blinded feature values. The feature vector library provides vector data to the LSH model training module and the block-splitting module, while the testing module verifies the compliance of the LSH model training module's training of the LSH model. After obtaining the LSH model, the vector data from the feature vector library serves as the input to the LSH model, outputting the corresponding hash values. The block-splitting module then divides and blinds these hash values to obtain blinded hash values, forming a hash table, thus creating the blinded LSH library. Furthermore, the HMAC function, LSH model, block-splitting algorithm, and blinded LSH library on the cloud server can all be distributed to terminals. A terminal can at least include an LSH model module, a block-splitting module, a blinding module, and a matching module. The LSH model module outputs the hash value of the query vector (i.e., the first hash value). The chunking module chunks the first hash value to obtain hash value chunks. The blinding module blinds the hash value chunks to obtain blinded hash value chunks. The matching module matches the blinded hash value chunks with the hash value chunks in the hash table to obtain the matching results (or retrieval results). The matching results can include successful matches and failed matches.
[0078] The aforementioned data retrieval system is not limited to a system consisting of a terminal and a cloud server; it can also be a system consisting of at least two cloud servers. This means that one of the cloud servers in the system implements… Figure 2 or Figure 3 The terminal's functionality. For example, one cloud server can be used to send a hash table to another cloud server. The other cloud server is used to obtain a first hash value corresponding to the feature vector of the first data, and if the similarity between the first hash value and the target hash value in the hash table is greater than or equal to a first threshold, determine that the first data belongs to the second data corresponding to the target hash value. Of course, the other cloud server also performs the following... Figure 4The steps performed by the terminal are not listed here. In this embodiment, a system consisting of a terminal and a cloud server is used as an example for detailed explanation.
[0079] The data retrieval method provided in the embodiments of this application will be described in detail below with reference to examples. Figure 4 This is a schematic flowchart of the data retrieval method provided in the embodiments of this application, as shown below. Figure 4 As shown, the method may include: S401-S406 (some of which are optional).
[0080] S401, Cloud server generates hash table.
[0081] For example, S401 can be implemented as follows: The cloud server extracts features from the collected data of the reference quantity to obtain a feature vector set. For example, if the collected data is image data, the cloud server uses a residual neural network (ResNet) model to extract features from the image data, converting the image into a high-dimensional vector representation, i.e., a feature vector. Here, a high-dimensional vector can be understood as a vector with three or more dimensions. For example, if the image data is I, after extraction by the ResNet model, a d-dimensional feature vector V is obtained:
[0082] V = ResNet(I), V∈R d
[0083] Where d represents the dimension of the vector, and V is the feature vector of the input image.
[0084] This process is repeated to obtain the feature vector set. For example, the image library may include image 1, image 2, image 3, and image 4. Inputting image 1, image 2, image 3, and image 4 into the ResNet model yields the feature vectors corresponding to image 1, image 2, image 3, and image 4, respectively. Figure 5 As shown, the feature vector corresponding to image 1 can be: 0.2|0.1|0.7|-0.3|……. The feature vector corresponding to image 2 can be: -0.8|0.4|0.1|0.3|……. The feature vector corresponding to image 3 can be: 0.3|0.5|0.9|-0.6|……. The feature vector corresponding to image 4 can be: 0.1|0.6|-0.5|0.8|……. Here, "|" represents a separator. Furthermore, the feature vector representation is not limited to the above forms; it can also be similar to a string of numbers, such as 0.491214981244. This embodiment does not impose specific limitations.
[0085] Next, the cloud server hashes each feature vector in the feature vector set to obtain a hash value. For example, the cloud server can input each feature vector in the feature vector set into a locality sensitive hash (LSH) model and output the hash value corresponding to each feature vector. These hash values form a hash table.
[0086] The training of the LSH model described above can be as follows: Based on a reference number of sample data, a feature vector set of the reference number of sample data is obtained. The generation of this feature vector set can be found in the relevant description above and will not be repeated here. Then, based on the feature vector set and a first specified cosine similarity, an irrelevant vector set is obtained. For example, the first specified cosine similarity can be less than or equal to 0.3. Based on the feature vector set and a second specified cosine similarity, a similar vector set is obtained. For example, the second specified cosine similarity is between 0.95 and 0.99. Therefore, a vector set V with a specified cosine similarity s to the feature vector V is generated. similar Its expression can be:
[0087]
[0088] Where: s is the specified cosine similarity, and the magnitude of s controls whether the vectors are similar or unrelated vectors. R is a randomly generated high-dimensional vector. The first term represents the projected component. The second term is the orthogonal component, obtained by removing the projection of R onto V.
[0089] Next, the feature vector set, irrelevant vector set, and similar vector set are encoded to obtain the first hash value set corresponding to the feature vector set, the second hash value set corresponding to the irrelevant vector set, and the third hash value set corresponding to the similar vector set. The first, second, and third hash value sets are compared to obtain the Hamming distance between the first and second or third hash value sets. If the Hamming distance meets a threshold range, the LSH model is obtained. For example, 1) Set the initial parameters of the training algorithm; select a set of LSH hyperplanes as initialization parameters based on a normal distribution; 2) Encode the dataset and training set based on the parameters of the current LSH model; 3) Use the Hamming distance difference between the encoding results of the training set and the dataset as the loss function, and determine the update of the LSH parameters based on the loss function evaluation results. Select appropriate parameters to keep based on the parameters set in 1); repeat 2) and 3) until the number of hyperplanes meets the requirements. After such iterations, the data-independent LSH algorithm is transformed into a data-dependent LSH algorithm. The hash function of the hyperplane LSH is defined as follows:
[0090] h(x) = sign(w·x+b)
[0091] Where: x∈R d It is the input vector; w∈R d is a randomly generated hyperplane normal vector; b ~ Uniform[0,δ] is the offset; sign(·) is the sign function.
[0092] By using the feature vector set of a reference number of sample data, irrelevant vector sets and similar vector sets are derived. Then, the feature vector sets, irrelevant vector sets, and similar vector sets are encoded to obtain the hash value sets corresponding to each vector set. These hash value sets serve as training data for the LSH model, making the training data more comprehensive and thus improving the accuracy of the LSH model.
[0093] After obtaining the LSH model, the LSH model is used to encode each feature vector in the feature vector set to generate hash values:
[0094] H(x)=[h1(x),h2(x),…,hk(x)]
[0095] Where: k is the number of hash functions; hi(x) represents the encoding embedding result of the i-th hyperplane hash function on vector x.
[0096] Continuing with the example above, input the feature vectors corresponding to images 1, 2, 3, and 4 into the LSH model to obtain the hash values corresponding to images 1, 2, 3, and 4 respectively. For example... Figure 5 As shown, the hash value corresponding to image 1 is 011101010101…. The hash value corresponding to image 2 is 111010100101…. The hash value corresponding to image 3 is 000110100111…. The hash value corresponding to image 4 is 101011100110…. Figure 5 As shown, a 512-dimensional LSH function is used, which effectively increases the number of LSH functions and reduces the false alarm rate of the scheme.
[0097] The cloud server responsible for training the LSH model and the cloud server that deploys the hash table can be the same or different servers.
[0098] Of course, the cloud server can also send the LSH model to the terminal. Subsequently, the terminal can obtain the hash value corresponding to the feature vector of each data point based on the LSH model. If the parameters of the LSH model are updated, the cloud server sends the parameters of the LSH model within a reference time period (which can be understood as the period most recent to the current time) to the terminal. The terminal receives these parameters and adjusts the LSH model accordingly. The adjusted LSH model is then used to output the first hash value based on the feature vector of the first data point. Alternatively, the cloud server can also send the latest hash table to the terminal.
[0099] To enhance the security of hash values, hash values can be blinded using Hash-based Message Authentication Code (HMAC). The HMAC key is obfuscated using white-box cryptography to obtain the blinded hash value. Blinding can be understood as processing the original data so that the processed data can still meet specific usage requirements without revealing the original sensitive information. Simply put, it makes the data "blurred" or "partially hidden" without affecting its usability in certain scenarios. Therefore, by blinding each hash value using HMAC, the security of the hash value is effectively improved, making the data retrieval process more secure and further enhancing the security of data retrieval. Continuing with the above example, such as... Figure 5 As shown, the hash value of image 1 is “011101010101…”, and after HMAC blinding processing, the hash value obtained is “77b689498aa75252…”. The hash value of image 2 is “111010100101…”, and after HMAC blinding processing, the hash value obtained is “760599d4f63ad98a9…”. The hash value of image 3 is “000110100111…”, and after HMAC blinding processing, the hash value obtained is “cce5bfb898cbb61a7f…”. The hash value of image 4 is “101011100110…”, and after HMAC blinding processing, the hash value obtained is “fd4396b76f9814f56f7…”.
[0100] To refine the granularity of hash values, the hash values corresponding to each feature vector can be divided into blocks according to the number of reference blocks, resulting in multiple hash value blocks corresponding to each feature vector. The number of reference blocks can be set according to actual needs. Hash value block division divides sensitive hash values into blocks, which can then be compared block by block, making the comparison more granular and ensuring more comprehensive data retrieval. Simultaneously, it supports dynamically adjusting the retrieval threshold, greatly enhancing the adaptability and flexibility of the algorithm in different application scenarios. Continuing with the above example, such as... Figure 5 The hash value of image 1 shown is "011101010101...". The reference block number can be 3. Therefore, each block consists of 3 characters, resulting in hash value blocks of "'011', '101', '010', '101'...". To further enhance the security of the hash value, the hash value corresponding to each feature vector can be divided into multiple initial hash value blocks according to the reference block number. Furthermore, HMAC blinding processing is applied to these initial hash value blocks to obtain multiple hash value blocks corresponding to the hash value of each feature vector. Continuing with the above example, as... Figure 5As shown, the hash values of Image 1 after the hash value blinding process are divided into blocks of “'77b6', '8949', '8aa7', '5252'…”.
[0101] Of course, the embodiments in this application are not limited to using HMAC blinding processing; other digest methods, such as SHA3 or SHA256, can also be used. SHA3 and SHA256 are both hash functions in cryptography. They will not be listed one by one in this application embodiment.
[0102] S402, The cloud server sends a hash table to the terminal, and the terminal receives the hash table accordingly.
[0103] As can be seen, the cloud server distributes sample data to the terminal in the form of a hash table, effectively protecting data security. Furthermore, the generation of the hash table is implemented on the cloud server, effectively reducing the computational and storage burden on the terminal.
[0104] S403, The terminal obtains the first hash value corresponding to the feature vector of the first data.
[0105] For example, the terminal can input the feature vector of the first data into the LSH model and output the first hash value. See the relevant description in S401 above; it will not be repeated here. Figure 5 As shown, assuming the first data is image data, the feature vector of this image data is 0.1|0.6|-0.5|0.9|……. Inputting this feature vector into the LSH model yields the first hash value of the first data, which is 101011100111……. Figure 5 As shown, a 512-dimensional LSH function is used, which effectively increases the number of LSH functions and reduces the false alarm rate of the scheme.
[0106] Before executing S403, the method may further include: receiving the parameters and hash table of the LSH model within a reference time period sent by the cloud server; adjusting the LSH model; and using the adjusted LSH model to output a first hash value based on the feature vector of the first data. The cloud server can send the latest parameters of the LSH model to the terminal in real time, enabling the terminal to update the LSH model in real time, effectively ensuring the accuracy of converting the query data into hash values, and laying a solid foundation for subsequently retrieving accurate data.
[0107] To refine the granularity of hash values, the hash table described above also includes multiple hash value blocks corresponding to each hash value. Therefore, after executing S403, the first hash value can be divided into blocks according to the reference block number, resulting in multiple hash value blocks corresponding to the first hash value. Continuing with the above example, as... Figure 5As shown, with 3 reference blocks, the first hash value 101011100111… is divided into blocks to obtain hash value blocks of “'101', '011', '100', '111'…”. Hash value block division separates locally sensitive hash values into blocks, allowing for more refined comparisons and ensuring more comprehensive data retrieval. Furthermore, it supports dynamically adjusting the retrieval threshold, greatly enhancing the algorithm's adaptability and flexibility in different application scenarios.
[0108] To enhance the security of hash values, if multiple hash value blocks in the hash table are all blinded using HMAC (Hash Message Authentication Code), then dividing the first hash value into multiple hash value blocks according to the reference block number can be done as follows: Divide the first hash value into multiple initial hash value blocks according to the reference block number; then apply HMAC blinding processing to these multiple initial hash value blocks to obtain multiple hash value blocks corresponding to the first hash value. See the relevant description in S401 above, which will not be repeated here. By applying HMAC blinding processing to the initial hash value corresponding to the first data within the trusted execution space of the terminal, the security of the hash value is further enhanced. Continuing with the above example, as... Figure 5 As shown, the hash value of the first hash value is divided into blocks "'101', '011', '100', '111'..." and blinded, resulting in blinded hash values (i.e., blinded feature values) of "'77b6', '8949', '8aa7', '5252'...". By using HMAC (Hash Message Authentication Code) to blind each hash value block, the security of the hash value is effectively improved, ensuring the security and privacy of the original data, making the data retrieval process more secure, and further enhancing the security of data retrieval.
[0109] To further enhance the security of the hash value, HMAC blinding processing is applied to multiple initial hash value blocks within the trusted execution space of the terminal, resulting in multiple hash value blocks corresponding to the first hash value. See the relevant description in S401 above; it will not be repeated here. By applying HMAC blinding processing to the initial hash value corresponding to the first data within the trusted execution space of the terminal, the security of the hash value is further enhanced.
[0110] S404. The terminal compares the similarity of the first hash value with each hash value in the hash table and retrieves the target hash value.
[0111] As mentioned above, if the hash table also includes multiple hash value blocks corresponding to each hash value, then S404 can be: comparing the similarity of the multiple hash value blocks corresponding to the first hash value with the multiple hash value blocks in the hash table. If the hash table also contains multiple hash value blocks corresponding to each hash value, then the terminal also performs block processing on the first hash value of the first data to obtain multiple hash value blocks for the first hash value. The terminal compares the multiple hash value blocks of the first hash value with the multiple hash value blocks of each hash value in the hash table. If the number of equal blocks between the multiple hash value blocks corresponding to the target hash value and the multiple hash value blocks corresponding to the first hash value is greater than or equal to a second threshold, then the data corresponding to the target hash value is determined to be the retrieved data of the first data. It can be seen that hash value block segmentation divides locally sensitive hash values into blocks and compares them one by one, making the comparison more refined and ensuring more comprehensive retrieved data.
[0112] Of course, in this application, S404 is not limited to being executed by the terminal; it can also be executed by a cloud server. For example, the hash table can be deployed on a cloud server, and the terminal will send the first hash value of the first data to the cloud server. The cloud server will match the first hash value with each hash value in the hash table to obtain the matching result, and then send the matching result back to the terminal. However, in this embodiment of the application, the terminal is used as the execution subject for description.
[0113] S405. If the similarity between the first hash value and the target hash value in the hash table is greater than or equal to a first threshold, the terminal determines that the first data belongs to the second data corresponding to the target hash value. The hash table is obtained from the cloud server.
[0114] As mentioned above, if the hash table also includes multiple hash value blocks corresponding to each hash value, step S405 involves comparing the similarity of the multiple hash value blocks corresponding to the first hash value with the multiple hash value blocks in the hash table. If the number of hash value blocks corresponding to the target hash value that are equal to the number of hash value blocks corresponding to the first hash value is greater than or equal to a second threshold, a successful match is considered, and the first data is determined to belong to the second data corresponding to the target hash value. For example, if the second data is sensitive data, it can be analyzed that the first data is also sensitive data, effectively improving the accuracy of data analysis.
[0115] S406. If the similarity between the first hash value and each hash value in the hash table is less than the first threshold, the terminal generates a search result for which no data was found.
[0116] As mentioned above, if the hash table also includes multiple hash value blocks corresponding to each hash value, step S406 involves comparing the similarity of the multiple hash value blocks corresponding to the first hash value with the multiple hash value blocks in the hash table. If the number of hash value blocks corresponding to the target hash value that are equal to the number of hash value blocks corresponding to the first hash value is less than a second threshold, the match is considered to have failed, and the data to which the first data belongs has not been matched. For example, if the data corresponding to the hash table is sensitive data, it can be analyzed that the first data is non-sensitive data, effectively improving the accuracy of data analysis.
[0117] The data retrieval method provided by the embodiments of this application has been described above. Corresponding to the above method, the embodiments of this application also provide a data retrieval device. This device is applied to a terminal. The device is used to retrieve data via… Figure 6 Each module shown performs the above... Figure 4 The data retrieval method executed by the terminal. For example... Figure 6 As shown, the data retrieval device 600 provided in this application embodiment includes the following modules.
[0118] The acquisition module 601 is used to acquire the first hash value corresponding to the feature vector of the first data;
[0119] The determination module 602 is used to determine that the first data belongs to the second data corresponding to the target hash value when the similarity between the first hash value and the target hash value in the hash table is greater than or equal to a first threshold. The hash table is obtained from the cloud server.
[0120] In one possible implementation, the apparatus further includes a generation module for generating retrieval results for which no data was retrieved, provided that the similarity between the first hash value and each hash value in the hash table is less than a threshold.
[0121] In one possible implementation, the apparatus further includes a comparison module for comparing the first hash value with each hash value in the hash table to retrieve the target hash value.
[0122] In one possible implementation, the hash table further includes multiple hash value blocks corresponding to each hash value; the apparatus further includes: a block segmentation module, used to segment the first hash value according to the reference block number to obtain multiple hash value blocks corresponding to the first hash value; and a comparison module, used to: compare the multiple hash value blocks corresponding to the first hash value with the multiple hash value blocks in the hash table, wherein the number of equal hash value blocks corresponding to the target hash value and the multiple hash value blocks corresponding to the first hash value is greater than or equal to a second threshold.
[0123] In one possible implementation, multiple hash value blocks in the hash table are blinded using the HMAC message verification code; the block segmentation module is used to segment the first hash value according to the reference block number to obtain multiple initial hash value blocks; the multiple initial hash value blocks are blinded using HMAC to obtain multiple hash value blocks corresponding to the first hash value.
[0124] In one possible implementation, a block-splitting module is used to perform HMAC blinding processing on multiple initial hash value blocks within the trusted execution space of the terminal to obtain multiple hash value blocks corresponding to the first hash value.
[0125] In one possible implementation, the apparatus further includes a receiving module for receiving a hash table sent by a cloud server.
[0126] In one possible implementation, the hash values in the hash table are obtained by the cloud server based on the Locality Sensitive Hash (LSH) model, which is trained by the cloud server.
[0127] In one possible implementation, the cloud server is used to: obtain a set of feature vectors for a reference number of sample data; obtain a set of irrelevant vectors based on the set of feature vectors and a first specified cosine similarity; obtain a set of similar vectors based on the set of feature vectors and a second specified cosine similarity, wherein the second specified cosine similarity is greater than the first specified cosine similarity; encode the set of feature vectors, the set of irrelevant vectors, and the set of similar vectors to obtain a first hash value set corresponding to the set of feature vectors, a second hash value set corresponding to the set of irrelevant vectors, and a third hash value set corresponding to the set of similar vectors; compare the first hash value set, the second hash value set, and the third hash value set to obtain the Hamming distance between the first hash value set and the second hash value set or the third hash value set; and obtain the LSH model if the Hamming distance meets a threshold interval.
[0128] In one possible implementation, the receiving module is further configured to receive parameters of the LSH model within a reference time period sent by the cloud server, adjust the LSH model, and use the adjusted LSH model to output a first hash value based on the feature vector of the first data.
[0129] It should be understood that the above Figure 6 The beneficial effects that the provided device possesses in performing its function are... Figure 4 The data retrieval methods provided have the same beneficial effects, which will not be elaborated upon here. Additionally, Figure 6The provided device, in implementing its functions, is only illustrated by the division of the above-described functional modules. In practical applications, the functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. Furthermore, the device and method embodiments provided in the above embodiments belong to the same concept, and their specific implementation processes are detailed in the method embodiments, and will not be repeated here.
[0130] The data retrieval method provided by the embodiments of this application has been described above. Corresponding to the above method, the embodiments of this application also provide a data retrieval device. This device is applied to a cloud server. The device is used to retrieve data via... Figure 7 Each module shown performs the above... Figure 4 The data retrieval methods performed by the cloud server. For example... Figure 7 As shown in the embodiments of this application, the data retrieval device 700 includes the following modules.
[0131] The sending module 701 is used to send a hash table to the terminal. Each hash value in the hash table is obtained by the cloud server based on the Locality Sensitive Hash (LSH) model, which is trained by the cloud server. The hash table is used to assist the terminal in determining that the first data belongs to the second data corresponding to the target hash value when the similarity between the first hash value corresponding to the feature vector of the first data and the target hash value in the hash table is greater than or equal to a first threshold.
[0132] In one possible implementation, the apparatus further includes: a training module, configured to: obtain a set of feature vectors for a reference number of sample data; obtain a set of irrelevant vectors based on the set of feature vectors and a first specified cosine similarity; obtain a set of similar vectors based on the set of feature vectors and a second specified cosine similarity, wherein the second specified cosine similarity is greater than the first specified cosine similarity; encode the set of feature vectors, the set of irrelevant vectors, and the set of similar vectors to obtain a first hash value set corresponding to the set of feature vectors, a second hash value set corresponding to the set of irrelevant vectors, and a third hash value set corresponding to the set of similar vectors; compare the first hash value set, the second hash value set, and the third hash value set to obtain the Hamming distance between the first hash value set and the second hash value set or the third hash value set; and obtain an LSH model if the Hamming distance satisfies a threshold interval.
[0133] It should be understood that the above Figure 7 The beneficial effects that the provided device possesses in performing its function are... Figure 4 The data retrieval methods provided have the same beneficial effects, which will not be elaborated upon here. Additionally, Figure 7The provided device, in implementing its functions, is only illustrated by the division of the above-described functional modules. In practical applications, the functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. Furthermore, the device and method embodiments provided in the above embodiments belong to the same concept, and their specific implementation processes are detailed in the method embodiments, and will not be repeated here.
[0134] See Figure 8 , Figure 8 A schematic diagram of the structure of an exemplary computer device 800 of this application is shown. The computer device 800 includes at least one processor 801, a memory 803, and at least one network interface 804.
[0135] The processor 801 is, for example, a general-purpose central processing unit (CPU), a digital signal processor (DSP), a network processor (NP), a GPU, a neural-network processing unit (NPU), a data processing unit (DPU), a microprocessor, or one or more integrated circuits or application-specific integrated circuits (ASICs), programmable logic devices (PLDs), other general-purpose processors or other programmable logic devices, discrete gates, transistor logic devices, discrete hardware components, or any combination thereof used to implement the scheme of this application. The PLD is, for example, a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof. The general-purpose processor can be a microprocessor or any conventional processor. It is worth noting that the processor can be a processor supporting an advanced reduced instruction set machine (RISC) machine (ARM) architecture. It can implement or execute the various logic blocks, modules, and circuits described in conjunction with the disclosure of this application. A processor can also be a combination of components that perform computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and so on.
[0136] Optionally, the computer device 800 also includes a bus 802. The bus 802 is used to transmit information between the various components of the computer device 800. The bus 802 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus 802 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 The symbol is represented by only one line, but this does not mean that there is only one bus or one type of bus.
[0137] The memory 803 may be, for example, volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory may be random access memory (RAM), which is used as an external cache.
[0138] By way of example, but not limitation, many forms of ROM and RAM are available. For example, ROM is a compact disc read-only memory (CD-ROM). RAM includes, but is not limited to, static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).
[0139] The memory 803 can also be other types of storage devices capable of storing static information and instructions. Alternatively, it can be other types of dynamic storage devices capable of storing information and instructions. It can also be other optical disc storage, optical disk storage (including compressed optical discs, laser discs, optical discs, digital versatile optical discs, Blu-ray discs, etc.), magnetic disk storage media, or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. The memory 803 may exist independently and be connected to the processor 801 via bus 802. The memory 803 may also be integrated with the processor 801.
[0140] Network interface 804 uses any transceiver-like device for communicating with other devices or communication networks, such as Ethernet, radio access network (RAN), or wireless local area network (WLAN). Network interface 804 can include wired network interfaces and wireless network interfaces. Specifically, network interface 804 can be an Ethernet interface, such as Fast Ethernet (FE), Gigabit Ethernet (GE), Asynchronous Transfer Mode (ATM), WLAN, cellular network, or combinations thereof. The Ethernet interface can be an optical interface, an electrical interface, or a combination thereof. In some embodiments of this application, network interface 804 can be used for computer device 800 to communicate with other devices.
[0141] In specific implementations, as some embodiments, processor 801 may include one or more CPUs, such as Figure 8 The CPU0 and CPU1 shown are examples of processors. Each of these processors can be a single-core processor or a multi-core processor. A processor here can refer to one or more devices, circuits, and / or processing cores used to process data (e.g., computer program instructions).
[0142] In specific implementations, as some methods, the computer device 800 may include multiple processors, such as... Figure 8 The processors 801 and 805 are shown in the diagram. Each of these processors may be a single-core processor or a multi-core processor. Here, "processor" may refer to one or more devices, circuits, and / or processing cores used to process data (such as computer program instructions).
[0143] In some embodiments, memory 803 is used to store program instructions 810 for executing the scheme of this application, and processor 801 can execute the program instructions 810 stored in memory 803. That is, computer device 800 can implement the method provided in the method embodiment through processor 801 and program instructions 810 in memory 803. Figure 4 The method executed. The program instructions 810 may include one or more software modules. Optionally, the processor 801 itself may also store program instructions for executing the scheme of this application.
[0144] In specific implementation, the computer device 800 of this application can correspond to a terminal or cloud server for executing the above method. The processor 801 in the computer device 800 reads the instructions in the memory 803, causing... Figure 8 The computer device 800 shown is capable of performing all or part of the steps in the method embodiments.
[0145] Computer device 800 can also correspond to the above. Figure 6 or Figure 7 The device shown, Figure 6 or Figure 7 Each functional module in the illustrated device is implemented using software from computer device 800. In other words, Figure 6 or Figure 7 The device shown includes functional modules generated by the processor 801 of the computer device 800 after reading the program instructions 810 stored in the memory 803.
[0146] in, Figure 4 Each step of the method shown is implemented through integrated logic circuits in the hardware of the processor of the computer device 800 or through instructions in software form. The steps of the method embodiments disclosed in this application can be directly implemented by the hardware processor, or implemented by a combination of hardware and software modules in the processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other storage media mature in the art. Since this storage medium is located in memory, the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method embodiments; to avoid repetition, they will not be described in detail here.
[0147] In an exemplary embodiment, a data retrieval system is provided, the system including a terminal and a cloud server, the terminal being used to perform... Figure 3 , Figure 4 and Figure 5 The method executed by the terminal is used by the cloud server to execute. Figure 3 , Figure 4 and Figure 5 The methods executed by the cloud server.
[0148] In an exemplary embodiment, a computer program (product) is provided, comprising: computer program code, which, when executed by a computer, causes the computer to perform... Figure 3 , Figure 4 and Figure 5 The method in the middle.
[0149] In an exemplary embodiment, a computer-readable storage medium is provided that stores a program or instructions, which, when executed on a computer, cause the computer to perform the aforementioned actions. Figure 3 , Figure 4 and Figure 5 The method in the middle.
[0150] In an exemplary embodiment, a chip is provided, including a processor for recalling and executing instructions stored in memory, causing a computer with the chip installed to perform... Figure 3 , Figure 4 and Figure 5 The method in the middle.
[0151] In an exemplary embodiment, another chip is provided, including: an input interface, an output interface, a processor, and a memory. The input interface, output interface, processor, and memory are connected via internal interconnection paths. The processor is used to execute code in the memory. When the code is executed, a computer with the chip installed performs... Figure 3 , Figure 4 and Figure 5 The method in the middle.
[0152] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive).
[0153] In this application, the terms "first," "second," etc., are used to distinguish identical or similar items with substantially the same function. It should be understood that there is no logical or temporal dependency between "first," "second," and "nth," nor does it limit the quantity or order of execution. It should also be understood that although the following description uses the terms "first," "second," etc., to describe various elements, these elements should not be limited by the terms. These terms are merely used to distinguish one element from another.
[0154] It should also be understood that, in the various embodiments of this application, the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0155] In this application, the term "at least one" means one or more, and the term "multiple" means two or more. For example, multiple second devices means two or more second devices. The terms "system" and "network" are often used interchangeably herein.
[0156] It should be understood that the terminology used in the description of the various examples herein is for the purpose of describing particular examples only and is not intended to be limiting. As used in the description of the various examples and the appended claims, the singular forms “a” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise.
[0157] It should also be understood that the term "and / or" as used herein refers to and covers any and all possible combinations of one or more of the associated listed items. The term "and / or" describes an association between related objects, indicating that three relationships can exist; for example, A and / or B can represent: A alone, A and B simultaneously, or B alone. Additionally, the character " / " in this application generally indicates that the preceding and following related objects are in an "or" relationship.
[0158] It should also be understood that the terms “if” and “if” can be interpreted as meaning “when” or “upon”, or “in response to determination” or “in response to detection”. Similarly, depending on the context, the phrases “if determination…” or “if detection [the stated condition or event]” can be interpreted as meaning “when determination…”, or “in response to determination…”, or “when detection [the stated condition or event]” or “in response to detection [the stated condition or event]”.
[0159] The above description is merely an embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the principles of this application should be included within the protection scope of this application.
Claims
1. A data retrieval method, characterized by, The method is applied to a terminal, and the method includes: Obtain the first hash value corresponding to the feature vector of the first data; If the similarity between the first hash value and the target hash value in the hash table is greater than or equal to a first threshold, the first data is determined to belong to the second data corresponding to the target hash value. The hash table is obtained from a cloud server.
2. The method according to claim 1, characterized in that, The method further includes: If the similarity between the first hash value and each hash value in the hash table is less than the first threshold, a search result for which no data was found is generated.
3. The method according to claim 1 or 2, characterized in that, Before determining that the first data belongs to the second data corresponding to the target hash value, the method further includes: The first hash value is compared with the hash values in the hash table to retrieve the target hash value.
4. The method according to claim 3, characterized in that, The hash table further includes multiple hash value blocks corresponding to each hash value; after obtaining the first hash value corresponding to the feature vector of the first data, the method further includes: The first hash value is divided into blocks according to the reference block number to obtain multiple hash value blocks corresponding to the first hash value; The step of comparing the hash value of the first data with the hash values in the hash table to retrieve the target hash value includes: The similarity of the multiple hash value blocks corresponding to the first hash value with the multiple hash value blocks in the hash table is compared to retrieve the target hash value. The number of multiple hash value blocks corresponding to the target hash value that are equal to the number of multiple hash value blocks corresponding to the first hash value is greater than or equal to the second threshold.
5. The method according to claim 4, characterized in that, The multiple hash value blocks in the hash table are all blinded using the Hash Message Authentication Code (HMAC). The step of dividing the first hash value into blocks according to the number of reference blocks to obtain multiple hash value blocks corresponding to the first hash value includes: The first hash value is divided into blocks according to the reference block number to obtain multiple initial hash value blocks; The HMAC blinding process is applied to the multiple initial hash value blocks to obtain multiple hash value blocks corresponding to the first hash value.
6. The method according to claim 5, characterized in that, The process of applying the HMAC blinding process to the plurality of initial hash value blocks to obtain a plurality of hash value blocks corresponding to the first hash value includes: Within the trusted execution space of the terminal, the HMAC blinding process is applied to the plurality of initial hash value blocks to obtain the plurality of hash value blocks corresponding to the first hash value.
7. The method according to any one of claims 3-6, characterized in that, Before comparing the first hash value with each hash value in the hash table, the method further includes: Receive the hash table sent by the cloud server.
8. The method according to any one of claims 1-7, characterized in that, Each hash value in the hash table is obtained by the cloud server based on the Locality Sensitive Hash (LSH) model, which is trained by the cloud server.
9. The method according to any one of claims 1-8, characterized in that, Before obtaining the first hash value corresponding to the feature vector of the first data, the method further includes: The parameters of the LSH model within a reference time period sent by the cloud server are received, the LSH model is adjusted, and the adjusted LSH model is used to output the first hash value based on the feature vector of the first data.
10. A data retrieval method, characterized in that, The method is applied to a cloud server, and the method includes: A hash table is sent to the terminal. Each hash value in the hash table is obtained by the cloud server based on the Locality Sensitive Hash (LSH) model, which is trained by the cloud server. The hash table is used to assist the terminal in determining that the first data belongs to the second data corresponding to the target hash value when the similarity between the first hash value corresponding to the feature vector of the first data and the target hash value in the hash table is greater than or equal to a first threshold.
11. The method according to claim 10, characterized in that, The cloud server trains the LSH model, including: Based on the reference number of sample data, a set of feature vectors for the reference number of sample data is obtained; Based on the set of feature vectors and the first specified cosine similarity, an irrelevant set of vectors is obtained; Based on the feature vector set and the second specified cosine similarity, a similar vector set is obtained, wherein the second specified cosine similarity is greater than the first specified cosine similarity; The feature vector set, the irrelevant vector set, and the similar vector set are encoded to obtain a first hash value set corresponding to the feature vector set, a second hash value set corresponding to the irrelevant vector set, and a third hash value set corresponding to the similar vector set; The first hash value set, the second hash value set, and the third hash value set are compared to obtain the Hamming distance between the first hash value set and the second hash value set or the third hash value set; The LSH model is obtained when the Hamming distance meets the threshold range.
12. A data retrieval device, characterized in that, The device is used in a terminal, and the device includes: The acquisition module is used to acquire the first hash value corresponding to the feature vector of the first data. The determining module is used to determine that the first data belongs to the second data corresponding to the target hash value when the similarity between the first hash value and the target hash value in the hash table is greater than or equal to a first threshold. The hash table is obtained from a cloud server.
13. A data retrieval device, characterized in that, The device is used in a cloud server, and the device includes: The sending module is used to send a hash table to the terminal. Each hash value in the hash table is obtained by the cloud server based on the Locality Sensitive Hash (LSH) model, which is trained by the cloud server. The hash table is used to assist the terminal in determining that the first data belongs to the second data corresponding to the target hash value when the similarity between the first hash value corresponding to the feature vector of the first data and the target hash value in the hash table is greater than or equal to a first threshold.
14. A data retrieval system, characterized in that, The system includes: A terminal for performing the method according to any one of claims 1-9; A cloud server for performing the method of claim 10 or 11.
15. A terminal, characterized in that, The terminal includes a processor coupled to a memory; the memory stores at least one instruction, which is loaded and executed by the processor to enable the terminal to implement the method described in any one of claims 1-9.
16. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one instruction, which is loaded and executed by a processor to implement the method of any one of claims 1-9.
17. A computer program product, characterized in that, The computer program product includes a computer program / instruction that is executed by a processor to cause a computer to perform the method described in any one of claims 1-9.
