Model service capacity expansion and contraction method and device, equipment and storage medium

By predicting future word load and current word generation speed, and dynamically adjusting the number of service instances, it solves the problem of unrefined resource allocation in the existing technology, achieves more efficient resource management and faster response capabilities, and adapts to request changes.

CN118708349APending Publication Date: 2024-09-27THE FOURTH PARADIGM BEIJING TECH CO LTD
View PDF 0 Cites 5 Cited by

Patent Information

Application Number
CN202410836296.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-09-27

AI Technical Summary

Technical Problem

When existing large-scale language model services handle changes in request load, resource allocation cannot be finely adjusted, resulting in resource waste or performance bottlenecks, and the lack of effective prediction mechanisms makes it difficult to cope with request peaks or valleys.

Method used

By predicting future word load and current word generation speed, the expansion and contraction strategy is determined, and the number of service instances is dynamically adjusted to meet the minimum number of service instances required under the conditions of response time indicators.

Benefits of technology

It has improved the precision of resource allocation, responded to request peaks or valleys in advance, reduced resource waste and performance bottlenecks, and improved system adaptability and response speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118708349A
    Figure CN118708349A
Patent Text Reader

Abstract

The invention relates to a capacity expansion and shrinkage method, device and equipment for model service and a storage medium. Predicting a future lexical element load, wherein the future lexical element load is used for representing the number of input lexical elements and / or the number of output lexical elements corresponding to all the requests in a period of time in the future; based on the future lexical element load and the current lexical element generation speed of the model service, determining a capacity expansion and contraction strategy, the capacity expansion and contraction strategy indicating the number for increasing or reducing the number of current service instances included in the model service; and increasing or reducing the number of the current service instances included in the model service according to the capacity expansion and contraction strategy. According to the method, the request characteristics are fully considered when the capacity of the model service is expanded and shrunk, so that the fine degree of resource allocation can be improved. Moreover, resource allocation can be carried out in advance for future loads, so that upcoming request peaks or troughs can be dealt with in advance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a method, device, equipment and storage medium for scaling up and down a model service. Background Art

[0002] With the rapid development of artificial intelligence technology, generative models (such as large language models, LLMs) play an important role in various application scenarios. However, these models usually require a lot of computing resources, and how to efficiently manage and allocate these resources to meet the ever-changing request load is a challenge.

[0003] Currently, many large language model services use a fixed resource allocation strategy, which means that no matter how the request load changes, the computing resources allocated to the model remain unchanged. This method is simple and easy to implement, but it cannot adapt to fluctuations in request load. Some systems allow administrators to manually adjust resource allocation based on experience. Although this manual scaling method can cope with specific load changes, it has a slow response speed and relies on manual judgment, making it difficult to adapt to rapidly changing load requirements. In addition, some systems have implemented automatic scaling mechanisms based on specific thresholds, such as automatically increasing resources when CPU utilization or request queue length reaches a certain threshold. However, these methods usually lack consideration of request characteristics, which may result in less refined resource allocation.

[0004] Therefore, a new scaling solution is still needed for model services. Summary of the invention

[0005] A technical problem to be solved by the present disclosure is how to design a more reasonable scaling solution for model services.

[0006] According to the first aspect of the present disclosure, a method for scaling a model service is provided, wherein the model service is a service provided by using a generative model, and the method comprises: predicting a future word element load, wherein the future word element load is used to characterize the number of input words and / or the number of output words corresponding to all requests within a future period of time; determining a scaling strategy based on the future word element load and a current word element generation speed of the model service, wherein the scaling strategy indicates an amount by which the number of current service instances included in the model service is increased or reduced; and increasing or reducing the number of current service instances included in the model service according to the scaling strategy.

[0007] Optionally, the scaling strategy is determined based on the future word element load and the current word element generation speed of the model service, including: based on the future word element load and the current word element generation speed of the model service, obtaining the number of service instances to increase or decrease the current number of service instances included in the model service, so that the number of service instances after increase or reduction is the minimum number of service instances required to meet the condition that the response time index of the model service to process the future word element load is not higher than a first threshold.

