Method and device for training artificial intelligence model of database

By receiving and processing user-defined machine learning functions in the database and training artificial intelligence models, it solves the problem of poor performance caused by AI4DB technology being independent of the database, realizes the integration of AI4DB technology, and improves database performance and efficiency.

CN118796867APending Publication Date: 2024-10-18BEIJING VOLCANO ENGINE TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410869024.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-28
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

The current method of using artificial intelligence technology to improve the intelligence, automation and efficiency of database systems results in poor database performance. This is mainly because AI4DB technology is independent of the database system, resulting in high data interaction overhead and difficulty in integrating into the database architecture.

Method used

Provides a database artificial intelligence model training method. By receiving the user-defined machine learning function in the target query statement, it is determined to be a supported programming language function, the function is called to train the target model, and the meta-information in the memory is used for data processing. Conversion and aggregation realize the integration of AI4DB technology into the database architecture.

Benefits of technology

It effectively reduces the data interaction overhead between the database and AI4DB technical architecture, improves database performance, realizes the integration of AI4DB technology, and improves the intelligence, automation and efficiency of the database system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118796867A_ABST
    Figure CN118796867A_ABST
Patent Text Reader

Abstract

The invention discloses a training method of an AI4DB (artificial intelligence of a database) model, which comprises the following steps: receiving a query statement which comprises a target UDMF (user-defined machine learning function); and determining that the target UDMF function is a function adopting a first programming language, and determining that the function type of the target UDMF function is UDMF. Wherein the first programming language is a programming language supported by an AI4DB model, is a function of a UDMF type, and is used for realizing training of the AI4DB model. And calling the target UDMF to train a target model, wherein the target model is an AI4DB model. Therefore, by means of the scheme, the database can call the target UDMF function, training of the AI4DB model is achieved, the AI4DB technology is integrated into the database architecture instead of enabling an AI4DB technology framework to be independent of the database architecture, and the database performance is correspondingly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence, and in particular to a method and device for training an artificial intelligence model of a database. Background Art

[0002] Artificial Intelligence for Database (AI4DB) is the concept and practice of applying artificial intelligence technology to the database field. AI4DB aims to improve the intelligence, automation and efficiency of database systems. AI4DB combines artificial intelligence and database technology, and brings many innovations and improvements to database systems by utilizing technologies such as machine learning.

[0003] However, the current method of using AI4DB to improve the intelligence, automation and efficiency of database systems has poor database performance. Therefore, a solution is urgently needed to solve the above problems. Summary of the invention

[0004] In order to solve or at least partially solve the above technical problems, the present application provides a method and device for training an artificial intelligence model of a database.

[0005] In a first aspect, the present application provides a method for training an artificial intelligence model of a database, which is applied to a database, and the method comprises:

[0006] Receive a target query statement, wherein the target query statement includes a target user-defined machine learning function;

[0007] Determining that the target user-defined machine learning function is a function using a first programming language, and determining that the function type of the target user-defined machine learning function is a user-defined machine learning function, wherein: the first programming language is a programming language supported by the artificial intelligence model of the database, and the function type is a user-defined machine learning function, which is used to implement the training of the artificial intelligence model of the database;

[0008] The target user-defined machine learning function is called to train a target model, where the target model is an artificial intelligence model of the database.

[0009] Optionally, the target user-defined machine learning function includes:

[0010] A first function that performs an add operation and a second function that performs a merge operation; wherein:

[0011] The first function is used to complete a model training operation based on input table information, where the table information includes table data and table meta-information;

[0012] The second function is used to aggregate results obtained by executing the first function multiple times.

[0013] Optionally, the input of the second function further includes meta information of the table, and the method further includes:

[0014] When executing the first function, storing the meta information in a memory;

[0015] When the second function is executed, the meta information is obtained from the memory and passed to the second function.

[0016] Optionally, determining that the target user-defined machine learning function is a function using a first programming language, and determining that the function type of the target user-defined machine learning function is a user-defined machine learning function, includes:

[0017] Calling the interface provided by the user-defined machine learning function management module to query the registration information of the target user-defined machine learning function;

[0018] According to the registration information, it is determined that the target user-defined machine learning function is a function using a first programming language, and it is determined that the function type of the target user-defined machine learning function is a user-defined machine learning function.

