Artificial intelligence real-time prediction method and device
By configuring the AI engine based on SQL statements and real-time AI metadata, the problem of insufficient usability of existing real-time AI prediction solutions is solved, and AI models from different modeling environments are seamlessly integrated, improving the usability and maintainability of real-time prediction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA MOBILE INFORMATION TECHNOLOGY CO LTD
- Filing Date
- 2022-04-01
- Publication Date
- 2026-06-19
AI Technical Summary
Existing real-time AI prediction solutions require code modification, testing, compilation, packaging, and deployment when business requirements change, resulting in insufficient usability and maintainability.
By obtaining physical plans and real-time AI metadata based on SQL statements, configuring the AI engine, and using the configured AI engine to make predictions on the data to be predicted, the code development of programming languages is avoided, and seamless integration of AI models in different modeling environments is supported.
It improves the usability and maintainability of real-time AI prediction solutions, reduces the cumbersome process of code modification and deployment, and enables data stream preprocessing and real-time prediction of AI models.
Smart Images

Figure CN116955385B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of IT application technology, and in particular to an AI real-time prediction method and apparatus. Background Technology
[0002] Traditional fraud prevention methods primarily rely on public education and awareness campaigns, which are passive approaches. Now, artificial intelligence (AI) technology is increasingly being applied. By using natural language processing on the voice recordings of unknown calls and the content of text messages, AI anomaly detection models are built to detect unusual and suspicious behavior in real time, thus preventing fraud.
[0003] From a development trend perspective, real-time computing and AI are increasingly being combined in the telecommunications industry, and various operators and technology solution providers are developing different types of technical solutions through continuous practice. Depending on the relationship between open-source real-time computing platforms and AI frameworks, common technical solutions now include: using their own platform's AI models, integrating third-party AI models, and using third-party AI prediction services.
[0004] The aforementioned technical solutions combining real-time computing and AI have solved the problem of real-time AI prediction to some extent. However, when business requirements change, the combination of real-time computing and AI using programming methods generally requires code modification, followed by a series of processes including unit testing, integration testing, compilation, packaging, submission to the pre-production environment, and finally to the computing engine in the production environment. This process suffers from insufficient usability. Summary of the Invention
[0005] This invention provides an AI real-time prediction method and apparatus to address the shortcomings of existing real-time AI prediction schemes in terms of ease of use.
[0006] This invention provides an artificial intelligence (AI) real-time prediction method, comprising:
[0007] Obtain the physical plan based on SQL statements associated with AI;
[0008] Based on the physical plan and real-time AI metadata, obtain the configured AI engine;
[0009] The configured AI engine is used to predict the data to be predicted and the prediction result is obtained; the amount of data to be predicted is dynamically adjusted according to the data backlog.
[0010] Optionally, obtaining the physical plan based on the SQL statement associated with AI includes:
[0011] The SQL statements associated with AI are parsed and optimized to obtain a logical plan;
[0012] The logical plan is transformed to obtain the physical plan.
[0013] Optionally, obtaining the configured AI engine based on the physical plan and real-time AI metadata includes:
[0014] According to the physical plan, obtain the external AI model runtime environment package information from the real-time AI metadata;
[0015] The external AI model runtime environment package is obtained from the AI model runtime environment package repository based on the external AI model runtime environment package information;
[0016] Configure the runtime environment of the AI engine according to the external AI model runtime environment package.
[0017] Optionally, obtaining the configured AI engine based on the physical plan and real-time AI metadata further includes:
[0018] External AI model information is obtained from the real-time AI metadata according to the physical plan;
[0019] The external AI model file is obtained from the external AI model file repository based on the external AI model information.
[0020] The AI engine is initialized based on the external AI model file.
[0021] Optionally, after obtaining the prediction result, the method further includes:
[0022] The prediction result is correlated with the data to be predicted to obtain new data to be predicted.
[0023] Optionally, it also includes:
[0024] Based on the real-time AI metadata, the SQL syntax is extended to obtain the AI real-time prediction syntax; the AI real-time prediction syntax includes the syntax structure for calling external AI models, the syntax structure for deleting external AI models, and the syntax structure for model prediction.
[0025] Optionally, the real-time AI metadata includes streaming metadata and external AI model metadata.
[0026] The present invention also provides an AI real-time prediction device, comprising:
[0027] The first acquisition module is used to obtain the physical plan based on SQL statements associated with AI;
[0028] The second acquisition module is used to acquire the configured AI engine based on the physical plan and real-time AI metadata;
[0029] The third acquisition module is used to use the configured AI engine to predict the data to be predicted and obtain the prediction result; the amount of data to be predicted is dynamically adjusted according to the data backlog.
[0030] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the AI real-time prediction method as described in any of the above.
[0031] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the AI real-time prediction method as described in any of the above.
[0032] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the AI real-time prediction method as described in any of the above.
[0033] The AI real-time prediction method and apparatus provided by this invention, by seamlessly integrating an AI framework based on SQL statements, supports AI models trained in different modeling environments, avoids the failure of AI models to execute due to environmental differences, and can realize data stream preprocessing and real-time AI model prediction without the need for code development using programming languages such as Java and Python, thereby improving the ease of use of real-time AI prediction solutions. Attached Figure Description
[0034] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0035] Figure 1 This is a flowchart illustrating the AI real-time prediction method provided by the present invention;
[0036] Figure 2 This is a schematic diagram of the overall framework of the AI real-time prediction method provided by the present invention;
[0037] Figure 3 This is a flowchart illustrating the AI engine management process provided by the present invention;
[0038] Figure 4 This is a schematic diagram of the real-time prediction process of the AI model provided by the present invention;
[0039] Figure 5This is a schematic diagram of the logical node structure and execution provided by the present invention;
[0040] Figure 6 This is a schematic diagram of the structure of the AI real-time prediction device provided by the present invention;
[0041] Figure 7 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0042] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0043] To facilitate a clearer understanding of the AI real-time prediction method provided by this invention, some relevant technical knowledge will be introduced as follows.
[0044] 1. Use the AI model of your own platform
[0045] In production environments, deploying real-time computing clusters inherently includes an AI framework. Spark is an open-source, batch-streaming integrated big data computing engine that dominates the batch processing field. Taking Spark Streaming (a batch-processing streaming computing framework) as an example, the Spark framework includes the Spark Machine Learning Libraries (Spark MLLib), which integrates a large number of machine learning algorithms. Models trained with Spark MLLib can be seamlessly used in Spark Streaming.
[0046] Such technical solutions are rarely used in production environments. Although real-time applications can be seamlessly integrated with their own platform's AI models, their built-in AI frameworks are rarely mainstream AI frameworks (such as Spark MLlib). AI modeling engineers usually choose deep learning frameworks such as TensorFlow (TensorFlow is Google's open-source deep learning framework) and need to use code to achieve real-time AI prediction.
[0047] 2. Integrate third-party AI models
[0048] In real-time computing applications, pre-trained AI models are integrated (the real-time computing engine is only responsible for using them, not for training). Taking an SMS anomaly model AI model as an example, a real-time computing application is written using Java, Scala, or Python to receive SMS content in real time, use the AI model to calculate the risk level of the SMS content, and if it is determined to be an abnormal SMS, the determination result is passed to the business system.
[0049] In this type of solution, the real-time computing development team is responsible for developing the real-time computing application and integrating and using the AI model within it, while the modeling team is only responsible for providing the AI model. The advantage is relatively high predictive performance, but it has the following disadvantages:
[0050] 1) Real-time computing is tightly coupled with AI models and cannot be scaled up independently;
[0051] 2) Implemented using coding development methods, it suffers from insufficient usability, poor maintainability, and high difficulty in migration and replication;
[0052] 3) AI models require code modifications or application restarts, resulting in long development cycles and the need for recompilation, packaging, and deployment.
[0053] 3. Use third-party AI prediction services
[0054] In real-time computing applications, the AI prediction service provided by the AI team is utilized. Taking the SMS anomaly AI model as an example, the AI model is deployed as a service, providing a remote service interface. Stream computing applications are written using programming languages such as Java and Scala to remotely call the AI prediction service interface for real-time prediction.
[0055] In this type of solution, real-time computing and AI are handled by two separate teams. The predictive service is deployed and maintained by the AI team, while the real-time computing team is responsible for developing real-time computing applications. The advantage is that real-time computing and AI services are independent and can be scaled independently. However, when dealing with the scale of real-time data in the telecommunications industry, the following problems arise:
[0056] 1) AI inference services often become a performance bottleneck;
[0057] 2) It is implemented using coding development, which is not easy to use, has poor maintainability, and is difficult to migrate and copy.
[0058] In summary, the above-mentioned technical solutions combining real-time computing and AI have solved the problem of real-time AI prediction to some extent. However, the application of real-time computing and AI using programming still has usability and maintainability issues. Using new AI models usually requires modifying the application, resulting in a long development cycle.
[0059] Figure 1This is a flowchart illustrating the AI real-time prediction method provided by the present invention, as shown below. Figure 1 As shown, this invention provides an AI real-time prediction method, which includes:
[0060] Step 101: Obtain the physical plan based on the SQL statement associated with AI.
[0061] Specifically, Figure 2 This is a schematic diagram of the overall framework of the AI real-time prediction method provided by the present invention, as shown below. Figure 2 As shown, it can be broadly divided into two parts: an AI real-time prediction engine and an execution engine. The AI real-time prediction engine includes a streaming SQL parsing and optimization engine, real-time AI metadata, a real-time computation and transformation module, an AI real-time prediction module, and an AI real-time prediction engine management module. The streaming SQL parsing and optimization engine is a combination of a Structured Query Language (SQL) parsing engine and a streaming computing engine.
[0062] The AI real-time computing SQL interface uses the JDBC (Java Database Connectivity) / ODBC (Open Database Connectivity) standard to implement the interaction interface. Real-time SQL applications can use JDBC / ODBC drivers to submit, stop, and delete computing tasks to the AI real-time prediction engine.
[0063] JDBC is a Java API (Application Programming Interface) for executing SQL statements. It provides unified access to various relational databases and consists of a set of classes and interfaces written in Java. The JDBC API is a database access interface standard proposed by Sun Microsystems and is a general-purpose API for accessing databases.
[0064] ODBC is a database-related component of Microsoft's Windows Open Services Architecture (WOSA). It establishes a set of specifications and provides a standard set of APIs for accessing databases. These APIs utilize SQL statements to accomplish most of their tasks. ODBC itself also provides support for the SQL language, allowing users to directly submit SQL statements to ODBC.
[0065] While most real-time computing engines offer standard JDBC support, they generally do not support ODBC, let alone SQL-based AI real-time prediction access. This invention uses standard JDBC / ODBC interfaces and supports SQL-based AI real-time prediction access, facilitating easy integration with third-party applications and opening up system capabilities.
[0066] The execution engine is the computing platform for task execution. The execution engine can use real-time computing engines, such as the scalable Flink. Flink is an open-source batch and stream computing engine that dominates the field of stream computing. The execution engine can also use machine learning engines, such as TensorFlow and SK-learn.
[0067] The real-time SQL application interacts with the AI real-time prediction engine through SQL statements associated with AI. The AI real-time calculation SQL interface in the AI real-time prediction engine receives the SQL statements associated with AI, and the streaming SQL parsing optimization engine and the real-time calculation conversion module process the SQL statements associated with AI to obtain the physical plan corresponding to the SQL statements associated with AI.
[0068] Optionally, a physical plan can be obtained based on SQL statements associated with AI, including:
[0069] Parse and optimize SQL statements related to AI to obtain logical plans;
[0070] Transform the logical plan to obtain the physical plan.
[0071] Specifically, the streaming SQL parsing and optimization engine parses and validates the SQL statements associated with AI, generates SQL nodes associated with AI, converts the valid SQL nodes associated with AI into SQL logical nodes associated with AI, and uses the SQL optimizer to optimize the SQL logical nodes associated with AI to obtain the logical plan corresponding to the SQL statements associated with AI.
[0072] After optimization, the logical plan is handed over to the real-time calculation and transformation module. The real-time calculation and transformation module is responsible for adapting to the underlying execution engine. The real-time calculation and transformation module converts the logical plan corresponding to the SQL statement associated with the AI into the physical plan corresponding to the SQL statement associated with the AI. The physical plan is executable code.
[0073] By parsing, optimizing, and transforming the SQL statements associated with AI, physical plans were obtained, laying the foundation for configuring the AI engine using physical plans in the future.
[0074] Optionally, it also includes:
[0075] The SQL syntax is extended based on real-time AI metadata to obtain the real-time AI prediction syntax; the real-time AI prediction syntax includes the syntax structure for calling external AI models, deleting external AI model syntax structures, and model prediction syntax structures.
[0076] Specifically, before performing real-time AI predictions based on SQL syntax, the SQL syntax needs to be extended. This extension requires real-time AI metadata, and the extension is achieved based on the attribute information within that metadata.
[0077] Optionally, real-time AI metadata includes streaming metadata and external AI model metadata.
[0078] Specifically, stream metadata is the metadata of a data stream, which is information describing the data stream.
[0079] Data streams are conceptually similar to tables. A data stream can be viewed as a table that continuously inserts data without deletion or update behavior.
[0080] Drawing inspiration from the structure of traditional metadata and considering the characteristics of data streams, a metadata structure for data streams was designed, including the data structure and connection information of the data stream. Real-time data streams frequently use semi-structured and unstructured data such as JSON, so the table field metadata supports descriptions of complex data structures. Table 1 shows the attribute table of the stream metadata, which includes the stream table name, stream table structure, and stream identifier attribute.
[0081] Table 1 Attribute Table of Stream Metadata
[0082] property describe Flow table name Name of data stream Flow table structure Similar to a traditional table structure, it includes field names, field types, etc. Flow table attributes Includes connection information for flow tables, such as Kafka Topic
[0083] External AI model metadata describes information about the external AI model. The storage and access capabilities of external AI model metadata are used to save the model's metadata. Table 2 is the attribute table of external AI model metadata. As shown in Table 2, the external AI model metadata includes the model type, model development language, model path, model input field types, prediction result field names, prediction result field types, and model runtime environment package.
[0084] Table 2 Attribute Table of External AI Model Metadata
[0085]
[0086] To manipulate real-time data using SQL, it is necessary to extend the syntax of streaming SQL at the SQL syntax level. The data stream syntax is obtained based on real-time AI metadata. The data stream syntax includes the syntax structure for creating data streams, the syntax structure for updating data streams, and the syntax structure for deleting data streams.
[0087] An example of the syntax structure for creating a data stream is shown below:
[0088] CREATE STREAM[IF NOT EXISTS] Flow table name(flow table fields…)
[0089] PROPERTIES (list of flow table properties);
[0090] An example of the syntax structure for updating a data stream is shown below:
[0091] ALTER STREAM flow_table_name SET PROPERTIES(flow_table_property_list);
[0092] An example of deleting a data stream syntax structure is shown below:
[0093] DROP STREAM IF EXISTS flow table name;
[0094] To use SQL for real-time AI prediction, it is necessary to extend the SQL syntax at the SQL syntax level and obtain the real-time AI prediction syntax based on real-time AI metadata. The real-time AI prediction syntax includes the syntax structure for calling external AI models, deleting external AI model syntax structures, and model prediction syntax structures.
[0095] An example of calling an external AI model syntax structure is shown below:
[0096] CREATE external MODEL model-name AS LOAD_EXTERNAL_MODEL(model-base-url,
[0097] language,
[0098] algorithm,
[0099] modules
[0100] model-init-function-full-name,
[0101] predict-function-full-name,
[0102] feature-columns,
[0103] runtime-url);
[0104] The configuration includes: `model-base-url`: the URL of the model folder (e.g., http / ftp / hdfs), which must contain at least two subdirectories: `model` (model folder) and `modules` (module folder); `language`: Python is supported; `algorithm`: the algorithm (an implementation prefix can be added for differentiation, e.g., `tf_decision_tree`); `modules`: the modules to be imported, separated by commas; `model-init-function-full-name`: the full name of the model initialization function; `predict-function-full-name`: the full name of the prediction function with the `module` prefix (if pandas batch calls are supported, the `batch` suffix should be added); `feature-columns`: the feature columns (optional, default is `features(doublearray)`, otherwise multiple comma-separated column names must be specified; the prediction data must have these columns); `runtime-url`: the URL of the runtime environment package, which the system uses to obtain the corresponding runtime environment package and create the appropriate runtime environment for the AI model.
[0105] An example of deleting the syntax structure of an external AI model is shown below:
[0106] Delete the external model name;
[0107] An example of the model's predicted syntax structure is shown below:
[0108] select * from real-time prediction function (external AI model name, data stream to be predicted);
[0109] SQL is a commonly used language for data analysis and processing in the telecommunications industry. Using SQL can significantly reduce the number of lines of code; modifications and debugging only require simple adjustments to the SQL statements, eliminating the need for cumbersome compilation, packaging, and deployment processes. Because SQL is standardized, job migration is easier, and it is also easier to understand.
[0110] Extending from SQL, this system enables real-time inference and prediction using AI models on data streams, eliminating the need for coding development in Java or Python. Numerous test cases have been written for the basic SQL operation logic, allowing users to focus solely on the correctness of the business logic. Changes in requirements can be easily mitigated by simply adjusting the SQL statements, making the entire process lightweight.
[0111] A model creation syntax was designed that allows models trained on different AI frameworks to be imported into the real-time computing platform. Model information is recorded in the AI metadata, and then the AI model can be conveniently used for real-time prediction in SQL. This avoids the cumbersome process of code modification, testing, compilation, packaging, and submission that real-time computing applications must go through when using new models.
[0112] Step 102: Obtain the configured AI engine based on the physical plan and real-time AI metadata.
[0113] Specifically, after obtaining the physical plan, the AI real-time prediction engine management module prepares the running environment for the AI engine based on the physical plan and real-time AI metadata, and the AI real-time prediction module initializes the AI engine based on the physical plan and real-time AI metadata, thereby obtaining the configured AI engine.
[0114] Optionally, based on the physical plan and real-time AI metadata, a configured AI engine is obtained, including:
[0115] Information about the external AI model runtime environment package is obtained from real-time AI metadata based on the physical plan;
[0116] The external AI model runtime environment package is obtained from the AI model runtime environment package repository based on the external AI model runtime environment package information;
[0117] Configure the AI engine's runtime environment based on the external AI model runtime environment package.
[0118] Specifically, in practical applications, the difference in version and module between the runtime environment used for AI modeling training and the runtime environment provided by the system can prevent external models from running in the runtime environment provided by the system.
[0119] For example, they use different AI frameworks, such as TensorFlow, PyTorch, and Sk-Learning.
[0120] For example, they may use different versions of the same framework. For instance, TensorFlow has multiple different versions, and these versions are not fully compatible.
[0121] For example, they use different versions of third-party modules, such as numpy, scipy, and pandas. The model training uses a newer version of numpy, while the system provides an older version of numpy. Their APIs may also differ.
[0122] Figure 3 This is a flowchart illustrating the AI engine management process provided by the present invention, such as... Figure 3 As shown, it is generally divided into 4 steps:
[0123] Step 301: The AI Engine Manager in the AI Real-time Prediction Engine Management Module reads the external AI model metadata from the AI metadata according to the physical plan. The external AI model metadata contains information about the external AI model runtime environment package, such as the storage location of the external AI model runtime environment package.
[0124] Step 302: The AI Engine Manager retrieves the external AI model runtime environment package from the AI model runtime environment package repository based on the read external AI model runtime environment package information.
[0125] The prerequisite for creating an AI model runtime environment package repository is that users package and upload AI model runtime environments. The AI model runtime environment package repository is created based on the AI model runtime environments packaged and uploaded by users.
[0126] If the external AI model runtime environment package has already been loaded by other operators or task processes, it can be reused; otherwise, the original external AI model runtime environment package should be obtained.
[0127] Step 303: The AI Engine Manager uses the acquired external AI model runtime environment package to configure the AI engine's runtime environment.
[0128] The AI engine has two startup methods: 1) If it is a programming language of the same type, the AI engine can be in the same process as the current operator; 2) Start a separate AI engine process. Using a separate process facilitates the isolation between jobs. The creation and destruction of the AI engine will not affect the operators of other jobs.
[0129] Step 304: The AI Engine Manager integrates the logic for starting, initializing, destroying, and cleaning up different AI engines. When an AI engine stops working, the AI Engine Manager terminates and destroys the AI engine to release resources.
[0130] By combining physical plans and real-time AI metadata with an AI model runtime environment package repository, external AI model runtime environment packages can be obtained. The runtime environment of the AI engine can be configured based on the external AI model runtime environment packages, which further facilitates the implementation of the configured AI engine.
[0131] Optionally, obtaining the configured AI engine based on the physical plan and real-time AI metadata further includes:
[0132] External AI model information is obtained from the real-time AI metadata according to the physical plan;
[0133] Retrieve external AI model files from an external AI model file repository based on external AI model information;
[0134] The AI engine is initialized based on external AI model files.
[0135] Figure 4 This is a schematic diagram of the real-time prediction process of the AI model provided by the present invention, such as... Figure 4 As shown, it is generally divided into 6 steps:
[0136] Step 401: The AI real-time prediction framework in the AI real-time prediction module reads the external AI model metadata from the AI metadata according to the physical plan. The external AI model metadata contains information about the external AI model, such as the storage path and development language of the external AI model.
[0137] Step 402: The AI real-time prediction framework submits relevant information from the external AI model to the AI engine and notifies the AI engine to initialize the model.
[0138] Step 403: The AI engine retrieves the external AI model file from the external AI model file repository according to the storage path of the external AI model, loads the external AI model file, initializes the model according to the external AI model file, and starts the Remote Procedure Call Protocol (RPC) prediction interface for the AI model.
[0139] With the AI engine's runtime environment configured, external AI model files are obtained through physical plans and real-time AI metadata, combined with an external AI model file repository. The AI engine's model is then initialized based on these external AI model files, thus realizing the configured AI engine.
[0140] Step 103: Use the configured AI engine to predict the data to be predicted and obtain the prediction result; the amount of data to be predicted is dynamically adjusted according to the data backlog.
[0141] Specifically, in step 404, the AI real-time prediction framework adaptively calls the RPC prediction interface in real time to pass a set of data to be predicted to the AI engine.
[0142] There are two types of invocation methods: synchronous and asynchronous.
[0143] 1) Synchronization blocks the thread, waiting for the prediction result to be returned, and then processes the next piece of data in the data stream;
[0144] 2) After an asynchronous call, there is no need to wait for the prediction result to be returned; the next piece of data in the data stream can continue to be processed.
[0145] Step 405: The AI engine returns the prediction results to the AI real-time prediction framework.
[0146] Step 406: When the AI real-time prediction task exits, shut down the AI engine.
[0147] The stream computing system has a backpressure mechanism. If the computational pressure on the downstream operator is too high and data backlog occurs, the backpressure mechanism will notify the upstream to reduce the amount of data sent or stop sending data.
[0148] The amount of data to be predicted is dynamically adjusted based on the data backlog. When data backlog causes back pressure, the amount of data to be predicted in each prediction RPC request is reduced; when there is no data backlog, the amount of data to be predicted in each prediction RPC request is increased. This dynamic adjustment of the amount of data to be predicted in AI prediction helps balance computational latency and computational pressure.
[0149] Optionally, after obtaining the prediction result, the method further includes:
[0150] The prediction results are correlated with the data to be predicted to obtain new data to be predicted.
[0151] Specifically, after the prediction result is returned, it is associated with the data to be predicted (the current data stream), which is similar to an association operation. After association, new data to be predicted is obtained. The new data to be predicted contains the original data to be predicted and its corresponding AI prediction result. The new data to be predicted is then pushed to the downstream for prediction.
[0152] Figure 5 This is a schematic diagram of the logical node structure and execution provided by the present invention, such as... Figure 5 As shown in the figure, the right side is an example of the execution logic of AI data prediction based on SQL. (1,2) is a real-time input event. 1 is used for prediction, and the prediction result is (1,101). Then, the prediction result is appended to the original input event to generate a new output data event (1,2,101). It can be seen that the execution of AI prediction based on SQL is a behavior similar to Join.
[0153] like Figure 5As shown in the diagram, the left side illustrates the structure of an AI logic node based on SQL. Essentially, the SQL-based AI data association logic node involves prediction logic and data association. Similar to an SQLJoin logic node, it has two inputs: logical planning nodes of other upstream standard SQL XX (logic planning nodes for filtering, projection, etc.) and a SQL-based AI real-time prediction execution logic node. The SQL XX logical planning nodes input real-time data streams into the SQL-based AI data association logic node, while the SQL-based AI real-time prediction execution logic node inputs real-time prediction result data streams into the SQL-based AI data association logic node. Finally, the SQL-based AI data association logic node outputs a real-time output data stream.
[0154] During real-time computing task execution, the computational steps of the task are parallelized. Each parallel computational step is called a computational step instance and is assigned to different physical nodes for execution. Each computational step instance initializes a dedicated AI engine process on its physical node. When prediction is needed, it interacts directly with the local AI engine process. The local RPC operating system optimizes the process to reduce CPU and network overhead caused by data serialization and deserialization, thereby reducing prediction latency and saving computing resources.
[0155] In real-time computing task execution, the real-time data stream is distributed relatively evenly to each computing step instance. When the computing pressure is high, the computing pressure of each computing step instance can be reduced by increasing the number of computing step instances, thus easily handling massive real-time data streams in real-time AI prediction.
[0156] The AI real-time prediction method provided by this invention seamlessly integrates an AI framework based on SQL statements, supports AI models trained in different modeling environments, avoids the inability of AI models to execute due to environmental differences, and can realize data stream preprocessing and AI model real-time prediction without the need for code development using programming languages such as Java and Python, thus improving the ease of use of real-time AI prediction solutions.
[0157] The AI real-time prediction device provided by the present invention will be described below. The AI real-time prediction device described below and the AI real-time prediction method described above can be referred to in correspondence.
[0158] Figure 6 This is a schematic diagram of the structure of the AI real-time prediction device provided by the present invention, as shown below. Figure 6 As shown, the present invention also provides an AI real-time prediction device, comprising: a first acquisition module 601, a second acquisition module 602, and a third acquisition module 603, wherein:
[0159] The first acquisition module 601 is used to acquire physical plans based on SQL statements associated with AI;
[0160] The second acquisition module 602 is used to acquire the configured AI engine based on the physical plan and real-time AI metadata;
[0161] The third acquisition module 603 is used to use the configured AI engine to predict the data to be predicted and obtain the prediction result; the amount of data to be predicted is dynamically adjusted according to the data backlog.
[0162] Specifically, the AI real-time prediction device provided in this application embodiment can implement all the method steps implemented in the above method embodiment and can achieve the same technical effect. Here, the parts that are the same as those in the method embodiment and the beneficial effects will not be described in detail.
[0163] Figure 7 This is a schematic diagram of the structure of the electronic device provided by the present invention, such as... Figure 7 As shown, the electronic device may include a processor 710, a communications interface 720, a memory 730, and a communication bus 740. The processor 710, communications interface 720, and memory 730 communicate with each other via the communication bus 740. The processor 710 can call logical instructions in the memory 730 to execute a real-time AI prediction method. This method includes: obtaining a physical plan based on SQL statements associated with AI; obtaining a configured AI engine based on the physical plan and real-time AI metadata; using the configured AI engine to predict the data to be predicted and obtaining the prediction result; the amount of data to be predicted is dynamically adjusted according to data backlog.
[0164] Furthermore, the logical instructions in the aforementioned memory 730 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0165] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the AI real-time prediction method provided by the above methods. The method includes: obtaining a physical plan based on an SQL statement associated with AI; obtaining a configured AI engine based on the physical plan and real-time AI metadata; using the configured AI engine to predict the data to be predicted and obtaining the prediction result; the amount of data to be predicted is dynamically adjusted according to the data backlog.
[0166] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the AI real-time prediction method provided by the above methods. The method includes: obtaining a physical plan based on an SQL statement associated with AI; obtaining a configured AI engine based on the physical plan and real-time AI metadata; using the configured AI engine to predict the data to be predicted and obtaining a prediction result; wherein the amount of data to be predicted is dynamically adjusted according to the data backlog.
[0167] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0168] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0169] In the embodiments of this application, the terms "first," "second," etc., are used to distinguish similar objects, and not to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first" and "second" are generally of the same class, and the number of objects is not limited; for example, the first object can be one or more.
[0170] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An AI real-time prediction method, characterized in that, include: Obtain the physical plan based on SQL statements associated with AI; Based on the physical plan and real-time AI metadata, obtain the configured AI engine; The configured AI engine is used to predict the data to be predicted, and the prediction results are obtained. The amount of data to be predicted is dynamically adjusted based on the data backlog situation; Also includes: Based on the real-time AI metadata, the SQL syntax is extended to obtain the real-time AI prediction syntax; the real-time AI prediction syntax includes the syntax structure for calling external AI models, the syntax structure for deleting external AI models, and the syntax structure for model prediction. 2.The AI real-time prediction method of claim 1, wherein, The process of obtaining the physical plan based on SQL statements associated with AI includes: The SQL statements associated with AI are parsed and optimized to obtain a logical plan; The logical plan is transformed to obtain the physical plan.
3. The AI real-time prediction method according to claim 1, characterized in that, The process of obtaining the configured AI engine based on the physical plan and real-time AI metadata includes: According to the physical plan, obtain the external AI model runtime environment package information from the real-time AI metadata; The external AI model runtime environment package is obtained from the AI model runtime environment package repository based on the external AI model runtime environment package information; Configure the runtime environment of the AI engine according to the external AI model runtime environment package. 4.The AI real-time prediction method of claim 3, wherein, The step of obtaining the configured AI engine based on the physical plan and real-time AI metadata also includes: External AI model information is obtained from the real-time AI metadata according to the physical plan; The external AI model file is obtained from the external AI model file repository based on the external AI model information. The AI engine is initialized based on the external AI model file. 5.The AI real-time prediction method of claim 1, wherein, After obtaining the prediction result, the process also includes: The prediction result is correlated with the data to be predicted to obtain new data to be predicted. 6.The AI real-time prediction method of claim 1, wherein, The real-time AI metadata includes streaming metadata and external AI model metadata.
7. An AI real-time prediction device, characterized by, include: The first acquisition module is used to obtain the physical plan based on SQL statements associated with AI; The second acquisition module is used to acquire the configured AI engine based on the physical plan and real-time AI metadata; The third acquisition module is used to use the configured AI engine to predict the data to be predicted and obtain the prediction result. The amount of data to be predicted is dynamically adjusted based on the data backlog situation; Also includes: The fourth acquisition module is used to extend the SQL syntax based on the real-time AI metadata to obtain the AI real-time prediction syntax; the AI real-time prediction syntax includes calling the syntax structure of external AI models, deleting the syntax structure of external AI models, and model prediction syntax structure.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the AI real-time prediction method as described in any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the AI real-time prediction method as described in any one of claims 1 to 6.