Index updating method, computing device and storage medium

By combining the write-ahead log mechanism with the feature vector library, the problem of retrieval performance degradation caused by FAISS index updates was solved, quasi-real-time updates and flexible index switching were achieved, and the retrieval performance and adaptability of model upgrades were improved.

CN114968922BActive Publication Date: 2025-10-03HAINAN CHEZHIYITONG INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210374574.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-11
Publication Date
2025-10-03
Estimated Expiration
2042-04-11

AI Technical Summary

Technical Problem

The existing FAISS index update method leads to a decline in retrieval performance when frequently updated, and fails to effectively utilize the characteristics of relational databases, increasing system complexity and overall retrieval time. In particular, when the algorithm model is upgraded, multidimensional vectors need to be regenerated, which is time-consuming and affects retrieval performance.

Method used

A write-ahead log mechanism is adopted. By writing feature data in the target write-ahead log file and updating the index regularly, combined with the FAISS index, feature identifiers are directly used as retrieval identifiers, eliminating the need to maintain a mapping table between index identifiers and metadata databases. A feature vector library is introduced to generate feature vectors offline, and vector slice files are generated to support flexible switching of index types.

Benefits of technology

It achieves quasi-real-time index updates, reduces the probability of retrieval performance degradation, improves retrieval performance, and does not affect the retrieval function of the current version when the deep learning model is upgraded, and supports flexible switching of index types.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114968922B_ABST
    Figure CN114968922B_ABST
Patent Text Reader

Abstract

The present invention discloses an index updating method, a computing device and a storage medium. The method comprises: determining a target write-ahead log file; writing feature data into the target write-ahead log file, the feature data comprising a feature vector and a feature identifier corresponding to the feature vector; when the size of the target write-ahead log file reaches a first threshold, creating a new target write-ahead log file and writing the feature data into the new target write-ahead log file; and periodically extracting the latest feature data from all current target write-ahead log files and adding the data to an index to update the index.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of big data processing and indexing technology, and in particular to an index updating method, computing device and storage medium. Background Art

[0002] On the internet, a vast amount of image metadata is generated constantly, typically stored in relational databases. The general process involves first adding the image metadata to the relational database, then invoking an algorithm model to generate the corresponding multidimensional vector, and finally adding the multidimensional vector to the FAISS index. FAISS, short for Facebook AI Similarity Search, is a tool developed by Facebook's AI (Artificial Intelligence) team to address the problem of large-scale similarity retrieval.

[0003] As an open-source library, FAISS provides efficient and reliable retrieval methods for massive amounts of data in high-dimensional spaces. However, FAISS only offers basic add, delete, and modify methods. In practice, adding or deleting vectors can severely degrade retrieval performance. Furthermore, with the advancement of deep learning technology, algorithm models are becoming increasingly complex, making the generation of multidimensional vectors a time-consuming task. Furthermore, as vector quality becomes increasingly demanding, frequent algorithm model upgrades are necessary.

[0004] Currently, updating the FAISS index is implemented using a queue middleware. Simply put, image metadata is first inserted into the queue middleware, which is then retrieved daily or weekly. The algorithm model is used to generate the corresponding multidimensional vector, which is then added to the FAISS index.

[0005] However, the FAISS index based on the queue middleware does not make good use of the characteristics of relational databases. Instead, it introduces additional dependencies and increases the complexity of the system. At the same time, there is a time delay in index updates. During the daily or weekly index update stage, the retrieval performance will also drop significantly. This does not solve the problem of degraded retrieval performance, but only narrows and concentrates the time period of performance degradation. Since vectors cannot be restored from the index, multidimensional vectors need to be regenerated when the index type is changed, which is very time-consuming. In order to match the retrieved vectors with the image metadata, a mapping table needs to be maintained. The retrieval results need to query the mapping table first, which increases the overall retrieval time and still does not solve the problem of algorithm model upgrades.

[0006] Therefore, a new index update method is needed to optimize the above process. Summary of the Invention

[0007] To this end, the present invention provides an index update solution to try to solve or at least alleviate the above problems.

[0008] According to one aspect of the present invention, an index updating method is provided, comprising the following steps: first, determining a target write-ahead log file; writing feature data into the target write-ahead log file, the feature data comprising a feature vector and a feature identifier corresponding to the feature vector; when the size of the target write-ahead log file reaches a first threshold, creating a new target write-ahead log file and writing the feature data into the new target write-ahead log file; and periodically extracting the latest feature data from all current target write-ahead log files and adding it to an index to update the index.