[0019] Optionally, the target query statement is a selection query statement, and a parameter of the selection query statement indicates training data required for training the target model; calling the target user-defined machine learning function to train the target model includes:

[0020] According to the parameters of the selection query statement, the training data is read from the database into the memory of the database to obtain an object in a second programming language, wherein the second programming language is a programming language supported by the database and is different from the first programming language;

[0021] Converting the object in the second programming language into an object in the first programming language;

[0022] The target model is trained using the objects of the first programming language and the target user-defined machine learning function.

[0023] Optionally, the first programming language is Python, and the second programming language is C or C++, and converting an object in the second programming language into an object in the first programming language includes:

[0024] Creating at least one array for an object in the second programming language, each array carrying a plurality of values ​​in the training data;

[0025] Convert each array in the at least one array into an object of the first programming language.

[0026] Optionally, the target model includes:

[0027] Cardinality estimation model, join order prompt model, or automatic parameter adjustment model.

[0028] In a second aspect, the present application provides a training device for an artificial intelligence model of a database, which is applied to a database, and the device comprises:

[0029] A receiving unit, configured to receive a target query statement, wherein the target query statement includes a target user-defined machine learning function;

[0030] A determination unit, used to determine that the target user-defined machine learning function is a function using a first programming language, and to determine that the function type of the target user-defined machine learning function is a user-defined machine learning function, wherein: the first programming language is a programming language supported by the artificial intelligence model of the database, and the function type is a user-defined machine learning function, which is used to implement the training of the artificial intelligence model of the database;

[0031] A training unit is used to call the target user's customized machine learning function to train a target model, where the target model is an artificial intelligence model of the database.

[0032] Optionally, the target user-defined machine learning function includes:

[0033] A first function that performs an add operation and a second function that performs a merge operation; wherein:

[0034] The first function is used to complete a model training operation based on input table information, where the table information includes table data and table meta-information;

[0035] The second function is used to aggregate results obtained by executing the first function multiple times.

[0036] Optionally, the input of the second function further includes meta information of the table, and the device further includes:

[0037] A storage unit, used for storing the meta information in a memory when executing the first function;

[0038] A reading unit is used to obtain the meta information from the memory and pass it to the second function when executing the second function.

[0039] Optionally, the determining unit is used to:

[0040] Calling the interface provided by the user-defined machine learning function management module to query the registration information of the target user-defined machine learning function;

[0041] According to the registration information, it is determined that the target user-defined machine learning function is a function using a first programming language, and it is determined that the function type of the target user-defined machine learning function is a user-defined machine learning function.

[0042] Optionally, the target query statement is a selection query statement, and a parameter of the selection query statement indicates training data required for training the target model; the training unit is used to:

[0043] According to the parameters of the selection query statement, the training data is read from the database into the memory of the database to obtain an object in a second programming language, wherein the second programming language is a programming language supported by the database and is different from the first programming language;

[0044] Converting the object in the second programming language into an object in the first programming language;

[0045] The target model is trained using the objects of the first programming language and the target user-defined machine learning function.

[0046] Optionally, the first programming language is Python, and the second programming language is C or C++, and converting an object in the second programming language into an object in the first programming language includes:

[0047] Creating at least one array for an object in the second programming language, each array carrying a plurality of values ​​in the training data;

[0048] Convert each array in the at least one array into an object of the first programming language.

[0049] Optionally, the target model includes:

[0050] Cardinality estimation model, join order prompt model, or automatic parameter adjustment model.

[0051] In a third aspect, an embodiment of the present application provides an electronic device, the device comprising a processor and a memory;

[0052] The processor is configured to execute instructions stored in the memory so that the device performs the method as described in any one of the first aspects above.

[0053] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, comprising instructions, wherein the instructions instruct a device to execute a method as described in any one of the above first aspects.

[0054] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a computer, enables the computer to execute any of the methods described in the first aspect above.

[0055] Compared with the prior art, the embodiments of the present application have the following advantages:

[0056] The embodiment of the present application provides a training method for an AI4DB model, which can be applied to a database. Specifically, the database can receive a query statement, which includes a target user-defined machine learning function (UDMF). After the database receives the target UDMF function, it can further determine that the target UDMF function is a function using a first programming language, and determine that the function type of the target UDMF function is UDMF. Wherein: the first programming language is a programming language supported by the AI4DB model, and the function type is UDMF, which is used to implement the training of the AI4DB model. Further, the database can call the target UDMF to train the target model, and the target model is the AI4DB model. It can be seen that using this solution, the database can call the target UDMF function to implement the training of the AI4DB model, thereby integrating the AI4DB technology into the database architecture, rather than separating the AI4DB technology architecture from the database architecture. Accordingly, when using AI4DB to improve the intelligence, automation and efficiency of the database system, the overhead caused by data interaction between the database and the AI4DB technology architecture can be effectively reduced, thereby improving the database performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0058] Figure 1 A flowchart of a training method for an AI4DB model provided in an embodiment of the present application;

[0059] Figure 2 A flowchart of a model training method provided in an embodiment of the present application;

[0060] Figure 3 A schematic diagram of the structure of a training device for an AI4DB model provided in an embodiment of the present application. DETAILED DESCRIPTION

[0061] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0062] The inventors of this application have found through research that AI4DB has brought many innovations and improvements to database systems. For example, in terms of data management and optimization, AI4DB can use machine learning algorithms to optimize database performance and resource management. It can automatically analyze database query history and access patterns, optimize query plans, adjust index and cache strategies, and improve database response speed and throughput. For another example, in terms of anomaly detection and fault prediction, AI4DB can monitor the operating status of the database system and use machine learning and pattern recognition technology to detect abnormal behavior and potential faults.

[0063] The current way of using AI4DB to improve the intelligence, automation and efficiency of database systems does not provide good performance. This is because AI4DB is currently independent of the database system. Therefore, when the amount of query data is large, the amount of data exchanged between the database and the AI4DB technical architecture is also large. Correspondingly, the data exchange between the database and the AI4DB technical architecture also brings a large overhead, resulting in poor database performance.

[0064] However, integrating AI4DB technology into database architecture also faces some challenges.

[0065] First, AI4DB algorithms are usually difficult to express using Structured Query Language (SQL), so AI4DB is difficult to integrate into the database at the SQL level. AI4DB algorithms are also difficult to implement using compiled languages ​​commonly used by databases, such as C or C++.

[0066] In addition, most AI4DB algorithms are implemented in Python because Python has a large number of third-party machine learning (ML) libraries, but the memory format of C objects in the database and the memory format of Python objects are very different.

[0067] This application provides a method and device for training an artificial intelligence model of a database, which can overcome the above challenges and integrate AI4DB technology into the database architecture, thereby improving database performance.

[0068] Various non-limiting implementations of the present application are described in detail below in conjunction with the accompanying drawings.

[0069] Exemplary Methods

[0070] See also Figure 1 , which is a flow chart of a training method of an AI4DB model provided in an embodiment of the present application. The method provided in an embodiment of the present application can be applied to a database. The so-called application to a database can also be understood as application to a database system or a server of a database system.

[0071] In this embodiment, the method may include, for example, the following steps: S101 - S103 .

[0072] S101: Receive a target query statement, where the target query statement includes a target UDMF.

[0073] In one example, the target query statement may be sent by a client of a database system to a server of the database system. As a specific example, the target query statement may be sent by the client to the server after a user triggers a corresponding operation on a page provided by the client.

[0074] The embodiment of the present application does not specifically limit the target query statement. As a specific example, considering that the database system can support a select query statement, the target query statement can be a select query statement.

[0075] In an embodiment of the present application, the target query statement includes a target UDMF, and the target UDMF is a machine learning function customized by the user. As an example, the user can write a script corresponding to the target UDMF. In an embodiment of the present application, the target UDMF adopts the first programming language supported by AI4DB. In the scenario where AI4DB supports the python language, the target UDMF supports the python language. In addition, the type of the target UDMF is UDMF, a function of the UDMF type, which is used to implement the training of the AI4DB model. In addition, the return value type and state type of the target UDMF can also be customized by the user as needed. Among them, in the UDMF type, the state represents the trained model string.

[0076] In one example, before customizing the aforementioned target UDMF, the user can import a third-party library (such as pandas) and a user-defined library. When the database is started, these third-party libraries and user-defined libraries are loaded in advance into the database's running directory, and the running directory is added to the PYTHONPATH system environment variable so that the import function can find it, so that the aforementioned third-party library (such as pandas) and user-defined library can be called when running the aforementioned target UDMF. The third-party library and user-defined library mentioned here can be a library supported by Python.

