Agent-oriented model-based reasoning query re-optimization method, device, equipment and medium

By monitoring system resources and query plan selection rate, when changes exceed a threshold, the proxy model is retrained based on the new query plan and historical data is reused. This solves the problem of high computational overhead in proxy model re-optimization and achieves more efficient query optimization.

CN119149588BActive Publication Date: 2026-01-27HANGZHOU HIGH-TECH ZONE (BINJIANG) INSTITUTE OF BLOCKCHAIN & DATA SECURITY +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411639951.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-18
Publication Date
2026-01-27
Estimated Expiration
2044-11-18

AI Technical Summary

Technical Problem

Existing methods for re-optimizing inference queries for agent models suffer from significant computational overhead, which remains unresolved.

Method used

By monitoring system resources and query plan selection rate during query plan execution, when changes exceed a threshold, the proxy model is retrained based on the new query plan. Historical data is reused during the retraining process, avoiding the use of machine learning models to relabel and reducing computational overhead.

Benefits of technology

It reduces the computational overhead of retraining the proxy model, improves retraining efficiency, and enables the query plan to adapt to changes in data distribution and system resources, avoiding the performance degradation caused by fixed query plans in traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119149588B_ABST
    Figure CN119149588B_ABST
Patent Text Reader

Abstract

The application relates to a reasoning query re-optimization method and device based on a proxy model, equipment and a medium. Current batch data is input into a reasoning model for processing based on a first query plan to obtain data required by a query. The reasoning model comprises a proxy model and a machine learning model. Statistical information is monitored during execution of the first query plan. The statistical information comprises system resources or a query plan selection rate. When a change in the statistical information exceeds a threshold value, historical data is input into the proxy model for retraining based on a second query plan. The historical data comprises data carrying a label after being input into the reasoning model for processing before the current batch data. The method reduces the calculation overhead generated by the re-optimization reasoning query method and improves the re-optimization efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing, and in particular to a method, apparatus, device, and medium for re-optimizing inference queries for a proxy model. Background Technology

[0002] In recent years, with the rapid development of big data and artificial intelligence technologies, the scale of data has continued to grow, and the data analysis process has become increasingly complex, often involving sophisticated machine learning and deep learning techniques to extract knowledge from massive amounts of data. The data analysis process is manifested in the form of queries, while complex machine learning and deep learning models are encapsulated in user-defined functions (UDFs).

[0003] Traditional inference query methods often plan a query only once. The fixed query plan generated before the query begins is likely to experience performance degradation over time. Therefore, a re-optimization mechanism is needed. Processing complex machine learning UDF queries on large-scale datasets is typically very time-consuming; therefore, traditional query optimization methods can usually only optimize the execution of UDF filtering queries to a limited extent. For example, predicate pushdown methods can only push the query predicate down to the machine learning UDF that generates the corresponding label columns. The machine learning UDF still needs to process all the input data because the filter requires the machine learning UDF to generate the corresponding category labels to select the appropriate category. Reordering techniques find the optimal order based on the execution cost and selectivity of the machine learning UDFs, but the first UDF still needs to process all the input data.

[0004] In recent years, to optimize the execution of UDF filtering queries, related techniques have involved cascading two lightweight models, called surrogate models, before the time-consuming UDFs. This reduces the amount of data that subsequent time-consuming UDFs need to process, thereby reducing the overall query processing time. To further reduce overall query processing time, a lightweight surrogate model is trained for each UDF filter at a finer granular level, and these lightweight surrogate models are cascaded before the first UDF. To fully utilize the correlations between different UDF filters, the surrogate models are retrained. However, retraining the surrogate models incurs significant computational overhead.

[0005] Currently, no effective solution has been proposed for the problem of large computational overhead in the reasoning query re-optimization method for agent models in related technologies. Summary of the Invention

[0006] Therefore, it is necessary to provide a method, apparatus, device, and medium for re-optimizing inference queries for agent-oriented models that can reduce computational overhead, in order to address the aforementioned technical problems.

[0007] Firstly, this application provides a reasoning query re-optimization method for agent models, including:

[0008] Based on the first query plan, the current batch of data is input into the inference model for processing to obtain the data to be queried; wherein, the inference model includes a proxy model and a machine learning model;

[0009] During the execution of the first query plan, statistical information is monitored; wherein, the statistical information includes system resources or query plan selection rate;

