Storage method and device suitable for deep learning model in relational database

CN118427196BActive Publication Date: 2026-10-13INSTITUTE OF COMPUTING INNOVATION ZHEJIANG UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410580754.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-11
Publication Date
2026-10-13
Estimated Expiration
2044-05-11

AI Technical Summary

Technical Problem

[0002]近年来,工业界在数据库内推理方面取得了显著进步,不少数据库内推理框架被推出,对于模型的存储普遍将整个模型存储到数据库中,或将模型在文件系统中的路径保存在数据库中,这导致了空间的严重浪费,对于深度学习模型来说大部分模型都是在一些开源的效果较好的基础模型基础上重新训练,比如resnet、vgg、alexnet等,数据库内推理框架亟待一种使用更少存储资源的模型存储解决方案

Benefits of technology

[0028]本发明通过模型结构与参数的分离存储,模型结构使用复用的基础模型结构,只需存储参数即可实现对模型的存储,实现了深度学习模型在数据库内的压缩存储;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118427196B_ABST
    Figure CN118427196B_ABST
Patent Text Reader

Abstract

The application discloses a storage method and device suitable for a deep learning model in a relational database. The application is based on a relational database vector storage technology and a deep learning framework, and is a method capable of storing model parameters in a database when importing a model and merging the model parameters in the database when using the model. The method internally stores multiple basic models. When a new model is imported, the basic model can be specified, the model is read, and the model layer name and the model parameters are saved to a model parameter table; when the model is used, the basic model information of the model is acquired according to the model parameter table, the basic model is loaded, and the layer name and the layer parameters recorded in the model parameter table are read, so that the layer parameters are set back to the basic model, and the model is restored. The application only needs to record the layer parameters for a new model based on the basic model, and does not need to store model structure information, and the model storage method in the database can significantly reduce the storage capacity occupied by the model in the database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a storage method for deep learning models within a database, specifically a storage method for deep learning models within a relational database, in the field of database and artificial intelligence integration. Background Technology

[0002] In recent years, the industry has made significant progress in in-database inference, and many in-database inference frameworks have been launched. The common practice for storing models is to store the entire model in the database or save the model's path in the file system in the database. This leads to serious waste of space. For deep learning models, most models are retrained on some open-source basic models with good performance, such as ResNet, VGG, and AlexNet. In-database inference frameworks urgently need a model storage solution that uses less storage resources.

[0003] The existing method for compressing and storing models in the library is to directly quantize and compress the deep learning model. After compression, the parameters of each layer of the model will suffer from a loss of precision, which will significantly affect the performance of the model. Summary of the Invention

[0004] To address the problems and needs in the background art, the present invention aims to provide a storage method suitable for deep learning models within relational databases, offering a space-saving solution for storing models within databases.

[0005] The technical solution of the present invention is as follows:

[0006] I. A storage method for deep learning models within relational databases

[0007] When modifying or creating a deep learning model in a relational database, the imported model is obtained based on the input SQL statement. The layer structure and layer name of the imported model are extracted using the deep learning framework. The layer parameters are extracted based on the layer name of the imported model, converted, and then saved into the database.

[0008] When loading a deep learning model from a relational database, the model name is obtained based on the input SQL statement. The parameters of each layer in the model name in the database are then converted and restored to the deep learning framework until the model is loaded.

[0009] When modifying or creating a deep learning model within a relational database, the imported model is obtained based on the input SQL statement. The layer structure and layer names of the imported model are then extracted using the deep learning framework, including:

[0010] The base model name of the imported model is obtained based on the input SQL statement. If the base model exists in the database, it is loaded through the deep learning framework to obtain the layer structure and layer name of the base model, as well as the layer structure and layer name of the imported model. If the layer structure and layer name of the base model and the imported model match, the layer parameters are extracted based on the layer name of the base model. If they do not match, the layer parameters are extracted based on the layer name of the imported model.

[0011] For fully connected layers, when the layer name matches but the layer structure does not match, the layer parameters can be extracted directly based on the layer name.

