Multi-vector query method and device, electronic equipment and storage medium

By splitting the multi-vector query task into a single-vector query task, and determining the nearest neighbor objects of the multi-vector query task based on the weight of each data set, the search similarity and object of the nearest neighbor vector and the object to which it belongs, the problem of poor results in multi-vector query is solved, and higher query accuracy and efficiency are achieved.

CN119621744APending Publication Date: 2025-03-14BEIJING OCEANBASE TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411589063.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-07
Publication Date
2025-03-14

AI Technical Summary

Technical Problem

Existing databases have poor results when processing multi-vector queries and cannot effectively manage and query multiple vector data.

Method used

By splitting the multi-vector query task into multiple single-vector query tasks, each single-vector query task corresponds to a data set in the database, determines the k nearest neighbor vectors of the query vector of each single-vector query task and its search similarity, and determines the n nearest neighbor objects of the multi-vector query task based on the weight of each data set, the search similarity and object of the nearest neighbor vector.

Benefits of technology

By splitting query tasks and weight-based processing methods, the accuracy and efficiency of multi-vector query are improved, and the nearest neighbors can be matched more accurately.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119621744A_ABST
    Figure CN119621744A_ABST
Patent Text Reader

Abstract

The invention provides a multi-vector query method and device, electronic equipment and a storage medium, and the method comprises the steps: splitting a multi-vector query task into a plurality of single-vector query tasks, each single-vector query task having a query vector, and each single-vector query task corresponding to a data set in a database; for each one-way vector query task in the plurality of one-way vector query tasks, determining k neighbor vectors of a query vector of the one-way vector query task and retrieval similarity of the neighbor vectors in a data set corresponding to the one-way vector query task, the retrieval similarity is the similarity between a neighbor vector and the query vector, and k is an integer greater than 1; and determining n neighbor objects of the multi-vector query task according to the weight of the data set corresponding to each single-vector query task and the retrieval similarity and belonging objects of the k neighbor vectors determined by each single-vector query task, n being an integer greater than 0.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] One or more embodiments of the present specification relate to the field of database technology, and in particular, to a multi-vector query method and device, an electronic device, and a storage medium. Background Art

[0002] With the rise of large language models, the demand for DB4AI (Database for AI) continues to grow. This is largely due to the need to convert sample data into vector form during AI (Artificial Intelligence) training and reasoning, which creates a need to manage these vectors. Currently, there is some research and development focused on creating database systems that specifically handle vector data types, such as Milvus; there are also some attempts to extend the functionality of traditional relational databases by adding plug-ins that support vector data types.

[0003] In the related art, databases capable of managing vector data types have achieved good results in dealing with ANNS (Approximate Nearest Neighbor Search) problems, but they are less effective in dealing with Multi-ANNS (multi-vector query) problems. Summary of the invention

[0004] In view of this, one or more embodiments of the present specification provide a transaction processing method and apparatus, an electronic device, and a storage medium.

[0005] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions:

[0006] According to a first aspect of one or more embodiments of this specification, a multi-vector query method is proposed, the method comprising:

[0007] Splitting the multi-vector query task into multiple single-vector query tasks, wherein each single-vector query task has a query vector, and each single-vector query task corresponds to a data set in the database;

[0008] For each single-vector query task in the multiple single-vector query tasks, determine k neighbor vectors of the query vector of the single-vector query task in the data set corresponding to the single-vector query task, and the retrieval similarity of the neighbor vectors, wherein the retrieval similarity is the similarity between the neighbor vector and the query vector, and k is an integer greater than 1;

[0009] According to the weight of the data set corresponding to each single-vector query task, and the retrieval similarity and the belonging object of the k nearest neighbor vectors determined by each single-vector query task, the n nearest neighbor objects of the multi-vector query task are determined, where n is an integer greater than 0.

[0010] In one or more possible embodiments of the present specification, determining the n target objects of the multi-vector query task according to the weight of the data set corresponding to each single-vector query task, and the retrieval similarity and the object to which the k nearest neighbor vectors determined by each single-vector query task belong, includes:

[0011] Clustering all neighbor vectors determined by the multiple single-vector query tasks according to the objects to which the neighbor vectors belong, so as to obtain a neighbor vector set of at least one object;

[0012] For the neighbor vector set of the at least one object, performing weighted summation on all neighbor vectors in the neighbor vector set according to the weights of the data sets to which they belong, so as to obtain a weighted summation result of the neighbor vector set;

[0013] For the neighbor vector sets of the at least one object, the objects to which the n neighbor vector sets having the highest weighted summation results belong are respectively determined as neighbor objects.

[0014] In one or more possible embodiments of the present specification, determining the objects to which the n nearest neighbor vector sets having the highest weighted sum results belong as nearest neighbor objects respectively includes:

[0015] The object to which a nearest neighbor vector set having the highest weighted sum result belongs is determined as the target object of the multi-vector query task.

[0016] In one or more possible embodiments of the present specification, objects to which vectors in data sets corresponding to different single-vector query tasks among the multiple single-vector query tasks belong partially or completely overlap.

[0017] In one or more possible embodiments of the present specification, splitting the multi-vector query task into multiple single-vector query tasks includes:

[0018] The parts for different query vectors in the SQL statement of the multi-vector query task are split, and each of the split parts is used as an SQL statement of a single-vector query task.

