Intelligent dynamic K value retrieval optimization system and method
By introducing a multi-dimensional feature library of questions and an adversarial training optimization module, and dynamically adjusting the top-k value, the adaptability problem of existing retrieval systems under different query scenarios is solved, and intelligent optimization of retrieval results is achieved.
Patent Information
- Application Number
- CN202511608174.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-05
- Publication Date
- 2026-03-03
AI Technical Summary
Existing retrieval systems fail to dynamically adjust the top-k value when performing similarity queries, making it difficult to adapt to diverse query scenarios, especially those involving different domains and complexities.
A multi-dimensional feature library for the problem is introduced. The generator network predicts the optimal K value by combining a dynamic K-value generation module with an adversarial training optimization module. A multi-index fusion loss function and an adaptive temperature control mechanism are used to optimize the generator performance.
The system achieves intelligent adaptive optimization for the retrieval system under different query scenarios, improving metrics such as precision, recall, normalized loss cumulative gain, average accuracy, and hit probability.
Smart Images

Figure CN121597716A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent retrieval technology, specifically to an intelligent dynamic K-value retrieval optimization system and method. Background Technology
[0002] With the deep application of artificial intelligence technology in fields such as natural language processing, recommendation systems, and image recognition, vector-based retrieval technology has become one of the core supporting technologies due to its ability to efficiently handle the similarity matching requirements of high-dimensional data. Currently, mainstream vector retrieval systems typically integrate vector database storage modules (for efficient management of massive high-dimensional vector data) and embedded vector caching modules (for improving the response speed of high-frequency queries). Some systems also introduce technologies such as GAN model training, automatic hyperparameter tuning, and incremental updates to optimize retrieval accuracy and iteration efficiency.
[0003] However, existing retrieval systems generally use a fixed top-k value setting (such as defaulting to top-5 or top-10 results) when performing similarity queries. This k value is mostly preset by human experience or configured by static rules, without considering the "differentiated characteristics of the question itself" in the retrieval task. For example, questions in different fields (such as medical diagnosis consultations and casual chat Q&A) have different requirements for the number of search results. The number of candidate results required for highly complex questions (such as multi-condition logical reasoning questions) is different from that required for simple questions (such as factual Q&A). The multi-dimensional characteristics of these questions, such as domain labels, complexity levels, and the number of candidate results, are not included in the decision-making basis for adjusting the k value in existing systems, making it difficult for retrieval systems to adapt to diverse query scenarios. Summary of the Invention
[0004] To address the shortcomings of existing technologies, this invention proposes an intelligent dynamic K-value retrieval and optimization system and method to solve the aforementioned technical problems.
[0005] Firstly, an intelligent dynamic K-value retrieval and optimization system is provided, including: Vector retrieval and storage module, dynamic K-value generation module, and adversarial training optimization module; The system introduces a multi-dimensional feature library for questions, which includes the question's domain label, complexity level, and candidate result cardinality. The system adjusts the top-k value during retrieval through a dynamic K-value generation module and optimizes the generator's performance by combining it with an adversarial training optimization module.
[0006] Furthermore, the vector retrieval and storage module includes an embedded vector management mechanism and a vector database architecture; The embedding vector management mechanism uses text embedding vectors for batch pre-caching of embedding vectors, calculates the distance between embedding vectors using cosine similarity, and supports both normalized and non-normalized modes. The vector database architecture is based on a vector database to build a vector storage engine, adopts a hybrid retrieval strategy, and supports the configuration of index parameters.
[0007] Furthermore, the dynamic K-value generation module includes a problem multi-dimensional feature library construction unit, which is used to obtain the domain label of the problem, evaluate the complexity level of the problem, and count the number of candidate results of the problem. When obtaining the domain labels for a question, the input question is analyzed to automatically label its domain. When assessing the complexity level of a problem, at least one of the following factors is considered: problem length, number of entities contained, syntactic complexity, and number of dependencies, and a quantitative complexity level is output. When determining the cardinality of candidate results for a statistical problem, the problem embedding vectors are quickly filtered in a vector database, and the total number of candidate results is determined based on the filtering results.
[0008] Furthermore, the dynamic K-value generation module also includes a generator network unit, which constructs a generator network; The input layer of the generator network concatenates the question embedding vector with the domain label, complexity level and candidate result cardinality from the multi-dimensional feature library of the question to form an enhanced multi-dimensional feature vector; The generator network is configured with a hidden layer, which adopts a fully connected neural network structure and employs activation functions and regularization. The output layer of the generator network generates a distribution representing the probability of choosing different K values, and combines temperature scaling and the Softmax function to generate the probability distribution.
[0009] Furthermore, the dynamic K-value generation module also includes a K-value calculation unit, which is used to pre-calculate the optimal K-value and the generator's predicted K-value; When pre-calculating the optimal K value, different K values are tried and the optimal K value is determined based on the recall rate metric of the retrieval. When the generator predicts the K value, it selects the K value with the highest probability as the predicted K value based on the probability distribution of the K value output by the generator network. The K-value calculation unit sets a lower limit constraint on the predicted K-value.
[0010] Furthermore, the adversarial training optimization module includes a GAN training framework unit, which constructs a GAN training framework including a generator and a discriminator. The generator is used to predict the optimal K value, with the goal of making the discriminator unable to distinguish its predicted K value from the true optimal K value. The discriminator is used to distinguish the search results corresponding to the true optimal K value from the search results corresponding to the generator's predicted K value; The GAN training framework unit introduces a gradient penalty mechanism.
[0011] Furthermore, the adversarial training optimization module also includes a loss function unit, which adopts a multi-index fusion loss function; The multi-index fusion loss function dynamically allocates the weights of each evaluation index according to the training phase. In the early stage of training, the focus is on optimizing the hit probability index, and in the later stage of training, the focus gradually shifts to optimizing the normalized loss cumulative gain and average accuracy index. The loss function unit performs a weighted summation of each evaluation index and, in conjunction with a dynamic temperature parameter adjustment mechanism, automatically adjusts the temperature decay rate based on recent changes in the evaluation indexes.
[0012] Furthermore, it also includes an evaluation and optimization module, which constructs a multi-dimensional retrieval evaluation system and an adaptive temperature control mechanism; The multidimensional retrieval evaluation system includes basic retrieval indicators, ranking-sensitive indicators, average precision indicators, and prediction matching indicators. The squeeze-out retrieval indicators include precision and recall. The ranking-sensitive indicators include normalized loss cumulative gain. The average precision indicators include average accuracy. The prediction matching indicators include the matching rate between the generator's predicted K value and the pre-calculated optimal K value. The adaptive temperature control mechanism initially sets the temperature parameter, adjusts the temperature parameter with the number of training iterations, provides temperature when the evaluation index stagnates, accelerates temperature decay when the evaluation index improves, and sets upper and lower limit boundary constraints on the temperature parameter.
[0013] Furthermore, the system also includes an engineering optimization module, which includes a caching and persistence mechanism and a training process management mechanism; The caching and persistence mechanism caches the calculated embedding vectors, persists the pre-calculated optimal K value, and sets up a cache verification mechanism to automatically check the validity of the cached data. The training process management mechanism includes an early stopping mechanism, an optimal model preservation mechanism, and a log recording mechanism. The early stopping mechanism terminates training when the evaluation metrics do not improve after multiple consecutive rounds. The optimal model preservation mechanism automatically saves the best-performing generator model based on the normalized loss cumulative gain metric. The log recording mechanism records the entire training process, evaluation metrics, and hyperparameter changes.
[0014] Secondly, an intelligent dynamic K-value retrieval optimization method is provided, based on an intelligent dynamic K-value retrieval optimization system described in any of the preceding items, including: Obtain the user's query question, and process the user's query question to obtain the corresponding question embedding vector; The multi-dimensional feature library construction unit of the problem is invoked to obtain the domain label and evaluator complexity level of the user query problem and to count the cardinality of its candidate results. The problem embedding vector, along with the domain label, complexity level, and candidate result cardinality, is input into the generator network. The probability distribution of the K value is input through the generator network, and the predicted K value is determined based on the probability distribution. The litigation prediction K value is then adjusted according to the lower bound constraint. The vector retrieval and storage module retrieves initial retrieval results by searching the vector database based on the adjusted predicted K value. Using the discriminator in the adversarial training optimization module, the initial retrieval result is compared with the retrieval result corresponding to the true best K value, and the performance of the generator and discriminator is optimized through a gradient penalty mechanism. The retrieval effect is evaluated through the multi-dimensional retrieval evaluation system of the evaluation and optimization module. If the evaluation index does not meet the standard, the temperature parameter is adjusted by combining the adaptive temperature control mechanism, and the generator network is returned to re-predict the K value and repeat the retrieval steps. If the evaluation criteria are met, the final search results will be output.
[0015] The invention employing the above technical solution has the following advantages: This invention integrates multiple technologies, including vector database storage, embedded vector caching, GAN model training, dynamic temperature adjustment, multi-index fusion optimization, incremental updates, and automatic hyperparameter tuning. Its innovation lies in transforming the k-value selection problem into a learnable generative task. Through adversarial training, the generator can predict the optimal number of retrieval results for a specific problem, overcoming the limitation of fixed k-values in traditional retrieval systems. Attached Figure Description
[0016] To more clearly illustrate the specific embodiments of the present invention, the accompanying drawings used in the specific embodiments will be briefly described below. In all the drawings, the elements or parts are not necessarily drawn to scale.
[0017] Figure 1 This is a schematic diagram of the system architecture of an intelligent dynamic K-value retrieval and optimization system and method according to the present invention; Figure 2 This is a flowchart of the GAN adversarial training module in an intelligent dynamic K-value retrieval optimization system of the present invention; Figure 3 This is a flowchart of the dynamic K-value calculation logic in an intelligent dynamic K-value retrieval and optimization system of the present invention; Figure 4This is a schematic diagram of a multi-index fusion loss function in an intelligent dynamic K-value retrieval optimization system according to the present invention. Detailed Implementation
[0018] The embodiments of the technical solution of the present invention will now be described in detail with reference to the accompanying drawings. These embodiments are merely illustrative of the technical solution of the present invention and are therefore intended to limit the scope of protection of the present invention.
[0019] like Figures 1-4 As shown, the present invention provides an intelligent dynamic K-value retrieval and optimization system, comprising: Vector retrieval and storage module, dynamic K-value generation module, and adversarial training optimization module; The system introduces a multi-dimensional feature library for questions, which includes the question's domain label, complexity level, and cardinality of candidate results. The system adjusts the top-k value during retrieval through a dynamic K-value generation module and optimizes the generator's performance by combining it with an adversarial training optimization module.
[0020] In this embodiment, the vector retrieval and storage module includes an embedded vector management mechanism and a vector database architecture; The embedding vector management mechanism uses text embedding vectors for batch pre-caching of embedding vectors, calculates the distance between embedding vectors using cosine similarity, and supports both normalized and non-normalized modes. The vector database architecture is built on a vector database to construct a vector storage engine, adopts a hybrid retrieval strategy, and supports the configuration of index parameters.
[0021] Specifically, embedding a vector management mechanism; The text embedding vector (BGE-M3 model) is used to implement a batch pre-caching mechanism, which supports the acquisition of embedding vectors for 1000 texts at a time. The embedding vectors are calculated using cosine similarity and support both normalized and non-normalized modes.
[0022] Embedded vector computation is a time-consuming operation. The caching mechanism can reduce the time consumption of repeated requests by more than 90%. Batch processing optimizes network request efficiency and reduces the frequency of API calls. Cosine similarity is the most commonly used distance metric in semantic retrieval, which meets the requirements of text semantic matching.
[0023] Vector database architecture; A vector storage engine is built based on ChromaDB, supporting high-performance vector retrieval; A hybrid retrieval strategy is adopted: IVF (Inverted Index) + PQ (Product Quantization) + HNSW (Hierarchical Navigation Search). Fine-grained configuration of index parameters: IVF_NLIST=4096, pq_M=32, HNSW_M=32; ChromaDB provides efficient vector storage and retrieval capabilities, supporting fast queries of tens of millions of vectors; Hybrid retrieval strategies combine the advantages of different indexing methods, achieving a balance between retrieval speed and accuracy. Configurable indexing parameters enable the system to be optimized according to data scale and hardware conditions.
[0024] In this embodiment, the dynamic K-value generation module includes a problem multi-dimensional feature library construction unit, which is used to obtain the domain label of the problem, evaluate the complexity level of the problem, and count the number of candidate results of the problem. When obtaining the domain labels for a question, the input question is analyzed to automatically label its domain. When assessing the complexity level of a problem, at least one of the following factors is considered: problem length, number of entities contained, syntactic result complexity, and number of dependencies, and a quantitative complexity level is output. When determining the cardinality of candidate results for a statistical problem, the problem embedding vectors are quickly filtered in a vector database, and the total number of candidate results is determined based on the filtering results.
[0025] In this embodiment, the dynamic K-value generation module further includes a generator network unit, which constructs a generator network; The input layer of the generator network concatenates the question embedding vector with the domain label, complexity level and candidate result cardinality from the multi-dimensional feature library of the question to form an enhanced multi-dimensional feature vector; The generator network has hidden layers, which use a fully connected neural network structure and are processed with activation functions and regularization. The output layer of the generator network generates a distribution representing the probability of choosing different K values, and combines temperature scaling and the Softmax function to generate the probability distribution.
[0026] In this embodiment, the dynamic K-value generation module further includes a K-value calculation unit, which is used to pre-calculate the optimal K-value and the generator-predicted K-value; When pre-calculating the optimal K value, different K values are tried and the optimal K value is determined based on the recall rate metric of the retrieval. When the generator predicts the K value, it selects the K value with the highest probability as the predicted K value based on the probability distribution of the K value output by the generator network. The K-value calculation unit sets a lower limit constraint on the predicted K-value.
[0027] Specifically, the construction of a multi-dimensional feature library for the problem; To address the issue of weak cross-scene adaptability, this module first constructs a feature library containing the following three key attributes; Domain label acquisition: Using a pre-trained text classification model, the input question is analyzed and automatically labeled with its educational domain.
[0028] Complexity rating: Construct a scoring model that comprehensively evaluates factors such as the length of the problem, the number of entities contained, the complexity of the syntactic structure, the depth of the clauses, and the number of dependencies, and outputs a quantitative complexity rating score.
[0029] Candidate result cardinality statistics: Before the formal search, a quick screening is first performed in the vector database to count the total number of candidate results with a "cosine similarity greater than or equal to 0.5" with the current question embedding vector. This number is used as the feature of the candidate result cardinality.
[0030] Generator network architecture; Input layer: The question embedding vector, domain label features, complexity level score and candidate result cardinality are concatenated to form an enhanced multi-dimensional feature vector, which is used as the input to the generator.
[0031] Hidden layer: A three-layer fully connected neural network structure is used, and the dimension of the hidden layer can be set to 256. Activation and Regularization: The ReLU activation function is used to solve the gradient vanishing problem, and Dropout regularization (e.g., with a probability of 0.2) is used to improve the model's generalization ability.
[0032] Output layer: The output dimension is the maximum K value (MAX_K, such as 7). Through temperature scaling and the Softmax function, a distribution representing the probability of choosing different K values is generated.
[0033] The integration of multi-dimensional features into the input enables the generator to understand the problem from a richer perspective, thus breaking the limitation of relying solely on semantic information and greatly improving cross-scene adaptability.
[0034] Multilayer fully connected networks can effectively capture the non-linear mapping relationship between the enhanced feature vector and the optimal K value. The ReLU activation function solves the gradient vanishing problem in deep networks, and Dropout improves the model's generalization ability. The temperature scaling mechanism allows the generator to adjust the randomness of the K-value prediction at different stages of training.
[0035] Dynamic K-value calculation logic; Pre-calculation of the optimal K value based on the Recall metric: Try K=3 to K=7 for each question and select the K value with the highest Recall; The generator predicts the K value by using softmax to output the probability distribution of the K value and selecting the K value with the highest probability. K-value lower limit constraint: Force K≥3 to ensure that the number of search results is statistically significant; Pre-calculating the optimal K value provides a supervisory signal for the generator and establishes a mapping benchmark between problem characteristics and the optimal K value; Generator prediction enables the selection of K value to generalize and handle new problems that did not appear in the pre-computation; The lower limit constraint avoids insufficient search results due to an excessively small K value, which would affect the calculation of evaluation indicators.
[0036] In this embodiment, the adversarial training optimization module includes a GAN training framework unit, which constructs a GAN training framework including a generator and a discriminator. The generator is used to predict the optimal K value, with the goal of making the discriminator unable to distinguish its predicted K value from the true optimal K value; The discriminator is used to distinguish the search results corresponding to the true optimal K value from the search results corresponding to the generator's predicted K value; The GAN training framework introduces a gradient penalty mechanism.
[0037] In this embodiment, the adversarial training optimization module further includes a loss function unit, which adopts a multi-index fusion loss function; The multi-index fusion loss function dynamically allocates the weights of each evaluation index according to the training phase. In the early stage of training, the focus is on optimizing the hit probability index, and in the later stage of training, the focus gradually shifts to optimizing the normalized loss cumulative gain and average accuracy index. The loss function unit performs a weighted summation of each evaluation index and, combined with a dynamic adjustment mechanism for temperature parameters, automatically adjusts the temperature decay rate based on recent changes in the evaluation indexes.
[0038] Specifically, the GAN training framework; Generator: Predicts the optimal K value, with the goal of deceiving the discriminator; Discriminator: Distinguishes between the true optimal K-value search results and the generator's predicted K-value search results; Gradient penalty mechanism: ensures the Lipschitz continuity of the discriminator; The adversarial training mode enables the generator to learn the distribution of the optimal K value, rather than simply memorizing the discriminator. This provides the generator with a more challenging optimization objective and improves the model's robustness. Gradient penalty solves the training instability problem in WGAN-GP and makes the training process smoother.
[0039] Multi-index fusion loss function; Phased weight allocation: Focus on optimizing Hit@k in the first 100 rounds, and then gradually shift to NDCG / MAP; Weighted summation of multiple indicators: LAMBDA_NDCG=0.5, LAMBDA_PRECISION=0.3; Dynamic temperature parameter adjustment: Automatically adjusts the temperature decay rate based on recent changes in evaluation indicators; Phased training aligns with the learning patterns of models, first mastering basic k-value matching, and then optimizing higher-order retrieval metrics. Multi-indicator fusion enables the model to move beyond a single optimization objective, achieving a comprehensive improvement in retrieval performance; Dynamic temperature adjustment can adaptively balance exploration and utilization according to the training progress, avoiding getting trapped in local optima.
[0040] In this embodiment, an evaluation and optimization module is also included, which constructs a multi-dimensional retrieval evaluation system and an adaptive temperature control mechanism. The multidimensional retrieval evaluation system includes basic retrieval indicators, ranking-sensitive indicators, average precision indicators, and prediction matching indicators. The squeeze-out retrieval indicators include precision and recall. The ranking-sensitive indicators include normalized loss cumulative gain. The average precision indicators include average accuracy. The prediction matching indicators include the matching rate between the generator's predicted K value and the pre-calculated optimal K value. The adaptive temperature control mechanism initially sets the temperature parameters and adjusts them with the number of training iterations. It provides temperature when the evaluation index stagnates and accelerates temperature decay when the evaluation index improves. It also sets upper and lower limit constraints on the temperature parameters.
[0041] Precision is the proportion of truly relevant results among the top k recommendations returned by the model. Recall is the proportion of successfully recalled relevant results out of all relevant results among the top k recommendations. Normalized depreciation cumulative gain measures the ranking quality of the recommendations, considering result relevance and position weight (results ranked earlier are more important), and normalization makes scores comparable across different scenarios. Average precision is the average precision of all queries, comprehensively measuring the model's recommendation accuracy under different queries, with particular attention to the ranking position of relevant results. Hit probability: the probability that the model has at least one relevant result among the top k recommendations.
[0042] Specifically, a multi-dimensional retrieval and evaluation system; Basic metrics: Precision@k, Recall@k; Ranking Sensitive Metric: NDCG (Normalized Discount Cumulative Gain); Average accuracy metric: MAP (Mean Average Precision). Predicted matching degree: Hit@k (the matching rate between the generator's predicted k value and the pre-computed optimal k value); Multi-dimensional evaluation comprehensively reflects the performance of the retrieval system, avoiding the one-sidedness of a single indicator; NDCG and MAP are particularly suitable for evaluating ranking quality, meeting the core requirements of retrieval systems; The Hit@k metric directly measures the predictive ability of the generator and provides a clear direction for model optimization. Adaptive temperature control mechanism; The initial temperature was set to 1.0, and it decreased linearly with the number of iterations. Dynamic acceleration / deceleration mechanism: Increase temperature when the indicator stagnates, and accelerate the decay when the indicator rises; Temperature boundary constraints: lower limit 0.1, upper limit 2.0, to ensure training stability; Temperature parameters control the randomness of the generator's output; high temperatures promote exploration, while low temperatures favor utilization. Dynamic adjustment enables the system to adaptively balance exploration and utilization based on the current training status; Boundary constraints prevent temperature parameters from exceeding reasonable ranges, thus avoiding training runaway.
[0043] In this embodiment, the system also includes an engineering optimization module, which includes a caching and persistence mechanism and a training process management mechanism; The caching and persistence mechanism caches the computed embedding vectors, persists the pre-computed optimal K value, and sets up a cache verification mechanism to automatically check the validity of the cached data. The training process management mechanism includes an early stopping mechanism, a best model preservation mechanism, and a log recording mechanism. The early stopping mechanism terminates training when there is no improvement in the evaluation metrics for several consecutive rounds. The best model preservation mechanism automatically saves the best-performing generator model based on the normalized depreciation cumulative gain metric. The log recording mechanism records all training processes, evaluation metrics, and hyperparameter changes.
[0044] Specifically, caching and persistence mechanisms; Embedding vector cache: Use Pickle to store computed embedding vectors to avoid duplicate API calls; Optimal k-value cache: Persistently stores pre-computed optimal k-values to accelerate the training process; Cache validation mechanism: Automatically checks the validity of the cache k value to ensure data correctness; Embedded vector computation and optimal k-value pre-computation are both time-consuming operations; caching can significantly improve training efficiency. Persistent storage allows the training process to be resumed after an interruption, avoiding repetitive work; Cache validation ensures data consistency and prevents dirty data from affecting training results.
[0045] Training process management; Early stop mechanism: If the metrics do not improve in consecutive PATIENCE rounds, training is terminated to avoid overfitting; Best Model Saving: Automatically saves the best-performing generator model based on the NDCG metric; Detailed log records: Full record of training process, evaluation metrics, and hyperparameter changes; Early stopping mechanism effectively prevents overfitting and saves computational resources; Automatic model saving ensures that the optimal training state is not missed; Complete logs provided ample evidence for subsequent model optimization and problem investigation; SmartRetrieve-K overcomes the limitation of fixed k-values in traditional retrieval systems by transforming the k-value selection problem into a learnable generative task, thus achieving intelligent adaptive optimization of the retrieval process. Its core innovation lies in: Dynamic k-value generation: This is the first time that a GAN architecture has been applied to the k-value optimization of a retrieval system, enabling the selection of k-values to have problem-aware capabilities. Multi-indicator fusion optimization: A comprehensive improvement in retrieval performance is achieved through a staged multi-indicator weighted loss function; Adaptive temperature control: dynamically adjusts temperature parameters based on training status to achieve an intelligent balance between exploration and utilization; Engineering-optimized design: A complete caching mechanism and training process management enable the system to have industrial-grade application capabilities.
[0046] In other embodiments, an intelligent dynamic K-value retrieval optimization method is provided, and an intelligent dynamic K-value retrieval optimization system based on any one of the preceding embodiments includes: Obtain user query questions and process them to obtain corresponding question embedding vectors; The system calls the multi-dimensional feature library building unit to obtain the domain label and evaluator complexity level of the user's query question and to count the cardinality of its candidate results. The problem embedding vector, along with the domain label, complexity level, and candidate result cardinality, is input into the generator network. The probability distribution of the K value is input through the generator network, and the predicted K value is determined based on the probability distribution. The litigation prediction K value is then adjusted according to the lower bound constraint. The vector retrieval and storage module retrieves initial retrieval results by searching the vector database based on the adjusted predicted K value. By using the discriminator in the adversarial training optimization module, the initial retrieval results are compared with the retrieval results corresponding to the true best K value, and the performance of the generator and discriminator is optimized through the gradient penalty mechanism. The retrieval effect is evaluated through a multi-dimensional retrieval evaluation system of the evaluation and optimization module. If the evaluation indicators do not meet the standards, the temperature parameters are adjusted by combining the adaptive temperature control mechanism, and the generator network is returned to re-predict the K value and repeat the retrieval steps. If the evaluation criteria are met, the final search results will be output.
[0047] Specifically, the core objective of this invention is to optimize the retrieval performance in a question-and-answer system by dynamically adjusting the top-k value during retrieval.
[0048] To address the issue of weak cross-scenario adaptability of existing dynamic K-value schemes, this system introduces a "multi-dimensional feature library for problems." This feature library contains three key attributes: the problem's domain label, complexity level, and candidate result technology. During K-value prediction, the system concatenates these multi-dimensional features with the original embedding vector of the problem to form a richer feature representation, which is then used as input to the dynamic K-value generator.
[0049] In this way, the system upgrades the K-value selection problem from a simple semantic matching task to a learnable generative task that considers the problem domain, complexity, and answer space. Through adversarial training, the generator can learn the complex mapping relationship between the multi-dimensional features of the problem and the optimal K value, thereby predicting the optimal number of retrieval results for a specific problem, overcoming the limitations of traditional fixed K values and the insufficient generalization ability of existing dynamic K-value schemes.
[0050] The system can significantly improve key metrics such as precision, recall, normalized loss cumulative gain, average accuracy, and hit probability.
[0051] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention, and they should all be covered within the scope of the claims and specification of the present invention.
Claims
1. An intelligent dynamic K-value retrieval and optimization system, characterized in that, include: Vector retrieval and storage module, dynamic K-value generation module, and adversarial training optimization module; The system introduces a multi-dimensional feature library for questions, which includes the question's domain label, complexity level, and candidate result cardinality. The system adjusts the top-k value during retrieval through a dynamic K-value generation module and optimizes the generator's performance by combining it with an adversarial training optimization module.
2. The intelligent dynamic K-value retrieval and optimization system according to claim 1, characterized in that, The vector retrieval and storage module includes an embedded vector management mechanism and a vector database architecture; The embedding vector management mechanism uses text embedding vectors for batch pre-caching of embedding vectors, calculates the distance between embedding vectors using cosine similarity, and supports both normalized and non-normalized modes. The vector database architecture is based on a vector database to build a vector storage engine, adopts a hybrid retrieval strategy, and supports the configuration of index parameters.
3. The intelligent dynamic K-value retrieval and optimization system according to claim 1, characterized in that, The dynamic K-value generation module includes a problem multi-dimensional feature library construction unit, which is used to obtain the domain label of the problem, evaluate the complexity level of the problem, and count the number of candidate results for the problem. When obtaining the domain labels for a question, the input question is analyzed to automatically label its domain. When assessing the complexity level of a problem, at least one of the following factors is considered: problem length, number of entities contained, syntactic complexity, and number of dependencies, and a quantitative complexity level is output. When determining the cardinality of candidate results for a statistical problem, the problem embedding vectors are quickly filtered in a vector database, and the total number of candidate results is determined based on the filtering results.
4. The intelligent dynamic K-value retrieval and optimization system according to claim 3, characterized in that, The dynamic K-value generation module also includes a generator network unit, which constructs a generator network; The input layer of the generator network concatenates the question embedding vector with the domain label, complexity level and candidate result cardinality from the multi-dimensional feature library of the question to form an enhanced multi-dimensional feature vector; The generator network is configured with a hidden layer, which adopts a fully connected neural network structure and employs activation functions and regularization. The output layer of the generator network generates a distribution representing the probability of choosing different K values, and combines temperature scaling and the Softmax function to generate the probability distribution.
5. The intelligent dynamic K-value retrieval and optimization system according to claim 4, characterized in that, The dynamic K-value generation module also includes a K-value calculation unit, which is used to pre-calculate the optimal K-value and the generator-predicted K-value. When pre-calculating the optimal K value, different K values are tried and the optimal K value is determined based on the recall rate metric of the retrieval. When the generator predicts the K value, it selects the K value with the highest probability as the predicted K value based on the probability distribution of the K value output by the generator network. The K-value calculation unit sets a lower limit constraint on the predicted K-value.
6. The intelligent dynamic K-value retrieval and optimization system according to claim 1, characterized in that, The adversarial training optimization module includes a GAN training framework unit, which constructs a GAN training framework including a generator and a discriminator. The generator is used to predict the optimal K value, with the goal of making the discriminator unable to distinguish its predicted K value from the true optimal K value. The discriminator is used to distinguish the search results corresponding to the true optimal K value from the search results corresponding to the generator's predicted K value; The GAN training framework unit introduces a gradient penalty mechanism.
7. The intelligent dynamic K-value retrieval and optimization system according to claim 6, characterized in that, The adversarial training optimization module also includes a loss function unit, which adopts a multi-index fusion loss function. The multi-index fusion loss function dynamically allocates the weights of each evaluation index according to the training phase. In the early stage of training, the focus is on optimizing the hit probability index, and in the later stage of training, the focus gradually shifts to optimizing the normalized loss cumulative gain and average accuracy index. The loss function unit performs a weighted summation of each evaluation index and, in conjunction with a dynamic temperature parameter adjustment mechanism, automatically adjusts the temperature decay rate based on recent changes in the evaluation indexes.
8. The intelligent dynamic K-value retrieval and optimization system according to claim 1, characterized in that, It also includes an evaluation and optimization module, which constructs a multi-dimensional retrieval evaluation system and an adaptive temperature control mechanism; The multidimensional retrieval evaluation system includes basic retrieval indicators, ranking-sensitive indicators, average precision indicators, and prediction matching indicators. The basic retrieval indicators include precision and recall. The ranking-sensitive indicators include normalized loss cumulative gain. The average precision indicators include average accuracy. The prediction matching indicators include the matching rate between the generator's predicted K value and the pre-calculated optimal K value. The adaptive temperature control mechanism initially sets the temperature parameter, adjusts the temperature parameter with the number of training iterations, provides temperature when the evaluation index stagnates, accelerates temperature decay when the evaluation index improves, and sets upper and lower limit boundary constraints on the temperature parameter.
9. The intelligent dynamic K-value retrieval and optimization system according to claim 1, characterized in that, The system also includes an engineering optimization module, which includes a caching and persistence mechanism and a training process management mechanism. The caching and persistence mechanism caches the calculated embedding vectors, persists the pre-calculated optimal K value, and sets up a cache verification mechanism to automatically check the validity of the cached data. The training process management mechanism includes an early stopping mechanism, a best model saving mechanism, and a log recording mechanism. The early stopping mechanism terminates training when the evaluation metric does not improve after multiple consecutive rounds. The best model saving mechanism automatically saves the best-performing generator model based on the normalized depreciation cumulative gain metric. The log recording mechanism records the entire training process, evaluation metrics, and hyperparameter changes.
10. An intelligent dynamic K-value retrieval and optimization method, characterized in that, A smart dynamic K-value retrieval and optimization system based on any one of claims 1 to 9 includes: Obtain the user's query question, and process the user's query question to obtain the corresponding question embedding vector; The multi-dimensional feature library construction unit of the problem is invoked to obtain the domain label and evaluator complexity level of the user query problem and to count the cardinality of its candidate results. The problem embedding vector, along with the domain label, complexity level, and candidate result cardinality, is input into the generator network. The generator network outputs a probability distribution of the K value. Based on the probability distribution, the predicted K value is determined, and the predicted K value is adjusted according to the lower bound constraint. The vector retrieval and storage module retrieves initial retrieval results by searching the vector database based on the adjusted predicted K value. Using the discriminator in the adversarial training optimization module, the initial retrieval result is compared with the retrieval result corresponding to the true best K value, and the performance of the generator and discriminator is optimized through a gradient penalty mechanism. The retrieval effect is evaluated through the multi-dimensional retrieval evaluation system of the evaluation and optimization module. If the evaluation index does not meet the standard, the temperature parameter is adjusted by combining the adaptive temperature control mechanism, and the generator network is returned to re-predict the K value and repeat the retrieval steps. If the evaluation criteria are met, the final search results will be output.
Citation Information
Cited By
Retrieval enhancement generation method and device, equipment and storage medium
CN121786069A
A retrieval augmentation generation method, device, apparatus and storage medium
CN121786069B