[0012] When modifying or creating a deep learning model in a relational database, the path of the modified or created model on the file system is obtained based on the input SQL statement. It is then determined whether the model file exists on that path. If it does not exist, a path error message is returned.

[0013] If the layer structure and layer name of the base model do not match the layer structure and layer name of the imported model, a prompt indicating that the base model does not exist will be returned.

[0014] The process of extracting layer parameters based on the layer names of the imported model, converting them, and then saving them to the database includes:

[0015] Extract layer parameters sequentially according to the layer name of the imported model, convert the tensor data type layer parameters to vector data type in the database, and then insert the model name, layer name and corresponding converted layer parameters into the model parameter table in the database.

[0016] When loading a deep learning model from a relational database, the model name is obtained based on the input SQL statement. The parameters of each layer within the model name in the database are then converted and restored to the deep learning framework until the model is loaded. This process includes:

[0017] Based on the model name in the input SQL statement, the base model in the model parameter table is found and loaded. The name of each layer in the base model is obtained. Based on the name of each layer and the model name, the vector parameter of that layer is found in the model parameter table. The vector parameter is then converted into the tensor data type of the deep learning framework and set back into the corresponding layer of the model. The process is repeated for each layer in the base model until all layer parameters are restored to the base model.

[0018] II. A storage device suitable for deep learning models within relational databases

[0019] Modify or create a deep learning model module within a relational database to obtain the imported model based on the input SQL statement, extract the layer structure and layer name of the imported model using a deep learning framework, extract layer parameters based on the layer name of the imported model, convert them, and save them to the database.

[0020] The module for loading deep learning models from relational databases is used to obtain the model name based on the input SQL statement, convert the parameters of each layer in the model name in the database and restore them to the deep learning framework until the model is loaded.

[0021] III. A computer device

[0022] The device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the method.

[0023] IV. A computer-readable storage medium

[0024] It stores a computer program that, when executed by a processor, implements the steps of the method.

[0025] V. A computer program product

[0026] The product includes a computer program / instructions that, when executed by a processor, implement the steps of the method.

[0027] The beneficial effects of this invention are as follows:

[0028] This invention separates the storage of model structure and parameters. The model structure uses a reused basic model structure, and only the parameters need to be stored to store the model, thus achieving compressed storage of deep learning models in the database.

[0029] This invention merges the parameters used in deep learning models. When using a model, the base model is loaded first, and then the parameters of each layer are set back into the base model, which greatly reduces the storage resources used by the model in the database. Attached Figure Description

[0030] Figure 1 This is a schematic diagram of the model parameter table in an embodiment of the present invention.

[0031] Figure 2 This is the model parameter extraction process of the present invention.

[0032] Figure 3 This is the model loading process of the present invention. Detailed Implementation

[0033] To make the technical solutions and advantages of the present invention clearer, the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.

[0034] In this embodiment, the relational database used is PostgreSQL. A model parameter table is added within PostgreSQL, and the database includes various basic deep learning model structures such as ResNet18, ResNet50, and AlexNet. Keywords have been added to the relational database, such as the `CREATE MODEL` keyword for creating models, the `PATH` keyword for declaring model paths, the `BASEMODEL` keyword for declaring base model names, and the `DESCRIPTION` keyword for adding model description information. The `BASEMODEL` keyword identifies the base model in SQL. After receiving the model address and base model name, the layer names, layer parameter dimensions, and other information of the two models need to be identified and verified.

[0035] The storage method of the present invention includes:

[0036] When modifying or creating a deep learning model in PostgreSQL, the imported model is obtained based on the input SQL statement. The layer structure and layer name of the imported model are extracted by combining the deep learning framework. The layer parameters are extracted based on the layer name of the imported model, converted and saved to the database.

[0037] When loading a deep learning model in PostgreSQL, the model name is obtained based on the input SQL statement. The parameters of each layer in the model name in the database are converted and restored to the deep learning framework until the model is loaded.