[0008] Optionally, the method also includes: evaluating the current word load, the current word load is used to characterize the number of input words and / or output words corresponding to all requests within a current period of time, wherein predicting the future word load includes: predicting the future word load using a timing prediction model, the input of the timing prediction model is the historical word load and the current word load, the output of the timing prediction model is the future word load, and the historical word load is used to characterize the word load in one or more historical time periods.

[0009] Optionally, the current word load is evaluated, including: obtaining indicator data within a current period of time; the indicator data includes the number of requests, the average number of input words for each request, and the average number of output words for each request; based on the indicator data, the current word load is evaluated; the current word load is equal to the product of the number of requests and the sum of the average number of input words and the average number of output words.

[0010] Optionally, the indicator data also includes the current number of service instances and the current word generation speed of each service instance.

[0011] Optionally, based on the future word unit load and the current word unit generation speed of the model service, obtaining the number of service instances to be increased or reduced for the current number of service instances included in the model service includes: using the following decision formula to determine the number of service instances to be increased or reduced,

[0012]

[0013] Wherein, p represents the future word unit load, ∑s represents the sum of word unit generation speeds of all current service instances, represents the average value of the word unit generation speed of all current service instances, Δi represents the number of service instances that need to be increased or reduced according to the minimum number of service instances when the above decision formula is established, and θ represents the first threshold.

[0014] According to a second aspect of the present disclosure, a device for scaling up and down a model service is provided, wherein the model service is a service provided by using a generative model, and the device comprises: a prediction module for predicting a future word element load, wherein the future word element load is used to characterize the number of input words and / or the number of output words corresponding to all requests within a future period of time; a determination module for determining a scaling strategy based on the future word element load and a current word element generation speed of the model service, wherein the scaling strategy indicates an amount of increase or decrease in the number of current service instances included in the model service; and a scaling module for increasing or decreasing the number of current service instances included in the model service according to the scaling strategy.

[0015] Optionally, the determination module obtains the number of service instances to be increased or reduced for the current number of service instances included in the model service based on the future word element load and the current word element generation speed of the model service, so that the number of service instances after increase or reduction is the minimum number of service instances required to satisfy the condition that the response time index of the model service to process the future word element load is not higher than a first threshold.

[0016] Optionally, the device also includes: an evaluation module, used to evaluate the current word load, the current word load is used to characterize the number of input words and / or output words corresponding to all requests within a current period of time, the prediction module uses a timing prediction model to predict the future word load, the input of the timing prediction model is the historical word load and the current word load, the output of the timing prediction model is the future word load, and the historical word load is used to characterize the word load in one or more historical time periods.

[0017] Optionally, the evaluation module obtains indicator data within a current period of time; the indicator data includes the number of requests, the average number of input words for each request, and the average number of output words for each request; the evaluation module evaluates the current word load based on the indicator data; the current word load is equal to the product of the number of requests and the sum of the average number of input words and the average number of output words.

[0018] Optionally, the indicator data also includes the current number of service instances and the current word generation speed of each service instance.

[0019] Optionally, the determination module uses the following decision formula to determine the number of service instances to be increased or reduced:

[0020]

[0021] Wherein, p represents the future word unit load, ∑s represents the sum of word unit generation speeds of all current service instances, represents the average value of the word unit generation speed of all current service instances, Δi represents the number of service instances that need to be increased or reduced according to the minimum number of service instances when the above decision formula is established, and θ represents the first threshold.

[0022] According to a third aspect of the present disclosure, a computing device is provided, comprising: a processor; and a memory on which executable codes are stored, and when the executable codes are executed by the processor, the processor executes the method described in the first aspect above.

[0023] According to a fourth aspect of the present disclosure, a computer program product is provided, comprising an executable code, and when the executable code is executed by a processor of an electronic device, the processor is caused to execute the method as described in the first aspect above.

[0024] According to a fifth aspect of the present disclosure, a non-temporary machine-readable storage medium is provided, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor executes the method described in the first aspect above.

[0025] The present disclosure predicts the future word unit load, determines the expansion and contraction strategy based on the future word unit load and the current word unit generation speed of the model service, and increases or decreases the number of current service instances included in the model service according to the expansion and contraction strategy, so that the request characteristics are fully considered when the model service is expanded and contracted, thereby improving the precision of resource allocation. In addition, the present disclosure can allocate resources in advance according to the future load, so that the upcoming request peak or trough can be dealt with in advance. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] The above and other objects, features and advantages of the present disclosure will become more apparent through a more detailed description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, wherein like reference numerals generally represent like components in the exemplary embodiments of the present disclosure.

