Low-delay large model reasoning method and system based on draft model and majority voting

By adopting a low-latency large model inference method based on draft models and majority voting in the customer service system, the problems of high LLM resource consumption and difficulty in maintaining draft models are solved, the efficiency and accuracy of inference are improved, and it is suitable for real-time operation of intelligent customer service systems. Respond to needs.

CN118761469APending Publication Date: 2024-10-11PIO CLOUD COMPUTING (SHANGHAI) CO LTD
View PDF 0 Cites 13 Cited by

Patent Information

Application Number
CN202410768412.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-14
Publication Date
2024-10-11

AI Technical Summary

Technical Problem

In the customer service system, the LLM-based question and answer model has problems such as high resource consumption, difficulty in maintaining draft models, and low acceptance rate of small speculative models, which affects the response speed of the system and customer satisfaction.

Method used

A low-latency large model inference method based on draft models and majority voting is adopted. By building multiple draft models and question and answer models, triplet encoders and context encoders are used to obtain feature-encoded text, and the optimal features are selected through a majority voting mechanism. Encode text for processing to improve reasoning efficiency and accuracy.

Benefits of technology

It effectively improves the performance of the question and answer model on the GPU, doubles the batch size, doubles the query rate per second (QPS), reduces hardware costs and maintenance complexity, and improves system parallelism and inference throughput. It is applicable Instant response scenarios for intelligent customer service systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118761469A_ABST
    Figure CN118761469A_ABST
Patent Text Reader

Abstract

The invention discloses a low-latency large model reasoning method and system based on a draft model and majority voting, and the method comprises the steps: collecting a user question and answer request, converting the user question and answer request into a prefix sequence, and constructing a triple; constructing a plurality of draft models, wherein each draft model at least comprises a triple encoder and a context encoder; respectively inputting the triple into each draft model, and obtaining a feature coding text of each lexical element based on the triple of all the lexical elements and a middle hidden state of the question and answer model; and constructing a text sequence selection decision tree based on the feature coding text, calculating the weight of each node in the text sequence selection decision tree based on the weight of each draft model, selecting an optimal feature coding text based on a majority voter mechanism, and processing a user question and answer request by the question and answer model based on the optimal feature coding text. According to the method, output is jointly speculated by using a plurality of draft models, so that the reasoning performance is improved, and the maintenance cost and complexity are remarkably reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of question-answering model reasoning, and specifically relates to a low-latency large model reasoning method and system based on a draft model and majority voting. Background Art

[0002] In recent years, large language models (LLMs) have demonstrated excellent performance in multiple application scenarios, such as natural language processing, machine translation, and text generation. However, in customer service systems, question-answering models based on LLMs and their auxiliary models such as draft models still face the following problems and challenges:

[0003] 1. Resource consumption and decoding efficiency

[0004] In customer service systems, LLM is used to handle a large number of user queries and provide instant responses. However, LLM requires a lot of computing resources when decoding, which affects the response speed and cost-effectiveness of the system. The introduction of draft models can alleviate this problem to a certain extent and improve the response speed through parallel prediction. However, parallel prediction may lead to incorrect answers due to insufficient accuracy in customer service scenarios, which will reduce customer satisfaction.

[0005] 2. Maintenance of independent draft models

[0006] In the customer service system, maintaining independent draft models is also a challenge. The accuracy of the draft model directly affects the response quality of the customer service system, and any inaccurate answers may lead to customer loss. As the amount of customer service data increases, verification time becomes a bottleneck for inference acceleration, affecting the system's real-time response capabilities.

[0007] 3. Low acceptance rate of small speculative models (SSM)

[0008] In the customer service scenario, the low acceptance rate of SSM results in fewer successfully verified inference tokens, affecting the inference efficiency. The queries in the customer service system are diverse, and the selection of inference length is complex. Different queries require different inference lengths. Wrong selection will increase the verification cost and reduce the inference efficiency. In addition, the idle time during the decoding and verification process will prolong the customer waiting time and affect the user experience.

[0009] In summary, although LLM has shown strong capabilities in customer service systems, its high resource consumption, difficulty in maintaining draft models, and low acceptance rate of small inference models have limited its performance and practical application effects. Optimizing these links is crucial to improving the efficiency and reliability of LLM in practical applications. Summary of the invention

