Enhanced retrieval-based agent rapid construction method and system

Through the multi-dimensional task analysis of the agent system and the hierarchical knowledge distillation transmission chain, the problem of high resource consumption and reduced accuracy in different application scenarios of the agent system is solved, and efficient and lightweight intelligent construction and deployment are achieved.

CN120407751AActive Publication Date: 2025-08-01JIANGSU HUIZHI INTELLIGENT DIGITAL TECH CO LTD

Patent Information

Application Number
CN202510912995.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-03
Publication Date
2025-08-01
Estimated Expiration
2045-07-03

AI Technical Summary

Technical Problem

In the prior art, the construction of intelligent body system faces the problems of different application scenarios with obvious differences in the architecture of the search model, high resource consumption, and reduced retrieval accuracy after lightweighting of the model. The lack of systematic optimization methods, resulting in low efficiency in the construction of intelligent body search capabilities.

Method used

Through searching task characteristics analysis and parameterization, a multi-dimensional task analysis system is built, and a multi-objective architecture search and optimization is adopted to perform hierarchical knowledge distillation and transfer chains, combining task-oriented adaptive compression and automated evaluation to achieve efficient knowledge transfer and model compression.

Benefits of technology

While maintaining high retrieval performance, it reduces the amount of model parameters, improves inference speed and energy consumption, and is suitable for 1GB memory devices, shortens the development cycle of the agent from the prototype to the product, improves construction efficiency, and achieves accurate resource adaptation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407751A_ABST
    Figure CN120407751A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, and discloses an agent rapid construction method and system based on enhanced retrieval, and the method comprises the steps: constructing a multi-dimensional task analysis system, retrieval task characteristics are automatically represented through characteristics such as data distribution, query complexity and semantic requirements; executing a progressive architecture evolution algorithm, and automatically searching an optimal architecture meeting multi-dimensional balance of retrieval precision, calculation complexity and memory occupation based on the task characteristic vector; constructing a hierarchical knowledge distillation transfer chain, and realizing efficient knowledge migration from a large model to a small model through feature matching and attention guidance; implementing mixing precision quantification and structured pruning on different hierarchies based on sensitivity analysis, and adapting to a target deployment environment; according to the method, the model volume is reduced, the reasoning speed is increased, the energy consumption is reduced, and the enhanced retrieval agent can efficiently operate on resource-constrained equipment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and more specifically, it relates to a method and system for rapidly constructing an agent based on enhanced retrieval. Background Art

[0002] With the rapid development of artificial intelligence technology, agent systems have been widely used in various industries. Among them, the retrieval-enhanced agent effectively expands the information boundary and problem-solving ability of the model through its external knowledge acquisition ability.

[0003] However, the current construction of agent systems faces three prominent technical problems: the requirements for the retrieval model architecture vary significantly in different application scenarios, and the traditional manual tuning method is time-consuming and has limited effects; the mainstream large-scale retrieval models consume a large amount of resources and are difficult to be efficiently deployed on edge devices with limited computing power and memory; during the migration process from complex large models to lightweight models, there are often problems of significant performance degradation, resulting in a significant reduction in retrieval accuracy after model lightweighting. These problems jointly restrict the rapid construction and wide application of retrieval-enhanced agents.

[0004] In the prior art, for the selection of model architecture, it mainly relies on expert experience or simple hyperparameter search, and it is difficult to find the optimal architecture in complex and changeable application scenarios; for model lightweighting, mainly single technologies such as pruning, quantization, and knowledge distillation are adopted, lacking a systematic optimization method; for the knowledge transfer between large and small models, direct distillation often leads to serious performance losses.

[0005] Therefore, how to achieve the automatic and efficient construction of the agent's retrieval ability, making it applicable to resource-constrained environments while maintaining high retrieval performance, has become a technical problem to be solved. Summary of the Invention

[0006] The present invention provides a method and system for rapidly constructing an agent based on enhanced retrieval, which solves the technical problems of the automatic construction of the agent's retrieval ability and lightweight and efficient deployment in related technologies.

[0007] The present invention provides a method for rapidly constructing an agent based on enhanced retrieval, including the following steps: Analysis and parameterization of retrieval task characteristics, constructing a multi-dimensional task analysis system, automatically characterizing the retrieval task characteristics through data distribution, query complexity, semantic requirements and other features, and forming a task characteristic vector; Multi-objective architecture search and optimization, based on the task characteristic vector, executing a progressive architecture evolution algorithm to automatically find the optimal model architecture that satisfies the multi-dimensional balance of retrieval accuracy, computational complexity, and memory occupancy; Hierarchical Knowledge Distillation Transfer Chain. Based on the optimal model architecture, a multi-level distillation structure from the original large model to the target lightweight model is constructed. Through feature matching and attention guidance, efficient knowledge transfer is achieved, and a preliminary lightweight model is output. Task-Oriented Adaptive Compression. Based on the preliminary lightweight model and model sensitivity analysis, mixed-precision quantization and structured pruning are performed on different levels to generate an optimized model adapted to the target device. Automated Evaluation and Iterative Improvement. Based on the optimized model, a multi-scenario evaluation system is constructed. The reinforcement learning algorithm is applied to optimize the distillation path and hyperparameters, perform dynamic adjustment and continuous optimization, form a closed-loop optimization process, and output the final deployment model.

[0008] In a preferred embodiment, in the retrieval task characteristic analysis and parameterization step, the multi-dimensional task analysis system extracts three types of key features: data distribution features, query complexity features, and semantic requirement features, and generates a low-dimensional task characteristic vector through a feature fusion network.

[0009] In a preferred embodiment, the feature fusion process is achieved through a weighted combination method, that is, the data distribution features, query complexity features, and semantic requirement features are respectively multiplied by the corresponding weight matrices and then added together, and then the final task characteristic vector is generated through a non-linear activation function.

[0010] In a preferred embodiment, the multi-objective architecture search and optimization step adopts a weighted comprehensive scoring function. The weighted comprehensive scoring function comprehensively considers three aspects: performance loss, computational complexity loss, and memory occupancy loss, and balances the importance of each objective through weight coefficients.

[0011] In a preferred embodiment, in the hierarchical knowledge distillation transfer chain step, the scale of the intermediate model is designed according to the linear decreasing rule from the original large model to the target lightweight model to ensure a smooth transition of knowledge during the transfer process.