[0010] If the change in the statistical information exceeds the threshold, historical data is input into the agent model for retraining based on the second query plan; wherein, the historical data includes data that was input into the inference model before the current batch of data and then labeled.

[0011] In one embodiment, if the change in the statistical information is detected to exceed a threshold, historical data is input into the proxy model for retraining based on a second query plan, including:

[0012] If the changes in the system resources exceed the threshold, the historical data is input into the agent model for retraining.

[0013] In one embodiment, if the change in the statistical information is detected to exceed a threshold, historical data is input into the proxy model for retraining based on a second query plan, including:

[0014] If the change in the query plan selection rate exceeds a threshold, target data similar to the current batch data is selected from the historical data.

[0015] The target data is input into the proxy model for retraining.

[0016] In one embodiment, the target data is input into the proxy model for retraining, including:

[0017] If the amount of data in the target data is less than the amount of data in the current batch, then some data is read from the current batch and added to the target data, so that the amount of data in the target data is not less than the amount of data in the current batch.

[0018] In one embodiment, when the changes in the system resources are detected to exceed a threshold, the historical data is input into the proxy model for retraining, including:

[0019] Multiple precision combinations are determined based on the target accuracy in the second query plan; wherein each precision combination includes multiple precision values ​​of the proxy model;

[0020] A first precision combination is obtained by combining the precision values ​​of multiple first surrogate models to be retrained, and it is determined whether there is a second precision combination that has a common prefix with the first precision combination; wherein, the second precision combination is obtained by combining the precision values ​​of multiple second surrogate models that have been retrained, and the common prefix includes at least one identical precision;

[0021] If it is determined that there is a second precision combination that has a common prefix with the first precision combination, the first proxy model corresponding to the common prefix part is replaced with the corresponding second proxy model, and the historical data is input into the remaining first proxy models for retraining.

[0022] In one embodiment, if the change in the statistical information is detected to exceed a threshold, the method further includes:

[0023] Multiple candidate query plans are input into a deep learning model. The execution time of each candidate query plan on the current batch of data is estimated based on the deep learning model, and the candidate query plan with the shortest execution time is determined as the second query plan.

[0024] In one embodiment, the method further includes, before inputting the current batch of data into the inference model:

[0025] Based on different search paths, different batches of data, and different system resources, multiple preset query plans are determined.

[0026] Execute the preset query plan and obtain the execution results; wherein the execution results include at least one of the following: accuracy, selection rate, rejection rate, and time cost;

[0027] Training data is generated based on the preset query plan and the execution results;

[0028] The deep learning model is trained based on the training data.

[0029] Secondly, this application also provides a reasoning query re-optimization apparatus for agent models, the apparatus comprising:

[0030] The query module is used to input the current batch of data into the inference model for processing based on the first query plan, so as to obtain the data to be queried; wherein, the inference model includes a proxy model and a machine learning model;

[0031] The monitoring module is used to monitor statistical information during the execution of the first query plan; wherein the statistical information includes system resources or query plan selection rate;

[0032] The re-optimization module is used to input historical data into the proxy model for retraining based on the second query plan when the change in the statistical information exceeds a threshold; wherein, the historical data includes data that was input into the inference model before the current batch of data and then labeled.

[0033] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method described in the first aspect above.

[0034] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the first aspect above.

[0035] The aforementioned inference query re-optimization method, apparatus, device, and medium for surrogate models utilize system resources or query plan selection rate as statistical information during query plan execution. By monitoring this statistical information and retraining the surrogate model based on a new query plan when a sudden change in statistical information is detected, the query plan can be adjusted according to changes in factors such as the data distribution and system resources involved in the query. This avoids the drawbacks of traditional methods that only plan the query plan once. Furthermore, by reusing historical data during the surrogate model retraining process, the re-optimization overhead caused by relabeling data using machine learning models can be avoided, thereby reducing the computational overhead of retraining the surrogate model and improving retraining efficiency. Attached Figure Description

[0036] Figure 1 This is a hardware structure block diagram of a terminal for a reasoning query re-optimization method for a proxy model in one embodiment.

[0037] Figure 2 This is a flowchart of a reasoning query re-optimization method for a proxy model in one embodiment;

