A usability evaluation method and system for large chat model services
By constructing a sponge sample test dataset based on gradient and word block mapping, the text discreteness and autoregressive output uncertainty of chat big model are solved, and the availability and resource efficiency evaluation of chat big model services are realized.
Patent Information
- Application Number
- CN202510780866.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-12
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2045-06-12
AI Technical Summary
The prior art cannot effectively construct sponge samples suitable for chat big models, resulting in the inability to evaluate their availability under high load pressures, and the text discreteness and autoregressive output uncertainty of chat big models lead to gradient conduction barriers and inconsistent output content.
By constructing a sponge sample test dataset based on the relationship between gradient and word block mapping, the gradient of the adversarial suffix is obtained using backpropagation, the adversarial suffix is optimized to generate sponge samples suitable for the chat big model, and the output length is controlled by fusing the EOS loss and uniform loss functions, the usability of the chat big model is evaluated.
Effectively evaluate the service stability and resource efficiency of the chat model, reduce the uncertainty of the model output, increase the diversity and length of the output content, and ensure the availability of the chat model in extreme cases.
Smart Images

Figure CN120297424B_ABST
Abstract
Description
Technical Field
[0001] A method and system for evaluating the availability of a chat big model service are provided, which are used to evaluate the availability of a chat big model service and belong to the field of artificial intelligence security and big model security technology. Background Art
[0002] The Chat Big Model is a highly optimized natural language processing system. Its core architecture and training process involve several key stages, including base model pre-training, dialogue command fine-tuning, and reinforcement learning alignment with human feedback. The base model is typically based on a decoder-only architecture and is pre-trained on large-scale text datasets. While the base model possesses powerful language generation capabilities, it may lack task adaptability and controllability when used directly in conversations. Therefore, supervised fine-tuning on conversation datasets is required to adapt it to conversational scenarios. Even after fine-tuning, the model may still generate content that does not conform to human preferences, such as meaningless responses and harmful messages, requiring further optimization through reinforcement learning. After training and optimization, the Chat Big Model requires engineering deployment before it can be used in real-world scenarios.
[0003] The whole process of large model inference stage: The large model inference process, that is, the process of large model generating content, can be divided into two stages. The first is the pre-filling stage. The large model processes all the received inputs in parallel through the self-attention mechanism, stores the corresponding KV vector cache, and generates the first output word. The second stage uses the KV cache to generate output word blocks one by one using autoregressive method until the end symbol is generated. <eos>Generation stops when a chunk of words is reached or when the model reaches its predefined maximum generation length. The first phase processes the input in parallel, while the second phase generates the output serially. Therefore, the time taken to infer a large model is primarily determined by the output length, and is unrelated to the input length.
[0004] Original sponge sample generation methods primarily use genetic algorithms to heuristically search for samples that improve the target model's inference time, resulting in low efficiency and poor results. The existing LLMEffiChecker method uses a white-box attack to find suitable sponge samples based on gradients. The specific process is as follows: First, the input sequence is fed into the target model. The gradient of the backpropagation in the embedding layer is calculated. The gradient in the embedding space can be used to determine the gradient of each word in the vocabulary. The keyword chunk with the largest absolute negative gradient is selected as the keyword chunk. The identified keyword chunk is perturbed at three levels to generate candidate samples: character-level perturbation (adding, deleting, or modifying a letter), word-level perturbation (replacing with a chunk with a larger negative gradient), and sentence-level perturbation (replacing with a synonym with the same part of speech based on the sentence's grammar). The generated candidate samples are then fed back into the target model, and the one with the longest output length is selected as the optimal sample for the current round. This process is repeated until the output length reaches the maximum value or the maximum number of iterations is reached. The resulting sample is then used as the sponge sample.
[0005] The prior art discloses a system load stress testing method for large language models. This method primarily targets large models with a hybrid expert model architecture. It utilizes the Gumble-Softmax technique to implement white-box gradient optimization, activating more expert models and thereby reducing the inference overhead of large models. This method is specific to large models with a hybrid expert model architecture. Due to the pre-order dependency issues of currently popular decoder-only models, this method cannot be directly applied to mainstream large chat models.
[0006] Currently, there is a lack of dedicated usability evaluation methods for large-model services. Existing methods primarily rely on natural samples from regular conversation datasets to assess resource consumption. While these samples can reflect everyday service scenarios, they cannot effectively simulate extreme conditions under high load. When large models are faced with carefully constructed adversarial examples, their inference mechanisms may be abnormally activated, resulting in continuous output, leading to overloaded computing resources and increased response times. These adversarial examples, which consume hardware resources and increase time overhead, are called sponge examples. Similar to denial-of-service attacks in traditional cybersecurity, when a large number of sponge examples are fed into a large model, the service is constantly under high load and consumes a significant amount of hardware resources, making it unable to respond to legitimate user input requests, significantly reducing the service's availability. Therefore, it is necessary to construct appropriate sponge examples for testing large models to evaluate their usability.
[0007] The original sponge samples were designed primarily for traditional models, which are highly sensitive to varying inputs. Even small perturbations can cause large output variations. However, large chat models, due to their massive parameter count and fine-tuning through massive amounts of data pre-training and extensive conversational commands, possess a strong understanding of user input. Small perturbations at the character or word level are easily automatically corrected by the large model's powerful semantic understanding, making the original sponge samples inappropriate for direct application to large chat models.
[0008] However, there are two problems to be solved in constructing sponge samples for large chat models, as follows:
[0009] Gradient conduction barriers caused by the discrete nature of text: The input processing flow of large models first maps discrete text to a continuous vector space through an embedding layer. However, mapping from the embedding layer back to the discrete text space is an irreversible process. Therefore, the gradient obtained by backpropagation cannot be directly used to optimize samples in the discrete space using gradient descent.
[0010] Uncertainty in autoregressive output content: Mainstream large chat models generally use a decoder-only architecture, and their text generation process has dual uncertainty. On the one hand, it comes from the dependency of the autoregressive mechanism itself on the previous output, and on the other hand, it comes from the randomness introduced by the model's decoding strategy. Therefore, even the same input can result in output content of varying lengths, making it difficult to directly restrict large models to generating responses of a specific length. Summary of the Invention
[0011] In response to the above research issues, the purpose of the present invention is to provide a method and system for evaluating the availability of large chat model services, so as to solve the problems of gradient conduction barriers and uncertainty of autoregressive output content caused by the discreteness of text in the prior art.
[0012] In order to achieve the above object, the present invention adopts the following technical solutions:
[0013] A method for evaluating the availability of a chat model service includes the following steps:
[0014] Step 1: Based on the original input samples and the chat model, a sponge sample test dataset is constructed using the mapping relationship between gradients and word chunks;
[0015] Step 2: Conduct usability evaluation of the chat model based on the sponge sample test dataset.
[0016] Furthermore, the specific steps of step 1 are:
[0017] Step 1.1: First, concatenate each original input sample with a randomly initialized adversarial suffix as the model input. Based on the model input and the vocabulary of the chat model, perform one-hot vector conversion and mapping, and then feed it into the chat model for forward inference to obtain an output sequence. The original input sample is user input from the chat model's public conversation datasets, including the ShareGPT dataset and the Alpaca dataset. The adversarial suffix includes at least one word block.
[0018] Step 1.2: Construct a total loss function that combines EOS loss and uniform loss based on the output sequence.
[0019] Step 1.3: Based on the total loss function, backpropagate the gradient corresponding to the adversarial suffix. Then, use the obtained gradient to apply the discrete text optimization algorithm of gradient search to obtain the top M largest negative gradients of the adversarial suffix as candidate adversarial suffixes.
[0020] Step 1.4: Concatenate each candidate adversarial suffix with the original input sample and input it back into the chat model to obtain the corresponding output sequence. The cost of the chat model is evaluated based on the length of the output sequence.
[0021] Step 1.5: If the chat model overhead reaches the maximum or the number of iterations reaches the maximum, stop the optimization and concatenate the candidate adversarial suffix with the largest output sequence length with the original input sample as the final sponge test sample. Otherwise, select the candidate adversarial suffix with the largest output sequence length to update the randomly initialized adversarial suffix and execute step 1.1 again.
[0022] Step 1.6: Construct a sponge sample test dataset based on all sponge test samples.
[0023] Furthermore, the specific steps of step 1.1 are:
[0024] Each original input sample is concatenated with a randomly initialized adversarial suffix as the model input, and each word block in the model input is indexed by its position in the vocabulary of the chat model.
[0025] Based on the size of the vocabulary, each position index is one-hot encoded. After one-hot encoding, a one-hot vector is obtained. The position index corresponding to the vocabulary in the one-hot vector is set to 1, and the other positions are 0;
[0026] The one-hot vector is mapped to a continuous real number space using an embedding layer, and then sent to the chat model for forward reasoning to obtain the output sequence.
[0027] Based on vocabulary size: Each large model has a unique vocabulary that maps text (such as "yes") to numeric identifiers (token IDs, such as 123) that the model can process. The vocabulary size refers to the total number of token IDs contained in this mapping table. For example, Llama 2's vocabulary contains 32,000 different mappings. In this case, the one-hot encoding of the text "yes" (assuming its token ID is 123) in the Llama 2 vocabulary is a vector of length 32,000, where only the position corresponding to ID 123 is 1, and all other positions are 0, represented as [0, 0, …, 0, 1, 0, 0, …, 0].
[0028] Furthermore, the total loss function in step 1.2 is:
[0029]
[0030]
[0031]
[0032] in, represents the total loss, Indicates EOS loss, represents uniform loss, represents the weight coefficient of uniform loss, Represents the total length of the output sequence of the chat model, Indicates the output sequence The chat model in the output position is <eos>The probability of a chunk, Indicates the output sequence The probability distribution of all chunks in the output positions, Indicates the output sequence uniform distribution of output positions, Represents KL divergence, which is a measure of and The smaller the KL divergence value, the closer the two distributions are.
[0033] Furthermore, the specific steps of step 2 are:
[0034] Step 2.1: Deploy the chat model as an online service based on an open source library, or upload the model to the large model cloud platform for one-click deployment as an online service. Deploying the chat model as an online service based on an open source library means deploying the chat model online as a backend using the open source library Ollama or vLLM. Then, through the open source library OpenWebUI, LangChain, or LM Studio, which provides a visual interaction interface for the chat model, the backend model is connected to the user to provide a visual interaction interface, simulating the chat model service in real-world scenarios. The large model deployment cloud platform includes HuggingFace's Inference Endpoint.
[0035] Step 2.2: Send the sponge sample test datasets one by one to the online service and obtain cost evaluation indicators during service operation, including the output sequence length of the large chat model, hardware resource consumption, service response time, and network throughput. Hardware resources include memory, video memory, and floating-point calculation times.
[0036] Step 2.3: Compare the difference between each overhead indicator and the overhead indicator of the normal sample in the normal sample data set, and finally generate the service test results. The normal sample data set includes the ShareGPT data set and the Alpaca data set.
[0037] A usability evaluation system for a large chat model service, comprising:
[0038] Dataset construction module: Based on the original input samples and the chat model, a sponge sample test dataset is constructed using the mapping relationship between gradients and word chunks;
[0039] Usability evaluation module: performs usability evaluation on the chat model based on the sponge sample test dataset.
[0040] Furthermore, the specific implementation steps of the dataset construction module are:
[0041] Step 1.1: First, concatenate each original input sample with a randomly initialized adversarial suffix as the model input. Based on the model input and the vocabulary of the chat model, perform one-hot vector conversion and mapping, and then feed it into the chat model for forward inference to obtain an output sequence. The original input sample is user input from the chat model's public conversation datasets, including the ShareGPT dataset and the Alpaca dataset. The adversarial suffix includes at least one word block.
[0042] Step 1.2: Construct a total loss function that combines EOS loss and uniform loss based on the output sequence.
[0043] Step 1.3: Based on the total loss function, backpropagate the gradient corresponding to the adversarial suffix. Then, use the obtained gradient to apply the discrete text optimization algorithm of gradient search to obtain the top M largest negative gradients of the adversarial suffix as candidate adversarial suffixes.
[0044] Step 1.4: Concatenate each candidate adversarial suffix with the original input sample and input it back into the chat model to obtain the corresponding output sequence. The cost of the chat model is evaluated based on the length of the output sequence.
[0045] Step 1.5: If the chat model overhead reaches the maximum or the number of iterations reaches the maximum, stop the optimization and concatenate the candidate adversarial suffix with the largest output sequence length with the original input sample as the final sponge test sample. Otherwise, select the candidate adversarial suffix with the largest output sequence length to update the randomly initialized adversarial suffix and execute step 1.1 again.
[0046] Step 1.6: Construct a sponge sample test dataset based on all sponge test samples.
[0047] Furthermore, the specific steps of step 1.1 are:
[0048] Each original input sample is concatenated with a randomly initialized adversarial suffix as the model input, and each word block in the model input is indexed by its position in the vocabulary of the chat model.
[0049] Based on the size of the vocabulary, each position index is one-hot encoded. After one-hot encoding, a one-hot vector is obtained. The position index corresponding to the vocabulary in the one-hot vector is set to 1, and the other positions are 0;
[0050] The one-hot vector is mapped to a continuous real number space using an embedding layer, and then sent to the chat model for forward reasoning to obtain the output sequence.
[0051] Furthermore, the total loss function in step 1.2 is:
[0052]
[0053]
[0054]
[0055] in, represents the total loss, Indicates EOS loss, represents uniform loss, represents the weight coefficient of uniform loss, Represents the total length of the output sequence of the chat model, Indicates the output sequence The chat model in the output position is <eos>The probability of a chunk, Indicates the output sequence The probability distribution of all chunks in the output positions, Indicates the output sequence uniform distribution of output positions, Represents KL divergence, which is a measure of and The smaller the KL divergence value, the closer the two distributions are.
[0056] Furthermore, the specific implementation steps of the usability evaluation module are:
[0057] Step 2.1: Deploy the chat model as an online service based on an open source library, or upload the model to the large model cloud platform for one-click deployment as an online service. Deploying the chat model as an online service based on an open source library means deploying the chat model online as a backend using the open source library Ollama or vLLM. Then, through the open source library OpenWebUI, LangChain, or LM Studio, which provides a visual interaction interface for the chat model, the backend model is connected to the user to provide a visual interaction interface, simulating the chat model service in real-world scenarios. The large model deployment cloud platform includes HuggingFace's Inference Endpoint.
[0058] Step 2.2: Send the sponge sample test datasets one by one to the online service and obtain cost evaluation indicators during service operation, including the output sequence length of the large chat model, hardware resource consumption, service response time, and network throughput. Hardware resources include memory, video memory, and floating-point calculation times.
[0059] Step 2.3: Compare the difference between each overhead indicator and the overhead indicator of the normal sample in the normal sample data set, and finally generate the service test results. The normal sample data set includes the ShareGPT data set and the Alpaca data set.
[0060] Compared with the prior art, the present invention has the following beneficial effects:
[0061] The present invention constructs a sponge sample adapted to the chat model to evaluate the availability of the chat model service, effectively filling the technical gaps in the existing technology in terms of service stability quantification, dynamic resource efficiency evaluation, and continuous monitoring of response timeliness. Specifically, it is embodied in the following aspects:
[0062] First, although the gradient obtained by backpropagation cannot be directly applied to discrete text space, the present invention establishes a mapping relationship between the gradient and each word block in the adversarial suffix through a discrete text optimization algorithm based on gradient search. The influence of the word block at each position in the adversarial suffix on the loss function is compared, and the loss function is reduced by replacing the word blocks in the adversarial suffix.
[0063] Second, in order to overcome the uncertainty of output content, the present invention designs two loss functions to effectively increase the output content of the large model, while breaking the dependency between the output sequences of the chat large model and introducing more uncertainty in each generated input sequence, encouraging the chat large model to output longer and more diverse content. That is, the present invention improves the general decoder architecture by delaying <eos>The emergence of chunks increases the length of large model outputs. The introduction of uniform loss further breaks the pre-order dependency of the large decoder architecture model, avoiding the dual uncertainty in the generation process of large chat models. This allows the large model to output longer content and output content of a consistent or specific length, thereby improving the inference overhead of the large model.
[0064] 3. The present invention constructs a sponge test sample by adding an optimized adversarial suffix after the original input sample. By separating the optimized suffix from the input content, it can more accurately trigger the anomaly of the output stage of the chat model while maintaining the fluency of the conversation, which is more suitable for the chat model. That is, the present invention optimizes the disturbance separately by adding adversarial disturbance after the original input sample, and more accurately finds the anomaly of the chat model reasoning mechanism, thereby increasing the output content length and thus increasing the hardware resource consumption. It solves the problem that current research mainly adds small disturbances to the input when constructing sponge samples, and the powerful language understanding ability of the chat model will automatically correct the small disturbances in the input part, resulting in poor resource consumption. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 A schematic diagram of the process for generating a sponge test sample in the present invention;
[0066] Figure 2 This is a schematic diagram of the structure of the chat model service availability evaluation in the present invention;
[0067] Figure 3 Schematic diagram for the specific implementation case L=10, K=3. DETAILED DESCRIPTION
[0068] The present invention will be further described below with reference to the accompanying drawings and specific embodiments.
[0069] The present invention mainly includes two parts. The first part is to create a sponge sample test dataset, and the second part is to evaluate the usability of the chat big model service based on the created test dataset. The sponge sample test dataset can be created based on the existing public big model chat dataset. Specifically, take the ShareGPT dataset as an example, which contains a conversation dataset between users and the real-scene chat big model ChatGPT. We select the user input as the original input dataset of the present invention, and then construct the corresponding test dataset through the sponge sample creation method of the present invention.
[0070] A method for evaluating the availability of a chat model service includes the following steps:
[0071] Step 1: Based on the original input samples and the chat model, a sponge sample test dataset is constructed using the mapping relationship between gradients and word chunks. The specific steps are as follows:
[0072] Step 1.1: First, concatenate each original input sample with a randomly initialized adversarial suffix as the model input. Based on the model input and the vocabulary of the chat model, perform one-hot vector conversion and mapping, and then feed it into the chat model for forward inference to obtain an output sequence. The original input sample is user input from the chat model's public conversation datasets, including the ShareGPT dataset and the Alpaca dataset. The adversarial suffix includes at least one word block.
[0073] The specific steps are:
[0074] Each original input sample is concatenated with a randomly initialized adversarial suffix as the model input, and each word block in the model input is indexed by its position in the vocabulary of the chat model.
[0075] Based on the size of the vocabulary, each position index is one-hot encoded. After one-hot encoding, a one-hot vector is obtained. The position index corresponding to the vocabulary in the one-hot vector is set to 1, and the other positions are 0;
[0076] The one-hot vector is mapped to a continuous real number space using an embedding layer, and then sent to the chat model for forward reasoning to obtain the output sequence.
[0077] Step 1.2: Construct a total loss function that combines EOS loss and uniform loss based on the output sequence; the total loss function is:
[0078]
[0079]
[0080]
[0081] in, represents the total loss, Indicates EOS loss, represents uniform loss, represents the weight coefficient of uniform loss, Represents the total length of the output sequence of the chat model, Indicates the output sequence The chat model in the output position is <eos>The probability of a chunk, Indicates the output sequence The probability distribution of all chunks in the output positions, Indicates the output sequence uniform distribution of output positions, Represents KL divergence, which is a measure of and The smaller the KL divergence value, the closer the two distributions are.
[0082] Step 1.3: Based on the total loss function, backpropagate the gradient corresponding to the adversarial suffix. Then, use the obtained gradient to apply the discrete text optimization algorithm of gradient search to obtain the top M largest negative gradients of the adversarial suffix as candidate adversarial suffixes.
[0083] Step 1.4: Concatenate each candidate adversarial suffix with the original input sample and input it back into the chat model to obtain the corresponding output sequence. The cost of the chat model is evaluated based on the length of the output sequence.
[0084] Step 1.5: If the chat model overhead reaches the maximum or the number of iterations reaches the maximum, stop the optimization and concatenate the candidate adversarial suffix with the largest output sequence length with the original input sample as the final sponge test sample. Otherwise, select the candidate adversarial suffix with the largest output sequence length to update the randomly initialized adversarial suffix and execute step 1.1 again.
[0085] Step 1.6: Construct a sponge sample test dataset based on all sponge test samples.
[0086] Step 2: Conduct usability evaluation of the chat model based on the sponge sample test dataset.
[0087] Specifically, the adversarial suffix length is L, and the vocabulary size of the chat model is V. For one of the original input samples, a randomly initialized adversarial suffix of fixed length L (L defaults to 20) is concatenated as the model input. First, the text input needs to be converted into a one-hot digital code through a word segmenter. That is, the preparatory process of forward reasoning first converts the text model input (including user input and adversarial suffix) into corresponding numbers, because the model can only process numbers, where the value of the number represents the position index of the word block in the vocabulary. For example, "yes" corresponds to position 157 in the vocabulary. Then, the number is converted into a one-hot code, that is, only the corresponding position is 1, and other positions are zero, and the length is the vocabulary size. Therefore, the one-hot encoding dimension of the adversarial suffix is , that is, the length is L, and each position is a one-hot encoding of length V; therefore, the text model input becomes a one-hot digital type that the model can process, and then becomes a continuous vector representation after passing through the embedding layer and is sent to the chat model for forward reasoning to obtain the output sequence of word distribution. Based on the output sequence, EOS loss and uniform loss are calculated respectively, where EOS loss refers to the loss of each output position. <eos>The mean of the word block probability, uniform loss refers to the KL divergence between the word distribution and the uniform distribution at each output position, and then the two loss functions are directly summed (the weight coefficient of the uniform loss is 1) as the final loss function. After calculating the loss function, backpropagation is performed to obtain the gradient corresponding to the adversarial suffix after one-hot encoding, which is still the same dimension. , where L is the length of the adversarial suffix and V is the size of the large model word space. The meaning of the gradient can be understood as the contribution of each word at each L position to the loss function. Therefore, the present invention selects the first K word blocks with the largest negative gradient at each position to replace the original word blocks as candidate suffixes to achieve the purpose of reducing the loss function. In order to prevent the optimization from falling into a local optimal solution, the K value is 32, and then it appears. candidate suffixes. In order to reduce the computational complexity, the present invention randomly selects M (M=128) candidate suffixes as the final candidates. Finally, the selected candidate suffixes are spliced with the original input and sent back to the chat model to obtain the corresponding output sequence. The adversarial suffix corresponding to the longest output sequence is selected as the current optimal suffix, and the initial suffix is updated. The optimization process is repeated until the model output reaches the maximum value or the number of iterations reaches the maximum, then the optimization is stopped. The final adversarial suffix is spliced with the original output as the final sponge test sample. The above method generates a corresponding sponge sample for each input in the original data set, and finally produces a sponge test sample data set. Another example, that is, the length of the adversarial suffix is L=10 (all initialized to asterisks" ********** ”), the vocabulary of the chat model is V, and the gradient dimension corresponding to the adversarial suffix obtained by back propagation is , that is, each of these ten positions has a gradient corresponding to V word blocks, and the first K (such as K=3 or K=20) word blocks are selected to replace the original asterisks. For the first position, there will be " A********* ” 、" B********* "And so on; for the second position there will be" *C******** ”、 " *D******** "There are K such positions, so there will be K candidates for these ten positions. In order to avoid falling into the local optimal solution, K is generally large, so there is Candidates, There are too many, so we can just randomly select M of them. Figure 3 This is a schematic diagram of the specific implementation case L=10, K=3.
[0088] The specific steps are:
[0089] Step 2.1: Deploy the chat model as an online service based on an open source library, or upload the model to the large model cloud platform for one-click deployment as an online service. Deploying the chat model as an online service based on an open source library means deploying the chat model online as a backend using the open source library Ollama or vLLM. Then, through the open source library OpenWebUI, LangChain, or LM Studio, which provides a visual interaction interface for the chat model, the backend model is connected to the user to provide a visual interaction interface, simulating the chat model service in real-world scenarios. The large model deployment cloud platform includes HuggingFace's Inference Endpoint.
[0090] Step 2.2: Send the sponge sample test datasets one by one to the online service and obtain cost evaluation indicators during service operation, including the output sequence length of the large chat model, hardware resource consumption, service response time, and network throughput. Hardware resources include memory, video memory, and floating-point calculation times.
[0091] Step 2.3: Compare the difference between each overhead indicator and the overhead indicator of the normal sample in the normal sample data set, and finally generate the service test results. The normal sample data set includes the ShareGPT data set and the Alpaca data set.
[0092] The second part evaluates the availability of the chat model service based on the constructed sponge sample test dataset. First, we deploy the chat model online as the model backend engine using the Ollama open source library. Then, we use the OpenWebUI open source library, a visual chat interaction interface for the model, to access the backend model and provide a visual front-end interaction interface to users, simulating the chat model service in a real scenario. The original dataset and the corresponding test dataset generated by the method of the present invention are then sent to the online chat model service. The front-end records the time from input to complete output to response, the network throughput, and the output sequence length of the chat model. The back-end records the hardware resource consumption, including the usage and consumption of video memory, memory usage, and the number of floating-point operations. The differences in the specific values of each indicator of the normal dataset and the test dataset are compared. Finally, a conclusion is drawn to evaluate whether the chat model can withstand extreme conditions as a service and whether its availability can be met.
[0093] The above are only representative embodiments of the present invention in many specific application scopes and do not constitute any limitation on the protection scope of the present invention. Any technical solutions formed by transformation or equivalent replacement fall within the scope of protection of the present invention.< / eos> < / eos> < / eos> < / eos> < / eos> < / eos>
Claims
1. A method for evaluating the availability of a chat model service, characterized in that: The steps include: Step 1: Based on the original input samples and the chat model, a sponge sample test dataset is constructed using the mapping relationship between gradients and word chunks; Step 2: Conduct usability evaluation on the chat model based on the sponge sample test dataset. Compare the differences in the specific values of each indicator between the normal dataset and the sponge sample test dataset to conduct usability evaluation. The specific steps of step 1 are: Step 1.1: First, concatenate each original input sample with a randomly initialized adversarial suffix as the model input. Based on the model input and the vocabulary of the chat model, perform one-hot vector conversion and mapping, and then feed it into the chat model for forward inference to obtain an output sequence. The original input sample is user input from the chat model's public conversation datasets, including the ShareGPT dataset and the Alpaca dataset. The adversarial suffix includes at least one word block. Step 1.2: Construct a total loss function that combines EOS loss and uniform loss based on the output sequence. Step 1.3: Based on the total loss function, backpropagate the gradient corresponding to the adversarial suffix. Then, use the obtained gradient to apply the discrete text optimization algorithm of gradient search to obtain the top M largest negative gradients of the adversarial suffix as candidate adversarial suffixes. Step 1.4: Concatenate each candidate adversarial suffix with the original input sample and input it back into the chat model to obtain the corresponding output sequence. The cost of the chat model is evaluated based on the length of the output sequence. Step 1.5: If the chat model overhead reaches the maximum or the number of iterations reaches the maximum, stop the optimization and concatenate the candidate adversarial suffix with the largest output sequence length with the original input sample as the final sponge test sample. Otherwise, select the candidate adversarial suffix with the largest output sequence length to update the randomly initialized adversarial suffix and execute step 1.1 again. Step 1.6: Construct a sponge sample test dataset based on all sponge test samples.
2. A method for evaluating the availability of a chat model service according to claim 1, characterized in that: The specific steps of step 1.1 are: Each original input sample is concatenated with a randomly initialized adversarial suffix as the model input, and each word block in the model input is indexed by its position in the vocabulary of the chat model. Based on the size of the vocabulary, each position index is one-hot encoded. After one-hot encoding, a one-hot vector is obtained. The position index corresponding to the vocabulary in the one-hot vector is set to 1, and the other positions are 0; The one-hot vector is mapped to a continuous real number space using an embedding layer, and then sent to the chat model for forward reasoning to obtain the output sequence.
3. A method for evaluating the availability of a chat model service according to claim 2, characterized in that: The total loss function in step 1.2 is: in, represents the total loss, Indicates EOS loss, represents uniform loss, represents the weight coefficient of uniform loss, Represents the total length of the output sequence of the chat model, Indicates the output sequence The chat model in the output position is <eos>The probability of a chunk, Indicates the output sequence The probability distribution of all chunks in the output positions, Indicates the output sequence uniform distribution of output positions, Represents KL divergence, which is a measure of and The smaller the KL divergence value, the closer the two distributions are.< / eos> 4. A method for evaluating the availability of a chat model service according to claim 3, characterized in that: Step 2 specifically includes the following steps: Step 2.1: Deploy the chat model as an online service based on an open source library, or upload the model to the large model cloud platform for one-click deployment as an online service. Deploying the chat model as an online service based on an open source library means deploying the chat model online as a backend using the open source library Ollama or vLLM. Then, through the open source library OpenWebUI, LangChain, or LM Studio, which provides a visual interaction interface for the chat model, the backend model is connected to the user to provide a visual interaction interface, simulating the chat model service in real-world scenarios. The large model deployment cloud platform includes HuggingFace's Inference Endpoint. Step 2.2: Send the sponge sample test datasets one by one to the online service and obtain overhead indicators during service operation, including the output sequence length of the large chat model, hardware resource consumption, service response time, and network throughput. Hardware resources include memory, video memory, and floating-point calculation times. Step 2.3: Compare the difference between each overhead indicator and the overhead indicator of the normal sample in the normal sample data set, and finally generate the service test results. The normal sample data set includes the ShareGPT data set and the Alpaca data set.
5. A usability evaluation system for a chat model service, characterized in that: include: Dataset construction module: Based on the original input samples and the chat model, a sponge sample test dataset is constructed using the mapping relationship between gradients and word chunks; Usability evaluation module: This module evaluates the usability of the chat model based on the sponge sample test dataset. The module compares the specific values of each indicator in the normal dataset and the sponge sample test dataset to perform usability evaluation. The specific implementation steps of the dataset construction module are: Step 1.1: First, concatenate each original input sample with a randomly initialized adversarial suffix as the model input. Based on the model input and the vocabulary of the chat model, perform one-hot vector conversion and mapping, and then feed it into the chat model for forward inference to obtain an output sequence. The original input sample is user input from the chat model's public conversation datasets, including the ShareGPT dataset and the Alpaca dataset. The adversarial suffix includes at least one word block. Step 1.2: Construct a total loss function that combines EOS loss and uniform loss based on the output sequence. Step 1.3: Based on the total loss function, backpropagate the gradient corresponding to the adversarial suffix. Then, use the obtained gradient to apply the discrete text optimization algorithm of gradient search to obtain the top M largest negative gradients of the adversarial suffix as candidate adversarial suffixes. Step 1.4: Concatenate each candidate adversarial suffix with the original input sample and input it back into the chat model to obtain the corresponding output sequence. The cost of the chat model is evaluated based on the length of the output sequence. Step 1.5: If the chat model overhead reaches the maximum or the number of iterations reaches the maximum, stop the optimization and concatenate the candidate adversarial suffix with the largest output sequence length with the original input sample as the final sponge test sample. Otherwise, select the candidate adversarial suffix with the largest output sequence length to update the randomly initialized adversarial suffix and execute step 1.1 again. Step 1.6: Construct a sponge sample test dataset based on all sponge test samples.
6. A usability evaluation system for chat big model service according to claim 5, characterized in that: The specific steps of step 1.1 are: Each original input sample is concatenated with a randomly initialized adversarial suffix as the model input, and each word block in the model input is indexed by its position in the vocabulary of the chat model. Based on the size of the vocabulary, each position index is one-hot encoded. After one-hot encoding, a one-hot vector is obtained. The position index corresponding to the vocabulary in the one-hot vector is set to 1, and the other positions are 0; The one-hot vector is mapped to a continuous real number space using an embedding layer, and then sent to the chat model for forward reasoning to obtain the output sequence.
7. A usability evaluation system for a chat model service according to claim 6, characterized in that: The total loss function in step 1.2 is: in, represents the total loss, Indicates EOS loss, represents uniform loss, represents the weight coefficient of uniform loss, Represents the total length of the output sequence of the chat model, Indicates the output sequence The chat model in the output position is <eos>The probability of a chunk, Indicates the output sequence The probability distribution of all chunks in the output positions, Indicates the output sequence uniform distribution of output positions, Represents KL divergence, which is a measure of and The smaller the KL divergence value, the closer the two distributions are.< / eos> 8. A usability evaluation system for chat big model service according to claim 7, characterized in that: The specific implementation steps of the usability evaluation module are: Step 2.1: Deploy the chat model as an online service based on an open source library, or upload the model to the large model cloud platform for one-click deployment as an online service. Deploying the chat model as an online service based on an open source library means deploying the chat model online as a backend using the open source library Ollama or vLLM. Then, through the open source library OpenWebUI, LangChain, or LM Studio, which provides a visual interaction interface for the chat model, the backend model is connected to the user to provide a visual interaction interface, simulating the chat model service in real-world scenarios. The large model deployment cloud platform includes HuggingFace's Inference Endpoint. Step 2.2: Send the sponge sample test datasets one by one to the online service and obtain overhead indicators during service operation, including the output sequence length of the large chat model, hardware resource consumption, service response time, and network throughput. Hardware resources include memory, video memory, and floating-point calculation times. Step 2.3: Compare the difference between each overhead indicator and the overhead indicator of the normal sample in the normal sample data set, and finally generate the service test results. The normal sample data set includes the ShareGPT data set and the Alpaca data set.
Citation Information
Patent Citations
System load pressure testing method for large language model
CN118035104A