Index generation method and device and electronic equipment

By determining and using different parameter groups to build indexes in the vector database, the problem of balancing index construction speed and search effect is solved, and the efficiency and reliability of index generation are improved.

CN118626486AActive Publication Date: 2024-09-10BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410686425.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-30
Publication Date
2024-09-10
Estimated Expiration
2044-05-30

AI Technical Summary

Technical Problem

Existing vector databases cannot take into account both index construction speed and search results when building indexes, which affects user experience.

Method used

When receiving the search request, determine the first and second parameter groups, build an initial index based on the first parameter group, build a second index based on the second parameter group after meeting the preset conditions, delete the first index, and use the second index Search.

Benefits of technology

The index construction speed and search effect are improved, thereby improving the efficiency and reliability of index generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626486A
    Figure CN118626486A
Patent Text Reader

Abstract

The invention provides an index generation method and device and electronic equipment, and relates to the technical field of computers, in particular to the technical field of artificial intelligence such as big data and natural language processing. According to the specific scheme, when a search request for a first vector database is received and the first vector database has no available index, a first parameter set and a second parameter set are determined firstly, and a first index of the first vector database is constructed based on the first parameter set, so that the first vector database is searched based on the first index; and then constructing a second index of the first vector database based on the second parameter group under the condition of meeting a preset condition, deleting the first index under the condition of determining that the construction of the second index is completed, and searching the first vector database based on the second index.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, in particular to the field of artificial intelligence technology such as big data and natural language processing, and specifically to an index generation method, device and electronic device. Background Art

[0002] In the prior art, when constructing an index in a vector database, a Hierarchical Navigable Small World (HNSW) approach is usually used. However, vector databases using this approach currently cannot take into account both index construction speed and search performance, which affects user experience. Summary of the invention

[0003] The present disclosure aims to solve one of the technical problems in the related art at least to some extent.

[0004] The first embodiment of the present disclosure provides an index generation method, including:

[0005] Upon receiving a search request for a first vector database and when the first vector database has no available index, determining a first parameter group and a second parameter group, wherein a parameter value in the second parameter group is greater than a corresponding parameter value in the first parameter group;

[0006] Based on the first parameter group, construct a first index of the first vector database, so as to search the first vector database based on the first index;

[0007] When a preset condition is met, constructing a second index of the first vector database based on the second parameter group;

[0008] When it is determined that the second index is built, the first index is deleted, and the first vector database is searched based on the second index.

[0009] The second aspect of the present disclosure provides an index generation device, including:

[0010] a determination module, configured to determine, upon receiving a search request for a first vector database and in a case where the first vector database has no available index, a first parameter group and a second parameter group, wherein a parameter value in the second parameter group is greater than a corresponding parameter value in the first parameter group;

[0011] A first building module, configured to build a first index of the first vector database based on the first parameter group, so as to search the first vector database based on the first index;

[0012] A second construction module, configured to construct a second index of the first vector database based on the second parameter group when a preset condition is met;

[0013] A processing module is used to delete the first index when it is determined that the second index is built, and search the first vector database based on the second index.

[0014] The third aspect embodiment of the present disclosure proposes a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the index generation method proposed in the first aspect embodiment of the present disclosure is implemented.

[0015] The fourth aspect embodiment of the present disclosure proposes a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the index generation method proposed in the first aspect embodiment of the present disclosure is implemented.

[0016] The fifth aspect embodiment of the present disclosure proposes a computer program product, including a computer program, which, when executed by a processor, implements the index generation method proposed in the first aspect embodiment of the present disclosure.

[0017] The index generation method, device and electronic device provided by the present disclosure have the following beneficial effects:

[0018] In the disclosed embodiment, when a search request for a first vector database is received and there is no available index for the first vector database, the first parameter group and the second parameter group are first determined, and based on the first parameter group, a first index of the first vector database is constructed to search the first vector database based on the first index, and then, when a preset condition is met, a second index of the first vector database is constructed based on the second parameter group, and when it is determined that the construction of the second index is complete, the first index is deleted, and the first vector database is searched based on the second index. Thus, by constructing the first index of the first vector database based on the first parameter group, and constructing the second index based on the second parameter group when the preset condition is met, and deleting the first index, the efficiency and reliability of index generation are improved on the basis of improving the index construction speed and index search effect.

[0019] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0021] Figure 1 A flowchart of an index generation method provided by an embodiment of the present disclosure;

[0022] Figure 2 A flowchart of an index generation method provided by an embodiment of the present disclosure;

[0023] Figure 3 A schematic diagram of a first index and a second index constructed for an embodiment of the present disclosure;

[0024] Figure 4 A flowchart of an index generation method provided by an embodiment of the present disclosure;

[0025] Figure 5 A schematic diagram of the structure of an index generating device provided by an embodiment of the present disclosure;

[0026] Figure 6 A block diagram of an exemplary computer device suitable for implementing embodiments of the present disclosure is shown. DETAILED DESCRIPTION

[0027] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0028] The present disclosure relates to the fields of artificial intelligence technologies such as big data and natural language processing.

[0029] Artificial Intelligence (AI) is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence.

[0030] Big data refers to a collection of data that cannot be captured, managed, and processed by conventional software tools within a certain time frame. It is a massive, high-growth, and diverse information asset that requires new processing models to have stronger decision-making power, insight discovery, and process optimization capabilities.

[0031] Natural Language Processing (NLP) is an interdisciplinary subject in the fields of computer science, artificial intelligence and linguistics. It mainly studies how to enable computers to understand, process, generate and simulate human language, so as to achieve the ability to have natural conversations with humans.

[0032] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0033] The index generation method, device and electronic device according to the embodiments of the present disclosure are described below with reference to the accompanying drawings.

[0034] Figure 1 A flowchart of an index generation method provided by an embodiment of the present disclosure.

[0035] like Figure 1 As shown, the index generation method may include the following steps:

[0036] Step 101, when a search request for a first vector database is received and the first vector database has no available index, determine a first parameter group and a second parameter group, wherein a parameter value in the second parameter group is greater than a corresponding parameter value in the first parameter group.

[0037] It should be noted that the first vector database may be any pre-set vector database, and the present disclosure does not limit this.

[0038] The first parameter group and the second parameter group may both be parameter groups containing parameters for constructing an index of the first vector database. For example, the first parameter group and the second parameter group may both contain a threshold value for the number of neighbor nodes of each vector in the first vector database, and a number of candidate neighbors of each vector, etc. The threshold value for the number of neighbor nodes may be a critical value for the number of neighbor nodes of each vector, which may be pre-set, and the present disclosure does not limit this.

[0039] In some possible implementation forms, the first parameter group and the second parameter group may be determined according to the number of vectors included in the first vector database, thereby ensuring the reliability of the determined first parameter group and the second parameter group.

[0040] It should be noted that the number of vectors included in the first vector database is different, and the determined first parameter group and second parameter group may be different, which is not limited in the present disclosure.

[0041] In some possible implementation forms, two groups of parameters in any set of preset parameter pairs may be respectively determined as the first parameter group and the second parameter group, thereby improving the accuracy of the determined first parameter group and the second parameter group.

[0042] The parameter pair may be a parameter pair including a neighbor node quantity threshold parameter of each vector in the first vector database and a candidate neighbor quantity parameter of the corresponding vector.

[0043] In the present disclosure, when a search request for a first vector database is received and there is no available index in the first vector database, in order to ensure user experience, it is necessary to construct an index of the first vector database. At this time, the first parameter group and the second parameter group for constructing the index in the first vector database can be first determined based on the number of vectors contained in the first vector database, or by two sets of parameters in any set of preset parameter pairs, thereby providing conditions for constructing the index of the first vector database and improving the flexibility of determining the parameters for constructing the index of the first vector database.

[0044] Step 102: construct a first index of a first vector database based on a first parameter group, so as to search the first vector database based on the first index.