[0027] Figure 1 It is a schematic flowchart showing a method for scaling up and down a model service according to an embodiment of the present disclosure.

[0028] Figure 2 It is a schematic flowchart showing a method for scaling up and down a model service according to another embodiment of the present disclosure.

[0029] Figure 3 It is a schematic diagram showing the structure of a capacity expansion and contraction device according to an embodiment of the present disclosure.

[0030] Figure 4 A schematic diagram of the structure of a computing device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0031] The preferred embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the preferred embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.

[0032] This disclosure aims to provide a more reasonable scaling solution for model services.

[0033] Model services refer to services provided using generative models. For example, model services may refer to intelligent question-answering services that use generative models (such as ChatGPT) to answer questions raised by users.

[0034] A generative model is a generative model that is constructed using machine learning techniques and includes a large number of parameters, such as a large model. The input of a generative model can be unimodal data (such as one of text, image, audio, and video) or multimodal data (such as at least two of text, image, audio, and video); the output of a generative model can be unimodal data or multimodal data. In other words, a generative model can support the processing of data of one or more modalities and generate one or more modal data. For example, a generative model can be a large model with multimodal data processing capabilities and multimodal data generation capabilities.

[0035] In the present disclosure, the generative model can adopt a generative model commonly used in the industry, such as a GPT model. Of course, a new generative model can also be trained. In addition, it should be noted that considering the high overhead (time overhead and cost overhead) of training a new model, a general model fine-tuning method can be used to obtain a generative model, that is, based on the existing general model, the general model can be adjusted according to the feature processing scale and computing power requirements, so as to obtain the generative model used in the present disclosure. This can effectively reduce the model training overhead.

[0036] Multiple service instances can be deployed for the same model service. That is, the model service can include (that is, be implemented or deployed as) multiple service instances. These multiple service instances can all provide services using the generative model. When there are multiple (such as a large number) requests, these requests can be assigned to different service instances for processing.

[0037] A service instance can also be called an inference instance.

[0038] Scaling the model service means increasing or reducing the number of service instances included in the model service.

[0039] Figure 1 It is a schematic flowchart showing a method for scaling up and down a model service according to an embodiment of the present disclosure.

[0040] See also Figure 1 , in step S110 , predict future word-unit load.

[0041] A token is the smallest semantic unit that represents a word in a language model using a number.

[0042] The number of input tokens refers to the number of tokens that need to be input into the generative model based on the request. The number of input tokens can reflect the complexity of the request to a certain extent. Generally speaking, the more input tokens there are, the more complex the request is. In other words, the complexity of the request is positively correlated with the number of input tokens.

[0043] A request may refer to a query made by a user to a model service.

[0044] The number of output tokens refers to the number of tokens that the generative model outputs for a request. The number of output tokens can also reflect the complexity of the request to a certain extent. Generally speaking, the more output tokens there are, the more complex the request is. In other words, the complexity of the request is positively correlated with the number of output tokens.

[0045] For model services, the workload required to process complex requests and simple requests is different. That is, the load on model services caused by complex requests and simple requests is different. In order to consider the characteristics of requests (i.e., complexity) when scaling model services, this disclosure proposes a load evaluation indicator called "word element load".

[0046] Token load is used to represent the number of input tokens and / or output tokens corresponding to all requests within a period of time. Token load reflects the load of the model service in the token dimension.

[0047] The word load can include future word load, current word load and historical word load. Future word load is used to characterize the number of input words and / or output words corresponding to all requests in a future period of time; current word load is used to characterize the number of input words and / or output words corresponding to all requests in the current period of time; historical word load is used to characterize the word load in one or more historical time periods. The word load in a historical time period is the number of input words and / or output words corresponding to all requests in the historical time period.

[0048] The current word load can be obtained by calculation (i.e., evaluation). For example, the indicator data within the current period of time can be obtained (e.g., collected), and the current word load can be evaluated based on the obtained indicator data. The obtained indicator data may include: the number of requests, the average number of input words per request, and the average number of output words per request. The current word load can be equal to the product of the number of requests and the sum of the average number of input words and the average number of output words.