[0019] In one or more possible embodiments of the present specification, when the data set corresponding to the single vector query task includes multiple vector columns, determining k nearest neighbor vectors of the query vector of the single vector query task in the data set corresponding to the single vector query task, and the retrieval similarity of each of the k nearest neighbor vectors, includes:

[0020] Determine m candidate neighbor vectors of the query vector of the single-vector query task and the retrieval similarity of the candidate neighbor vectors in the multiple vector columns, respectively, where m is an integer greater than 1;

[0021] According to the objects to which the m candidate neighbor vectors determined by each vector column in the plurality of vector columns belong, k neighbor vectors and the retrieval similarities of the neighbor vectors are determined.

[0022] In one or more possible embodiments of the present specification, determining k neighbor vectors and the retrieval similarity of the neighbor vectors according to the objects to which the m candidate neighbor vectors determined by each vector column in the multiple vector columns belong includes:

[0023] If the vectors of any object in each of the multiple vector columns are determined to be candidate neighbor vectors, the vectors of any object in each of the multiple vector columns are combined into one neighbor vector, and the vectors of any object in each of the multiple vector columns are weighted and summed according to the weights of the vector columns, so that the obtained weighted summation result is used as the retrieval similarity of the neighbor vector;

[0024] Retain the k nearest neighbor vectors with the highest similarity among all the nearest neighbor vectors obtained.

[0025] In one or more possible embodiments of the present specification, the step of retrieving k neighbor vectors with the highest similarity from all obtained neighbor vectors and determining them as the k neighbor vectors includes:

[0026] If the number of all obtained nearest neighbor vectors is greater than k, then the k nearest neighbor vectors with the highest similarity are retained;

[0027] If the number of all obtained nearest neighbor vectors is not greater than k, all obtained nearest neighbor vectors are retained.

[0028] In one or more possible embodiments of the present specification, objects to which vectors in a plurality of vector columns included in a data set corresponding to the single-vector query task belong overlap partially or completely.

[0029] In one or more possible embodiments of the present specification, determining k neighbor vectors of the query vector of the single vector query task in the data set corresponding to the single vector query task, and the retrieval similarity of each of the k neighbor vectors, includes:

[0030] Based on heap sort or merge sort, k nearest neighbor vectors of the query vector of the single vector query task and the retrieval similarity of each of the k nearest neighbor vectors are determined in the data set corresponding to the single vector query task.

[0031] According to a second aspect of one or more embodiments of this specification, a multi-vector query device is provided, the device comprising:

[0032] A splitting module, used to split the multi-vector query task into multiple single-vector query tasks, wherein each single-vector query task has a query vector, and each single-vector query task corresponds to a data set in the database;

[0033] a query module, configured to determine, for each single-vector query task in the plurality of single-vector query tasks, k neighbor vectors of the query vector of the single-vector query task in the data set corresponding to the single-vector query task, and a retrieval similarity of the neighbor vectors, wherein the retrieval similarity is a similarity between the neighbor vector and the query vector, and k is an integer greater than 1;

[0034] The screening module is used to determine n neighboring objects of the multi-vector query task according to the weight of the data set corresponding to each single-vector query task and the retrieval similarity and the belonging object of the k neighboring vectors determined by each single-vector query task, where n is an integer greater than 0.

[0035] In one or more possible embodiments of this specification, the screening module is used to:

[0036] Clustering all neighbor vectors determined by the multiple single-vector query tasks according to the objects to which the neighbor vectors belong, so as to obtain a neighbor vector set of at least one object;

[0037] For the neighbor vector set of the at least one object, performing weighted summation on all neighbor vectors in the neighbor vector set according to the weights of the data sets to which they belong, so as to obtain a weighted summation result of the neighbor vector set;

[0038] For the neighbor vector sets of the at least one object, the objects to which the n neighbor vector sets having the highest weighted summation results belong are respectively determined as neighbor objects.

[0039] In one or more possible embodiments of the present specification, when the screening module is used to determine the objects to which the n nearest neighbor vector sets with the highest weighted sum results belong as nearest neighbor objects, it is used to:

[0040] The object to which a nearest neighbor vector set having the highest weighted sum result belongs is determined as the target object of the multi-vector query task.

[0041] In one or more possible embodiments of the present specification, objects to which vectors in data sets corresponding to different single-vector query tasks among the multiple single-vector query tasks belong partially or completely overlap.

[0042] In one or more possible embodiments of this specification, the splitting module is used to:

[0043] The parts for different data sets in the SQL statement of the multi-vector query task are split, and each of the split parts is used as an SQL statement of a single-vector query task.

[0044] In one or more possible embodiments of the present specification, when the data set corresponding to the single-vector query task includes multiple vector columns, the query module is used to:

[0045] Determining n candidate neighbor vectors of the query vector of the single-vector query task and the retrieval similarities of the candidate neighbor vectors in the multiple vector columns respectively;

[0046] According to the objects to which the n candidate neighbor vectors determined by each vector column in the plurality of vector columns belong, k neighbor vectors and the retrieval similarities of the neighbor vectors are determined.

[0047] In one or more possible embodiments of the present specification, the screening module is used to determine k nearest neighbor vectors and the search similarity of the nearest neighbor vectors according to the objects to which the n candidate nearest neighbor vectors determined by each vector column in the multiple vector columns belong, and is used to:

[0048] If the vectors of any object in each of the multiple vector columns are determined to be candidate neighbor vectors, the vectors of any object in each of the multiple vector columns are combined into one neighbor vector, and the vectors of any object in each of the multiple vector columns are weighted and summed according to the weights of the vector columns, so that the obtained weighted summation result is used as the retrieval similarity of the neighbor vector;

