Method, device, computer equipment and storage medium for calling algorithm model
By receiving the application's call request and using the current limiting strategy to manage system resources, the problem of call confusion in the algorithm model with multiple callers is solved, the effective calling of the algorithm model and the reasonable allocation of resources are achieved, and the stability and development efficiency of the system are improved.
Patent Information
- Application Number
- CN202210040636.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-14
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2042-01-14
AI Technical Summary
The deployment scheme of the algorithm model in the existing technology is prone to call confusion when there are multiple callers, resulting in the algorithm model being unable to be effectively called and the ability of the algorithm model being unable to be fully utilized.
By receiving the application's call request, using the current limiting strategy and unique identifier to manage system resources, it is ensured that the application party calls the target algorithm model in the specified or default manner after obtaining the resources to be allocated, and returns the result to the application party.
It realizes the effective calling of algorithm models and the rational allocation of resources, ensures that system resources are not occupied by a single application party, improves the stability and development efficiency of the system, and expands the scope of application.
Smart Images

Figure CN114385268B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method, apparatus, computer device, and storage medium for calling an algorithm model. Background Art
[0002] The implementation of AI applications involves applying algorithm models to real-world business applications, a long-standing industry focus. Several model deployment solutions exist, such as TF-Serving and TensorRT. The invocation process of these existing algorithm deployment solutions can be roughly understood as: receiving a request, invoking the algorithm, and returning the result.
[0003] Most algorithm models may be called by multiple callers at the same time. Deploying simple models in existing technologies to multiple callers can lead to confusion, resulting in ineffective algorithm model calls and inability to fully leverage the model to empower the callers. Therefore, the practical implementation of AI (artificial intelligence) applications requires consideration of numerous issues and numerous supporting functions. Summary of the Invention
[0004] In order to solve the technical problem in the prior art that the algorithm model deployment scheme is rough and the algorithm model cannot be effectively called, this application provides a method, device, computer equipment and storage medium for calling an algorithm model, the main purpose of which is to realize the deployment, application and implementation of the algorithm model.
[0005] To achieve the above objectives, the present application provides a method for calling an algorithm model, which includes:
[0006] Receive a call request from the application party, where the call request carries the first unique identifier of the target algorithm model to be called, the second unique identifier of the application party, and input parameter data;
[0007] Determine whether the application party can currently obtain the resources to be allocated based on the current limiting strategy and the second unique identifier, where the resources to be allocated include concurrent resources used by the system to call the algorithm model;
[0008] If the application party can currently obtain the resources to be allocated, the target algorithm model indicated by the first unique identifier is called according to the input parameter data and the obtained calling method to obtain the calling result;
[0009] Return the call result to the application.
[0010] In addition, to achieve the above purpose, the present application also provides a device for calling an algorithm model, which includes:
[0011] A call request receiving module is used to receive a call request from an application party, where the call request carries a first unique identifier of a target algorithm model to be called, a second unique identifier of the application party, and input parameter data;
[0012] A first judgment module is used to determine whether the application party can currently obtain the resources to be allocated based on the current limiting strategy and the second unique identifier, wherein the resources to be allocated include concurrent resources used by the system to call the algorithm model;
[0013] The model calling module is used to call the target algorithm model indicated by the first unique identifier according to the input parameter data and the obtained calling method to obtain a calling result if the application party can currently obtain the resources to be allocated;
[0014] The result return module is used to return the call result to the application.
[0015] To achieve the above-mentioned purpose, the present application also provides a computer device, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor. When the processor executes the computer-readable instructions, the processor executes the steps of the calling method of the algorithm model as described in any of the above items.
[0016] To achieve the above-mentioned purpose, the present application also provides a computer-readable storage medium, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor, the processor executes the steps of the calling method of the algorithm model as described in any of the above items.
[0017] The calling method, device, computer equipment and storage medium of the algorithm model proposed in this application realize the deployment and implementation of the algorithm model integrated by the system through the management of system resources and the flow limiting strategy, and realize the allocation of the algorithm capability resources owned by the system to different application parties according to actual needs, thereby ensuring that the algorithm model is effectively called and enabling the algorithm model to be used to empower the caller. In addition, the system can integrate the service capabilities of a single algorithm model, and can also integrate multiple different algorithm models to form an overall service capability, with a wide range of applications. At the same time, the unified processing logic and system resource management of this application can greatly accelerate the development efficiency of the algorithm model's external empowerment, reduce costs and increase efficiency, and improve the stability of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 This is an application scenario diagram of the calling method of the algorithm model in one embodiment of the present application;
[0019] Figure 2 This is a flowchart of a method for calling an algorithm model in one embodiment of the present application;
[0020] Figure 3 This is a structural block diagram of a device for calling an algorithm model in one embodiment of the present application;
[0021] Figure 4 This is a block diagram of the internal structure of a computer device in one embodiment of the present application.
[0022] The realization of the objectives, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application. It should be understood that the specific embodiments described here are only used to explain the present application and are not used to limit the present application.
[0024] The calling method of the algorithm model provided in this application can be applied in Figure 1 In an application environment, a terminal device 110 communicates with a server 120 via a network. The terminal device 110 may be, but is not limited to, various personal computers, laptops, smartphones, tablet computers, and portable wearable devices. The server 120 may be implemented as an independent server or a server cluster consisting of multiple servers.
[0025] Figure 2 This is a flow chart of a method for calling an algorithm model in one embodiment of the present application. Figure 2 , this method is applied in Figure 1 The method for calling the algorithm model includes the following steps S100-S400.
[0026] S100: Receive a call request from an application party, where the call request carries a first unique identifier of a target algorithm model to be called, a second unique identifier of the application party, and input parameter data.
[0027] Specifically, the present application is applied to the server side of the system, and the application party is an application service of the client. The application party also belongs to the caller. The same client can include multiple application parties, and the client is installed in the terminal device. Before calling the algorithm model, each application party is authorized to call part or all of the algorithm models of the system, and configure the corresponding application configuration information. The application configuration information may include but is not limited to the second unique identifier assigned to the application party, the algorithm model that the application party can call, the maximum system resources that the application party can occupy, the available calling method, the specified calling method of some algorithm models, the current limiting strategy, the callback address, etc. Among them, the second unique identifier is used to uniquely identify an application party, and the second unique identifier of different application parties is different. The second unique identifier can be the application number of the application party.
[0028] The call request is an algorithm model call request sent by an application service (application party) of the client to the server side of the system. The call request is a call to the system interface. The system integrates at least one algorithm model, and each algorithm model is assigned a first unique identifier that can uniquely identify the algorithm model. The input data is the assignment of the parameter variables of the target algorithm model by the application party. The first unique identifier can be the model number of the algorithm model. The algorithm model of the system of the present application can be called by different application parties. Different application parties can be different application parties of the same client, or different application parties of different clients.
[0029] The algorithm model is an executable code developed by developers. The algorithm model is deployed so that the system integrates the algorithm model. Each algorithm model forms an independent service. Only by calling the algorithm model can the corresponding service capabilities be provided to the outside world. Model deployment is part of the algorithm implementation. The algorithm models that can be integrated by the system of this application may include, but are not limited to, various artificial intelligence models such as face recognition models, fingerprint recognition models, speech processing models, natural language processing models, and computer vision models.
[0030] The system of this application uses an algorithm model execution framework to enable the algorithm model to be empowered externally. The algorithm model is part of the system. A system can integrate multiple algorithm capabilities by using the algorithm model execution framework. The application party can successfully access this system and call the algorithm capabilities integrated by the system to serve a corresponding application in the client program.
[0031] S200: Determine whether the application party can currently obtain the resources to be allocated based on the current limiting strategy and the second unique identifier, where the resources to be allocated include concurrent resources used by the system to call the algorithm model.
[0032] Specifically, while authorizing applications to use certain algorithm models, the maximum system resources each application can access are also configured. Because the same application can call the same algorithm model multiple times in a short period of time, if a certain application service suddenly experiences a surge in traffic, all of the system's concurrent resources may be occupied by it. If unrestricted, this could result in a lack of available resources for other applications. To prevent system resources from being occupied by a single application, a current limiting strategy can be used to isolate system resources, preventing a situation where a single application's failure could deprive other applications of their resources.
[0033] Since the system resources that each application can occupy are limited, and the system needs to occupy system resources when calling any algorithm model, when receiving a new call request, the server side will determine whether the application side can still be allocated resources. Only when the application side can still be allocated resources can the corresponding target algorithm model be called. Otherwise, even if the system receives the call request, it may not call the target algorithm model, so as to ensure that the system resources are not all occupied by the same application side. The server side of this embodiment corresponds to the system, and the concurrent resources of the system are also the concurrent resources of the server side.
[0034] S300: If the application party can currently obtain the resources to be allocated, the target algorithm model indicated by the first unique identifier is called according to the input parameter data and the obtained calling method to obtain a calling result.
[0035] Specifically, the calling method includes synchronous calling and asynchronous calling. If the calling method of the target algorithm model is specified in the application configuration information, the calling method is the specified calling method. If it is not specified, the calling method calls the target algorithm model according to the calling method specified by the application. Different calling interfaces are configured for algorithm models that do not specify a calling method. Each calling interface corresponds to a calling method, so the application specifies the calling method through the calling interface. For algorithms with low time consumption and strong concurrency capabilities, a synchronous calling method is generally adopted. For algorithms with high time consumption or weak concurrency capabilities, an asynchronous calling method is generally adopted. The specific calling method is determined according to the actual configuration or the specified method.
[0036] This embodiment specifically calls the algorithm model through the algorithm executor, which is a base class. The algorithm executor is also the algorithm adapter. The algorithm adapter is customized according to the characteristics of each algorithm or model, and is used to perform pre-processing, post-processing and other operations on the data of the algorithm model. The algorithm executor includes a synchronous call executor for synchronous calling of the algorithm model and an asynchronous call executor for asynchronous calling of the algorithm model. Special services can extend their own algorithm executors based on the base class. When the system integrates an algorithm model, it also integrates the algorithm adapter corresponding to this algorithm. After receiving the call request from the client, the system completes the call to the algorithm model through the algorithm adapter corresponding to the target algorithm model according to the algorithm capability of calling a target algorithm model specified by the client.
[0037] S400: Return the call result to the application.
[0038] Specifically, the server determines how to return the call result to the application based on the call method and configuration information. For example, the call result can be returned to the application through active query by the application, or the call result can be returned to the application through active callback by the server and push.
[0039] This embodiment can effectively implement the client's call to the system integrated algorithm model through the management of system resources and the flow limiting strategy, and realize the allocation of the system's algorithm capability resources to different application parties or callers according to actual needs.
[0040] The algorithm model used in this application embodiment specifically acquires and processes relevant data based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results.
[0041] Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0042] In one embodiment, step S200 specifically includes:
[0043] Based on the obtained current available resource data of the system, the maximum available resource data configured for the application, and the used resource data of the application, it is determined whether the application can currently obtain the resources to be allocated and whether the system has the resources to be allocated allocated to the application.
[0044] Step S300 specifically includes:
[0045] If the application party can currently obtain the resources to be allocated and the system has the resources to be allocated allocated to the application party, the target algorithm model indicated by the first unique identifier is called according to the input parameter data and the obtained calling method to obtain the calling result.
[0046] Specifically, the system's maximum available resources are pre-configured. As available resources are occupied by different applications, the current available resources will change accordingly. Furthermore, the resources that can be allocated to each application or client (maximum usage) are also pre-configured. As applications occupy more system resources, the amount of resources they can continue to be allocated is also limited. Each application cannot occupy system resources indefinitely.
[0047] Resource allocation is achieved through a rate limiting mechanism. For example, in Algorithm A, the system resources currently support only 100 concurrent requests. Now, if four different applications are connected to the system, each application can be allocated 25 concurrent requests. This is because the algorithm's capacity is limited (100 concurrent requests). If one application suddenly experiences a surge in traffic, without any restrictions, it could occupy all 100 concurrent requests, leaving the other three applications without resources. Rate limiting strategies can achieve isolation and management of application resources.
[0048] For example, if the maximum available resources for an application are 25 concurrent resources, then if the application has already occupied 25 concurrent resources, then even if there are unoccupied concurrent resources in the system, no more resources will be allocated to the application. If the application has already occupied 22 concurrent resources, then if there are unoccupied concurrent resources in the system, then the unallocated resources can still be allocated to the application. If there are no unallocated concurrent resources in the system, then the application still cannot obtain the unallocated resources.
[0049] If the application does not allow the resource to be allocated, the application is temporarily isolated from the resource. At this time, the server returns a prompt such as system busy or call error to the application.
[0050] When the application is allowed to obtain the resources to be allocated, the server will allocate concurrent resources for the application's call request and obtain the call result by calling the target algorithm model through the concurrent resources.
[0051] In one embodiment, step S300 specifically includes:
[0052] Determine the calling method corresponding to the calling request according to the target interface called by the application or the specified calling method configured for the target algorithm model, wherein the calling method includes synchronous calling and asynchronous calling;
[0053] If the calling method is synchronous, the input parameter data is passed to the target algorithm model, the target algorithm model after the input parameters is executed, and the calling result is obtained;
[0054] If the calling method is asynchronous, a result query identifier is returned to the application, the input parameter data is passed into the target algorithm model, the target algorithm model after the input parameter is executed, and the calling result is obtained.
[0055] Specifically, among the multiple algorithm models integrated into the system, some have unique invocation methods assigned by the system administrator, eliminating the need for the application to select a specific invocation method for that algorithm model. Some algorithm models, however, are not assigned a single invocation method and instead have multiple different invocation interfaces configured, each corresponding to a different invocation method. Therefore, the application can determine the invocation method corresponding to the request by calling the target server interface.
[0056] During synchronous calls, the server will execute the target algorithm model and return the call result (i.e., execution result) to the application after the execution is completed.
[0057] During asynchronous calls, the server assigns a result query identifier to the application before completing the target algorithm model, rather than directly returning the call result. The returned result query identifier acts as a receipt response from the server to the application. The application can then request the corresponding call result from the server based on the result query identifier, or the server can proactively push the call result to the application after execution is complete.
[0058] In one embodiment, step S400 specifically includes:
[0059] If the calling method is synchronous, the calling result will be returned to the application synchronously;
[0060] If the calling mode is asynchronous, then if the result query request from the application is received, the calling result will be returned to the application, wherein the result query request carries the result query identifier;
[0061] or,
[0062] If the calling method is asynchronous calling, the callback interface indicated by the callback interface information is called according to the callback interface information provided by the application party, and the calling result is pushed to the application party.
[0063] Specifically, after the algorithm is executed, the appropriate callback strategy is selected according to the application. Generally, the result of a synchronous call is returned synchronously, but the result of asynchronous processing can be selected according to the application configuration information. If the application configuration information also configures the callback interface provided by the application, the server (service party) can actively call back according to the callback interface information provided by the client, and actively push the obtained call result (execution result) to the client application. It is also possible that the client application actively queries the result through the query interface of the server. The result query request of the application calling the query interface of the server carries the result query identifier. Therefore, when the server receives the result query request, it queries the corresponding call result according to the result query identifier and returns the call result to the application.
[0064] In one embodiment, the method further comprises:
[0065] If the calling method is synchronous, upon receiving the calling request from the application, the resources currently occupied by the application are accumulated and updated synchronously;
[0066] If the calling method is asynchronous, the execution progress of the target algorithm model is monitored. If the target algorithm model is executed, the resources currently occupied by the application are accumulated and updated synchronously.
[0067] Specifically, different call methods use different timings for resource usage statistics. Synchronous request throttling uses the receipt of a call request (HTTP request) as the statistical timing, with the completion of a single HTTP call considered complete. Asynchronous call throttling differs. In asynchronous requests, HTTP calls return a server-side response rather than a processing result, so asynchronous throttling uses the completion of the algorithm as the statistical timing.
[0068] Systems are typically deployed across multiple instances, and client applications need to share their system call counts across multiple instances. Therefore, this embodiment utilizes a Redis (Remote Dictionary Service) shared cache to synchronize updates of resources used by each application. This allows for synchronized updates of the total number of system calls by each application or client, even if the system is integrated across multiple servers and different applications access the algorithmic models in the system through different servers.
[0069] Redis stores the mapping between the application's second unique identifier and the system resources currently occupied by the application. The data on the system resources occupied by the application will be updated in real time based on the actual operation status.
[0070] Of course, this application can also configure the maximum available system resources corresponding to the client, and store the mapping relationship between the client's unique identifier and the system resources currently occupied by the client in redis. The system resources occupied by different applications of the same client are accumulated as the client's used system resources.
[0071] The current limiting strategy of this embodiment is combined with Redis to achieve reasonable allocation and unified management of system resources.
[0072] In one embodiment, the call request also carries the application password of the application party;
[0073] Step S200 specifically includes:
[0074] Verifying the application's calling authority based on the application's second unique identifier and application password;
[0075] If the application party has the calling permission to the target algorithm model, it is determined whether the application party can currently obtain the resources to be allocated based on the current limiting strategy and the second unique identifier.
[0076] Specifically, this embodiment verifies whether the identity of the application party is legal and whether it has the right to call the target algorithm model through the second unique identifier and application password of the application party. The second unique identifier of the application party can be the application number. The application number, application password, and which algorithm models of the system this client is allowed to call are pre-assigned and configured by the system administrator for each application service of each client to be connected to the system. This embodiment also prevents illegal calls to a certain extent by verifying the calling authority of the application party, thereby ensuring system security.
[0077] In one embodiment, step S300 specifically includes:
[0078] Perform parameter verification on the input data according to the model configuration information of the target algorithm model;
[0079] If the application party can currently obtain the resources to be allocated and the input parameter data is legal, the target algorithm model indicated by the first unique identifier is called according to the input parameter data and the obtained calling method to obtain the calling result.
[0080] Specifically, the parameter verification of this embodiment is business parameter verification. Different algorithms have different capabilities, and the code of the algorithm model is also different, so the input parameters will also be different. After the algorithm model is developed, its input parameters are generally fixed. Before calling the algorithm model, the input parameter data is verified in advance to determine the correctness of the input parameters. The execution of the algorithm model will occupy system resources, namely concurrent resources. Therefore, performing parameter verification in advance can avoid the waste caused by resource mismatch, thereby avoiding invalid input parameters that lead to invalid execution of the algorithm model, reducing invalid computing overhead.
[0081] In one embodiment, the call request also carries the application password of the application party;
[0082] Step S200 specifically includes:
[0083] Verifying the application's calling authority based on the application's second unique identifier and application password;
[0084] If the application party has the right to call the target algorithm model, it is determined whether the application party can currently obtain the resources to be allocated based on the current limiting strategy and the second unique identifier;
[0085] Step S300 specifically includes:
[0086] Perform parameter verification on the input data according to the model configuration information of the target algorithm model;
[0087] If the application party can currently obtain the resources to be allocated and the input parameter data is legal, the target algorithm model indicated by the first unique identifier is called according to the input parameter data and the obtained calling method to obtain the calling result.
[0088] In one embodiment, the method further comprises:
[0089] After the call result is returned to the application, it is determined to release the corresponding resources occupied by the application, and the resources currently occupied by the application are synchronously updated.
[0090] Specifically, any application will occupy system server resources when calling an algorithm model, but the corresponding resources will be released after the call is completed. Therefore, synchronous updates after the resources are released can manage the system's available resources and facilitate the effective and reasonable allocation of system resources after receiving new call requests.
[0091] In one embodiment, the method further comprises:
[0092] Monitor the execution time of the target algorithm model;
[0093] If the target algorithm model has not been completed when the execution time exceeds the preset timeout period of the target algorithm model, a timeout failure response is returned to the application party according to the exception handling strategy, or the retry mechanism is triggered when the number of retries does not exceed the preset number of times, and the target algorithm model is re-executed.
[0094] Specifically, different client applications may have different requirements for server response timeliness. For example, some applications require a prompt response from the server, while others can wait for a certain period of time. Therefore, this embodiment pre-configures corresponding preset timeout periods for different applications. The preset timeout period is determined based on the application's desired response speed and the execution speed of the algorithm model. Different applications may have different preset timeout periods for invoking different algorithm models.
[0095] In addition, the application configuration information is configured with a corresponding exception handling strategy for each application party, and the configuration of the exception handling strategy is configured according to the needs of the application party and the actual business. The exception handling strategy can be a timeout failure mechanism or a timeout retry mechanism. The timeout failure mechanism is specifically that if the algorithm model has not been executed or the call result has not been obtained after the preset timeout period has passed, the execution of the algorithm model will be directly interrupted, and the server will directly return a timeout failure response to the application party. The timeout retry mechanism is specifically that if the algorithm model has not been executed or the call result has not been obtained after the preset timeout period has passed, and the cumulative number of retries for this call has not exceeded the preset number, the execution of the algorithm model will be interrupted and the algorithm model will be re-executed. If the algorithm model has not been executed or the call result has not been obtained after the preset timeout period has passed, and the cumulative number of retries for this call has exceeded the preset number, the execution of the algorithm model will be interrupted, and the server will return a timeout retry failure response to the application party. Of course, this application also supports the extension of personalized exception handling strategies.
[0096] This application is a complete solution for the production and implementation of AI applications, implementing numerous supporting functions, including system interface access or invocation, interface invocation authentication, synchronous and asynchronous interface rate limiting strategies, result callbacks, allocation of system concurrent resources, data pre-processing, data post-processing, multi-model combination, exception handling strategies, invocation method selection, etc. It abstracts the algorithm invocation process, serves as a bridge between the business and a single algorithm model, and is an indispensable part of a complete AI application.
[0097] This application manages system resources and implements a current limiting strategy to effectively enable clients to call the algorithm models integrated into the system. It also enables the system to integrate multiple different algorithm models, giving the system different algorithmic capabilities. By uniformly maintaining application information for access algorithmic capabilities, unified system planning and resource allocation are possible. This enables rapid external empowerment of algorithmic capabilities.
[0098] The unified processing logic of this application can greatly accelerate the development efficiency of the algorithm's external empowerment, reduce costs and increase efficiency, and improve the stability of the system.
[0099] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0100] Figure 3 This is a structural block diagram of the device for calling the algorithm model in one embodiment of the present application. Figure 3 , the device comprises:
[0101] The call request receiving module 100 is used to receive a call request from an application party, where the call request carries a first unique identifier of a target algorithm model to be called, a second unique identifier of the application party, and input parameter data;
[0102] The first judgment module 200 is used to determine whether the application party can currently obtain the resources to be allocated based on the current limiting policy and the second unique identifier, wherein the resources to be allocated include concurrent resources used by the system to call the algorithm model;
[0103] The model calling module 300 is configured to call the target algorithm model indicated by the first unique identifier according to the input parameter data and the obtained calling method to obtain a calling result if the application party can currently obtain the resources to be allocated;
[0104] The result returning module 400 is used to return the call result to the application.
[0105] In one embodiment, the first judgment module 200 is specifically used to determine whether the application party can currently obtain the resources to be allocated and whether the system has the resources to be allocated allocated to the application party based on the currently available resource data of the system, the maximum available resource data configured for the application party, and the used resource data of the application party.
[0106] The model calling module 300 is specifically used to: if the application party can currently obtain the resources to be allocated and the system has the resources to be allocated allocated to the application party, then call the target algorithm model indicated by the first unique identifier according to the input parameter data and the obtained calling method to obtain the calling result.
[0107] In one embodiment, the model calling module 300 specifically includes:
[0108] A calling mode determination module determines a calling mode corresponding to the calling request according to the target interface called by the application or the specified calling mode configured for the target algorithm model, wherein the calling mode includes synchronous calling and asynchronous calling;
[0109] The synchronous call module is used to pass the input parameter data into the target algorithm model if the calling mode is synchronous call, execute the target algorithm model after the input parameter, and obtain the calling result;
[0110] The asynchronous call module is used to return a result query identifier to the application if the calling method is asynchronous call, pass the input parameter data into the target algorithm model, execute the target algorithm model after the input parameter, and obtain the call result.
[0111] In one embodiment, the result returning module 400 specifically includes:
[0112] The first return module is used to synchronously return the call result to the application if the call mode is synchronous call;
[0113] The second returning module is configured to return the calling result to the application party if the calling mode is asynchronous calling and if a result query request from the application party is received, wherein the result query request carries a result query identifier; or
[0114] The second return module is used to call the callback interface indicated by the callback interface information according to the callback interface information provided by the application side if the calling mode is asynchronous calling, and push the calling result to the application side.
[0115] In one embodiment, the apparatus further comprises:
[0116] A first synchronization module is configured to accumulate and synchronously update the resources currently occupied by the application upon receiving a call request from the application if the call mode is synchronous call;
[0117] The second synchronization module is used to monitor the execution progress of the target algorithm model if the calling method is asynchronous calling. If the target algorithm model is executed, the resources currently occupied by the application are accumulated and updated synchronously.
[0118] In one embodiment, the call request also carries the application password of the application party;
[0119] The first judgment module 200 specifically includes:
[0120] A calling authority verification module, configured to verify the calling authority of the application party based on the second unique identifier and application password of the application party;
[0121] The resource allocation judgment module is used to determine whether the application party can currently obtain the resources to be allocated based on the current limiting strategy and the second unique identifier if the application party has the calling permission to the target algorithm model.
[0122] In one embodiment, the model calling module 300 specifically includes:
[0123] The input parameter verification module is used to verify the parameters of the input parameter data according to the model configuration information of the target algorithm model;
[0124] The calling module is used to call the target algorithm model indicated by the first unique identifier according to the input parameter data and the obtained calling method to obtain the calling result if the application party can currently obtain the resources to be allocated and the input parameter data is legal.
[0125] In one embodiment, the apparatus further comprises:
[0126] The third synchronization module is used to determine the release of corresponding resources occupied by the application after returning the call result to the application, and to synchronously update the resources currently occupied by the application.
[0127] In one embodiment, the apparatus further comprises:
[0128] Duration monitoring module, used to monitor the execution time of the target algorithm model;
[0129] The exception handling module is used to return a timeout failure response to the application party according to the exception handling strategy if the target algorithm model has not been completed when the execution time exceeds the preset timeout period of the target algorithm model, or to trigger the retry mechanism and re-execute the target algorithm model when the number of retries does not exceed the preset number.
[0130] The meaning of "first" and "second" in the above modules / units is only to distinguish different modules / units, and is not used to limit which module / unit has a higher priority or other limiting meanings. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or modules is not necessarily limited to those steps or modules clearly listed, but may include other steps or modules that are not clearly listed or inherent to these processes, methods, products or devices. The division of modules in this application is only a logical division, and other division methods may be used in actual applications.
[0131] For the specific definition of the calling device of the algorithm model, please refer to the definition of the calling method of the algorithm model above, which will not be repeated here. The various modules in the calling device of the above algorithm model can be implemented in whole or in part by software, hardware and their combination. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0132] Figure 4 This is a block diagram of the internal structure of a computer device in one embodiment of the present application. The computer device can be specifically Figure 1 The server side in . Figure 4As shown, the computer device includes a processor, memory, a network interface, an input device, and a display screen connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory includes a storage medium and internal memory. The storage medium can be either non-volatile or volatile. The storage medium stores an operating system and may also store computer-readable instructions. When executed by the processor, the computer-readable instructions enable the processor to implement a method for invoking an algorithm model. The internal memory provides an environment for the operation of the operating system and computer-readable instructions in the storage medium. The internal memory may also store computer-readable instructions. When executed by the processor, the computer-readable instructions enable the processor to execute the method for invoking the algorithm model. The network interface of the computer device is used to communicate with an external server via a network connection. The display screen of the computer device can be a liquid crystal display or an electronic ink display. The input device of the computer device can be a touch screen layer covering the display screen, buttons, a trackball, or a touchpad provided on the computer device housing, or an external keyboard, touchpad, or mouse.
[0133] In one embodiment, a computer device is provided, including a memory, a processor, and computer-readable instructions (e.g., a computer program) stored in the memory and executable on the processor. When the processor executes the computer-readable instructions, the steps of the method for calling the algorithm model in the above embodiment are implemented, such as Figure 2 Alternatively, when the processor executes the computer-readable instructions, the functions of the modules / units of the calling device of the algorithm model in the above embodiment are realized, for example, Figure 3 The functions of modules 100 to 400 are shown in FIG. 1 and will not be described in detail here to avoid repetition.
[0134] The processor can be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the computer device and connects the various parts of the entire computer device using various interfaces and lines.
[0135] The memory can be used to store computer-readable instructions and / or modules. The processor implements various functions of the computer device by running or executing the computer-readable instructions and / or modules stored in the memory, and calling data stored in the memory. The memory can mainly include a program storage area and a data storage area. The program storage area can store an operating system and at least one application required for a function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created based on the use of the mobile phone (such as audio data, video data, etc.).
[0136] The memory may be integrated into the processor or provided separately from the processor.
[0137] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0138] In one embodiment, a computer-readable storage medium is provided on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor, the steps of the method for calling the algorithm model in the above embodiment are implemented, such as Figure 2 Alternatively, when the computer-readable instructions are executed by the processor, the functions of the modules / units of the calling device of the algorithm model in the above embodiment are realized, such as Figure 3 The functions of modules 100 to 400 are shown in FIG. 1 and will not be described in detail here to avoid repetition.
[0139] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware to perform the processes through computer-readable instructions. The computer-readable instructions can be stored in a computer-readable storage medium. When the computer-readable instructions are executed, they can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0140] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, apparatus, article, or method comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, apparatus, article, or method. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, apparatus, article, or method comprising the element.
[0141] The serial numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments. Through the description of the above implementation modes, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, including a number of instructions to enable a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0142] The above are only preferred embodiments of the present application and do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for calling an algorithm model, characterized in that: The method comprises: Receive a call request from an application party, the call request carrying a first unique identifier of a target algorithm model to be called, a second unique identifier of the application party, and input parameter data; Determining whether the application party can currently obtain the resources to be allocated based on the current limiting strategy and the second unique identifier, wherein the resources to be allocated include concurrent resources used by the system to call the algorithm model; determining whether the application party can currently obtain the resources to be allocated based on the current limiting strategy and the second unique identifier, including, based on the obtained current available resource data of the system, the maximum available resource data configured for the application party, and the used resource data of the application party, determining whether the application party can currently obtain the resources to be allocated and whether the system has the resources to be allocated allocated to the application party; If the application party can currently obtain the resources to be allocated, then the target algorithm model indicated by the first unique identifier is called according to the input parameter data and the obtained calling method to obtain a calling result; if the application party can currently obtain the resources to be allocated, then the target algorithm model indicated by the first unique identifier is called according to the input parameter data and the obtained calling method to obtain a calling result, including, if the application party can currently obtain the resources to be allocated and the system has the resources to be allocated allocated to the application party, then the target algorithm model indicated by the first unique identifier is called according to the input parameter data and the obtained calling method to obtain a calling result; If the application party cannot currently obtain the resources to be allocated, isolating the resource occupation by the application party and returning a call error prompt to the application party; The target algorithm model indicated by the first unique identifier is called according to the input parameter data and the obtained calling method to obtain a calling result, including determining the calling method corresponding to the calling request according to the target interface called by the application party or the specified calling method configured for the target algorithm model, wherein the calling method includes synchronous calling and asynchronous calling; If the calling mode is synchronous calling, the input parameter data is passed into the target algorithm model, the target algorithm model after the input parameter is executed, and the calling result is obtained; If the calling mode is an asynchronous call, a result query identifier is returned to the application side, the input parameter data is passed into the target algorithm model, the target algorithm model after the input parameter is executed, and the calling result is obtained; The call result is returned to the application.
2. The method according to claim 1, characterized in that The returning the call result to the application party includes: If the calling mode is synchronous calling, the calling result is synchronously returned to the application side; If the calling mode is an asynchronous call, then upon receiving a result query request from the application party, the calling result is returned to the application party, wherein the result query request carries the result query identifier; or, If the calling mode is an asynchronous calling, then according to the callback interface information provided by the application party, the callback interface indicated by the callback interface information is called, and the calling result is pushed to the application party.
3. The method according to claim 1, characterized in that The method further comprises: If the calling mode is synchronous calling, upon receiving the calling request from the application party, the resources currently occupied by the application party are accumulated and synchronously updated; If the calling method is an asynchronous call, the execution progress of the target algorithm model is monitored. If the execution of the target algorithm model is completed, the resources currently occupied by the application are accumulated and updated synchronously.
4. The method according to claim 1, wherein The call request also carries the application password of the application party; The determining, based on the current limiting policy and the second unique identifier, whether the application party can currently obtain the resources to be allocated includes: Verifying the calling authority of the application party according to the second unique identifier and application password of the application party; If the application party has the calling authority for the target algorithm model, it is determined whether the application party can currently obtain the resources to be allocated according to the current limiting strategy and the second unique identifier.
5. The method according to claim 1 or 4, characterized in that If the application party can currently obtain the resources to be allocated, calling the target algorithm model indicated by the first unique identifier according to the input parameter data and the obtained calling method, and obtaining a calling result, including: Perform parameter verification on the input parameter data according to the model configuration information of the target algorithm model; If the application party can currently obtain the resources to be allocated and the input parameter data is legal, the target algorithm model indicated by the first unique identifier is called according to the input parameter data and the obtained calling method to obtain a calling result.
6. The method according to claim 1 or 3, characterized in that The method further comprises: After returning the call result to the application, it is determined to release the corresponding resources occupied by the application, and the resources currently occupied by the application are synchronously updated.
7. The method according to claim 1, characterized in that The method further comprises: Monitoring the execution time of the target algorithm model; If the target algorithm model has not been completed when the execution time exceeds the preset timeout time of the target algorithm model, a timeout failure response is returned to the application party according to the exception handling strategy, or a retry mechanism is triggered when the number of retries does not exceed the preset number of times, and the target algorithm model is re-executed.
8. A device for calling an algorithm model, characterized in that: The device comprises: A call request receiving module is used to receive a call request from an application party, wherein the call request carries a first unique identifier of a target algorithm model to be called, a second unique identifier of the application party, and input parameter data; A first judgment module is used to determine whether the application party can currently obtain the resources to be allocated based on the current limiting strategy and the second unique identifier, wherein the resources to be allocated include concurrent resources used by the system to call the algorithm model; the method for determining whether the application party can currently obtain the resources to be allocated based on the current limiting strategy and the second unique identifier includes determining whether the application party can currently obtain the resources to be allocated and whether the system has the resources to be allocated allocated to the application party based on the currently available resource data of the system, the maximum available resource data configured for the application party, and the used resource data of the application party; A model calling module is used to call the target algorithm model indicated by the first unique identifier according to the input parameter data and the obtained calling method to obtain a calling result if the application party can currently obtain the resources to be allocated; if the application party can currently obtain the resources to be allocated, the target algorithm model indicated by the first unique identifier is called according to the input parameter data and the obtained calling method to obtain a calling result, including: if the application party can currently obtain the resources to be allocated and the system has the resources to be allocated allocated to the application party, the target algorithm model indicated by the first unique identifier is called according to the input parameter data and the obtained calling method to obtain a calling result; and is also used to isolate the application party's occupation of resources and return a calling error prompt to the application party if the application party cannot currently obtain the resources to be allocated; A calling mode determining module, configured to determine a calling mode corresponding to the calling request according to a target interface called by the application or a designated calling mode configured for the target algorithm model, wherein the calling mode includes synchronous calling and asynchronous calling; A synchronous calling module is used to pass the input parameter data into the target algorithm model if the calling mode is synchronous calling, execute the target algorithm model after the input parameter data, and obtain the calling result; An asynchronous calling module is used to return a result query identifier to the application party if the calling mode is an asynchronous call, pass the input parameter data into the target algorithm model, execute the target algorithm model after the input parameter, and obtain the calling result; The result returning module is used to return the calling result to the application party.
9. A computer device comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein: When the processor executes the computer-readable instructions, it performs the steps of the calling method of the algorithm model according to any one of claims 1 to 7.
10. A computer-readable storage medium having computer-readable instructions stored thereon, characterized in that: When the computer-readable instructions are executed by a processor, the processor executes the steps of the calling method of the algorithm model as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Resource allocation method and device
CN112073498A
Model calling method, device and equipment and storage medium
CN112596919A
Traffic limiting method and device, server and storage medium
CN113595922A