[0049] Exemplarily, the above-mentioned indicator data can be obtained by performing data embedding on each service instance included in the model service. Data embedding refers to attaching the program code for collecting specific indicator data to the service instance to collect the indicator data corresponding to the service instance. For example, the number of requests mentioned above may refer to the sum of the number of requests of all service instances in the current period of time, and the number of requests obtained by the data embedding of each reasoning instance may be summed to obtain the above-mentioned number of requests. For another example, the average number of input tokens for each request mentioned above may refer to the average number of input tokens for all requests processed by all current service instances in the current period of time, and the number of all input tokens obtained by the data embedding of each reasoning instance may be averaged to obtain the average number of input tokens. For another example, the average number of output tokens for each request mentioned above may refer to the average number of output tokens for all requests processed by all current service instances in the current period of time, and the number of all output tokens obtained by the data embedding of each reasoning instance may be averaged to obtain the average number of output tokens.

[0050] The present disclosure can also obtain indicator data such as the current number of service instances and the word generation speed of each current service instance. Among them, the current number of service instances can be determined according to the system configuration. The word generation speed of each current service instance can be obtained by burying data points for each service instance included in the model service.

[0051] The historical word load refers to the word load corresponding to a time period obtained by calculating the indicator data in the past time period. The present disclosure can collect the above indicator data in real time and evaluate the current word load in real time. Moreover, the current word loads of different time periods can be stored as historical data. That is, as time goes by, the current word load can be used as the historical word load.

[0052] The future word load can be obtained through prediction. That is, the future word load reflects the word load prediction results in the future period of time. Exemplarily, the future word load can be equal to the sum of the number of input words and the number of output words corresponding to all requests in the future period of time. Therefore, the future word load can also be called the total request token load.

[0053] The present disclosure can predict future word loads based on current word loads and historical word loads. The future word load prediction problem can be regarded as a typical time series prediction problem. Therefore, the time series prediction model can be used to predict future word loads. The input of the time series prediction model can be the historical word load and the current word load, and the output of the time series prediction model is the future word load. The historical word load is used to characterize the word load in one or more historical time periods. This time series prediction model can specifically adopt but is not limited to the long short-term memory network (LSTM, Long Short-Term Memory). In addition, any other feasible method can also be used to predict the future word load.

[0054] In step S120, a scaling strategy is determined based on the future word load and the current word generation speed of the model service.

[0055] The current word generation speed may refer to the current word generation speed of each service instance among all service instances currently included in the model service, or it may refer to the total word generation speed determined based on the current word generation speed of each service instance among all service instances currently included in the model service.

[0056] The future word load reflects the load that the model service will face in the word dimension in the future; and the current word generation speed of the model service can reflect the current load-solving ability of the model service in the word dimension. Therefore, based on the future word load and the current word generation speed of the model service, the model service's current ability to cope with the future word load can be evaluated, and the expansion and contraction strategy can be determined accordingly. The expansion and contraction strategy indicates the number of increases or decreases in the number of current service instances included in the model service. For example, if the evaluation result shows that the model service's current ability to cope with the future word load is too weak, the expansion and contraction strategy can indicate that a number of service instances are added on the basis of the current number of service instances to allocate more resources to the model service. For another example, if the evaluation result shows that the model service's current ability to cope with the future word load is too strong, the expansion and contraction strategy can indicate that a number of service instances are reduced on the basis of the current number of service instances to release some resources. For another example, if the evaluation result shows that the model service's current ability to cope with the future word load is within the normal range, the determined expansion and contraction strategy can indicate that the number of service instances is increased or reduced to zero on the basis of the current number of service instances, that is, the number of service instances of the model service is not adjusted. Among them, not adjusting the number of service instances of the model service can be regarded as a special scaling strategy.

[0057] Exemplarily, the response time can be calculated based on the future word load and the current word generation speed of the model service. The response time can be equal to the future word load divided by the current total word generation speed of the model service. The current total word generation speed of the model service is the sum of the word generation speeds of all service instances currently included in the model service. The response time can then be used to evaluate the current ability of the model service to cope with future word loads. For example, if the response time is too long (such as exceeding the second threshold), the number of service instances can be increased; if the response time is too short (such as below the third threshold), the number of service instances can be reduced; if the response time is moderate (such as above the third threshold and below the second threshold), the number of service instances can be neither increased nor reduced.