[0012] In a preferred embodiment, in the hierarchical knowledge distillation transfer chain step, the feature matching loss function is achieved by calculating the sum of the squares of the Euclidean distances between the feature representations of the corresponding layers of the student model and the teacher model, and different weights are assigned according to the importance of the layers.

[0013] In a preferred embodiment, in the task-oriented adaptive compression step, the parameter sensitivity evaluation is measured by calculating the average absolute value of the gradient of the validation set loss function with respect to each layer's parameters, so as to determine the influence degree of different layer parameters on the model performance.

[0014] In a preferred embodiment, in the task-oriented adaptive compression step, a mixed-precision quantization strategy is adopted, with 8-bit quantization for high-sensitivity layers, 4-bit quantization for medium-sensitivity layers, and 2-bit quantization for low-sensitivity layers.

[0015] In a preferred embodiment, it further includes an automated evaluation and iterative improvement step: constructing a multi-scenario evaluation system, applying a reinforcement learning algorithm to optimize the distillation path and hyperparameters, performing dynamic adjustment and continuous optimization to form a closed-loop optimization process.

[0016] In a preferred embodiment, a rapid intelligent agent construction system based on enhanced retrieval is used to execute a rapid intelligent agent construction method based on enhanced retrieval, including: A retrieval task analysis subsystem for performing retrieval task feature analysis and parameterization; An architecture search subsystem for performing multi-objective architecture search and optimization; A knowledge distillation subsystem for performing a hierarchical knowledge distillation transfer chain; A model compression subsystem for performing task-oriented adaptive compression; An evaluation and optimization subsystem for performing automated evaluation and iterative improvement.

[0017] The beneficial effects of the present invention are as follows: In terms of model lightweighting, compared with traditional compression methods, the present invention can reduce the number of model parameters, improve the inference speed, reduce energy consumption, enable the enhanced retrieval intelligent agent to run in real time on a 1GB memory device, and expand the application scenarios of the intelligent agent.

[0018] In terms of performance retention, the present invention improves the retrieval accuracy of the lightweighted model through a hierarchical knowledge distillation transfer chain and multi-objective optimization, improves the accuracy in complex semantic retrieval tasks, and reduces the performance loss during the lightweighting process.

[0019] In terms of construction efficiency, the automated architecture search and evaluation optimization system of the present invention reduces the manual intervention time, shortens the development cycle of the intelligent agent from prototype to product from weeks to hours, and greatly improves the intelligent agent construction efficiency.

[0020] The present invention provides strict resource controllability. Through adaptive compression technology, it can accurately control the size, computational amount, and memory occupancy of the model according to the resource constraints of the target deployment environment, and achieve precise adaptation and efficient operation on various devices. Brief Description of the Drawings

[0021] Figure 1 is a flowchart of a rapid intelligent agent construction method based on enhanced retrieval of the present invention. Detailed Embodiments

[0022] The subject matter described herein will now be discussed with reference to example embodiments. It should be understood that discussing these embodiments is only to enable those skilled in the art to better understand and thus implement the subject matter described herein. Without departing from the scope of protection of the content of this specification, changes can be made to the functions and arrangements of the elements discussed. Each example can omit, substitute, or add various processes or components as needed. Additionally, the features described in some examples can also be combined in other examples.

[0023] In at least one embodiment of the present invention, a method for quickly constructing an agent based on enhanced retrieval is disclosed, as Figure 1 shown, including the following steps: Step 1, retrieval task feature analysis and parameterization, constructing a multi-dimensional task analysis system, automatically characterizing the retrieval task features through data distribution, query complexity, semantic requirements, and other features, and forming a task feature vector; Specifically, it includes the following sub-steps: Step 1.1, constructing a multi-dimensional task feature analysis system; Using a feature extraction algorithm to perform multi-dimensional feature analysis on the retrieval task, with the input being the retrieval task dataset for constructing the agent, and the output being the feature vector of the retrieval task. The specific implementation is as follows: Preprocess the input retrieval task dataset and extract three types of key features: Data distribution features, including query length distribution, document length distribution, word frequency statistics, etc.; Query complexity features, including query type distribution, semantic complexity, multi-hop reasoning requirements, etc.; Semantic requirement features, including exact match requirement degree, semantic match requirement degree, etc.

[0024] In some embodiments, feature extraction may also include domain-specific features, such as term density in the financial field, professional knowledge requirement degree in the medical field, etc., so as to capture more refined task features for specific vertical domains.

[0025] The feature extraction algorithm, as one of the innovations of this application, can be applied in the intelligent customer service scenario. For example, analyze user query logs, extract the query length distribution, common problem type distribution, and semantic match requirements. These features will guide subsequent architecture selection. For example, in a scenario dominated by short queries, complex long text processing capabilities may not be required, thus simplifying the model architecture.

[0026] Process these original features through a feature fusion network to generate a low-dimensional feature vector. The feature fusion process can be expressed as: ; where, Denotes the final task feature vector, which is a low-dimensional representation obtained by fusing multiple features and is used to guide subsequent architecture selection; Denotes the data distribution feature, including data statistical information such as query length distribution, document length distribution, word frequency statistics, etc.; Denotes the query complexity feature, including query difficulty metrics such as query type distribution, semantic complexity, multi-hop reasoning requirements, etc.; Denotes the semantic requirement feature, including semantic understanding requirements such as exact match requirement degree, semantic match requirement degree, etc.; , , Denote the weight matrices of the data distribution feature, query complexity feature, and semantic requirement feature respectively, which are used to adjust the importance of different feature categories during the fusion process; Is a non-linear activation function, which is used to introduce non-linear transformation and enhance the feature expression ability.

[0027] The feature fusion network can adopt an attention mechanism to dynamically adjust the importance weights of different feature groups according to the task type, enabling the system to better adapt to the characteristic differences in different fields.

[0028] In practical applications, such as when building a medical Q&A system, the feature fusion network can fuse the medical term density (data feature), diagnostic reasoning complexity (query feature), and professional term understanding requirement (semantic feature) into a unified feature vector, which indicates that the medical Q&A system requires strong professional vocabulary understanding ability and reasoning ability, and thus tends to select a complex architecture containing a medical knowledge enhancement module in subsequent architecture search.

