A cross-modal vector query method, device and medium based on dynamic graph indexing
By constructing a dynamic graph index in cross-modal queries and incrementally updating the graph index using the nearest neighbor information of the query vector, the problem of search path mismatch caused by inconsistent modality distribution in cross-modal queries is solved, improving query efficiency and recall, and supporting dynamic updates and scalability of large-scale data.
Patent Information
- Application Number
- CN202610997986.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-06
- Publication Date
- 2026-11-24
AI Technical Summary
Existing cross-modal vector query methods suffer from several problems in cross-modal query scenarios, including search path mismatch due to inconsistency between the distribution of the query modality and the baseline modality, low utilization efficiency of auxiliary query vectors, skewed query coverage, insufficient updating of adjacency relationships, decreased connectivity of graph structure after dynamic updates, and storage and computational limitations in large-scale scenarios.
By acquiring the baseline vector and query vector, an initial graph index is constructed, and the query vector is introduced incrementally in batches. The adjacency relationship of the graph index is updated using the nearest neighbor vector set of the query vector in the baseline vector set. Combined with the coverage-aware adaptive pruning and full-neighborhood-aware projection mechanism, the graph index is dynamically updated, supporting hierarchical storage and parallel computing of hundreds of millions of data.
It improves the recall and efficiency of cross-modal queries, reduces redundant construction overhead, improves the connectivity and query path quality of graph indexes, and supports scalability in dynamic data updates and large-scale data scenarios.
Smart Images