[0058] In some embodiments of the present disclosure, the number of service instances (i.e., scaling strategy) for increasing or decreasing the number of current service instances included in the model service can be obtained based on the future word load and the current word generation speed of the model service, so that the number of service instances after increase or decrease is the minimum number of service instances required to meet the condition that the response time index of the model service to process the future word load is not higher than the first threshold. The response time index can be equal to the future word load divided by the total word generation speed of all service instances included in the model service after scaling. The first threshold can be flexibly set according to actual conditions, such as being set to 10s. By determining the scaling strategy according to the minimum number of service instances, the resources allocated to the model service can be more in line with the future word load.

[0059] Exemplarily, the following decision formula may be used to determine the number of service instances to be increased or decreased.

[0060]

[0061] Where p represents the future word unit load, ∑s represents the sum of the word unit generation speeds of all current service instances, Represents the average value of the word generation speed of all current service instances, Δi represents the number of service instances that need to be increased or reduced according to the minimum number of service instances when the above decision formula is valid, and θ represents the first threshold. Δi can be a positive integer or a negative integer. When Δi is a positive integer, it indicates that the number of service instances needs to be increased. When Δi is a negative integer, it indicates that the number of service instances needs to be reduced. The sum of Δi and the number of service instances before scaling can be equal to the minimum number of service instances. When Δi>0, the Δi instances can be directly increased. When Δi<-1, one instance can be reduced at a time, and when it is determined that the service instances still need to be reduced in the subsequent method according to the present invention, they can be reduced one by one. In addition, the Δi instances can also be directly reduced.

[0062] As an optional but not necessarily preferred solution, the number of service instances that need to be increased or reduced may not be determined strictly according to the minimum number of service instances. Instead, fine-tuning may be performed based on the minimum number of service instances. For example, the number of service instances after expansion or contraction may be greater than the minimum number of service instances while satisfying the above decision formula.

[0063] In step S130, the number of current service instances included in the model service is increased or reduced according to the scaling strategy.

[0064] Increase or decrease the number of current service instances included in the model service, that is, create one or more new service instances, or destroy one or more currently deployed service instances. Exemplarily, the number of current service instances included in the model service can be increased or decreased by calling a specific API. For example, a service instance can refer to a Pod instance in a K8S cluster. A new Pod instance can be created by calling a system API, or an already created Pod instance can be destroyed.

[0065] Figure 2 It is a schematic flow chart showing a method for scaling up and down a model service according to another disclosed embodiment.

[0066] See also Figure 2 , in step S1, the system is initialized.

[0067] When the system starts, computing resources can be allocated according to preset initial parameters, which may be based on historical average load or manually set. Allocating computing resources according to preset initial parameters means determining the number of service instances that need to be created in the initial situation according to the preset initial parameters.

[0068] In step S2, real-time load monitoring.

[0069] After the system starts running, the load monitoring module can be used to collect the following current indicators in real time: number of requests (acquisition method: data embedding for each inference instance, preprocessing: final sum); average number of input tokens (acquisition method: data embedding for each inference instance, preprocessing: final average); average number of output tokens (acquisition method: data embedding for each inference instance, preprocessing: final average); current token generation speed for each instance (acquisition method: data embedding for each inference instance); current number of instances (system configuration). Average number of input tokens, that is, the average number of input tokens mentioned above. Average number of output tokens, that is, the average number of output tokens mentioned above.

[0070] In step S3, data preprocessing is performed.

[0071] The collected indicator data can be cleaned and standardized through the preprocessing module for subsequent processing. Cleaning can refer to removing abnormal data. Standardization can refer to unifying the format of the cleaned data.

[0072] In step S4, load evaluation.

[0073] You can use a multi-dimensional load assessment algorithm to evaluate the current load status by comprehensively considering the number of requests, average number of input tokens, average number of output tokens, etc. You can use the following formula to evaluate the load.

[0074] Estimated total number of request tokens = number of requests * (average number of request tokens + average number of generated tokens). The estimated total number of request tokens is the current word load mentioned above.