[0049] Retain the k nearest neighbor vectors with the highest similarity among all the nearest neighbor vectors obtained.

[0050] In one or more possible embodiments of the present specification, when the screening module is used to retain the k nearest neighbor vectors with the highest similarity among all the obtained nearest neighbor vectors, it is used to:

[0051] If the number of all obtained nearest neighbor vectors is greater than k, then the k nearest neighbor vectors with the highest similarity are retained;

[0052] If the number of all obtained nearest neighbor vectors is not greater than k, all obtained nearest neighbor vectors are retained.

[0053] In one or more possible embodiments of the present specification, objects to which vectors in a plurality of vector columns included in a data set corresponding to the single-vector query task belong overlap partially or completely.

[0054] In one or more possible embodiments of this specification, the screening module is used to:

[0055] Based on heap sort or merge sort, k nearest neighbor vectors of the query vector of the single vector query task and the retrieval similarity of each of the k nearest neighbor vectors are determined in the data set corresponding to the single vector query task.

[0056] According to a third aspect of one or more embodiments of this specification, a computer program product is provided, comprising a computer program / instruction, which implements the steps of the method described in the first aspect when executed by a processor.

[0057] According to a fourth aspect of one or more embodiments of this specification, an electronic device is provided, including:

[0058] processor;

[0059] a memory for storing processor-executable instructions;

[0060] The processor implements the method as described in the first aspect by running the executable instructions.

[0061] According to a fifth aspect of one or more embodiments of the present specification, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method described in the first aspect are implemented.

[0062] The technical solutions provided by the embodiments of this specification may have the following beneficial effects:

[0063] The multi-vector query method provided in the embodiment of the present specification first splits the multi-vector query task into multiple single-vector query tasks, then for each single-vector query task in the multiple single-vector query tasks, determines the k nearest neighbor vectors of the query vector of the single-vector query task in the data set corresponding to the single-vector query task, and the retrieval similarity of the nearest neighbor vectors, and finally determines the n nearest neighbor objects of the multi-vector query task according to the weight of the data set corresponding to each single-vector query task, and the retrieval similarity and the object to which the k nearest neighbor vectors determined by each single-vector query task belong. Since the multi-vector query task is split into multiple single-vector query tasks, it is convenient for the database to execute the query task, and the query results of each single-vector query task are processed based on the weight of the data set corresponding to each single-vector query task, so as to accurately match the nearest neighbor objects based on the vector query results of different data sets, thereby improving the accuracy of the multi-vector query. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] Figure 1 It is an architectural diagram of a distributed database provided by an exemplary embodiment.

[0065] Figure 2 is a flowchart of a multi-vector query method provided by an exemplary embodiment.

[0066] Figure 3 It is a flowchart of a face query example provided by an exemplary embodiment.

[0067] Figure 4 It is a structural schematic diagram of a device provided by an exemplary embodiment.

[0068] Figure 5 It is a block diagram of a multi-vector query device provided by an exemplary embodiment. DETAILED DESCRIPTION

[0069] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.

[0070] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.

[0071] First, some concepts involved in this specification are explained.

[0072] Vector database: refers to a database system specifically designed to store, manage, and retrieve vector data. Vector data usually refers to high-dimensional data, such as mathematical representations of images, audio, video, and text content, which are usually converted into high-dimensional vectors through deep learning models.

[0073] DB4AI (Database for Artificial Intelligence): is a field that involves the combination of database technology and artificial intelligence (AI) applications. It focuses on integrating artificial intelligence algorithms and machine learning (ML) models in the database, thereby enabling data analysis, prediction, and automated decision-making directly within the database environment.

[0074] Embedding: In the process of AI training and reasoning, "embedding" refers to converting large-scale sparse data (such as words, phrases, or entire files in text) into a low-dimensional dense vector representation. This vectorized expression can capture and represent the important features of the data and is used for the subsequent training and reasoning of machine learning models.

[0075] ANNS (Approximate Nearest Neighbor Search): Compared with k-NNS (k Nearest Neighbor Search), ANNS sacrifices a certain degree of accuracy to obtain higher recall performance, and accelerates the search by establishing indexes or quantization. It mainly uses two indexing methods: HNSW or IVFFlat.

[0076] Multi-ANNS: is a database and information retrieval technology that involves the process of performing approximate nearest neighbor searches on multiple query points simultaneously in a high-dimensional space, that is, for a series of query points, the system will perform many search operations simultaneously instead of performing a separate search on each point separately.

[0077] Multi-ANNS can perform retrieval of multiple query vectors in a single operation, rather than querying them one by one. In this way, the query efficiency of the system can be significantly improved, thereby optimizing the overall performance. For example, in a recommendation system, the multi-dimensional behavior data of users (such as browsing history, search history, and purchase behavior) can be comprehensively considered to generate more accurate recommendations. Multi-ANNS plays a vital role in commercial applications, especially in providing customized recommendations and performing natural language processing tasks. For example, in a personalized recommendation system, each user may have multiple vectors representing different interests. Through Multi-ANNS, the system can process these vectors in parallel, thereby achieving more personalized and accurate recommendations. For another example, in the field of natural language processing (NLP), Multi-ANNS allows the simultaneous processing of several word vectors or sentence vectors. This comprehensive analysis improves the accuracy and result quality of text analysis and semantic search. Multi-ANNS's batch query processing not only greatly improves efficiency, but also demonstrates extremely high information capture capabilities and flexibility when dealing with complex and changing business needs.