[0029] Step 1.2, establish a differentiable retrieval component library; Construct a differentiable component library containing various retrieval model components, with the input being the set of basic components of the retrieval model and the output being a parameterizable component operation graph.

[0030] According to the embodiments of the present application, in specific implementation, three types of basic components are first defined: Encoder components, including different types such as BERT - like encoders, CNN encoders, RNN encoders, etc., which are used for text representation extraction; Interaction layer components, including attention interaction, dot - product interaction, cosine similarity calculation, etc., which are used for calculating the relevance between the query and the document; Aggregation layer components, including pooling layers, fully - connected layers, etc., which are used for generating the final relevance score.

[0031] In some implementation manners, the component library can be extended to include domain - specific functional modules, such as ontology mapping modules in the medical field, clause association modules in the legal field, etc., so as to improve the adaptability to specific domain tasks.

[0032] In addition, these components are constructed into a differentiable computational graph, and the selection of each component is achieved through a soft selection mechanism, that is: ; where, represents the final architecture representation, which is a weighted combination of all selected components; represents the index of the component type; represents the option index within a specific type of component; represents the weight of the -th option in the -th type of component, which determines the importance of this option in the final architecture; represents the corresponding component operation, that is, the actual computational function or module executed.

[0033] The weight is calculated through a soft selection function: ; where, represents the soft selection weight of the -th option in the -th type of component, which determines the importance degree of this option in the final architecture; is the corresponding architecture parameter, which is set to a random value initially and is continuously optimized during the subsequent architecture search process; represents the natural exponential function; represents the sum over all possible options of the -th type of component; represents the index of all possible options in the -th type of component, which is the variable of the summation operation; the entire formula implements the softmax function, ensuring that the sum of the weights of all options in the same type of component is 1, making the architecture selection differentiable.

[0034] For a complex search space, a hierarchical architecture parameter representation can be introduced to separate component selection from component configuration, thereby reducing the complexity of the search space while maintaining flexibility.

[0035] Step 1.3, implement the architecture soft selection mapping; Use the task feature vector to guide the initialization of the architecture parameters. The input is the task feature vector and the component library, and the output is the initialized architecture parameters.

[0036] Specifically, when implementing, construct a mapping network to map the task feature vector to the initial value of the architecture parameters: ; where, represents the The architecture parameter values of the th option in the class component, which will be used for subsequent calculation of soft selection weights ; represents the task feature vector, which contains multi-dimensional feature information such as the data distribution, query complexity, and semantic requirements of the retrieval task; represents a multi-layer perceptron network, which is a feed-forward neural network used to learn the mapping relationship between task features and optimal architecture parameters; represents the task feature vector After being input into the multi-layer perceptron, the architecture parameter value corresponding to the th option in the

[0037] th class component. In this way, the system can automatically initialize more appropriate architecture parameters according to the characteristics of the retrieval task, accelerating the subsequent architecture search process. Specifically, it includes the following sub-steps: Step 2.1, construct a multi-objective evaluation system; Establish a multi-dimensional evaluation index system, with the input being the candidate retrieval model architecture and the output being the evaluation scores of this architecture on multiple objective dimensions.

[0038] Define three types of evaluation indicators: Retrieval performance indicators, including indicators such as Mean Average Precision (MAP), Normalized Discounted Cumulative Gain (NDCG), and recall rate to measure retrieval accuracy; Computational complexity indicators, including indicators such as Floating Point Operations Per Second (FLOPs) and inference latency to measure computational efficiency; Memory consumption indicators, including indicators such as the number of model parameters and runtime memory occupancy to measure storage requirements.

[0039] Construct a weighted comprehensive scoring function: ; where represents the total loss function, which is used to comprehensively evaluate the overall performance of the model; represents the performance loss, which measures the performance of the model in terms of retrieval accuracy; represents the complexity loss, which measures the computational complexity of the model; Represents memory loss, which measures the storage requirements of the model; Is the weight coefficient of the complexity loss, used to adjust the importance of computational complexity in the overall evaluation; Is the weight coefficient of the memory loss, used to adjust the importance of memory consumption in the overall evaluation. By adjusting and values, according to the requirements of the actual application scenario, the relationship between the retrieval performance, computational efficiency, and memory occupancy of the model can be balanced.

[0040] These loss functions are defined as: ; ; ; Among them, Represents the performance loss, calculated as 1 minus the average of all retrieval performance metrics; Represents the total number of retrieval performance metrics; Represents the th normalized value of the retrieval performance metric, with a value range of 0 to 1, and the larger the value, the better the performance; Represents the computational complexity loss, calculated by dividing the floating-point operation count of the current model by the maximum allowed floating-point operation count, and the smaller the value, the higher the computational efficiency; Represents the memory loss, calculated by dividing the number of parameters of the current model by the maximum allowed number of parameters, and the smaller the value, the less memory occupancy; Represents the floating-point operation count of the current model; Represents the number of parameters of the current model; Represents the upper limit of the maximum allowed floating-point operation count of the system; Represents the upper limit of the maximum allowed number of parameters of the system. These three loss functions together constitute the evaluation criteria of the multi-objective evaluation system.

[0041] Step 2.2, Implement the progressive architecture evolution algorithm; Adopt a progressive evolution strategy to optimize the architecture parameters, with the input being the initial architecture parameters and the multi-objective evaluation system, and the output being the optimized architecture parameters.

[0042] Specifically, when implementing, start from a simple basic architecture and adopt the following iterative optimization process: For the current architecture parameters Calculate the soft selection weight ; Build a retrieval model based on the soft selection weight and evaluate it on the validation set; Calculate the multi-objective loss ; Update the architecture parameters through gradient descent: ; wherein, represents the iteration round, that is, the number of iterations of the current optimization algorithm; is the learning rate, which controls the step size of each parameter update; represents the round of iteration and the architecture parameter of the th option of the class component; represents the updated architecture parameter; represents the partial derivative of the multi-objective loss function

[0043] with respect to the architecture parameter

[0044] , indicating the direction of parameter update. This formula implements the optimization process of architecture parameters based on gradient descent.

[0045] In some embodiments, a second-order optimization method, such as Newton's method or quasi-Newton's method, can be adopted to accelerate the convergence speed of architecture parameters, especially in the case of a large search space.