[0009] Optionally, in the index update method according to the present invention, the step of determining the target write-ahead log file includes: if the target write-ahead log file does not exist, creating the write-ahead log file; and pre-allocating a disk of a first threshold size for the write-ahead log file, and using the write-ahead log file as the target write-ahead log file.

[0010] Optionally, in the index update method according to the present invention, the step of writing feature data to the target write-ahead log file includes: associating a corresponding serial number with each feature data in sequence; and inserting each feature data associated with the serial number into the tail of the target write-ahead log file in sequence.

[0011] Optionally, in the index update method according to the present invention, the step of periodically extracting the latest feature data from all current target write-ahead log files includes: periodically traversing all current target write-ahead log files; extracting feature data whose associated serial number is greater than the first serial number value as the latest feature data, and updating the first serial number value to the corresponding serial number.

[0012] Optionally, the index update method according to the present invention also includes: periodically querying the distributed object storage system to determine whether there is any missing feature data in the vector slice file; if so, extracting the missing feature data from the corresponding vector slice file and writing it into the slice pre-write log file.

[0013] Optionally, in the index update method according to the present invention, the step of extracting missing feature data from the corresponding vector slice file includes: downloading the corresponding vector slice file from the distributed object storage system; traversing the downloaded vector slice file to extract feature data whose feature identifier is less than the first serial number value and greater than the second serial number value as the missing feature data.

[0014] Optionally, the index update method according to the present invention also includes pre-generating feature vectors and storing them. The steps of pre-generating feature vectors and storing them include: querying the image database to obtain a first number of images whose deep learning model version number is equal to the current version number; for each acquired image, calling the deep learning model to process it to generate a corresponding feature vector; storing each feature vector into a feature vector library, and updating the deep learning model version number associated with the corresponding image in the image database.

[0015] Optionally, in the index updating method according to the present invention, the feature vector library includes multiple feature vector data, and each feature vector data includes a feature identifier, an image identifier, a deep learning model version number and a feature vector.

[0016] Optionally, the index update method according to the present invention also includes pre-generating a vector slice file and storing it. The step of pre-generating a vector slice file and storing it includes: determining the feature identifier corresponding to the last feature vector in the previous vector slice file according to the vector slice file naming rules, and using it as the first comparison identifier; querying the feature vector library to obtain the largest feature identifier whose deep learning model version number is equal to the current version number, as the second comparison identifier; if the difference between the second comparison identifier and the first comparison identifier is greater than a second threshold, generating a new vector slice file and storing it in the distributed object storage system.

[0017] Optionally, in the index update method according to the present invention, the step of generating a new vector slice file includes: creating a new vector slice file; writing file header information to the vector slice file; obtaining a second number of feature vectors whose deep learning model version number is equal to the current version number from the feature vector library each time, and feature identifiers corresponding to the feature vectors, and writing them into the vector slice file in sequence.

[0018] According to another aspect of the present invention, a computing device is provided, comprising: at least one processor; and a memory storing program instructions, wherein the program instructions are configured to be suitable for execution by the at least one processor, and the program instructions include instructions for executing the index update method as described above.

[0019] According to another aspect of the present invention, a readable storage medium storing program instructions is provided. When the program instructions are read and executed by a computing device, the computing device executes the index updating method described above.

[0020] According to the index update scheme of the present invention, feature data is first written to a determined target pre-written log file. The feature data includes a feature vector and a feature identifier corresponding to the feature vector. When the size of the target pre-written log file reaches a first threshold, a new target pre-written log file is created, and feature data is written to the new target pre-written log file. The latest feature data is periodically extracted from all current target pre-written log files and added to the index to update the index. The above technical solution is based on the pre-written log mechanism and combined with the FAISS index. It does not require a queue middleware. When adding to the index, the feature identifier can be directly used as the retrieval identifier, eliminating the need to maintain the index identifier and the metadata database mapping table. It can effectively reduce the probability of retrieval performance degradation due to frequent index updates, achieve the effect of quasi-real-time updates, and improve the overall retrieval performance.