[0075] In step S5, future load is predicted.

[0076] A prediction algorithm can be used to predict the request load change trend in the future based on historical data and real-time monitoring data. The prediction algorithm can be used, but not limited to, "time series analysis", "machine learning prediction", "deep learning LSTM" and other algorithms. For example, LSTM can be used to generate the total request token load in the next minute. The total request token load in the next minute is the future word load mentioned above.

[0077] In step S6, resource requirements are calculated.

[0078] The required amount of resources can be calculated based on the future load prediction results (optionally, combined with the current load assessment results) and the current token generation speed. For example, the number of service instances that need to be increased or reduced can be determined based on the average response time indicator T. The average response time indicator T can be calculated based on the following formula.

[0079]

[0080] Where p represents the total load (payload). p can be equal to the future load prediction result, or the weighted average of the future load prediction result and the current load evaluation result. s represents the token generation speed of each service instance.

[0081] Specifically, the scaling decision formula mentioned above can be used to determine the number of service instances that need to be increased or reduced.

[0082] In step S7, capacity expansion and contraction decision is made. According to the resource demand calculated in step S6, it can be decided whether resource allocation needs to be adjusted and the scale of adjustment can be determined.

[0083] In step S8, resource adjustment is performed. If resources need to be adjusted, computing resources can be dynamically increased or decreased by interacting with the scheduling system API (such as kubernetes, docker, etc.). The scheduling system API is used to increase or decrease service instances.

[0084] Existing technologies usually have the following defects: 1) Resource waste: When the request load is low, fixed resource allocation or excessive automatic expansion may cause a large amount of computing resources to be idle, resulting in resource waste; 2) Performance bottleneck: When the request load is peak, if the resource allocation is insufficient, it may lead to prolonged service response time or even service unavailability, affecting user experience; 3) Low cost efficiency: Due to the inability to accurately match the request load, the existing technology may lead to increased operating costs, especially when computing resources are expensive; 4) Lack of prediction mechanism: Existing automatic expansion and contraction technologies usually lack an effective prediction mechanism, making it difficult to respond to upcoming request peaks or troughs in advance; 5) Poor adaptability: Existing systems have poor adaptability to different types of requests (such as complex requests with a large number of tokens and simple requests with a small number of tokens), and cannot achieve differentiated resource allocation; 6) Lack of real-time performance: In some systems, there are delays in the decision and implementation of resource adjustments, and they cannot respond quickly to sudden request fluctuations.

[0085] The present disclosure can monitor the current number of requests and the number of input / output tokens of each request in real time to ensure that resource allocation can quickly respond to actual load changes; the present disclosure can automatically adjust the computing resources allocated to large language model services based on real-time monitoring data to achieve on-demand resource allocation; the present disclosure can also use machine learning algorithms to predict future request loads, so that the system can allocate resources in advance to cope with upcoming peaks or troughs; the present disclosure specifically formulates a sophisticated scaling rule that fully considers request characteristics and historical data to achieve more accurate resource adjustments; based on the sophisticated scaling strategy of the present disclosure, 90% of the model service response times can be kept within the control threshold.

[0086] The scaling method of the model service disclosed in the present invention can also be implemented as a scaling device. Figure 3 1 is a schematic diagram showing the structure of a device for expanding and contracting a capacity according to an embodiment of the present disclosure. The functional units of the device for expanding and contracting a capacity can be implemented by hardware, software, or a combination of hardware and software that implements the principles of the present disclosure. It can be understood by those skilled in the art that Figure 3The functional units described can be combined or divided into sub-units to implement the principles of the above invention. Therefore, the description herein can support any possible combination, division, or further limitation of the functional units described herein. The following is a brief description of the functional units that the expansion and contraction device can have and the operations that each functional unit can perform. For the details involved, please refer to the relevant description above, which will not be repeated here.

[0087] See also Figure 3 , the expansion and contraction device 300 may include a prediction module 310, a determination module 320 and an expansion and contraction module 330. The prediction module 310 is used to predict the future word element load, and the future word element load is used to characterize the number of input words and / or the number of output words corresponding to all requests in a future period of time. The determination module 320 is used to determine the expansion and contraction strategy based on the future word element load and the current word element generation speed of the model service, and the expansion and contraction strategy indicates the amount of increase or decrease in the number of current service instances included in the model service. The expansion and contraction module 330 is used to increase or decrease the number of current service instances included in the model service according to the expansion and contraction strategy.