[0046] To prevent falling into local optimal solutions, the system can introduce periodic random perturbations or adopt strategies such as simulated annealing to balance exploration and exploitation.

[0047] As one of the core innovative algorithms of this application, the progressive architecture evolution algorithm can be specifically applied in the scenario of an e-commerce recommendation system during the construction of an intelligent agent.

[0048] In the initial stage, the algorithm can start from a simple content-based encoder and then gradually introduce complex components such as a user behavior interaction layer and a multi-modal feature fusion layer.

[0049] Through continuous iterative evaluation, the algorithm may find that in this scenario, modeling the user's historical click sequence contributes the most to the recommendation accuracy. Therefore, it will gradually increase the complexity of the components related to sequence modeling while keeping other components relatively simple, so as to find the best balance point between performance and resource consumption. As the iteration progresses, the architecture complexity is gradually increased by introducing new component options or increasing component connections to expand the architecture search space. After each increase in complexity, the optimal parameters of the previous stage are used as the initial point to continue optimization to avoid falling into local optima.

[0050] Step 2.3, perform architecture determination and discretization; Convert the optimized soft architecture parameters into a deterministic architecture, with the optimal soft architecture parameters as the input and the deterministic retrieval model architecture as the output.

[0050] In specific implementation according to the embodiments of the present application, for each type of component, the option with the largest weight is selected as the final choice: ; Among them, represents the index of the optimal component option selected finally, represents the parameter value when the following expression obtains the maximum value, represents the set of all optional component options, represents the th soft selection weight of the

[0051] th option of the

[0052] Step 3, hierarchical knowledge distillation transfer chain. Based on the optimal model architecture, a multi-level distillation structure from the original large model to the target lightweight model is constructed, and efficient knowledge transfer is achieved through feature matching and attention guidance, and a preliminary lightweight model is output; Specifically, it includes the following sub-steps: Step 3.1, construct the knowledge transfer chain architecture; Establish a hierarchical model transfer chain structure, with the input being the original large retrieval model and the target lightweight model architecture, and the output being a transfer chain containing multiple intermediate-scale models.

[0053] In specific implementation, first determine the length of the transfer chain, which is determined according to the scale difference between the original model and the target model. Then, design intermediate models to form a decreasing sequence of scales from the original large model to the target lightweight model , where , , respectively represent the th, th, th intermediate models; represents the target lightweight model.

[0054] Each intermediate model adopts the same architecture type as the target model, but the scale gradually decreases, usually following the following rules: ; Among them, Represents the number of parameters of the th model, represents the index position of the model in the transfer chain ( from 0 to ), represents the original large model, represents the target lightweight model, represents the total length of the transfer chain, that is, the total number of models minus 1, represents the ratio of the number of parameters of the target lightweight model to that of the original large model. This formula ensures that the model scale shows a smooth decreasing trend from the original large model to the target lightweight model, avoiding knowledge transfer loss caused by excessive difference in the number of parameters between adjacent models.

[0055] Step 3.2, implement feature matching and attention guidance; For adjacent model pairs in the transfer chain, perform knowledge transfer of feature matching and attention guidance, with the input being the teacher model and the student model , and the output being the trained student model.

[0056] The feature matching process aligns the intermediate layer feature representations of the models, and the loss function is: ; where, represents the feature matching loss function, which is used to measure the difference between the feature representations of the student model and the teacher model; represents the index of the model layer, which is used to traverse each layer of the model; , respectively represent the feature representations of the th layer of the student model and the teacher model, that is, the output vectors or tensors of each layer; is the layer weight coefficient, which is used to adjust the importance of feature matching in different layers. Usually, the weight is larger for layers closer to the output layer; represents the square of the Euclidean distance, which is used to calculate the difference degree between two feature representations; represents the summation operation over all selected model layers, comprehensively considering the feature matching situations of each layer.

[0057] In some embodiments, feature matching can be extended from simple Euclidean distance to more complex distribution matching, such as by minimizing the KL divergence or JS divergence between the student features and the teacher features. Especially when the feature distribution shows multimodal characteristics, this method can better preserve the distribution information.

[0058] For different types of feature representations, different distance metrics can be adopted. For example, for sequence features, the Dynamic Time Warping (DTW) distance can be used, and for graph structure features, the graph edit distance can be used, etc.

[0059] The attention guidance process ensures that the student model focuses on the same input regions as the teacher model, specifically achieved through the alignment of attention maps: ; where represents the attention guidance loss function, which is used to measure the difference in the attention distributions between the student model and the teacher model; represents the attention weight matrix generated by the student model when processing input data, reflecting which parts of the input the student model focuses on; represents the attention weight matrix of the teacher model, serving as the learning target for the student model; represents the Frobenius norm, which is a type of matrix norm used to calculate the Euclidean distance between two attention matrices. The smaller its value, the more similar the two attention distributions are.

[0060] Feature matching and attention guidance are the key innovative technologies of this application. In the application scenario of financial risk control agents, large teacher models may construct complex feature representations on multiple dimensions of transaction data, including time patterns, amount distributions, merchant categories, etc.

[0061] Through feature matching, the small student model not only learns the final risk control decisions but also learns the extraction methods of these intermediate features. For example, when an abnormal transaction pattern is detected, the student model will focus on the same key transaction features as the teacher model (such as geographical location span within a short time, sudden change in transaction frequency, etc.), so that it can still maintain a high-accuracy risk identification ability while significantly reducing the model size.

[0062] The final distillation loss function combines feature matching, attention guidance, and task-specific losses: ; where is the final distillation loss function, which is used to guide the training of the student model; is the loss function for a specific retrieval task, such as ranking loss or classification loss, ensuring that the student model can complete the original task; is the feature matching loss, which is used to align the intermediate layer feature representations of the student model and the teacher model; is the attention guidance loss, which ensures that the student model focuses on the same input regions as the teacher model; 、 、 They are weight coefficients representing task learning, feature matching, and attention respectively.

[0063] The distillation process can introduce a curriculum learning strategy, starting from simple samples and gradually increasing the sample complexity, enabling the student model to learn the knowledge of the teacher model more smoothly.

[0064] Step 3.3, perform progressive knowledge transfer; Perform knowledge distillation sequentially on the transfer chain. The input is the constructed transfer chain and the initialized model parameters of each model, and the output is the trained target lightweight model.