[0010] In view of the above problems, the present invention proposes a low-latency large model inference method and system based on a draft model and majority voting, which can effectively improve the performance of the Q&A model on the GPU. On the llama-2-7b model + 4090 graphics card in NLP, the batch size can be doubled, and the QPS (queries-per-second) is increased by a total of 2 times. To solve the above technical problems, the technical solutions adopted by the present invention are as follows:

[0011] A low-latency large model inference method based on a draft model and majority voting, comprising the following steps:

[0012] S1, collect user Q&A requests, use the Q&A model to convert the user Q&A requests into prefix sequences, and construct triples for each token in the prefix sequence;

[0013] S2, construct a plurality of draft models, each draft model includes at least one triple encoder and one context encoder. The input end of the context encoder is used to receive the output of the triple encoder and the intermediate hidden state of the Q&A model. The output end of the context encoder is connected to the input end of the decoder of the Q&A model. The input end of the triple encoder is used to receive the triples of all tokens;

[0014] S3, input the triples obtained in step S1 into the draft models and the Q&A model obtained in step S2 respectively. Each draft model obtains the feature encoding text of each token based on the triples of all tokens and the intermediate hidden state of the Q&A model;

[0015] S4, construct a text sequence selection decision tree based on the feature encoding text obtained in step S3, and at the same time calculate the weight of each node in the text sequence selection decision tree based on the weight of each draft model. Select the optimal feature encoding text based on the majority voter mechanism, and the Q&A model processes the user Q&A requests based on the optimal feature encoding text.

[0016] In step S2, the method for obtaining the output of the triple encoder includes the following steps:

[0017] i, initialize the inference round τ = 1;

[0018] ii, input the triple t1 of the token x1 into the triple encoder to obtain the hidden state and cache the hidden state ;

[0019] iii, execute τ = τ + 1;

[0020] iv, judge whether τ < p. If so, based on the triple of the token x τ and the hidden state Using triplet encoder to get hidden state For hidden state Cache and return to step iii, otherwise, execute step v, where p represents the total number of word units in the prefix sequence;

[0021] v, all hidden states in the output cache.

[0022] The hidden state The expression is:

[0023]

[0024] In the formula, MLP represents the linear layer, SwiGLU represents the nonlinear activation function, BN represents batch normalization, and t τ Represents word x τ The triplet of .

[0025] In step S3, the expression of the feature coding text is:

[0026]

[0027] In the formula, represents the word x output by the j-th draft model i The feature encoding text, Represents the i-th word x output by the question-answering model i The intermediate hidden state of Represents the pth word x output by the question-answering model p The intermediate hidden state of .

[0028] In step S4, before calculating the weight of each node in the text sequence selection decision tree based on the weight of each draft model, the weighted majority algorithm and the Bert-Score evaluation method can be used to update the weights of all draft models. The update formula is:

[0029]

[0030] In the formula, w j (t+1) represents the weight of the j-th draft model at time t+1, w j (t) represents the weight of the j-th draft model at time t, η represents the learning rate, Q j (t) represents the inference quality metric of the j-th draft model at time t obtained based on the Bert-Score evaluation method, represents the average inference quality metric of all draft models at time t.

[0031] After updating the weights of all draft models, the updated weights are normalized. The calculation formula for the normalized weights is:

[0032]

[0033] In the formula, w j′ (t+1) represents the weight of the j′th draft model after being updated at time t+1, and N represents the total number of draft models.

[0034] A low-latency large-model reasoning system based on a draft model and majority voting, comprising:

[0035] Model storage module: used to store question-answering models, which are used to process user question-answering requests;

[0036] Triple construction module: used to collect user question and answer requests, convert the user question and answer requests into prefix sequences using the question and answer model stored in the model storage module, and construct triples for each word in the prefix sequence;

[0037] A draft model building module: used to build several draft models, each of which includes at least one triple encoder and one context encoder. The input end of the context encoder is used to receive the output of the triple encoder and the intermediate hidden state of the question-answering model stored in the model storage module. The output end of the context encoder is connected to the input end of the question-answering model decoder. The input end of the triple encoder is used to receive the triples of all word units output by the triple building module.

[0038] Feature encoding text acquisition module: used to acquire the feature encoding text of each word based on the triples of all word units output by the triple building module, the intermediate hidden states of the question-answering model stored in the model storage module, and all the draft models of the draft model building module;