[0038] Figure 3 This is a flowchart of a historical data reuse method under different circumstances in one embodiment;

[0039] Figure 4This is a flowchart of a proxy model reuse method in one embodiment;

[0040] Figure 5 This is a block diagram of a reasoning query re-optimization device for a proxy model in one embodiment.

[0041] Figure 6 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0042] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0043] Unless otherwise defined, the technical or scientific terms used in this application shall have the general meaning understood by one of ordinary skill in the art to which this application pertains. Words such as “a,” “an,” “an,” “the,” “the,” and “these” used in this application do not indicate quantitative limitation and may be singular or plural. The terms “comprising,” “including,” “having,” and any variations thereof used in this application are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that comprises a series of steps or modules (units) is not limited to the listed steps or modules (units) but may include steps or modules (units) not listed, or may include other steps or modules (units) inherent to these processes, methods, products, or devices. Words such as “connected,” “linked,” and “coupled” used in this application are not limited to physical or mechanical connections but may include electrical connections, whether direct or indirect. “Multiple” used in this application refers to two or more. “And / or” describes the relationship between related objects, indicating that three relationships may exist; for example, “A and / or B” can represent: A alone, A and B simultaneously, and B alone. Normally, the character " / " indicates that the objects before and after it are in an "or" relationship. The terms "first," "second," "third," etc., used in this application are merely to distinguish similar objects and do not represent a specific order of objects.

[0044] Suppose that the UDF filtering query q contains user-defined functions UDFs{F1, ..., F2}. n}, and their corresponding filters are {σ1, ..., σ} n}, and target accuracy A.

[0045] In related technologies, the reordering techniques and optimization methods for UDF-based filtering queries include the following steps:

[0046] S1, Construct the search tree (containing all permutations of UDFs involved in the query): For example, if the query contains two UDFs, F1 and F2, then the search space contains F1F2 and F2F1;

[0047] S2 explores different paths to find the fastest path given the accuracy target; S2 can be further divided into:

[0048] S2.1, Use UDF to process the data to be processed to generate labeled data for subsequent training of the agent model;

[0049] S2.2: Train the proxy model using the labeled data generated in S2.1 under different precision combinations, calculate the corresponding costs, and find the precision combination and path with the lowest cost, which is the near-optimal query plan.

[0050] The methods described above, when invoking the inference model (obtained by cascading a machine learning model onto a proxy model) based on the query plan, require labeling the data using a machine learning model to retrain the proxy model, followed by training the proxy model with the labeled data. However, this approach results in re-optimization overhead being as large as the initial optimization overhead. Furthermore, these methods ignore the dynamic changes in the environment present in queries. In stream processing scenarios, data distribution and system resources may constantly change, potentially leading to performance degradation of the fixed execution plan generated before the query begins. Based on the analysis of these issues, this application provides a method, apparatus, device, and medium for re-optimizing inference queries for proxy models that can reduce computational overhead.

[0051] In one embodiment, the inference query re-optimization method for the agent model can be executed on a terminal, computer, or similar computing device. For example, running on a terminal... Figure 1 This is a hardware structure block diagram of a terminal for a proxy-based inference query re-optimization method according to an embodiment of this application. For example... Figure 1 As shown, a terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 101 and a memory 102 for storing data are also included. The processor 101 may be, but is not limited to, a microprocessor (MCU) or a programmable logic device (FPGA). The terminal may also include a transmission device 103 for communication functions and an input / output device 104. Those skilled in the art will understand that… Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the terminal described above. For example, the terminal may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown are illustrated.

[0052] The memory 102 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the agent-based inference query re-optimization method in this embodiment. The processor 101 executes various functional applications and data processing by running the computer programs stored in the memory 102, thereby implementing the aforementioned method. The memory 102 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 102 may further include memory remotely located relative to the processor 101, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0053] The transmission device 103 is used to receive or send data via a network. This network includes a wireless network provided by the terminal's communication provider. In one example, the transmission device 103 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 103 can be a Radio Frequency (RF) module used for wireless communication with the Internet.

[0054] In one embodiment, such as Figure 2 The diagram shows a flowchart of a reasoning query re-optimization method for a proxy model, which is then applied to... Figure 1 Taking the terminal in the example, the explanation includes the following steps:

[0055] Step S101: Based on the first query plan, the current batch of data is input into the inference model for processing to obtain the data to be queried; wherein, the inference model includes a proxy model and a machine learning model.

