Approximate nearest neighbor search method and system based on ray tracing intersection, medium, and device
By introducing ray tracing intersecting technology in IVFPQ, screening the necessary coded entries and selectively calculating distances, the problem of insufficient search efficiency of IVFPQ on high-dimensional embedding vectors is solved, and faster search response speed is achieved.
Patent Information
- Application Number
- PCT/CN2024/108295
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-09-14
- Filing Date
- 2024-07-29
- Publication Date
- 2025-03-20
AI Technical Summary
The existing IVFPQ-based approximate neighbor search methods have shortcomings in computing resources and search response speed, especially the exhaustive search cost on high-dimensional embedded vectors.
The approximate neighbor search method based on ray tracing intersection is adopted, and the necessary coded entries are filtered through the ray tracing unit, and the distance calculation operation in the construction of the subspace distance query table is replaced by the ray tracing intersection test, and the distance is selectively calculated to construct the subspace distance query table.
The search efficiency of ANNS based on IVFPQ is significantly improved, and the search response speed is improved by reducing unnecessary distance calculation and query operations of subspace distance lookup tables.
Smart Images

Figure CN2024108295_20032025_PF_FP_ABST
Abstract
Description
Approximate neighbor search method, system, medium and device based on ray tracing intersection Technical Field
[0001] The present application relates to the field of approximate neighbor search, and in particular to an approximate neighbor search method, system, medium and device based on ray tracing intersection. Background Art
[0002] At present, various intelligent applications including generative models widely use embedding vectors to represent various concepts in real life. Its definition is a vector embedded in a high-dimensional space based on the original data through some transformation or training. Therefore, the nearest neighbor search (NNS) is one of the most important operations on the embedding vector. Based on the nearest neighbor search, images, voices, texts, etc. can be searched on similar concepts, such as searching for pictures with similar styles, voice information with similar content, etc. Embedding vectors often exist in high-dimensional space, and their dimensions are often around 10 2 ~10 3 As the dimensionality increases, the cost of performing an exhaustive, precise nearest neighbor search on a large number of embedding vectors rapidly increases. However, in real industrial production scenarios, a certain degree of compromise in search quality is often acceptable. Consequently, the application of approximate nearest neighbor search (ANNS) is becoming increasingly widespread. ANNS trades off a certain degree of search quality in exchange for higher search throughput and faster search response.
[0003] Currently, inverted filter index product quantization (IVFPQ) is widely used in ANNS. However, IVFPQ introduces a large number of unnecessary distance calculations and subspace distance lookup table queries, increasing computing resources and affecting search response speed.
[0004] Summary of the Invention
[0005] The purpose of this application is to provide an approximate neighbor search method, system, medium and device based on ray tracing intersection, which is used to solve the technical problem of how to improve the search efficiency of ANNS based on IVFPQ.
[0006] To achieve the above-mentioned purpose and other related purposes, the first aspect of the present application provides an approximate neighbor search method based on ray tracing intersection, including: filtering search points to obtain coding book entries and subspace-level reverse indexes; screening the coding book entries based on ray tracing intersection to construct a subspace distance query table; querying distances based on the subspace distance query table and the subspace-level reverse index to obtain approximate neighbor search results.
[0007] In an embodiment of the first aspect, filtering the search points to obtain codebook entries includes: performing a first clustering based on an original space to obtain reference search points; and performing a second clustering based on the original space and the reference search points to obtain codebook entries.
[0008] In one embodiment of the first aspect, filtering the codebook entries based on ray tracing intersection to construct a subspace distance query table includes: placing a sphere at the reference search point; filtering necessary codebook entries based on the intersection of the ray projected by the query point projection and the sphere; and calculating the distance between the necessary codebook entry and the query point projection to construct the subspace distance query table.
[0009] In an embodiment of the first aspect, the projected ray at the query point projection intersects the sphere to filter the necessary coding book entries, including: determining a distance threshold based on the reference search point density; calculating the maximum intersection time between the ray and the sphere based on the distance threshold; and filtering the necessary coding book entries based on the maximum intersection time.
[0010] In one embodiment of the first aspect, calculating the distance between the necessary code book entry and the projection of the query point to construct the subspace distance query table includes: placing a sub-sphere within the sphere; and calculating the distance between the necessary code book entry and the projection of the query point based on the intersection of the ray with the sphere and the sub-sphere to construct the subspace distance query table.
[0011] In an embodiment of the first aspect, calculating the distance between the necessary code book entry and the projection of the query point based on the intersection of the ray with the sphere and the sub-sphere includes: when the ray intersects with both the sphere and the sub-sphere, increasing the number of intersections; when the ray does not intersect with both the sphere and the sub-sphere, decreasing the number of intersections; and using the number of intersections as the distance between the necessary code book entry and the projection of the query point.
[0012] In an embodiment of the first aspect, calculating the distance based on the subspace distance query table and the subspace-level reverse index to obtain an approximate neighbor search result includes: obtaining the necessary search point corresponding to the necessary coding book entry based on the subspace-level reverse index; querying the distance between the necessary search point and the projection of the query point based on the subspace distance query table to accumulate and obtain an approximate distance; and sorting the necessary search points based on the approximate distance to obtain the approximate neighbor search result.
[0013] The second aspect of the present application provides an approximate neighbor search system based on ray tracing intersection, including: an encoding module for filtering search points to obtain encoding book entries and subspace-level reverse indexes; a construction module for filtering the encoding book entries based on ray tracing intersection to construct a subspace distance query table; and a calculation module for querying distances based on the subspace distance query table and the subspace-level reverse index to obtain approximate neighbor search results.
[0014] A third aspect of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the approximate neighbor search method based on ray tracing intersection described in the first aspect of the present application is implemented.
[0015] The fourth aspect of the present application provides an electronic device, comprising: a memory storing a computer program; a processor communicating with the memory, and executing the approximate neighbor search method based on ray tracing intersection described in the first aspect of the present application when calling the computer program.
[0016] As described above, the approximate neighbor search method, system, medium and device based on ray tracing intersection provided by the embodiments of the present application have the following beneficial effects: the present application screens necessary coding entries through a ray tracing unit, uses a ray tracing intersection test to replace the distance calculation operation in the construction of the subspace distance query table, and uses the intersection values in different table item subspaces as distances for selective distance calculation, thereby greatly accelerating the search speed at the cost of a very small decrease in search quality, thereby improving the search efficiency of ANNS based on IVFPQ. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] FIG1 is a flow chart showing an approximate neighbor search method based on ray tracing intersection in an embodiment of the present application.
[0018] FIG2 is a schematic flow chart showing an approximate neighbor search method based on ray tracing intersection in an embodiment of the present application.
[0019] FIG3 is a flow chart showing an approximate neighbor search method based on ray tracing intersection in an embodiment of the present application.
[0020] FIG4 is a schematic flow chart showing an approximate neighbor search method based on ray tracing intersection in an embodiment of the present application.
[0021] FIG5 is a schematic flow chart showing an approximate neighbor search method based on ray tracing intersection in an embodiment of the present application.
[0022] FIG6 is a flow chart showing an approximate neighbor search method based on ray tracing intersection in an embodiment of the present application.
[0023] FIG7 is a schematic diagram showing the usage of codebook entries of the DEEP1M dataset in an embodiment of the present application.
[0024] FIG8 is a schematic diagram showing a comparison of the time taken for three steps in the IVFPQ process in an embodiment of the present application.
[0025] FIG9 is a schematic flow chart showing an approximate neighbor search method based on ray tracing intersection in an embodiment of the present application.
[0026] FIG10 is a flow chart showing an approximate neighbor search method based on ray tracing intersection in an embodiment of the present application.
[0027] FIG11 is a schematic diagram showing a comparison of the time taken for three steps in the IVFPQ process in an embodiment of the present application.
[0028] FIG12 is a schematic diagram showing the negative correlation between the total number of intersections between codebook entries and query point projections and the distance between the two in an embodiment of the present application.
[0029] FIG13 is a schematic structural diagram of an approximate neighbor search system based on ray tracing intersection in an embodiment of the present application.
[0030] FIG14 is a schematic diagram showing the structure of an electronic device in an embodiment of the present application.
[0031] Component number description
[0032] 20 encoding modules
[0033] 30 building blocks
[0034] 40 computing modules
[0035] 90 electronic equipment
[0036] 901 Memory
[0037] 902 processor
[0038] 903 Display
[0039] Steps S1 to S3
[0040] Steps S11 to S12
[0041] Steps S111 to S112
[0042] Steps S21 to S23
[0043] Steps S221 to S223
[0044] Steps S2211 to S2212
[0045] Steps S231 to S232
[0046] Steps S31 to S33 DETAILED DESCRIPTION
[0047] The following describes the embodiments of the present application through specific examples. Those skilled in the art can easily understand the other advantages and effects of the present application from the content disclosed in this specification. The present application can also be implemented or applied through other different specific embodiments. The details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that the following embodiments and features in the embodiments can be combined with each other unless they conflict.
[0048] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present application. Therefore, the illustrations only show components related to the present application and are not drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component can be changed at will, and the component layout type may also be more complicated.
[0049] The present application provides an approximate neighbor search method, system, medium and device based on ray tracing intersection, which screens necessary coding entries through a ray tracing unit, uses ray tracing intersection test to replace the distance calculation operation in the construction of the subspace distance query table, and uses the intersection values in different table item subspaces as distances for selective distance calculation, thereby improving the search efficiency of ANNS based on IVFPQ.
[0050] Next, the approximate neighbor search method, system, medium and device based on ray tracing intersection provided by the present application will be described through specific embodiments and drawings.
[0051] As shown in FIG1 , in one embodiment, the approximate nearest neighbor search method based on ray tracing intersection of the present application includes steps S1 to S3:
[0052] S1: Filter search points to obtain codebook entries and subspace-level inverted indices.
[0053] Specifically, as shown in FIG2 , step S1 includes steps S11 to S12:
[0054] S11: Filter the search points to obtain codebook entries.
[0055] Specifically, as shown in FIG3 , step S11 includes steps S111 to S112:
[0056] S111: Perform the first clustering based on the original space to obtain reference search points.
[0057] Specifically, the search vector is organized into multiple clusters (Inverted file index, IVF) in the original space. During the search, several clusters closest to the query vector are selected to quickly filter out search points with a low probability of becoming nearest neighbors.
[0058] S112: Perform a second clustering based on the original space and the reference search point to obtain codebook entries.
[0059] Specifically, the original space is divided into multiple subspaces. The filtered search point projections are clustered again in the subspaces. The cluster centers obtained in the subspaces are organized into a codebook (Product Quantization, PQ), which corresponds to each subspace. Step S112 then uses these cluster centers to encode the projections of the original search points to obtain codebook entries.
[0060] For example, if the original search point vector is in 128-dimensional float data format, step S112 divides the original space into 8 16-dimensional subspaces, and each subspace is divided into 256 clusters. The storage overhead of each search point vector is reduced from 128×sizeof(float)×8 bits to 8×log2(256) bits.
[0061] Specifically, step S112 divides the acquired codebook entries into different regions in each subspace using bounding boxes based on Euclidean distance (L2 distance), and organizes these bounding boxes into a hierarchical tree structure. A bounding box contains several codebook entries or several small bounding boxes, and the bounding box represented by the root node of the tree contains all codebook entries.
[0062] S12: Obtain the subspace-level inverted index.
[0063] Specifically, in each subspace, a key is constructed as a coding entry, and a value is a list of reference search points encoded by the key in the subspace, and these key-value pairs are organized into a subspace-level inverted index.
[0064] S2: Filter the codebook entries based on ray tracing intersection conditions to construct a subspace distance lookup table.
[0065] Specifically, a ray tracing unit (RT Core) is used to filter the necessary encoding entries to the artifact subspace distance lookup table.
[0066] Specifically, as shown in FIG4 , step S2 includes steps S21 to S23:
[0067] S21: placing a sphere at the reference search point.
[0068] S22: Filter necessary coding entries based on the intersection of the ray projected by the query point and the sphere.
[0069] Specifically, as shown in FIG5 , step S22 includes steps S221 to S223 .
[0070] S221: Determine a distance threshold based on the reference search point density.
[0071] Specifically, the distance threshold is dynamically adjusted based on the density of the region where the filtered search point projection (ie, the reference search point) is located in each subspace, so as to select a reasonable distance to filter out unnecessary codebook entries.
[0072] Specifically, as shown in FIG6 , step S21 includes steps S2211 to S2212:
[0073] S2211: Selecting a number of the filtered search points to train a polynomial regression model.
[0074] Specifically, each subspace is further divided into a 100x100 grid, with the number of search point projections in each grid serving as the density of that grid. Several search point projections are then randomly selected, and the distance threshold required for these selected search points to contain their true 100 nearest neighbors is calculated. A polynomial regression model is then trained using the density of these search point projections and the calculated distance threshold.
[0075] S2212: Acquire a query point to dynamically confirm the distance threshold based on the reference search point density in the subspace where the query point is located and the polynomial regression model.
[0076] Specifically, a query point is selected, and the projection vector of the query point is divided into subspaces of the same number and dimension. The reference search point density of the area where the projection of the query point on each subspace is located is obtained. The distance threshold is dynamically determined based on the density and the polynomial regression model.
[0077] S222: Calculate the maximum intersection time between the ray and the sphere based on the distance threshold.
[0078] Specifically, the maximum duration (maximum intersection time) that the ray needs to travel is calculated according to the distance threshold, that is, tmax Since the distance threshold determined in step S221 basically includes the 100 nearest neighbors of the query point projection, the maximum intersection time determined according to the distance threshold can directly screen necessary codebook entries through the rays cast by the query point projection.
[0079] S223: Filter the necessary codebook entries based on the maximum intersection time.
[0080] Specifically, the codebook entries within the maximum continuous travel time range of the ray are the filtered necessary codebook entries.
[0081] Specifically, N reference search points are organized into N circles located on the xOy plane, each with a bounding radius r (distance threshold). Next, a query point is obtained, and the query point projection vector is divided into subspaces of equal number and dimension. In each subspace, a ray is projected from the query point projection toward the Z axis (the maximum travel time of the ray is determined according to steps S221-S222). Any sphere intersected by the ray indicates that the distance between the query point (represented by the ray) and the search point (represented by the circle) is less than the distance threshold, indicating that the entry is required.
[0082] In one embodiment, given a query point and its 100 nearest neighbors, the sparsity of codebook entries is shown in Figure 7. Darker colors represent more nearest neighbors encoded by this entry, while white colors represent entries not used by any of the 100 nearest neighbors. This indicates that the colored points are sparsely distributed. Therefore, filtering out necessary codebook entries can reduce unnecessary subsequent distance calculations and subspace distance lookup table queries.
[0083] S23: Calculate the distance between the necessary codebook entry and the query point projection to construct the subspace distance query table.
[0084] Specifically, as shown in FIG8 , step S23 includes steps S231 to S232 .
[0085] S231: placing a sub-sphere within the sphere.
[0086] Specifically, in order to further save computing resources, step S231 places another sub-sphere within the sphere of each reference search point based on step S21.
[0087] S232: Calculate the distance between the necessary codebook entry and the query point projection according to the intersection of the ray with the sphere and the sub-sphere to construct the subspace distance query table.
[0088] Specifically, a ray tracing unit is placed at the projection of the query point, and the distance is calculated based on the intersection of the output ray of the ray tracing unit with the sphere and the sub-sphere.
[0089] Specifically, as shown in FIG9 , it includes:
[0090] 1) When the ray intersects both the sphere and the sub-sphere (intersecting twice), the intersection count increases by 1.
[0091] 2) When the ray does not intersect with the sphere or the sub-sphere (intersection 0 times), the intersection count is reduced by 1.
[0092] 3) When the ray intersects only with the sphere or the sub-sphere (intersects once), the number of intersections remains unchanged.
[0093] Finally, the number of intersections between the necessary codebook entry and the ray projected by the query point is used as the distance between the necessary codebook entry and the query point projected in the subspace, thereby constructing a subspace distance query table.
[0094] It can be seen that step S232 simplifies the intersection time calculation (distance calculation) required in the ray tracing unit and replaces it with a simple intersection test. The distance between the query point and the necessary coding book entry is directly obtained by calculating the number of intersections, thereby constructing a subspace distance query table, which successfully greatly accelerates the search response speed at the cost of a very small decrease in search quality.
[0095] S3: Query the distance based on the subspace distance query table and the subspace-level inverted index to obtain approximate neighbor search results.
[0096] Specifically, as shown in FIG10 , step S3 includes steps S31 to S33:
[0097] S31: Obtaining necessary search points corresponding to the necessary codebook entries based on the subspace-level inverted index.
[0098] Specifically, step S12 obtains the subspace-level inverted index, which organizes codebook entries and search points into key-value pairs. Therefore, step S31 can obtain the necessary search points corresponding to the necessary codebook entries based on the screening of the necessary codebook entries in step S22.
[0099] S32: Query the distance between the necessary search point and the projection of the query point based on the subspace distance query table to accumulate and obtain an approximate distance.
[0100] Specifically, according to the subspace distance query table obtained by calculation in step S23, the distance between the necessary search point and the projection of the query point is queried, and the distance is accumulated to obtain the approximate distance.
[0101] Specifically, the total number of intersections between each necessary codebook entry and the query point projection in each subspace is directly accumulated and used as the approximate distance for sorting.
[0102] S33: Sort the necessary search points based on the approximate distances to obtain the approximate neighbor search results.
[0103] Specifically, the approximate distance is sorted and the neighbors with the smallest distance are returned according to the number of neighbors required by the user, and finally the approximate neighbor search results are obtained.
[0104] The following is an example of the DEEP1M dataset and further illustrates the optimization principle and effect of this application.
[0105] As shown in Figure 11, in the existing IVFPQ process, after a query point is given, the time spent on filtering is negligible, while the time spent on subspace distance lookup table construction (L2-LUT construction) and distance calculation respectively accounts for a large amount of running time.
[0106] As shown in Figure 12, the total number of intersections between the codebook entries and the query point projections in each subspace has a significant negative correlation with the distance between the codebook entries and the query vector. Therefore, this application makes full use of this relationship and proposes an intersection counting algorithm based on a reward and punishment mechanism, which makes the above negative correlation more obvious and simplifies the distance calculation. Although directly sorting the intersection number as the distance will produce some false positive and false negative errors, this application can greatly accelerate the search response speed at the cost of a very small decrease in search quality, thereby providing users with an adjustable parameter to balance throughput optimization and search quality degradation.
[0107] The protection scope of the approximate neighbor search method based on ray tracing intersection described in the embodiment of the present application is not limited to the execution order of the steps listed in this embodiment. All solutions implemented by adding, reducing, or replacing steps in the prior art based on the principles of the present application are included in the protection scope of the present application.
[0108] An embodiment of the present application also provides an approximate neighbor search system based on ray tracing intersection, which can implement the approximate neighbor search method based on ray tracing intersection described in the present application. However, the implementation device of the approximate neighbor search method based on ray tracing intersection described in the present application includes but is not limited to the structure of the approximate neighbor search system based on ray tracing intersection listed in this embodiment. All structural deformations and replacements of the prior art made according to the principles of the present application are included in the protection scope of the present application.
[0109] As shown in FIG13 , the present application also provides an approximate neighbor search system based on ray tracing intersection, which includes an encoding module 20 , a construction module 30 , and a calculation module 40 .
[0110] The encoding module 20 is used to filter the search points to obtain codebook entries and subspace-level inverted indexes.
[0111] The construction module 30 is configured to filter the codebook entries based on the ray tracing intersection condition to construct a subspace distance lookup table.
[0112] The calculation module 40 is configured to obtain approximate neighbor search results based on the subspace distance query table and the subspace-level inverted index query distance.
[0113] Specifically, in one embodiment, the encoding module 20 performs a first clustering based on the original space to obtain reference search points, and performs a second clustering based on the original space and the reference search points to obtain codebook entries. The encoding module 20 divides the obtained codebook entries into different regions according to the Euclidean distance using a number of bounding boxes in each subspace, and organizes these bounding boxes into a hierarchical tree structure. A bounding box contains a number of codebook entries or a number of small bounding boxes, and the bounding box represented by the root node of the tree contains all codebook entries. In addition, the encoding module constructs a key (Key) as the codebook entry in each subspace, and a value (Value) as a list of reference search points encoded by the key in the subspace, and organizes these key-value pairs into a subspace-level inverted index. Afterwards, the construction module 30 will dynamically determine the distance threshold and use it to calculate the maximum intersection time, screen the necessary codebook entries based on the intersection of the ray projected by the query point and the codebook entry, and directly use the number of intersections as the distance calculation to organize it into a selective subspace distance query table. Finally, calculation module 40 uses the subspace-level inverted index to retrieve the necessary search points corresponding to the required codebook entries. During distance queries, only the distances between the necessary search points and the projection of the query point are accumulated, eliminating the need for extensive subspace distance table lookups. Calculation module 40 then sorts the accumulated distances and returns the number of neighbors with the smallest distances, based on the number of neighbors specified by the user.
[0114] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices or methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of modules / units is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or units 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 devices or modules or units, which can be electrical, mechanical or other forms.
[0115] The modules / units described as separate components may or may not be physically separate, and the components displayed as modules / units may or may not be physical modules, that is, they may be located in one place or distributed across multiple network elements. Some or all of the modules / units may be selected according to actual needs to achieve the purpose of the embodiments of the present application. For example, the functional modules / units in the various embodiments of the present application may be integrated into a processing module, or each module / unit may exist physically separately, or two or more modules / units may be integrated into a single module / unit.
[0116] Those skilled in the art should further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the composition and steps of each example according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0117] As shown in FIG14 , the present application also provides an electronic device, including a memory 901 and a processor 902 .
[0118] The memory 901 is used to store computer programs; preferably, the memory 901 includes: ROM, RAM, disk, USB flash drive, memory card or optical disk, etc., various media that can store program codes.
[0119] Specifically, the memory 901 may include a computer system readable medium in the form of a volatile memory, such as a random access memory (RAM) and / or a cache memory. The electronic device 90 may further include other removable / non-removable, volatile / non-volatile computer system storage media. The memory 901 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the various embodiments of the present application.
[0120] The processor 902 is connected to the memory 901 and is used to execute the computer program stored in the memory 901 so that the electronic device 90 executes the approximate neighbor search method based on ray tracing intersection provided in the embodiment of the present application.
[0121] Preferably, the processor 902 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0122] Preferably, the electronic device 90 in this embodiment may further include a display 903. The display 903 is communicatively connected to the memory 901 and the processor 902, and is configured to display a GUI interaction interface related to the approximate neighbor search method based on ray tracing intersection.
[0123] The embodiment of the present application also provides a computer-readable storage medium. Those skilled in the art will understand that all or part of the steps in the method for implementing the above embodiment can be completed by instructing the processor through a program, and the program can be stored in a computer-readable storage medium, and the storage medium is a non-transitory medium, such as a random access memory, a read-only memory, a flash memory, a hard disk, a solid-state drive, a magnetic tape, a floppy disk, an optical disc, and any combination thereof. The above storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more available media. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a tape), an optical medium (for example, a digital video disc (DVD)), or a semiconductor medium (for example, a solid-state drive (SSD)), etc.
[0124] The embodiment of the present application may also provide a computer program product, the computer program product including one or more computer instructions. When the computer instructions are loaded and executed on a computing device, the process or function described in the embodiment of the present application is generated in whole or in part. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer or data center to another website, computer or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method.
[0125] When the computer program product is executed by a computer, the computer executes the method described in the above method embodiment. The computer program product can be a software installation package. When the above method is needed, the computer program product can be downloaded and executed on the computer.
[0126] The descriptions of the processes or structures corresponding to the above figures have different emphases. For parts that are not described in detail in a certain process or structure, please refer to the relevant descriptions of other processes or structures.
[0127] The above embodiments are merely illustrative of the principles and effects of this application and are not intended to limit this application. Anyone skilled in the art may modify or alter the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or alterations made by one of ordinary skill in the art without departing from the spirit and technical concepts disclosed in this application shall be covered by the claims of this application.
Claims
1. A method for approximate neighbor search based on ray tracing intersection, characterized in that: include: Filter search points to obtain codebook entries and subspace-level inverted indices; Filter the codebook entries based on ray tracing intersections to construct a subspace distance lookup table; Querying the distance based on the subspace distance query table and the subspace-level reverse index to obtain approximate neighbor search results; The filtering of the search points to obtain the codebook entries and the subspace-level inverted indexes includes: Perform the first clustering based on the original space to obtain reference search points; Dividing the original space into a plurality of subspaces to perform a second clustering on the reference search points on the plurality of subspaces, and organizing the second clustering centers of the plurality of subspaces into a codebook to encode the reference search points to obtain codebook entries; and taking the reference search point as a value; Using the codebook entry as a key; Constructing the key-value pairs as the subspace-level inverted index; Wherein, filtering the codebook entries based on the ray tracing intersection to construct the subspace distance query table includes: placing a sphere at the reference search point; Filter necessary coding entries based on the intersection of the ray projected by the query point projection and the sphere; Calculating the distance between the necessary codebook entry and the query point projection to construct the subspace distance query table; wherein screening the necessary codebook entry based on the intersection of the projection ray at the query point projection and the sphere comprises: determining a distance threshold based on the reference search point density; Calculate the maximum intersection time between the ray and the sphere based on the distance threshold; Filtering the necessary codebook entries based on the maximum intersection time; Wherein, calculating the distance between the necessary codebook entry and the query point projection to construct the subspace distance query table includes: place sub-spheres within said sphere; The distance between the necessary codebook entry and the query point projection is calculated according to the intersection of the ray with the sphere and the sub-sphere to construct the subspace distance query table.
2. The approximate nearest neighbor search method based on ray tracing intersection according to claim 1, characterized in that: Calculating the distance between the necessary codebook entry and the query point projection according to the intersection of the ray with the sphere and the sub-sphere includes: When the ray intersects both the sphere and the sub-sphere, the intersection number is increased; When the ray does not intersect with the sphere or the sub-sphere, reducing the number of intersections; The number of intersections is taken as the distance between the necessary codebook entry and the projection of the query point.
3. The approximate nearest neighbor search method based on ray tracing intersection according to claim 2, characterized in that: Calculating the distance based on the subspace distance query table and the subspace-level inverted index to obtain an approximate neighbor search result includes: Obtaining necessary search points corresponding to the necessary codebook entries based on the subspace-level inverted index; Based on the subspace distance query table, query the distance between the necessary search point and the query point projection to accumulate and obtain an approximate distance; The necessary search points are sorted based on the approximate distances to obtain the approximate neighbor search results.
4. An approximate nearest neighbor search system based on ray tracing intersection, characterized in that: include: The encoding module is used to filter the search points to obtain the codebook entries and the subspace-level inverted index; A construction module, configured to filter the codebook entries based on ray tracing intersection conditions to construct a subspace distance lookup table; A calculation module, configured to obtain an approximate nearest neighbor search result based on the subspace distance query table and the subspace-level reverse index query distance; The filtering of the search points to obtain the codebook entries and the subspace-level inverted indexes includes: Perform the first clustering based on the original space to obtain reference search points; Dividing the original space into a plurality of subspaces to perform a second clustering on the reference search points on the plurality of subspaces, and organizing the second clustering centers of the plurality of subspaces into a codebook to encode the reference search points to obtain codebook entries; and taking the reference search point as a value; Using the codebook entry as a key; Constructing the key-value pairs as the subspace-level inverted index; Wherein, filtering the codebook entries based on the ray tracing intersection to construct the subspace distance query table includes: placing a sphere at the reference search point; Filter necessary coding entries based on the intersection of the ray projected by the query point projection and the sphere; Calculating the distance between the necessary codebook entry and the query point projection to construct the subspace distance query table; The method of screening necessary coding entries based on the intersection of the projection ray at the query point projection and the sphere includes: determining a distance threshold based on the reference search point density; Calculate the maximum intersection time between the ray and the sphere based on the distance threshold; Filtering the necessary codebook entries based on the maximum intersection time; Wherein, calculating the distance between the necessary codebook entry and the query point projection to construct the subspace distance query table includes: place sub-spheres within said sphere; The distance between the necessary codebook entry and the query point projection is calculated according to the intersection of the ray with the sphere and the sub-sphere to construct the subspace distance query table.
5. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the approximate neighbor search method based on ray tracing intersection described in any one of claims 1 to 3 is implemented.
6. An electronic device, characterized in that: The device comprises: A memory storing a computer program; A processor is communicatively connected to the memory, and executes the approximate neighbor search method based on ray tracing intersection described in any one of claims 1 to 3 when calling the computer program.
Citation Information
Patent Citations
Data storage method and device and data query method and device
CN113297331A
Spatial data semantic query method and device
CN114491088A
Approximate neighbor search method and system based on ray tracing intersection, medium and equipment
CN117076726A