[0078] Therefore, it is necessary to improve the efficiency and effectiveness of multi-vector query (Multi-ANNS).

[0079] Based on the above technical problems, at least one embodiment of the present specification provides a multi-vector query method, which can be applied to the Multi-ANNS (multi-vector query) scenario, that is, using multiple query vectors to search for different data sets respectively, so as to further lock the neighbor objects by locking the neighbor vectors in each data set, where the neighbor vector refers to a vector with a high similarity to the query vector, and the neighbor object refers to the object to which the neighbor vector belongs.

[0080] Next, we will give an example of multi-vector query to describe the scenario more vividly; and the following description of the process of this method can also be combined with this example for a more detailed and vivid description. For the convenience of the following description, this example is called a face retrieval example. The content of the face retrieval example is as follows:

[0081] The database has a data table for storing the facial features of each person in the person set, and the data table includes a key value column, a front face feature column, a left face feature column, and a right face feature column, wherein the key value column is used to store a person identification, such as a person ID, the front face feature column is used to store the front face features of the person, the left face feature column is used to store the left face features of the person, and the right face feature column is used to store the right face features of the person; that is, each row of records in the data table includes a task identifier, and the front face features, left face features, and right face features of the person corresponding to the task identifier. The content of the multi-vector query task is: based on the given front face features and side face features, a multi-vector search is performed in the above database to determine the person to whom the given features belong, that is, the target person.

[0082] For example, the method can be applied to Figure 1 The distributed database shown, or other types of databases.

[0083] Please refer to the attached Figure 2 , which exemplarily shows a flowchart of a multi-vector query method, including steps S201 to S203.

[0084] In step S201, the multi-vector query task is split into a plurality of single-vector query tasks, wherein each single-vector query task has a query vector, and each single-vector query task corresponds to a data set in the database.

[0085] Among them, the multi-vector query task includes multiple query vectors, each query vector corresponds to a data set, and the objects of the vectors in the data sets corresponding to different query vectors partially or completely overlap; the data set corresponding to the query vector may include one vector column or multiple vector columns, and the objects of the vectors in these vector columns partially or completely overlap. For example, the multi-vector query task in the above face retrieval example includes two query vectors of given frontal face features and side face features. The data set corresponding to the given frontal face features is the frontal face feature column, and the data set corresponding to the given side face features is two vector columns, the left face feature column and the right face feature column. The objects to which the vectors in the left face feature column belong, namely, people, overlap with the objects to which the vectors in the right face feature column, namely, people. The objects to which the front face features in the front face feature column, namely, people, overlap with the objects to which the left face features in the left face feature column, namely, people.

[0086] The multi-vector query task can be represented in the form of an SQL statement. Therefore, in this step, the parts for different query vectors in the SQL statement of the multi-vector query task can be split, and each of the split parts can be used as an SQL statement of a single-vector query task. Among them, the objects to which the vectors in the data sets corresponding to different single-vector query tasks in the multiple single-vector query tasks belong partially or completely overlap.

[0087] For example, the lexical and grammatical parsing module OBMPQuery module of the database (especially the database for processing structured data) can be adjusted according to the vector grammar specification so that it can parse and optimize the SQL statement representing the vector query, so that the multi-vector query task can be converted into a parallel retrieval task for multiple single query vectors, that is, multiple single-vector retrieval tasks, during the SQL statement parsing and optimization stage. For example, the Parser is adjusted so that it can adapt to the SQL statement representing the vector query when performing lexical analysis, grammatical analysis, error detection and other parsing functions; the Resolver is adjusted so that it can adapt to the SQL statement representing the vector query when performing name resolution, type checking, permission verification, and other context-related verification functions.

[0088] For example, the above face retrieval example can be represented by the following SQL statement: select c1 and c2<->"[1,2,3]"limit 5and c3<->"[4,5,6,7]"limit 3from item; where [1,2,3] represents the given side face feature, c1 is the left face feature column, c2 is the right face feature column, [4,5,6,7] is the given front face feature, and c3 is the front face feature column. This SQL statement means: by retrieving 5 side face features similar to the given side face feature in the side face feature set, and retrieving 3 front face features similar to the given front face feature in the front face feature set, the person to whom the given side face feature and front face feature belong is locked. In this step, the SQL statement is split into the following two SQL statements that represent the single vector query task respectively during the SQL statement parsing stage:

[0089] select c1 and c2<->"[1,2,3]" from item limit 5;

[0090] select c3<->"[4,5,6,7]" from item limit 3.

[0091] Among them, the query vector of select c1 and c2<->"[1,2,3]" from item limit 5 is [1,2,3], and the corresponding data set is c1 and c2; the query vector of select c3<->"[4,5,6,7]" from item limit 3 is [4,5,6,7], and the corresponding data set is c3. The object to which the vector in c1 belongs, the object to which the vector c2 belongs, and the object to which the quantity c3 belongs completely overlap, and they are all people in the person set.

[0092] Current databases, including databases for processing structured data, have the ability to execute multiple SQL statements in parallel, so that the split multiple SQL statements can be executed separately to process each single-vector query task.