[0045] It should be noted that the first index may include vector data in the first vector database and an edge set associated with the vector data, wherein the edge set may include a node set of neighbor nodes having connecting edges with nodes of the vector data.

[0046] In the present disclosure, after determining the first parameter group and the second parameter group, in order to increase the index construction speed of the first vector database and improve the user search experience, a first index in the first vector database can be constructed based on the first parameter group, so that the user can search the first vector database based on the first index with a faster construction speed.

[0047] Step 103: construct a second index of the first vector database based on the second parameter group when a preset condition is met.

[0048] Among them, the preset condition may be a condition for determining whether the second index of the first vector database can be constructed based on the second parameter group. It may be any pre-set condition, and the present disclosure does not limit this.

[0049] It should be noted that the range of vector data corresponding to the second index is the same as that of the first index, and the range of the edge set in the second index is larger than the range of the edge set in the first index.

[0050] In some possible implementations, the preset conditions may include at least one of the following: the system's remaining resources are greater than a resource threshold; the duration for which the system's remaining resources are greater than the resource threshold is greater than a duration threshold; an instruction to create a second index is received; and the current operating period is within a preset time range.

[0051] The resource threshold may be a critical value of the remaining system resources for determining whether the second index of the first vector database can be constructed based on the second parameter group. The resource threshold may be pre-set and the present disclosure does not limit this.

[0052] The duration threshold may be a critical value of the duration used to determine whether the remaining system resources can be used to construct the second index. It may be pre-set and the present disclosure does not limit this.

[0053] The time range may be a time range used to construct the second index based on the second parameter group, and the range may be preset, which is not limited in the present disclosure.

[0054] In the present disclosure, when the remaining resource amount of the system is greater than the resource amount threshold, or the duration for which the remaining resource amount of the system is greater than the resource amount threshold is greater than the duration threshold, it can be determined that the current remaining resource amount of the system satisfies the resource amount required for constructing the second index based on the second parameter group. At this time, the second index of the first vector database can be constructed based on the second parameter group, or when an instruction to create a second index is received, or the current operating period is within a preset time range, the second index can be constructed based on the second parameter group, thereby improving the success rate of constructing the second index.

[0055] In the present disclosure, after constructing a first index and searching the first vector database based on the first index, in order to improve the search effect of the first vector database, a second index of the first vector database may be constructed based on a second parameter group.

[0056] Step 104: when it is determined that the second index is constructed, the first index is deleted, and the first vector database is searched based on the second index.

[0057] In the present disclosure, when it is determined that the second index is constructed, since the data range corresponding to the second index is the same as the data range corresponding to the first index, in order to improve system resource utilization and improve search results, the first index can be deleted and the first vector database can be searched based on the second index.

[0058] In the disclosed embodiment, when a search request for a first vector database is received and there is no available index for the first vector database, the first parameter group and the second parameter group are first determined, and based on the first parameter group, a first index of the first vector database is constructed to search the first vector database based on the first index, and then, when a preset condition is met, a second index of the first vector database is constructed based on the second parameter group, and when it is determined that the construction of the second index is complete, the first index is deleted, and the first vector database is searched based on the second index. Thus, by constructing the first index of the first vector database based on the first parameter group, and when the preset condition is met, constructing the second index based on the second parameter group with a larger parameter value, and deleting the first index, the efficiency and reliability of index generation are improved on the basis of improving the index construction speed and index search effect.

[0059] Figure 2 A flowchart of an index generation method provided by an embodiment of the present disclosure.

[0060] like Figure 2 As shown, the index generation method may include the following steps:

[0061] Step 201, when a search request for a first vector database is received and the first vector database has no available index, determine a first parameter group and a second parameter group, wherein a parameter value in the second parameter group is greater than a corresponding parameter value in the first parameter group.

[0062] Step 202: construct a first index of the first vector database based on the first parameter group, so as to search the first vector database based on the first index.