[0056] The first query plan mainly includes: target accuracy, search path, and the selection of surrogate models. Optionally, the query plan can also include the data to be processed (i.e., the data to be queried) and system resources. Based on the first query plan, the current batch of data is input into the inference model for processing, which is the execution of the query plan. Specifically, given the target accuracy and system resources, the search path is used to filter and query the current batch of data to obtain the required data. The search path specifically refers to the order of the machine learning models. The machine learning models can be encapsulated in user-defined functions (UDFs) to filter and query the current batch of data and generate corresponding category labels. The surrogate model is cascaded before the machine learning model to select the appropriate category data for the machine learning model to process, thereby accelerating the execution of the machine learning model and reducing the filtering query time.

[0057] Specifically, in step S101, the batch data to be processed and system resources to be determined can be obtained by receiving the query request and predicate input by the user, and then a query plan can be generated. Based on the query plan, the inference model is called to process the current batch data to obtain the data to be queried.

[0058] Step S102: During the execution of the first query plan, monitor statistical information; wherein, the statistical information includes system resources or query plan selection rate.

[0059] System resources include, but are not limited to, hardware resources such as available CPUs, memory, and disk I / O, as well as software resources such as database connections. Query plan selection rate refers to the rate at which the machine learning model selects multiple possible query plans. Monitoring statistics involves monitoring whether changes in statistical information exceed thresholds. If changes exceed thresholds, it indicates a change in the current data distribution or system resources, causing a sudden shift in the execution time of the query plan per unit of data. If the surrogate model is not adjusted, the inference model will become unable to adapt to the current data distribution or system resources.

[0060] Step S103: If the change in statistical information exceeds the threshold, based on the second query plan, historical data is input into the proxy model for retraining; wherein, historical data includes data that was input into the inference model before the current batch of data and then labeled.

[0061] When changes in statistical information exceed a threshold, it indicates a sudden change in the current data distribution or system resources, requiring retraining of the surrogate model to adapt the inference model to the new data distribution or system resources. During surrogate model retraining, multiple search paths can be determined based on a given second query plan. These paths are then explored to find the fastest search path for a given target accuracy. The second query plan is the new query plan. Previously, a machine learning model was used to process the data to be processed, generating labeled data. This labeled data was then used to retrain the surrogate model. Specifically, the model was trained using labeled data under different accuracy combinations, and the corresponding costs were calculated to find the lowest-cost accuracy combination and search path, resulting in an approximately optimal query plan. Now, this embodiment skips the labeling step of the machine learning model and directly inputs historical data into the surrogate model for retraining. This is because the historical data has already been processed by the inference model and labeled, eliminating the need for repeated labeling.

[0062] Steps S101 to S103 above involve using system resources or query plan selection rate as statistical information during the execution of the query plan, and monitoring this statistical information. If a sudden change in the statistical information is detected, the proxy model is retrained based on the new query plan. This allows the query plan to be adjusted according to changes in factors such as the data distribution and system resources involved in the query, avoiding the drawbacks of traditional methods that only plan the query plan once. At the same time, historical data is reused during the retraining of the proxy model, which avoids the re-optimization overhead caused by relabeling the data using a machine learning model, thereby reducing the computational overhead of retraining the proxy model and improving retraining efficiency.

[0063] In one embodiment, Figure 3 Flowcharts are provided for methods of reusing historical data under different circumstances, such as Figure 3 As shown, the process includes the following steps:

[0064] Step S201: During the execution of the current query plan, monitor statistical information; if the change in system resources exceeds the threshold, proceed to step S202; otherwise, if the change in the query plan selection rate exceeds the threshold, proceed to step S203.

[0065] Step S202: Input historical data into the surrogate model for retraining. In this step, if the processing cost of the inference model changes due to changes in system resources (such as available CPUs, memory, disk I / O, and other hardware resources, as well as software resources such as database connections), the previously processed historical data can be reused without filtering to retrain the surrogate model.