Figure CN123157941A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of vector database and approximate nearest neighbor retrieval technology, and particularly relates to a cross-modal vector query method, device, and medium based on dynamic graph index. Background Technology
[0002] With the development of multimodal data systems, search engines, recommendation systems, and vector databases, cross-modal vector querying has become an important technology in the management of massive unstructured data. Cross-modal vector querying typically refers to mapping data from different modalities such as text, images, videos, and audio to the same vector space through a multimodal representation learning model, and using data from one modality as the query to find semantically relevant objects in a dataset from another modality. For example, querying for an image using text, querying for text using an image, or querying for video using text. Since the base vector set is usually large, practical systems generally need to use approximate nearest neighbor search techniques to construct a vector index to avoid exhaustively calculating distances to all base vectors.
[0003] Existing approximate nearest neighbor search methods typically include inverted indexing methods, quantization-based indexing methods, and graph-based indexing methods. Among them, graph-based indexing methods, by establishing adjacency relationships between reference vectors and performing greedy or bundle search along the graph structure during the query phase, can achieve good query efficiency with high recall. However, these methods are mostly designed for single-modal or identically distributed query scenarios, meaning that the query vector and the reference vector are assumed to follow the same or similar data distribution. The adjacency relationships in the graph index mainly reflect the local geometric proximity relationships within the reference vector space.
[0004] In cross-modal vector query scenarios, query data and reference data originate from different modalities. Even if they are mapped to the same shared vector space, there may still be significant differences between the distribution of query vectors and the distribution of reference vectors, i.e., there are modal gaps or out-of-distribution query problems. Therefore, the adjacency relationships established solely based on the distance between reference vectors in traditional graph indexes may not be able to form an effective search path to the semantically relevant region of the query, easily leading to longer search paths, increased distance calculations, decreased recall, and reduced query throughput.
[0005] To alleviate the aforementioned problems, some existing cross-modal vector query methods introduce auxiliary query vectors into graph index construction. This involves first obtaining the set of nearest neighbor vectors of the auxiliary query vector within the baseline vector set, and then supplementing the graph index with query-aware adjacency relationships based on this set, making the graph structure more closely resemble the query modality distribution. However, such methods still have significant drawbacks in practical applications.
[0006] First, existing methods typically rely on a pre-defined set of auxiliary query vectors for index construction, making it difficult to determine the amount of auxiliary query vectors used based on actual changes in graph index quality. Once the graph structure has stabilized, introducing more auxiliary query vectors often only triggers repeated nearest neighbor calculations and adjacency updates, resulting in redundant construction overhead and making it difficult to balance index quality and construction efficiency.
[0007] Secondly, the coverage of auxiliary query vectors in cross-modal queries is often skewed. A small number of reference vectors may repeatedly appear in the nearest neighbor results of multiple auxiliary query vectors, while a large number of reference vectors are rarely covered, or even remain isolated or weakly connected for a long time. If existing methods do not address this coverage skew, local areas of the graph index will be over-optimized, while insufficiently covered areas will lack effective connections, thus affecting the overall connectivity of the graph index, query stability, and result recall.
[0008] Furthermore, existing graph index update methods do not adequately utilize the structural information in the nearest neighbor set of the auxiliary query vector. Some methods only perform adjacency updates around a single pivot node, failing to fully leverage the associations between multiple reference vectors within the same nearest neighbor set. When the graph index out-degree is limited, this leads to the partial discarding of semantic neighborhood information provided by the auxiliary query vector. Simultaneously, the fine-grained, serialized update process also struggles to fully utilize the parallel acceleration capabilities of the graphics processing unit (GPU) in distance calculation, candidate node generation, sorting and pruning, and adjacency list write-back.
[0009] Furthermore, existing cross-modal vector query methods still lack sufficient support for dynamic data updates and large-scale deployments. During continuous vector insertion, new nodes often only establish limited connections with their local nearest neighbors, making it difficult to effectively integrate them into the global graph structure. When deleting vectors, if only lazy marking is used to handle invalid nodes, these invalid nodes will occupy adjacency capacity for a long time, reducing query efficiency. As the size of the baseline vectors expands to hundreds of millions or even larger, the complete graph index is difficult to fully load into the graphics processor's memory. The lack of effective hierarchical storage and data scheduling mechanisms will further limit the scalability of cross-modal vector query methods.
[0010] Therefore, existing cross-modal vector query methods suffer from several technical problems, including graph search path mismatch due to inconsistencies between the distribution of query modal and baseline modal, low utilization efficiency of auxiliary query vectors, skewed query coverage, insufficient adjacency updates, decreased graph connectivity after dynamic updates, and storage and computational constraints in large-scale scenarios. There is an urgent need for a cross-modal vector query method that can effectively utilize the semantic structure information provided by the query modal even when the distributions of query vectors and baseline vectors are inconsistent. This method would reduce redundant construction and update overhead, improve graph index connectivity and query path quality, and maintain high recall, query efficiency, and scalability in dynamic update and large-scale data scenarios. Summary of the Invention
[0011] To address the shortcomings of existing technologies, embodiments of the present invention provide a method, device, and medium for cross-modal vector query based on dynamic graph indexing.
[0012] In a first aspect, embodiments of the present invention provide a cross-modal vector query method based on dynamic graph indexing, the method comprising: Obtain a set of reference vectors obtained by encoding the reference modality data, and a set of query vectors obtained by encoding the query modality data that is different from the reference modality, wherein the set of reference vectors and the set of query vectors are located in the same vector space; Construct an initial graph index using the pivot vector as the node and the adjacency relationships between pivot vectors as the edge; The query vector set is divided into several query vector batches, and the query vectors are incrementally introduced into the graph index in batches. The process of introducing the current query vector batch into the graph index includes: obtaining the nearest neighbor vector set of each query vector in the current query vector batch in the baseline vector set; updating the adjacency relationship of the current graph index based on the nearest neighbor vector set; and checking the retrieval performance indicators and structural quality indicators of the current graph index. If the current graph index converges, the construction of the graph index is completed; otherwise, the next query vector batch is introduced to continue the iteration. In response to the vector to be queried, a beam search is performed on the graph index to obtain several reference vectors that are closest to the vector to be queried as cross-modal vector query results.
[0013] In a second aspect, embodiments of the present invention provide an electronic device, comprising: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs that can be executed by the at least one processor, and the one or more computer programs are executed by the at least one processor to enable the at least one processor to perform the above-described cross-modal vector query method based on dynamic graph index.
[0014] Thirdly, embodiments of the present invention provide a computer-readable storage medium having a computer program stored thereon, characterized in that the computer program, when executed by a processor, implements the above-described cross-modal vector query method based on dynamic graph index.
[0015] Fourthly, embodiments of the present invention provide a computer program product, including a computer program / instruction, characterized in that the computer program / instruction, when executed by a processor, implements the above-described cross-modal vector query method based on dynamic graph indexing.
[0016] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention provides a cross-modal vector query method based on dynamic graph index. By obtaining the reference vector and the query vector and placing them in the same vector space, the cross-modal semantic relevance can be transformed into a distance relationship in the vector space, providing a unified data foundation for subsequent cross-modal vector queries using graph index.
[0017] Secondly, this invention constructs an initial graph index using reference vectors as nodes and adjacency relationships between reference vectors as edges, and further introduces query vectors incrementally in batches into the graph index construction process. By updating the graph index adjacency relationships through the set of nearest neighbor vectors of the query vector in the reference vector set, the graph index no longer only reflects the local geometric proximity relationships between reference vectors, but also incorporates semantic proximity relationships from the perspective of the query modality, thereby alleviating the search path mismatch problem caused by the inconsistency between the query modality and the reference modality distribution. Simultaneously, compared to the method of introducing query vectors in a fixed, one-time manner, this incremental construction method can gradually supplement adjacency information useful for cross-modal queries, improving the matching degree between the graph index structure and the actual query distribution, which is beneficial for shortening the search path in subsequent bundle search processes and improving the recall rate of cross-modal query results.
[0018] Furthermore, this invention detects the retrieval performance and structural quality indicators of the current graph index during the graph index construction process. Through this convergence judgment mechanism, it can determine whether to continue iterating based on the actual construction effect of the graph index, avoiding the continued execution of nearest neighbor calculation and adjacency update after the improvement of graph index quality has slowed down, thereby reducing redundant construction overhead and improving the efficiency of graph index construction.
[0019] Finally, this invention performs a beam search on the completed graph index in response to the query vector, and uses the nearest reference vectors to the query vector as the cross-modal vector query results. Since the adjacency relationship of the graph index has been dynamically updated during the construction phase in conjunction with the nearest neighbor information of the query modality vector, the beam search can reach the reference vector region semantically related to the query vector more quickly, reducing unnecessary distance calculations and improving the efficiency and accuracy of cross-modal vector queries. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are merely some embodiments of the present invention, and those skilled in the art can obtain other drawings based on these drawings without any creative effort.
[0021] Figure 1 A flowchart of a cross-modal vector query method based on dynamic graph index provided in an embodiment of the present invention; Figure 2 This is a schematic diagram comparing the graph index construction provided in this embodiment of the invention with existing graph index construction methods. Figure 3 This is a schematic diagram of the incremental construction process of the graph index provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of coverage-aware adaptive pruning and target connectivity enhancement provided in an embodiment of the present invention; Figure 5 A comparative schematic diagram of neighborhood-aware projection and full-neighborhood-aware projection provided in an embodiment of the present invention; Figure 6 This is a schematic diagram of the graph index search and topology-aware update process provided in an embodiment of the present invention; Figure 7 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0023] It should be noted that, unless otherwise specified, the technical features in the following embodiments and implementation methods can be combined with each other.
[0024] like Figure 1 and Figure 2 As shown, this embodiment of the invention provides a cross-modal vector query method based on dynamic graph indexing, the method comprising: Step S1: Obtain a set of reference vectors encoded from the reference modality data, and a set of query vectors encoded from query modality data that is different from the reference modality. The set of reference vectors and the set of query vectors are located in the same vector space.
[0025] In this example, the baseline modal data includes, but is not limited to, images, videos, audio, text, or other unstructured data, while the query modal data is another modal data that is different from the baseline modal data.
[0026] This example uses a multimodal embedding model to map baseline modal data and query modal data to the same shared vector space, resulting in a baseline vector set and an auxiliary query vector set.
[0027] Step S2: Construct an initial graph index using the reference vector as nodes and the adjacency relationships between reference vectors as edges.
[0028] Specifically, when constructing the graph index, each reference vector is treated as a node in the graph structure, and the adjacency relationships between nodes are determined based on the similarity or distance between different reference vectors, thus forming the initial graph index. This graph index is used to represent the topological relationships within the set of reference vectors, enabling subsequent vector retrieval to perform stepwise traversal or expanded searches based on the adjacent edges between nodes, thereby improving retrieval efficiency.
[0029] The distance or similarity can be measured using methods such as Euclidean distance, cosine similarity, or inner product similarity. Subsequently, candidate adjacent nodes are sorted in descending order of similarity or ascending order of distance, and nodes with an out-degree not exceeding a preset maximum are selected as adjacent nodes of the baseline vector. The initial graph index constructed in this way can reduce the storage complexity of the graph index while ensuring the effective representation of the relationships between baseline vectors, and provides a foundation for subsequent graph-based nearest neighbor search, incremental updates, or index optimization.
[0030] Step S3 involves dividing the query vector set into several query vector batches and incrementally introducing the query vectors into the graph index in batches. The process of introducing the current query vector batch into the graph index includes: obtaining the nearest neighbor vector set of each query vector in the current query vector batch in the baseline vector set; updating the adjacency relationship of the current graph index based on the nearest neighbor vector set; and checking the retrieval performance indicators and structural quality indicators of the current graph index. If the current graph index converges, the construction of the graph index is completed; otherwise, the next query vector batch is introduced to continue the iteration.
[0031] It should be noted that, unlike the approach of introducing a fixed-size auxiliary query vector all at once, this embodiment of the invention divides the query vector set into multiple query vector batches, and gradually introduces each batch of query vectors into the index building process according to the batch order. Each batch of query vectors is used to supplement the current graph index, so that the graph index further incorporates structural information related to the query modality distribution on the basis of the baseline vector adjacency relationship.
[0032] After processing one or more query vector batches, the current graph index can be subjected to structural quality testing and / or retrieval performance testing to determine whether continuing to introduce subsequent query vector batches can still improve the graph index quality or retrieval performance.
[0033] Through the above method, the embodiments of the present invention can adaptively determine the scale of query vectors used based on the actual convergence state during the graph index construction process, without having to pre-set a fixed number of query vectors before index construction. Therefore, while ensuring graph index retrieval performance, unnecessary nearest neighbor calculations and graph structure update operations can be reduced, thus lowering the computational overhead during the index construction process.
[0034] Specifically, such as Figure 3 As shown, the process of introducing the current query vector batch into the graph index includes the following sub-steps: Step S301: Obtain the set of nearest neighbor vectors in the reference vector set for each query vector in the current query vector batch. The set of nearest neighbor vectors reflects the set of reference vectors that are semantically related to the query vector from the perspective of query modality.
[0035] In one implementation, when the base vector set is small and can be loaded into the graphics processor's video memory, an exact nearest neighbor search is used to obtain the set of nearest neighbor vectors in the base vector set for each query vector in the current query vector batch; or, In another implementation, when the base vector set is too large to be loaded into the graphics processor's video memory, the Approximate Nearest Neighbor Search Index (ANN Index) is used to obtain the set of nearest neighbor vectors in the base vector set for each query vector in the current query vector batch.
[0036] Furthermore, step S301 also includes: performing Coverage-Aware Adaptive Pruning (CAAP) during the acquisition of the nearest neighbor vector set; such as Figure 4 As shown, it specifically includes: During the process of obtaining the nearest neighbor vector set, the number of times each reference vector is hit by different query vectors is recorded to obtain the coverage frequency of each reference vector; The number of newly covered isolated nodes in the nearest neighbor vector set obtained in the current query vector batch is counted, thereby calculating the proportion of isolated nodes; the isolated nodes are the unvisited reference vectors. If the proportion of isolated nodes is less than the threshold, it indicates that the current query vector batch mainly covers high-frequency areas that have been accessed multiple times or are well connected. It is determined that there is coverage redundancy in the process of obtaining the nearest neighbor vector set, and the high-frequency coverage reference vector is determined based on the coverage frequency. In the subsequent process of obtaining the nearest neighbor vector set of the query vector, the high-frequency coverage reference vector is pruned; specifically, the high-frequency coverage reference vector can be removed from the candidate reference vector, or the selection priority of the high-frequency coverage reference vector in the nearest neighbor search can be reduced, so that the subsequent query vector is more inclined to cover low-frequency access nodes, weak connection nodes or unaccessed nodes.
[0037] Repeat the above process of nearest neighbor acquisition, coverage frequency update, isolated node ratio statistics, and adaptive pruning until the nearest neighbor vector set of each query vector in the current query vector batch is obtained.
[0038] It should be noted that in cross-modal vector retrieval scenarios, due to the differences in feature distribution between different modalities, the nearest neighbor results obtained by the query vector in the benchmark vector set are often not uniformly distributed, but tend to concentrate on a small number of benchmark vectors with high semantic similarity or dense feature space locations. This results in a coverage skew phenomenon, where a small number of benchmark vectors are repeatedly hit by multiple query vectors and frequently appear in the nearest neighbor vector set, while a large number of other benchmark vectors are only partially covered, or even never accessed or connected. To solve the above problem, this embodiment of the invention introduces the aforementioned coverage-aware adaptive pruning mechanism in the process of obtaining the nearest neighbor vector set of auxiliary query vectors. This reduces the repeated coverage of a small number of high-frequency benchmark vectors by auxiliary query vectors, reduces the redundant graph update overhead of fully connected regions, increases the amount of effective structural information provided by each batch of query vectors, and enables the graph index to obtain more balanced node coverage during the construction process, thereby improving the overall connectivity, construction efficiency, and subsequent cross-modal vector retrieval performance of the graph index.
[0039] Step S302: The adjacency relationship of the current graph index is updated based on the nearest neighbor vector set using the full neighborhood-aware projection method.
[0040] Specifically, for a set of nearest neighbor vectors of a query vector in the set of reference vectors, each reference vector is used as a pivot node; When the pivot node is an isolated node, the reference vectors in the nearest neighbor vector set other than the pivot node are used as candidate adjacent nodes; when the pivot node is not an isolated node, the existing adjacent nodes of the pivot node and the isolated nodes in the nearest neighbor vector set are used as candidate adjacent nodes; for example, as Figure 5 As shown, when pivot node 1 is an isolated node, the reference vectors {2, 3, 4, 5} other than the pivot node in the set of nearest neighbor vectors are taken as candidate adjacent nodes; when pivot node 3 is a non-isolated node, the existing adjacent nodes {6, 7} of the pivot node and the isolated nodes {1, 2} in the set of nearest neighbor vectors are taken as candidate adjacent nodes. For candidate adjacent nodes, perform reverse sorting and pruning, and update the adjacency relationship of the pivot node while satisfying the maximum out-degree constraint.
[0041] Furthermore, the process of sorting and pruning the candidate neighbor set includes: Calculate the distance between each candidate adjacent node and the pivot node, and sort the candidate adjacent nodes from closest to furthest in distance; Candidate adjacent nodes are scanned sequentially according to the sorting order; for the current candidate adjacent node, if it is retained as the adjacent node of the pivot node, for any other candidate adjacent node after it, if the distance between the other candidate adjacent node and the pivot node is greater than the distance between the other candidate adjacent node and the retained candidate adjacent node, then the other candidate adjacent node is discarded. Repeat the above process until the number of retained adjacent nodes reaches the maximum out-degree constraint, or all candidate adjacent nodes have been scanned.
[0042] Furthermore, in this example, multiple pivot nodes in the same nearest neighbor vector set can be updated independently, and different nearest neighbor vector sets can also be processed in parallel. This embodiment of the invention can transform the adjacency update in the graph index construction process into a batch parallel task suitable for graphics processors to execute, thereby improving construction efficiency.
[0043] It should be noted that, as Figure 5 As shown on the left side of the diagram, existing neighborhood-aware projection typically only uses the nearest neighbor node of the query vector as the pivot node (the blue node in the diagram) and selects candidate neighbors from the k nearest neighbor set around this node to update the adjacency relationship of that single node. In other words, other reference vectors in the same nearest neighbor set only participate as candidate neighbors and do not actively become objects to be updated. Therefore, this approach only utilizes the local relationships between the nearest neighbor node and other nodes in the query nearest neighbor set, and does not fully leverage the potential neighborhood structure among multiple reference vectors within the nearest neighbor set.
[0044] The full-neighborhood sensing projection method proposed in this example is different. For example... Figure 5 As shown on the right, for the set of nearest neighbor vectors obtained from the same auxiliary query vector, instead of selecting only one nearest neighbor node as the pivot node, multiple reference vectors in the set are used as pivot nodes respectively. For each pivot node, a candidate neighbor node set is generated by combining other reference vectors in the nearest neighbor vector set and the existing neighbor nodes of the pivot node. The adjacency relationship of the pivot node is updated under the maximum out-degree constraint through distance sorting and pruning.
[0045] Furthermore, this example distinguishes between isolated and non-isolated nodes: when the pivot node is an isolated node, other reference vectors in the nearest neighbor set are used as candidate neighbors to help the isolated node quickly access the graph structure; when the pivot node is a non-isolated node, its existing adjacent nodes and isolated nodes in the nearest neighbor set are used as candidate neighbors, thereby reducing the disturbance to existing stable adjacency relationships while absorbing new neighborhood information.
[0046] By using the full neighborhood-aware projection method described above, this example improves the utilization rate of neighborhood structure information while taking into account graph structure quality and GPU parallel efficiency, thereby helping to improve the graph index construction speed and subsequent approximate nearest neighbor retrieval performance.
[0047] Step S303: Detect the retrieval performance indicators and structural quality indicators of the current graph index. If the current graph index converges, the construction of the graph index is completed; otherwise, introduce the next query vector batch to continue the iteration.
[0048] Furthermore, the retrieval performance metrics of the graph index include recall rate, query throughput, search path length, and / or distance calculation count; the structural quality metrics of the graph index include the number of isolated nodes, the proportion of isolated nodes, the average out-degree, and / or the proportion of weakly connected nodes.
[0049] If the change in the retrieval performance index of the current graph index is less than the first threshold, and the change in the structural quality index of the current graph index is less than the second threshold, then the previous graph index is determined to have converged, and thus the graph index is constructed. Otherwise, the next query vector is introduced and steps S301 to S303 are repeated in batches to continue iterating.
[0050] Furthermore, step S3 may also include: Step S304: Perform connection enhancement on the target nodes in the graph index.
[0051] Specifically, a subset of isolated nodes and frequently accessed nodes are selected as target nodes. A bundle search is performed in the current graph index using the target nodes as query nodes to obtain the set of retrieval nodes corresponding to the target nodes. Among them, the isolated nodes (ISO) are nodes with zero out-degree or insufficient connectivity, and the frequently accessed nodes (hot nodes) are the baseline vector nodes determined according to the coverage frequency during the coverage-aware adaptive pruning process, or nodes that are frequently accessed during the retrieval process.
[0052] Based on the target node and its corresponding set of retrieved nodes, the adjacency relationship of the target node is updated using a full neighborhood-aware projection method; including: The target node is used as the current pivot node to be updated. The existing adjacent nodes of the target node in the current graph index are obtained, and it is determined whether the target node is an isolated node. At the same time, based on the adjacency status of each node in the current graph index, the isolated nodes in the search node set are determined. When the target node is an isolated node, the search nodes in the search node set other than the target node are selected as candidate adjacent nodes; when the target node is not an isolated node, the existing adjacent nodes of the target node and the isolated nodes in the search node set are selected as candidate adjacent nodes. Subsequently, the distance or similarity between each candidate neighbor node and the target node is calculated, and the candidate neighbor nodes are sorted in order of distance from nearest to farthest or similarity from highest to lowest. The sorted candidate neighbor nodes are then pruned to remove candidate neighbor nodes that have redundant relationships with the selected neighbor nodes or do not meet the neighborhood dispersion requirements, resulting in a pruned set of neighbor nodes. Finally, provided that the number of nodes in the set of adjacent nodes does not exceed a preset maximum out-degree threshold, the set of adjacent nodes is written into the adjacency table of the target node to update the adjacency relationship of the target node in the current graph index.
[0053] It should be noted that although the overall structure of the graph index is improved after incremental construction and coverage-aware adaptive pruning, some isolated nodes or frequently accessed nodes that play an important role in query navigation may still require further optimization. Therefore, this embodiment of the invention performs target connection enhancement after the graph index converges. This example reduces broken connections in the graph index by enhancing the connections of isolated nodes; and improves the navigation capabilities of key routing nodes in the graph index by enhancing the connections of frequently accessed nodes. Furthermore, frequently accessed nodes can also serve as entry nodes in subsequent retrieval processes to shorten the search path and improve retrieval efficiency.
[0054] Furthermore, such as Figure 6 As shown, step S3 may further include: Step S305: Perform a graph index update process that inserts vectors into the graph index and / or deletes vectors into the graph index.
[0055] The process of performing vector insertion on the graph index includes: Obtain the query vector corresponding to the vector to be inserted; perform a nearest neighbor search in the graph index based on the query vector to obtain the reference vector that is semantically associated with the vector to be inserted across modalities; The vector to be inserted and the reference vector are used as nodes to be updated. The local adjacency relationship between the vector to be inserted and the graph index is established by the full neighborhood-aware projection method. Perform a graph search in the graph index using the vector to be inserted as the query, and enhance the global connection between the vector to be inserted and the graph index based on the graph search results.
[0056] Furthermore, the process of establishing the local adjacency relationship between the vector to be inserted and the graph index using a full neighborhood-aware projection method includes: A local update node set is formed by combining the vector to be inserted and the reference vector associated with it in cross-modal semantics, and each node in the local update node set is sequentially used as a pivot node. The vector to be inserted is not included in the graph index before insertion and is therefore initially considered an isolated node. For the current pivot node, determine its adjacency status in the graph index. If the current pivot node is an isolated node, consider all nodes in the local update node set other than the current pivot node as candidate adjacent nodes; if the current pivot node is not an isolated node, consider the existing adjacent nodes of the current pivot node in the graph index, as well as the isolated nodes in the local update node set, as candidate adjacent nodes, wherein the isolated nodes include at least the vector to be inserted. Calculate the distance, similarity, or fusion semantic association score between each candidate neighbor node and the current pivot node, and sort the candidate neighbor nodes according to the calculation results; perform neighborhood pruning on the sorted candidate neighbor nodes to obtain the candidate retained neighbor nodes corresponding to the current pivot node; If the number of candidate adjacent nodes does not exceed the preset maximum out-degree constraint, update the adjacency relationship of the current pivot node.
[0057] Furthermore, to further enhance the connectivity between the vector to be inserted and the global graph structure, a graph search is performed in the graph index using the vector to be inserted as a query node, and the global connection between the vector to be inserted and the graph index is enhanced based on the graph search results.
[0058] In another implementation, when there is no query vector directly corresponding to the vector to be inserted, a lightweight query vector index is created on the set of introduced query vectors, and the query vector corresponding to the vector to be inserted is determined based on the lightweight query vector index, and then the vector insertion is completed according to the above process.
[0059] The vector deletion of the graph index includes: Physically remove the node to be deleted from the graph index, and physically remove the corresponding inbound and outbound edges of the node to be deleted; Identify the nodes that are adjacent to the node to be deleted, and use them as the set of affected adjacent nodes. Reconstruct the adjacency relationships of the set of adjacent nodes.
[0060] In one implementation, the nodes in the affected neighbor set are used as the set of nodes to be updated, and their adjacency relationships are updated using a full neighborhood-aware projection method. In another implementation, the affected nodes are used as query nodes to perform a local search in the graph index, and new candidate neighbor nodes are added based on the search results, followed by sorting and pruning. This maintains the local connectivity and global reachability of the graph index after node deletion.
[0061] The process of updating the adjacency relationships of the affected neighboring node set using the full neighborhood-aware projection method includes: Each node in the set of affected adjacent nodes is taken as a pivot node in turn. The existing adjacent nodes of the current pivot node after the deletion operation are obtained, and it is determined whether the current pivot node becomes an isolated node due to the deletion operation. At the same time, the nodes in the set of affected adjacent nodes that are in an isolated state after the deletion operation are identified. If the current pivot node is an isolated node, all other nodes in the affected adjacent node set except the current pivot node are considered as candidate adjacent nodes; if the current pivot node is not an isolated node, the existing adjacent nodes of the current pivot node after the deletion operation, as well as the isolated nodes in the affected adjacent node set, are considered as candidate adjacent nodes. Calculate the distance, similarity, or semantic association score between each candidate neighbor node and the current pivot node, and sort the candidate neighbor nodes according to the calculation results; perform neighborhood pruning on the sorted candidate neighbor nodes to obtain the candidate retained neighbor nodes corresponding to the current pivot node; If the number of candidate adjacent nodes does not exceed the preset maximum out-degree constraint, update the adjacency relationship of the current pivot node.
[0062] It should be noted that this invention uses a topology-aware vector insertion and deletion mechanism to simultaneously construct local semantic connections and global graph connections during the insertion of new vectors; during the deletion of vectors, the target node is physically removed and the local topology within its influence range is repaired, thereby continuously maintaining the retrieval performance and structural stability of the graph index in dynamic update scenarios.
[0063] Step S4: In response to the vector to be queried, perform a beam search on the graph index to obtain several reference vectors that are closest to the vector to be queried as cross-modal vector query results.
[0064] Specifically, such as Figure 6 As shown, during the online retrieval phase, in response to the query vector, a beam search is performed on the graph index starting from a preset set of entry nodes, which includes high-frequency access nodes, covering entry nodes, nodes near cluster centers, or combinations thereof.
[0065] During the beam search, a candidate node set is maintained. In each iteration, unvisited nodes in the candidate node set are expanded, their adjacent nodes are read, the distance between the query vector and the reference vectors corresponding to the adjacent nodes is calculated, and the candidate node set is updated according to the distance. When the candidate node set meets the termination condition, the few reference vectors closest to the query vector are returned as the cross-modal vector retrieval results.
[0066] In one implementation, multiple unvisited nodes in the beam search can be expanded synchronously to improve the retrieval parallelism on the graphics processor.
[0067] Furthermore, to support the construction, retrieval, and dynamic updating of graph indexes on datasets with scales of hundreds of millions, this example adopts a multi-layered index storage mechanism that includes a graphics processor memory layer, a main memory layer, and a disk layer, to hierarchically store and schedule on-demand the complete graph index and the node data involved in the calculation process.
[0068] The disk layer is used to persistently store the complete graph index, which includes a base vector, node identifiers, adjacency relationships, distances between adjacent nodes, and index metadata. The main memory layer is used to cache active node data involved in the current build, retrieval, or update task. The graphics processor memory layer is used to load the hot data required for the current batch of computation to support parallel computing operations such as distance calculation, nearest neighbor selection, candidate adjacent node generation, sorting and pruning, adjacency relationship write-back, and graph search.
[0069] During the graph index construction process, the set of nodes to be accessed or updated is determined based on the set of nearest neighbor vectors corresponding to the current auxiliary query vector batch. Subsequently, the relevant node data is loaded from the disk layer or main memory layer to the graphics processor memory layer, and distance calculation, candidate adjacent node generation, adjacent node filtering, and adjacency relationship update are performed on the graphics processor. After the update is completed, the updated adjacency relationship is written back to the main memory layer or disk layer.
[0070] During graph index retrieval, candidate nodes and their adjacency information are dynamically determined based on the current retrieval path, and candidate node data is loaded into the graphics processor's memory layer for graph search calculations as needed. Simultaneously, frequently accessed or hot nodes are retained in the graphics processor's memory layer or main memory layer to reduce redundant data handling and improve retrieval efficiency.
[0071] During the graph index update process, the set of affected nodes is determined based on the vector insertion or deletion task, and the vectors, adjacency relationships, and related metadata of the affected nodes are loaded into the graphics processor's video memory layer. Subsequently, a topology update is performed on the graphics processor, including adding adjacency relationships, deleting invalid adjacency relationships, reselecting nearest neighbor nodes, or adjusting adjacency distances. After the update is completed, the updated node data is written back to the main memory layer or disk layer.
[0072] Furthermore, node data is divided into read-only neighbor information and a variable adjacency list. The read-only neighbor information is used for candidate node generation and distance calculation, and can be shared and read by multiple computing tasks; the variable adjacency list is used to store the current adjacency relationship of a node, and adopts an exclusive modification method when the adjacency relationship is updated to avoid concurrent update conflicts and ensure the consistency of the graph index topology.
[0073] Through the aforementioned multi-layered index storage mechanism, the system can manage the complete graph index even with limited graphics processor memory capacity. Based on the actual access requirements of the construction, retrieval, and update tasks, it can schedule node data between the disk layer, main memory layer, and graphics processor memory layer, thereby reducing memory usage and data transfer overhead. This enables the graph index construction, retrieval, and update methods to be extended to datasets of hundreds of millions in scale.
[0074] In summary, this invention provides a cross-modal vector query method based on dynamic graph index. By obtaining the reference vector and the query vector and placing them in the same vector space, the cross-modal semantic relevance can be transformed into a distance relationship in the vector space, providing a unified data foundation for subsequent cross-modal vector queries using graph index.
[0075] Secondly, this invention constructs an initial graph index using reference vectors as nodes and adjacency relationships between reference vectors as edges, and further introduces query vectors incrementally in batches into the graph index construction process. By updating the graph index adjacency relationships through the set of nearest neighbor vectors of the query vector in the reference vector set, the graph index no longer only reflects the local geometric proximity relationships between reference vectors, but also incorporates semantic proximity relationships from the perspective of the query modality, thereby alleviating the search path mismatch problem caused by the inconsistency between the query modality and the reference modality distribution. Simultaneously, compared to the method of introducing query vectors in a fixed, one-time manner, this incremental construction method can gradually supplement adjacency information useful for cross-modal queries, improving the matching degree between the graph index structure and the actual query distribution, which is beneficial for shortening the search path in subsequent bundle search processes and improving the recall rate of cross-modal query results.
[0076] Furthermore, this invention detects the retrieval performance and structural quality indicators of the current graph index during the graph index construction process. Through this convergence judgment mechanism, it can determine whether to continue iterating based on the actual construction effect of the graph index, avoiding the continued execution of nearest neighbor calculation and adjacency update after the improvement of graph index quality has slowed down, thereby reducing redundant construction overhead and improving the efficiency of graph index construction.
[0077] Finally, this invention performs a beam search on the completed graph index in response to the query vector, and uses the nearest reference vectors to the query vector as the cross-modal vector query results. Since the adjacency relationship of the graph index has been dynamically updated during the construction phase in conjunction with the nearest neighbor information of the query modality vector, the beam search can reach the reference vector region semantically related to the query vector more quickly, reducing unnecessary distance calculations and improving the efficiency and accuracy of cross-modal vector queries.
[0078] Accordingly, this application also provides an electronic device, including: one or more processors; a memory for storing one or more programs; and when the one or more programs are executed by the one or more processors, causing the one or more processors to implement the cross-modal vector query method based on dynamic graph index as described above. Figure 7 The diagram shown illustrates a hardware structure of any device with data processing capabilities for the cross-modal vector query method based on dynamic graph indexing provided in this embodiment of the invention, except... Figure 7 In addition to the processor, memory, and network interface shown, any data processing device in the embodiment may also include other hardware depending on the actual function of the data processing device, which will not be described in detail here.
[0079] Accordingly, this application also provides a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the cross-modal vector query method based on dynamic graph indexing as described above. The computer-readable storage medium can be an internal storage unit of any data-processing device as described in any of the foregoing embodiments, such as a hard disk or memory. The computer-readable storage medium can also be an external storage device, such as a plug-in hard disk, smart media card (SMC), SD card, flash card, etc., equipped on the device. Furthermore, the computer-readable storage medium can include both internal storage units of any data-processing device and external storage devices. The computer-readable storage medium is used to store the computer program and other programs and data required by the data-processing device, and can also be used to temporarily store data that has been output or will be output.
[0080] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the disclosure herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only.
[0081] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope.
Claims
1. A cross-modal vector query method based on dynamic graph indexing, characterized in that, The method includes: Obtain a set of reference vectors obtained by encoding the reference modality data, and a set of query vectors obtained by encoding the query modality data that is different from the reference modality, wherein the set of reference vectors and the set of query vectors are located in the same vector space; Construct an initial graph index using the pivot vector as the node and the adjacency relationships between pivot vectors as the edge; The query vector set is divided into several query vector batches, and the query vectors are incrementally introduced into the graph index in batches. The process of introducing the current query vector batch into the graph index includes: obtaining the nearest neighbor vector set of each query vector in the current query vector batch in the baseline vector set; updating the adjacency relationship of the current graph index based on the nearest neighbor vector set; and checking the retrieval performance indicators and structural quality indicators of the current graph index. If the current graph index converges, the construction of the graph index is completed; otherwise, the next query vector batch is introduced to continue the iteration. In response to the vector to be queried, a beam search is performed on the graph index to obtain several reference vectors that are closest to the vector to be queried as cross-modal vector query results.
2. The cross-modal vector query method based on dynamic graph index according to claim 1, characterized in that, The process of obtaining the set of nearest neighbor vectors in the baseline vector set for each query vector in the current query vector batch includes: When the base vector set is small enough to be loaded into the graphics processor's video memory, the exact nearest neighbor search method is used to obtain the set of nearest neighbor vectors in the base vector set for each query vector in the current query vector batch; or, When the base vector set is too large to be loaded into the graphics processor's video memory, the approximate vector indexing method is used to obtain the nearest neighbor vector set of each query vector in the current query vector batch in the base vector set.
3. The cross-modal vector query method based on dynamic graph index according to claim 1 or 2, characterized in that, The process of obtaining the set of nearest neighbor vectors in the baseline vector set for each query vector in the current query vector batch also includes: During the process of obtaining the nearest neighbor vector set, the number of times each reference vector is hit by different query vectors is recorded to obtain the coverage frequency of each reference vector; The number of newly covered isolated nodes in the nearest neighbor vector set obtained in the current query vector batch is counted, thereby calculating the proportion of isolated nodes; the isolated nodes are the unvisited reference vectors. If the proportion of isolated nodes is less than the threshold, it is determined that there is coverage redundancy in the process of obtaining the nearest neighbor vector set, and the high-frequency coverage reference vector is determined according to the coverage frequency. In the subsequent process of obtaining the nearest neighbor vector set of the query vector, the high-frequency coverage reference vector is pruned.
4. The cross-modal vector query method based on dynamic graph index according to claim 1, characterized in that, The process of updating the adjacency relationship of the current graph index based on the nearest neighbor vector set includes: For a set of nearest neighbor vectors of a query vector in a set of reference vectors, each of the reference vectors is taken as a pivot node. When the pivot node is an isolated node, the reference vectors in the nearest neighbor vector set other than the pivot node are used as candidate adjacent nodes; when the pivot node is not an isolated node, the existing adjacent nodes of the pivot node and the isolated nodes in the nearest neighbor vector set are used as candidate adjacent nodes. For candidate adjacent nodes, perform reverse sorting and pruning, and update the adjacency relationship of the pivot node while satisfying the maximum out-degree constraint.
5. The cross-modal vector query method based on dynamic graph index according to claim 4, characterized in that, The process of sorting and pruning the candidate neighbor set includes: Calculate the distance between each candidate adjacent node and the pivot node, and sort the candidate adjacent nodes from closest to furthest in distance; Candidate adjacent nodes are scanned sequentially according to the sorting order; for the current candidate adjacent node, if it is retained as the adjacent node of the pivot node, for any other candidate adjacent node after it, if the distance between the other candidate adjacent node and the pivot node is greater than the distance between the other candidate adjacent node and the retained candidate adjacent node, then the other candidate adjacent node is discarded. Repeat the above process until the number of retained adjacent nodes reaches the maximum out-degree constraint, or the candidate adjacent node scan is completed.
6. The cross-modal vector query method based on dynamic graph index according to claim 1, characterized in that, The retrieval performance metrics of the graph index include recall, query throughput, search path length, and / or distance calculation counts. The structural quality metrics of the graph index include the number of isolated nodes, the proportion of isolated nodes, the average out-degree, and / or the proportion of weakly connected nodes.
7. The cross-modal vector query method based on dynamic graph index according to claim 1, characterized in that, The method further includes: Perform vector insertion on the graph index, including: Obtain the query vector corresponding to the vector to be inserted; perform a nearest neighbor search in the graph index based on the query vector to obtain the reference vector that is semantically associated with the vector to be inserted across modalities; The vector to be inserted and the reference vector are used as nodes to be updated, and a local adjacency relationship is established between the vector to be inserted and the graph index. Perform a graph search in the graph index using the vector to be inserted as the query, and enhance the global connection between the vector to be inserted and the graph index based on the graph search results; And / or, Perform vector deletion on graph indices, including: Physically remove the node to be deleted from the graph index, and physically remove the corresponding inbound and outbound edges of the node to be deleted; Determine the set of adjacent nodes affected by the node to be deleted, and reconstruct the adjacency relationships of the adjacent node set.
8. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs that can be executed by the at least one processor, the one or more of the computer programs being executed by the at least one processor to enable the at least one processor to perform the cross-modal vector query method based on dynamic graph index as described in any one of claims 1-7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the cross-modal vector query method based on dynamic graph index as described in any one of claims 1-7.
10. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instruction is executed by the processor, it implements the cross-modal vector query method based on dynamic graph index as described in any one of claims 1-7.
