Model data backflow method, electronic equipment and device
Kong gateway receives and forwards the inference requests and results of the AI model, and decouples data collection and log generation in the cache queue, solving the synchronization impact and asynchronous complexity of data reflow in AI model inference, and realizing an efficient asynchronous model. Data reflow.
Patent Information
- Application Number
- CN202410797340.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-19
- Publication Date
- 2024-10-18
AI Technical Summary
In the existing technology, during the AI model inference process, data reflow has problems such as synchronization affecting performance, asynchronous need to modify the core code, and complicated data collection in concurrent scenarios, making it difficult to achieve efficient asynchronous model data reflow.
Receive inference requests through the Kong gateway, forward them to the AI model, record the inference requests and results in the cache queue, decouple the data collection and log generation processes, and use custom plug-ins to achieve efficient asynchronous data reflow.
It realizes data reflow without impact in high concurrency scenarios of AI model reasoning, simplifies code logic, and ensures data integrity and scalability.
Smart Images

Figure CN118796507A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a model data reflow method, electronic equipment and device. Background Art
[0002] AI (Artificial Intelligence) models are powerful tools for data analysis and decision-making that can be used by businesses and ordinary users. Through training, AI models can extract knowledge from historical data; through reasoning, they can apply this knowledge to new scenarios to make intelligent decisions. AI models have a wide range of applications in terms of reasoning. For example, they can act as virtual customer service, generate content such as articles, reports, advertisements, social media posts, perform language translation, or perform programming and technical support, medical and health consulting, market research and analysis, etc.
[0003] In the field of AI model reasoning, the collection of question-and-answer logs can also be called data reflow. Question-and-answer logs include requests made by users and responses made by AI models. The reflowed data can be reused in model training, model analysis, or other fields. Therefore, in the field of AI model reasoning, data reflow plays an important role. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a model data reflow method, electronic device and device to reflow the inference data of the AI model. The specific technical solution is as follows:
[0005] In a first aspect, an embodiment of the present application provides a model data reflow method, which is applied to a Kong gateway, and the method includes:
[0006] Receive the inference request sent by the user;
[0007] Forwarding the inference request to an inference service of an artificial intelligence AI model for processing the inference request;
[0008] Obtaining an inference result generated by the inference service in response to the inference request;
[0009] Recording the inference request and the inference result in a cache queue;
[0010] The cached data is extracted from the cache queue, and an inference log is generated based on the extracted data to achieve model data reflow.
[0011] In one embodiment of the present application, recording the inference request and the inference result in a cache queue includes:
[0012] Splitting the inference request and the inference result into different data bodies, wherein each data body includes a preset amount of data;
[0013] Record each data body in a cache queue;
[0014] The extracting the cached data from the cache queue and generating an inference log based on the extracted data to implement model data reflow includes:
[0015] The cached data bodies are extracted from the cache queue, and the extracted data bodies are spliced into complete original data according to the original data to which each data body belongs. An inference log is generated based on the spliced original data to realize model data reflow, wherein the original data includes an inference request and an inference result.
[0016] In one embodiment of the present application, each data body includes data contained in a token Token.
[0017] In one embodiment of the present application, the inference request and the inference result include inference information, and the inference information includes at least one of the following information: an identifier of the user terminal, an identifier of the inference service, a timestamp of the corresponding original data, and an identifier of the session to which it belongs, wherein the original data includes the inference request and the inference result, and the inference request and the inference result interacted between the same group of user terminals and the inference service belong to the same session;
[0018] The generating of the inference log based on the extracted data to realize the model data reflow includes:
[0019] According to the inference information, the extracted data belonging to the same session is merged into the same inference log to achieve model data reflow.
[0020] In one embodiment of the present application, after obtaining the inference result generated by the inference service in response to the inference request, the method further includes:
[0021] The inference result is sent to the user terminal.
[0022] In a second aspect, an embodiment of the present application provides an electronic device, on which a Kong gateway runs, and the electronic device includes:
[0023] processor;
[0024] Transceiver;
[0025] A machine-readable storage medium storing machine-executable instructions that can be executed by the processor; the machine-executable instructions prompt the processor to perform the following steps:
[0026] Receive the inference request sent by the user;
[0027] Forwarding the inference request to an inference service of an artificial intelligence AI model for processing the inference request;
[0028] Obtaining an inference result generated by the inference service in response to the inference request;
[0029] Recording the inference request and the inference result in a cache queue;
[0030] The cached data is extracted from the cache queue, and an inference log is generated based on the extracted data to achieve model data reflow.
[0031] In one embodiment of the present application, recording the inference request and the inference result in a cache queue includes:
[0032] Splitting the inference request and the inference result into different data bodies, wherein each data body includes a preset amount of data;
[0033] Record each data body in a cache queue;
[0034] The extracting the cached data from the cache queue and generating an inference log based on the extracted data to implement model data reflow includes:
[0035] The cached data bodies are extracted from the cache queue, and the extracted data bodies are spliced into complete original data according to the original data to which each data body belongs. An inference log is generated based on the spliced original data to realize model data reflow, wherein the original data includes an inference request and an inference result.
[0036] In one embodiment of the present application, each data body includes data contained in a token T0ken.
[0037] In one embodiment of the present application, the inference request and the inference result include inference information, and the inference information includes at least one of the following information: an identifier of the user terminal, an identifier of the inference service, a timestamp of the corresponding original data, and an identifier of the session to which it belongs, wherein the original data includes the inference request and the inference result, and the inference request and the inference result interacted between the same group of user terminals and the inference service belong to the same session;
[0038] The generating of the inference log based on the extracted data to realize the model data reflow includes:
[0039] According to the inference information, the extracted data belonging to the same session is merged into the same inference log to achieve model data reflow.
[0040] In one embodiment of the present application, the machine executable instructions further cause the processor to perform the following steps after obtaining the inference result generated by the inference service in response to the inference request:
[0041] The inference result is sent to the user terminal.
[0042] In a third aspect, an embodiment of the present application provides a model data reflow device, which is applied to a Kong gateway, and the device includes:
[0043] A request receiving module, used to receive an inference request sent by a user terminal;
[0044] A request forwarding module, used to forward the inference request to an inference service of an artificial intelligence AI model used to process the inference request;
[0045] A result obtaining module, used for obtaining the inference result generated by the inference service in response to the inference request;
[0046] A result recording module, used for recording the inference request and the inference result in a cache queue;
[0047] The log generation module is used to extract the cached data from the cache queue and generate an inference log based on the extracted data to achieve model data reflow.
[0048] In one embodiment of the present application, the result recording module is specifically used to:
[0049] Splitting the inference request and the inference result into different data bodies, wherein each data body includes a preset amount of data;
[0050] Record each data body in a cache queue;
[0051] The log generation module is specifically used for:
[0052] The cached data bodies are extracted from the cache queue, and the extracted data bodies are spliced into complete original data according to the original data to which each data body belongs. An inference log is generated based on the spliced original data to realize model data reflow, wherein the original data includes an inference request and an inference result.
[0053] In one embodiment of the present application, each data body includes data contained in a token T0ken.
[0054] In one embodiment of the present application, the inference request and the inference result include inference information, and the inference information includes at least one of the following information: an identifier of the user terminal, an identifier of the inference service, a timestamp of the corresponding original data, and an identifier of the session to which it belongs, wherein the original data includes the inference request and the inference result, and the inference request and the inference result interacted between the same group of user terminals and the inference service belong to the same session;
[0055] The log generation module is specifically used for:
[0056] The cached data is extracted from the cache queue, and the extracted data belonging to the same session is merged into the same inference log according to the inference information to realize the model data reflow.
[0057] In one embodiment of the present application, the device further includes:
[0058] A result sending module is used to send the inference result to the user terminal.
[0059] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any step of the method in the first aspect is implemented.
[0060] In a fifth aspect, an embodiment of the present application further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the methods described in the first aspect above.
[0061] Beneficial effects of the embodiments of the present application:
[0062] In the embodiment of the present application, the inference request sent by the user end can be received through the Kong gateway, and the Kong gateway can forward the inference request to the inference service of the AI model that matches the inference request, and obtain the inference result, and then store the inference request and the inference result in the cache queue, and then extract the cached data from the cache queue and generate an inference log. Since the inference log is generated based on the inference request and the inference result, the generated inference log can be applied to subsequent model training, model analysis, or other fields, which is equivalent to completing the model data reflow.
[0063] Moreover, since the Kong gateway can complete functional expansion through custom plug-ins, adding a program to the Kong gateway to complete the solution provided in the embodiment of the present application will not affect the original business code, and efficient asynchronous model data reflux can be achieved without affecting the AI model reasoning.
[0064] Furthermore, in the embodiment of the present application, a cache queue is used to temporarily store reasoning requests and reasoning results, so that the process of collecting reasoning requests and reasoning results into the cache queue is decoupled from the process of extracting data from the cache queue to generate reasoning logs. In a scenario where the AI model generates a large amount of data with high concurrency due to reasoning, the AI model will generate a large amount of data. In the related art, in order to ensure the effect of data reflow, the AI model needs to wait for the end of data reflow before continuing to the next round of reasoning after a large amount of data is generated by reasoning, so as to prevent the large amount of data generated from not being recorded and causing data loss. However, in the embodiment of the present application, since the process of data collection and generating reasoning logs is decoupled, the AI model can continue to reason, and the process of data reflow will not affect the reasoning of the AI model. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] 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 of the present application, and a person skilled in the art can also obtain other drawings based on these drawings.
[0066] Figure 1 A flow chart of a business tracking point provided in the related technology;
[0067] Figure 2 A schematic diagram of a flow chart of a first model data reflow method provided in an embodiment of the present application;
[0068] Figure 3 A schematic diagram of a flow chart of a second model data reflow method provided in an embodiment of the present application;
[0069] Figure 4 An architecture diagram of a model data reflow system provided in an embodiment of the present application;
[0070] Figure 5 A schematic diagram of a flow chart of a third model data reflow method provided in an embodiment of the present application;
[0071] Figure 6 A schematic diagram of a fourth model data reflow method provided in an embodiment of the present application;
[0072] Figure 7 A schematic diagram of a fifth model data reflow method provided in an embodiment of the present application;
[0073] Figure 8 A flowchart of a sixth model data reflow method provided in an embodiment of the present application;
[0074] Fig. 9 A flowchart of a seventh model data reflow method provided in an embodiment of the present application;
[0075] Fig.10 A schematic diagram of a process for generating an inference log provided in an embodiment of the present application;
[0076] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0077] Fig.12 A schematic diagram of the structure of a model data reflow device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0078] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions 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 based on the present application belong to the scope of protection of the present application.
[0079] In order to highlight the difference between the embodiments of the present application and the related art, the related art is first described.
[0080] The complete reasoning question-and-answer data collection in the related technology is essentially the log collection and data preservation of the request body and return body of HTTP (Hypertext Transfer Protocol) / HTTPS (Hypertext Transfer Protocol Secure) access. The common method of log collection is business tracking.
[0081] Business tracking refers to inserting specific codes or tags into the program for AI model reasoning on the server side to capture and record the client's behavior and the interaction data between the client and the server. These codes are usually added by developers to key touchpoints or events, such as the event that the server receives the client's reasoning request, the event that the server sends the reasoning result to the client, etc. Through business tracking, the specific behavior of the client on the server can be tracked and recorded, and events and attribute data can be generated, thereby realizing data reflow.
[0082] See also Figure 1 , which is a flow chart of a business tracking point provided in the related technology.
[0083] The left side of the figure shows the user side, which includes two user sides, user 1 and user 2. The two user sides send inference requests to the server side respectively. The server side runs an AI model, which is an AI model that generates text. The inference request sent by user1 includes user1's question "Hello". After the server side processes the inference request, the generated inference result includes the answer to the question "Hello! Is there anything I can help you with?". The inference request sent by user2 includes user2's question "hello". After the server side processes the inference request, the generated inference result includes the answer to the question "Sure! How can I assist you today?".
[0084] The dotted part in the figure represents the server's processing process of the inference request. Related technologies generally consider performing business tracking during this processing, so as to synchronously or asynchronously return data of the inference request and the inference result during the processing.
[0085] However, the application scenarios of AI models have the following characteristics:
[0086] 1. The amount of data for reasoning requests and reasoning results is often large, that is, the questions and answers of AI model reasoning generally have a large amount of data. For example, the questions of reasoning are often long text data or audio data, and the answers of reasoning can be long text data, images, videos, audio, etc.
[0087] 2. High concurrency, that is, there are often a large number of users requesting the server to perform AI model inference, so the server usually faces a large number of concurrent accesses.
[0088] The following problems may occur in data reflux in related technologies:
[0089] 1. If synchronous data reflow is used, the next data inference needs to be performed after each data reflow is completed. The large amount of data inference requests and inference results will cause the data reflow time to be longer, thus affecting the performance of AI model inference itself and reducing the user experience.
[0090] 2. If asynchronous data reflow is used, the core code of AI model reasoning needs to be modified, and the code for data reflow that is not required for AI model reasoning itself needs to be added. This violates the "single responsibility principle" in programming principles and reduces the scalability of the code.
[0091] 3. The inserted code snippet for data reflow requires additional interface return, which makes the logic of data reflow complicated. In high-concurrency scenarios, it is a big challenge for the server to accurately collect each inference request and inference result.
[0092] In order to solve the above problems, the embodiments of the present application provide a model data reflow method and device.
[0093] See also Figure 2 , is a flow chart of a first model data reflow method provided in an embodiment of the present application, the method includes the following steps S201-S205.
[0094] S201: receiving an inference request sent by a user terminal.
[0095] Among them, in the microservice architecture, there is usually a unified gateway for routing and forwarding, security authentication and authorization, monitoring and analysis, traffic control and current limiting, protocol conversion and format conversion. Kong Gateway is a commonly used API (Application Programming Interface) gateway with the characteristics of high flexibility, good scalability, reliable performance, high support from the open source community, and easy deployment and management. In the Kong Gateway, custom plug-ins can be used to update functions without affecting the original functions of the gateway. Global plug-ins and business plug-ins can be integrated in the Kong Gateway. In this application, the Kong Gateway is selected, and the functions that the Kong Gateway needs to implement in the embodiment of this application are implemented through plug-ins. Thereby, the impact of the collection of business embedding methods on the reasoning performance can be reduced.
[0096] In one embodiment of the present application, when a user-side inference request is triggered, the inference request will first reach the Kong gateway, which will first perform security authentication and authorization, specify other custom plug-ins, and then route and forward the inference request to the specified inference service.
[0097] Specifically, the API functions of the Kong gateway are usually implemented based on the OpenResty module and the Lua language.
[0098] The OpenResty module is a high-performance Web (World Wide Web) platform based on Nginx, which integrates LuaJIT (Just-In-Time Compiler for Lua) and packages a series of useful Nginx modules. OpenResty extends Nginx through Lua language scripts, and can quickly add new features without modifying the core code of Nginx.
[0099] Nginx is a high-performance HTTP and reverse proxy server. It is also an IMAP (Internet Message Access Protocol) / POP3 (Post Office Protocol-Version 3) / SMTP (Simple Mail Transfer Protocol) proxy server. It is widely used in static content services, load balancing, reverse proxy, API gateway and other scenarios of websites. The functions of Nginx can be extended through C modules.
[0100] Kong Gateway is an open source API gateway and microservice management layer, mainly used to manage, monitor and protect API traffic. Kong Gateway is built on OpenResty module, using Lua script and OpenResty module's module system to implement its core functions and plug-in mechanism. Users can extend the functionality of Kong Gateway by writing Lua scripts, or use existing plug-ins in Kong Gateway.
[0101] In addition, the Kong gateway needs to be initialized before implementing the functions of the embodiment of the present application. In the initialization phase, the master process needs to be started preloaded, and the worker process needs to be generated preloaded.
[0102] The master process starts preloading through the init_by_lua function preset in the Kong gateway. This function runs in the Nginx loading-config phase, registers Nginx Lua global variables and preloads modules, and is the function executed by the master process when loading the Nginx configuration.
[0103] Worker process preloading can be achieved through the init_worker_by_lua function preset in the Kong gateway. Each worker process calls this function when it starts. It is usually used to hook the worker process and create a timer for the worker process to perform health checks.
[0104] Specifically, the above reasoning request will enter the Kong gateway after passing through the Nginx proxy. If the gateway is initialized in advance, the Kong gateway can implement steps S201-S202.
[0105] In addition, the above-mentioned reasoning request may be a request for the AI model to answer a question, a request to generate or modify an image, a request to generate or modify a video, a request to translate the text or audio carried in the reasoning request, etc.
[0106] S202: Forward the above-mentioned inference request to the inference service of the AI model used to process the above-mentioned inference request.
[0107] Specifically, the Kong gateway can route the inference request to the inference service of the AI model used to process the inference request according to pre-configured rules. Different inference services are used to implement different AI model inference functions.
[0108] The above-mentioned preset rules can be represented by the correspondence between the AI model reasoning function and the reasoning service, for example, the function of generating or modifying an image corresponds to reasoning service 1, the function of answering a question corresponds to reasoning service 2, etc. After receiving the reasoning request, the reasoning service used to process the above reasoning request can be determined according to the function indicated by the reasoning request.
[0109] After determining the inference service, the Kong gateway can forward the inference request to the inference service according to the URL (uniform resource location) of the inference service.
[0110] The above step S202 can be called the rewrite access phase, which implements forwarding of the inference request and authority judgment. Forwarding of the inference request refers to forwarding the inference request to the inference service, and authority judgment refers to judging the authority of the inference request and whether the service required by the inference request can be obtained.
[0111] The process starts when the Kong gateway receives the inference request. After requeststart, the Kong gateway determines whether the request is a Secure request. If so, the ssl_certificate_by_lua function of the Kong gateway threshold is used to process the request, and then the set_by_lua function initializes the branch processing. If the request is not a Securerequest, the set_by_lua function directly initializes the branch processing. After that, the rewrite_by_lua function forwards, rewrites, and redirects the inference request, and the access_by_lua function centrally processes the access and interface permissions. Step S202 is thus implemented.
[0112] In addition, it should be noted that the Kong gateway and inference service are both virtual services. Both can run on the same electronic device or on different electronic devices that communicate with each other.
[0113] S203: Obtain the inference result generated by the inference service in response to the inference request.
[0114] Specifically, after receiving the inference request, the inference service may generate an inference result based on the inference request. After generating the inference result, the inference service may feed the inference result back to the Kong gateway.
[0115] After receiving the inference result, the Kong gateway may not process the inference result, or may filter the header (data header) and / or body (data body) of the inference result.
[0116] Filtering the header may include modifying the destination address contained in the header of the inference result to send the inference result to the modified destination address. In addition, the header of the above-mentioned inference result may also include one or more of the user terminal information, the inference service information, and the dialogue identifier. The user terminal information is used to indicate the user terminal that triggered this inference, the inference service information indicates the inference service that processes this inference, and the dialogue identifier is used to indicate the session to which this inference belongs. During a conversation, the same user terminal and the same AI model can have multiple rounds of conversations, and the conversation identifiers of the conversations belonging to the same conversation are the same. The Kong gateway can modify one or more of the user terminal information, the inference service information, and the dialogue identifier.
[0117] Filtering the body may include modifying the content contained in the body of the inference result, which is the content generated by the AI model for the inference request. The specific modification may be deleting, replacing, or blocking the illegal content contained in the body.
[0118] In addition, the amount of data generated by AI model reasoning is often large. Therefore, in order to reduce the memory consumption of AI model reasoning and reduce the reasoning time, streaming is usually used to feed data back to the user end. To this end, the Kong gateway can also filter the body and perform streaming conversion on the content contained in the body to obtain a data stream. For details, the process of streaming conversion can be seen below. Figure 5 The content shown will not be described in detail here.
[0119] In one embodiment of the present application, after obtaining the inference result, the Kong gateway first determines the source of the generated content (Content generated by?). If the content is generated by lua, the inference result is processed by the content_by_lua function in the Kong gateway, and then the header filtering process is performed by the header_filter_by_lua function. If the content is generated by the Upstream module, the inference result is processed by the balancer_by_lua function in the Kong gateway, and then the header filtering process is performed by the header_filter_by_lua function. If it comes from other commands (other directives), the header filtering process is performed directly through the headerfilter_by_lua function. Then the body filtering process is performed through the body_filter_by_lua function. In addition, it should be noted that the header filtering process and the body filtering process may not be performed, or at least one may be selected for execution according to actual needs.
[0120] S204: Record the above inference request and the above inference result in a cache queue.
[0121] The above-mentioned cache queue can be a Kafka queue. The Kafka queue has the advantages of high throughput, low latency, scalability, persistence, reliability, data stream processing capabilities, and compatibility with modern data architectures, and can handle large amounts of data streams. It can process millions of messages per second, and the delay from the producer (i.e., the module that writes data) to the consumer (i.e., the module that uses the data) is usually at the millisecond level. It is suitable for use in scenarios with high concurrency and large amounts of data for the AI model in this application.
[0122] In one embodiment of the present application, the Kong gateway can use a timer to periodically record the collected inference requests and inference results in a cache queue. The timer can be a timer preset by Nginx.
[0123] When writing data into the cache queue, the data is written to the tail of the queue in accordance with the first-in-first-out principle of the queue.
[0124] In addition, there may be multiple cache queues. For example, when the cache queue is a Kafka queue, there may be multiple partitions in the topic of the Kafka queue, which means there are multiple cache queues. When writing data, the embodiment of the present application can randomly select any cache queue for writing, or write the data to the queue containing the least data.
[0125] S205: extracting cached data from the cache queue, and generating an inference log based on the extracted data to achieve model data reflow.
[0126] Specifically, the above S205 may be executed after receiving an instruction from a consumer to consume a message. The above consumer is a module that uses data. For example, the consumer may be a module that needs to use inference requests and inference results for model training and model analysis.
[0127] Alternatively, when the amount of data cached in the cache queue reaches a preset amount of data, step S205 is executed. Furthermore, step S205 may also be executed once after each preset period.
[0128] In one embodiment of the present application, a group of mutually corresponding inference requests and inference results can be extracted from the cache queue and written into the inference log to achieve model data reflow.
[0129] In addition, the generated reasoning logs can be stored in a database, so as to realize data solidification for subsequent use. For example, the above database can be a Mysql database, a Redis database, an NFS (Network File System), a GPFS (General Parallel File System), a RocketMQ database, etc.
[0130] Specifically, the log can be generated by the log_by_lua function preset by the Kong gateway. In addition, the AI model reasoning process and the log generation process in the embodiment of the present application are two processes that can be executed independently, so the log in the embodiment of the present application is generated asynchronously.
[0131] As can be seen from the above, in the embodiment of the present application, the inference request sent by the user end can be received through the Kong gateway, and the Kong gateway can forward the inference request to the inference service of the AI model that matches the inference request, and obtain the inference result, and then store the inference request and the inference result in the cache queue, and then extract the cached data from the cache queue and generate an inference log. Since the inference log is generated based on the inference request and the inference result, the generated inference log can be applied to subsequent model training, model analysis, or other fields, which is equivalent to completing the model data reflow.
[0132] Moreover, since the Kong gateway can complete functional expansion through custom plug-ins, adding a program to the Kong gateway to complete the solution provided in the embodiment of the present application will not affect the original business code, and efficient asynchronous model data reflux can be achieved without affecting the AI model reasoning.
[0133] In addition, since the content required by the embodiment of the present application can be completed by adding a custom plug-in, the code logic of the embodiment of the present application is relatively simple and can accurately collect each inference request and inference result.
[0134] Furthermore, in the embodiment of the present application, a cache queue is used to temporarily store reasoning requests and reasoning results, so that the process of collecting reasoning requests and reasoning results into the cache queue is decoupled from the process of extracting data from the cache queue to generate reasoning logs. In a scenario where the AI model generates a large amount of data with high concurrency due to reasoning, the AI model will generate a large amount of data. In the related art, in order to ensure the effect of data reflow, the AI model needs to wait for the end of data reflow before continuing to the next round of reasoning after a large amount of data is generated by reasoning, so as to prevent the large amount of data generated from not being recorded and causing data loss. However, in the embodiment of the present application, since the process of data collection and generating reasoning logs is decoupled, the AI model can continue to reason, and the process of data reflow will not affect the reasoning of the AI model.
[0135] See also Figure 3 , is a flow chart of the second model data reflow method provided in the embodiment of the present application, including the initialization phase, the rewrite access phase, the content generation phase, and the log phase.
[0136] The initialization phase corresponds to the content described in the aforementioned step S201, the rewrite access phase corresponds to the content described in the aforementioned step S202, the content generation phase corresponds to the content described in the aforementioned step S203, and the log phase corresponds to the content described in the aforementioned step S205.
[0137] See also Figure 4 , which is an architecture diagram of a model data reflow system provided in an embodiment of the present application.
[0138] The diagram includes the application layer, access layer, service layer, and storage layer.
[0139] The application layer includes PC (Personal Computer), Android client, IOS client, applets and other user terminals.
[0140] The access layer includes units for load balancing, units for security protection, and the Kong gateway.
[0141] The unit for load balancing is used to implement hardware load balancing, Nginx, DNS (Domain Name System), and IP access control.
[0142] The Kong gateway contains global plug-ins and business plug-ins. The global plug-ins include plug-ins for identity authentication, interface signature, access behavior tracking, and Session management. Business plug-ins include plug-ins for request header rewriting, request verification, route log collection, and route rewriting. The plug-in for request header rewriting can be used to implement the aforementioned header filtering process, the plug-in for request verification can be used to implement the verification of inference requests, the plug-in for route log collection can realize the collection of inference requests and inference results and the generation of inference logs, and the plug-in for route rewriting can realize the forwarding of inference requests to the inference service.
[0143] The security protection unit can be used for attack protection, data protection and SLA (Service-Level Agreement) reporting.
[0144] The service layer includes units for user services, units for file services, units for AI asset services, units for billing services, units for monitoring services, units for resource limit services, units for report management, a Kubernetes unified scheduling middle platform, and units for user job management.
[0145] The unit used for user services can be used for user management, user rights management, and Oauth authentication.
[0146] The unit for performing file services can be used for file management, sharing management, and SFTP (Secret File Transfer Protocol) uploading.
[0147] The units used for AI asset services can be used for model management, algorithm management, and image management.
[0148] The unit used for billing services can be used for annual and monthly package management, real-time billing management, and prepaid management.
[0149] The unit used for monitoring services can be used for Prometheus, Grafana, and gpu-exporter.
[0150] The unit for performing resource quota service may be used for performing AI resource quota management.
[0151] The unit for performing report management may be used to manage resource utilization reports.
[0152] The unit used for user job management can be used for model reasoning, model training, model fine-tuning, model evaluation, development environment management, and visual modeling.
[0153] The storage layer includes Mysql database, Redis database, NFS, GPFS, RocketMQ database, and Kafka queue.
[0154] Since AI models often use streaming to feedback inference results to the user end, that is, the inference results are split into data bodies and then sent to the user end in sequence, if there is such a requirement, the following can be performed: Figure 5 The embodiment shown.
[0155] See also Figure 5 , is a flow chart of a third model data reflow method provided in an embodiment of the present application, which is similar to the aforementioned Figure 2 Compared with the illustrated embodiment, the above step S204 can be implemented by the following steps S204A-S204B, and the above step S205 can be implemented by the following step S205A.
[0156] S204A: Split the above inference request and the above inference result into different data bodies.
[0157] Each data body includes a preset amount of data.
[0158] In one embodiment of the present application, whether the inference result and the inference request need to be split into different data bodies can be determined based on the identifier carried in the body of the inference result.
[0159] For example, the identifier carried in the above body can be the content-type field to determine whether the return of this call is a streaming return or a normal return. When the content-type value is application or json, it means that this call is a normal call; when the content-type value is event or stream, it means that this call is a streaming call.
[0160] If it is a streaming return, then steps S204A-S204B and S205A are executed. If it is a normal return, then there is no need to perform subsequent processing on the inference result and the inference request.
[0161] The above step S204A can be implemented through the aforementioned body filtering.
[0162] In addition, if the content included in the above inference result and the inference request is text, the above preset data amount can be the data amount of one word, the data amount of one character, the data amount of one Chinese character, the data amount of two Chinese characters, etc. If the content included in the above inference result or inference request is an image, audio or video, the above preset data amount can be 5 bytes, 10 bytes, etc.
[0163] For example, if the content contained in the normal return is "Hello", the content contained in the split data body during the streaming return is "You" and "Good" respectively.
[0164] In another embodiment of the present application, each data body includes data contained in a Token. The amount of data contained in each Token is a preset amount of data, and the amount of data contained in each Token is predefined by the AI model.
[0165] S204B: Record each data body in the cache queue.
[0166] Specifically, the method of recording the data body in the cache queue is similar to the aforementioned step S204, the only difference is that what is cached here is the data body, and what is cached in step S204 is the unsplit inference request and inference result, which will not be repeated here.
[0167] S205A: extracting cached data bodies from the cache queue, splicing the extracted data bodies into complete original data according to the original data to which each data body belongs, and generating an inference log based on the spliced original data to achieve model data reflow.
[0168] The above raw data includes inference requests and inference results.
[0169] If the data stored in the above cache queue is a split data body, the data contained in each data body is not a complete reasoning request or reasoning result. Therefore, before generating the reasoning log, the data body needs to be spliced into complete original data, and then the original data for recording the reasoning log is generated.
[0170] As can be seen from the above, in the embodiment of the present application, the Kong gateway can split the inference results and inference requests to meet the needs of the AI model to send data to the user end in a streaming return manner. And after the inference results and inference requests are split to obtain the data body, the data body can also be spliced when the inference log needs to be generated, so that the data recorded in the generated inference log is complete original data.
[0171] See also Figure 6 , is a flow chart of a fourth model data reflow method provided in an embodiment of the present application, which is similar to the aforementioned Figure 2Compared with the embodiment shown, after the above step S203, the following step S206 is also included.
[0172] S206: Send the above inference result to the above user terminal.
[0173] Based on the above-mentioned normal return and streaming return, if the identifier carried in the body of the inference result indicates that the return of this call is a streaming return, the inference result is split using the above-mentioned step S204A, and then the data body is sent to the user end in the order of the data body.
[0174] If the identifier carried in the body of the inference result indicates that the return of this call is a normal return, the inference result is sent directly to the user end.
[0175] From the above, it can be seen that in addition to realizing the model data reflow, the Kong gateway in the embodiment of the present application can also feedback the inference results to the user end that requests AI model inference.
[0176] See also Figure 7 , is a flow chart of a fifth model data reflow method provided in an embodiment of the present application, in the aforementioned Figure 4 Based on the architecture shown, the service layer includes a unit for log management, which is used to implement the log processing of the aforementioned step S205, showing the process of implementing the model data backflow and feeding back the inference results to the user end. Figure 4 compared to, Figure 7 The following steps 1 to 7 are also included.
[0177] Step 1: The user in the application layer initiates an inference request to the Kong gateway.
[0178] Step 2: The Kong gateway forwards the inference request to the model inference service.
[0179] Step 3: The model inference service returns the inference result to the Kong gateway.
[0180] Step 4: The Kong gateway returns the inference result to the user end in the application layer.
[0181] Step 5: The model inference service records the inference request and inference result in the Kafka queue.
[0182] Step 6: The log management unit performs log processing to generate an inference log.
[0183] Step 7: Store the inference log in the MySQL database.
[0184] Specifically, the implementation of steps 1 to 7 can be found in the previous description and will not be repeated here.
[0185] See also Figure 8 , is a flow chart of a sixth model data reflow method provided in an embodiment of the present application, Figure 8 By Figure 4 The architecture shown here is after removing the access layer and Figure 3 The embodiments shown are combined, on this basis, additional steps one to five are added, as well as detailed steps a to e for performing reasoning request and reasoning result splitting (i.e., performing body filtering).
[0186] Specifically, step 1: the user in the application layer sends an inference request to the Kong gateway.
[0187] Step 2: The Kong gateway completes the rewrite access phase and forwards the inference request to the model inference service.
[0188] Step 3: The model inference service processes the inference request and feeds back the inference result to the Kong gateway, so that the Kong gateway enters the content generation stage.
[0189] Step 4: The Kong gateway feeds back the inference results to the user end in the application layer.
[0190] Step 5: In the logging phase, the generated inference logs are stored in the storage layer.
[0191] Step a: Obtain the attribute information contained in the inference request and inference result.
[0192] The attribute information includes the request header (header in the inference request) and request body (body in the inference request) in the inference request, the response header (header in the inference result) and response body (body in the inference result) in the inference result, and the request timestamp.
[0193] Step b: Determine whether streaming return is required.
[0194] If yes, go to step c, otherwise go to step d.
[0195] Step c: Split the inference results and inference requests into streaming data.
[0196] Step d: Keep the original inference results and inference requests.
[0197] Step e: Send data asynchronously to the Kafka queue.
[0198] If the inference results and inference requests are split into streaming data, the streaming data is integrated into a data group and sent to the Kafka queue. If the inference results and inference requests are not streaming data, the data is directly sent to the Kafka queue.
[0199] Specifically, the method of splitting the data and the method of interaction between the Kong gateway, the user terminal and the reasoning service can be referred to the aforementioned embodiment, which will not be repeated here.
[0200] Furthermore, since the conversation between the user terminal and the reasoning service may be composed of multiple conversations, for example, the user terminal and the reasoning service have multiple conversations on the same issue in a short period of time, one conversation will contain multiple reasoning requests and multiple reasoning results. When generating an reasoning log, the multiple reasoning requests and multiple reasoning results contained in one conversation can be recorded in the same reasoning log for subsequent use.
[0201] In this case, the above-mentioned inference request and inference result include inference information, and the above-mentioned inference information includes at least one of the following information: the identification of the above-mentioned user terminal, the identification of the above-mentioned inference service, the timestamp of the corresponding original data, and the identification of the session to which it belongs.
[0202] The above raw data includes inference requests and inference results. The inference requests and inference results interacting between the same group of user terminals and the inference service belong to the same session.
[0203] Specifically, the identifier of the user terminal may be the triggering person information, and the identifier may be the number of the user terminal, the user name, the address of the user terminal, etc.
[0204] The identifier of the above-mentioned reasoning service may be reasoning service information, and the identifier may be a number of the reasoning service, a name of the reasoning service, an address of the reasoning service, etc.
[0205] The timestamp of the original data is the timestamp of the time when the inference request or inference result is generated.
[0206] Different sessions have different identifiers, and the session identifier can be represented in the form of numbers, characters, etc.
[0207] In addition, the inference requests and inference results exchanged between the same group of users and the inference service within a preset time period belong to the same session. Or the inference requests and inference results exchanged between the user terminal and the inference service from the first time the user terminal sends an inference request to the inference service until the connection with the inference service is disconnected belong to the same session.
[0208] See also Fig. 9 , is a flow chart of the seventh model data reflow method provided in the embodiment of the present application, which is similar to the aforementioned Figure 2 Compared with the embodiment shown, the above step S205 can be implemented by the following step S205B.
[0209] S205B: According to the inference information, the extracted data belonging to the same session are merged into the same inference log to achieve model data reflux.
[0210] In one embodiment of the present application, the inference requests and inference results interacting between the same group of user terminals and the inference service can be identified based on the identifier of the user terminal and the identifier of the inference service. In addition, since there may be multiple sessions between the same group of user terminals and the inference service, the inference requests and inference results interacting between the same group of user terminals and the inference service that belong to the same session can be identified based on the identifier of the session to which they belong.
[0211] In addition, the inference requests and inference results of the interaction between the same group of users and the inference service can be sorted according to the timestamp of the original data. The sorting can be done in order from the front to the back according to the timestamp, thereby restoring the process of interaction between the user and the inference service.
[0212] It should be noted that since there may be multiple cache queues, the inference requests and inference results belonging to the same session may be stored in different cache queues. Although the data access of the cache queue follows the first-in-first-out principle, the amount of data stored in different cache queues is different, and the speed of retrieving data from the cache queue is different. Therefore, the inference requests and inference results belonging to the same session written to different cache queues within a time period may not be taken out of the cache queues in the order in which the sessions occurred. Therefore, in this case, the inference requests and inference results can be sorted based on timestamps.
[0213] See also Fig.10 , is a flow chart of generating an inference log provided in an embodiment of the present application, including the following steps A1 to A8.
[0214] Step A1: Extract data from the cache queue.
[0215] Step A2: Extract the identifier of the inference service.
[0216] Step A3: Extract the user terminal's identifier.
[0217] Step A4: Extract timestamp.
[0218] Step A5: Determine whether it is streaming data.
[0219] If yes, go to step A6, otherwise go to step A7.
[0220] Step A6: Splice the data.
[0221] After executing step A6, proceed to step A7.
[0222] Step A7: Extract the session identifier.
[0223] Step A8: Record the data belonging to the same session in the same inference log.
[0224] As can be seen from the above, in the embodiment of the present application, the reasoning requests and reasoning results belonging to the same session can be identified based on the reasoning information, so that the reasoning requests and reasoning results belonging to the same session can be stored in an reasoning log, so that when the reasoning log is used later, all the reasoning requests and reasoning results contained in a session can be obtained at one time, which is convenient for subsequent use and processing.
[0225] Corresponding to the aforementioned model data reflow method, an embodiment of the present application also provides an electronic device.
[0226] See also Fig.11 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, on which a Kong gateway runs, and the electronic device includes:
[0227] Processor 1101;
[0228] transceiver 1104;
[0229] A machine-readable storage medium 1102 storing machine-executable instructions that can be executed by the processor; the machine-executable instructions prompt the processor to perform the following steps:
[0230] Receive the inference request sent by the user;
[0231] Forwarding the inference request to an inference service of an artificial intelligence AI model for processing the inference request;
[0232] Obtaining an inference result generated by the inference service in response to the inference request;
[0233] Recording the inference request and the inference result in a cache queue;
[0234] The cached data is extracted from the cache queue, and an inference log is generated based on the extracted data to achieve model data reflow.
[0235] like Fig.11As shown, the network device may further include a communication bus 1103. The processor 1101, the machine-readable storage medium 1102, and the transceiver 1104 communicate with each other through the communication bus 1103. The communication bus 1103 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus 1103 may be divided into an address bus, a data bus, a control bus, etc.
[0236] The transceiver 1104 may be a wireless communication module. Under the control of the processor 1101 , the transceiver 1104 exchanges data with other devices.
[0237] The machine-readable storage medium 1102 may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk storage. In addition, the machine-readable storage medium 1102 may also be at least one storage device located away from the aforementioned processor.
[0238] Processor 1101 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0239] As can be seen from the above, in the embodiment of the present application, the inference request sent by the user end can be received through the Kong gateway, and the Kong gateway can forward the inference request to the inference service of the AI model that matches the inference request, and obtain the inference result, and then store the inference request and the inference result in the cache queue, and then extract the cached data from the cache queue and generate an inference log. Since the inference log is generated based on the inference request and the inference result, the generated inference log can be applied to subsequent model training, model analysis, or other fields, which is equivalent to completing the model data reflow.
[0240] Moreover, since the Kong gateway can complete functional expansion through custom plug-ins, adding a program to the Kong gateway to complete the solution provided in the embodiment of the present application will not affect the original business code, and efficient asynchronous model data reflux can be achieved without affecting the AI model reasoning.
[0241] Furthermore, in the embodiment of the present application, a cache queue is used to temporarily store reasoning requests and reasoning results, so that the process of collecting reasoning requests and reasoning results into the cache queue is decoupled from the process of extracting data from the cache queue to generate reasoning logs. In a scenario where the AI model generates a large amount of data with high concurrency due to reasoning, the AI model will generate a large amount of data. In the related art, in order to ensure the effect of data reflow, the AI model needs to wait for the end of data reflow before continuing to the next round of reasoning after a large amount of data is generated by reasoning, so as to prevent the large amount of data generated from not being recorded and causing data loss. However, in the embodiment of the present application, since the process of data collection and generating reasoning logs is decoupled, the AI model can continue to reason, and the process of data reflow will not affect the reasoning of the AI model.
[0242] In one embodiment of the present application, recording the inference request and the inference result in a cache queue includes:
[0243] Splitting the inference request and the inference result into different data bodies, wherein each data body includes a preset amount of data;
[0244] Record each data body in a cache queue;
[0245] The extracting the cached data from the cache queue and generating an inference log based on the extracted data to implement model data reflow includes:
[0246] The cached data bodies are extracted from the cache queue, and the extracted data bodies are spliced into complete original data according to the original data to which each data body belongs. An inference log is generated based on the spliced original data to realize model data reflow, wherein the original data includes an inference request and an inference result.
[0247] In one embodiment of the present application, each data body includes data contained in a token Token.
[0248] As can be seen from the above, in the embodiment of the present application, the Kong gateway can split the inference results and inference requests to meet the needs of the AI model to send data to the user end in a streaming return manner. And after the inference results and inference requests are split to obtain the data body, the data body can also be spliced when the inference log needs to be generated, so that the data recorded in the generated inference log is complete original data.
[0249] In one embodiment of the present application, the inference request and the inference result include inference information, and the inference information includes at least one of the following information: an identifier of the user terminal, an identifier of the inference service, a timestamp of the corresponding original data, and an identifier of the session to which it belongs, wherein the original data includes the inference request and the inference result, and the inference request and the inference result interacted between the same group of user terminals and the inference service belong to the same session;
[0250] The generating of the inference log based on the extracted data to realize the model data reflow includes:
[0251] According to the inference information, the extracted data belonging to the same session is merged into the same inference log to achieve model data reflow.
[0252] As can be seen from the above, in the embodiment of the present application, the reasoning requests and reasoning results belonging to the same session can be identified based on the reasoning information, so that the reasoning requests and reasoning results belonging to the same session can be stored in an reasoning log, so that when the reasoning log is used later, all the reasoning requests and reasoning results contained in a session can be obtained at one time, which is convenient for subsequent use and processing.
[0253] In one embodiment of the present application, the machine executable instructions further cause the processor to perform the following steps after obtaining the inference result generated by the inference service in response to the inference request:
[0254] The inference result is sent to the user terminal.
[0255] From the above, it can be seen that in addition to realizing the model data reflow, the Kong gateway in the embodiment of the present application can also feedback the inference results to the user end that requests AI model inference.
[0256] Corresponding to the aforementioned data reflow method, the embodiment of the present application also provides a data reflow device.
[0257] See also Fig.12 , is a structural diagram of a model data reflow device provided in an embodiment of the present application, which is applied to a Kong gateway, and the device includes:
[0258] The request receiving module 1201 is used to receive the inference request sent by the user end;
[0259] A request forwarding module 1202, used for forwarding the inference request to an inference service of an artificial intelligence AI model for processing the inference request;
[0260] A result obtaining module 1203, used to obtain the inference result generated by the inference service in response to the inference request;
[0261] A result recording module 1204, used for recording the inference request and the inference result in a cache queue;
[0262] The log generation module 1205 is used to extract the cached data from the cache queue and generate an inference log based on the extracted data to achieve model data reflow.
[0263] As can be seen from the above, in the embodiment of the present application, the inference request sent by the user end can be received through the Kong gateway, and the Kong gateway can forward the inference request to the inference service of the AI model that matches the inference request, and obtain the inference result, and then store the inference request and the inference result in the cache queue, and then extract the cached data from the cache queue and generate an inference log. Since the inference log is generated based on the inference request and the inference result, the generated inference log can be applied to subsequent model training, model analysis, or other fields, which is equivalent to completing the model data reflow.
[0264] Moreover, since the Kong gateway can complete functional expansion through custom plug-ins, adding a program to the Kong gateway to complete the solution provided in the embodiment of the present application will not affect the original business code, and efficient asynchronous model data reflux can be achieved without affecting the AI model reasoning.
[0265] Furthermore, in the embodiment of the present application, a cache queue is used to temporarily store reasoning requests and reasoning results, so that the process of collecting reasoning requests and reasoning results into the cache queue is decoupled from the process of extracting data from the cache queue to generate reasoning logs. In a scenario where the AI model generates a large amount of data with high concurrency due to reasoning, the AI model will generate a large amount of data. In the related art, in order to ensure the effect of data reflow, the AI model needs to wait for the end of data reflow before continuing to the next round of reasoning after a large amount of data is generated by reasoning, so as to prevent the large amount of data generated from not being recorded and causing data loss. However, in the embodiment of the present application, since the process of data collection and generating reasoning logs is decoupled, the AI model can continue to reason, and the process of data reflow will not affect the reasoning of the AI model.
[0266] In one embodiment of the present application, the result recording module 1204 is specifically used to:
[0267] Splitting the inference request and the inference result into different data bodies, wherein each data body includes a preset amount of data;
[0268] Record each data body in a cache queue;
[0269] The log generation module 1205 is specifically used for:
[0270] The cached data bodies are extracted from the cache queue, and the extracted data bodies are spliced into complete original data according to the original data to which each data body belongs. An inference log is generated based on the spliced original data to realize model data reflow, wherein the original data includes an inference request and an inference result.
[0271] In one embodiment of the present application, each data body includes data contained in a token Token.
[0272] As can be seen from the above, in the embodiment of the present application, the Kong gateway can split the inference results and inference requests to meet the needs of the AI model to send data to the user end in a streaming return manner. And after the inference results and inference requests are split to obtain the data body, the data body can also be spliced when the inference log needs to be generated, so that the data recorded in the generated inference log is complete original data.
[0273] In one embodiment of the present application, the inference request and the inference result include inference information, and the inference information includes at least one of the following information: an identifier of the user terminal, an identifier of the inference service, a timestamp of the corresponding original data, and an identifier of the session to which it belongs, wherein the original data includes the inference request and the inference result, and the inference request and the inference result interacted between the same group of user terminals and the inference service belong to the same session;
[0274] The log generation module 1205 is specifically used for:
[0275] The cached data is extracted from the cache queue, and the extracted data belonging to the same session is merged into the same inference log according to the inference information to realize the model data reflow.
[0276] As can be seen from the above, in the embodiment of the present application, the reasoning requests and reasoning results belonging to the same session can be identified based on the reasoning information, so that the reasoning requests and reasoning results belonging to the same session can be stored in an reasoning log, so that when the reasoning log is used later, all the reasoning requests and reasoning results contained in a session can be obtained at one time, which is convenient for subsequent use and processing.
[0277] In one embodiment of the present application, the device further includes:
[0278] A result sending module is used to send the inference result to the user terminal.
[0279] From the above, it can be seen that in addition to realizing the model data reflow, the Kong gateway in the embodiment of the present application can also feedback the inference results to the user end that requests AI model inference.
[0280] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned model data reflow methods are implemented.
[0281] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any one of the model data reflow methods in the above embodiments.
[0282] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0283] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0284] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the electronic device, device, computer-readable storage medium, and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0285] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
Claims
1. A model data reflow method, characterized in that: Applied to Kong gateway, the method includes: Receive the inference request sent by the user; Forwarding the inference request to an inference service of an artificial intelligence AI model for processing the inference request; Obtaining an inference result generated by the inference service in response to the inference request; Recording the inference request and the inference result in a cache queue; The cached data is extracted from the cache queue, and an inference log is generated based on the extracted data to achieve model data reflow.
2. The method according to claim 1, characterized in that: The recording the inference request and the inference result in a cache queue includes: Splitting the inference request and the inference result into different data bodies, wherein each data body includes a preset amount of data; Record each data body in a cache queue; The extracting the cached data from the cache queue and generating an inference log based on the extracted data to implement model data reflow includes: The cached data bodies are extracted from the cache queue, and the extracted data bodies are spliced into complete original data according to the original data to which each data body belongs. An inference log is generated based on the spliced original data to realize model data reflow, wherein the original data includes an inference request and an inference result.
3. The method according to claim 2, characterized in that Each data body includes the data contained in a token Token.
4. The method according to claim 1, characterized in that: The inference request and the inference result include inference information, and the inference information includes at least one of the following information: the identifier of the user terminal, the identifier of the inference service, the timestamp of the corresponding original data, and the identifier of the session to which it belongs, wherein the original data includes the inference request and the inference result, and the inference request and the inference result interacted between the same group of user terminals and the inference service belong to the same session; The generating of the inference log based on the extracted data to realize the model data reflow includes: According to the inference information, the extracted data belonging to the same session is merged into the same inference log to achieve model data reflow.
5. The method according to any one of claims 1 to 4, characterized in that After obtaining the inference result generated by the inference service in response to the inference request, the method further includes: The inference result is sent to the user terminal.
6. An electronic device, characterized in that: A Kong gateway is running on the electronic device, and the electronic device includes: processor; Transceiver; A machine-readable storage medium storing machine-executable instructions that can be executed by the processor; the machine-executable instructions prompt the processor to perform the following steps: Receive the inference request sent by the user; Forwarding the inference request to an inference service of an artificial intelligence AI model for processing the inference request; Obtaining an inference result generated by the inference service in response to the inference request; Recording the inference request and the inference result in a cache queue; The cached data is extracted from the cache queue, and an inference log is generated based on the extracted data to achieve model data reflow.
7. The electronic device according to claim 6, characterized in that: The recording the inference request and the inference result in a cache queue includes: Splitting the inference request and the inference result into different data bodies, wherein each data body includes a preset amount of data; Record each data body in a cache queue; The extracting the cached data from the cache queue and generating an inference log based on the extracted data to implement model data reflow includes: The cached data bodies are extracted from the cache queue, and the extracted data bodies are spliced into complete original data according to the original data to which each data body belongs. An inference log is generated based on the spliced original data to realize model data reflow, wherein the original data includes an inference request and an inference result.
8. The electronic device according to claim 7, characterized in that: Each data body includes the data contained in a token Token.
9. The electronic device according to claim 6, characterized in that: The inference request and the inference result include inference information, and the inference information includes at least one of the following information: the identifier of the user terminal, the identifier of the inference service, the timestamp of the corresponding original data, and the identifier of the session to which it belongs, wherein the original data includes the inference request and the inference result, and the inference request and the inference result interacted between the same group of user terminals and the inference service belong to the same session; The generating of the inference log based on the extracted data to realize the model data reflow includes: According to the inference information, the extracted data belonging to the same session is merged into the same inference log to achieve model data reflow.
10. The electronic device according to any one of claims 6 to 9, characterized in that: The machine executable instructions further cause the processor to perform the following steps after obtaining the inference result generated by the inference service in response to the inference request: The inference result is sent to the user terminal.
11. A model data reflow device, characterized in that: Applied to Kong gateway, the device includes: A request receiving module, used to receive an inference request sent by a user terminal; A request forwarding module, used to forward the inference request to an inference service of an artificial intelligence AI model used to process the inference request; A result obtaining module, used for obtaining the inference result generated by the inference service in response to the inference request; A result recording module, used for recording the inference request and the inference result in a cache queue; The log generation module is used to extract the cached data from the cache queue and generate an inference log based on the extracted data to achieve model data reflow.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 5 are implemented.