[0077] The embodiment of the present application does not specifically limit the functions specifically included in the target UDMF. In one example, considering that the model training process needs to undergo multiple iterative calculations, and the results of the multiple iterative calculations can be used together to determine the results of the model training. Therefore, the target UDMF may include a first function that performs an add operation and a second function that performs a merge operation. Among them:

[0078] The add operation is used to add new data values ​​to the intermediate state of an aggregate function. Whenever a new data value arrives, the add operation combines that value with the current state and updates the state to reflect the new data.

[0079] The fusion operation is used to merge the intermediate states of two aggregate functions. When there are multiple partial calculation results in a parallel or distributed computing environment, the fusion operation can merge these partial results to obtain the final aggregate result.

[0080] The first function is used to complete the training operation of the model based on the input table information. For example, the first function is used to complete a batch of training operations based on the input table information. For example, the first function is the addSingleBatch function, which is used to complete local model training. Wherein, addSingleBatch is the function name of the first function. The inputs of the addSingleBatch function are ouput, inputs, and schema_info. Output is used to store the output value of the function, that is, the binary string of the trained model. Inputs is a table data with multiple rows and columns. Schema_info is the summary (schema) information of the table. Wherein, the meta information of the table includes but is not limited to one or more of the database name, table name, column name, etc. to which the table belongs. The first function can first convert the inputs data into the data frame format in pandas, set the column name, and then call the training function in the user-defined library to complete the model training.

[0081] The second function is used to aggregate the results obtained by executing the first function multiple times. In one example, the second function can be a mergeBatch function, which is used to aggregate model results in multiple places. Wherein, mergeBatch is the function name of the second function. The input of the mergeBatch function is output, state, and rowsMap. Output is used to store the aggregated results. State is used to store model results in multiple places. RowsMap is used to store row information of valid data, that is, to identify which rows store valid data and which rows store empty data. The second function can call the model aggregation function in the custom library to aggregate the results obtained by executing the first function multiple times. For example, in a scenario where the database supports C language and AI4DB supports python language, the second function can call the model aggregation function in the custom library through the PyObject_CallFunctionObjArgs function in the python C application programming interface (Application Programming Interface, API) to aggregate the results obtained by executing the first function multiple times. Wherein, the python C API is an API that supports C language and can trigger the execution of python functions.

[0082] In one example, the input of the aforementioned second function also includes the meta-information of the aforementioned table. However, the meta-information of the table is generally lost after the first function is executed. In order to enable the second function to obtain the meta-information of the table, in this solution, the analysis logic of the target UDMF can be modified in the analysis layer, and the meta-information used when the first function is executed is stored in the memory in the form of a data structure of a structure, and is passed to the second function through function parameter passing. In other words, when the first function is executed, the meta-information of the table can be stored in the memory, and correspondingly, when the second function is executed, the meta-information is obtained from the memory and passed to the second function.

[0083] In one example, after the user customizes the aforementioned target UDMF, the user can register the target UDMF to the UDMF management module, that is, register the function name of the target UDMF, the function type of the target UDMF, the target UDMF supports the first programming language and other information to the UDMF management module, and the UDMF management module saves the function name of the target UDMF, the function type of the target UDMF, the target UDMF supports the first programming language and other information. Among them, the function name of the target UDMF, the function type of the target UDMF, the target UDMF supports the first programming language and other information can be called the registration information of the target UDMF. In one example, the registration information contained in the UDMF management module will be persisted to the underlying storage of the database. In one example, the UDMF management module can be UserDefinedFunctionFactory.

[0084] S102: Determine that the target UDMF is a function in a first programming language, and determine that the function type of the target UDMF is UDMF, wherein the first programming language is a programming language supported by AI4DB, and the function type is UDMF, which is used to implement AI4DB model training.

[0085] After obtaining the target query statement, the target query statement may be further parsed. After parsing and obtaining the target UDMF, the target UDMF may be further analyzed. After determining that the target UDMF is a function using a first programming language and the function type of the target UDMF is UDMF, the target UDMF function may be further called.

[0086] The embodiment of the present application does not specifically limit the specific implementation of S102. Two possible implementations are described below.