[0065] According to the embodiments of the present application, in specific implementation, the distillation process is performed in descending order: Use the pre-trained original large model as the first teacher model; For each pair of adjacent models , use the method in Step 3.2 to perform knowledge distillation and train the student model ; After training is completed, change the current student model to the teacher model in the next stage and continue the distillation process; Repeat the above process until the target lightweight model is trained.

[0066] This progressive knowledge transfer method effectively reduces the information loss in the knowledge compression process by narrowing the scale gap between adjacent models, enabling the final lightweight model to better retain the retrieval ability of the original large model.

[0067] Step 4, task-oriented adaptive compression, perform mixed-precision quantization and structured pruning on different layers based on the preliminary lightweight model and model sensitivity analysis to generate an optimized model adapted to the target device; Specifically, it includes the following sub-steps: Step 4.1, perform model sensitivity analysis; This step analyzes the importance of the parameters of each layer of the model. The input is the lightweight model, and the output is the sensitivity score of the parameters of each layer.

[0068] In specific implementation, first define a parameter sensitivity evaluation function: ; Among them, is the loss function on the validation set, representing the overall performance metric of the model on the validation dataset; is the th weight parameter of the th layer, representing the th th trainable parameter in the represents the partial derivative of the loss function with respect to this weight parameter, reflecting the degree of influence of this parameter on the model performance; is the magnitude of the gradient after taking the absolute value, representing a quantitative indicator of parameter importance; is the total number of parameters in this layer, used for normalizing the calculation result; represents the overall sensitivity score of the

[0069] layer. The larger the value, the more significant the influence of this layer on the model performance.

[0070] In some embodiments, in addition to the gradient-based sensitivity analysis, a perturbation analysis method can also be adopted, that is, by adding different degrees of noise to the parameters and observing the degree of change in the model performance, so as to evaluate the importance of the parameters. This method is also applicable to non-differentiable evaluation metrics.

[0071] The sensitivity analysis algorithm has important applications in the deployment of video analysis agents. For example, in a security monitoring system, through sensitivity analysis, it may be found that the convolutional layer responsible for face feature extraction in the model has the greatest impact on the final recognition accuracy, while the impact of the background scene analysis layer is relatively small.

[0072] Based on this discovery, the system will reserve a higher precision (8 bits) for the layers related to face feature extraction, while using a lower precision quantization (2 to 4 bits) for the background analysis layer, so as to significantly reduce the model volume and inference latency while maintaining the key recognition ability, enabling the agent to operate efficiently on devices with limited computing resources such as edge cameras.

[0073] To improve the stability of sensitivity evaluation, the average sensitivity can be calculated using multiple batches of data: ; where represents the average sensitivity score of the parameters of the layer, is the sensitivity of the parameters of the layer calculated on the batch of data, is the total number of batches used for calculating sensitivity. This formula improves the stability and reliability of sensitivity evaluation by taking the average of the sensitivities calculated from multiple data batches, reducing the impact of fluctuations that may be brought by a single batch of data.

[0074] Finally, according to the sensitivity scores, each layer of the model is divided into high-sensitivity layers, medium-sensitivity layers, and low-sensitivity layers, providing a basis for subsequent differential compression.

[0075] Step 4.2, apply mixed-precision quantization; Perform differential precision quantization on the model, with the input being the model parameters and sensitivity scores, and the output being the quantized low-precision model.

[0076] According to the embodiments of the present application, in specific implementation, the following quantization strategy is adopted: For high-sensitivity layers, 8-bit quantization is adopted to retain a relatively high precision: ; where, represents the original floating-point weight parameter of the th layer, represents the minimum value of the parameters of this layer, represents the maximum value of the parameters of this layer, represents the operation of normalizing the parameters to the interval, represents mapping the normalized value to the integer interval, The function ensures that the value does not exceed the valid range, represents performing a rounding operation,

[0077] ; where, represents the weight parameter of the th layer after 4-bit quantization; represents the original weight parameter of the th layer; represents the minimum value of the weight parameters of the th layer; represents the maximum value of the weight parameters of the th layer; represents the rounding function; represents the clipping function that limits the value within the valid range; represents that the integer range that 4 bits can represent is 0 - 15, a total of 16 different values. This formula realizes the quantization process of linearly mapping the floating-point weights to 4-bit integer representation.

[0078] For low-sensitivity layers, 2-bit quantization is adopted: ; where, represents the weight parameter of the th layer after 2-bit quantization; represents the Original weight parameters of the layer; Indicates the Minimum value of the weight parameters of the Indicates the Maximum value of the weight parameters of the Indicates the rounding function; Indicates the clipping function that limits the value within a valid range; Indicates the normalization of the weights, mapping the weights to the interval [0, 1]; multiplying by 3 gives values in the interval [0, 3], corresponding to the 4 possible values (0, 1, 2, 3) after 2-bit quantization.

[0079] For particularly important parameter blocks, asymmetric quantization can be used to improve accuracy: ; Among them, Indicates the Weight parameters after asymmetric quantization for the Indicates the Weight parameters of the layer quantized into integer form; is the quantization scaling factor, used to map the integer value back to the floating-point range, and its value is calculated based on the distribution characteristics of the parameters of this layer;

[0080] Step 4.3, perform structured pruning; Remove the connections with less contribution through structured pruning. The input is the quantized model, and the output is a further compressed sparse model.

[0081] In specific implementation, first calculate the importance score for the parameters of each layer of the model or the entire sub-structure: ; Among them, Indicates the importance score of the parameters of the is the absolute value size of the parameters of the layer, reflecting the magnitude of the parameters themselves; is the magnitude of the gradient after taking the absolute value; the product of the two comprehensively considers the magnitude and sensitivity of the parameter. The larger the value, the more important the parameter or structure is to the model and the more it should be retained.

[0082] Set the pruning threshold according to the importance score , for each layer: Remove the connections with importance lower than the threshold: ; where represents the weight matrix after pruning, represents the original weight matrix, represents the importance score of the weight, represents the pruning threshold of the layer, is the indicator function, which takes the value of 1 when the weight importance is greater than the threshold and 0 otherwise, achieving the removal of low-importance connections; For structural units (such as the entire filter or attention head), evaluate their overall importance and remove several units with the lowest importance; After the pruning operation, perform short-term fine-tuning to restore performance.