[0021] Furthermore, a feature vector library has been introduced. Since feature vector generation can be handled by a separate module and run offline, when a deep learning model is upgraded, only the new deep learning model needs to be called, without affecting the retrieval function of the current model version. This allows for flexible handling of feature vector inconsistencies caused by model upgrades. Furthermore, vector slice files are generated and stored based on the feature vectors. When changing index types later, simply loading the vector slice files is sufficient, enabling flexible switching of index types. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] To achieve the above and related purposes, certain illustrative aspects are described herein in conjunction with the following description and accompanying drawings, which indicate various ways in which the principles disclosed herein may be practiced, and all aspects and their equivalents are intended to fall within the scope of the claimed subject matter. The above and other objects, features, and advantages of the present disclosure will become more apparent by reading the following detailed description in conjunction with the accompanying drawings. Throughout this disclosure, the same reference numerals generally refer to the same parts or elements.

[0023] Figure 1 shows a structural block diagram of a computing device 100 according to an embodiment of the present invention; and

[0024] Figure 2 FIG. 2 is a flowchart of an index updating method 200 according to an embodiment of the present invention. DETAILED DESCRIPTION

[0025] Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0026] Figure 1 FIG. 1 shows a structural block diagram of a computing device 100 according to an embodiment of the present invention.

[0027] like Figure 1 As shown, in a basic configuration 102, computing device 100 typically includes system memory 106 and one or more processors 104. A memory bus 108 may be used for communication between processor 104 and system memory 106.

[0028] Depending on the desired configuration, the processor 104 can be any type of processor, including but not limited to: a microprocessor (UP), a microcontroller (UC), a digital signal processing unit (DSP), or any combination thereof. The processor 104 can include one or more levels of cache, such as a level 1 cache 110 and a level 2 cache 112, a processor core 114, and registers 116. An example processor core 114 can include an arithmetic logic unit (ALU), a floating point unit (FPU), a digital signal processing core (DSP core), or any combination thereof. An example memory controller 118 can be used with the processor 104, or in some implementations, the memory controller 118 can be an internal part of the processor 104.

[0029] Depending on the desired configuration, system memory 106 can be any type of memory, including but not limited to volatile memory (such as RAM), non-volatile memory (such as ROM, flash memory, etc.), or any combination thereof. System memory 106 can include an operating system 120, one or more applications 122, and program data 124. In some embodiments, application 122 can be arranged to execute instructions on the operating system by one or more processors 104 using program data 124.

[0030] Computing device 100 also includes storage 132 , which includes removable storage 136 and non-removable storage 138 .

[0031] The computing device 100 may also include a storage interface bus 134. The storage interface bus 134 enables communication from storage devices 132 (e.g., removable storage 136 and non-removable storage 138) to the basic configuration 102 via the bus / interface controller 130. At least a portion of the operating system 120, applications 122, and program data 124 may be stored on the removable storage 136 and / or the non-removable storage 138 and loaded into the system memory 106 via the storage interface bus 134 when the computing device 100 is powered on or when the application 122 is to be executed, and executed by the one or more processors 104.

[0032] The computing device 100 may also include an interface bus 140 that facilitates communication from various interface devices (e.g., output devices 142, peripheral interfaces 144, and communication devices 146) to the basic configuration 102 via the bus / interface controller 130. Example output devices 142 include a graphics processing unit 148 and an audio processing unit 150. These can be configured to facilitate communication with various external devices such as a display or speakers via one or more A / V ports 152. Example peripheral interfaces 144 may include a serial interface controller 154 and a parallel interface controller 156, which can be configured to facilitate communication with external devices such as input devices (e.g., a keyboard, mouse, pen, voice input device, touch input device) or other peripherals (e.g., a printer, scanner, etc.) via one or more I / O ports 158. Example communication devices 146 may include a network controller 160, which can be arranged to facilitate communication with one or more other computing devices 162 via a network communication link via one or more communication ports 164.

[0033] A network communication link can be an example of a communication medium. Communication media can generally be embodied as computer-readable instructions, data structures, program modules in a modulated data signal such as a carrier wave or other transmission mechanism, and can include any information delivery medium. A "modulated data signal" can be a signal in which one or more of a data set or a change therein can be carried out in a manner that encodes information in the signal. As non-limiting examples, communication media can include wired media such as a wired network or a dedicated line network, and various wireless media such as sound, radio frequency (RF), microwave, infrared (IR) or other wireless media. The term computer-readable medium as used herein can include both storage media and communication media.