[0039] Request processing module: used to build a text sequence selection decision tree based on the feature coding text output by the feature coding text acquisition module, and calculate the weight of each node in the text sequence selection decision tree based on the weight of each draft model output by the draft model establishment module, select the optimal feature coding text based on the majority voter mechanism, and use the question and answer model stored in the model storage module to process the user question and answer request based on the optimal feature coding text.

[0040] Beneficial effects of the present invention:

[0041] 1. A lightweight draft model is introduced, which effectively uses previously generated tokens to predict subsequent words. To ensure accuracy and efficiency, two strategies are proposed in the lightweight draft model: first, using triples to focus on capturing the underlying short-range dependencies (relationships); second, using the original question-answering model to capture long-range dependencies. Through empirical evaluation of the llama2 series, compared with ordinary auto-regressive decoding methods, the present invention has lower requirements for card video memory, can support eight cards in a single machine, reduce hardware costs, and reduce PCIe (PCI-Express, peripheral component interconnectexpress) communication;

[0042] 2. Since the low acceptance rate of the draft model and the high verification cost of the LLM hinder the further improvement of the reasoning performance, the present invention adds a majority voting mechanism to use multiple draft models to jointly infer the output of the question-answering model, thereby improving the reasoning performance without introducing excessive computational costs for the question-answering model. In addition, the decoding of the draft model and the LLM verification are efficiently decoupled, and the pipeline execution mechanism is adopted, which greatly improves the parallelism and reasoning throughput of the system. This innovative execution mechanism further enhances the reasoning performance of the question-answering model and provides strong support for its wide application in practical applications;

[0043] 3. The collective wisdom of multiple small draft models is used to infer the output of the question-answering model, and the accuracy and acceptance rate of the inference are improved through the majority voting mechanism; by adopting a more efficient maintenance strategy, the maintenance cost and complexity are significantly reduced, thereby comprehensively improving the reasoning efficiency. In addition, the present invention also optimizes the verification process, greatly shortens the verification time, and thus speeds up the response speed of LLMs in real-time applications. This improvement makes the question-answering model more suitable for application scenarios such as intelligent customer service systems that require instant responses. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0045] Figure 1 Schematic diagram of the structure of the triplet encoder and context encoder.

[0046] Figure 2 It is a schematic diagram of the process of the present invention.

[0047] Figure 3 An example diagram of how to choose a decision tree for a text sequence. DETAILED DESCRIPTION

[0048] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0049] Before the embodiments of the present application, the prior art involved in the present application is briefly introduced as follows:

[0050] Transformer: Transformer is a deep learning model architecture that is mainly used to process sequence data, especially in the field of natural language processing (NLP). It was first proposed by the Google team in 2017 and has made significant breakthroughs in machine translation tasks. The core of the design of the Transformer model is the self-attention mechanism, which enables the model to dynamically pay attention to information at different positions when processing sequences and dynamically adjust weights according to the context, thereby capturing longer-distance dependencies without using traditional sequence modeling methods such as recurrent neural networks (RNNs) or long short-term memory networks (LSTMs). The Transformer model usually consists of two parts: an encoder and a decoder. The encoder is responsible for converting the input sequence into hidden representations, while the decoder converts these hidden representations into output sequences. Each encoder and decoder layer contains a multi-head self-attention mechanism and a fully connected feedforward network, as well as residual connections and layer normalization techniques to facilitate model training and convergence.

[0051] LLM: LLM is short for Large Language Model, which is a deep learning-based artificial intelligence model designed to process and generate natural language text. LLM is a special type of neural network model that has been pre-trained on a large scale to perform a variety of natural language processing tasks, such as language modeling, text generation, sentiment analysis, question answering, etc. LLMs are usually composed of billions or even tens of billions of parameters, which enables them to capture complex patterns and relationships in large-scale language data. The training of these models usually requires huge computing resources and a large amount of data, so they are often performed on large computer clusters or high-performance computing environments.

[0052] Draft model: Also known as the draft model, it takes a different approach by introducing a lightweight model to assist LLM in reasoning. To this end, the draft model usually adopts some simplification and approximation strategies, such as truncating the number of layers of the model, reducing the number of parameters, and adopting a faster reasoning algorithm. Since these strategies may reduce the accuracy of the model, the draft model is usually used in conjunction with the LLM as a preprocessing step in the LLM reasoning process. During the reasoning process, the draft model first receives the input of the LLM and generates a rough output. Then, the LLM further refines and corrects the output of the draft model to generate the final output result.