[0083] The final pruning rate is adaptively adjusted according to the resource constraints of the target device. For devices with extremely limited computing resources, more aggressive pruning can be performed, sacrificing some accuracy in exchange for higher efficiency.

[0084] Step 4.4, optimize the inference computation graph; Optimize the inference graph for the quantized and pruned model. The input is the compressed model, and the output is the optimized computation graph suitable for the target hardware.

[0085] According to the embodiments of the present application, the specific implementation includes: Operator fusion, combining multiple consecutive operations into a single efficient operation; Memory planning, optimizing the storage and reuse of intermediate results; Parallel scheduling, reasonably allocating computing tasks to make full use of the hardware parallel characteristics.

[0086] For different target deployment platforms, such as ARM mobile processors, FPGAs or custom AI accelerators, perform specific inference optimizations to further improve the running efficiency of the model on the target device.

[0087] Step 5, automated evaluation and iterative improvement. Based on the optimized model, build a multi-scenario evaluation system, apply reinforcement learning algorithms to optimize the distillation path and hyperparameters, perform dynamic adjustment and continuous optimization, form a closed-loop optimization process, and output the final deployment model; Specifically, it includes the following sub-steps: Step 5.1, construct a multi-scenario evaluation system; Establish an evaluation environment covering multiple retrieval scenarios, with the input being the compressed and optimized model, and the output being the comprehensive performance score of the model in each scenario.

[0088] Specifically, when implementing, construct an evaluation dataset containing different retrieval difficulties and characteristics, covering: Simple word matching scenario; Semantic retrieval scenario; Multi-round interactive retrieval scenario; Noisy data retrieval scenario.

[0089] For each scenario, design corresponding evaluation metrics and weights, and comprehensively consider retrieval accuracy, response time, and resource consumption.

[0090] In some embodiments, the evaluation system can introduce adversarial sample testing. By generating boundary cases and abnormal inputs, the robustness and abnormal handling ability of the model are evaluated, which is particularly important for safety-critical applications.

[0091] Multi-scenario evaluation can adopt automated sensitivity analysis. By systematically varying input parameters (such as query length, noise level, etc.), draw a curve of model performance varying with parameters, so as to comprehensively understand the advantages and limitations of the model.

[0092] In practical applications, for example, when constructing an intelligent customer service robot, the multi-scenario evaluation system will evaluate the model performance in multiple scenarios simultaneously: test the accuracy and response speed in the simple FAQs matching scenario; Test the context understanding ability in the complex multi-round dialogue scenario; Test the robustness in the noisy data scenario (such as user spelling mistakes, ungrammatical expressions).

[0093] By synthesizing the evaluation results of these scenarios, the system can discover in which scenarios the model performs poorly, and thus targetedly adjust the optimization direction. For example, if it is found that the model has insufficient context understanding ability in multi-round conversations, the system will automatically enhance the expression ability of relevant modules, and may appropriately sacrifice some response speed to improve the overall user experience.

[0094] The evaluation results are presented in the form of a performance profiling chart, clearly showing the performance of the model in various aspects and the bottlenecks, providing a direction for subsequent optimization.

[0095] Step 5.2, apply reinforcement learning to optimize the distillation path and hyperparameters; Use the reinforcement learning algorithm to automatically search for the optimal distillation path and hyperparameters, with the input being the feedback data of the evaluation system, and the output being the optimized distillation strategy.

[0096] According to the embodiment of the present application, in a specific implementation, a policy space is first defined, including: delivery chain length and structure; The weight coefficient of the distillation loss function; Layer selection for feature matching; Hyperparameters such as learning rate and number of training rounds.

[0097] Then, a reinforcement learning agent is built to gradually learn the optimal strategy by continuously trying different strategy combinations and obtaining evaluation feedback.

[0098] A gradient-based strategy search algorithm is used, and the optimization goal is the comprehensive performance score of the model in the evaluation system.

[0099] During the learning process, the agent can automatically adjust the most suitable distillation strategy according to the characteristics of different retrieval tasks. For example, for semantically complex tasks, the weight of feature matching may be increased; while for simple matching tasks, more emphasis may be placed on model lightweighting.

[0100] Step 5.3, perform dynamic adjustment and continuous optimization; The optimization direction is dynamically adjusted based on the evaluation feedback. The input is the model performance analysis data, and the output is the adjusted optimization strategy and improved model.

[0101] According to an embodiment of the present application, during implementation, the system analyzes performance profiling data to identify the main bottlenecks of the current model: If the bottleneck is retrieval accuracy, adjust the architecture search space and add component options with stronger model expressiveness; If the bottleneck is inference speed, optimize computationally intensive operations such as attention calculation or sequence processing; If the bottleneck is memory usage, strengthen parameter sharing or increase the intensity of structured pruning.

[0102] Based on the identified bottlenecks, the system automatically adjusts the focus of each optimization step, such as re-executing the architecture search, adjusting the distillation strategy, or modifying the compression scheme, forming a closed-loop optimization process to continuously improve model performance until the predetermined goals are met.

[0103] Application examples of this embodiment: Intelligent customer service scenario application: The method for rapidly constructing an intelligent agent based on enhanced retrieval of the present invention can be applied to the rapid construction and deployment of an enterprise intelligent customer service system. The following takes the construction of an after-sales service intelligent agent on an e-commerce platform as an example to explain the specific application process of the method of the present invention in detail.

[0104] Predefined model library construction: For e-commerce after-sales service scenarios, a predefined model library containing the following models is built: Base encoders: 10 mainstream pre-trained models such as BERT-base Chinese pre-trained model, RoBERTa-wwm-ext Chinese pre-trained model, MacBERT pre-trained model, DeBERTa-v3-base model, etc.; Interaction layer: 5 interaction mechanisms such as Cross-Attention mechanism, Co-Attention mechanism, Dot-ProductAttention; Aggregation layer: 6 aggregation methods such as average pooling, max pooling, self-attention pooling; Feature analysis network: 4 feature analysis networks such as Transformer-based text analysis network, CNN-based feature extraction network.