[0088] In some embodiments of the present disclosure, the determination module 320 may obtain the number of service instances to be increased or decreased for the current number of service instances included in the model service based on the future word unit load and the current word unit generation speed of the model service, so that the number of service instances after increase or decrease is the minimum number of service instances required to satisfy the condition that the response time index of the model service processing the future word unit load is not higher than the first threshold. Exemplarily, the determination module 320 may use the decision formula mentioned above to determine the number of service instances to be increased or decreased.

[0089] In some embodiments of the present disclosure, the expansion and contraction device 300 may further include an evaluation module. The evaluation module is used to evaluate the current word element load, and the current word element load is used to characterize the number of input word elements and / or the number of output word elements corresponding to all requests within the current period of time. The prediction module 310 can use a time series prediction model to predict the future word element load, and the input of the time series prediction model is the historical word element load and the current word element load, and the output of the time series prediction model is the future word element load, and the historical word element load is used to characterize the word element load in one or more historical time periods. Exemplarily, the evaluation module can obtain indicator data within the current period of time; the indicator data includes the number of requests, the average number of input word elements per request, and the average number of output word elements per request; the evaluation module evaluates the current word element load based on the indicator data; the current word element load is equal to the product of the number of requests and the sum of the average number of input word elements and the average number of output word elements. The indicator data may also include the current number of service instances and the word element generation speed of each service instance.

[0090] Figure 4 A schematic diagram of the structure of a computing device that can be used to implement the above-mentioned method for scaling the model service according to an embodiment of the present disclosure is shown.

[0091] See also Figure 4 , the computing device 400 includes a memory 410 and a processor 420 .

[0092] Processor 420 may be a multi-core processor or may include multiple processors. In some embodiments, processor 420 may include a general-purpose main processor and one or more special coprocessors, such as a graphics processing unit (GPU), a digital signal processor (DSP), etc. In some embodiments, processor 420 may be implemented using a customized circuit, such as an application-specific integrated circuit (ASIC) or a field programmable gate array (FPGA).

[0093] The memory 410 may include various types of storage units, such as system memory, read-only memory (ROM), and permanent storage devices. Among them, ROM can store static data or instructions required by the processor 420 or other modules of the computer. The permanent storage device may be a readable and writable storage device. The permanent storage device may be a non-volatile storage device that does not lose the stored instructions and data even after the computer is powered off. In some embodiments, the permanent storage device uses a large-capacity storage device (such as a magnetic or optical disk, flash memory) as a permanent storage device. In some other embodiments, the permanent storage device may be a removable storage device (such as a floppy disk, optical drive). The system memory may be a readable and writable storage device or a volatile readable and writable storage device, such as a dynamic random access memory. The system memory may store some or all instructions and data required by the processor at run time. In addition, the memory 410 may include any combination of computer-readable storage media, including various types of semiconductor memory chips (DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), and disks and / or optical disks may also be used. In some embodiments, the memory 410 may include a readable and / or writable removable storage device, such as a laser disc (CD), a read-only digital versatile disc (such as a DVD-ROM, a double-layer DVD-ROM), a read-only Blu-ray disc, an ultra-density optical disc, a flash memory card (such as an SD card, a mini SD card, a Micro-SD card, etc.), a magnetic floppy disk, etc. The computer-readable storage medium does not include carrier waves and transient electronic signals transmitted wirelessly or wired.

[0094] The memory 410 stores executable codes, and when the executable codes are processed by the processor 420 , the processor 420 can execute the above-mentioned scaling method.

[0095] The method, device, and apparatus for scaling up and down the model service according to the present disclosure have been described in detail above with reference to the accompanying drawings.

[0096] In addition, the method according to the present disclosure may also be implemented as a computer program or a computer program product, which includes computer program code instructions for executing the above steps defined in the above method of the present disclosure.