[0063] The specific implementation forms of step 201 to step 202 can refer to the detailed descriptions in other embodiments of the present disclosure, and will not be described in detail here.

[0064] Step 203: Store the distance set associated with the first edge set in the first index, wherein the distance set includes the first distance value of each connecting edge in the first edge set.

[0065] The first edge set may be a node set including connecting edges between the vector node in the first index and the neighboring nodes.

[0066] In the present disclosure, after constructing the first index of the first vector database, the distance set associated with the first edge set in the first index may be stored, thereby providing a data basis for improving the efficiency of constructing the second index.

[0067] In the present disclosure, taking HNSW as an example, when generating the distance set associated with the first edge set, since the distance set will be calculated when the HNSW graph is built, no extra time will be consumed when generating the distance set associated with the first edge set. The first vector database can usually control the number of nodes of HNSW through sharding, so that the generated distance set occupies less space, thereby saving system resources.

[0068] Among them, HNSW is the abbreviation of Hierarchical Navigable Small World (HNSW).

[0069] Step 204: construct a second edge set in a second index of the first vector database based on the second parameter group and the distance set when a preset condition is met.

[0070] In the present disclosure, when preset conditions are met, in order to improve user search results and index building efficiency, a second edge set in a second index of the first vector database may be constructed based on a second parameter group and a distance set.

[0071] Combine the following Figure 3 An example is given of constructing a first index and a second index by using the index generation method provided by the present disclosure. Figure 3 A schematic diagram of a first index and a second index constructed for an embodiment of the present disclosure. Figure 3 The index diagram in the figure takes the index diagram of HNSW as an example; level is the layer; neighbors can be the neighbor nodes corresponding to node #1 or node #2 in each layer; distances can be the distance value set of the connection edges between node #1 or node #2 and the neighbor nodes in each layer.

[0072] like Figure 3 As shown, through the first parameter combination, the first index of node #1 or node #2 constructed can include the original data (floating point vector) and the first edge set. At the same time, the distance set associated with the first edge set of node #1 or node #2 can also be generated. If the conditions are met, based on the distance set associated with the first edge set and the second parameter group, the second index of node #1 or node #2 constructed includes the original data (floating point vector) and the second edge set. Figure 3 It can be obtained that the original data range corresponding to the first index of node #1 or node #2 is the same as the original data range corresponding to the second index.

[0073] Step 205 : when it is determined that the second edge set in the second index is constructed, the first edge set is deleted, and the first vector database is searched based on the second index.

[0074] In the present disclosure, when it is determined that the second edge set in the second index is constructed, in order to save system resources, the first edge set can be deleted, and the first vector data can be searched based on the second index, thereby improving the search effect and enhancing the user experience.

[0075] In the disclosed embodiment, when a search request for a first vector database is received and there is no available index for the first vector database, the first parameter group and the second parameter group are first determined, and based on the first parameter group, a first index of the first vector database is constructed to search the first vector database based on the first index, and then the distance set associated with the first edge set in the first index is stored, and when a preset condition is met, a second edge set in a second index of the first vector database is constructed based on the second parameter group and the distance set, and finally, when it is determined that the construction of the second index is completed, the first index is deleted, and the first vector database is searched based on the second index. Thus, after the first index of the first vector database is constructed based on the first parameter group, when the preset condition is met, a second index of the first vector database is constructed based on the distance set associated with the first edge set in the first index and the second parameter group, thereby improving the efficiency of index generation and enhancing the user experience.

[0076] Figure 4 A flowchart of an index generation method provided by an embodiment of the present disclosure.

[0077] like Figure 4 As shown, the index generation method may include the following steps:

[0078] Step 401, upon receiving a search request for a first vector database and in the case that the first vector database has no available index, determining a first parameter group and a second parameter group, wherein a parameter value in the second parameter group is greater than a corresponding parameter value in the first parameter group.

[0079] Step 402: construct a first index of a first vector database based on a first parameter group, so as to search the first vector database based on the first index.