[0053] Speculative Decoding: This is a decoding paradigm where in each decoding step, multiple future tokens are first efficiently drafted and then verified in parallel using the original LLM. Specifically, in speculative decoding, the process is divided into two steps: drafting and verification. In the drafting step, multiple future tokens are quickly generated in parallel without waiting for verification. This drafting process is generally more efficient because it can exploit parallelism and take advantage of the computational power of modern hardware. After the drafting step is completed, all drafted tokens are verified simultaneously using the target language model. The language model evaluates the probability or likelihood of each drafted token, allowing for efficient and fast verification. By combining drafting and parallel verification, speculative decoding can significantly speed up inference, thereby accelerating inference for generative models.

[0054] A low-latency large model reasoning method based on a draft model and majority voting includes the following steps:

[0055] S1, collect user question and answer requests, use the embedding layer of the customer service system's question and answer model to convert the user question and answer requests into prefix sequences, and construct triples of each word based on the prefix sequence;

[0056] The prefix sequence is represented by X, X = {x1, ..., x i ,…,x p}, where x i represents the i-th word in the prefix sequence, p represents the number of words in the prefix sequence, and x i ∈R d , d represents the embedding dimension of the embedding layer.

[0057] The expression of the triple is:

[0058] t i =[x i-2 ,x i-1 ,x i ];(1)

[0059] In the formula, t i Represents word xi The triplet of x is the horizontal concatenation of the embedding. i-1 represents the i-1th word in the prefix sequence, x i-2 represents the i-2th word in the prefix sequence, and t i ∈R 3d Since there is no word before x1, the START tag needs to be used instead, that is, t1 = [START, START, x1], t2 = [START, x1, x2].

[0060] S2, constructing several draft models, each of which includes at least a triple encoder and a context encoder, the input end of the context encoder is used to receive the output of the triple encoder and the intermediate hidden state of the question-answering model constructed based on the LLM, and the output end of the context encoder is connected to the input end of the question-answering model decoder;

[0061] Since the lower layers of the pre-trained language model, i.e. the neural network layers below the FeedForward layer, such as the multi-attention layer, mainly focus on short-range dependencies, truncating the entire input into short-length blocks can reduce the inference time, because the computational complexity is related to the input length. This application uses the triple encoder as the basis of the lightweight draft model, which can save inference time without affecting performance too much. Figure 1 As shown, the triplet encoder is composed of multiple neural network layers, including a batch normalization (BatchNorm) layer, a first MLP (Multilayer Perceptron) layer, an activation function layer, and a second MLP layer. The output of the batch normalization layer is connected to the input of the first MLP layer, the output of the first MLP layer is connected to the input of the activation function layer, the output of the activation function layer is connected to the input of the second MLP layer, and the output of the second MLP layer is connected to the input of the context encoder. The input of the triplet encoder, i.e., the input of the batch normalization layer, is represented by T, where T = {t1,…,t i ,…,t p},like Figure 1 As shown in Figure 2, a text sequence consisting of p tokens of the prefix sequence can obtain p triples, where t p Represents word x p t1 represents the triple of word x1.

[0062] In a normal large language model, capturing long-range dependencies across a long context usually requires multiple attention modules, so the lightweight draft model cannot accomplish this task in the original way, so we need to use the ready-made intermediate hidden states in the original LLM. Figure 1As shown, the context encoder includes a transformer model and a linear layer (also known as Linear), the input end of the transformer model is used to receive the output of the triple encoder, the output end of the transformer model is connected to the input end of the linear layer, and the output end of the linear layer is connected to the input end of the LLM model decoder.

[0063] In summary, the triple encoder focuses on local triple representations to save inference time and space complexity, and mainly handles short-distance dependencies. The context encoder uses Transformer blocks to handle long-distance dependencies of the entire sequence. Its goal is to capture global semantics and dependencies in the entire context. By leveraging the hidden states encoded by the original large language model (LLM), the context encoder is able to inherit and utilize longer-distance dependencies without retraining or completely replacing the original model. While maintaining global semantic consistency, it can combine the hidden states of the original LLM with the local dependency information generated by the triple encoder. By processing the input through the Transformer block, it can effectively capture long-distance dependencies and broader and deeper semantic relationships, improving the model's understanding and modeling capabilities of the entire input sequence.