[0066] Step S203: Select target data similar to the current batch of data from historical data; input the target data into the surrogate model for retraining. In this step, if the processing cost of the inference model changes due to a change in the query plan selection rate, it is necessary to filter historical data and select historical data similar to the current batch of data. Specifically, the similarity between the current batch of data and previously processed batches can be compared one by one. If the similarity exceeds a threshold, it is reused; otherwise, it is not reused. This is because if historical data is not similar to the current batch of data, directly reusing historical data will result in newly generated query plans that are not applicable to the current batch of data. By using historical data similar to the current batch of data to re-optimize the surrogate model, the retrained surrogate model can be made suitable for the current batch of data.

[0067] In this embodiment, by reusing historical data under different scenarios, the computational overhead of generating labeled data using machine learning models is reduced, and the retraining effect of the surrogate model is improved. The historical data reuse strategies under these two scenarios will be described below.

[0068] Furthermore, in step S203 above, if the amount of data in the target data is less than the amount of data in the current batch, then some data is read from the current batch and added to the target data, ensuring that the amount of data in the target data is not less than the amount of data in the current batch. This is because the retraining of the proxy model requires a certain amount of data. If there is not enough historical data after similarity judgment to retrain the proxy model, then new input data needs to be read. Therefore, a feasible method is to make the amount of data in the target data comparable to the amount of data required for the current query optimization. If the amount of reusable historical data is insufficient, it is supplemented by reading new data. This setting improves the reliability of the retraining process of the proxy model.

[0069] In one embodiment, when changes in system resources exceed a threshold, historical data is input into the proxy model for retraining. To further improve the efficiency of retraining, the proxy model that has already been retrained can be reused under certain circumstances. Figure 4 A flowchart is provided for a proxy model reuse method, such as... Figure 4 As shown, the process includes the following steps:

[0070] Step S301: Determine multiple precision combinations based on the target accuracy in the second query plan; wherein each precision combination contains the precision values ​​of multiple surrogate models.

[0071] While surrogate models accelerate query processing, they incur execution costs, resulting in some loss of accuracy. Each surrogate model has a different accuracy value. A query plan involves using multiple surrogate models, and the actual accuracy of the query plan is obtained by multiplying the accuracy values ​​of the multiple surrogate models. Setting a target accuracy is to ensure a certain level of query quality. In this step, based on the target accuracy given by the second query plan, multiple accuracy values ​​can be determined. These accuracy values ​​are then permuted and combined to obtain multiple accuracy combinations. The product of the accuracy values ​​in each accuracy combination equals or approximates the target accuracy. The second query plan then determines the search path. Based on the search path, the surrogate models are retrained using labeled data under different accuracy combinations, and the corresponding costs are calculated to find the accuracy combination with the lowest cost.

[0072] Step S302: Obtain a first precision combination obtained by combining the precision values ​​of multiple first surrogate models to be retrained, and determine whether there is a second precision combination with a common prefix to the first precision combination; wherein, the second precision combination is obtained by combining the precision values ​​of multiple second surrogate models that have been retrained, and the common prefix includes at least one identical precision.

[0073] In this step, the precision combinations that have been retrained or tried can be recorded (defined as the second precision combination). Before trying a new precision combination (defined as the first precision combination), it is necessary to find whether there is a second precision combination that has been tried and has a common prefix with the first precision combination. If so, the surrogate model corresponding to the precision value of the common prefix part (i.e., the second surrogate model) can be reused when retraining the first surrogate model to avoid repeated training.

[0074] Step S303: If it is determined that there is a second precision combination that has a common prefix with the first precision combination, the first surrogate model corresponding to the common prefix part is replaced with the corresponding second surrogate model, and the historical data is input into the remaining first surrogate models for retraining.

[0075] For example, suppose the precision values ​​of the first precision combination currently being tried are 0.98, 0.95, and 0.97, and the precision values ​​of the second precision combinations already tried are 0.98, 0.97, and 0.95. It can be observed that the first and second precision combinations share a common prefix of 0.98. Therefore, the first precision combination does not need to be retrained to obtain the first surrogate model corresponding to the first precision value; instead, the second surrogate model corresponding to the first precision value in the second precision combination can be directly reused. Of course, it is not necessarily only the first second surrogate model that can be directly reused; multiple models can be reused, depending on the length and number of common prefixes. This setup reduces redundancy in the surrogate model retraining method and further accelerates the optimization process.

[0076] In one embodiment, when a change in the detected statistical information exceeds a threshold, the method further includes:

[0077] Multiple candidate query plans are input into a deep learning model. The deep learning model estimates the execution time of the candidate query plans on the current batch of data, and the candidate query plan with the shortest execution time is selected as the second query plan.

[0078] In this embodiment, the multiple candidate query plans represent all possible query plans. A deep learning model can determine the candidate query plan with the shortest execution time from among these multiple plans. This shortest execution time is then used as the second query plan to retrain the proxy model, thereby limiting the size of the search space and accelerating the optimization process. The search space refers to the multiple search paths obtained by permuting and combining multiple machine learning models required for a query. The training process of the deep learning model is as follows:

[0079] Based on different search paths, different batches of data, and different system resources, multiple preset query plans are determined; the preset query plans are executed to obtain execution results; the execution results include at least one of the following: accuracy, selection rate, rejection rate, and time cost; training data is generated based on the preset query plans and execution results; and a deep learning model is trained based on the training data.

[0080] Among them, accuracy may include the accuracy of the proxy model and / or the overall accuracy of the query plan; selection rate may include the selection rate of the proxy model; rejection rate may include the rejection rate of the proxy model; time cost may include one or more of the time cost spent by the proxy model processing each piece of data, the time cost spent by the machine learning model processing each piece of data, or the overall time cost of the query plan.

[0081] Specifically, this embodiment can receive user-input query requests, determine the data stream, system resources, and search space to be processed based on the query requests, encode different search paths in the data stream, system resources, and search space, and input them into a trained deep learning model to obtain the estimated execution time for different search paths. Since the second query plan is the query plan with the shortest execution time among all possible candidate query plans, the order of the machine learning models determined by the second query plan is an approximately optimal order. Thus, the size of the search space is reduced, and the re-optimization process of the proxy model is accelerated.

[0082] This embodiment also provides a reasoning query re-optimization device for a proxy model, which is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. The terms "module," "unit," "subunit," etc., used below can refer to combinations of software and / or hardware that perform a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0083] Figure 5 This is a structural block diagram of the inference query re-optimization device for the agent-oriented model in this embodiment, as shown below. Figure 5 As shown, the device includes:

[0084] The query module is used to input the current batch of data into the inference model for processing based on the first query plan, so as to obtain the data to be queried; the inference model includes a proxy model and a machine learning model.

[0085] The monitoring module is used to monitor statistical information during the execution of the first query plan; the statistical information includes system resources or query plan selection rate.

[0086] The re-optimization module is used to retrain the proxy model based on the second query plan when the changes in the statistical information exceed the threshold. The historical data includes the data that was input into the inference model before the current batch of data and then labeled.

[0087] It should be noted that the above modules can be functional modules or program modules, and can be implemented through software or hardware. For modules implemented through hardware, the above modules can reside in the same processor; or the above modules can be located in different processors in any combination.

[0088] In one embodiment, the monitoring module is used to input historical data into the proxy model for retraining when it detects that changes in system resources exceed a threshold.

[0089] In one embodiment, the re-optimization module is used to select target data similar to the current batch of data from historical data when it detects that the change in the query plan selectability exceeds a threshold.

[0090] The target data is input into the surrogate model for retraining.

[0091] In one embodiment, the re-optimization module is used to: if the amount of data in the target data is less than the amount of data in the current batch, read some data from the current batch into the target data so that the amount of data in the target data is not less than the amount of data in the current batch.

[0092] In one embodiment, the re-optimization module is used to determine multiple precision combinations based on the target accuracy in the second query plan; wherein each precision combination contains precision values ​​of multiple surrogate models;

[0093] Obtain a first precision combination obtained by combining the precision values ​​of multiple first surrogate models to be retrained, and determine whether there is a second precision combination that has a common prefix with the first precision combination; wherein, the second precision combination is obtained by combining the precision values ​​of multiple second surrogate models that have been retrained, and the common prefix includes at least one identical precision;

[0094] If a second precision combination with a common prefix is ​​found to exist with the first precision combination, the first surrogate model corresponding to the common prefix part is replaced with the corresponding second surrogate model, and historical data is input into the remaining first surrogate models for retraining.

[0095] In one embodiment, the apparatus further includes a second query plan determination module, which is used to input multiple candidate query plans into a deep learning model, estimate the execution time of each candidate query plan on the current batch of data based on the deep learning model, and determine the candidate query plan with the shortest execution time as the second query plan.