[0034] The computing device 100 can be implemented as a personal computer including desktop and notebook computer configurations. Of course, the computing device 100 can also be implemented as part of a small-sized portable (or mobile) electronic device, such as a cellular phone, a digital camera, a personal digital assistant (PDA), a personal media player device, a wireless network browsing device, a personal head-mounted device, an application-specific device, or a hybrid device that can include any of the above functions. It can even be implemented as a server, such as a file server, a database server, an application server, and a web server. The embodiments of the present invention are not limited to this.

[0035] In an embodiment according to the present invention, the computing device 100 is configured to execute the index update method 200 according to the present invention. The application 122 deployed on the operating system includes multiple program instructions for executing the index update method 200 of the present invention. These program instructions can instruct the processor 104 to execute the index update method 200 of the present invention, so that the computing device 200 generates and completes the index update by executing the index update method 200 of the present invention.

[0036] Figure 2 FIG2 is a flowchart of an index updating method 200 according to an embodiment of the present invention. The index updating method 200 may be executed in a computing device (eg, the aforementioned computing device 100). It should be noted that the indexes involved in the present invention are all FAISS indexes.

[0037] like Figure 2 As shown, method 200 begins at step S210. In step S210, a target write-ahead log file is determined. According to one embodiment of the present invention, the target write-ahead log file can be determined as follows. In this embodiment, if the target write-ahead log file does not exist, a write-ahead log file is created. A disk of a first threshold size is pre-allocated to the write-ahead log file, and the write-ahead log file is used as the target write-ahead log file. The first threshold size can be set to 128 MB (megabytes).

[0038] A write-ahead log file is a WAL file. WAL stands for Write-Ahead Logging. For a newly created write-ahead log file, a fixed-size disk of 128MB is pre-allocated. This write-ahead log file is used as the target write-ahead log file and named seq.wal. The value of seq is 0, 1, 2, ..., which are increasing non-negative integers, and wal represents the file format. If a target write-ahead log file with a size smaller than the first threshold already exists, it is directly used as the target write-ahead log file for subsequent feature data writing.

[0039] Then, the process proceeds to step S220 , where feature data is written to the target write-ahead log file. The feature data includes a feature vector and a feature identifier corresponding to the feature vector.

[0040] According to one embodiment of the present invention, method 200 further includes pre-generating and storing feature vectors. In this embodiment, the image database is first queried to obtain a first number of images whose deep learning model version number is equal to the current version number. The first number can be set to 1000. In this case, each time the image database is queried, 1000 images whose deep learning model version number is equal to the current version number are obtained from the image database.

[0041] The main fields of the image database include image ID, deep learning model version number and image URL (Uniform Resource Locator). Users can store the image URL in the image database in real time by calling the corresponding interface.

[0042] Image IDs are generally auto-incremental. The deep learning model version number is the version number of the deep learning model used when extracting feature vectors, and the image URL is the original image address. Each time the deep learning model is upgraded, the deep learning model version number is incremented by 1. If the deep learning model version number is equal to the current version number, it indicates that the latest feature vector has been extracted for the image.

[0043] The following is an example of an image database:

[0044] Image logo Deep learning model version number Image URL 2 4 http: / / xxx.jpg 3 3 http: / / xxx.png

[0045] Table 1

[0046] Table 1 shows an example of image data in an image database according to an embodiment of the present invention. Taking the image data with image ID 2 as an example, its deep learning model version number is 4, and the image URL, i.e., the original image address, is http: / / xxx.jpg.

[0047] Then, for each acquired image, the deep learning model is invoked to generate a corresponding feature vector. Each feature vector is then stored in the feature vector library, and the deep learning model version number associated with the corresponding image in the image database is updated. This feature vector generation process can be handled by a separate module and run offline to avoid the adverse effects of real-time feature vector generation on retrieval performance.

[0048] The feature vector library can be thought of as a sub-library of the image database. Its main fields include feature identifiers, image identifiers, deep learning model version numbers, and feature vectors. In other words, the feature vector library contains multiple pieces of feature vector data, each of which includes a feature identifier, image identifier, deep learning model version number, and a feature vector.

[0049] In the feature vector data, the feature identifier is generally self-incrementing. The image identifier and the deep learning model version number correspond to the image identifier and the deep learning model version number in the image database, respectively. The feature vector is a multidimensional vector generated by calling the deep learning model to process the image corresponding to the image identifier.