[0064] S3, inputting the triples obtained in step S1 into the draft model and the question-answering model obtained in step S2 respectively, and the context encoder of each draft model obtains the feature encoding text of each word based on the output of the corresponding triple encoder and the intermediate hidden state of the question-answering model respectively;

[0065] The output of the triple encoder, i.e., the hidden state of the triple, is expressed as:

[0066]

[0067] In the formula, represents the output of the triplet encoder of the j-th draft model, Represents word x i The hidden state in the j-th draft model, Represents word x p Hidden states in the j-th draft model.

[0068] The method of obtaining the output of the triplet encoder comprises the following steps:

[0069] i, initialize the reasoning round τ = 1;

[0070] ii. Input the triplet t1 of word x1 into the triplet encoder to get the hidden state And for the hidden state Cache.

[0071] iii. Execute τ = τ + 1;

[0072] iv. Determine if τ < p. If so, based on the triple of the token x τ and the hidden state use the triple encoder to obtain the hidden state cache the hidden state and return to step iii. Otherwise, execute step v;

[0073] The formula for the hidden state is:

[0074]

[0075] where MLP represents a linear layer, SwiGLU represents a non - linear activation function, BN represents batch normalization, and t τ represents the triple of the token x τ ;

[0076] v. Output all the hidden states in the cache;

[0077] One advantage of the triple encoder is that by pre - computing and caching the hidden states of triples, a large amount of time can be saved during the inference process. To make full use of the limited cache space, a fixed - size triple is used as the cache and stored in the cache. We adopt the method in pagedattention to maintain a mapping access table from the logical space to the physical space for the storage of triples. By calling the address in the mapping access table, the hidden state cached at the corresponding address can be called. This is prior art and will not be elaborated in this application. When a new triple is encountered, the least recently used strategy is adopted to remove the least frequently used triple from the cache to make room for the new triple and load it into the cache.

[0078] The expression for the feature - encoded text, which is also the output of each draft model, is:

[0079]

[0080] where represents the feature - encoded text of the token x output by the j - th draft model i ; represents the intermediate hidden state of the i - th token output by the question - answering model, represents the intermediate hidden state of the p - th token output by the question - answering model.

[0081] From formula (3), we can see that the input length of the context encoder is p+p. In order to manage the increased length, we only retain the last p hidden states as the output of the full context encoder.

[0082] S4, using the weighted majority algorithm and the Bert-Score evaluation method to update the weights of all draft models, constructing a text sequence selection decision tree based on the feature coding text obtained in step S3, and calculating the weight of each node in the text sequence selection decision tree based on the updated weight of each draft model, selecting the optimal feature coding text based on the majority voter mechanism, and the question-answering model processing the user's question-answering request based on the optimal feature coding text;

[0083] like Figure 2 As shown in the figure, the newly arrived user Q&A request is placed in the pending request pool and waits for execution. We execute the Q&A request through the pipeline execution mechanism and use the intermediate result pool to store the output of the draft model, thereby decoupling the draft model decoding and LLM verification. In order to ensure the efficiency of the pipeline, the scheduler can be used to execute the scheduler to track the intermediate result pool to determine the time of the draft model execution. At the same time, the scheduler also dynamically determines the speculation length of the draft model execution according to the Q&A model running time through the adaptive speculation length selector. Through the speculation length and execution time of the scheduler, we speculate the result of the request through the draft model execution engine. Specifically, it uses speculators with majority votes and uses the collective decision of multiple draft models to determine the draft model outputs approved by the majority. Then, these majority-approved outputs will be placed in the intermediate result pool and wait for the Q&A model verification. If the request is still incomplete after this round of verification, it will be moved to the running request pool to wait for the next execution.

[0084] This method dynamically adjusts the weight of each draft model through the weighted majority algorithm and the inferred quality metric to improve the accuracy and efficiency of the overall reasoning. In the initial stage of the method, an initial weight is set for each draft model. We use the Bert-Score evaluation method to assign an initial weight w to each draft model. i , models with better performance have higher initial weights. The weight update is based on the output quality of the draft model, adjusted by weighted majority decision and Bert-Score inference quality metric. The following steps are set for weight update: We define the inference quality metric Q i (t) to evaluate the performance of each draft model at time t, and then adjust the weight according to the inferred quality metric. The update formula is as follows:

[0085]

[0086] In the formula, w j(t+1) represents the weight of the j-th draft model at time t+1, w j (t) represents the weight of the j-th draft model at time t, η represents the learning rate, which is used to control the step size of weight update, Q j (t) represents the inference quality metric of the j-th draft model at time t, represents the average inference quality metric of all draft models at time t.

[0087] The average inference quality metric of all draft models at time t The calculation formula is:

[0088]

[0089] Where N represents the total number of draft models.

[0090] In addition, in order to ensure that the weights are within a reasonable range, the updated weights need to be normalized. The corresponding formula is:

[0091]

[0092] In the formula, w j′ (t+1) represents the weight of the j′th draft model after being updated at time t+1.

[0093] like Figure 3 As shown, each node in the tree represents a text word. Each output sequence of the draft model corresponds to a branch of the result pool, starting from the root node and ending at a leaf node. Figure 3 There are two text sequence selection decision trees in total. Each branch and trunk combination corresponds to an output of the draft model. The weight of each node is the sum of the weights of all the draft models that produce the output sequence. The larger the weight, the more correct the draft model that produces the output sequence path is. After obtaining the weighted tree, starting from the root node, iteratively search for the node with the largest weight at each tree level, and select the output of the draft model corresponding to the sequence path with the largest weight corresponding to the leaf node as the optimal feature encoding text.

[0094]

[0095] In the formula, leaf is the set of all leaf nodes in the text sequence selection decision tree, w u It represents the weight of the output sequence of a draft model represented by the leaf node, len(u) is the length of the output sequence, and dividing by len(u) is to eliminate the influence of the number of words. u represents the output sequence of a draft model represented by the leaf node, and O(r) represents the optimal feature encoding text at time t.

[0096] The embodiment of the present application also provides a low-latency large model reasoning system based on a draft model and majority voting, including:

[0097] Model storage module: used to store question-answering models, which are used to process user question-answering requests;

[0098] Triple construction module: used to collect user question and answer requests, convert the user question and answer requests into prefix sequences using the question and answer model stored in the model storage module, and construct triples for each word in the prefix sequence;

[0099] A draft model building module: used to build several draft models, each of which includes at least one triple encoder and one context encoder. The input end of the context encoder is used to receive the output of the triple encoder and the intermediate hidden state of the question-answering model stored in the model storage module. The output end of the context encoder is connected to the input end of the question-answering model decoder. The input end of the triple encoder is used to receive the triples of all word units output by the triple building module.

[0100] Feature encoding text acquisition module: used to acquire the feature encoding text of each word based on the triples of all word units output by the triple building module, the intermediate hidden states of the question-answering model stored in the model storage module, and all the draft models of the draft model building module;

[0101] Request processing module: used to build a text sequence selection decision tree based on the feature coding text output by the feature coding text acquisition module, and calculate the weight of each node in the text sequence selection decision tree based on the weight of each draft model output by the draft model establishment module, select the optimal feature coding text based on the majority voter mechanism, and use the question and answer model stored in the model storage module to process the user question and answer request based on the optimal feature coding text.

[0102] An embodiment of the present application also provides an electronic device, which includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the steps of the above-mentioned low-latency large model reasoning method based on the draft model and majority voting are performed.

[0103] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the low-latency large model reasoning method based on the draft model and majority voting are executed. Specifically, the storage medium can be a general storage medium, such as a mobile disk, a hard disk, etc. When the computer program on the storage medium is run, it can execute the embodiment of the low-latency large model reasoning method based on the draft model and majority voting.

[0104] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A low-latency large model reasoning method based on a draft model and majority voting, characterized in that: The steps include: S1, collect user question-answering requests, convert them into prefix sequences using the question-answering model, and construct triples for each word in the prefix sequence; S2, constructing several draft models, each of which includes at least a triple encoder and a context encoder, the input end of the context encoder is used to receive the output of the triple encoder and the intermediate hidden state of the question-answering model, the output end of the context encoder is connected to the input end of the question-answering model decoder, and the input end of the triple encoder is used to receive the triplets of all word units; S3, inputting the triples obtained in step S1 into the draft models obtained in step S2 respectively, and each draft model obtains the feature encoding text of each word based on the triples of all word units and the intermediate hidden state of the question-answering model; S4, constructing a text sequence selection decision tree based on the feature coding text obtained in step S3, and calculating the weight of each node in the text sequence selection decision tree based on the weight of each draft model, selecting the optimal feature coding text based on the majority voter mechanism, and the question and answer model processes the user question and answer request based on the optimal feature coding text.