[0093] In step S202, for each single-vector query task in the multiple single-vector query tasks, k neighbor vectors of the query vector of the single-vector query task and the retrieval similarity of the neighbor vectors are determined in the data set corresponding to the single-vector query task, wherein the retrieval similarity is the similarity between the neighbor vector and the query vector, and k is an integer greater than 1.

[0094] The value of k in different single vector query tasks may be different. For example, in the above face retrieval example, the value of k in the single vector query task related to the frontal face feature is 3, and the value of k in the single vector query task related to the side face feature is 5. It should be understood that in this step, if the number of neighbor vectors that can be queried is greater than k, k neighbor vectors are retained, and if the number of neighbor vectors that can be queried is not greater than k, all the queried neighbor vectors are retained.

[0095] Optionally, when the data set corresponding to the single vector query task contains multiple vector columns, this step can complete the single vector query task in the following manner: based on heap sort or merge sort, k nearest neighbor vectors of the query vector of the single vector query task and the retrieval similarity of each of the k nearest neighbor vectors are determined in the data set corresponding to the single vector query task. This can avoid traversing all vectors in the data set to calculate the similarity, thereby reducing the amount of calculation and improving the query efficiency.

[0096] Optionally, the objects to which the vectors in the multiple vector columns contained in the data set corresponding to the single vector query task belong overlap partially or completely. In the case where the data set corresponding to the single vector query task contains multiple vector columns, this step can complete the single vector query task in the following manner:

[0097] First, m candidate neighbor vectors of the query vector of the single vector query task and the retrieval similarity of the candidate neighbor vectors are determined in the multiple vector columns, respectively, where m is an integer greater than 1. For example, based on heap sort or merge sort, m candidate neighbor vectors of the query vector of the single vector query task and the retrieval similarity of the candidate neighbor vector are determined in each vector column of the multiple vector columns. This avoids traversing all vectors in the vector column to calculate the similarity, thereby reducing the amount of calculation and improving the query efficiency.

[0098] Next, k nearest neighbor vectors and the retrieval similarities of the nearest neighbor vectors are determined according to the objects to which the m candidate nearest neighbor vectors determined by each vector column in the plurality of vector columns belong.

[0099] For example, if the vectors of any object in each of the multiple vector columns are determined to be candidate neighbor vectors, the vectors of any object in each of the multiple vector columns are combined into one neighbor vector, and the vectors of any object in each of the multiple vector columns are weighted and summed according to the weight of the vector column, so that the obtained weighted summation result is used as the retrieval similarity of the neighbor vector; and then the k neighbor vectors with the highest retrieval similarity among all the obtained neighbor vectors are retained. It should be understood that if the number of all the obtained neighbor vectors is greater than k, the k neighbor vectors with the highest retrieval similarity among all the obtained neighbor vectors are retained; if the number of all the obtained neighbor vectors is not greater than k, all the obtained neighbor vectors are retained.

[0100] The weight of the vector column can be statically annotated on each data column of the database in advance; or dynamically annotated in each multi-vector query task, that is, the weight of each vector column in the data set involved is annotated. For example, the SQL statement "select c1 and c2<->"[1,2,3]" limit 5and c3<->"[4,5,6,7]" limit 3from item" corresponding to the above face retrieval example does not dynamically annotate the weights of the vector columns involved. If it is adjusted to "select c1*W1 and c2*W2<->"[1,2,3]" limit 5and c3*W3<->"[4,5,6,7]" limit 3fromitem, W1+W2+W3=1", the weights of the c1 column, c2 column and c3 column involved are dynamically annotated respectively.

[0101] Taking the side face retrieval task in the above face retrieval example (i.e., a single vector query task with a given side face feature as the query vector and a left face feature column and a right face feature column as the corresponding data set) as an example, m candidate neighbor vectors of the given side face feature and the retrieval similarity of each candidate neighbor vector can be determined in the left face feature column, and m candidate neighbor vectors of the given side face feature and the retrieval similarity of each candidate neighbor vector can be determined in the left face feature column, and then the intersection of the m candidate neighbor vectors determined in the left face feature column and the m candidate neighbor vectors determined in the right face feature column is taken based on the object to which the candidate neighbor vectors belong - the person, and k candidate neighbor vectors in the intersection are retained as neighbor vectors.

[0102] It should be understood that when executing the SQL statement involving multiple columns in this optional example, strategies such as Index Merge can be used to improve query efficiency. For example, taking the SQL statement "select c1 and c2<->"[1,2,3]" from item limit 5" of the side face retrieval task in the above face retrieval example (i.e., a single vector query task with a given side face feature as the query vector and the left face feature column and the right face feature column as the corresponding data set) as an example, the Index Merge strategy can be used to execute it, thereby improving query efficiency.

[0103] In step S203, n neighbor objects of the multi-vector query task are determined according to the weight of the data set corresponding to each single-vector query task and the retrieval similarity and the object to which the k neighbor vectors determined by each single-vector query task belong, where n is an integer greater than 0.

[0104] Exemplarily, this step is performed in the following manner:

[0105] First, all neighbor vectors determined by the plurality of single-vector query tasks are clustered according to the objects to which the neighbor vectors belong, so as to obtain a neighbor vector set of at least one object.

[0106] Taking the above face retrieval example as an example, all neighbor vectors obtained from the frontal face retrieval task (i.e., a single vector query task with a given frontal face feature as the query vector and a frontal face feature column as the corresponding data set) and the side face retrieval task (i.e., a single vector query task with a given side face feature as the query vector and a left face feature column and a right face feature column as the corresponding data set) are clustered according to their objects - people, that is, the neighbor vectors belonging to the same person are classified into one category.