[0050] The following are examples of feature vector libraries:

[0051] Feature Identifier Image logo Deep learning model version number Eigenvector 1 2 4 [0.3,…,0.2] 2 3 3 [0.6,…,0.9]

[0052] Table 2

[0053] Table 2 shows an example of feature vector data in a feature vector library according to an embodiment of the present invention. Taking feature vector data with feature ID 1 as an example, its image ID is 2, the deep learning model version number is 4, and the feature vector is [0.3, ..., 0.2].

[0054] According to one embodiment of the present invention, feature data may be written to a target write-ahead log file in the following manner: In this embodiment, each feature data is sequentially associated with a corresponding sequence number, and the feature data associated with each sequence number is sequentially inserted into the end of the target write-ahead log file.

[0055] For example, if id represents the feature identifier and feature represents the feature vector, then the feature data can be represented as [id, feature]. For each [id, feature], a sequence number is assigned, which can be represented by index. The index is then associated with [id, feature]. For example, index can be inserted into the head of [id, feature] to form [index, id, feature] as the feature data associated with the sequence number. Then, [index, id, feature] is inserted into the end of the seq.wal file.

[0056] In step S230, when the size of the target write-ahead log file reaches a first threshold, a new target write-ahead log file is created, and feature data is written to the new target write-ahead log file. According to one embodiment of the present invention, when the size of the target write-ahead log file reaches 128 MB, a new target write-ahead log file is created and named seq+1.wal, and feature data can continue to be written to the seq+1.wal file.

[0057] Finally, step S240 is executed to periodically extract the latest feature data from all currently targeted write-ahead log files and add it to the index to update the index. Because the target write-ahead log files are stored locally, an update request can be submitted to the FAISS index every second, achieving near-real-time updates. Furthermore, retrieval performance does not significantly decrease with a single index. When adding to the FAISS index, the feature identifier can be directly used as the index identifier, eliminating the need to maintain a mapping table between the index identifier and the metadata database, thus improving overall retrieval speed.

[0058] According to one embodiment of the present invention, the latest feature data can be periodically extracted from all currently targeted write-ahead log files in the following manner. In this embodiment, all currently targeted write-ahead log files are first periodically traversed, and feature data associated with a sequence number greater than a first sequence number value is extracted as the latest feature data, and the first sequence number value is correspondingly updated as the sequence number.

[0059] The first sequence number value is represented by max_id, which records the minimum id (feature identifier) ​​value among all [index, id, feature] (feature data associated with sequence numbers) in all realtime_wal files (real-time write-ahead log files). max_id means that all [id, feature] with an index less than or equal to max_id in [index, id, feature] have been updated to the index.

[0060] The above-mentioned realtime_wal file refers to newly added images during the index type change and deep learning model upgrade. For these newly added images, a new WAL file is first created, recorded as realtime_wal. After the corresponding feature vectors are generated and stored in the feature vector library, the corresponding interface can be called to write the feature identifier and feature vector to the realtime_wal file. The specific process can be seen in the above description of generating and storing feature vectors and steps S210 and S220, and will not be repeated here.

[0061] For example, if the seq.wal file is currently being traversed, then when the index in [index, id, feature] is greater than max_id, [id, feature] is added to the index, and max_id is updated with index. If a seq+1.wal file exists, it is deleted after traversing the seq.wal file. In other words, only the most recent target write-ahead log file is retained, and all other target write-ahead log files are deleted. That is, except for the WAL file with the largest seq value, all other WAL files are deleted.

[0062] According to one embodiment of the present invention, method 200 further includes periodically querying the distributed object storage system to determine whether any vector slice files contain missing feature data. If so, the missing feature data is extracted from the corresponding vector slice files and written to a slice write-ahead log file. In this embodiment, the slice write-ahead log file is referred to as a shard_wal file.

[0063] For ease of description and understanding, the relevant contents of the vector slice file are first described here. According to one embodiment of the present invention, method 200 also includes pre-generating and storing the vector slice file. First, according to the vector slice file naming rules, the feature identifier corresponding to the last feature vector in the previous vector slice file is determined and used as the first comparison identifier.