[0080] Step 403: Store the distance set associated with the first edge set in the first index, wherein the distance set includes the first distance value of each connecting edge in the first edge set.

[0081] The specific implementation forms of steps 401 to 403 may refer to the detailed descriptions in other embodiments of the present disclosure, and will not be described in detail here.

[0082] Step 404 : when the preset conditions are met, based on the exploration element EF construction parameters in the second parameter group, determine a candidate neighbor set of the first vector in the first vector database.

[0083] Among them, EF can be the abbreviation of exploration factor.

[0084] The exploration factor EF construction parameter can be used to determine the number of candidate neighbors of the first vector, which can be any preset value. For example, when EF is 200, the number of candidate neighbors of the first vector can be determined to be 200, and so on, which is not limited in the present disclosure.

[0085] It should be noted that the first vector may be any vector in the first vector database, and the present disclosure does not limit this.

[0086] The candidate neighbor set may be a set of candidate neighbors that include the first vector.

[0087] In the present disclosure, when the preset conditions are met, the candidate neighbor set of the first vector can be determined based on the exploration element EF construction parameters in the second parameter group to provide conditions for constructing the second edge set in the second index.

[0088] It should be noted that, if the exploration element EF construction parameters in the second parameter group are different, the determined candidate neighbor sets of the first vector may be different, and this is not limited in the present disclosure.

[0089] It should be noted that the value of the exploration element EF construction parameter in the second parameter group is greater than the value of the exploration element EF construction parameter in the first parameter group.

[0090] Step 405 , based on the identifier of each candidate neighbor in the candidate neighbor set, traverse the distance set corresponding to the first vector to obtain a first distance value of the connection edge corresponding to the candidate neighbor.

[0091] The identifier of the candidate neighbor may be used to characterize the candidate neighbor of the first vector, and may be an identifier in any pre-set form, which is not limited in the present disclosure.

[0092] In the present disclosure, after determining the candidate neighbor set of the first vector, the distance set corresponding to the first vector can be traversed based on the identifier of each candidate neighbor in the candidate neighbor set to obtain the first distance value of the connecting edge corresponding to the candidate neighbor.

[0093] It should be noted that different first vectors may correspond to different distance sets, which is not limited in the present disclosure.

[0094] Step 406 : When the distance set does not contain the first distance value of the connecting edge corresponding to any candidate neighbor vector, calculate the second distance value between the first vector and any candidate neighbor vector.

[0095] In the present disclosure, based on the identifier of each candidate neighbor in the candidate neighbor set, the distance set corresponding to the first vector is traversed to obtain the first distance value of the connecting edge corresponding to the candidate neighbor. When the distance set does not contain the first distance value of the connecting edge corresponding to any candidate neighbor vector, the second distance value between the first vector and any candidate neighbor vector can be directly calculated, thereby improving the flexibility and reliability of determining the distance value between the first vector and the candidate neighbor vector.

[0096] Step 407 : Determine a neighbor node corresponding to the first vector in each layer according to the first distance value or the second distance value corresponding to each candidate neighbor of the first vector.

[0097] In the present disclosure, after determining the first distance value or the second distance value corresponding to each candidate neighbor of the first vector, based on the neighbor node number threshold of the first vector in the second parameter group and the distance values ​​of the candidate neighbor nodes of the first vector in each layer, the candidate neighbor nodes with smaller distance values ​​can be determined as neighbor nodes of the first vector by a threshold number of neighbor nodes. The present disclosure does not limit this.

[0098] Step 408: construct a second edge set in the second index based on the neighbor nodes corresponding to each vector in each layer in the first vector database.

[0099] In the present disclosure, after determining the neighbor nodes corresponding to the first vector in each layer, a second edge set in the second index can be constructed based on the neighbor nodes corresponding to each vector in each layer in the first vector database, thereby improving the accuracy and reliability of the second edge set of the constructed second index.

[0100] Step 409: When it is determined that the second edge set in the second index is constructed, the first edge set is deleted, and the first vector database is searched based on the second index.