[0107] Next, for the neighbor vector set of the at least one object, all neighbor vectors in the neighbor vector set are weighted summed according to the weights of the data sets to which they belong, so as to obtain a weighted sum result of the neighbor vector set.

[0108] The weight of the data set can be statically annotated on each data column of the database in advance; or dynamically annotated in each multi-vector query task, that is, the weight of each vector column of the data set involved is annotated. For example, the SQL statement "select c1 and c2<->"[1,2,3]"limit 5and c3<->"[4,5,6,7]"limit 3from item" corresponding to the above face retrieval example does not dynamically annotate the weights of each vector column involved. If it is adjusted to "select c1*W1 and c2*W2<->"[1,2,3]"limit 5and c3*W3<->"[4,5,6,7]"limit 3fromitem, W1+W2+W3=1" means that the weights of the c1 column, c2 column and c3 column involved are dynamically annotated respectively, among which, the weight of the dataset corresponding to the frontal face retrieval task (i.e., a single vector query task with a given frontal face feature as the query vector and a frontal face feature column as the corresponding dataset) is W3, and the weight of the dataset corresponding to the side face retrieval task (i.e., a single vector query task with a given side face feature as the query vector and a left face feature column and a right face feature column as the corresponding dataset) is W1+W2.

[0109] Finally, for the neighbor vector sets of the at least one object, the objects to which the n neighbor vector sets having the highest weighted summation results belong are respectively determined as neighbor objects.

[0110] For example, the object to which a nearest neighbor vector set with the highest weighted sum result belongs is determined as the target object of the multi-vector query task. Taking the above face retrieval example, the target object is the target person of face retrieval.

[0111] Please refer to the attached Figure 3 , which exemplarily shows the processing flow of the above-mentioned face retrieval example.

[0112] First, enter the SQL: select c1 and c2 <-> "[1,2,3]" limit 5 and c3 <-> "[4,5,6,7]" limit 3 from item.

[0113] Next, modify the Parser and Resolver to make the above SQL pass the syntax and semantic checks and split it into: select c1and c2<->"[1,2,3]"limit 5from item and select c3<->"[4,5,6,7]"limit3from item.

[0114] Next, optimize, execute, and index to execute select c1 and c2<->"[1,2,3]" limit 5fromitem and select c3<->"[4,5,6,7]" limit 3from item. Preferably, based on operations such as index merge, the query between the single query vector and the multi-vector column, select c3<->"[4,5,6,7]" limit 3from item, is processed.

[0115] Finally, based on the query results of select c1 and c2<->“[1,2,3]”limit 5from item and select c3<->“[4,5,6,7]”limit 3from item, the target person to whom the face belongs is determined.

[0116] The multi-vector query method provided in the embodiments of this specification splits the multi-vector query task into multiple single-vector query tasks, thereby facilitating the database to execute the query task, and processes the query results of each single-vector query task based on the weight of the data set corresponding to each single-vector query task, so as to accurately match neighboring objects based on the vector query results of different data sets, thereby improving the accuracy of the multi-vector query.

[0117] Figure 4 is a schematic structural diagram of a device provided by an exemplary embodiment. Figure 4 At the hardware level, the device includes a processor 402, an internal bus 404, a network interface 406, a memory 408, and a non-volatile memory 410, and may also include hardware required for other tasks. One or more embodiments of this specification may be implemented based on software, such as the processor 402 reading the corresponding computer program from the non-volatile memory 410 into the memory 408 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0118] Please refer to Figure 5 , the multi-vector query device can be applied to Figure 4 The multi-vector query device may include:

[0119] A splitting module 501 is used to split the multi-vector query task into multiple single-vector query tasks, wherein each single-vector query task has a query vector, and each single-vector query task corresponds to a data set in the database;

[0120] A query module 502 is used to determine, for each single-vector query task in the multiple single-vector query tasks, k neighbor vectors of the query vector of the single-vector query task in the data set corresponding to the single-vector query task, and a retrieval similarity of the neighbor vectors, wherein the retrieval similarity is a similarity between the neighbor vector and the query vector, and k is an integer greater than 1;

[0121] The screening module 503 is used to determine n neighboring objects of the multi-vector query task according to the weight of the data set corresponding to each single-vector query task and the retrieval similarity and the object to which the k neighboring vectors determined by each single-vector query task belong, where n is an integer greater than 0.

[0122] In one or more possible embodiments of this specification, the screening module is used to:

[0123] Clustering all neighbor vectors determined by the multiple single-vector query tasks according to the objects to which the neighbor vectors belong, so as to obtain a neighbor vector set of at least one object;

[0124] For the neighbor vector set of the at least one object, performing weighted summation on all neighbor vectors in the neighbor vector set according to the weights of the data sets to which they belong, so as to obtain a weighted summation result of the neighbor vector set;

[0125] For the neighbor vector sets of the at least one object, the objects to which the n neighbor vector sets having the highest weighted summation results belong are respectively determined as neighbor objects.

[0126] In one or more possible embodiments of the present specification, when the screening module is used to determine the objects to which the n nearest neighbor vector sets with the highest weighted sum results belong as nearest neighbor objects, it is used to:

[0127] The object to which a nearest neighbor vector set having the highest weighted sum result belongs is determined as the target object of the multi-vector query task.