[0087] In an example, the function name of the target UDMF may follow certain naming rules. When the database parses the target UDMF, if the naming of the target UDMF conforms to the naming rules, it may be determined that the target UDMF is a function in the first programming language and the function type of the target UDMF is UDMF.

[0088] In another example, in a scenario where the target UDMF is registered with the UDMF management module, an interface provided by the UDMF management module can be called to query the registration information of the target UDMF, and further based on the registration information, determine that the target UDMF is a function using the first programming language, and determine that the function type of the target UDMF is UDMF. For the registration information, reference can be made to the relevant description in the previous text, which will not be repeated here.

[0089] S103: calling the target UDMF function to train a target model, where the target model is an AI4DB model.

[0090] The embodiment of the present application does not specifically limit the target model, and the target model can be any model supported by AI4DB.

[0091] In one example, the target model may be a cardinality estimation model (e.g., FactorJoin), wherein the cardinality estimation model may calculate the filtering degree of predicates in a query, adjust the predicate order according to the filtering degree, and optimize the query plan, thereby speeding up the query execution speed and reducing the query execution time.

[0092] In another example, the target model may be a join order hint model (e.g., HyperQO), wherein the join order hint model may recommend join-order hints for join queries, adjust the join order when executing queries, thereby speeding up query execution and reducing query execution time.

[0093] In another example, the target model may be an automatic parameter tuning model (eg, a ByAutoTuner model), wherein the automatic parameter tuning model may be a query recommendation parameter to reduce the failure rate of query execution.

[0094] As mentioned above, the target query statement may be a selection query statement. In an embodiment of the present application, the selection query statement includes at least one parameter, and the at least one parameter is used to indicate the training data required for training the target model. The at least one parameter mentioned here may be an input parameter of the target UDMF. In this scenario, when S103 is implemented, the training data may be obtained from a database, and the target UDMF may be executed using the training data to train the target model.

[0095] In one example, the database supports a second programming language different from the first programming language, for example, the first programming language is Python, and the second programming language is C or C++. In this case, S103 can be implemented by Figure 2 The S1031-S1033 shown are implemented. Figure 2 A flowchart of a model training method provided in an embodiment of the present application.

[0096] S1031: Read the training data from the database into the memory of the database according to the parameters of the selection query statement, and obtain an object in a second programming language.

[0097] The database can read the field specified by the selection query statement from the database table specified by the selection query statement as the training data according to the parameters of the selection query statement, and store the read data in the memory. In the present application, since the database supports the second programming language, after the training data is read into the memory of the database, the training data will exist in the memory of the database in the form of an object using the second programming language. For example, the training data exists in the memory of the database in the form of a C object. Therefore, by reading the training data from the database into the memory of the database, an object of the second programming language can be obtained.

[0098] S1032: Convert the object in the second programming language into an object in the first programming language.

[0099] Since the target UDMF uses the first programming language, the target UDMF cannot directly use the object of the second programming language to train the target model. Specifically, in the scenario where the first programming language is python, the object of the python C-API operation of the aforementioned second function call is a python object (PyObject). Therefore, in the present application, after obtaining the object of the second programming language, the object of the second programming language can be converted to obtain the object of the first programming language.

[0100] Next, taking the first programming language as Python and the second programming language as C or C++ as an example, the implementation method of S1032 is introduced.

[0101] In an example, the training data may include multiple values, each value may correspond to a C object, and accordingly, during the specific implementation of S1032, each C object may be converted into a Python object respectively.

[0102] In another example, consider that Python objects store type information and reference counts in addition to values. But this design makes it unsuitable for processing large data. Since each PyObject has a reference count (64-bit integer) and type information (pointer), each object has a 16-byte overhead on a 64-bit system. This means that a single 4-byte integer requires 20 bytes of storage space. Since each PyObject must be allocated separately on the heap, it is very expensive to construct a large number of separate PyObjects. In view of this, in one example, instead of storing each individual value as a PyObject, an array can be used to store the value as a single PyObject. As a specific example, at least one array can be created for the aforementioned C object, each array carrying multiple values ​​in the training data, for example, an array is used to carry a certain type of value in the training data. Further, each array in the at least one array is converted into a PyObject respectively.