[0064] The naming rules for vector slice files require that the name of a vector slice file include at least the deep learning model version number, the feature identifier of the first feature vector in the vector slice file, and the feature identifier of the last feature vector in the vector slice file. ft_version represents the deep learning model version number, and first_id and last_id represent the feature identifiers of the first and last feature vectors in the vector slice file, respectively. Therefore, the name of a vector slice file can be expressed as ft_version / first_id-last_id.ft, where ft represents the file format.

[0065] By querying the distributed object storage system and following the vector slice file naming convention of ft_version / first_id-last_id.ft, the feature identifier corresponding to the last feature vector in the previous vector slice file is determined as the first comparison identifier, recorded as previous_last_id. This previous_last_id is the feature identifier corresponding to the last feature vector in the vector slice file in the feature vector library.

[0066] Then, the feature vector library is queried to obtain the largest feature identifier whose deep learning model version number is equal to the current version number as the second comparison identifier. If the difference between the second comparison identifier and the first comparison identifier is greater than the second threshold, a new vector slice file is generated and stored in the distributed object storage system. Among them, the second threshold can be set to 20000000. In other words, a vector slice file is generated for every 20000000 feature vectors, and it can be checked regularly (such as every day) whether the conditions for generating a new vector slice file are met. If so, the generation of a new vector slice file begins.

[0067] The above-mentioned distributed object storage system can use MinIO (a high-performance, distributed object storage system), and the file storage path of the vector slice file in it is ft_version / first_id-last_id.ft.

[0068] The second comparison identifier is recorded as temp_id. If temp_id-previous_last_id>20000000, start generating a new vector slice file. The first_id of the vector slice file is previous_last_id+1, and the last_id is previous_last_id+20000000.

[0069] When generating a new vector slice file, usually a new vector slice file is first created, and then file header information is written into the vector slice file. Each time, a second quantity of feature vectors whose deep learning model version numbers are equal to the current version number are obtained from the feature vector library, along with the corresponding feature identifiers, and are written into the vector slice file in sequence. Here, the second quantity can be set to 1000. The feature vectors and the corresponding feature identifiers actually constitute the feature data, and what is ultimately written into the vector slice file is actually individual feature data.

[0070] The storage format of the vector slice file has the file header information as the head, and the feature identifiers and feature vectors are arranged in sequence thereafter. The file header information includes the data type and the feature dimension. For example, when the vector slice file is stored, it is in the following order: data type, feature dimension, feature identifier 1, feature vector 1, feature identifier 2, feature vector 2,..., feature identifier 20000000, feature vector 20000000. Feature vector 1 corresponds to feature identifier 1, feature identifier 2 corresponds to feature vector 2,..., feature identifier 20000000 corresponds to feature vector 2000000.

[0071] When querying the distributed object storage system, if a vector slice file with first_id < max_id < last_id is found, it means that there are missing feature data in the vector slice file. At this time, the missing feature data can be extracted from the corresponding vector slice file in the following way. First, download the corresponding vector slice file from the distributed object storage system, and then traverse the downloaded vector slice file to extract the feature data whose feature identifiers are less than the first sequence number value and greater than the second sequence number value as the missing feature data.

[0072] Let min_id represent the second sequence number value, which records the largest last_id in the names first_id-last_id.ft of all downloaded vector slice files when changing the index type. Then ultimately, the feature data that satisfies the condition min_id < id < max_id is written into the shard_wal file.

[0073] According to one embodiment of the present invention, when the index type is changed, the deep learning model version number is determined according to the current version number, and all vector slice files under the path ft_version / in the distributed object storage system are downloaded locally. For each vector slice file, the header file information is first read to obtain the data type and feature dimension, and then according to the data type and feature dimension, a third number (such as 1000) of corresponding feature identifiers and feature vectors are decoded each time, and finally a new related WAL file is created and recorded as shard_wal, and the interface is called to write the third number of feature identifiers and feature vectors into the shard_wal file. For the specific process, please refer to the relevant content in steps S210 to S240, which will not be repeated here.

[0074] In addition, when the deep learning model is upgraded, the deep learning model version number is increased by 1, and the image database and feature vector library are updated synchronously. The feature vector of the latest version is then generated, and the feature vector is written to the shard_wal file according to the above processing procedure when changing the index type.

[0075] In actual applications, after receiving an image retrieval request, the deep learning model is first called to obtain the multi-dimensional feature vector corresponding to the image, and then the FAISS search is called to obtain the feature identifier of similar images. This feature identifier is also the feature identifier in the feature vector library. The image identifier in the feature vector library is obtained through the feature identifier, and finally the image information in the image database is obtained through the image identifier and returned to the image retrieval requester.