[0101] The specific implementation of step 409 can refer to the detailed description in other embodiments of the present disclosure, and will not be described in detail here.

[0102] In an embodiment of the present disclosure, when a search request for a first vector database is received and the first vector database has no available index, the first parameter group and the second parameter group are first determined, and based on the first parameter group, a first index of the first vector database is constructed to search the first vector database based on the first index, and then a distance set associated with the first edge set in the first index is stored. When a preset condition is met, a candidate neighbor set of the first vector in the first vector database is determined based on the exploration element EF construction parameter in the second parameter group, and based on the identifier of each candidate neighbor in the candidate neighbor set, the distance set corresponding to the first vector is traversed to obtain a first distance value of a connecting edge corresponding to the candidate neighbor. When the distance set does not contain the first distance value of a connecting edge corresponding to any candidate neighbor vector, the second distance value between the first vector and any candidate neighbor vector is calculated. Then, according to the first distance value or the second distance value corresponding to each candidate neighbor of the first vector, the neighbor node corresponding to the first vector in each layer is determined, and based on the neighbor node corresponding to each vector in each layer in the first vector database, a second edge set in the second index is constructed. When it is determined that the second edge set in the second index is constructed, the first edge set is deleted, and the first vector database is searched based on the second index. Therefore, after constructing the first index of the first vector database, under the condition of meeting the preset conditions, the candidate neighbors of the first vector are determined based on the exploration element EF construction parameters in the second parameter group, and the distance values ​​of the connecting edges corresponding to the candidate neighbors are determined based on the distance set associated with the first edge set in the first index. When the distance value of the connecting edge corresponding to any candidate neighbor is not included in the distance set associated with the first edge set, the distance value of the connecting edge of any candidate neighbor is determined by direct calculation, and the neighbor nodes of the first vector in each layer are determined based on the distance value of each candidate neighbor, and the second edge set in the second index is constructed based on the neighbor nodes of each vector in the first vector database, thereby improving the accuracy and reliability of index generation and improving the effect of index search.

[0103] In order to implement the above embodiment, the present disclosure also proposes an index generating device.

[0104] Figure 5 A schematic diagram of the structure of an index generating device provided in an embodiment of the present disclosure.

[0105] like Figure 5 As shown, the index generating device 500 includes: a determining module 501 , a first constructing module 502 , a second constructing module 503 , and a processing module 504 .

[0106] A determination module 501 is configured to determine a first parameter group and a second parameter group when a search request for a first vector database is received and the first vector database has no available index, wherein a parameter value in the second parameter group is greater than a corresponding parameter value in the first parameter group;

[0107] A first construction module 502 is used to construct a first index of the first vector database based on the first parameter group, so as to search the first vector database based on the first index;

[0108] A second construction module 503 is used to construct a second index of the first vector database based on a second parameter group when a preset condition is met;

[0109] The processing module 504 is configured to delete the first index when it is determined that the second index is constructed, and search the first vector database based on the second index.

[0110] In a possible implementation of the present disclosure, the first building module 502 is further used to:

[0111] storing a distance set associated with the first edge set in the first index, wherein the distance set includes a first distance value of each connected edge in the first edge set;

[0112] The second building block 503 is further used for:

[0113] Based on the second parameter group and the distance set, a second edge set of the first vector database is constructed.

[0114] In a possible implementation of the present disclosure, the second building module 503 is further used to:

[0115] Determine a candidate neighbor set of the first vector in the first vector database based on the exploration element EF construction parameters in the second parameter group;

[0116] Based on the identifier of each candidate neighbor in the candidate neighbor set, traverse the distance set corresponding to the first vector to obtain a first distance value of the connection edge corresponding to the candidate neighbor;

[0117] When the distance set does not contain the first distance value of the connecting edge corresponding to any candidate neighbor vector, calculate the second distance value between the first vector and any candidate neighbor vector;

[0118] Determine a neighbor node corresponding to the first vector in each layer according to the first distance value or the second distance value corresponding to each candidate neighbor of the first vector;

