Deep learning model selection method suitable for relational database
By constructing a performance matrix and objective function, and combining a pre-trained model and a regressor, the deep learning model within a relational database is automatically selected. This solves the problems of high user knowledge requirements and high time complexity in traditional methods, and achieves low-difficulty, efficient model selection and accurate inference.
Patent Information
- Application Number
- CN202510983946.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-17
- Publication Date
- 2025-11-11
AI Technical Summary
Traditional database inference frameworks require users to have a certain level of AI knowledge, and the time complexity increases linearly when processing a large number of models, resulting in high difficulty for users and system performance bottlenecks.
By constructing a performance matrix and objective function, and utilizing pre-trained large-scale visual models and random forest regressors, the most suitable deep learning model is automatically selected, and users only need to operate through SQL statements.
It reduces the difficulty of use for users, improves the accuracy of model selection and the reliability of inference results, reduces errors caused by improper model selection, and improves system performance.
Smart Images

Figure CN120930833A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of database and artificial intelligence combination, and specifically relates to a method for selecting deep learning models in relational databases. Background Technology
[0002] In recent years, with the rapid development of artificial intelligence technology, the industry has made significant progress in in-database inference. The core idea of in-database inference is to directly embed the inference process of machine learning models into the database system, enabling users to perform model inference using familiar SQL statements or database operations, thereby reducing data movement and inter-system interaction overhead. This technological trend not only improves inference efficiency but also simplifies user operations. However, despite the success of in-database inference frameworks in simplifying user operations, traditional methods still face some challenges and limitations.
[0003] Traditional in-database inference frameworks typically require users to specify a model within the database for inference. While this approach allows users to perform inference using simple SQL statements, it still necessitates a certain level of AI knowledge to select appropriate models and parameters. For example, users need to understand the applicable scenarios for different models, their input and output formats, and how to invoke the model via SQL statements. This technical requirement increases the difficulty of use, especially for non-professional users or business personnel, and may become an obstacle to using in-database inference.
[0004] Furthermore, traditional methods typically estimate matching scores during model matching and inference by leveraging the correlation between labels and forward features. While intuitive and easy to implement, this approach suffers from linearly increasing time complexity with the number of models. When the database contains a large number of models, the inference process can become extremely time-consuming, impacting the overall system performance. This linearly increasing time complexity can become a bottleneck, especially in scenarios requiring large-scale datasets or real-time inference. Summary of the Invention
[0005] To address the problems existing in the background art, this invention provides a method for selecting deep learning models within relational databases, solving the technical problem of the lack of a database-based deep learning model selection method with low time overhead and ease of use for users.
[0006] The technical solution adopted in this invention includes:
[0007] I. A method for selecting deep learning models within relational databases:
[0008] S1. Obtain the performance weights of each deep learning model in the deep learning model library on various historical visual tasks, and construct a performance matrix based on the performance weights of each deep learning model on various historical visual tasks.
[0009] S2. Construct the objective function. Based on the objective function and the performance matrix, obtain the model embedding matrix and the historical visual task embedding matrix respectively. Extract features from the historical visual tasks to obtain the forward features of the historical visual tasks. Train the constructed regressor based on the forward features of all historical tasks and the historical visual task embedding matrix to obtain the trained regressor.
[0010] S3. Real-time acquisition of the target visual task, feature extraction of the target visual task, input of the feature extraction results into the trained regressor for processing, and acquisition of the transfer weight of each deep learning model on the target visual task based on the regressor processing results and the model embedding matrix. The deep learning model corresponding to the largest transfer weight is the final model selected for the target visual task.
[0011] Furthermore, users can directly input the target vision task into the final selected model for processing using simple SQL statements within a relational database, and obtain the processing results of the target vision task.
[0012] Step S1 specifically involves:
[0013] S11. Obtain several deep learning models from a relational database and aggregate all deep learning models to build a deep learning model library.
[0014] S12. Obtain several historical visual tasks from the relational database, process each historical visual task on all deep learning models, and obtain the performance weight of each deep learning model on each historical visual task.
[0015] The performance weights are the evaluation metrics obtained after the deep learning model processes historical visual tasks, used to evaluate the deep learning model.
[0016] S13. Construct the performance matrix of the deep learning model based on the performance weights of each deep learning model on each historical vision task.
[0017] Step S2 specifically involves:
[0018] S21. Construct the objective function, and perform matrix decomposition on the performance matrix according to the objective function to obtain the model embedding matrix and the historical visual task embedding matrix for each historical visual task.
[0019] S22. Use a pre-trained large-scale visual model to extract features from historical visual tasks to obtain the forward features of each historical visual task.
[0020] S23. Using the forward features as input and the historical visual task embedding matrix as output, construct the data pair for each historical visual task. Summarize all the data pairs for historical visual tasks to obtain the historical visual task dataset.
[0021] S24. Using a random forest as the regressor, the regressor is trained based on the historical visual task dataset to obtain the trained regressor.
[0022] The large-scale visual model pre-trained in step S22 adopts a contrastive language-image pre-trained model.
[0023] The objective function is set according to the following formula:
[0024]
[0025] Where min represents taking the minimum; V represents the performance matrix; W represents the model embedding matrix; and H represents the historical visual task embedding matrix. This represents the transpose of the historical visual task embedding matrix; Let f(x) denote the square of the Frobenius norm of the matrix.
[0026] Step S3 specifically involves:
[0027] S31. Acquire the target visual task in real time, and use a pre-trained large-scale visual model to extract features of the target visual task to obtain the forward features of the target visual task.
[0028] S32. Input the forward features of the target visual task into the trained regressor for processing to obtain the target visual task embedding matrix.
[0029] S33. Multiply the target visual task embedding matrix and the model embedding matrix to obtain the transfer matrix of the deep learning model on the target visual task.
[0030] S34. Obtain the transfer weights of each deep learning model on the target vision task based on the transfer matrix.
[0031] S35. Sort all transfer weights and select the deep learning model with the largest transfer weight as the final model to be selected for the target vision task.
[0032] The large-scale visual model pre-trained in step S31 adopts a contrastive language-image pre-trained model.
[0033] II. A computer device, comprising 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 above-described method.
[0034] 3. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the above-described method.
[0035] IV. A computer program product comprising a computer program / instructions that, when executed by a processor, implement the steps of the above-described method.
[0036] The beneficial effects of this invention are:
[0037] 1. Through automated model selection methods, users do not need to delve into the details of AI models. They can complete the reasoning of complex tasks simply by using simple SQL statements, which greatly reduces the difficulty of use and the learning cost for users.
[0038] 2. By more accurately matching tasks and models, this method can select the most suitable model for inference based on the specific needs of the task, thereby improving the accuracy and reliability of the inference results. Compared with traditional methods, this method can better adapt to the complexity of different tasks and reduce errors caused by inappropriate model selection. Attached Figure Description
[0039] Figure 1 This is a flowchart of the method for obtaining the trained regressor in the present invention.
[0040] Figure 2 This is a flowchart illustrating the processing of the target vision task in the method of the present invention. Detailed Implementation
[0041] The present invention will now be described in more detail with reference to the accompanying drawings and embodiments. However, the present invention is not limited thereto. For those skilled in the art, several improvements and modifications can be made without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention. Contents not described in detail in this specification are prior art known to those skilled in the art.
[0042] This embodiment describes a method for selecting deep learning models within relational databases, including the following steps:
[0043] like Figure 1 As shown, S1, obtain the performance weights of each deep learning model in the deep learning model library on each historical vision task, and construct a performance matrix based on the performance weights of each deep learning model on each historical vision task.
[0044] S11. Obtain several deep learning models from a relational database and aggregate all deep learning models to build a deep learning model library.
[0045] S12. Obtain several historical visual tasks from the relational database, process each historical visual task on all deep learning models, and obtain the performance weight of each deep learning model on each historical visual task.
[0046] Performance weights are evaluation metrics obtained after the deep learning model has processed historical visual tasks, used to assess the deep learning model. These metrics include accuracy, precision, recall, inference time, computational resource consumption, and model robustness. Each evaluation metric can be one of these metrics or a combination of several of them.
[0047] S13. Construct the performance matrix of the deep learning model based on the performance weights of each deep learning model on each historical vision task.
[0048] like Figure 1 As shown, S2, construct the objective function, obtain the model embedding matrix and the historical visual task embedding matrix according to the objective function and the performance matrix respectively, extract features from the historical visual task to obtain the forward features of the historical visual task, train the constructed regressor according to the forward features of all historical tasks and the historical visual task embedding matrix, and obtain the trained regressor.
[0049] S21. Construct the objective function, and perform matrix decomposition on the performance matrix according to the objective function to obtain the model embedding matrix and the historical visual task embedding matrix for each historical visual task.
[0050] The objective function is set according to the following formula:
[0051]
[0052] Wherein, min means taking the minimum; V represents the performance matrix, which is an M×N matrix, where M represents the number of deep learning models and N represents the number of historical visual tasks; W represents the model embedding matrix, which is an M×k matrix, where M represents the number of deep learning models and k represents the preset dimension; H represents the historical visual task embedding matrix, which is an N×k matrix, where N represents the number of historical visual tasks and k is the same dimension as k in the model embedding matrix W. This represents the transpose of the historical visual task embedding matrix; This represents the square of the Frobenius norm of the matrix.
[0053] In practical implementation, matrix element v ij ∈V represents the performance weight of the i-th model on the j-th historical visual task. For example, in an image classification task scenario, if there are 10 different image classification models (M=10) and 20 different historical image classification tasks (N=20), then V is a 10×20 matrix, v3,5 This represents the performance weight (such as classification accuracy) of the third model on the fifth historical visual task.
[0054] S22. Use a pre-trained large-scale visual model to extract features from historical visual tasks to obtain the forward features of each historical visual task.
[0055] The pre-trained large-scale visual model employs the Contrastive Language-Image Pre-trained Model (CLIP model).
[0056] S23. Using the forward features as input and the historical visual task embedding matrix as output, construct the data pair for each historical visual task. Summarize all the data pairs for historical visual tasks to obtain the historical visual task dataset.
[0057] S24. Using a random forest as the regressor, the regressor is trained based on the historical visual task dataset to obtain the trained regressor.
[0058] like Figure 2 As shown, S3 acquires the target visual task in real time, extracts features from the target visual task in the relational database, inputs the feature extraction results into the trained regressor for processing, and obtains the transfer weight of each deep learning model on the target visual task based on the regressor processing results and the model embedding matrix. The deep learning model corresponding to the largest transfer weight is the final model selected for the target visual task.
[0059] S31. Acquire the target visual task in real time, and use a pre-trained large-scale visual model to extract features of the target visual task to obtain the forward features of the target visual task.
[0060] The pre-trained large-scale visual model employs a contrastive language-image pretraining model.
[0061] S32. Input the forward features of the target visual task into the trained regressor for processing to obtain the target visual task embedding matrix.
[0062] S33. Multiply the target vision task embedding matrix and the model embedding matrix to obtain the total transfer matrix of all deep learning models on the target vision task.
[0063] In practice, each element in the total transfer matrix of all deep learning models on the target vision task represents the transfer weight of a deep learning model on the target vision task.
[0064] S34. Obtain the transfer weights of each deep learning model on the target vision task based on the total transfer matrix.
[0065] S35. Sort all transfer weights and select the deep learning model with the largest transfer weight as the final model to be selected for the target vision task.
[0066] Furthermore, users can directly input the target vision task into the final selected model within a relational database using simple SQL statements to obtain the processing results for the target vision task. This greatly reduces the difficulty of use and the learning cost for users.
[0067] This invention improves the accuracy and reliability of inference results by more accurately matching tasks and models, selecting the most suitable model for inference based on the specific needs of the task. Compared to traditional methods, this approach better adapts to the complexity of different tasks and reduces errors caused by inappropriate model selection.
[0068] The above embodiments are merely preferred embodiments provided to fully illustrate the present invention, and the scope of protection of the present invention is not limited thereto. Equivalent substitutions or modifications made by those skilled in the art based on the present invention are all within the scope of protection of the present invention. The scope of protection of the present invention is defined by the claims.
Claims
1. A method for selecting deep learning models within relational databases, characterized in that, Includes the following steps: S1. Obtain the performance weights of each deep learning model in the deep learning model library on each historical visual task, and construct a performance matrix based on the performance weights of each deep learning model on each historical visual task. S2. Construct the objective function, obtain the model embedding matrix and the historical visual task embedding matrix based on the objective function and the performance matrix, respectively, extract features from the historical visual tasks to obtain the forward features of the historical visual tasks, train the constructed regressor based on the forward features of all historical tasks and the historical visual task embedding matrix, and obtain the trained regressor. S3. Real-time acquisition of the target visual task, feature extraction of the target visual task, input of the feature extraction results into the trained regressor for processing, and acquisition of the transfer weight of each deep learning model on the target visual task based on the regressor processing results and the model embedding matrix. The deep learning model corresponding to the largest transfer weight is the final model selected for the target visual task.
2. The method for selecting deep learning models within relational databases according to claim 1, characterized in that, Step S1 specifically involves: S11. Obtain several deep learning models from a relational database and aggregate all deep learning models to build a deep learning model library; S12. Obtain several historical visual tasks from the relational database, process each historical visual task on all deep learning models, and obtain the performance weight of each deep learning model on each historical visual task. The performance weight is the evaluation index value obtained after the deep learning model processes historical visual tasks to evaluate the deep learning model; S13. Construct the performance matrix of the deep learning model based on the performance weights of each deep learning model on each historical vision task.
3. The method for selecting deep learning models within relational databases according to claim 1, characterized in that, Step S2 specifically involves: S21. Construct the objective function, and perform matrix decomposition on the performance matrix according to the objective function to obtain the model embedding matrix and the historical visual task embedding matrix for each historical visual task. S22. Use a pre-trained large-scale visual model to extract features from historical visual tasks to obtain the forward features of each historical visual task. S23. Using the forward features as input and the historical visual task embedding matrix as output, construct the data pair for each historical visual task. Summarize the data pairs of all historical visual tasks to obtain the historical visual task dataset. S24. Using a random forest as the regressor, the regressor is trained based on the historical visual task dataset to obtain the trained regressor.
4. The method for selecting deep learning models within relational databases according to claim 3, characterized in that: The large-scale visual model pre-trained in step S22 adopts a contrastive language-image pre-trained model.
5. The method for selecting deep learning models within relational databases according to claim 1, characterized in that: The objective function is set according to the following formula: Where min represents taking the minimum; V represents the performance matrix; W represents the model embedding matrix; H represents the historical visual task embedding matrix; H T This represents the transpose of the historical visual task embedding matrix; Let f(x) denote the square of the Frobenius norm of the matrix.
6. The method for selecting deep learning models within relational databases according to claim 1, characterized in that, Step S3 specifically involves: S31. Acquire the target visual task in real time, and use a pre-trained large-scale visual model to extract features of the target visual task to obtain the forward features of the target visual task. S32. Input the forward features of the target visual task into the trained regressor for processing to obtain the target visual task embedding matrix. S33. Multiply the target visual task embedding matrix and the model embedding matrix to obtain the transfer matrix of the deep learning model on the target visual task; S34. Obtain the transfer weights of each deep learning model on the target vision task based on the transfer matrix; S35. Sort all transfer weights and select the deep learning model with the largest transfer weight as the final model to be selected for the target vision task.
7. The method for selecting deep learning models within relational databases according to claim 6, characterized in that: The large visual model pre-trained in step S31 adopts a contrastive language-image pre-trained model.
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 7.
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 7.
10. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method according to any one of claims 1 to 7.