[0096] In one embodiment, the apparatus further includes a deep learning model training module for determining multiple preset query plans based on different search paths, different batches of data, and different system resources; wherein the preset query plans are used to filter the corresponding batches of data;

[0097] Execute the preset query plan and obtain the execution results; the execution results include at least one of the following: accuracy, selection rate, rejection rate, and time cost;

[0098] Training data is generated based on the preset query plan and execution results;

[0099] Deep learning models are trained based on training data.

[0100] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated in this embodiment.

[0101] Furthermore, in conjunction with the agent-oriented inference query re-optimization method provided in the above embodiments, this embodiment can also provide a storage medium for implementation. The storage medium stores a computer program; when executed by a processor, the computer program performs the following steps:

[0102] Based on the first query plan, the current batch of data is input into the inference model for processing to obtain the data to be queried; the inference model includes a proxy model and a machine learning model.

[0103] During the execution of the first query plan, monitor statistical information, including system resources or query plan selection rate.

[0104] If the changes in the statistical information detected exceed the threshold, historical data is input into the surrogate model for retraining based on the second query plan; the historical data includes data that was input into the inference model before the current batch of data and then labeled.

[0105] In one embodiment, when the computer program is executed by a processor, it performs the following steps: upon detecting a change in statistical information exceeding a threshold, based on a second query plan, inputting historical data into the surrogate model for retraining, including:

[0106] If changes in system resources exceed a threshold, historical data is input into the proxy model for retraining.

[0107] In one embodiment, when the computer program is executed by a processor, it performs the following steps: upon detecting a change in statistical information exceeding a threshold, based on a second query plan, inputting historical data into the surrogate model for retraining, including:

[0108] If the change in the query plan selectability exceeds the threshold, select target data that is similar to the current batch of data from historical data.

[0109] The target data is input into the surrogate model for retraining.

[0110] In one embodiment, when the computer program is executed by a processor, it performs the following steps: inputting target data into the surrogate model for retraining, including:

[0111] If the target data volume is less than the current batch data volume, then some data is read from the current batch data and transferred to the target data volume, so that the target data volume is not less than the current batch data volume.

[0112] In one embodiment, when the computer program is executed by a processor, it performs the following steps: upon detecting changes in system resources exceeding a threshold, inputting historical data into the agent model for retraining, including:

[0113] Multiple precision combinations are determined based on the target accuracy in the second query plan; each precision combination contains the precision values ​​of multiple surrogate models.

[0114] Obtain a first precision combination obtained by combining the precision values ​​of multiple first surrogate models to be retrained, and determine whether there is a second precision combination that has a common prefix with the first precision combination; wherein, the second precision combination is obtained by combining the precision values ​​of multiple second surrogate models that have been retrained, and the common prefix includes at least one identical precision;

[0115] If a second precision combination with a common prefix is ​​found to exist with the first precision combination, the first surrogate model corresponding to the common prefix part is replaced with the corresponding second surrogate model, and historical data is input into the remaining first surrogate models for retraining.

[0116] In one embodiment, when the computer program is executed by a processor, it performs the following steps: If a change in statistical information is detected to exceed a threshold, the method further includes:

[0117] Multiple candidate query plans are input into a deep learning model. The deep learning model estimates the execution time of each candidate query plan on the current batch of data, and the candidate query plan with the shortest execution time is selected as the second query plan.

[0118] In one embodiment, when the computer program is executed by a processor, it performs the following steps: before inputting the current batch of data into the inference model, the method further includes:

[0119] Based on different search paths, different batches of data, and different system resources, multiple preset query plans are determined; among them, the preset query plans are used to filter the corresponding batches of data.

[0120] Execute the preset query plan and obtain the execution results; the execution results include at least one of the following: accuracy, selection rate, rejection rate, and time cost;

[0121] Training data is generated based on the preset query plan and execution results;

[0122] Deep learning models are trained based on training data.

[0123] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 6As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements a proxy-based inference query re-optimization method.

[0124] Those skilled in the art will understand that Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0125] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.