[0119] A second edge set is constructed based on the neighbor nodes corresponding to each vector in each layer in the first vector database.

[0120] In a possible implementation of the present disclosure, the second building module 503 is further used to:

[0121] Delete the first edge set.

[0122] In a possible implementation of the present disclosure, the determination module 501 is specifically configured to:

[0123] A first parameter group and a second parameter group are determined according to the number of vectors included in the first vector database.

[0124] In a possible implementation of the present disclosure, the determination module 501 is specifically configured to:

[0125] Two groups of parameters in any set of preset parameter pairs are respectively determined as a first parameter group and a second parameter group.

[0126] In a possible implementation of the present disclosure, the preset condition includes at least one of the following:

[0127] The remaining resources of the system are greater than the resource threshold;

[0128] The duration that the remaining resources of the system are greater than the resource threshold is greater than the duration threshold;

[0129] Receiving an instruction to create a second index;

[0130] The current runtime period is within the preset time range.

[0131] The functions and specific implementation principles of the above modules in the embodiments of the present disclosure can be referred to the above method embodiments, and will not be repeated here.

[0132] In the disclosed embodiment, when a search request for a first vector database is received and there is no available index for the first vector database, the first parameter group and the second parameter group are first determined, and based on the first parameter group, a first index of the first vector database is constructed to search the first vector database based on the first index, and then, when a preset condition is met, a second index of the first vector database is constructed based on the second parameter group, and when it is determined that the construction of the second index is complete, the first index is deleted, and the first vector database is searched based on the second index. Thus, by constructing the first index of the first vector database based on the first parameter group, and constructing the second index based on the second parameter group when the preset condition is met, and deleting the first index, the efficiency and reliability of index generation are improved on the basis of improving the index construction speed and index search effect.

[0133] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0134] Figure 6A schematic block diagram of an example electronic device 600 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0135] like Figure 6 As shown, the device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0136] A number of components in the device 600 are connected to the I / O interface 605, including: an input unit 606, such as a keyboard, a mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a disk, an optical disk, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 609 allows the device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0137] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 601 performs the various methods and processes described above, such as the index generation method. For example, in some embodiments, the index generation method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 600 via ROM 602 and / or communication unit 609. When the computer program is loaded into RAM 603 and executed by the computing unit 601, one or more steps of the index generation method described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform the index generation method in any other appropriate manner (e.g., by means of firmware).

[0138] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0139] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable index generating device, so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0140] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0141] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0142] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.

[0143] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain.

[0144] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0145] In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. In the description of the present disclosure, the words "if" and "if" used can be interpreted as "at the time of" or "when" or "in response to determination" or "under the circumstances of".

[0146] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A method for generating an index, comprising: Upon receiving a search request for a first vector database and when the first vector database has no available index, determining a first parameter group and a second parameter group, wherein a parameter value in the second parameter group is greater than a corresponding parameter value in the first parameter group; Based on the first parameter group, construct a first index of the first vector database, so as to search the first vector database based on the first index; When a preset condition is met, constructing a second index of the first vector database based on the second parameter group; When it is determined that the second index is built, the first index is deleted, and the first vector database is searched based on the second index.

2. The method of claim 1, wherein: After the first index of the first vector database is constructed by the first parameter group, the method further includes: storing a distance set associated with a first edge set in the first index, wherein the distance set includes a first distance value of each connecting edge in the first edge set; The constructing a second index of the first vector database based on the second parameter group includes: Based on the second parameter group and the distance set, a second edge set of the first vector database is constructed.

3. The method of claim 2, wherein: The constructing a second edge set of the first vector database based on the second parameter group and the distance set includes: determining a candidate neighbor set of the first vector in the first vector database based on the exploration element EF construction parameters in the second parameter group; Based on the identifier of each candidate neighbor in the candidate neighbor set, traverse the distance set corresponding to the first vector to obtain a first distance value of the connection edge corresponding to the candidate neighbor; When the distance set does not contain the first distance value of the connecting edge corresponding to any candidate neighbor vector, calculating the second distance value between the first vector and any candidate neighbor vector; Determine a neighbor node corresponding to the first vector in each layer according to a first distance value or a second distance value corresponding to each candidate neighbor of the first vector; The second edge set is constructed based on the neighbor nodes corresponding to each vector in each layer in the first vector database.