[0128] In one or more possible embodiments of the present specification, objects to which vectors in data sets corresponding to different single-vector query tasks among the multiple single-vector query tasks belong partially or completely overlap.

[0129] In one or more possible embodiments of this specification, the splitting module is used to:

[0130] The parts for different data sets in the SQL statement of the multi-vector query task are split, and each of the split parts is used as an SQL statement of a single-vector query task.

[0131] In one or more possible embodiments of the present specification, when the data set corresponding to the single-vector query task includes multiple vector columns, the query module is used to:

[0132] Determining n candidate neighbor vectors of the query vector of the single-vector query task and the retrieval similarities of the candidate neighbor vectors in the multiple vector columns respectively;

[0133] According to the objects to which the n candidate neighbor vectors determined by each vector column in the plurality of vector columns belong, k neighbor vectors and the retrieval similarities of the neighbor vectors are determined.

[0134] In one or more possible embodiments of the present specification, the screening module is used to determine k nearest neighbor vectors and the search similarity of the nearest neighbor vectors according to the objects to which the n candidate nearest neighbor vectors determined by each vector column in the multiple vector columns belong, and is used to:

[0135] If the vectors of any object in each of the multiple vector columns are determined to be candidate neighbor vectors, the vectors of any object in each of the multiple vector columns are combined into one neighbor vector, and the vectors of any object in each of the multiple vector columns are weighted and summed according to the weights of the vector columns, so that the obtained weighted summation result is used as the retrieval similarity of the neighbor vector;

[0136] Retain the k nearest neighbor vectors with the highest similarity among all the nearest neighbor vectors obtained.

[0137] In one or more possible embodiments of the present specification, when the screening module is used to retain the k nearest neighbor vectors with the highest similarity among all the obtained nearest neighbor vectors, it is used to:

[0138] If the number of all obtained nearest neighbor vectors is greater than k, then the k nearest neighbor vectors with the highest similarity are retained;

[0139] If the number of all obtained nearest neighbor vectors is not greater than k, all obtained nearest neighbor vectors are retained.

[0140] In one or more possible embodiments of the present specification, objects to which vectors in a plurality of vector columns included in a data set corresponding to the single-vector query task belong overlap partially or completely.

[0141] In one or more possible embodiments of this specification, the screening module is used to:

[0142] Based on heap sort or merge sort, k nearest neighbor vectors of the query vector of the single vector query task and the retrieval similarity of each of the k nearest neighbor vectors are determined in the data set corresponding to the single vector query task.

[0143] One or more embodiments of the present specification also propose a computer program product, including a computer program / instruction, which implements the steps of the method provided in the first aspect when the computer program / instruction is executed by a processor.

[0144] One or more embodiments of the present specification also propose a computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method described in the first aspect.

[0145] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.

[0146] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0147] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0148] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0149] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0150] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0151] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0152] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0153] It should be understood that although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of this specification, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0154] The above description is merely a preferred embodiment of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present specification shall be included in the scope of protection of one or more embodiments of the present specification.

Claims

1. A multi-vector query method, the method comprising: Splitting the multi-vector query task into multiple single-vector query tasks, wherein each single-vector query task has a query vector, and each single-vector query task corresponds to a data set in the database; For each single-vector query task in the multiple single-vector query tasks, determine k neighbor vectors of the query vector of the single-vector query task in the data set corresponding to the single-vector query task, and the retrieval similarity of the neighbor vectors, wherein the retrieval similarity is the similarity between the neighbor vector and the query vector, and k is an integer greater than 1; According to the weight of the data set corresponding to each single-vector query task, and the retrieval similarity and the belonging object of the k nearest neighbor vectors determined by each single-vector query task, the n nearest neighbor objects of the multi-vector query task are determined, where n is an integer greater than 0.

2. The multi-vector query method according to claim 1, wherein the n target objects of the multi-vector query task are determined according to the weight of the data set corresponding to each single-vector query task, and the retrieval similarity and the object to which the k nearest neighbor vectors determined by each single-vector query task belong, comprising: Clustering all neighbor vectors determined by the multiple single-vector query tasks according to the objects to which the neighbor vectors belong, so as to obtain a neighbor vector set of at least one object; For the neighbor vector set of the at least one object, performing weighted summation on all neighbor vectors in the neighbor vector set according to the weights of the data sets to which they belong, so as to obtain a weighted summation result of the neighbor vector set; For the neighbor vector sets of the at least one object, objects to which n neighbor vector sets having the highest weighted summation results belong are respectively determined as neighbor objects.

3. The multi-vector query method according to claim 2, wherein the objects to which the n nearest neighbor vector sets with the highest weighted sum results belong are respectively determined as nearest neighbor objects, comprising: The object to which a nearest neighbor vector set having the highest weighted sum result belongs is determined as the target object of the multi-vector query task.

4. According to the multi-vector query method according to any one of claims 1 to 3, objects to which vectors in data sets corresponding to different single-vector query tasks in the multiple single-vector query tasks belong partially or completely overlap.

5. The multi-vector query method according to claim 1, wherein splitting the multi-vector query task into a plurality of single-vector query tasks comprises: The parts for different query vectors in the SQL statement of the multi-vector query task are split, and each of the split parts is used as an SQL statement of a single-vector query task.