[0126] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0127] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0128] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A reasoning query re-optimization method for agent-based models, characterized in that, include: Based on the first query plan, the current batch of data is input into the inference model for processing to obtain the data to be queried; wherein, the inference model includes a proxy model and a machine learning model; During the execution of the first query plan, statistical information is monitored; wherein, the statistical information includes system resources or query plan selection rate; If the change in the statistical information exceeds the threshold, historical data is input into the agent model for retraining based on the second query plan; wherein, the historical data includes data that was input into the inference model before the current batch of data and then labeled; If the changes in the statistical information exceed a threshold, based on the second query plan, historical data is input into the proxy model for retraining, including: Multiple precision combinations are determined based on the target accuracy in the second query plan; wherein each precision combination includes multiple precision values ​​of the proxy model; A first precision combination is obtained by combining the precision values ​​of multiple first surrogate models to be retrained, and it is determined whether there is a second precision combination that has a common prefix with the first precision combination; wherein, the second precision combination is obtained by combining the precision values ​​of multiple second surrogate models that have been retrained, and the common prefix includes at least one identical precision; If it is determined that there is a second precision combination that has a common prefix with the first precision combination, the first proxy model corresponding to the common prefix part is replaced with the corresponding second proxy model, and the historical data is input into the remaining first proxy models for retraining.

2. The reasoning query re-optimization method for agent-based models according to claim 1, characterized in that, If the changes in the statistical information exceed a threshold, based on the second query plan, historical data is input into the proxy model for retraining, including: If the changes in the system resources exceed the threshold, the historical data is input into the agent model for retraining.

3. The reasoning query re-optimization method for agent-based models according to claim 1, characterized in that, If the changes in the statistical information exceed a threshold, based on the second query plan, historical data is input into the proxy model for retraining, including: If the change in the query plan selection rate exceeds a threshold, target data similar to the current batch data is selected from the historical data. The target data is input into the proxy model for retraining.

4. The reasoning query re-optimization method for agent-based models according to claim 3, characterized in that, The target data is input into the proxy model for retraining, including: If the amount of data in the target data is less than the amount of data in the current batch, then some data is read from the current batch and added to the target data, so that the amount of data in the target data is not less than the amount of data in the current batch.

5. The reasoning query re-optimization method for agent-based models according to claim 1, characterized in that, If the change in the statistical information is detected to exceed a threshold, the method further includes: Multiple candidate query plans are input into a deep learning model. The execution time of each candidate query plan on the current batch of data is estimated based on the deep learning model, and the candidate query plan with the shortest execution time is determined as the second query plan.

6. The reasoning query re-optimization method for agent-based models according to claim 5, characterized in that, Before inputting the current batch of data into the inference model, the method further includes: Based on different search paths, different batches of data, and different system resources, multiple preset query plans are determined. Execute the preset query plan and obtain the execution results; wherein the execution results include at least one of the following: accuracy, selection rate, rejection rate, and time cost; Training data is generated based on the preset query plan and the execution results; The deep learning model is trained based on the training data.

7. A reasoning query re-optimization device for a proxy model, characterized in that, The device includes: The query module is used to input the current batch of data into the inference model for processing based on the first query plan, so as to obtain the data to be queried; wherein, the inference model includes a proxy model and a machine learning model; The monitoring module is used to monitor statistical information during the execution of the first query plan; wherein the statistical information includes system resources or query plan selection rate; The re-optimization module is used to input historical data into the proxy model for retraining based on the second query plan when the changes in the statistical information exceed a threshold; wherein, the historical data includes data that was input into the inference model before the current batch of data and then labeled; If the changes in the statistical information exceed a threshold, based on the second query plan, historical data is input into the proxy model for retraining, including: Multiple precision combinations are determined based on the target accuracy in the second query plan; wherein each precision combination includes multiple precision values ​​of the proxy model; A first precision combination is obtained by combining the precision values ​​of multiple first surrogate models to be retrained, and it is determined whether there is a second precision combination that has a common prefix with the first precision combination; wherein, the second precision combination is obtained by combining the precision values ​​of multiple second surrogate models that have been retrained, and the common prefix includes at least one identical precision; If it is determined that there is a second precision combination that has a common prefix with the first precision combination, the first proxy model corresponding to the common prefix part is replaced with the corresponding second proxy model, and the historical data is input into the remaining first proxy models for retraining.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Inference query optimization method and device based on proxy model rearrangement technology

    CN116842060A

  • Database query optimization method based on exploration value and query cost

    CN117520385A

  • Using query logs to optimize execution of parametric queries

    US20220414099A1