4. The method of claim 2, wherein: The deleting the first index comprises: Delete the first edge set.

5. The method of claim 1, wherein: The determining of the first parameter group and the second parameter group includes: The first parameter group and the second parameter group are determined according to the number of vectors included in the first vector database.

6. The method of claim 1, wherein: The determining of the first parameter group and the second parameter group includes: Two groups of parameters in any set of preset parameter pairs are respectively determined as the first parameter group and the second parameter group.

7. The method according to any one of claims 1 to 6, wherein: The preset condition includes at least one of the following: The remaining resources of the system are greater than the resource threshold; The duration that the remaining resources of the system are greater than the resource threshold is greater than the duration threshold; Receiving an instruction to create a second index; The current runtime period is within the preset time range.

8. An index generating device, wherein: The device comprises: a determination module, configured to determine, upon receiving a search request for a first vector database and in a case where the first vector database has no available index, a first parameter group and a second parameter group, wherein a parameter value in the second parameter group is greater than a corresponding parameter value in the first parameter group; A first building module, configured to build a first index of the first vector database based on the first parameter group, so as to search the first vector database based on the first index; A second construction module, configured to construct a second index of the first vector database based on the second parameter group when a preset condition is met; A processing module is used to delete the first index when it is determined that the second index is built, and search the first vector database based on the second index.

9. The device of claim 8, wherein: The first building block is further used for: storing a distance set associated with a first edge set in the first index, wherein the distance set includes a first distance value of each connecting edge in the first edge set; The second building block is further used for: Based on the second parameter group and the distance set, a second edge set of the first vector database is constructed.

10. The device of claim 9, wherein: The second building block is further used for: determining a candidate neighbor set of the first vector in the first vector database based on the exploration element EF construction parameters in the second parameter group; Based on the identifier of each candidate neighbor in the candidate neighbor set, traverse the distance set corresponding to the first vector to obtain a first distance value of the connection edge corresponding to the candidate neighbor; When the distance set does not contain the first distance value of the connecting edge corresponding to any candidate neighbor vector, calculating the second distance value between the first vector and any candidate neighbor vector; Determine a neighbor node corresponding to the first vector in each layer according to a first distance value or a second distance value corresponding to each candidate neighbor of the first vector; The second edge set is constructed based on the neighbor nodes corresponding to each vector in each layer in the first vector database.

11. The device according to claim 9, wherein: The second building block is further used for: Delete the first edge set.

12. The device of claim 8, wherein: The determination module is specifically used for: The first parameter group and the second parameter group are determined according to the number of vectors included in the first vector database.

13. The device of claim 8, wherein: The determination module is specifically used for: Two groups of parameters in any set of preset parameter pairs are respectively determined as the first parameter group and the second parameter group.

14. The device according to any one of claims 8 to 13, wherein: The preset condition includes at least one of the following: The remaining resources of the system are greater than the resource threshold; The duration that the remaining resources of the system are greater than the resource threshold is greater than the duration threshold; Receiving an instruction to create a second index; The current runtime period is within the preset time range.

15. An electronic device, characterized in that: include: at least one processor; and, a memory communicatively coupled to the at least one processor; The memory stores instructions that may be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method according to any one of claims 1 to 7.

16. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-7.

17. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method for creating index, searching method, device and system

    CN102890682A

  • Index construction method and device, electronic equipment and storage medium

    CN113821704A

  • Vector data index updating method and device and related equipment

    CN117763204A

  • Big data index optimization method and device, electronic equipment and storage medium

    CN117873995A

  • Data retrieval method, device and system, electronic equipment and readable storage medium

    CN118093962A