[0105] Perform feature analysis on the e-commerce after-sales knowledge base: Collect historical Q&A data and knowledge base documents of e-commerce platform after-sales services, including multiple categories such as return and exchange policies, logistics issues, and product quality issues, totaling 100,000 Q&A pairs and 5,000 knowledge documents. Use the feature analysis system for processing: Semantic feature analysis: Perform semantic analysis on Q&A pairs and knowledge documents to extract key information such as question type, sentiment tendency, and key entities. The analysis finds that e-commerce after-sales problems mainly focus on several aspects such as "refund process", "logistics status", and "product quality", and the problem expressions are diverse, and the same problem may have multiple different expressions.

[0106] Structural feature analysis: Analyze the structural features of knowledge base documents, including paragraph division, title hierarchy, list structure, etc. It is found that most knowledge documents adopt a hierarchical structure, and important information often appears at the title and the beginning of paragraphs.

[0107] Interaction feature analysis: Analyze the semantic association pattern between user questions and answers, and find that in after-sales services, user questions are often incomplete or contain implicit information, and the intelligent agent needs to understand the user's true intention through the context.

[0108] Based on the analysis results, the feature fusion network generates a 16-dimensional low-dimensional feature vector, including 6-dimensional semantic features, 4-dimensional structural features, and 6-dimensional interaction features. This feature vector contains the core feature information of e-commerce after-sales service text data.

[0109] Execute the architecture evolution algorithm: According to the 16-dimensional features of the feature vector, set the constraint conditions of the architecture evolution algorithm: Response speed limit: The single query response time does not exceed 100ms; Accuracy requirement: The Top-3 recall rate is not less than 95%; Resource limit: The model size should not exceed 500MB.

[0110] The evolutionary algorithm executes as follows: Initialize the population: Randomly generate 50 different combinations of encoder interaction layer and aggregation layer; Fitness evaluation: Evaluate the performance of each combination on the e-commerce after-sales dataset; Evolutionary iteration: Execute 200 rounds of evolutionary iteration, including crossover, mutation, and selection operations; Optimal solution selection: Select the 5 architecture combinations with the highest fitness to enter the next stage.

[0111] After algorithm optimization, the finally selected optimal architecture is: MacBERT-base encoder + Cross-Attention interaction layer + self-attention pooling aggregation layer combination. This architecture performs best on the feature vectors in the e-commerce after-sales scenario, balancing accuracy and efficiency.

[0112] Construct the knowledge distillation chain: Starting from the optimal architecture, construct a 3-level knowledge distillation chain: Teacher model: MacBERT-base encoder (110M parameters) + Cross-Attention interaction layer + self-attention pooling aggregation layer; Intermediate student model: 6-layer Transformer encoder (60M parameters) + simplified Cross-Attention interaction layer + self-attention pooling aggregation layer; Final lightweight model: 4-layer Transformer encoder (25M parameters) + dot product attention interaction layer + weighted average pooling aggregation layer.

[0113] During the distillation process, use 100,000 question-and-answer pairs and 5,000 knowledge documents from the e-commerce after-sales platform as distillation data, and at the same time introduce 3,000 manually annotated high-quality question-and-answer pairs as alignment data.

[0114] Differential compression: For the final lightweight model, implement the differential compression strategy: Encoding layer compression: Apply the weight pruning technique to retain 85% of the weights and reduce the number of parameters; Interaction layer optimization: Design a simplified dot product attention mechanism to reduce the computational complexity; Aggregation layer simplification: Use weighted average pooling to replace complex pooling operations; Quantization processing: Perform 8-bit quantization on the model weights to further reduce the model size.

[0115] After differential compression, the size of the finally obtained lightweight retrieval model is only 15 MB, the single-query response time is reduced to 35 ms, and the Top-3 recall rate remains at 96.8%, meeting the high-efficiency response requirements of the e-commerce after-sales intelligent agent.

[0116] Deployment and evaluation: Deploy the constructed lightweight retrieval model to the after-sales service system of the e-commerce platform and conduct a comprehensive evaluation: Efficiency evaluation: Single-query response time: The average is 35 ms, meeting the instant response requirements; System resource occupancy: The peak CPU utilization rate does not exceed 30%, and the memory occupancy does not exceed 200 MB; Concurrent processing capacity: A single machine can handle 200 user queries simultaneously.

[0117] Effect evaluation: Problem understanding accuracy rate: 92.5%, a 15% increase compared to traditional methods; Knowledge retrieval accuracy rate: The Top-1 accuracy rate is 85.3%, and the Top-3 accuracy rate is 96.8%; User satisfaction: The tested user satisfaction reaches 4.6 / 5 points, a 22% increase compared to the original system.

[0118] Comparative experiment: Compared with traditional retrieval methods based on BM25 and TF-IDF, under the same hardware conditions, this system: The response speed is increased by 65% (from 100 ms to 35 ms); The retrieval accuracy rate is increased by 25% (the Top-3 accuracy rate is increased from 71.8% to 96.8%); The system resource occupancy is reduced by 40%.

[0119] Compared with the intelligent agent constructed directly using large language models: The deployment cost is reduced by 90%; The response speed is increased by 98%; The accuracy rate in specific domain knowledge Q&A is increased by 12%.

[0120] Medical consultation intelligent agent application example: To demonstrate the generality of the method of the present invention, its application in the construction of a medical consultation intelligent agent is briefly described below.

[0121] Feature analysis and architecture selection: For the text characteristics in the field of medical consultation (with many professional terms and high requirements for semantic precision), the feature analysis system generates a 20-dimensional feature vector focusing on professional term recognition and semantic precision. The optimal architecture selected by the architecture evolution algorithm is: BioBERT encoder + Co-Attention interaction layer + multi-head self-attention aggregation layer.

[0122] Knowledge distillation and compression: Through a three-level knowledge distillation chain and a differential compression strategy, a lightweight retrieval model with a size of 18MB is finally obtained, which controls the response time within 40ms while maintaining an accuracy rate of over 95%.

[0123] Application effect: The deployed medical consultation intelligent agent obtained a satisfaction score of 4.5 / 5 among 5000 test users, was able to accurately understand over 90% of medical consultation questions, and quickly retrieve relevant knowledge, greatly improving the efficiency and accuracy of medical consultation.