[0038] When modifying or creating a deep learning model within PostgreSQL, the imported model is obtained based on the input SQL statement. Then, the layer structure and layer names of the imported model are extracted using the deep learning framework, including:

[0039] like Figure 2As shown, the system retrieves the base model name of the imported model based on the input SQL statement. If the base model (such as ResNet18, ResNet50, AlexNet, etc.) exists in the database, it is loaded through the deep learning framework, and its layer structure and layer names are obtained. Similarly, the imported model's layer structure and layer names are also retrieved after loading through the deep learning framework. If the base model does not exist in the database, the corresponding error message is returned. If the layer structure and layer names of the base model and the imported model completely match, the layer parameters are extracted based on the base model's layer names. For fully connected layers (FC layers), layer parameters can be extracted based on the layer name even if the layer names match but the layer structures do not. If they do not match, the layer parameters are extracted based on the imported model's layer names, and the imported model is also used as the base model, meaning the entire model is stored on the file system.

[0040] When modifying or creating a deep learning model in PostgreSQL, the system obtains the path of the modified or created model on the file system based on the input SQL statement, checks whether the model file exists on that path, and returns a path error message if it does not exist.

[0041] If the layer structure and layer name of the base model do not match the layer structure and layer name of the imported model, a message indicating that the base model does not exist will be returned.

[0042] Based on the layer names of the imported model, layer parameters are extracted, transformed, and saved to the database, including:

[0043] like Figure 3 As shown, layer parameters are extracted sequentially according to the layer names of the imported model. Tensor data type layer parameters are converted to vector data type in the database. Then, the model name, all layer names, and the corresponding converted layer parameters are inserted into the model parameter table in the database. The model parameter table includes model name, layer name, layer number, and layer parameters, such as... Figure 1 As shown.

[0044] When loading a deep learning model from PostgreSQL, the model name is obtained based on the input SQL statement. The parameters of each layer within that model name in the database are then converted and restored to the deep learning framework until the model is successfully loaded. This process includes:

[0045] Based on the model name in the input SQL statement, the base model in the model parameter table is located and loaded. The name of each layer in the base model is obtained. Based on the name of each layer and the model name, the vector parameters of that layer are located in the model parameter table. The vector parameters are then converted into tensor data types of the deep learning framework and set back into the corresponding layer of the model. The process is repeated for each layer in the base model until all layer parameters are restored to the base model. This model can then be used for subsequent inference operations.

[0046] This invention enables the storage of deep learning models within a database. Utilizing a built-in integrated deep learning framework and the database's vector types, it extracts and stores deep learning model parameters, achieving compressed storage of the deep learning model within the database. Specifically, it stores the layer name, layer index, and layer parameters of each layer in a model parameter table. Since this method only stores the model's parameter information and not its structural information, it significantly reduces the storage space required to store the model.

[0047] On one hand, a storage device suitable for deep learning models within PostgreSQL includes:

[0048] Modify or create a deep learning model module within PostgreSQL to obtain the imported model based on the input SQL statement, extract the layer structure and layer name of the imported model using a deep learning framework, extract layer parameters based on the layer name of the imported model, and save them to the database after conversion.

[0049] The deep learning model module within PostgreSQL is used to retrieve the model name based on the input SQL statement, convert the parameters of each layer in the model name in the database, and restore them to the deep learning framework until the model is loaded.

[0050] On the one hand, a computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of a method.

[0051] On the one hand, there is a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of a method.

[0052] On the one hand, a computer program product includes a computer program / instructions that, when executed by a processor, implement the steps of a method.

[0053] Finally, it should be noted that the above embodiments and descriptions are only used to illustrate the technical solutions of the present invention and not to limit it. Those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the disclosure of the technical solutions of the present invention, and all such modifications and substitutions should be covered within the protection scope of the claims of the present invention.

Claims