6. The multi-vector query method according to claim 1, wherein when the data set corresponding to the single vector query task contains multiple vector columns, determining k nearest neighbor vectors of the query vector of the single vector query task in the data set corresponding to the single vector query task, and the retrieval similarity of each of the k nearest neighbor vectors, comprises: Determine m candidate neighbor vectors of the query vector of the single-vector query task and the retrieval similarity of the candidate neighbor vectors in the multiple vector columns, respectively, where m is an integer greater than 1; According to the objects to which the m candidate neighbor vectors determined by each vector column in the plurality of vector columns belong, k neighbor vectors and the retrieval similarities of the neighbor vectors are determined.

7. The multi-vector query method according to claim 6, wherein the determining k nearest neighbor vectors and the retrieval similarity of the nearest neighbor vectors according to the objects to which the m candidate nearest neighbor vectors determined by each vector column in the plurality of vector columns belong comprises: If the vectors of any object in each of the multiple vector columns are determined to be candidate neighbor vectors, the vectors of any object in each of the multiple vector columns are combined into one neighbor vector, and the vectors of any object in each of the multiple vector columns are weighted and summed according to the weights of the vector columns, so that the obtained weighted summation result is used as the retrieval similarity of the neighbor vector; Retain the k nearest neighbor vectors with the highest similarity among all the nearest neighbor vectors obtained.

8. The multi-vector query method according to claim 7, wherein the step of retrieving k nearest neighbor vectors with the highest similarity from all the retained nearest neighbor vectors comprises: If the number of all obtained nearest neighbor vectors is greater than k, then the k nearest neighbor vectors with the highest similarity are retained; If the number of all obtained nearest neighbor vectors is not greater than k, all obtained nearest neighbor vectors are retained.

9. According to the multi-vector query method of claim 6, the objects to which the vectors in the multiple vector columns contained in the data set corresponding to the single-vector query task belong overlap partially or completely.

10. The multi-vector query method according to claim 1, wherein determining k nearest neighbor vectors of the query vector of the single vector query task in the data set corresponding to the single vector query task, and the retrieval similarity of each of the k nearest neighbor vectors, comprises: Based on heap sort or merge sort, k nearest neighbor vectors of the query vector of the single vector query task and the retrieval similarity of each of the k nearest neighbor vectors are determined in the data set corresponding to the single vector query task.

11. A multi-vector query device, the device comprising: A splitting module, used to split the multi-vector query task into multiple single-vector query tasks, wherein each single-vector query task has a query vector, and each single-vector query task corresponds to a data set in the database; a query module, configured to determine, for each single-vector query task in the plurality of single-vector query tasks, k neighbor vectors of the query vector of the single-vector query task in the data set corresponding to the single-vector query task, and a retrieval similarity of the neighbor vectors, wherein the retrieval similarity is a similarity between the neighbor vector and the query vector, and k is an integer greater than 1; The screening module is used to determine n neighboring objects of the multi-vector query task according to the weight of the data set corresponding to each single-vector query task and the retrieval similarity and the belonging object of the k neighboring vectors determined by each single-vector query task, where n is an integer greater than 0.

12. The multi-vector query device according to claim 11, wherein the screening module is used for: Clustering all neighbor vectors determined by the multiple single-vector query tasks according to the objects to which the neighbor vectors belong, so as to obtain a neighbor vector set of at least one object; For the neighbor vector set of the at least one object, performing weighted summation on all neighbor vectors in the neighbor vector set according to the weights of the data sets to which they belong, so as to obtain a weighted summation result of the neighbor vector set; For the neighbor vector sets of the at least one object, objects to which n neighbor vector sets having the highest weighted summation results belong are respectively determined as neighbor objects.

13. The multi-vector query device according to claim 12, wherein when the screening module is used to determine the objects to which the n nearest neighbor vector sets with the highest weighted sum results belong as nearest neighbor objects, it is used to: The object to which a nearest neighbor vector set having the highest weighted sum result belongs is determined as the target object of the multi-vector query task.

14. The multi-vector query device according to claim 11, wherein the splitting module is used for: The parts for different data sets in the SQL statement of the multi-vector query task are split, and each of the split parts is used as an SQL statement of a single-vector query task.

15. The multi-vector query device according to claim 11, wherein when the data set corresponding to the single-vector query task contains multiple vector columns, the query module is used to: Determining n candidate neighbor vectors of the query vector of the single-vector query task and the retrieval similarities of the candidate neighbor vectors in the multiple vector columns respectively; According to the objects to which the n candidate neighbor vectors determined by each vector column in the plurality of vector columns belong, k neighbor vectors and the retrieval similarities of the neighbor vectors are determined.

16. The multi-vector query device according to claim 15, wherein the screening module is used to determine k nearest neighbor vectors according to the objects to which the n candidate nearest neighbor vectors determined by each vector column in the plurality of vector columns belong, and the search similarity of the nearest neighbor vectors, and is used to: If the vectors of any object in each of the multiple vector columns are determined to be candidate neighbor vectors, the vectors of any object in each of the multiple vector columns are combined into one neighbor vector, and the vectors of any object in each of the multiple vector columns are weighted and summed according to the weights of the vector columns, so that the obtained weighted summation result is used as the retrieval similarity of the neighbor vector; Retain the k nearest neighbor vectors with the highest similarity among all the nearest neighbor vectors obtained.

17. A computer program product comprising a computer program / instructions, which when executed by a processor implement the steps of the method according to any one of claims 1 to 10.

18. An electronic device comprising: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 10 by running the executable instructions.

19. A computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 10.