[0124] Summary of application examples: From the above two application examples, it can be seen that the method for quickly constructing an intelligent agent based on enhanced retrieval of the present invention has the following advantages: High efficiency: It can quickly construct a lightweight retrieval-enhanced intelligent agent in a specific field, and the deployment cycle is shortened from the traditional several months to several days; Accuracy: Through feature analysis, architecture evolution, and knowledge distillation, a retrieval effect with high accuracy is achieved; Lightweight: The final model has a small volume and low resource occupancy, and is suitable for deployment in resource-constrained environments; Versatility: The method is applicable to a variety of different fields and only needs to be appropriately adjusted according to the field characteristics; Scalability: The constructed intelligent agent is easy to maintain and update, and the performance can be continuously optimized as the knowledge base expands.

[0125] The above application examples fully demonstrate the application value and technical advantages of the present invention in actual scenarios, providing an effective solution for the quick construction of various intelligent agents.

[0126] The embodiments of the present invention have been described above, but the embodiments are not limited to the above specific implementation manners. The above specific implementation manners are merely illustrative and not restrictive. Under the inspiration of this embodiment, those of ordinary skill in the art can also make more equivalent embodiments in various forms, all of which fall within the protection scope of this embodiment.

Claims

1. A method for quickly constructing an agent based on enhanced retrieval, characterized in that It includes the following steps: Retrieval task feature analysis and parameterization, constructing a multi-dimensional task analysis system, automatically characterizing the retrieval task features through data distribution, query complexity, semantic requirements and other features, and forming a task feature vector; Multi-objective architecture search and optimization, based on the task feature vector, executing a progressive architecture evolution algorithm to automatically find the optimal model architecture that satisfies the multi-dimensional balance of retrieval accuracy, computational complexity and memory occupancy; Hierarchical knowledge distillation transfer chain, based on the optimal model architecture, constructing a multi-level distillation structure from the original large model to the target lightweight model, realizing efficient knowledge transfer through feature matching and attention guidance, and outputting a preliminary lightweight model; Task-oriented adaptive compression, based on the preliminary lightweight model and model sensitivity analysis, performing mixed-precision quantization and structured pruning on different levels to generate an optimized model adapted to the target device; Automated evaluation and iterative improvement, based on the optimized model, constructing a multi-scenario evaluation system, applying reinforcement learning algorithms to optimize the distillation path and hyperparameters, performing dynamic adjustment and continuous optimization, forming a closed-loop optimization process, and outputting the final deployment model.

2. The method for quickly constructing an agent based on enhanced retrieval according to claim 1, wherein In the retrieval task feature analysis and parameterization step, the multi-dimensional task analysis system extracts three types of key features: data distribution features, query complexity features and semantic requirement features, and generates a low-dimensional task feature vector through a feature fusion network.

3. The method for quickly constructing an agent based on enhanced retrieval according to claim 2, wherein The feature fusion process is realized by a weighted combination method, that is, the data distribution feature, query complexity feature and semantic requirement feature are respectively multiplied by the corresponding weight matrix and then added, and then the final task feature vector is generated through a non-linear activation function.

4. A method for quickly constructing an agent based on enhanced retrieval according to claim 1, characterized in that, In the multi-objective architecture search and optimization step, a weighted comprehensive scoring function is adopted. The weighted comprehensive scoring function comprehensively considers three aspects: performance loss, computational complexity loss and memory occupancy loss, and balances the importance of each objective through weight coefficients.

5. A method for quickly constructing an agent based on enhanced retrieval according to claim 1, characterized in that, In the hierarchical knowledge distillation transfer chain step, the scale of the intermediate model is designed according to the linear decreasing rule from the original large model to the target lightweight model to ensure smooth transition of knowledge during the transfer process.

6. A method for quickly constructing an agent based on enhanced retrieval according to claim 1, characterized in that In the hierarchical knowledge distillation transfer chain step, the feature matching loss function is realized by calculating the sum of the squares of the Euclidean distances between the feature representations of the corresponding layers of the student model and the teacher model, and different weights are assigned according to the importance of the layers.

7. A method for quickly constructing an agent based on enhanced retrieval according to claim 1, characterized in that, In the task-oriented adaptive compression step, the parameter sensitivity evaluation is measured by calculating the average absolute value of the gradient of the validation set loss function with respect to each layer's parameters, so as to determine the influence degree of different layer parameters on the model performance.

8. A method for quickly constructing an agent based on enhanced retrieval according to claim 1, characterized in that, In the task-oriented adaptive compression step, a mixed-precision quantization strategy is adopted, 8-bit quantization is used for high-sensitivity layers, 4-bit quantization is used for medium-sensitivity layers, and 2-bit quantization is used for low-sensitivity layers.

9. A method for quickly constructing an agent based on enhanced retrieval according to claim 1, characterized in that It also includes an automated evaluation and iterative improvement step: constructing a multi-scenario evaluation system, applying reinforcement learning algorithms to optimize the distillation path and hyperparameters, performing dynamic adjustment and continuous optimization, and forming a closed-loop optimization process.

10. An intelligent agent rapid construction system based on enhanced retrieval, which is used to execute an intelligent agent rapid construction method based on enhanced retrieval according to any one of claims 1-9, and is characterized in that, It includes: A retrieval task analysis subsystem for performing retrieval task feature analysis and parameterization; An architecture search subsystem for performing multi-objective architecture search and optimization; Knowledge distillation subsystem for performing hierarchical knowledge distillation transfer chain; Model compression subsystem for performing task-oriented adaptive compression; Evaluation and optimization subsystem for performing automated evaluation and iterative improvement.

Citation Information

Patent Citations

  • Classification task label noise-oriented robustness loss function search method and system

    CN115618935A

  • Information matching method and system based on large language model

    CN118484510A

  • Monocular image multi-modal CAD model retrieval method based on pre-training large model

    CN119106151A

  • AI-based big data distributed computing task automatic optimization method and system

    CN119576507A

  • Text retrieval enhancement generation method and device, medium and equipment

    CN120104718A

Cited By

  • Domain large model lightweight adaptive method and system based on knowledge distillation

    CN120832915A

  • AI model distillation migration edge deployment method of cross-chip architecture

    CN121029189A

  • An AI model distillation migration edge deployment method across a chip architecture

    CN121029189B

  • Energy consumption optimization-oriented ecological environment large model hierarchical optimization method and system

    CN121920622A

  • An ecological environment large model hierarchical optimization method and system for energy consumption optimization

    CN121920622B