1. A method for storing deep learning models within a relational database, characterized in that, include: When modifying or creating a deep learning model in a relational database, the imported model is obtained based on the input SQL statement. The layer structure and layer name of the imported model are extracted using the deep learning framework. The layer parameters are extracted based on the layer name of the imported model, converted, and then saved into the database. When modifying or creating a deep learning model within a relational database, the imported model is obtained based on the input SQL statement. The layer structure and layer names of the imported model are then extracted using the deep learning framework, including: The base model name of the imported model is obtained based on the input SQL statement. If the base model exists in the database, it is loaded through the deep learning framework to obtain the layer structure and layer name of the base model, and the layer structure and layer name of the imported model are also obtained after loading the imported model through the deep learning framework. If the layer structure and layer name of the base model and the imported model match, the layer parameters are extracted based on the layer name of the base model. If they do not match, the layer parameters are extracted based on the layer name of the imported model. When loading a deep learning model from a relational database, the model name is obtained based on the input SQL statement. The parameters of each layer in the model name in the database are converted and restored to the deep learning framework until the model is loaded. When loading a deep learning model from a relational database, the model name is obtained based on the input SQL statement. The parameters of each layer within the model name in the database are then converted and restored to the deep learning framework until the model is loaded. This process includes: Based on the model name in the input SQL statement, the base model in the model parameter table is found and loaded. The name of each layer in the base model is obtained. Based on the name of each layer and the model name, the vector parameter of that layer is found in the model parameter table. The vector parameter is then converted into the tensor data type of the deep learning framework and set back into the corresponding layer of the model. The process is repeated for each layer in the base model until all layer parameters are restored to the base model.

2. The method for storing deep learning models within a relational database according to claim 1, characterized in that, When modifying or creating a deep learning model in a relational database, the path of the modified or created model on the file system is obtained based on the input SQL statement. It is then determined whether the model file exists on that path. If it does not exist, a path error message is returned.

3. The method for storing deep learning models within a relational database according to claim 1, characterized in that, If the layer structure and layer name of the base model do not match the layer structure and layer name of the imported model, a prompt indicating that the base model does not exist will be returned.

4. The method for storing deep learning models within a relational database according to claim 1, characterized in that, The process of extracting layer parameters based on the layer names of the imported model, converting them, and then saving them to the database includes: Extract layer parameters sequentially according to the layer name of the imported model, convert the tensor data type layer parameters to vector data type in the database, and then insert the model name, layer name and corresponding converted layer parameters into the model parameter table in the database.

5. A storage device suitable for deep learning models within a relational database, characterized in that, include: Modify or create a deep learning model module within a relational database to obtain the imported model based on the input SQL statement, extract the layer structure and layer name of the imported model using a deep learning framework, extract layer parameters based on the layer name of the imported model, convert them, and save them to the database. Specifically, it includes: The base model name of the imported model is obtained based on the input SQL statement. If the base model exists in the database, it is loaded through the deep learning framework to obtain the layer structure and layer name of the base model, and the layer structure and layer name of the imported model are also obtained after loading the imported model through the deep learning framework. If the layer structure and layer name of the base model and the imported model match, the layer parameters are extracted based on the layer name of the base model. If they do not match, the layer parameters are extracted based on the layer name of the imported model. The module for loading deep learning models from relational databases is used to obtain the model name based on the input SQL statement, convert and restore the parameters of each layer of the model name in the database to the deep learning framework, until the model is loaded. Specifically, it includes: Based on the model name in the input SQL statement, the base model in the model parameter table is found and loaded. The name of each layer in the base model is obtained. Based on the name of each layer and the model name, the vector parameter of that layer is found in the model parameter table. The vector parameter is then converted into the tensor data type of the deep learning framework and set back into the corresponding layer of the model. The process is repeated for each layer in the base model until all layer parameters are restored to the base model.

6. 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 4.

7. 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 4.

8. 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 described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Query statement generation method, data query method and generative model training method

    CN116303558A

  • Supporting Synergistic and Retrofittable Graph Queries Inside a Relational Database

    US20210056104A1