Data collaborative query method and device, computer equipment and storage medium
By determining the model parameters and calculating diagrams based on the preset execution rules in the database, automatically realize data collaborative query, solve the problem of high labor costs and low efficiency in the existing technology, and achieve efficient Data query process.
Patent Information
- Application Number
- CN202411296629.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2025-01-24
AI Technical Summary
In the prior art, the data collaborative query method requires users to manually parse deep learning models and write a large amount of SQL, resulting in high labor costs, cumbersome query process, long time and low efficiency.
By obtaining the query information, determine the query relationship operator and the target model operator, and preset the execution rules in the database. The model parameters and model calculation diagrams based on the target model determine the execution rules to automatically implement the data query process.
The labor cost has been reduced, the data query time is shortened, the data query efficiency is significantly improved, and the tedious process of manually parsing the model and writing SQL is avoided.
Smart Images

Figure CN119357234A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data collaborative query method, device, computer equipment and storage medium. Background Art
[0002] In current data analysis technologies, data analysts tend to use deep learning (DL) technology to process data and extract valuable information based on the data analysis capabilities of conventional databases. Collaborative query is a complex query that combines traditional database relational operations and inference of models within the database.
[0003] To solve the collaborative query problem, traditional technologies usually use tightly integrated methods to implement in-database model inference. This method directly integrates the inference process of the deep learning model into the database system. However, the data collaborative query method in traditional technologies requires users to manually parse the deep learning model and manually write a large amount of SQL (Structured Query Language) to implement the model execution process and then perform data query in the database. Obviously, the query method in traditional technologies consumes high labor costs, resulting in a cumbersome data collaborative query process, a long query time, and low data query efficiency. Summary of the invention
[0004] Based on this, it is necessary to provide a data collaborative query method, device, computer equipment and storage medium that can improve data query efficiency in response to the above technical problems.
[0005] In a first aspect, the present application provides a data collaborative query method. The method comprises:
[0006] Acquire query information, and determine a query relationship operator and at least one target model operator based on the query information;
[0007] Presetting execution rules in a database, and determining the execution rules of the target model in the database based on the target model operator, wherein the execution rules are determined based on model parameters and a model calculation graph of the target model;
[0008] Based on the query relation operator and the execution rule, a query result is determined from the database.
[0009] In one embodiment, the process of presetting the execution rules in the database is:
[0010] determining a target tensor parameter based on the model parameter, the target tensor parameter comprising a multidimensional array stored in the database;
[0011] Determine a target phase acyclic graph in the database based on the model calculation graph;
[0012] The execution rule is determined based on the target tensor parameter and the target phased acyclic graph, and the execution rule matches the target model operator.
[0013] In one embodiment, determining the target phased acyclic graph in the database based on the model calculation graph includes:
[0014] Determining a model relation operator of the target phase acyclic graph based on the nodes of the model computation graph;
[0015] Based on the topological order of the model computation graph, the execution order of the model relation operators is determined.
[0016] In one embodiment, the query relation operator includes a relation operator, the model relation operator includes a custom operator, and the determining the query result from the database based on the query relation operator and the execution rule includes:
[0017] Determining the computing power cost of the relational operator and the custom operator based on the computing power cost model;
[0018] Based on the computing power costs of the relational operator and the custom operator and the execution rule, the query tasks of the relational operator and the custom operator are executed in parallel to determine the query result.
[0019] In one embodiment, determining the target phased acyclic graph in the database based on the model calculation graph includes:
[0020] Based on a preset graph replacement rule, determine a target computation graph that is equivalent to a sub-computation graph in the model computation graph;
[0021] If the computing power cost of the sub-computation graph is greater than the computing power cost of the target computation graph, the sub-computation graph is replaced with the target computation graph;
[0022] Based on the model computation graph after replacing the sub-computation graph, determine the target phase acyclic graph in the database.
[0023] In one of the embodiments, after determining the target tensor parameters based on the model parameters, the method further includes:
[0024] Determine a sparse vector in the target tensor parameter, and perform data compression on the sparse vector;
[0025] Based on a preset storage rule, the target tensor parameters are stored in the database.
[0026] In one of the embodiments, after determining the execution rule based on the target tensor parameter and the target phased acyclic graph, the method further includes:
[0027] Determine a target structured query statement based on the target model operator and the custom declaration rule;
[0028] Based on the target structured query statement, an execution rule in the database is determined.
[0029] In one embodiment, the custom claim rules include:
[0030] Declare a transformation function of unstructured data, and / or declare a custom field of model attribute information, wherein the model attribute information includes at least one of an input data attribute, an input data type, and a model file path of the target model.
[0031] In one embodiment, before determining the query result from the database based on the query relation operator and the execution rule, the method further includes:
[0032] If there are multiple target model operators, determine the computing power overhead corresponding to each target model operator;
[0033] The target model operator whose computing power overhead is greater than a preset computing power threshold is executed later.
[0034] In a second aspect, the present application also provides a data collaborative query device. The device comprises:
[0035] An operator determination module, used to obtain query information, and determine a query relationship operator and at least one target model operator based on the query information;
[0036] An execution rule determination module, used to preset execution rules in a database, and determine the execution rules of the target model in the database based on the target model operator, wherein the execution rules are determined based on model parameters and a model calculation graph of the target model;
[0037] A query module is used to determine a query result from the database based on the query relationship operator and the execution rule.
[0038] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the data collaborative query method described in any one of the first aspects are implemented.
[0039] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the data collaborative query method described in any one of the first aspects above.
[0040] The above-mentioned data collaborative query method, device, computer equipment and storage medium obtain query information and determine the query relationship operator and at least one target model operator based on the query information; preset execution rules in the database, and determine the execution rules of the target model in the database based on the target model operator, and the execution rules are determined based on the model parameters of the target model and the model calculation graph; based on the query relationship operator and the execution rules, determine the query results from the database.
[0041] The embodiment of the present application determines the relational operator and the target model operator according to the query information, and then determines the execution rules of the target model in the database according to the target model operator. The execution rules have been preset in the database, and the execution rules have been determined based on the model parameters of the target model and the model calculation diagram, and stored in the database. In the data query process, the target model can be loaded and executed in the database based on the query relational operator and the execution rules in the database, and the data query process can be automatically implemented to obtain the data query results, without the need for the user to manually parse the target model and manually write a large amount of SQL according to the target model. Therefore, the present application not only reduces labor costs, but also effectively shortens the time of data query, thereby significantly improving the efficiency of data query.
[0042] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0044] Figure 1 An application environment diagram of a data collaborative query method in an embodiment;
[0045] Figure 2 A schematic diagram of a process flow of a collaborative data query method in one embodiment;
[0046] Figure 3 A schematic diagram of an execution rule of a target model preset in a database in one embodiment;
[0047] Figure 4 A schematic diagram of a preset execution rule for offline optimization in an embodiment;
[0048] Figure 5 A schematic diagram of an optimization method in an online collaborative query process in one embodiment;
[0049] Figure 6 A schematic diagram of a collaborative data query architecture in one embodiment;
[0050] Figure 7 It is a structural block diagram of a data collaborative query device in an embodiment;
[0051] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0053] The terms "module", "unit", etc. used below are a combination of software and / or hardware that can implement a predetermined function. Although the devices described in the following embodiments are preferably implemented in hardware, the implementation of software, or a combination of software and hardware is also possible and conceivable.
[0054] In traditional data collaborative query technology, there are usually the following problems that need to be solved: First, how to achieve model inference within the database, that is, native collaborative query processing, without introducing an external deep learning system. Second, how to enable users to quickly generate complex SQL queries containing inferred models within the database through simple input. Third, how to improve the execution performance and response speed of collaborative queries to cope with the high computing cost and long execution time problems in large-scale data analysis tasks.
[0055] Currently, the closest traditional technology to solving the problem of native collaborative query processing is to use a tightly integrated approach to achieve model inference within the database. This approach integrates the inference process of the deep learning model directly into the database system to avoid the high cost and complexity of relying on an external runtime. Specifically, the tightly integrated approach has the following features: First, the parameters of the deep learning model are represented as a relational table, and the model inference operation is implemented through explicitly written SQL queries, and the query is optimized in conjunction with the database optimizer to reduce the overhead of data transformation and transmission. Second, by integrating model inference within the database, the dependence on external systems is reduced and the system architecture is simplified; at the same time, because the data in the database will not be transmitted to external systems, the security of the system is guaranteed.
[0056] However, although the tightly integrated method solves the problem of external system dependence to a certain extent, it still has the following technical disadvantages: First, the user burden is heavy. The tightly integrated method in traditional technology requires users to manually parse deep learning models and manually write a large number of SQL queries to implement model inference. This manual workflow will generate a huge amount of manual workload, which not only increases the burden on users, but also easily leads to errors in the writing process. Especially for complex deep learning models and multimodal data, the process of manually writing and optimizing SQL queries is very cumbersome and time-consuming, and the query efficiency is low. Second, the performance bottleneck and storage overhead are large. The tightly integrated method in traditional technology relies on relational models and conventional SQL queries to perform model inference in the database, but there are performance bottlenecks when performing complex deep learning calculations, especially when processing a large number of matrix operations and high-dimensional data calculations, the query execution efficiency is significantly reduced. In addition, the way model parameters are stored as relational tables also leads to large storage overhead, which increases the resource consumption and maintenance cost of the system. Third, performance optimization is difficult. The tightly integrated method in traditional technology only supports database optimizers to perform conventional query optimization, but for complex queries containing deep learning model inference, its performance optimization still faces huge challenges. Traditional technologies lack automated optimization mechanisms, requiring users to manually adjust and optimize queries, further leading to inefficient query execution.
[0057] Based on the above problems, the present application provides a data collaborative query method. The data collaborative query method provided by the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The server 104 obtains the query information sent by the terminal 102, and determines the query relationship operator and at least one target model operator based on the query information. The server 104 presets the execution rules in the database in the data storage system, and determines the execution rules of the target model in the database based on the target model operator, and the execution rules are determined based on the model parameters of the target model and the model calculation diagram. The server 104 determines the query result from the database based on the query relationship operator and the execution rule, and sends it to the terminal 102. In other embodiments, the database can also be stored in the data storage device of the terminal 102, and the above-mentioned data collaborative query process can also be executed entirely by the terminal 102. This application does not specifically limit the way of data interaction. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices, and portable wearable devices. The server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.
[0058] In some embodiments, Figure 2 As shown, a data collaborative query method is provided, which is applied to Figure 1 The application scenario in is taken as an example to illustrate, including the following steps:
[0059] S201: Acquire query information, and determine a query relationship operator and at least one target model operator based on the query information.
[0060] In an embodiment of the present application, the query information includes collaborative query information containing target model inference, and the target model may include a deep learning model. In order to determine the collaborative query result based on the query information, it is necessary to execute the target model contained in the query information. By parsing the query information, the query relationship operator and at least one target model operator can be determined. The parsing process of the query information can be implemented by a query parsing tool preset by the database, or can refer to the information parsing method in traditional technology, and this application does not limit this.
[0061] In an embodiment of the present application, the query relation operator may include a relational operator in a database query language. Specifically, the query relation operator may include relational operators such as select, where, and join in SQL. The target model operator may include a model user-defined function (nUDF, neural User Defined Function). After parsing the query information, at least one target model operator may be determined. The target model operator is used to determine the execution rules of the target model in the database.
[0062] S203: Preset execution rules in the database, and determine execution rules of the target model in the database based on the target model operator, where the execution rules are determined based on model parameters of the target model and a model calculation graph.
[0063] In an embodiment of the present application, execution rules are preset in the database before obtaining query information. Generally speaking, the target model is usually executed independently as a whole model, but the present application requires the target model to be executed in the database. By presetting the execution rules of the target model in the database, the embodiment of the present application can realize loading the target model in the database, and optimizing the target model in a database-oriented manner, and automatically generating the corresponding model query operator and model parameters. In the process of presetting the execution rules in the database, the target model query operator is bound to the corresponding target model operator so as to efficiently execute the inference of the target model in subsequent collaborative queries. The target model query operator may include query statements that the database can recognize, such as SQL statements. Based on the target model operator, the target model query operator can be determined, and then the execution rules of the target model in the database can be determined. Compared with traditional technologies, the present application does not need to write corresponding SQL statements in real time for the target model during the collaborative query process, which can effectively improve the query efficiency.
[0064] In the embodiment of the present application, the execution rules of the target model in the database are determined based on the model parameters and model calculation graph of the target model. It can be understood that the target model includes trained model parameters and model calculation graphs, and the execution rules are determined based on the model parameters and model calculation graphs and stored in the database, and the target model can be loaded in the database.
[0065] In some specific embodiments, the model parameters and the model calculation graph can be parsed and stored in a structured table of a database. In other specific embodiments, the model parameters and the model calculation graph can also be serialized into binary data and stored in a BLOB (Binary Large Object) type field of the database. In other embodiments, the model parameters can also be extracted as tensor parameters, and the model calculation graph can be converted into a DAG (Directed Acyclic Graph), and the tensor parameters and DAG can be stored in the database.
[0066] S205: Determine the query result from the database based on the query relationship operator and the execution rule.
[0067] In an embodiment of the present application, based on the query relationship operator and the execution rules of the target model in the database, the target model can be loaded and executed in the database according to the execution rules, and the query result can be determined from the database according to the execution results of the query relationship operator and the target model.
[0068] The embodiment of the present application determines the relational operator and the target model operator based on the query information, and then determines the execution rules of the target model in the database according to the target model operator. The execution rules have been preset in the database, and the execution rules have been determined based on the model parameters of the target model and the model calculation diagram, and stored in the database. In the data query process, the target model can be loaded and executed in the database based on the query relational operator and the execution rules in the database, and the data query process can be automatically implemented to obtain the data query results, without the need for the user to manually parse the target model and manually write a large amount of SQL according to the target model. Therefore, the present application not only reduces labor costs, but also effectively shortens the time of data query, thereby significantly improving the efficiency of data query.
[0069] The following is a method for presetting execution rules in a database through an embodiment of the present application. In some embodiments, the process of presetting execution rules in a database is:
[0070] S301: Determine target tensor parameters based on model parameters, where the target tensor parameters include a multidimensional array stored in a database.
[0071] S303: Determine the target phase-free graph in the database based on the model calculation graph.
[0072] S305: Determine execution rules based on target tensor parameters and target phased acyclic graph, and match the execution rules with target model operators.
[0073] In the embodiment of the present application, the method of presetting execution rules in the database can be understood as an offline processing process before online collaborative query. The main purpose of the offline processing process is to optimize and prepare the target model in the database so as to efficiently perform the inference of the target model in the database.
[0074] The target tensor parameters are determined based on the model parameters, and the target tensor parameters include a multidimensional array stored in a database. The model parameters of the trained target model are extracted as tensor parameters, and each tensor parameter is stored as a data table in the database with the data type of a multidimensional array (MDA, Multi-Dimensional Array). In traditional technology, tensor parameters are usually stored in the database in the form of a relational data table, so there is a performance bottleneck when processing complex deep learning calculations, and the storage overhead is large in the way that the model parameters are stored as a relational table. The present application uses a multidimensional array data model to store tensor parameters, so that the storage of tensor data in the database is more efficient, further reducing the storage space occupied.
[0075] Based on the model computation graph, the target directed acyclic graph in the database can be determined. In some embodiments, each node and its direct child node or parent node in the model computation graph can be stored in the database through an adjacency list to represent the target directed acyclic graph. In other embodiments, the connection relationship of the model computation graph can also be stored through an edge table to represent the directed edge relationship between the nodes of the target directed acyclic graph.
[0076] In other embodiments, determining a target phased acyclic graph in a database based on the model computation graph includes:
[0077] S401: Based on the nodes of the model computation graph, determine the model relationship operator of the target phased acyclic graph.
[0078] S403: Determine the execution order of the model relationship operators based on the topological order of the model calculation graph.
[0079] In an embodiment of the present application, each node (i.e., deep learning operator) in the model computation graph is mapped to a model relation operator in a target directed acyclic graph, and the model relation operator may include a relation operator. The execution order of the model relation operator can be determined by traversing the model computation graph in topological order. After determining the model relation operator of the target directed acyclic graph and its execution order, the model computation graph can be converted into a target directed acyclic graph in a database, so that the reasoning calculation process of the target model can be executed in the database.
[0080] Based on the target tensor parameters and the target directed acyclic graph, the execution rules can be determined, and the execution rules are matched with the target model operators. It can be understood that the model parameters of the target model and the target directed acyclic graph are determined in the database, that is, the execution rules of the target model in the database are determined, and the target model is loaded and executed in the database. Among them, by parsing the nUDF creation statement, the target model operator nUDF can be associated with the model parameters and the target directed acyclic graph, thereby matching the target model operator with the execution rules.
[0081] In some specific embodiments, the schematic diagram of the execution rules of the target model preset in the database is as follows: Figure 3 As shown in the figure, the model parameters are the convolution layer parameters, i.e., the convolution kernels. The convolution layer parameters are represented as a three-dimensional array table. In this way, all model parameters of the target model are organized in a data table. Each data table includes a separate MDA attribute corresponding to the tensor parameter associated with it. Figure 3 The data table storing the model parameters as 3×3×64 and its loading process are shown in FIG.
[0082] The embodiment of the present application avoids the manual parsing of deep learning models and manual writing of a large number of SQL queries in traditional technologies to achieve model inference by presetting the execution rules of the target model in the database. The present application introduces automated collaborative query grammar and optimization mechanisms, and users only need to provide simple query instructions to automatically parse the target model operator, determine the execution rules of the target model, and execute the inference of the target model in the database. This not only greatly reduces labor costs, but also reduces the probability of errors that may occur due to manual operations, effectively improving the overall efficiency of collaborative queries.
[0083] In order to further improve the efficiency of collaborative query, the embodiments of the present application also provide two implementation methods for optimizing the preset execution rules.
[0084] In some embodiments, determining a target phased acyclic graph in a database based on the model computation graph includes:
[0085] S501: Based on a preset graph replacement rule, determine a target computation graph that is equivalent to a sub-computation graph in the model computation graph.
[0086] S503: If the computing power cost of the sub-computation graph is greater than the computing power cost of the target computation graph, the sub-computation graph is replaced with the target computation graph.
[0087] S505: Based on the model computation graph after replacing the sub-computation graph, determine the target phase acyclic graph in the database.
[0088] In an embodiment of the present application, the preset execution rules can be optimized in a graph-driven form. The sub-computation graph includes a partial calculation graph in the model calculation graph, that is, the model calculation graph includes at least one sub-computation graph. The target calculation graph equivalent to the sub-computation graph includes a target calculation graph that is equivalent to the sub-computation graph in terms of operation logic, that is, for the same input data, the output data of the sub-computation graph and the target calculation graph are the same. According to the preset graph replacement rules, the target calculation graph equivalent to the sub-computation graph in the model calculation graph can be determined. In some specific embodiments, the preset graph replacement rules may include layer fusion rules, operator replacement rules, constant folding rules, branch merging rules, etc.
[0089] In some specific embodiments, multiple consecutive matrix multiplications of the sub-computation graph can be merged into one matrix multiplication of the target computation graph to reduce the number of operators in the database, thereby reducing the intermediate results of the automatically generated SQL when querying and reducing the query time. In other embodiments, the convolution operator, activation layer operator, and normalization operator in the neural network with high overhead in the sub-computation graph can also be merged into a new convolution operator of the target computation graph to reduce the operator overhead.
[0090] Determine the computing power cost of the sub-computation graph and the computing power cost of the target computation graph. If the computing power cost of the sub-computation graph is greater than the computing power cost of the target computation graph, replace the sub-computation graph with the target computation graph. After replacing the model computation graph with the sub-computation graph, a target directed acyclic graph with lower cost in the database can be determined. The computing power cost of the sub-computation graph and the computing power cost of the target computation graph can be determined by determining the execution time, memory usage, storage space, and data throughput of the computation graph in the database.
[0091] In an embodiment of the present application, by identifying the sub-computation graph in the calculation graph, and based on the preset graph replacement rules, using a more efficient target calculation graph to replace the sub-computation graph, ultimately a model calculation graph with lower overhead and its corresponding target phased acyclic graph are obtained, which can further improve the efficiency of collaborative query.
[0092] In some embodiments, the preset execution rules may also be optimized in a data-driven manner. After determining the target tensor parameters based on the model parameters, the method further includes:
[0093] S601: Determine a sparse vector in a target tensor parameter, and perform data compression on the sparse vector.
[0094] S603: Based on preset storage rules, store the target tensor parameters in a database.
[0095] In the embodiment of the present application, by optimizing the preset execution rules in a data-driven manner, static data can be optimized according to the parameter characteristics of the model calculation graph to reduce storage overhead. The sparse vectors in the target tensor parameters are determined, and the sparse vectors are compressed to reduce redundant calculations and storage space. Based on the preset storage rules, the target tensor parameters are stored in the database.
[0096] In some specific embodiments, the preset storage rules may include row-priority storage rules, memory cache optimization storage rules, etc. Among them, the row-priority storage rule can adapt to the tensor parameter calculation requirements, and its priority memory read and write data has better locality, avoiding frequent cross-address reading and writing, so that data stored in similar locations are calculated first. The memory cache optimization storage rule may include memory alignment and cache optimization storage rules, which can improve the cache line utilization of the target model during execution.
[0097] In order to adapt to more complex collaborative queries and improve collaborative query efficiency, the present application also provides an implementation method for expanding structured query statements.
[0098] In some embodiments, after determining the execution rule based on the target tensor parameter and the target phased acyclic graph, the method further includes:
[0099] S701: Determine a target structured query statement based on a target model operator and a custom declaration rule.
[0100] S703: Determine execution rules in the database based on the target structured query statement.
[0101] In the embodiment of the present application, in the process of associating the target model operator nUDF with the target model, the target structured query statement (SQL) can be determined based on the target model operator and the custom declaration rules, and then the execution rules in the database can be determined through the target structured query statement that can be recognized by the database, and then the target model is executed according to the execution rules stored in the database. It can be understood that in the actual collaborative query process, since the target model operator can be determined by parsing the query information, and the target structured query statement can be automatically generated according to the target model operator, and then the execution rules associated with the target model operator are determined, efficient and automated collaborative query is achieved.
[0102] In some embodiments, the custom declaration rules include: declaring a transformation function of unstructured data, and / or declaring a custom field of model attribute information, wherein the model attribute information includes at least one of the input data attributes of the target model, the input data type, and the model file path.
[0103] In the embodiment of the present application, the collaborative relationship in the collaborative query is a relationship containing multiple attributes, each of which can be a standard relationship attribute or an unstructured attribute. For unstructured data (such as pictures and text), it can be converted into tensor data through a conversion function, and then stored as an unstructured attribute according to the multidimensional array (MDA) data type.
[0104] The custom declaration rule may include declaring a transformation function for unstructured data. Specifically, a transformation function may be added based on the creation of a conventional relational operator. The transformation function may be a TRANSFORM keyword, such as "Normalize, Standardize, Encode". Unstructured data will be automatically processed according to the transformation function during data storage. In some specific embodiments, the collaborative relation syntax for adding a transformation function may include:
[0105] CREATE CTABLE name(
[0106] [[attributeName attributeType
[0107] [TRANSFORM
[0108] <Normalize|Standardize|Encode|Scale|Impute>
[0109] ]],
[0110] [, ...]] )
[0112] The custom declaration rule may also include a custom field for declaring model attribute information, where the model attribute information includes at least one of the input data attributes, input data types, and model file path of the target model. Specifically, the custom field for declaring model attribute information may include an nUDF that declares model attribute information using the keyword CREATE INFERENCE FUNCTION, and the model file path in the model attribute information may include "cnn.onnx". In other embodiments, the model file path in the model attribute information may also support target models in other formats such as PyTorch. In some specific embodiments, the custom field for declaring model attribute information may include:
[0113] CREATE INFERENCE FUNCTION Color(jpeg image)
[0114] FROM MODEL IN FILE "cnn.onnx"
[0115] It should be noted that nUDF is similar to relational operators and can be combined with other relational operators and used in any query, so that each model inference appears as a corresponding nUDF call in the collaborative query, allowing users to interact with the database without writing non-SQL code.
[0116] In other embodiments, the nUDF declaration syntax may be extended to support binding of multiple model files, and the optimal model may be automatically selected according to query conditions and data features during collaborative query, thereby further improving the accuracy of model inference.
[0117] In the embodiments of the present application, the SQL standard syntax is expanded to support the creation and management of collaborative relationships and nUDFs. Through these extended syntaxes, complex queries involving deep learning model inference can be performed quickly and efficiently, effectively improving the efficiency of collaborative queries.
[0118] The following is a specific example to illustrate the implementation of the offline optimization preset execution rule. Figure 4As shown, on the left side, the nUDF processor (nUDF Processor) reads the nUDF creation query statement (nUDFCreation Query) and parses it, determines the model file path of the target model according to the model attribute information (Model File) defined by nUDF, obtains the target directed acyclic graph DAG of the model, and inputs it into the offline optimizer. Figure 4 The middle part is the offline optimization process, which includes the graph-driven optimization process and the data-driven optimization process. The right part is the serialization of nUDF according to the function name (nUDFName), parameter type (argType), and nUDF SQL (nUDF query statement), and the nUDF is stored in the database in a binary file (dagBin).
[0119] In order to further improve the efficiency of collaborative query, the embodiment of the present application also provides an optimization method in the online collaborative query process.
[0120] In some embodiments, before determining the query result from the database based on the query relation operator and the execution rule, the method further includes:
[0121] S801: If there are multiple target model operators, determine the computing power overhead corresponding to each target model operator.
[0122] S803: Postponing the execution of the target model operator whose computing power cost is greater than the preset computing power threshold.
[0123] In an embodiment of the present application, the purpose of online optimization is to improve the efficiency of collaborative queries during execution, which may include combined queries of nUDF and other relational operators. After parsing the query information, if there are multiple target model operators nUDF, a query tree including a query relation operator and multiple target model operators can be obtained to implement a coarse-grained collaborative query rewriting process. Determine the computing power overhead corresponding to each target model operator in the query tree. Specifically, the computing power overhead can be quantified as data throughput, that is, the computing power overhead corresponding to the target model operator nUDF can be determined based on the change in the amount of data before and after. Among them, the change in data volume can be determined based on the database's own tools, such as a database optimizer.
[0124] The target model operator nUDF whose computing power cost is greater than the preset computing power threshold is delayed for execution to obtain a rewritten query tree. In some specific embodiments, the computing power costs of all target model operators nUDFs can also be sorted from small to large, and the target model operators nUDFs are executed in order from small to large, that is, the place where the nUDF data throughput is the smallest is found and executed first.
[0125] In an embodiment of the present application, by postponing the execution of the target model operator nUDF with higher computational cost and adjusting the order of nodes to rewrite the query tree, the amount of input data for subsequent operations can be reduced, thereby reducing the overhead of collaborative query and improving the efficiency of collaborative query.
[0126] In some embodiments, the query relation operator includes a relation operator, the model relation operator includes a custom operator, and based on the query relation operator and the execution rule, determining the query result from the database includes:
[0127] S901: Determine the computing power overhead of the relational operator and the custom operator based on the computing power overhead cost model.
[0128] S903: Based on the computing power costs and execution rules of the relational operators and the custom operators, query tasks of the relational operators and the custom operators are executed in parallel to determine query results.
[0129] In an embodiment of the present application, the query relation operator includes a relational operator, and the model relation operator includes a custom operator. Among them, the custom operator UDO (User Defined Operator, UDO) may include an algebraic operator, and the basic relational algebra in the traditional database may be extended through the custom operator UDO. The custom operator UDO is a fine-grained built-in nUDF for MDA data. Specifically, the custom operator may include matrix multiplication (mat_mul), element-by-element addition (eadd), etc. In a collaborative query, the corresponding target query statement SQL may be automatically generated according to the model relation operator nUDF, thereby determining a fine-grained query plan containing relational operators and custom operators UDO.
[0130] In an embodiment of the present application, the computing power cost of relational operators and custom operators can be determined based on a computing power cost model. Specifically, the computing power cost model can evaluate the data size and data attributes of relational operators and custom operators as the number of floating-point operations, and then determine their computing power costs. The computing power cost model can use a cost model in a database, or refer to an operator computing power cost model in the prior art, and the present application does not make specific restrictions on this.
[0131] Based on the computing power cost and execution rules of relational operators and custom operators, query tasks of relational operators and custom operators can be executed in parallel through query scheduling to determine the query results. In some embodiments, query tasks can be executed in parallel by identifying parallel processing opportunities. Some relational operators may be CPU intensive (such as UDO or connection operations for complex calculations), while others may be data intensive (such as large-scale data scanning). By identifying these characteristics, CPU intensive tasks and data intensive tasks can be reasonably allocated during parallelization to maximize resource utilization. In other embodiments, high-cost operators (such as complex UDOs) can also be assigned to multiple nodes or threads for execution to disperse the computing load. For example, for a UDO that needs to process a large amount of data, the UDO operation can be executed in parallel after the data is sliced. In other embodiments, the relational operators that are executed continuously can also be set to execute in parallel on different processors. For example, the selection operation can be executed in parallel with the subsequent projection operation without waiting for the previous operation to complete.
[0132] The embodiment of the present application determines the query results by executing the query tasks of the relational operator and the custom operator in parallel, thereby improving the execution performance of the collaborative query, reducing the response time, and improving the efficiency of the collaborative query.
[0133] In some specific embodiments, the optimization method in the online collaborative query process is as follows: Figure 5 shown. Figure 5In the example, the query information of the collaborative query is parsed. The query selects data from the Fabric and Images tables, filters the weather Weather and Color, groups the results and calculates the number of each object. By parsing the query information (Query Parsing), a coarse-grained query tree (Coarse-grained Query Tree) including query relationship operators and multiple target model operators is obtained. By postponing the execution of the target model operator nUDF whose computing power overhead is greater than the preset computing power threshold, that is, coarse-grained query rewriting (Coarse-grained Query Rewriting), the rewritten query tree is obtained. After that, the nUDF inlining process is performed to inline custom operators (such as mat_add, bias, and mat_mul) into the query tree. The fine-grained query tree obtained helps to further optimize query execution. The collaborative cost model then determines the computational cost of relational operators and custom operators, and the logical optimizer further optimizes the fine-grained query tree based on the computational cost. The goal of the optimization is to minimize the total cost of query execution, for example, by reordering operators, reducing intermediate results, or parallel execution. The query scheduler is responsible for assigning the optimized query plan to the execution engine. It schedules tasks in consideration of the system's resource status (such as CPU, memory, I / O bandwidth, etc.) to achieve efficient parallel processing. The execution engine executes the query tasks assigned by the scheduler and performs operations according to the optimized query plan, including relational operators, nUDF, etc. The final query execution plan is determined by the results of the scheduler's execution in the execution engine. The entire query is efficiently completed through parallel processing and optimization strategies to determine the query results.
[0134] The data collaborative query method provided in the embodiment of the present application can be performed by Figure 6The data collaborative query architecture shown in the figure is implemented. The data loader first converts multimodal data (such as images and text) into a multidimensional array MDA, and stores it in the form of an array table inside the system (Storage Manager). The model loader reads the model file, reads the model calculation graph and tensor parameters of the target model, converts the model calculation graph into the target directed acyclic graph DAG in the database, and stores the parameters as an array table. The data catalog is used to store the source data of the database table, such as the table name, table size, etc. The parser is used to parse the input query information. The nUDF processor parses the nUDF creation statement and associates the target directed acyclic graph DAG with the nUDF. The query optimizer includes an offline optimizer and an online optimizer. The offline optimizer is called for optimization to generate the corresponding nUDF metadata. The offline optimizer applies a database-oriented computational graph optimization algorithm to optimize the model computational graph. It reduces the computational complexity and storage overhead of the target model inference in the database through subgraph replacement, vector compression, data re-layout, etc., thereby improving the efficiency of online collaborative queries. On the other hand, after obtaining data from the parser, database, and nUDF processor, the processing engine optimizes the query plan online through the online optimizer, adjusts the execution order and execution mode of the operator through heuristic query rewriting, and combines the deep learning-aware cost model to generate an efficient execution plan. The query executor finally determines the query result based on all relational operations and model inference operators.
[0135] The data collaborative query method provided by the present application is described below through a specific embodiment.
[0136] Taking the application scenario of social media database analysis as an example, the user (data analyst) wants to use collaborative query to analyze the pictures uploaded in 2023 and count the number of red objects in them. The user wants to be able to enter the following collaborative query:
[0137] SELECT Object(I.image)AS O,count(F.id)AS C
[0138] FROM FABRIC F,IMAGES as I
[0139] WHERE
[0140] F.createDate>='2023-01-01'and
[0141] F.createDate<='2023-12-31'and
[0142] Color(I.image) = 'red'
[0143] GROUP BY O;
[0144] To support this collaborative query, the user first uploads a color classifier model "color.onnx" and creates the corresponding nUDF Color:
[0145] CREATE INFERENCE FUNCTION Color(JPEG image)
[0146] FROM MODEL IN FILE"color.onnx
[0147] The data collaboration method proposed in this application will load the model and perform offline optimization, and finally generate the SQL query and model parameter table corresponding to the color classifier model.
[0148] The user inputs the collaborative query information, and after parsing the query information, online optimization such as query rewriting and nUDF inlining is performed, and the query is executed using a parallel mechanism based on the optimized query plan. After the query is executed, the query result is returned to the user. In this specific embodiment, the query result is the statistical result of the number of each type of red objects in the FABRIC table during 2023.
[0149] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0150] Based on the same inventive concept, the embodiment of the present application also provides a data collaborative query device 1100 for implementing the data query method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations of one or more data collaborative query device 1100 embodiments provided below can refer to the limitations of the data collaborative query method above, and will not be repeated here.
[0151] In one embodiment, Figure 7 As shown, a data collaborative query device 1100 is provided, comprising:
[0152] An operator determination module 1101 is used to obtain query information and determine a query relationship operator and at least one target model operator based on the query information;
[0153] An execution rule determination module 1102 is used to preset execution rules in the database and determine the execution rules of the target model in the database based on the target model operator, wherein the execution rules are determined based on the model parameters of the target model and the model calculation graph;
[0154] The query module 1103 is used to determine the query result from the database based on the query relationship operator and the execution rule.
[0155] In some embodiments, the execution rule determination module 1102 is also used to determine the target tensor parameters based on the model parameters, the target tensor parameters include a multidimensional array stored in a database; determine the target phased acyclic graph in the database based on the model calculation graph; determine the execution rules based on the target tensor parameters and the target phased acyclic graph, and match the execution rules with the target model operators.
[0156] In some embodiments, the execution rule determination module 1102 is further used to determine the model relationship operators of the target phased acyclic graph based on the nodes of the model calculation graph; and determine the execution order of the model relationship operators based on the topological order of the model calculation graph.
[0157] In some embodiments, the query relational operator includes a relational operator, the model relational operator includes a custom operator, and the query module 1103 is further used to determine the computing power overhead of the relational operator and the custom operator based on a computing power overhead cost model; based on the computing power overhead and execution rules of the relational operator and the custom operator, the query tasks of the relational operator and the custom operator are executed in parallel to determine the query results.
[0158] In some embodiments, the execution rule determination module 1102 is also used to determine a target computation graph equivalent to a sub-computation graph in a model computation graph based on a preset graph replacement rule; if the computing power overhead of the sub-computation graph is greater than the computing power overhead of the target computation graph, the sub-computation graph is replaced with the target computation graph; based on the model computation graph after replacing the sub-computation graph, the target phase-acyclic graph in the database is determined.
[0159] In some embodiments, the execution rule determination module 1102 is also used to determine the sparse vectors in the target tensor parameters and perform data compression on the sparse vectors; based on preset storage rules, the target tensor parameters are stored in a database.
[0160] In some embodiments, the data collaborative query device 1100 is also used to determine a target structured query statement based on a target model operator and a custom declaration rule; and determine an execution rule in a database based on the target structured query statement.
[0161] In some embodiments, the custom declaration rule includes: declaring a transformation function of unstructured data, and / or, declaring a custom field of model attribute information, the model attribute information including at least one of the input data attribute of the target model, the input data type, and the model file path.
[0162] In some embodiments, the query module 1103 is also used to determine the computing power cost corresponding to each target model operator if there are multiple target model operators; and postpone the execution of the target model operator whose computing power cost is greater than a preset computing power threshold.
[0163] Each module in the above-mentioned data collaborative query device 1100 can be implemented in whole or in part by software, hardware, or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0164] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a data collaborative query method is implemented.
[0165] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0166] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the data collaborative query method in any of the above embodiments is implemented.
[0167] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the data collaborative query method in any of the above embodiments is implemented.
[0168] In one embodiment, a computer program product is provided, including a computer program, which, when executed by a processor, implements the data collaborative query method in any of the above embodiments.
[0169] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the", "these" and the like in this application do not represent quantitative restrictions, and they can be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether directly or indirectly. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. Usually, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0170] 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, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0171] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present 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), magnetoresistive 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. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0172] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, 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.
[0173] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A data collaborative query method, characterized in that: The method comprises: Acquire query information, and determine a query relationship operator and at least one target model operator based on the query information; Presetting execution rules in a database, and determining the execution rules of the target model in the database based on the target model operator, wherein the execution rules are determined based on model parameters and a model calculation graph of the target model; Based on the query relation operator and the execution rule, a query result is determined from the database.
2. The method according to claim 1, characterized in that The process of presetting the execution rules in the database is as follows: determining a target tensor parameter based on the model parameter, the target tensor parameter comprising a multidimensional array stored in the database; Determine a target phase acyclic graph in the database based on the model calculation graph; The execution rule is determined based on the target tensor parameter and the target phased acyclic graph, and the execution rule matches the target model operator.
3. The method according to claim 2, characterized in that Determining the target phase-acyclic graph in the database based on the model calculation graph includes: Determining a model relation operator of the target phase acyclic graph based on the nodes of the model computation graph; Based on the topological order of the model computation graph, the execution order of the model relation operators is determined.
4. The method according to claim 3, characterized in that The query relation operator includes a relation operator, the model relation operator includes a custom operator, and the determining the query result from the database based on the query relation operator and the execution rule includes: Determining the computing power cost of the relational operator and the custom operator based on the computing power cost model; Based on the computing power costs of the relational operator and the custom operator and the execution rule, the query tasks of the relational operator and the custom operator are executed in parallel to determine the query result.
5. The method according to claim 2, characterized in that: Determining the target phase-acyclic graph in the database based on the model calculation graph includes: Based on a preset graph replacement rule, determine a target computation graph that is equivalent to a sub-computation graph in the model computation graph; If the computing power cost of the sub-computation graph is greater than the computing power cost of the target computation graph, the sub-computation graph is replaced with the target computation graph; Based on the model computation graph after replacing the sub-computation graph, determine the target phase acyclic graph in the database.
6. The method according to claim 2, characterized in that After determining the target tensor parameters based on the model parameters, the method further includes: Determine a sparse vector in the target tensor parameter, and perform data compression on the sparse vector; Based on a preset storage rule, the target tensor parameters are stored in the database.
7. The method according to claim 2, characterized in that After determining the execution rule based on the target tensor parameter and the target phased acyclic graph, the method further includes: Determine a target structured query statement based on the target model operator and the custom declaration rule; Based on the target structured query statement, an execution rule in the database is determined.
8. The method according to claim 7, characterized in that The custom claim rules include: Declare a transformation function of unstructured data, and / or declare a custom field of model attribute information, wherein the model attribute information includes at least one of an input data attribute, an input data type, and a model file path of the target model.
9. The method according to claim 1, characterized in that: Before determining the query result from the database based on the query relation operator and the execution rule, the method further includes: If there are multiple target model operators, determine the computing power overhead corresponding to each target model operator; The target model operator whose computing power overhead is greater than a preset computing power threshold is executed later.
10. A data collaborative query device, characterized in that: The device comprises: An operator determination module, used to obtain query information, and determine a query relationship operator and at least one target model operator based on the query information; An execution rule determination module, used to preset execution rules in a database, and determine the execution rules of the target model in the database based on the target model operator, wherein the execution rules are determined based on model parameters and a model calculation graph of the target model; A query module is used to determine a query result from the database based on the query relationship operator and the execution rule.
11. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.
Citation Information
Cited By
Modeling application full link type calculation method and system
CN120892407A
A modeling application full-link type calculation method and system
CN120892407B