Feature vector processing method and target object retrieval method
By dividing the eigenvectors into batches and setting the termination scan conditions, the problem of waste of computing resources when searching the eigenvectors is solved, and more efficient scanning operations are achieved, reducing the delay processing time.
Patent Information
- Application Number
- CN202010897986.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-31
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2040-08-31
AI Technical Summary
In the prior art, scanning operations are performed using a fixed proportion or quantity when retrieving feature vectors, resulting in the problem of wasting computing resources.
By dividing the multiple feature vectors to be scanned into multiple batch feature vectors, and setting a termination scan condition, stopping the scanning operation when the condition is met, and obtaining the feature vector to be recalled determined based on the search vector.
It realizes the scanning operation when the termination scan condition is met, avoids unnecessary waste of computing resources and reduces the delay processing time.
Smart Images

Figure CN114201485B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to a method for processing feature vectors and a method for retrieving target objects. Background Art
[0002] In related technologies, a common approach for neighbor retrieval of feature vectors is to first cluster them and then construct an inverted index based on the cluster centers. This common approach scans the inverted index of the N nearest centers to the query vector to find neighboring points.
[0003] The problem with the above method is that since the scanning operation is performed in a fixed ratio or quantity, even if the relevant nearest neighbor points have been found before the scan is completed, the remaining unscanned nodes will still be compared, resulting in unnecessary waste of calculations and the inability to adopt different scanning amounts according to different retrieval vectors.
[0004] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention
[0005] The embodiments of the present application provide a method for processing feature vectors and a method for retrieving target objects, so as to at least solve the technical problem in the related art of using a fixed ratio or quantity to perform scanning operations when retrieving feature vectors, resulting in a waste of computing resources.
[0006] According to one aspect of an embodiment of the present application, a method for processing a feature vector is provided, comprising: dividing a plurality of feature vectors to be scanned into a plurality of batch feature vectors; scanning a first feature vector from at least one batch feature vector of the plurality of batch feature vectors, and stopping the scanning operation when a termination scanning condition is met, wherein the first feature vector is a feature vector to be recalled determined based on a retrieval vector.
[0007] According to another aspect of an embodiment of the present application, a method for retrieving a target object is also provided, including: receiving a retrieval request from a client, wherein the information carried in the above retrieval request includes: a retrieval object; converting the retrieval object into a retrieval vector, wherein the candidate objects to be scanned locally on the server are multiple feature vectors; scanning the above multiple feature vectors in batches to obtain a first feature vector, and stopping the scanning operation when a termination scan condition is met, wherein the above first feature vector is a feature vector to be recalled determined based on the above retrieval vector; restoring the above first feature vector to a target object, and feeding back a retrieval response to the above client, wherein the information carried in the above retrieval response includes: the above target object.
[0008] According to another aspect of an embodiment of the present application, a method for retrieving a target object is also provided, including: sending a retrieval request to a server, wherein the information carried in the retrieval request includes: a retrieval object; receiving a retrieval response fed back by the server, wherein the information carried in the retrieval response includes: a target object, the target object is restored from a first feature vector, the first feature vector is a feature vector to be recalled determined based on a retrieval vector, the retrieval vector is converted from the retrieval object, the first feature vector is obtained by the server converting a local candidate object to be scanned into multiple feature vectors and scanning the multiple feature vectors in batches, and when the scanning termination condition is met, the server stops the scanning operation.
[0009] According to another aspect of an embodiment of the present application, a method for retrieving a target object is also provided, including: obtaining a retrieval request, wherein the information carried in the above retrieval request includes: a retrieval object; converting the retrieval object into a retrieval vector, wherein the candidate objects to be scanned locally by the terminal are multiple feature vectors; scanning the above multiple feature vectors in batches to obtain a first feature vector, and stopping the scanning operation when a scanning termination condition is met, wherein the above first feature vector is a feature vector to be recalled determined based on the above retrieval vector; restoring the above first feature vector to a target object, and displaying the above target object.
[0010] According to another aspect of an embodiment of the present application, a feature vector processing device is also provided, including: a division module, used to divide multiple feature vectors to be scanned into multiple batch feature vectors; a processing module, used to scan a first feature vector from at least one batch feature vector of the above multiple batch feature vectors, and stop the scanning operation when a termination scanning condition is met, wherein the above first feature vector is a feature vector to be recalled determined based on a retrieval vector.
[0011] According to another aspect of an embodiment of the present application, a target object retrieval device is also provided, including: a receiving module for receiving a retrieval request from a client, wherein the information carried in the above retrieval request includes: a retrieval object; a conversion module for converting the retrieval object into a retrieval vector, wherein the candidate objects to be scanned locally on the server are multiple feature vectors; a scanning module for scanning the above multiple feature vectors in batches, obtaining a first feature vector, and stopping the scanning operation when a termination scanning condition is met, wherein the above first feature vector is a feature vector to be recalled determined based on the above retrieval vector; a restoration module for restoring the above first feature vector to a target object, and feeding back a retrieval response to the above client, wherein the information carried in the above retrieval response includes: the above target object.
[0012] According to another aspect of an embodiment of the present application, a target object retrieval device is also provided, including: a request module for sending a retrieval request to a server, wherein the information carried in the above retrieval request includes: a retrieval object; a response module for receiving a retrieval response fed back by the above server, wherein the information carried in the above retrieval response includes: a target object, the above target object is restored from a first feature vector, the above first feature vector is a feature vector to be recalled determined based on a retrieval vector, the above retrieval vector is converted from the above retrieval object, the above first feature vector is obtained by the above server converting a local candidate object to be scanned into multiple feature vectors and scanning the above multiple feature vectors in batches, and when the scanning termination condition is met, the above server stops the scanning operation.
[0013] According to another aspect of an embodiment of the present application, a non-volatile storage medium is also provided, wherein the non-volatile storage medium includes a stored program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute any one of the above-mentioned feature vector processing methods or the above-mentioned target object retrieval methods.
[0014] According to another aspect of an embodiment of the present application, a feature vector processing device is also provided, including: a processor; and a memory, connected to the above-mentioned processor, for providing the above-mentioned processor with instructions for processing the following processing steps: dividing multiple feature vectors to be scanned into multiple batch feature vectors; scanning a first feature vector from at least one batch feature vector of the above-mentioned multiple batch feature vectors, and stopping the scanning operation when a termination scanning condition is met, wherein the above-mentioned first feature vector is a feature vector to be recalled determined based on a retrieval vector.
[0015] In an embodiment of the present application, a termination scanning condition is set by dividing a plurality of feature vectors to be scanned into a plurality of batch feature vectors; a first feature vector is scanned from at least one batch feature vector of the plurality of batch feature vectors, and the scanning operation is stopped when the termination scanning condition is met, wherein the first feature vector is a feature vector to be recalled determined based on a retrieval vector.
[0016] It is easy to notice that the embodiment of the present application sets a termination scanning condition. When scanning multiple feature vectors to be scanned, the multiple feature vectors to be scanned are divided into multiple batch feature vectors, and from at least one batch feature vector of the above multiple batch feature vectors, the feature vector to be recalled determined based on the retrieval vector is scanned, and the scanning operation is stopped when the termination scanning condition is met.
[0017] Therefore, the embodiment of the present application achieves the purpose of stopping the scanning operation when the termination scanning condition is met when retrieving feature vectors, thereby achieving the technical effect of avoiding wasting unnecessary computing resources and reducing delayed processing time, and further solving the technical problem in the related technology of using a fixed ratio or quantity to perform scanning operations when retrieving feature vectors, resulting in waste of computing resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0019] Figure 1 This is a hardware structure block diagram of a computer terminal (or mobile device) for implementing a method for processing feature vectors according to an embodiment of the present application;
[0020] Figure 2 is a flowchart of a method for processing a feature vector according to an embodiment of the present application;
[0021] Figure 3 is a schematic diagram of an optional distribution of fitting probabilities according to an embodiment of the present application;
[0022] Figure 4 is a schematic diagram of connecting two optional fitting probabilities according to an embodiment of the present application;
[0023] Figure 5 is a flowchart of a method for retrieving a target object according to an embodiment of the present application;
[0024] Figure 6 is a flowchart of another method for retrieving a target object according to an embodiment of the present application;
[0025] Figure 7 is a flowchart of another method for retrieving a target object according to an embodiment of the present application;
[0026] Figure 8 is a structural diagram of a feature vector processing device according to an embodiment of the present application;
[0027] Figure 9 is a schematic structural diagram of a target object retrieval device according to an embodiment of the present application;
[0028] Figure 10 is a schematic structural diagram of another target object retrieval device according to an embodiment of the present application;
[0029] Figure 11 is a structural diagram of a feature vector processing device according to an embodiment of the present application;
[0030] Figure 12 It is a structural block diagram of another computer terminal according to an embodiment of the present application. DETAILED DESCRIPTION
[0031] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0033] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following interpretations:
[0034] Nearest Neighbor Search (NNS), also known as "Closest point search," is an optimization problem for finding the closest point in a scale space. The problem is described as follows: Given a set of points S and a target point q∈M in a scale space M, find the point in S that is closest to q. In many cases, M is a multidimensional Euclidean space, and distance is determined by Euclidean distance or Manhattan distance.
[0035] A feature vector is a single attribute extracted from raw data, typically a number. Raw data must be converted into a feature vector before further analysis. For example, after converting an image into a feature vector, the nearest neighbor search method can be used to find similar images in a large number of images.
[0036] Clustering: The unsupervised Kmeans clustering method is generally used to obtain N center points.
[0037] Center point inverted list: Calculate the distance between each eigenvector in the data set and N center points, select the center point with the closest distance as the linked list to which the eigenvector belongs, and thus establish N inverted lists, one for each center point.
[0038] Center inverted list scan: Calculate the distance between the search vector and each feature vector in the center point inverted list, and select the K vectors with the closest distance as the nearest neighbor points. The commonly used distance calculation method is Euclidean distance.
[0039] Recall rate: also known as the recall ratio, refers to the ratio of relevant neighbors found from the index to the true neighbors. For example, when topk = 200, of the 200 vectors obtained by the nearest neighbor search algorithm, 180 are within the 200 closest documents in the entire document, then the recall rate is 90%.
[0040] Scanning: This refers to calculating the distance between the search vector and each vector in a certain feature vector set. For example, the Euclidean distance is calculated with all vectors in the inverted list of a certain center point, and the nearest K vectors are selected.
[0041] Example 1
[0042] According to an embodiment of the present application, an embodiment of a method for processing a feature vector is also provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0043] The method embodiment provided in Example 1 of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 A hardware structure block diagram of a computer terminal (or mobile device) for implementing a feature vector processing method is shown in FIG. Figure 1 As shown, the computer terminal 10 (or mobile device 10) may include one or more (illustrated as 102a, 102b, ..., 102n) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission module 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1More or fewer components than shown, or with Figure 1 Different configurations shown.
[0044] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuitry". The data processing circuitry may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuitry may be a single independent processing module, or may be incorporated in whole or in part into any of the other components of the computer terminal 10 (or mobile device). As described in the embodiments of the present application, the data processing circuitry serves as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0045] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the method for processing feature vectors in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, realizes the above-mentioned method for processing feature vectors. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0046] The transmission device 106 is configured to receive or transmit data via a network. A specific example of the aforementioned network may include a wireless network provided by the communications provider of the computer terminal 10. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.
[0047] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or mobile device).
[0048] Under the above operating environment, this application provides Figure 2 A feature vector processing method shown in Figure 2 is a flow chart of a method for processing a feature vector according to an embodiment of the present application, such as Figure 2 As shown, the processing method of the above feature vector includes:
[0049] Step S202, dividing the multiple feature vectors to be scanned into multiple batches of feature vectors;
[0050] Step S204 , scanning a first feature vector from at least one batch of feature vectors of the plurality of batches of feature vectors, and stopping the scanning operation when a scanning termination condition is met, wherein the first feature vector is a feature vector to be recalled determined based on the retrieval vector.
[0051] In an embodiment of the present application, a termination scanning condition is set by dividing a plurality of feature vectors to be scanned into a plurality of batch feature vectors; a first feature vector is scanned from at least one batch feature vector of the plurality of batch feature vectors, and the scanning operation is stopped when the termination scanning condition is met, wherein the first feature vector is a feature vector to be recalled determined based on a retrieval vector.
[0052] It is easy to notice that the embodiment of the present application sets a termination scanning condition. When scanning multiple feature vectors to be scanned, the multiple feature vectors to be scanned are divided into multiple batch feature vectors, and from at least one batch feature vector of the above multiple batch feature vectors, the feature vector to be recalled determined based on the retrieval vector is scanned, and the scanning operation is stopped when the termination scanning condition is met.
[0053] Therefore, the embodiment of the present application achieves the purpose of stopping the scanning operation when the termination scanning condition is met when retrieving feature vectors, thereby achieving the technical effect of avoiding wasting unnecessary computing resources and reducing delayed processing time, and further solving the technical problem in the related technology of using a fixed ratio or quantity to perform scanning operations when retrieving feature vectors, resulting in waste of computing resources.
[0054] The feature vector processing method provided in the embodiments of the present application can be applied, but is not limited to, in the field of vector retrieval, for example, in scenarios where an inverted index algorithm is used for nearest neighbor retrieval of vectors. As an optional embodiment, the embodiments of the present application can infer whether the feature vector to be recalled is currently close to being retrieved based on the distribution pattern of the scanned feature vectors.
[0055] It should be noted that the executor of the embodiment of the present application is the server. After receiving the retrieval request from the client, the server converts the retrieval object carried in the retrieval request, such as pictures, documents, audio, video, etc., into a retrieval vector, and converts the candidate objects to be scanned locally on the server into multiple feature vectors; the above multiple feature vectors are scanned in batches to obtain the feature vectors to be recalled determined based on the above retrieval vectors, and when the termination scanning conditions are met, the scanning operation is stopped, the above first feature vector is restored to the target object, and a retrieval response carrying the above target object is fed back to the above client.
[0056] In an optional embodiment, the above method further includes:
[0057] Step S302: Obtain a first number and a second number, wherein the first number is the number of second feature vectors in each batch of feature vectors, and the second number is the number of feature vectors in each batch, the second feature vectors are used to replace part of the vectors in the third feature vector, the third feature vector is determined based on the distance between the search vector and the third feature vector, and the number of the third feature vectors is greater than or equal to the number of the first feature vectors;
[0058] Step S304: determining the scanning termination condition based on the first number and the second number.
[0059] In the above optional embodiment, the first number is obtained by obtaining the number of second feature vectors in each batch of feature vectors; the second number is obtained by obtaining the number of feature vectors in each batch; and the above termination scanning condition is determined based on the above first number and the above second number.
[0060] The second eigenvector is used to replace part of the third eigenvector, and the third eigenvector is determined based on the distance between the search vector and the third eigenvector. The number of the third eigenvectors is greater than or equal to the number of the first eigenvectors.
[0061] In an optional embodiment, the above method further includes:
[0062] Step S402: Use a max-heap data structure to store and sort the distances between the search vector and the third eigenvector.
[0063] Among them, the above-mentioned max heap data structure uses a complete binary tree structure to maintain a one-dimensional array, the number of nodes in the above-mentioned max heap data structure is determined by the number of the above-mentioned third eigenvectors, and the value of each node in the above-mentioned max heap data structure is greater than or equal to the values of the left child and right child nodes of the node.
[0064] In an optional embodiment, the above method further includes:
[0065] Step S502: Acquire a first distance and a second distance.
[0066] The first distance is the actual distance between the search vector and the second feature vector currently scanned, and the second distance is the maximum distance between the search vector and the third feature vector stored in the max-heap data structure.
[0067] Step S504: When the first distance is smaller than the second distance, the second eigenvector is used to replace the third eigenvector corresponding to the maximum distance.
[0068] As an optional embodiment, the value of each node in the above-mentioned max-heap data structure is topN. For example, a max-heap of N elements can be used to store the topN eigenvectors (N>=k) with the closest distance. When scanning the inverted list under each central eigenvector (i.e., the central inverted list), each time a eigenvector is compared, the first distance between the search vector and the eigenvector is compared with the second distance between the search vector and the third eigenvector stored in the max-heap data structure. If the first distance is less than the second distance, the second eigenvector is put into the heap, and the second eigenvector is used to replace the third eigenvector corresponding to the maximum distance. The corresponding probability is called the heap entry probability (i.e., the fitting probability).
[0069] When searching the posting list based on the search vector (i.e., central posting list scanning), if the central eigenvectors are randomly scanned in order, then p(i) should obey the P1 distribution in the figure below. As the number of comparison vectors increases, the probability of the second eigenvector entering the heap becomes lower and lower, but relatively mild. If the central eigenvectors are scanned from near to far, then p(i) should obey the following distribution: Figure 3 The distribution of P2 shown in FIG. 1 shows that as the number of comparison vectors increases, the probability of the second eigenvector entering the heap decreases rapidly.
[0070] As an optional embodiment, if the retrieval vector query is the target point q1, that is, the feature vector just compared is already the most recent feature vector to be recalled, then the probability of entering the heap should obey the following formula: Figure 3The P3 distribution shown is steeper than the P2 distribution. Therefore, when encountering P3, if the rate of decrease in the probability of heap entry is found to be very rapid, for example, when the probability of heap entry is detected to be below a preset threshold, the scanning operation can be terminated. This means that there is a high probability that the feature vector to be recalled has been determined based on the search vector. Through the embodiments of the present application, the appropriate amount of scanning can be automatically determined based on the search vector. When a relevant neighbor point is found with a high probability, the scanning and search for subsequent nodes can be automatically stopped, thereby reducing the amount of computation and shortening the computational delay.
[0071] In an optional embodiment, dividing the plurality of feature vectors to be scanned into the plurality of batches of feature vectors includes:
[0072] Step S602, determining the number of feature vectors contained in each batch of feature vectors in the plurality of batches of feature vectors based on the number of the first feature vectors;
[0073] Step S604 : Divide the plurality of feature vectors into the plurality of batch feature vectors according to the number of feature vectors contained in each batch feature vector.
[0074] As an optional embodiment, since the probability of a single feature vector entering the heap is not convenient to calculate, in order to obtain the probability of entering the heap efficiently and accurately, the calculation method in the embodiment of the present application is to calculate the probability of entering the heap once for a batch of data. Optionally, the number of feature vectors contained in each batch feature vector in the above-mentioned multiple batch feature vectors can be determined based on the number of the above-mentioned first feature vectors; and according to the number of feature vectors contained in each batch feature vector, the above-mentioned multiple feature vectors can be divided into the above-mentioned multiple batch feature vectors.
[0075] For example, if 1k vectors are scanned at a time, and 10 of them are put into the heap, the corresponding probability of being put into the heap is considered to be 0.01.
[0076] In an optional embodiment, determining the scanning termination condition based on the first number and the second number includes:
[0077] Step S702: Obtain a first weight, a second weight, and a first fitting probability, wherein the first weight is the current scan weight of the current batch of feature vectors, the second weight is the previous scan weight of the previous batch of feature vectors, and the first fitting probability is the fitting probability of the previous batch of feature vectors;
[0078] Step S704: Calculate the actual probability of the feature vectors of the current batch using the first quantity and the second quantity, and calculate a second fitting probability using the first weight, the second weight, the first fitting probability, and the actual probability, wherein the second fitting probability is the fitting probability of the feature vectors of the current batch;
[0079] Step S706 : determining the scanning termination condition based on the comparison result between the second fitting probability and the preset probability.
[0080] Optionally, in this embodiment, if the user is determining the top k feature vectors to be recalled, the value N >= k is used when selecting the heap to increase the probability of inclusion in the heap, thereby facilitating access to the true value. For example, if k = 10, using topN = 10 indicates a very low probability of inclusion in the heap, making calculation difficult. Therefore, an N value of 1000 or higher is generally appropriate.
[0081] In addition, during the actual scan, the probability of entering the heap may not be completely smooth, and may be similar to Figure 4 As an optional embodiment, the wavy line shown in Figure 4 The straight line shown is a relatively smooth distribution of the eigenvectors, and the termination condition needs to be determined by superimposing the comparison result of the second fitting probability and the preset probability.
[0082] In an optional embodiment, scanning the first feature vector from the at least one batch of feature vectors of the plurality of batches of feature vectors includes:
[0083] Step S802: randomly selecting at least one batch feature vector from the plurality of batch feature vectors based on the search vector, and scanning the first feature vector from the at least one batch feature vector; or
[0084] Step S804 : selecting the at least one batch feature vector from the plurality of batch feature vectors in order of vector distance from near to far based on the search vector, and scanning the first feature vector from the at least one batch feature vector.
[0085] As an optional embodiment, the probability of the current scan vector entering the heap P can be calculated by the following calculation formula in the embodiment of the present application: i (P i The smaller it is, the farther the distance is):
[0086] P i =λ1P i-1 +λ2P i ;
[0087] Among them, P0=1, λ1=1 / e, λ2=1-λ1. Specifically, the above P i is the actual probability, that is, the probability of the actual calculation of the i-th stacking (the amount of vectors in the i-th batch stacked / the total amount of scans in the i-th batch); P iis the fitting probability, P0=1, λ1 is the previous scan weight, which is taken as the mathematical natural logarithm e=2.718281828459045; λ2 is the current scan weight.
[0088] As an optional embodiment, in the embodiment of the present application, the termination condition parameter p is set, when the fitting probability i When it is less than p, it means that the scan vector distance is too far and there is a small probability that it can be selected as the top k, which means the scanning operation is terminated. The default value of p is 0.01. The smaller it is, the more points need to be scanned and the higher the recall rate.
[0089] It should be noted that the calculation formula and parameter values for calculating the probability of the current scan vector entering the heap provided in the embodiment of the present application are not uniquely determined, and can be selected based on training with actual data, so as to implement the embodiment of the present application.
[0090] Through the embodiments of the present application, the number of scans can be dynamically adjusted according to the actual situation of the retrieval vector. When it is found that the scanned vector is already a feature vector to be recalled at a relatively close distance, the scanning operation can be terminated in advance. Thus, while the recall rate remains unchanged, the overall scanning amount can be reduced, thereby improving the retrieval performance.
[0091] Embodiments of the present application provide a method for adaptively searching by dynamically adjusting the number of scans based on the distribution of the distance between the search vector and the documents in the inverted index when scanning an inverted list according to a search vector. Furthermore, when the distance to the nearest event cannot be accurately known in advance, an implementation method is designed that utilizes a max-heap data structure and a heap entry probability to determine whether the current vector is increasingly distant from the search vector. Furthermore, the heap entry probability can be used to design a calculation formula for determining a termination condition and corresponding parameter values.
[0092] In the above operating environment, the embodiment of the present application also provides the following Figure 5 A method for retrieving a target object is shown in FIG. Figure 5 is a flow chart of a method for retrieving a target object according to an embodiment of the present application. Figure 5 As shown, the above-mentioned target object retrieval method includes:
[0093] Step S902: receiving a search request from a client, wherein the information carried in the search request includes: a search object;
[0094] Step S904: converting the search object into a search vector, wherein the candidate objects to be scanned locally on the server are multiple feature vectors;
[0095] Step S906 , scanning the plurality of feature vectors in batches to obtain a first feature vector, and stopping the scanning operation when a termination scanning condition is met, wherein the first feature vector is a feature vector to be recalled determined based on the search vector;
[0096] Step S908: Restore the first feature vector to the target object, and feed back a search response to the client, wherein the information carried in the search response includes: the target object.
[0097] The target object retrieval method provided in the embodiment of the present application can be applied, but is not limited to, in the field of vector retrieval, for example, in a scenario where an inverted index algorithm is used for vector nearest neighbor retrieval.
[0098] It should be noted that the executor of the embodiment of the present application is the server. In the embodiment of the present application, a method of setting a termination scanning condition is adopted. After receiving the retrieval request from the client, the server converts the retrieval object carried in the retrieval request, such as pictures, documents, audio, video, etc., into a retrieval vector, and converts the candidate objects to be scanned locally on the server into multiple feature vectors; the above multiple feature vectors are scanned in batches to obtain the feature vectors to be recalled determined based on the above retrieval vectors, and when the termination scanning condition is met, the scanning operation is stopped, the above first feature vector is restored to the target object, and a retrieval response carrying the above target object is fed back to the above client.
[0099] It is easy to notice that the embodiment of the present application sets a termination scanning condition. When scanning multiple feature vectors to be scanned, the multiple feature vectors to be scanned are divided into multiple batch feature vectors, and from at least one batch feature vector of the above multiple batch feature vectors, the feature vector to be recalled determined based on the retrieval vector is scanned, and the scanning operation is stopped when the termination scanning condition is met.
[0100] Therefore, the embodiment of the present application achieves the purpose of stopping the scanning operation when the termination scanning condition is met when retrieving feature vectors, thereby achieving the technical effect of avoiding wasting unnecessary computing resources and reducing delayed processing time, and further solving the technical problem in the related technology of using a fixed ratio or quantity to perform scanning operations when retrieving feature vectors, resulting in waste of computing resources.
[0101] In the above operating environment, this application also provides Figure 6 Another target object retrieval method shown is Figure 6 is a flowchart of another method for retrieving a target object according to an embodiment of the present application. Figure 6 As shown, the above-mentioned target object retrieval method includes:
[0102] Step S1002: Send a search request to the server, wherein the information carried in the search request includes: the search object;
[0103] Step S1004, receiving the retrieval response fed back by the above-mentioned server, wherein the information carried in the above-mentioned retrieval response includes: the target object, the above-mentioned target object is restored by the first feature vector, the above-mentioned first feature vector is the feature vector to be recalled determined based on the retrieval vector, the above-mentioned retrieval vector is converted from the above-mentioned retrieval object, the above-mentioned first feature vector is obtained by the above-mentioned server converting the local candidate object to be scanned into multiple feature vectors and scanning the above-mentioned multiple feature vectors in batches, and when the termination scanning condition is met, the above-mentioned server stops the scanning operation.
[0104] The target object retrieval method provided in the embodiment of the present application can be applied, but is not limited to, in the field of vector retrieval, for example, in a scenario where an inverted index algorithm is used for vector nearest neighbor retrieval.
[0105] It should be noted that the executing entity of the embodiment of the present application is the client. In the embodiment of the present application, the client sends a retrieval request to the server by setting a termination scanning condition. After receiving the retrieval request from the client, the server converts the retrieval object carried in the retrieval request, such as pictures, documents, audio, video, etc., into a retrieval vector, and converts the candidate objects to be scanned locally on the server into multiple feature vectors; the above multiple feature vectors are scanned in batches to obtain the feature vectors to be recalled determined based on the above retrieval vectors, and when the termination scanning condition is met, the scanning operation is stopped, the above first feature vector is restored to the target object, and a retrieval response carrying the above target object is fed back to the above client.
[0106] It is easy to notice that the embodiment of the present application sets a termination scanning condition. When scanning multiple feature vectors to be scanned, the multiple feature vectors to be scanned are divided into multiple batch feature vectors, and from at least one batch feature vector of the above multiple batch feature vectors, the feature vector to be recalled determined based on the retrieval vector is scanned, and the scanning operation is stopped when the termination scanning condition is met.
[0107] Therefore, the embodiment of the present application achieves the purpose of stopping the scanning operation when the termination scanning condition is met when retrieving feature vectors, thereby achieving the technical effect of avoiding wasting unnecessary computing resources and reducing delayed processing time, and further solving the technical problem in the related technology of using a fixed ratio or quantity to perform scanning operations when retrieving feature vectors, resulting in waste of computing resources.
[0108] In the above operating environment, this application also provides Figure 7 Another target object retrieval method shown is Figure 7is a flowchart of another method for retrieving a target object according to an embodiment of the present application. Figure 7 As shown, the above-mentioned target object retrieval method includes:
[0109] Step S1102: Obtain a search request, wherein the information carried in the search request includes: a search object;
[0110] Step S1104: converting the search object into a search vector, wherein the candidate object to be scanned locally by the terminal is a plurality of feature vectors;
[0111] Step S1106, scanning the plurality of feature vectors in batches to obtain a first feature vector, and stopping the scanning operation when a termination scanning condition is met, wherein the first feature vector is a feature vector to be recalled determined based on the search vector;
[0112] Step S1108: Restore the first feature vector to a target object and display the target object.
[0113] The target object retrieval method provided in the embodiment of the present application can be applied, but is not limited to, in the field of vector retrieval, for example, in a scenario where an inverted index algorithm is used for vector nearest neighbor retrieval.
[0114] It should be noted that the execution subject of the embodiment of the present application is a terminal, that is, the above-mentioned target object retrieval method can be implemented on a single machine. In the embodiment of the present application, the terminal obtains the retrieval request of the client by setting the termination scanning condition, wherein the information carried in the above-mentioned retrieval request includes: retrieval object; converting the retrieval object into a retrieval vector, wherein the candidate objects to be scanned locally by the terminal are multiple feature vectors; scanning the above-mentioned multiple feature vectors in batches to obtain the first feature vector, and stopping the scanning operation when the termination scanning condition is met, wherein the above-mentioned first feature vector is a feature vector to be recalled determined based on the above-mentioned retrieval vector; restoring the above-mentioned first feature vector to the target object, and displaying the above-mentioned target object.
[0115] It is easy to notice that the embodiment of the present application sets a termination scanning condition. When scanning multiple feature vectors to be scanned, the multiple feature vectors to be scanned are divided into multiple batch feature vectors, and from at least one batch feature vector of the above multiple batch feature vectors, the feature vector to be recalled determined based on the retrieval vector is scanned, and the scanning operation is stopped when the termination scanning condition is met.
[0116] Therefore, the embodiment of the present application achieves the purpose of stopping the scanning operation when the termination scanning condition is met when retrieving feature vectors, thereby achieving the technical effect of avoiding wasting unnecessary computing resources and reducing delayed processing time, and further solving the technical problem in the related technology of using a fixed ratio or quantity to perform scanning operations when retrieving feature vectors, resulting in waste of computing resources.
[0117] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0118] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a non-volatile storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the above-mentioned methods of each embodiment of the present application.
[0119] Example 2
[0120] According to an embodiment of the present application, a device embodiment for implementing the above-mentioned feature vector processing method is also provided. Figure 8 is a structural diagram of a feature vector processing device according to an embodiment of the present application, such as Figure 8 As shown, the device includes: a division module 70 and a processing module 72, wherein:
[0121] The division module 70 is used to divide the multiple feature vectors to be scanned into multiple batch feature vectors; the processing module 72 is used to scan a first feature vector from at least one batch feature vector of the above multiple batch feature vectors, and stop the scanning operation when the termination scanning condition is met, wherein the above first feature vector is a feature vector to be recalled determined based on the retrieval vector.
[0122] It should be noted that the above-mentioned division module 70 and processing module 72 correspond to steps S202 to S204 in Example 1. The examples and application scenarios implemented by the two modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above-mentioned Example 1. It should be noted that the above-mentioned modules, as part of the device, can be run in the computer terminal 10 provided in Example 1.
[0123] According to an embodiment of the present application, there is also provided an embodiment of a device for implementing the above-mentioned method for retrieving a target object. Figure 9 is a schematic diagram of a target object retrieval device according to an embodiment of the present application. Figure 9 As shown, the device includes: a receiving module 80, a conversion module 82, a scanning module 84 and a restoration module 86, wherein:
[0124] A receiving module 80 is used to receive a retrieval request from a client, wherein the information carried in the above retrieval request includes: a retrieval object; a conversion module 82 is used to convert the retrieval object into a retrieval vector, wherein the candidate objects to be scanned locally on the server are multiple feature vectors; a scanning module 84 is used to scan the above multiple feature vectors in batches, obtain a first feature vector, and stop the scanning operation when a scanning termination condition is met, wherein the above first feature vector is a feature vector to be recalled determined based on the above retrieval vector; a restoration module 86 is used to restore the above first feature vector to a target object, and feed back a retrieval response to the above client, wherein the information carried in the above retrieval response includes: the above target object.
[0125] It should be noted that the receiving module 80, conversion module 82, scanning module 84, and restoration module 86 described above correspond to steps S902 to S908 in Example 1. The examples and application scenarios implemented by the four modules and the corresponding steps are the same, but are not limited to the contents disclosed in Example 1. It should be noted that the above modules, as part of the device, can be run in the computer terminal 10 provided in Example 1.
[0126] According to an embodiment of the present application, another device embodiment for implementing the above-mentioned target object retrieval method is also provided. Figure 10 is a schematic structural diagram of another target object retrieval device according to an embodiment of the present application, such as Figure 10 As shown, the apparatus includes: a request module 90 and a response module 92, wherein:
[0127] The request module 90 is used to send a retrieval request to the server, wherein the information carried in the above retrieval request includes: a retrieval object; the response module 92 is used to receive a retrieval response fed back by the above server, wherein the information carried in the above retrieval response includes: a target object, the above target object is restored from the first feature vector, the above first feature vector is a feature vector to be recalled determined based on the retrieval vector, the above retrieval vector is converted from the above retrieval object, the above first feature vector is obtained by the above server converting the local candidate object to be scanned into multiple feature vectors and scanning the above multiple feature vectors in batches, and when the termination scanning condition is met, the above server stops the scanning operation.
[0128] It should be noted that the request module 90 and the response module 92 correspond to steps S1002 to S1004 in Example 1. The examples and application scenarios implemented by the two modules and the corresponding steps are the same, but are not limited to the contents disclosed in Example 1. It should be noted that the above modules, as part of the device, can be run in the computer terminal 10 provided in Example 1.
[0129] It should also be noted that the preferred implementation of this embodiment can be found in the relevant description in Example 1 and will not be repeated here.
[0130] Example 3
[0131] According to an embodiment of the present application, an embodiment of a feature vector processing device is also provided. The feature vector processing device can be any computing device in a computing device group. Figure 11 is a structural diagram of a feature vector processing device according to an embodiment of the present application, such as Figure 11 As shown, the feature vector processing device includes: a processor 1000 and a memory 1002, wherein:
[0132] Processor 1000; and memory 1002, connected to the above-mentioned processor 1000, used to provide the above-mentioned processor with instructions for processing the following processing steps: dividing multiple feature vectors to be scanned into multiple batch feature vectors; scanning a first feature vector from at least one batch feature vector of the above-mentioned multiple batch feature vectors, and stopping the scanning operation when a termination scanning condition is met, wherein the above-mentioned first feature vector is a feature vector to be recalled determined based on the retrieval vector.
[0133] In an embodiment of the present application, a termination scanning condition is set by dividing a plurality of feature vectors to be scanned into a plurality of batch feature vectors; a first feature vector is scanned from at least one batch feature vector of the plurality of batch feature vectors, and the scanning operation is stopped when the termination scanning condition is met, wherein the first feature vector is a feature vector to be recalled determined based on a retrieval vector.
[0134] It is easy to notice that the embodiment of the present application sets a termination scanning condition. When scanning multiple feature vectors to be scanned, the multiple feature vectors to be scanned are divided into multiple batch feature vectors, and from at least one batch feature vector of the above multiple batch feature vectors, the feature vector to be recalled determined based on the retrieval vector is scanned, and the scanning operation is stopped when the termination scanning condition is met.
[0135] Therefore, the embodiment of the present application achieves the purpose of stopping the scanning operation when the termination scanning condition is met when retrieving feature vectors, thereby achieving the technical effect of avoiding wasting unnecessary computing resources and reducing delayed processing time, and further solving the technical problem in the related technology of using a fixed ratio or quantity to perform scanning operations when retrieving feature vectors, resulting in waste of computing resources.
[0136] It should also be noted that the preferred implementation of this embodiment can be found in the relevant description in Example 1 and will not be repeated here.
[0137] Example 4
[0138] According to an embodiment of the present application, a computer terminal embodiment is also provided, which can be any computer terminal device in a computer terminal group. Optionally, in this embodiment, the computer terminal can also be replaced by a terminal device such as a mobile terminal.
[0139] Optionally, in this embodiment, the computer terminal may be located in at least one network device among a plurality of network devices of a computer network.
[0140] In this embodiment, the computer terminal may execute the program code of the following steps in the feature vector processing: dividing the plurality of feature vectors to be scanned into a plurality of batch feature vectors; scanning a first feature vector from at least one batch feature vector of the plurality of batch feature vectors, and stopping the scanning operation when a termination scanning condition is met, wherein the first feature vector is a feature vector to be recalled determined based on the retrieval vector.
[0141] In this embodiment, the above-mentioned computer terminal can execute the program code of the following steps in the processing of feature vectors: receiving a retrieval request from a client, wherein the information carried in the above-mentioned retrieval request includes: a retrieval object; converting the retrieval object into a retrieval vector, wherein the candidate objects to be scanned locally on the server are multiple feature vectors; scanning the above-mentioned multiple feature vectors in batches to obtain a first feature vector, and stopping the scanning operation when the termination scanning condition is met, wherein the above-mentioned first feature vector is a feature vector to be recalled determined based on the above-mentioned retrieval vector; restoring the above-mentioned first feature vector to a target object, and feeding back a retrieval response to the above-mentioned client, wherein the information carried in the above-mentioned retrieval response includes: the above-mentioned target object.
[0142] In this embodiment, the computer terminal can execute the program code of the following steps in the processing of feature vectors: sending a retrieval request to the server, wherein the information carried in the retrieval request includes: a retrieval object; receiving a retrieval response fed back by the server, wherein the information carried in the retrieval response includes: a target object, the target object is restored from the first feature vector, the first feature vector is a feature vector to be recalled determined based on the retrieval vector, the retrieval vector is converted from the retrieval object, the first feature vector is obtained by the server converting the local candidate object to be scanned into multiple feature vectors and scanning the multiple feature vectors in batches, and when the scanning termination condition is met, the server stops the scanning operation.
[0143] Optionally, Figure 12 is a structural block diagram of another computer terminal according to an embodiment of the present application, such as Figure 12 As shown, the computer terminal may include: one or more (only one is shown in the figure) processors 1102 , a memory 1104 , and a peripheral interface 1106 .
[0144] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the processing and device of the feature vector in the embodiment of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, realizes the above-mentioned feature vector processing method. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories can be connected to the computer terminal via a network. Examples of the above-mentioned network include but are not limited to the Internet, corporate intranet, local area network, mobile communication network and combinations thereof.
[0145] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: dividing the multiple feature vectors to be scanned into multiple batch feature vectors; scanning a first feature vector from at least one batch feature vector of the above multiple batch feature vectors, and stopping the scanning operation when the termination scanning condition is met, wherein the above first feature vector is a feature vector to be recalled determined based on the retrieval vector.
[0146] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: receive a retrieval request from the client, wherein the information carried in the above retrieval request includes: a retrieval object; convert the retrieval object into a retrieval vector, wherein the candidate objects to be scanned locally on the server are multiple feature vectors; scan the above multiple feature vectors in batches to obtain a first feature vector, and stop the scanning operation when the termination scanning condition is met, wherein the above first feature vector is a feature vector to be recalled determined based on the above retrieval vector; restore the above first feature vector to a target object, and feed back a retrieval response to the above client, wherein the information carried in the above retrieval response includes: the above target object.
[0147] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: sending a retrieval request to the server, wherein the information carried in the above retrieval request includes: the retrieval object; receiving a retrieval response fed back by the above server, wherein the information carried in the above retrieval response includes: the target object, the above target object is restored by the first feature vector, the above first feature vector is a feature vector to be recalled determined based on the retrieval vector, the above retrieval vector is converted from the above retrieval object, the above first feature vector is obtained by the above server converting the local candidate object to be scanned into multiple feature vectors and scanning the above multiple feature vectors in batches, and when the termination scanning condition is met, the above server stops the scanning operation.
[0148] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: obtain a retrieval request, wherein the information carried in the above retrieval request includes: a retrieval object; convert the retrieval object into a retrieval vector, wherein the candidate objects to be scanned locally by the terminal are multiple feature vectors; scan the above multiple feature vectors in batches to obtain the first feature vector, and stop the scanning operation when the termination scanning condition is met, wherein the above first feature vector is a feature vector to be recalled determined based on the above retrieval vector; restore the above first feature vector to a target object, and display the above target object.
[0149] According to an embodiment of the present application, a termination scanning condition is set, by dividing multiple feature vectors to be scanned into multiple batch feature vectors; scanning a first feature vector from at least one batch feature vector of the multiple batch feature vectors, and stopping the scanning operation when the termination scanning condition is met, wherein the first feature vector is a feature vector to be recalled determined based on the retrieval vector.
[0150] It is easy to notice that the embodiment of the present application sets a termination scanning condition. When scanning multiple feature vectors to be scanned, the multiple feature vectors to be scanned are divided into multiple batch feature vectors, and from at least one batch feature vector of the above multiple batch feature vectors, the feature vector to be recalled determined based on the retrieval vector is scanned, and the scanning operation is stopped when the termination scanning condition is met.
[0151] Therefore, the embodiment of the present application achieves the purpose of stopping the scanning operation when the termination scanning condition is met when retrieving feature vectors, thereby achieving the technical effect of avoiding wasting unnecessary computing resources and reducing delayed processing time, and further solving the technical problem in the related technology of using a fixed ratio or quantity to perform scanning operations when retrieving feature vectors, resulting in waste of computing resources.
[0152] It can be understood by those skilled in the art that Figure 12 The structure shown is for illustration only, and the computer terminal may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a handheld computer, a mobile Internet device (MID), a PAD, or other terminal devices. Figure 12 It does not limit the structure of the above electronic device. For example, the computer terminal 11 may also include Figure 12 More or fewer components (such as network interfaces, display devices, etc.) shown in, or with Figure 12 Different configurations shown.
[0153] A person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable non-volatile storage medium. The non-volatile storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0154] Example 5
[0155] According to an embodiment of the present application, an embodiment of a non-volatile storage medium is further provided. Optionally, in this embodiment, the non-volatile storage medium can be used to store the program code executed by any one of the above-mentioned feature vector processing methods or the above-mentioned target object retrieval method provided in the above-mentioned embodiment 1.
[0156] Optionally, in this embodiment, the non-volatile storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.
[0157] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for performing the following steps: dividing multiple feature vectors to be scanned into multiple batch feature vectors; scanning a first feature vector from at least one batch feature vector of the above multiple batch feature vectors, and stopping the scanning operation when a termination scanning condition is met, wherein the above first feature vector is a feature vector to be recalled determined based on the retrieval vector.
[0158] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for performing the following steps: receiving a retrieval request from a client, wherein the information carried in the retrieval request includes: a retrieval object; converting the retrieval object into a retrieval vector, wherein the candidate objects to be scanned locally on the server are multiple feature vectors; scanning the multiple feature vectors in batches to obtain a first feature vector, and stopping the scanning operation when a scanning termination condition is met, wherein the first feature vector is a feature vector to be recalled determined based on the retrieval vector; restoring the first feature vector to a target object, and feeding back a retrieval response to the client, wherein the information carried in the retrieval response includes: the target object.
[0159] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: sending a retrieval request to the server, wherein the information carried in the retrieval request includes: a retrieval object; receiving a retrieval response fed back by the server, wherein the information carried in the retrieval response includes: a target object, the target object is restored from a first feature vector, the first feature vector is a feature vector to be recalled determined based on the retrieval vector, the retrieval vector is converted from the retrieval object, the first feature vector is obtained by the server converting the local candidate object to be scanned into multiple feature vectors and scanning the multiple feature vectors in batches, and when the scanning termination condition is met, the server stops the scanning operation.
[0160] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for performing the following steps: obtaining a retrieval request, wherein the information carried in the above retrieval request includes: a retrieval object; converting the retrieval object into a retrieval vector, wherein the candidate objects to be scanned locally by the terminal are multiple feature vectors; scanning the above multiple feature vectors in batches to obtain a first feature vector, and stopping the scanning operation when the termination scanning condition is met, wherein the above first feature vector is a feature vector to be recalled determined based on the above retrieval vector; restoring the above first feature vector to a target object, and displaying the above target object.
[0161] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0162] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0163] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0164] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0165] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0166] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable non-volatile storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a non-volatile storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned non-volatile storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk, etc. Various media that can store program codes.
[0167] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for retrieving a target object, characterized in that: include: Receiving a search request from a client, wherein the information carried in the search request includes: a search object; Converting the search object into a search vector, wherein the candidate objects to be scanned locally on the server are multiple feature vectors; Scanning the multiple feature vectors in batches to obtain a first feature vector, and stopping the scanning operation when a termination scanning condition is met, wherein the first feature vector is a feature vector to be recalled determined based on the retrieval vector, and the termination scanning condition is determined based on a first quantity and a second quantity, the first quantity being the number of second feature vectors in each batch of feature vectors, and the second quantity being the number of feature vectors in each batch, the second feature vectors being used to replace part of a third feature vector, the third feature vector being determined based on a distance between the retrieval vector and the third feature vector, and the number of the third feature vectors being greater than or equal to the number of the first feature vectors; The first feature vector is restored to a target object, and a search response is fed back to the client, wherein the information carried in the search response includes: the target object.
2. A method for processing a feature vector, characterized in that: include: Dividing the multiple feature vectors to be scanned into multiple batch feature vectors; Scan a first feature vector from at least one batch feature vector of the plurality of batch feature vectors, and stop the scanning operation when a termination scanning condition is met, wherein the first feature vector is a feature vector to be recalled determined based on a retrieval vector, and the termination scanning condition is determined based on a first quantity and a second quantity, the first quantity being the number of second feature vectors in each batch feature vector, and the second quantity being the number of each batch feature vector, the second feature vector being used to replace part of a third feature vector, the third feature vector being determined based on a distance between the retrieval vector and the third feature vector, and the number of the third feature vectors being greater than or equal to the number of the first feature vectors.
3. The method according to claim 2, characterized in that The method further comprises: A max-heap data structure is used to store and sort the distances between the search vector and the third eigenvector, wherein the max-heap data structure maintains a one-dimensional array using a complete binary tree structure, the number of nodes in the max-heap data structure is determined by the number of the third eigenvectors, and the value of each node in the max-heap data structure is greater than or equal to the values of the left child and right child nodes of the node.
4. The method according to claim 3, characterized in that The method further comprises: Obtaining a first distance and a second distance, wherein the first distance is an actual distance between the search vector and the second feature vector currently scanned, and the second distance is a maximum distance between the search vector and the third feature vector stored in the max heap data structure; When the first distance is smaller than the second distance, the second eigenvector is used to replace the third eigenvector corresponding to the maximum distance.
5. The method according to claim 2, characterized in that Dividing the plurality of feature vectors to be scanned into the plurality of batch feature vectors includes: Determining the number of feature vectors included in each batch of feature vectors in the plurality of batch feature vectors based on the number of the first feature vectors; The plurality of feature vectors are divided into the plurality of batch feature vectors according to the number of feature vectors contained in each batch feature vector.
6. The method according to claim 2, characterized in that Determining the scanning termination condition based on the first number and the second number includes: Obtain a first weight, a second weight, and a first fitting probability, wherein the first weight is the current scan weight of the current batch of feature vectors, the second weight is the preceding scan weight of the previous batch of feature vectors, and the first fitting probability is the fitting probability of the previous batch of feature vectors; Calculating an actual probability of feature vectors of the current batch using the first quantity and the second quantity, and calculating a second fitting probability using the first weight, the second weight, the first fitting probability, and the actual probability, wherein the second fitting probability is the fitting probability of the feature vectors of the current batch; The scanning termination condition is determined based on a comparison result between the second fitting probability and a preset probability.
7. The method according to claim 2, characterized in that Scanning the first feature vector from the at least one batch feature vector of the plurality of batch feature vectors includes: Randomly select the at least one batch feature vector from the plurality of batch feature vectors based on the search vector, and scan the first feature vector from the at least one batch feature vector; or, The at least one batch feature vector is selected from the plurality of batch feature vectors in an order of vector distance from near to far based on the search vector, and the first feature vector is scanned from the at least one batch feature vector.
8. A method for retrieving a target object, characterized in that: include: Obtaining a search request, wherein the information carried in the search request includes: a search object; Converting the search object into a search vector, wherein the candidate object to be scanned locally on the terminal is a plurality of feature vectors; Scanning the multiple feature vectors in batches to obtain a first feature vector, and stopping the scanning operation when a termination scanning condition is met, wherein the first feature vector is a feature vector to be recalled determined based on the retrieval vector, and the termination scanning condition is determined based on a first quantity and a second quantity, the first quantity being the number of second feature vectors in each batch of feature vectors, and the second quantity being the number of feature vectors in each batch, the second feature vectors being used to replace part of a third feature vector, the third feature vector being determined based on a distance between the retrieval vector and the third feature vector, and the number of the third feature vectors being greater than or equal to the number of the first feature vectors; The first feature vector is restored to a target object, and the target object is displayed.
9. A method for retrieving a target object, characterized in that: include: Sending a search request to the server, wherein the information carried in the search request includes: the search object; Receive a retrieval response fed back by the server, wherein the information carried in the retrieval response includes: a target object, the target object is restored from a first feature vector, the first feature vector is a feature vector to be recalled determined based on a retrieval vector, the retrieval vector is converted from the retrieval object, the first feature vector is obtained by the server converting a local candidate object to be scanned into multiple feature vectors and scanning the multiple feature vectors in batches, and when a termination scan condition is met, the server stops the scanning operation, the termination scan condition is determined based on a first quantity and a second quantity, the first quantity is the number of second feature vectors in each batch of feature vectors, the second quantity is the number of feature vectors in each batch, the second feature vector is used to replace part of the vector in the third feature vector, the third feature vector is determined based on the distance between the retrieval vector and the third feature vector, and the number of the third feature vectors is greater than or equal to the number of the first feature vectors.
10. A non-volatile storage medium, characterized in that: The non-volatile storage medium includes a stored program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the feature vector processing method described in any one of claims 2 to 7, and the target object retrieval method described in claims 1, 8, and 9.
11. A feature vector processing device, characterized in that: include: processor; as well as A memory, connected to the processor, configured to provide the processor with instructions for processing the following processing steps: Dividing the multiple feature vectors to be scanned into multiple batch feature vectors; Scan a first feature vector from at least one batch feature vector of the plurality of batch feature vectors, and stop the scanning operation when a termination scanning condition is met, wherein the first feature vector is a feature vector to be recalled determined based on a retrieval vector, and the termination scanning condition is determined based on a first quantity and a second quantity, the first quantity being the number of second feature vectors in each batch feature vector, and the second quantity being the number of each batch feature vector, the second feature vector being used to replace part of a vector in a third feature vector, the third feature vector being determined based on a distance between the retrieval vector and the third feature vector, and the number of the third feature vectors being greater than or equal to the number of the first feature vectors.
Citation Information
Patent Citations
Vector retrieval method, device and apparatus
CN110209895A