[0076] According to the index update scheme of an embodiment of the present invention, feature data is first written to a determined target write-ahead log file. The feature data includes a feature vector and a feature identifier corresponding to the feature vector. When the size of the target write-ahead log file reaches a first threshold, a new target write-ahead log file is created, and feature data is written to the new target write-ahead log file. The latest feature data is extracted from all current target write-ahead log files at regular intervals and added to the index to update the index. The above technical solution is based on the write-ahead log mechanism and combined with the FAISS index. It does not require a queue middleware. When adding to the index, the feature identifier can be directly used as the retrieval identifier, eliminating the need to maintain the index identifier and the metadata database mapping table. It can effectively reduce the probability of retrieval performance degradation due to frequent index updates, achieve a quasi-real-time update effect, and improve the overall retrieval performance.

[0077] Furthermore, a feature vector library has been introduced. Since feature vector generation can be handled by a separate module and run offline, when a deep learning model is upgraded, only the new deep learning model needs to be called, without affecting the retrieval function of the current model version. This allows for flexible handling of feature vector inconsistencies caused by model upgrades. Furthermore, vector slice files are generated and stored based on the feature vectors. When changing index types later, simply loading the vector slice files is sufficient, enabling flexible switching of index types.

[0078] The various techniques described herein may be implemented in conjunction with hardware or software, or a combination thereof. Thus, the methods and apparatus of the present invention, or certain aspects or portions of the methods and apparatus of the present invention, may be implemented in the form of program codes (i.e., instructions) embedded in a tangible medium, such as a removable hard disk, a USB flash drive, a floppy disk, a CD-ROM, or any other machine-readable storage medium, wherein when the program is loaded into a machine such as a computer and executed by the machine, the machine becomes an apparatus for practicing the present invention.