2. The low-latency large model reasoning method based on a draft model and majority voting according to claim 1 is characterized in that: In step S2, the method for obtaining the output of the triplet encoder comprises the following steps: i, initialize the reasoning round τ = 1; ii. Input the triplet t1 of word x1 into the triplet encoder to get the hidden state And for the hidden state Cache. iii, execute τ=τ+1; iv. Determine if τ < p. If so, based on the triple and hidden state of the token x τ obtain the hidden state using the triple encoder for the triple and hidden state cache the hidden state and return to step iii. Otherwise, execute step v, where p represents the total number of tokens in the prefix sequence; v, all hidden states in the output cache.

3. The low-latency large model reasoning method based on a draft model and majority voting according to claim 2 is characterized in that: The hidden state The expression is: In the formula, MLP represents the linear layer, SwiGLu represents the nonlinear activation function, BN represents batch normalization, and t τ Represents word x τ The triplet of .

4. The low-latency large model reasoning method based on a draft model and majority voting according to claim 1 is characterized in that: In step S3, the expression of the feature coding text is: In the formula, represents the word x output by the j-th draft model i The feature encoding text, Represents the i-th word x output by the question-answering model i The intermediate hidden state of Represents the pth word x output by the question-answering model p The intermediate hidden state of .

5. The low-latency large model reasoning method based on a draft model and majority voting according to claim 1 is characterized in that: In step S4, before calculating the weight of each node in the text sequence selection decision tree based on the weight of each draft model, the weighted majority algorithm and the Bert-Score evaluation method can be used to update the weights of all draft models. The update formula is: In the formula, w j (t+1) represents the weight of the j-th draft model at time t+1, w j (t) represents the weight of the j-th draft model at time t, η represents the learning rate, Q j (t) represents the inference quality metric of the j-th draft model at time t obtained based on the Bert-Score evaluation method, represents the average inference quality metric of all draft models at time t.

6. The low-latency large model reasoning method based on a draft model and majority voting according to claim 5 is characterized in that: After updating the weights of all draft models, the updated weights are normalized. The calculation formula for the normalized weights is: In the formula, w j′ (t+1) represents the weight of the j′th draft model after being updated at time t+1, and N represents the total number of draft models.

7. A low-latency large-model reasoning system based on a draft model and majority voting, characterized in that: include: Model storage module: used to store question-answering models, which are used to process user question-answering requests; Triple construction module: used to collect user question and answer requests, convert the user question and answer requests into prefix sequences using the question and answer model stored in the model storage module, and construct triples for each word in the prefix sequence; A draft model building module: used to build several draft models, each of which includes at least one triple encoder and one context encoder. The input end of the context encoder is used to receive the output of the triple encoder and the intermediate hidden state of the question-answering model stored in the model storage module. The output end of the context encoder is connected to the input end of the question-answering model decoder. The input end of the triple encoder is used to receive the triples of all word units output by the triple building module. Feature encoding text acquisition module: used to acquire the feature encoding text of each word based on the triples of all word units output by the triple building module, the intermediate hidden states of the question-answering model stored in the model storage module, and all the draft models of the draft model building module; Request processing module: used to build a text sequence selection decision tree based on the feature coding text output by the feature coding text acquisition module, and calculate the weight of each node in the text sequence selection decision tree based on the weight of each draft model output by the draft model establishment module, select the optimal feature coding text based on the majority voter mechanism, and use the question and answer model stored in the model storage module to process the user question and answer request based on the optimal feature coding text.

Citation Information

Cited By

  • Inference method and device, electronic equipment and computer readable storage medium

    CN119272881A

  • Large model reasoning method and system based on adjacency matrix and speculative decoding

    CN119721244A

  • Large language model reasoning acceleration method and system based on progressive grassy tree

    CN120654833A

  • A large language model reasoning acceleration method and system based on a progressive drafting tree

    CN120654833B

  • Speculative decoding acceleration method based on multiple draft blocks and greedy verification

    CN121436190A