[0103] The array mentioned here may also be called a list. In an example, the array mentioned this time may be a NumPy (numerical python) array.

[0104] For example: for the input data of n columns, initialize a python list of size n through the python C-API PyList_New. Convert each column in inputs to a PyObject through the custom convert function, and then insert this column of data into the python list through the PyList_SetItem function. In the convert function, the data type of this column will be determined. If it is the target type (such as integer or floating point type), call the numpy C function interface PyArray_SimpleNewFromData to generate a numpy array of this type.

[0105] S1033: Train the target model using the object of the first programming language and the target UDMF.

[0106] After obtaining the object of the first programming language, the target UDMF can be executed to train the target model. As described above, the target UDMF includes a first function and a second function. Therefore, when S1033 is specifically implemented, the object of the first programming language can be used as a function input to execute the first function and the second function, thereby training the target model.

[0107] From the above description, it can be seen that by using the solution provided in the embodiment of the present application, the database can call the target UDMF function to implement the training of the AI4DB model, thereby integrating the AI4DB technology into the database architecture, rather than the AI4DB model being independent of the database architecture. Accordingly, when using AI4DB to improve the intelligence, automation and efficiency of the database system, the overhead caused by data interaction between the database and the AI4DB technical architecture can be effectively reduced, thereby improving database performance.

[0108] Exemplary Devices

[0109] Based on the method provided in the above embodiment, the embodiment of the present application further provides a device, which is described below in conjunction with the accompanying drawings.

[0110] See also Figure 3 , Figure 3 A schematic diagram of a training device for an AI4DB model provided in an embodiment of the present application. The device 300 is applied to a database, and the device 300 may specifically include: a receiving unit 301, a determining unit 302, and a training unit 303.

[0111] A receiving unit 301 is used to receive a target query statement, wherein the target query statement includes a target user-defined machine learning function;

[0112] A determination unit 302 is used to determine that the target user-defined machine learning function is a function using a first programming language, and to determine that the function type of the target user-defined machine learning function is a user-defined machine learning function, wherein: the first programming language is a programming language supported by the artificial intelligence model of the database, and the function type is a user-defined machine learning function, which is used to implement the training of the artificial intelligence model of the database;

[0113] The training unit 303 is used to call the target user's customized machine learning function to train the target model, and the target model is an artificial intelligence model of the database.

[0114] Optionally, the target user-defined machine learning function includes:

[0115] A first function that performs an add operation and a second function that performs a merge operation; wherein:

[0116] The first function is used to complete a model training operation based on input table information, where the table information includes table data and table meta-information;

[0117] The second function is used to aggregate results obtained by executing the first function multiple times.

[0118] Optionally, the input of the second function further includes meta information of the table, and the device further includes:

[0119] A storage unit, used for storing the meta information in a memory when executing the first function;

[0120] A reading unit is used to obtain the meta information from the memory and pass it to the second function when executing the second function.

[0121] Optionally, the determining unit 302 is configured to:

[0122] Calling the interface provided by the user-defined machine learning function management module to query the registration information of the target user-defined machine learning function;

[0123] According to the registration information, it is determined that the target user-defined machine learning function is a function using a first programming language, and it is determined that the function type of the target user-defined machine learning function is a user-defined machine learning function.

[0124] Optionally, the target query statement is a selection query statement, and a parameter of the selection query statement indicates training data required for training the target model; the training unit is used to:

[0125] According to the parameters of the selection query statement, the training data is read from the database into the memory of the database to obtain an object in a second programming language, wherein the second programming language is a programming language supported by the database and is different from the first programming language;

[0126] Converting the object in the second programming language into an object in the first programming language;

[0127] The target model is trained using the objects of the first programming language and the target user-defined machine learning function.

[0128] Optionally, the first programming language is Python, and the second programming language is C or C++, and converting an object in the second programming language into an object in the first programming language includes:

[0129] Creating at least one array for an object in the second programming language, each array carrying a plurality of values ​​in the training data;

[0130] Convert each array in the at least one array into an object of the first programming language.

[0131] Optionally, the target model includes:

[0132] Cardinality estimation model, join order prompt model, or automatic parameter adjustment model.