[0097] Alternatively, the present disclosure may also be implemented as a non-temporary machine-readable storage medium (or computer-readable storage medium, or machine-readable storage medium) on which executable code (or computer program, or computer instruction code) is stored. When the executable code (or computer program, or computer instruction code) is executed by a processor of an electronic device (or computing device, server, etc.), the processor executes the various steps of the above-mentioned method according to the present disclosure.

[0098] Those skilled in the art will further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or a combination of both.

[0099] The flow charts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the system and method according to multiple embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0100] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.

Claims

1. A method for scaling model services. It is characterized in that The model service is a service provided by using a generative model, and the method includes: Predicting a future word unit load, where the future word unit load is used to represent the number of input word units and / or the number of output word units corresponding to all requests within a future period of time; Determine a scaling strategy based on the future word unit load and the current word unit generation speed of the model service, wherein the scaling strategy indicates an amount by which to increase or decrease the number of current service instances included in the model service; The number of current service instances included in the model service is increased or reduced according to the scaling strategy.

2. The method according to claim 1, It is characterized in that The determining of the expansion and contraction strategy based on the future word unit load and the current word unit generation speed of the model service includes: Based on the future word element load and the current word element generation speed of the model service, the number of service instances to be increased or reduced for the current number of service instances included in the model service is obtained, so that the number of service instances after increase or reduction is the minimum number of service instances required to meet the condition that the response time index of the model service to process the future word element load is not higher than the first threshold.

3. The method according to claim 1, It is characterized in that Also includes: Evaluate the current word unit load, where the current word unit load is used to represent the number of input word units and / or the number of output word units corresponding to all requests within a current period of time, Among them, predicting the future word load includes: using a time series prediction model to predict the future word load, the input of the time series prediction model is the historical word load and the current word load, the output of the time series prediction model is the future word load, and the historical word load is used to characterize the word load in one or more historical time periods.

4. The method according to claim 3, It is characterized in that Evaluate the current word load, including: Obtaining indicator data for the current period of time; the indicator data includes the number of requests, the average number of input words per request, and the average number of output words per request; Based on the indicator data, the current word load is evaluated; the current word load is equal to the product of the number of requests and the sum of the average number of input words and the average number of output words.

5. The method according to claim 3, It is characterized in that The indicator data also includes the current number of service instances and the current word generation speed of each service instance.

6. The method according to claim 2, It is characterized in that Based on the future word unit load and the current word unit generation speed of the model service, the number of service instances to be increased or decreased for the current number of service instances included in the model service is obtained, including: using the following decision formula to determine the number of service instances to be increased or decreased, Wherein, p represents the future word unit load, ∑s represents the sum of word unit generation speeds of all current service instances, represents the average value of the word unit generation speed of all current service instances, Δi represents the number of service instances that need to be increased or reduced according to the minimum number of service instances when the above decision formula is established, and θ represents the first threshold.

7. A device for scaling up and down a model service, It is characterized in that The model service is a service provided by using a generative model, and the device includes: A prediction module, used to predict a future word unit load, where the future word unit load is used to represent the number of input word units and / or the number of output word units corresponding to all requests within a future period of time; A determination module, configured to determine a scaling strategy based on the future word unit load and the current word unit generation speed of the model service, wherein the scaling strategy indicates an amount by which the number of current service instances included in the model service is increased or reduced; The expansion and contraction module is used to increase or reduce the number of current service instances included in the model service according to the expansion and contraction strategy.

8. A computing device, include: processor; as well as A memory having executable codes stored thereon, which, when executed by the processor, causes the processor to execute the method according to any one of claims 1 to 6.

9. A computer program product, comprising executable codes, which, when executed by a processor of an electronic device, causes the processor to perform the method according to any one of claims 1 to 6.

10. A non-transitory machine-readable storage medium having executable codes stored thereon, which, when executed by a processor of an electronic device, causes the processor to execute the method according to any one of claims 1 to 6.

Citation Information

Cited By

  • Method and system for expanding and shrinking capacity based on large model

    CN119292796A

  • Method for realizing expansion and contraction of inference service instance, electronic equipment and storage medium

    CN121303367A

  • Safe atomic force elastic capacity expansion and shrinkage and flow distribution method, device, equipment and medium

    CN121907844A

  • Control method for ai model running instance, and related apparatus

    WO2026170855A1

  • Model inference management method, apparatus, device and storage medium

    WO2026208281A1