Vector retrieval adaptive optimization method and related apparatus
By automatically adjusting the compression model by monitoring changes in key vector rankings, the problem of decreased vector retrieval accuracy caused by changes in data distribution was solved. This achieved efficient and low-cost model optimization, ensuring the stability and accuracy of the vector retrieval system.
Patent Information
- Application Number
- CN202511503143.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-21
- Publication Date
- 2026-01-27
- Estimated Expiration
- 2045-10-21
AI Technical Summary
Existing technologies cannot effectively and promptly retrain models when faced with the performance degradation of compressed models caused by changes in data distribution, resulting in decreased vector retrieval accuracy and wasted computational resources.
By monitoring the ranking changes of key vectors in the candidate set and retrieval set, the performance status of the compressed model is automatically determined, and retraining is performed when performance degrades. The model is optimized using incremental data to achieve on-demand updates.
It enables timely adjustment of the compression model when data distribution changes, ensuring the accuracy and efficiency of vector retrieval, reducing unnecessary consumption of computing resources, and improving operational efficiency and system stability.
Smart Images

Figure CN120973992B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of software technology, and in particular to an adaptive optimization method and related apparatus for vector retrieval. Background Technology
[0002] With the development of artificial intelligence, vector retrieval has become a core technology in many fields such as image search, recommendation systems, and natural language processing. Faced with massive vector data of tens of millions or even hundreds of millions, the industry has developed a mature "approximate nearest neighbor" (ANN) retrieval scheme.
[0003] The aforementioned retrieval scheme mainly consists of two stages: The first stage uses compressed (dimensionality-reduced or quantized) vectors combined with an approximate nearest neighbor algorithm (such as HNSW) to quickly recall a small candidate set from massive amounts of data; this stage primarily prioritizes speed. The second stage focuses solely on the candidate set recalled in the first stage, using full-precision, high-dimensional original vectors for accurate similarity calculation. The candidate set is then reordered based on similarity to obtain the final accurate retrieval set; this stage prioritizes accuracy. The effectiveness of the first stage highly depends on the consistency between the compression model (such as the PCA model) and the current data distribution. However, as data is continuously generated in actual business operations, the underlying data distribution inevitably undergoes conceptual drift over time. This causes the pre-trained compression model to gradually become ineffective, and the compressed vectors cannot accurately represent the relative relationships of the original vectors, resulting in a significant decrease in retrieval accuracy. Summary of the Invention
[0004] In view of the above problems, this application provides a vector retrieval adaptive optimization method and related apparatus to achieve on-demand optimization of the compression model. The specific solution is as follows:
[0005] This application provides a vector retrieval adaptive optimization method, the vector retrieval adaptive optimization method comprising:
[0006] In response to the query vector, a vector retrieval is performed on the query vector to obtain a candidate set and a retrieval set;
[0007] Determine key vectors and determine the performance status of the compression model by comparing the ranking changes of the key vectors in the candidate set and the retrieval set;
[0008] When the performance is in a degraded state, the compressed model is retrained.
[0009] In one possible implementation, determining the key vector includes:
[0010] The vector that ranks highest in the search set is taken as the key vector.
[0011] In one possible implementation, determining the performance state of the compression model by comparing the ranking changes of the key vectors in the candidate set and the retrieval set includes:
[0012] The ranking of the key vectors in the candidate set is calculated to obtain the performance degradation value of the compression model;
[0013] Determine whether the performance degradation value is greater than the corresponding degradation threshold;
[0014] If so, determine that the compression model is in a decay state;
[0015] If not, it is determined that the compression model is in a normal state.
[0016] In one possible implementation, the step of ranking the key vectors in the candidate set to obtain the performance degradation value of the compression model includes:
[0017] Retrieve multiple rankings compiled within a sliding time window;
[0018] The average of the multiple rankings is used to obtain the actual ranking, and the actual ranking is used as the performance degradation value.
[0019] In one possible implementation, retraining the compressed model includes:
[0020] Collect incremental vectors from the data source as a dataset;
[0021] Select a subset of vectors from the dataset as test cases, and divide the other vectors in the dataset, excluding the test cases, into a training set and a test set;
[0022] The compression model is trained using the training set, and the trained compression model is verified using the test set as the retrieval scope and the test cases.
[0023] Once the trained compressed model passes validation, it will be deployed online.
[0024] In one possible implementation, deploying the trained compressed model online includes:
[0025] The trained compressed model is used to rebuild the vector index for all vectors in the data source;
[0026] The alias mechanism smoothly switches query traffic to the vector index.
[0027] A second aspect of this application provides a vector retrieval adaptive optimization device, the vector retrieval adaptive optimization device comprising:
[0028] The vector retrieval module is used to respond to a query vector and perform vector retrieval on the query vector to obtain a candidate set and a retrieval set.
[0029] The model performance determination module is used to determine key vectors and determine the performance status of the compressed model by comparing the ranking changes of the key vectors in the candidate set and the retrieval set.
[0030] The model retraining module is used to retrain the compressed model when the performance state is in a degraded state.
[0031] A third aspect of this application provides a computer program product including computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement the vector retrieval adaptive optimization method described in the first aspect or any implementation thereof.
[0032] A fourth aspect of this application provides an electronic device, including at least one processor and a memory connected to the processor, wherein:
[0033] The memory is used to store computer programs;
[0034] The processor is used to execute the computer program so that the electronic device can implement the vector retrieval adaptive optimization method of the first aspect or any implementation thereof.
[0035] The fifth aspect of this application provides a computer storage medium carrying one or more computer programs, which, when executed by an electronic device, enable the electronic device to implement the vector retrieval adaptive optimization method described in the first aspect or any implementation thereof.
[0036] By employing the above technical solution, this application provides a vector retrieval adaptive optimization method and related apparatus, comprising: responding to a query vector, performing vector retrieval on the query vector to obtain a candidate set and a retrieval set; determining key vectors in the retrieval set, and determining the performance state of a compressed model by comparing the ranking changes of key vectors in the candidate set and the retrieval set; and retraining the compressed model when the performance state is in a decaying state. This application can determine the performance state of the compressed model by comparing the ranking changes of key vectors in the candidate set and the retrieval set after vector retrieval is completed, thereby enabling timely retraining when the model decays. This allows for automatic optimization of the compressed model as needed, ensuring detection accuracy even when concept drift occurs in the data distribution. Attached Figure Description
[0037] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.
[0038] Figure 1 A flowchart illustrating an adaptive optimization method for vector retrieval provided in this application embodiment;
[0039] Figure 2 This is a partial flowchart illustrating an adaptive optimization method for vector retrieval provided in an embodiment of this application.
[0040] Figure 3 This is another schematic diagram of the process of an adaptive optimization method for vector retrieval provided in an embodiment of this application;
[0041] Figure 4 This is another schematic diagram of the process of an adaptive optimization method for vector retrieval provided in an embodiment of this application;
[0042] Figure 5 This is another schematic diagram of the process of an adaptive optimization method for vector retrieval provided in an embodiment of this application;
[0043] Figure 6 A schematic diagram of the structure of a vector retrieval adaptive optimization device provided in an embodiment of this application;
[0044] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0045] The embodiments of this application are described below with reference to the accompanying drawings. The terminology used in the implementation section of this application is for explaining specific embodiments only and is not intended to limit the scope of this application.
[0046] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0047] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.
[0048] To facilitate understanding of this application, the relevant concepts involved in this application will be explained below:
[0049] ES stands for Elasticsearch, a search server built on Lucene. It provides a distributed, multi-user, full-text search engine based on a RESTful web interface. Elasticsearch versions 8.x and later natively support vector search functionality, allowing users to build efficient KNN search services.
[0050] Vector: A point in a high-dimensional space, usually represented by an array of floating-point numbers, used to represent the semantic features of unstructured data such as text, images, and audio.
[0051] KNN: K-Nearest Neighbors algorithm, a method for finding the K most similar data points in a vector space to a query point.
[0052] HNSW: A graph algorithm and data structure for efficiently performing approximate nearest neighbor (ANN) search, widely used in large-scale vector retrieval.
[0053] PCA: Principal Component Analysis, a classic statistical method used for dimensionality reduction of high-dimensional data. It transforms the data to a new coordinate system through linear transformation and retains the principal components with the largest variance.
[0054] Quantization: In this application, it specifically refers to the process of converting high-precision floating-point numbers (such as Float32) into low-precision integers (such as Int8) to reduce memory usage and speed up computation, which usually results in a slight loss of precision.
[0055] Concept drift: In the field of machine learning, this refers to the phenomenon where the statistical properties of data change dynamically over time. In this application, it specifically refers to the shift in the distribution of newly incoming data from the distribution of the old data used to train the compressed model, leading to a decline in model performance.
[0056] In large-scale vector retrieval scenarios, to balance query speed and resource consumption, dimensionality reduction or quantization techniques are typically used to compress the original vectors, and an index is built using near-nearest neighbor algorithms such as HNSW. While this mechanism can achieve rapid recall, its effectiveness is highly dependent on the consistency between the compression model (such as the PCA model) and the current data distribution. However, in real-world business scenarios, data is continuously generated (e.g., new product images, new user behaviors), and the underlying data distribution undergoes "conceptual drift" over time. This causes the pre-trained compression model to gradually become ineffective, and the dimensionality-reduced vectors can no longer accurately represent the relative relationships of the original vectors. The direct consequence is that truly similar vectors from the first stage are ranked relatively low in the candidate set, or even cannot be recalled, leading to a significant decrease in the accuracy of the retrieval set output from the second stage.
[0057] Existing technologies typically employ periodic retraining to address this issue, but this cannot promptly resolve the performance degradation problem of compressed models and may lead to unnecessary waste of computational resources. To address this, this application provides an adaptive optimization method for vector retrieval that can automatically and promptly detect performance degradation in compressed models caused by changes in data distribution (concept drift) and intelligently trigger retraining of the compressed model to continuously ensure the speed and accuracy of vector retrieval.
[0058] See Figure 1 , Figure 1 This is a flowchart illustrating an adaptive optimization method for vector retrieval provided in an embodiment of this application. Figure 1 As shown in the figure, the vector retrieval adaptive optimization method provided in this application embodiment may include steps S101 to S103, which are described in detail below.
[0059] S101, responding to the query vector, performs vector retrieval on the query vector to obtain the candidate set and the retrieval set.
[0060] In this embodiment, before responding to query traffic, initialization is required. This includes collecting initial, representative raw vectors (typically 512-dimensional) to form a vector dataset. Then, a compression algorithm (such as PCA) is run on this vector dataset to train an initial compression model. This model can map vectors from 512 dimensions to 128 dimensions. Using the obtained compression model, all existing data in the data source (database or other storage) is reduced from 512 dimensions to 128 dimensions. The 128-dimensional vectors are then quantized using INT8, and an HNSW index is built in Elasticsearch using the quantized 128-dimensional vectors.
[0061] Based on this, after obtaining the query vector (512 dimensions) input by the user, the system responds to the query vector by transforming it into a 128-dimensional quantized vector through the loaded compression model and quantization process. Then, the quantized vector is used to perform an ANN query in the HNSW index of Elasticsearch to quickly retrieve the Top K candidate results (e.g., K=20) to form a candidate set. The IDs of the K vectors in the candidate set and their respective rankings are recorded.
[0062] Furthermore, based on the IDs of each vector in the candidate set, 512-dimensional original vectors are extracted from the data source. The similarity scores (such as cosine similarity or Euclidean distance) of each extracted original vector and the query vector are calculated one by one. Then, the K vectors in the candidate set are reordered according to the similarity scores to obtain the final and most accurate retrieval set, which is then returned to the user.
[0063] S102, determine the key vectors, and determine the performance status of the compression model by comparing the ranking changes of the key vectors in the candidate set and the retrieval set.
[0064] In this embodiment, a top-ranked vector can be selected as the key vector from the candidate set or the retrieval set. Assuming the key vector ranks 'a' in the candidate set and 'b' in the retrieval set, the difference between rank a and rank b represents the retrieval error in the first stage of vector retrieval. The larger the difference between rank a and rank b, the larger the retrieval error in the first stage, and the closer the performance state of the compression model is to a decaying state. To address this, a ranking difference threshold can be set. If the difference between rank a and rank b is greater than or equal to this threshold, the performance state of the compression model is determined to be in a decaying state; conversely, if the difference between rank a and rank b is less than this threshold, the performance state of the compression model is determined to be in a normal state.
[0065] In one possible implementation, since the retrieval set is the final, accurate retrieval result output by vector retrieval, the higher the ranking of a vector in the retrieval set, the higher its similarity to the query vector, and thus the more likely it is to meet the user's needs. To this end, this application provides a vector retrieval adaptive optimization method, wherein step S102, "determining key vectors," may include the following steps:
[0066] The top-ranked vector in the search set is used as the key vector.
[0067] In this embodiment, the vector with the highest ranking in the retrieval set is selected as the key vector. The lower the ranking of the key vector in the candidate set, the closer the performance state of the compression model is to the decay state.
[0068] Based on this, this application can use the ranking of the key vector in the candidate set as the performance degradation value of the compression model, and then use this performance degradation value to determine whether the compression model is in a degradation state. See also Figure 2 , Figure 2 This is a partial flowchart illustrating an adaptive optimization method for vector retrieval provided in an embodiment of this application. Figure 2 As shown in the embodiment of this application, an adaptive optimization method for vector retrieval is provided. In step S102, "determining the performance status of the compression model by comparing the ranking changes of key vectors in the candidate set and the retrieval set" may include steps S201 to S204. These steps are described in detail below.
[0069] S201, rank the key vectors in the candidate set to obtain the performance degradation value of the compressed model.
[0070] In this embodiment, an asynchronous monitoring task can be executed after vector retrieval is completed. This monitoring task retrieves key vectors from the retrieval set and determines their ranking by matching their IDs in the candidate set. This ranking is then used as the performance degradation value of the compression model. For example, if the ranking of a key vector in the candidate set is rank c, then the performance degradation value of the compression model is c.
[0071] In one possible implementation, to smooth out occasional fluctuations in performance degradation during a single vector retrieval, the performance degradation of the compressed model can be determined by maintaining a sliding window about the ranking of the key vector in the candidate set. See also Figure 3 , Figure 3 This is another schematic diagram of the flowchart of an adaptive optimization method for vector retrieval provided in an embodiment of this application. Figure 3 As shown in the embodiment of this application, an adaptive optimization method for vector retrieval is provided. In this method, step S201, "statistically ranking the key vectors in the candidate set to obtain the performance degradation value of the compression model", may include steps S301 to S302. These steps are described in detail below.
[0072] S301 retrieves multiple rankings compiled under the sliding time window.
[0073] In this embodiment of the application, a sliding time window is set to store the ranking of key vectors counted in the most recent time period. For example, the ranking of multiple consecutive key vectors counted in the most recent 1000 times can be calculated.
[0074] S302 calculates the average of multiple rankings to obtain the actual ranking and uses the actual ranking as the performance degradation value.
[0075] In this embodiment, all rankings under the sliding time window can be averaged, such as by directly calculating the average or calculating the P90 quantile, to obtain the actual ranking under the sliding time window, and the actual ranking can be used as the performance degradation value of the compression model.
[0076] S202, determine whether the performance degradation value is greater than the corresponding degradation threshold. If yes, proceed to step S203; if no, proceed to step S204.
[0077] In this embodiment of the application, the performance degradation value of the compression model is compared with its corresponding degradation threshold. When the performance degradation value exceeds the degradation threshold, it can be determined that the compression model is in a degradation state.
[0078] S203, confirming that the compression model is in a decay state.
[0079] In this embodiment of the application, if the performance degradation value is greater than the degradation threshold, the compression model is determined to be in a degradation state.
[0080] S204, confirming that the compression model is in a normal state.
[0081] In this embodiment of the application, if the performance degradation value is less than or equal to the degradation threshold, the compression model is determined to be in a normal state.
[0082] S103, retrain the compressed model when the performance is in a degraded state.
[0083] In this embodiment of the application, when the performance of the compressed model is in a degraded state, the retraining process of the compressed model is triggered.
[0084] In one possible implementation, the compressed model can be retrained using incremental data to allow it to quickly adapt to the current data distribution. See also Figure 4 , Figure 4 This is another schematic diagram of the flowchart of an adaptive optimization method for vector retrieval provided in an embodiment of this application. Figure 4 As shown in the embodiment of this application, a vector retrieval adaptive optimization method is provided, wherein step S103, "retraining the compressed model", may include steps S401 to S404, which are described in detail below.
[0085] S401 collects incremental vectors from the data source as a dataset.
[0086] In this embodiment of the application, by setting markers on the vectors used in the previous training in the data source, the incremental vectors in the data source can be quickly identified, and the incremental vectors can be used as the dataset for this training.
[0087] S402: Select a subset of vectors from the dataset as test cases, and divide the other vectors in the dataset, except for those used for testing, into training and test sets.
[0088] In this embodiment of the application, a portion of vectors (e.g., 1000 vectors) can be randomly selected from the dataset as test cases, and then the remaining vectors in the dataset other than the test cases can be divided into training set and test set, for example, the remaining vectors can be divided into training set and test set in a ratio of 9:1.
[0089] S403 trains the compression model using the training set and verifies the trained compression model using the test set as the retrieval scope and test cases.
[0090] In this embodiment, the training set can be divided into K parts, and K-1 parts of the vector are used to train the compressed model each time, thus obtaining K trained compressed models. The K trained compressed models are then validated on a test set. Specifically, the original vector (512 dimensions) and the compressed quantized vector (128 dimensions) of the test cases can be used to calculate the similarity in the test set. The compressed model whose similarity calculation result is closest to the original vector among the K trained compressed models is selected as the final compressed model, and this model passes the validation.
[0091] S404: If the trained compressed model passes validation, the trained compressed model will be deployed online.
[0092] In this embodiment of the application, the validated and trained compressed model is deployed online, and marker points are set for the incremental data used in this training.
[0093] In one possible implementation, aliases can be used to smoothly switch between the compressed model before and after training. See also Figure 5 , Figure 5 This is another schematic diagram of the flowchart of an adaptive optimization method for vector retrieval provided in an embodiment of this application. Figure 5 As shown in the embodiment of this application, a vector retrieval adaptive optimization method is provided. In step S404, "uploading the trained compressed model", it can include steps S501 to S502. These steps are described in detail below.
[0094] S501 uses the trained compressed model to rebuild vector indices for all vectors in the data source.
[0095] In this embodiment, the trained compression model is used to reduce all vectors in the data source from 512 dimensions to 128 dimensions, and the 128-dimensional vectors are quantized using INT8. The 128-dimensional quantized vectors are then used to build an HNSW index in Elasticsearch.
[0096] S502 uses an alias mechanism to smoothly switch query traffic to vector indexes.
[0097] In this embodiment of the application, online query traffic can be switched to the latest HNSW index through mechanisms such as aliases, and the old compressed model and HNSW index can be archived or deleted.
[0098] Based on the above description, the vector retrieval adaptive optimization method provided in this application can monitor the performance of the compressed model in real time and automatically trigger model updates when most needed, based on objective quantitative indicators of performance degradation. This minimizes operational costs and computational resource consumption while continuously ensuring high accuracy and efficiency of the vector retrieval service. This application can evaluate the effectiveness of the compressed model in real time and trigger retraining based on the actual performance of the compressed model, achieving intelligent and efficient system maintenance. This application has the following advantages:
[0099] 1) High efficiency and low cost: Since retraining is triggered on demand, unnecessary and expensive computational and storage overhead is avoided when the model is still valid. Resources are only consumed for updates when "needed," greatly improving operational efficiency and economy.
[0100] 2) High timeliness and strong robustness: It can detect performance degradation caused by changes in data distribution in near real time. Once the performance exceeds the red line, the repair process can be quickly initiated, which greatly shortens the time window when the service is in a low-precision state and enhances the stability of the entire vector retrieval system and its adaptability to business changes (robustness).
[0101] 3) Intelligence and automation: The decision-making process of "when to retrain", which relies on human experience and guesswork, is transformed into an automated process driven by objective data, which reduces the reliance on senior operation and maintenance personnel and reduces the risk of human error.
[0102] In other words, this invention solves the core contradiction of existing technologies in dealing with the "concept drift" problem, and achieves the optimal balance between speed, accuracy and cost in a vector retrieval system in a dynamic data environment, continuously and automatically.
[0103] The above describes a vector retrieval adaptive optimization method provided by the embodiments of this application. The following describes the apparatus for performing the above-described vector retrieval adaptive optimization method.
[0104] See Figure 6 , Figure 6 This is a schematic diagram of a vector retrieval adaptive optimization device provided in an embodiment of this application. Figure 6 As shown in the figure, an adaptive optimization device for vector retrieval provided in this application includes:
[0105] The vector retrieval module 601 is used to respond to a query vector and perform vector retrieval on the query vector to obtain a candidate set and a retrieval set.
[0106] The model performance determination module 602 is used to determine key vectors and determine the performance status of the compressed model by comparing the ranking changes of key vectors in the candidate set and the retrieval set.
[0107] The model retraining module 603 is used to retrain the compressed model when the performance state is in a degraded state.
[0108] In one possible implementation, the model performance determination module 602 for determining key vectors is specifically used for:
[0109] The top-ranked vector in the search set is used as the key vector.
[0110] In one possible implementation, the model performance determination module 602, used to determine the performance state of the compressed model by comparing the changes in the ranking of key vectors in the candidate set and the retrieval set, is specifically used for:
[0111] The ranking of key vectors in the candidate set is used to obtain the performance degradation value of the compression model; it is then determined whether the performance degradation value is greater than the corresponding degradation threshold; if so, the compression model is determined to be in a degradation state; otherwise, the compression model is determined to be in a normal state.
[0112] In one possible implementation, the model performance determination module 602, used to rank the key vectors in the candidate set to obtain the performance degradation value of the compressed model, is specifically used for:
[0113] Obtain multiple rankings collected within the sliding time window; average the multiple rankings to obtain the actual ranking, and use the actual ranking as the performance degradation value.
[0114] In one possible implementation, the model retraining module 603 for retraining the compressed model is specifically used for:
[0115] Collect incremental vectors from the data source as a dataset; select a portion of the vectors from the dataset as test cases, and divide the other vectors in the dataset into a training set and a test set; train the compression model using the training set, and use the test set as the retrieval scope and test cases to verify the trained compression model; if the trained compression model passes the verification, deploy the trained compression model online.
[0116] In one possible implementation, the model retraining module 603, used to deploy the trained compressed model online, is specifically used for:
[0117] The trained compressed model is used to rebuild the vector index for all vectors in the data source; query traffic is smoothly switched to the vector index through an alias mechanism.
[0118] It should be noted that the detailed functions of each module in the embodiments of this application can be found in the corresponding disclosure of the above-mentioned vector retrieval adaptive optimization method embodiments, and will not be repeated here.
[0119] This application also provides an electronic device in its embodiments. See also... Figure 7 , Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device in this embodiment may include, but is not limited to, fixed terminals such as mobile phones, laptops, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Figure 7 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0120] like Figure 7 As shown, the electronic device may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage device 708 into a random access memory (RAM) 703. When the electronic device is powered on, the RAM 703 also stores various programs and data required for the operation of the electronic device. The processing unit 701, ROM 702, and RAM 703 are interconnected via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0121] Typically, the following devices can be connected to I / O interface 705: input devices 706 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 707 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 708 including, for example, memory cards, hard drives, etc.; and communication devices 709. Communication device 709 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 7 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have instead.
[0122] This application also provides a computer program product including computer-readable instructions, which, when executed on an electronic device, cause the electronic device to implement any of the vector retrieval adaptive optimization methods provided in this application.
[0123] This application also provides a computer-readable storage medium that carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any of the vector retrieval adaptive optimization methods provided in this application.
[0124] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.
[0125] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0126] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.
[0127] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).
Claims
1. An adaptive optimization method for vector retrieval, characterized in that, The vector retrieval adaptive optimization method includes: In response to the query vector, a vector retrieval is performed on the query vector to obtain a candidate set and a retrieval set. The candidate set is obtained by filtering from the data source based on a compression model. The top-ranked vector in the retrieval set is used as the key vector, and the performance status of the compression model is determined by comparing the ranking changes of the key vector in the candidate set and the retrieval set. The performance status is determined based on the performance decay value, which is the difference in the ranking of the key vector in the candidate set and the retrieval set. When the performance is in a degraded state, the compressed model is retrained, and the retrained compressed model is used for the next vector retrieval.
2. The vector retrieval adaptive optimization method according to claim 1, characterized in that, The step of determining the performance status of the compression model by comparing the ranking changes of the key vectors in the candidate set and the retrieval set includes: The ranking of the key vectors in the candidate set is calculated to obtain the performance degradation value of the compression model; Determine whether the performance degradation value is greater than the corresponding degradation threshold; If so, determine that the compression model is in a decay state; If not, it is determined that the compression model is in a normal state.
3. The vector retrieval adaptive optimization method according to claim 2, characterized in that, The process of ranking the key vectors in the candidate set to obtain the performance degradation value of the compression model includes: Retrieve multiple rankings compiled within a sliding time window; The average of the multiple rankings is used to obtain the actual ranking, and the difference between the actual ranking and the ranking of the key vector in the candidate set is used as the performance degradation value.
4. The vector retrieval adaptive optimization method according to claim 1, characterized in that, The retraining of the compressed model includes: Incremental vectors are collected from the data source as a dataset; Select a subset of vectors from the dataset as test cases, and divide the other vectors in the dataset, excluding the test cases, into a training set and a test set; The compression model is trained using the training set, and the trained compression model is verified using the test set as the retrieval scope and the test cases. Once the trained compressed model passes validation, it will be deployed online.
5. The vector retrieval adaptive optimization method according to claim 4, characterized in that, The step of deploying the trained compressed model online includes: The trained compressed model is used to rebuild the vector index for all vectors in the data source; The alias mechanism smoothly switches query traffic to the vector index.
6. A vector retrieval adaptive optimization device, characterized in that, The vector retrieval adaptive optimization device includes: The vector retrieval module is used to respond to a query vector and perform a vector retrieval on the query vector to obtain a candidate set and a retrieval set. The candidate set is obtained by filtering from the data source based on a compression model. The model performance determination module is used to take the top-ranked vector in the retrieval set as the key vector, and determine the performance status of the compressed model by comparing the ranking changes of the key vector in the candidate set and the retrieval set. The performance status is determined based on the performance decay value, which is the difference in the ranking of the key vector in the candidate set and the retrieval set. The model retraining module is used to retrain the compressed model when the performance state is in a decay state, and the retrained compressed model is used for the next vector retrieval.
7. A computer program product, characterized in that, Includes computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement the vector retrieval adaptive optimization method as described in any one of claims 1 to 5.
8. An electronic device, characterized in that, It includes at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program to enable the electronic device to implement the vector retrieval adaptive optimization method as described in any one of claims 1 to 5.
9. A computer storage medium, characterized in that, The storage medium carries one or more computer programs that, when executed by an electronic device, enable the electronic device to implement the vector retrieval adaptive optimization method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
NL2SQL modeling method and device, electronic equipment and storage medium
CN115455156A
Data retrieval method, device and system, electronic equipment and readable storage medium
CN118093962A