[0079] When the program code is executed on a programmable computer, the computing device generally includes a processor, a storage medium readable by the processor (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device. The memory is configured to store the program code; and the processor is configured to execute the index update method of the present invention according to instructions in the program code stored in the memory.

[0080] By way of example and not limitation, readable media include readable storage media and communication media. Readable storage media store information such as computer-readable instructions, data structures, program modules, or other data. Communication media typically embody computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and include any information delivery medium. Combinations of any of the above are also included within the scope of readable media.

[0081] In the description provided herein, the algorithms and displays are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems may also be used in conjunction with the examples of the present invention. Based on the above description, it is apparent that the structure required for constructing such systems is well understood. In addition, the present invention is not directed to any specific programming language. It should be understood that various programming languages ​​may be utilized to implement the present invention described herein, and the description of specific languages ​​above is provided for the purpose of disclosing the preferred embodiment of the present invention.

[0082] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of this description.

[0083] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected in the claims below, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Accordingly, the claims that follow the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of the invention.

[0084] Those skilled in the art will appreciate that the modules, units, or components of the devices in the examples disclosed herein may be arranged in the device described in the embodiment, or alternatively may be located in one or more devices different from the devices in the examples. The modules in the foregoing examples may be combined into one module or further divided into multiple submodules.

[0085] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition may be divided into multiple submodules or subunits or subcomponents. All features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed herein may be combined in any combination, except that at least some of such features and / or processes or units are mutually exclusive. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.

[0086] Furthermore, those skilled in the art will appreciate that although some embodiments described herein include certain features included in other embodiments but not other features, combinations of features from different embodiments are intended to be within the scope of the present invention and to form different embodiments. For example, in the claims below, any of the claimed embodiments may be used in any combination.

[0087] In addition, some of the embodiments are described herein as methods or combinations of method elements that can be implemented by a processor of a computer system or by other devices that perform the functions described. Thus, a processor having the necessary instructions for implementing the method or method element forms a device for implementing the method or method element. Furthermore, the elements described herein of the device embodiments are examples of devices for implementing the functions performed by the elements for the purpose of implementing the invention.

[0088] As used herein, unless otherwise specified, the use of ordinal numbers "first," "second," "third," etc. to describe common objects merely indicates that different instances of similar objects are involved and are not intended to imply that the objects so described must have a given order in time, space, ranking, or in any other manner.

[0089] Although the present invention has been described with respect to a limited number of embodiments, it will be apparent to those skilled in the art, having benefit of the foregoing description, that other embodiments are contemplated within the scope of the invention thus described. Furthermore, it should be noted that the language used in this specification has been selected primarily for readability and didactic purposes, rather than for the purpose of explaining or limiting the subject matter of the present invention. Consequently, many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the appended claims. The disclosure of the present invention is intended to be illustrative rather than restrictive of the scope of the invention, which is defined by the appended claims.

Claims

1. An index updating method, comprising: Pre-generating and storing feature vectors includes: querying an image database to obtain a first number of images whose deep learning model version number is equal to the current version number; for each obtained image, invoking the deep learning model to process it to generate a corresponding feature vector; storing each feature vector in a feature vector library, and updating the deep learning model version number associated with the corresponding image in the image database; wherein the feature vector library includes multiple feature vector data, each feature vector data including a feature identifier, an image identifier, a deep learning model version number, and a feature vector; Determine the target write-ahead log file; Writing feature data to the target write-ahead log file, the feature data including a feature vector and a feature identifier corresponding to the feature vector; When the size of the target write-ahead log file reaches a first threshold, creating a new target write-ahead log file, and writing the characteristic data into the new target write-ahead log file; The latest feature data is extracted from all current target write-ahead log files at regular intervals and added to the index to update the index, wherein the index is a FAISS index.

2. The method according to claim 1, wherein The step of determining the target write-ahead log file includes: If the target write-ahead log file does not exist, create a write-ahead log file; For the write-ahead log file, a disk of the first threshold size is pre-allocated, and the write-ahead log file is used as a target write-ahead log file.

3. The method according to claim 2, wherein: The step of writing characteristic data to the target write-ahead log file includes: For each characteristic data, the corresponding serial number is associated in turn; Each piece of characteristic data associated with a sequence number is inserted into the tail of the target write-ahead log file in sequence.

4. The method according to claim 3, wherein: The step of periodically extracting the latest feature data from all current target write-ahead log files includes: Regularly traverse all current target write-ahead log files; Extract the feature data whose associated serial number is greater than the first serial number value as the latest feature data, and update the first serial number value to the corresponding serial number, wherein the first serial number value means that the feature data whose serial number is less than or equal to the first serial number value has been updated to the index.

5. The method of claim 4, further comprising: Periodically querying the distributed object storage system to determine whether there is any missing feature data in the vector slice file, wherein the vector slice file stores feature data including feature vectors and corresponding feature identifiers in the feature vector library; If so, the missing feature data is extracted from the corresponding vector slice file and written to the slice pre-write log file.

6. The method according to claim 5, wherein: The step of extracting the missing feature data from the corresponding vector slice file includes: Downloading a corresponding vector slice file from the distributed object storage system, wherein the name of the vector slice file includes a feature identifier first_id of the first feature vector and a feature identifier last_id of the last feature vector in the vector slice file; Traverse the downloaded vector slice files to extract feature data whose feature identifier is less than the first serial number value and greater than the second serial number value as the missing feature data, wherein the second serial number value is the largest last_id among the names of all downloaded vector slice files.

7. The method according to claim 5, further comprising pre-generating and storing a vector slice file, wherein the step of pre-generating and storing a vector slice file comprises: According to the naming rules of the vector slice file, the feature identifier corresponding to the last feature vector in the previous vector slice file is determined and used as the first comparison identifier; Query the feature vector library to obtain the feature identifier with the largest deep learning model version number equal to the current version number as the second comparison identifier; If the difference between the second comparison identifier and the first comparison identifier is greater than a second threshold, a new vector slice file is generated and stored in the distributed object storage system.

8. The method of claim 7, wherein: The step of generating a new vector slice file includes: Create a new vector tile file; Writing file header information to the vector slice file; Each time, a second number of feature vectors whose deep learning model version numbers are equal to the current version number and feature identifiers corresponding to the feature vectors are obtained from the feature vector library and written into the vector slice file in sequence.

9. A computing device comprising: at least one processor; as well as A memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, and the program instructions include instructions for executing the method according to any one of claims 1 to 8.

10. A readable storage medium storing program instructions, wherein when the program instructions are read and executed by a computing device, the computing device is caused to execute the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Log-structured storage systems

    CN111886591A

  • Image intelligent storage method, system and device and storage medium

    CN113297403A