[0133] Since the device 300 is a device corresponding to the training method of the artificial intelligence model of the database provided by the above method embodiment, the specific implementation of each unit of the device 300 is the same concept as the above method embodiment. Therefore, regarding the specific implementation of each unit of the device 300, please refer to the relevant description part of the above method embodiment, which will not be repeated here.

[0134] The embodiment of the present application also provides an electronic device, the electronic device comprising a processor and a memory;

[0135] The processor is used to execute instructions stored in the memory so that the device executes the training method of the artificial intelligence model of the database provided in the above method embodiment.

[0136] An embodiment of the present application provides a computer-readable storage medium, including instructions, wherein the instructions instruct a device to execute the training method of the artificial intelligence model of the database provided in the above method embodiment.

[0137] An embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, it enables the computer to execute the training method of the artificial intelligence model of the database provided in the above method embodiment.

[0138] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0139] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

[0140] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims

1. A method for training an artificial intelligence model of a database, characterized in that: Applied to a database, the method comprises: Receive a target query statement, wherein the target query statement includes a target user-defined machine learning function; Determining that the target user-defined machine learning function is a function using a first programming language, and determining that the function type of the target user-defined machine learning function is a user-defined machine learning function, wherein: the first programming language is a programming language supported by the artificial intelligence model of the database, and the function type is a user-defined machine learning function, which is used to implement the training of the artificial intelligence model of the database; The target user-defined machine learning function is called to train a target model, where the target model is an artificial intelligence model of the database.

2. The method according to claim 1, characterized in that The target user-defined machine learning function includes: A first function that performs an add operation and a second function that performs a merge operation; wherein: The first function is used to complete a model training operation based on input table information, where the table information includes table data and table meta-information; The second function is used to aggregate results obtained by executing the first function multiple times.

3. The method according to claim 2, characterized in that The input of the second function also includes meta information of the table, and the method further includes: When executing the first function, storing the meta information in a memory; When the second function is executed, the meta information is obtained from the memory and passed to the second function.

4. The method according to claim 1, characterized in that: The step of determining that the target user-defined machine learning function is a function using a first programming language, and determining that the function type of the target user-defined machine learning function is a user-defined machine learning function, includes: Calling the interface provided by the user-defined machine learning function management module to query the registration information of the target user-defined machine learning function; According to the registration information, it is determined that the target user-defined machine learning function is a function using a first programming language, and it is determined that the function type of the target user-defined machine learning function is a user-defined machine learning function.

5. The method according to claim 1, characterized in that The target query statement is a selection query statement, and a parameter of the selection query statement indicates the training data required for training the target model; The calling of the target user-defined machine learning function to train the target model includes: According to the parameters of the selection query statement, the training data is read from the database into the memory of the database to obtain an object in a second programming language, wherein the second programming language is a programming language supported by the database and is different from the first programming language; Converting the object in the second programming language into an object in the first programming language; The target model is trained using the objects of the first programming language and the target user-defined machine learning function.

6. The method according to claim 5, characterized in that The first programming language is Python, the second programming language is C or C++, and converting an object in the second programming language into an object in the first programming language includes: Creating at least one array for an object in the second programming language, each array carrying a plurality of values ​​in the training data; Convert each array in the at least one array into an object of the first programming language.

7. The method according to claim 1, characterized in that The target model includes: Cardinality estimation model, join order prompt model, or automatic parameter adjustment model.

8. A training device for an artificial intelligence model of a database, characterized in that: Applied to a database, the device comprises: A receiving unit, configured to receive a target query statement, wherein the target query statement includes a target user-defined machine learning function; A determination unit, used to determine that the target user-defined machine learning function is a function using a first programming language, and to determine that the function type of the target user-defined machine learning function is a user-defined machine learning function, wherein: the first programming language is a programming language supported by the artificial intelligence model of the database, and the function type is a user-defined machine learning function, which is used to implement the training of the artificial intelligence model of the database; A training unit is used to call the target user's customized machine learning function to train a target model, where the target model is an artificial intelligence model of the database.

9. An electronic device, characterized in that: The device comprises a processor and a memory; The processor is configured to execute instructions stored in the memory so that the device executes the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The method comprises instructions, wherein the instructions instruct a device to execute the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and device for processing database query, electronic equipment and medium

    CN117874099A

  • Machine learning using query engines

    US20220147516A1

  • Method for implementing in-database artificial intelligence, and database system

    WO2023178977A1