Model reasoning verification method and device, electronic equipment and storage medium

Through dynamic pruning reasoning and tree decoding methods, the problem of low efficiency of large model reasoning and decoding is solved, and efficient model reasoning verification and effect improvement are achieved.

CN119338007AActive Publication Date: 2025-01-21CHINA TELECOM ARTIFICIAL INTELLIGENCE TECHNOLOGY (BEIJING) CO LTD

Patent Information

Application Number
CN202411515559.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-28
Publication Date
2025-01-21
Estimated Expiration
2044-10-28

AI Technical Summary

Technical Problem

The existing large-model inference and coding methods mainly adopt unidirectional serial decoding, which leads to inefficient decoding, especially when long-form inference, cannot meet the needs of efficiently generating articles of hundreds or thousands of words.

Method used

A model reasoning and verification method is proposed. By obtaining text prompt words, using a large model to perform dynamic pruning reasoning, multiple candidate text sequences are generated, a candidate sequence combination tree is established, and tree decoding is used to determine the optimal text sequence.

Benefits of technology

It improves the speed and efficiency of model inference, improves the effect of model inference, realizes model inference verification, and reduces the number of model verifications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119338007A_ABST
    Figure CN119338007A_ABST
Patent Text Reader

Abstract

The invention discloses a model reasoning verification method and device, electronic equipment and a storage medium. The method comprises the following steps: acquiring a text cue word; performing dynamic pruning reasoning on the text cue word by utilizing a large model to generate a plurality of candidate text sequences; establishing a corresponding candidate sequence combination tree according to each candidate text sequence; performing tree decoding on the candidate sequence combination tree by using the large model, and determining a tree decoding output sequence; and performing consistency verification on each candidate text sequence according to the tree decoding output sequence, and determining an optimal text sequence from the plurality of candidate text sequences. The method can achieve model reasoning verification, introduces dynamic pruning reasoning, reduces the number of times of model verification, improves the model reasoning verification efficiency, improves the model reasoning effect, improves the model reasoning speed, and can be widely applied to the technical field of large model application.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of large model application, and in particular to a model reasoning verification method, device, electronic device and storage medium. Background Art

[0002] At present, the decoding of inference using large models is basically one-way decoding (decode only), that is, the current decoding needs to rely on the result of the previous decoding, which is a serial structure. This greatly reduces the decoding efficiency, especially when inferring long texts, often requiring hundreds or thousands of words to be generated in one request. Traditional serial decoding can no longer meet this demand.

[0003] In terms of large model reasoning, methods such as quantization and distillation are often used to make the model smaller, thereby increasing the model reasoning speed. However, this in turn leads to a decrease in the model reasoning effect. For example, methods such as flash attention that use fusion operators to alleviate IO achieve model reasoning verification by losing part of the softmax accuracy. Methods such as kv cache and page attention make a trade-off between cache and reading speed, alleviating redundancy in the reasoning process by sacrificing cache, thereby speeding up the model reasoning speed. Summary of the invention

[0004] The main purpose of the embodiments of the present application is to propose a model reasoning verification method, device, electronic device and storage medium, which can realize model reasoning verification, improve model reasoning speed, improve model reasoning verification efficiency, and improve model reasoning effect.

[0005] On the one hand, an embodiment of the present application proposes a model reasoning verification method, the method comprising the following steps:

[0006] Get text prompt words;

[0007] Using the large model to perform dynamic pruning reasoning on the text prompt words to generate multiple candidate text sequences;

[0008] According to each of the candidate text sequences, a corresponding candidate sequence combination tree is established;

[0009] Using the large model to perform tree decoding on the candidate sequence combination tree to determine a tree decoding output sequence;

[0010] According to the tree decoding output sequence, consistency verification is performed on each of the candidate text sequences, and an optimal text sequence is determined from the multiple candidate text sequences.

[0011] In some embodiments, the use of a large model to perform dynamic pruning reasoning on the text prompt words to generate multiple candidate text sequences specifically includes:

[0012] Dividing the text prompt word into text characters, determining each text character position and the unit text corresponding to each text character position;

[0013] Input the unit text corresponding to each of the text character positions into the multi-head attention mechanism network included in the large model, and output a plurality of inference texts corresponding to each of the unit texts and the attention accumulation probability corresponding to each of the inference texts;

[0014] According to the attention accumulation probability corresponding to each of the inference texts corresponding to each of the unit texts, dynamically determine a sampling threshold corresponding to each of the unit texts, and determine a plurality of candidate inference texts corresponding to the sampling threshold from the plurality of inference texts;

[0015] According to the multiple candidate inference texts corresponding to each of the unit texts and the text character positions, text arrangement and combination are performed to generate multiple candidate text sequences.

[0016] In some embodiments, the step of establishing a corresponding candidate sequence combination tree according to each of the candidate text sequences specifically includes:

[0017] Constructing the candidate sequence combination tree;

[0018] Determining the node level of each unit text in the candidate sequence combination tree according to the text character position corresponding to each unit text;

[0019] According to the node level corresponding to each of the unit texts, determine the node position of each of the candidate inference texts corresponding to each of the unit texts in the candidate sequence combination tree, and fill each of the candidate inference texts into the corresponding node position;

[0020] According to each of the candidate text sequences, a text association relationship between each of the candidate inference texts is determined, and according to the text association relationship, an association mark is established in the candidate sequence combination tree.

[0021] In some embodiments, using the large model to perform tree decoding on the candidate sequence combination tree to determine the tree decoding output sequence specifically includes:

[0022] Input the candidate sequence combination tree into the tree-like attention mechanism network in the large model for decoding, and output multiple target reasoning texts and the sequence position corresponding to each target reasoning text;

[0023] According to the sequence position of each target inference text, each target inference text is concatenated to generate the tree decoding output sequence.

[0024] In some embodiments, the step of performing consistency verification on each of the candidate text sequences according to the tree decoding output sequence and determining the optimal text sequence from the plurality of candidate text sequences specifically includes:

[0025] For each of the candidate text sequences, determine a consistent text sequence that matches the tree-decoding output sequence from the candidate text sequences, and determine a text length corresponding to the consistent text sequence, wherein the consistent text sequence is a sequence corresponding to a text overlap portion between the candidate text sequence and the tree-decoding output sequence;

[0026] Determine a target consistent text sequence from the consistent text sequences according to the text lengths corresponding to the consistent text sequences, wherein the text length corresponding to the target consistent text sequence is the longest;

[0027] The candidate text sequence to which the target consistent text sequence belongs is determined as the optimal text sequence.

[0028] In some embodiments, dynamically determining a sampling threshold corresponding to each of the unit texts according to the attention accumulation probability corresponding to each of the inference texts corresponding to each of the unit texts, and determining a plurality of candidate inference texts corresponding to the sampling threshold from a plurality of the inference texts specifically includes:

[0029] Obtaining a preset attention accumulation probability threshold;

[0030] According to the attention accumulation probability corresponding to each of the inference texts corresponding to each of the unit texts, determining a plurality of target texts from the plurality of inference texts, wherein the attention accumulation probability corresponding to the target text is greater than the attention accumulation probability threshold;

[0031] Counting the number of the target texts, and dynamically setting the sampling threshold according to the number of the target texts, wherein the sampling threshold is less than or equal to the number of the target texts;

[0032] According to the attention cumulative probability corresponding to each of the target texts, the attention cumulative probability is sorted, and a number of the candidate inference texts are determined from the multiple target texts, wherein the number of the candidate inference texts corresponds to the sampling threshold.

[0033] In some embodiments, the step of performing text arrangement and combination according to the plurality of candidate inference texts and the text character positions corresponding to each of the unit texts to generate a plurality of candidate text sequences specifically includes:

[0034] Determine the candidate text sequence position corresponding to each of the unit texts according to the text character position corresponding to each of the unit texts;

[0035] The candidate inference texts corresponding to the unit texts are sequentially filled into the candidate text sequence positions corresponding to the unit texts in the form of permutations and combinations to generate the candidate text sequences.

[0036] On the other hand, an embodiment of the present application proposes a model reasoning verification device, the device comprising:

[0037] The first module is used to obtain text prompt words;

[0038] The second module is used to use the large model to perform dynamic pruning reasoning on the text prompt words to generate multiple candidate text sequences;

[0039] The third module is used to establish a corresponding candidate sequence combination tree according to each of the candidate text sequences;

[0040] The fourth module is used to perform tree decoding on the candidate sequence combination tree using the large model to determine the tree decoding output sequence;

[0041] The fifth module is used to perform consistency verification on each of the candidate text sequences according to the tree decoding output sequence, and determine the optimal text sequence from the multiple candidate text sequences.

[0042] On the other hand, an embodiment of the present application proposes an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the model reasoning verification method described above when executing the computer program.

[0043] On the other hand, an embodiment of the present application proposes a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the model reasoning verification method described above.

[0044] The embodiments of the present application include at least the following beneficial effects: the present application provides a model reasoning verification method, device, electronic device and storage medium, which obtains text prompt words, uses a large model to perform dynamic pruning reasoning on the text prompt words, generates multiple candidate text sequences, establishes a corresponding candidate sequence combination tree according to each candidate text sequence, uses a large model to perform tree decoding on the candidate sequence combination tree, determines the tree decoding output sequence, performs consistency verification on each candidate text sequence according to the tree decoding output sequence, and determines the optimal text sequence from multiple candidate text sequences. The present application can realize model reasoning verification, introduce dynamic pruning reasoning, reduce the number of model verifications, improve the efficiency of model reasoning verification, enhance the model reasoning effect, and increase the speed of model reasoning. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 It is a flow chart of a model reasoning verification method provided by an embodiment of the present application;

[0046] Figure 2 is a flowchart of step S102 in an embodiment of the present application;

[0047] Figure 3 is a schematic diagram of dividing text prompt words into text characters in an embodiment of the present application;

[0048] Figure 4 is a flowchart of step S203 in an embodiment of the present application;

[0049] Figure 5 is a flowchart of step S204 in an embodiment of the present application;

[0050] Figure 6 is a flowchart of step S103 in an embodiment of the present application;

[0051] Figure 7 is a flowchart of step S104 in an embodiment of the present application;

[0052] Figure 8 is a flowchart of step S105 in an embodiment of the present application;

[0053] Fig. 9 It is a structural diagram of a model reasoning verification device provided in an embodiment of the present application;

[0054] Fig.10 It is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0055] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.

[0056] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".

[0057] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.

[0058] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0059] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.

[0060] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.

[0061] 1) Dynamic pruning: In the decoding process of a large model, logits need to be sampled and decoded. If the number of tokens intercepted each time is fixed, it is static pruning. If it changes according to specific circumstances, it is dynamic pruning. This patent is adjusted according to the cumulative probability distribution value, so it is dynamic pruning.

[0062] 2) Logit: Logit is an important concept in deep learning. It represents the raw value output by the model without being processed by the softmax function. These raw values ​​may be interpreted as the confidence score of the model for each possible output category, but they are not necessarily normalized or have probabilistic meaning23. During training, the model usually uses logits as the input of the loss function, which is then converted into a probability distribution through the softmax function and finally used to calculate the loss. In the testing or inference phase, the softmax function is usually used to convert logits into a probability distribution so that predictions can be made based on the category with the highest score.

[0063] 3) Token: refers to breaking down the input text into smaller units, such as words, letters, or characters. In natural language processing, breaking down text into tokens helps the model understand semantic and grammatical structures. When a prompt is sent to the big model, it is broken down into multiple tokens, a process called Tokenier. Generally, for English words, four characters represent a token.

[0064] 4) Top-k sampling: Top-k sampling is a decoding strategy commonly used in natural language generation tasks, which aims to balance the diversity and accuracy of generated text. In each decoding step, the model selects the top k words in terms of likelihood, and then randomly selects one of these words as the next generated word.

[0065] 5) Prompt: refers to a text prompt word, which is a piece of text input into the model. It aims to guide the model to generate output with specific content or following a specific context. It can help the AI ​​model generate articles, scripts and other content.

[0066] 6) N-gram model: The N-gram model is an algorithm based on a statistical language model. Its basic idea is to perform a sliding window operation of size N on the text content according to bytes to form a sequence of byte segments of length N. Each byte segment is called a gram. The occurrence frequency of all grams is counted and filtered according to a set threshold to form a key gram list, that is, the vector feature space of the text.

[0067] 7) Vocabulary size: refers to the size of the training set dictionary. In natural language processing (NLP), vocab size usually refers to the number of different words or tokens in the training set. During training, the model learns embedded representations of these words so that it can recognize and utilize them when processing new text.

[0068] 8) head_logits: In deep learning, it usually refers to the raw scores or scores of the model output layer, especially in classification problems. These scores are the linear output of the model for each category, and have not been processed by activation functions such as softmax or sigmoid. In deep learning frameworks, head_logits is usually represented as a tensor or array, where each element corresponds to the logit value of a category. For example, when dealing with a classification problem with 10 categories, the head_logits output of the network will be an array containing 10 elements.

[0069] 9) Softmax: The softmax function is mainly used in the output layer of multi-classification problems in large models. Its essence is a normalized exponential function that is used to convert a set of arbitrary real numbers into real numbers representing probability distribution. The softmax function maps the output value of the output node to the range of [0,1] and ensures that the sum of all output values ​​is 1, which makes it interpretable as a probability distribution.

[0070] At present, the decoding of inference using large models is basically one-way decoding (decode only), that is, the current decoding needs to rely on the result of the previous decoding, which is a serial structure. This greatly reduces the decoding efficiency, especially when inferring long texts, often requiring hundreds or thousands of words to be generated in one request. Traditional serial decoding can no longer meet this demand.

[0071] In terms of large model reasoning, methods such as quantization and distillation are often used to make the model smaller, thereby increasing the model reasoning speed. However, this in turn leads to a decrease in the model reasoning effect. For example, methods such as flash attention that use fusion operators to alleviate IO achieve model reasoning verification by losing part of the softmax accuracy. Methods such as kv cache and page attention make a trade-off between cache and reading speed, alleviating redundancy in the reasoning process by sacrificing cache, thereby speeding up the model reasoning speed.

[0072] Based on this, the embodiments of the present application propose a model reasoning verification method, device, electronic device and storage medium, which adopts a multi-head attention mechanism network for parallel decoding, and uses a tree-like attention mechanism network for tree-like reasoning decoding to improve the reasoning speed of large models, introduce a dynamic pruning processing mechanism, reduce the number of result verifications of large models, improve the efficiency of model reasoning verification, enhance the model reasoning effect, and realize model reasoning verification.

[0073] Reference Figure 1 , Figure 1This is an optional flowchart of a model reasoning verification method provided in an embodiment of the present application. The method may include but is not limited to steps S101 to S105:

[0074] Step S101, obtaining text prompt words;

[0075] Step S102, using the large model to perform dynamic pruning reasoning on the text prompt words to generate multiple candidate text sequences;

[0076] Step S103, establishing a corresponding candidate sequence combination tree according to each candidate text sequence;

[0077] Step S104, using the large model to perform tree decoding on the candidate sequence combination tree to determine the tree decoding output sequence;

[0078] Step S105 , performing consistency verification on each candidate text sequence according to the tree decoding output sequence, and determining the optimal text sequence from multiple candidate text sequences.

[0079] In some embodiments, the text prompt word is Prompt, and Prompt can be input into the big model. The big model performs reasoning and verification based on Prompt to generate an output with specific content or following a specific context, that is, the above-mentioned optimal text sequence.

[0080] In some embodiments, reference Figure 2 , Figure 2 This is an optional flowchart of step S102 in the embodiment of the present application. Step S102 may include but is not limited to steps S201 to S204:

[0081] Step S201, dividing the text prompt word into text characters, determining the position of each text character and the unit text corresponding to each text character position;

[0082] Step S202, inputting the unit text corresponding to each text character position into the multi-head attention mechanism network included in the large model, and outputting multiple inference texts corresponding to each unit text and the attention accumulation probability corresponding to each inference text;

[0083] Step S203, dynamically determining a sampling threshold corresponding to each unit text according to the attention accumulation probability corresponding to each inference text corresponding to each unit text, and determining a plurality of candidate inference texts corresponding to the sampling threshold from the plurality of inference texts;

[0084] Step S204, performing text arrangement and combination according to the multiple candidate inference texts and text character positions corresponding to each unit text, to generate multiple candidate text sequences.

[0085] In some embodiments, the prompt is divided into multiple tokens (such as the unit text above), each token has a fixed position in the prompt (such as the text character position above), refer to Figure 3 , Figure 3 It is an optional schematic diagram of text character division for a text prompt word in an embodiment of the present application, wherein Prompt is divided into multiple tokens, generating token1 to token5 and text character positions 1 to 5, the text character position corresponding to token1 is 1, the text character position corresponding to token2 is 2, and so on.

[0086] Optionally, the Prompt may be divided using an N-gram model to form a sequence of byte segments of length N, each byte segment being a token.

[0087] In some embodiments, each unit text is processed in parallel through a multi-head attention mechanism network to improve the reasoning speed of the model. Optionally, the multi-head attention mechanism network includes multiple self-attention structures, and each attention structure corresponds to each text character position one by one, and is used to obtain the unit text at the corresponding text character position, reason and predict the unit text, and output the corresponding prediction result. The prediction result includes multiple reasoning texts and the attention cumulative probability corresponding to each reasoning text. Optionally, the tokens at different text character positions are input into the corresponding respective attention structures, and the respective attention structures are used to perform reasoning and prediction, and output multiple next tokens corresponding to each token (such as the above-mentioned reasoning texts) and the logit corresponding to each next token (such as the above-mentioned attention cumulative probability).

[0088] The multi-head attention mechanism network is fine-tuned through the loss function to improve the reasoning and prediction effect of the multi-head attention mechanism network. The loss function is:

[0089]

[0090] Wherein, K is the number of self-attention structures, k is the kth self-attention structure, λ is the constraint weight, which is the constraint of the K value in the multi-head attention mechanism network, and refers to the regularization term constraint, which is a penalty for excessively large K values. t is the text character position corresponding to the unit text processed by the kth self-attention structure, and L is the cross entropy loss of the probability p of the text estimated value y at the associated text character position t+k+1 of position t when the kth self-attention structure is used to perform inference and prediction on the unit text at text character position t.

[0091] In some embodiments, reference Figure 4 , Figure 4This is an optional flowchart of step S203 in the embodiment of the present application. Step S203 may include but is not limited to steps S301 to S304:

[0092] Step S301, obtaining a preset attention accumulation probability threshold;

[0093] Step S302, determining a plurality of target texts from a plurality of inference texts according to the attention accumulation probabilities corresponding to the inference texts corresponding to the unit texts, wherein the attention accumulation probabilities corresponding to the target texts are greater than the attention accumulation probability threshold;

[0094] Step S303, counting the number of target texts, and dynamically setting a sampling threshold according to the number of target texts, wherein the sampling threshold is less than or equal to the number of target texts;

[0095] Step S304, sorting the attention cumulative probabilities corresponding to the target texts, and determining a number of candidate inference texts from the multiple target texts, wherein the number of candidate inference texts corresponds to a sampling threshold.

[0096] In some embodiments, each unit text is inferred and predicted through a multi-head attention mechanism network to obtain multiple inference texts corresponding to each unit text. Top-k sampling is performed according to the attention cumulative probability corresponding to each inference text, that is, the Top k candidate inference texts are taken out from the multiple inference texts, wherein the k value is the above-mentioned sampling threshold, and the k value can be set dynamically to realize dynamic pruning processing. Specifically, according to the attention cumulative probability corresponding to each inference text, multiple target texts whose attention cumulative probability is greater than the attention cumulative probability threshold are determined from the multiple inference texts, and the k value is set dynamically according to the number of target texts. If the number of target texts is too large, the vocab size of the large model can be obtained, and the k value is set according to the vocabsize, such as setting the k value to 60% or 50% of the vocab size, which can be set by yourself. If the number of target texts is small, the number of target texts can be directly taken as the k value. Then, according to the sampling threshold k corresponding to the unit text, multiple candidate inference texts corresponding to the sampling threshold are collected.

[0097] In some embodiments, reference Figure 5 , Figure 5 This is an optional flowchart of step S204 in the embodiment of the present application. Step S204 may include but is not limited to steps S401 to S402:

[0098] Step S401, determining the candidate text sequence position corresponding to each unit text according to the text character position corresponding to each unit text;

[0099] Step S402, filling each candidate inference text corresponding to each unit text in sequence into the candidate text sequence position corresponding to each unit text in the form of permutations and combinations, to generate each candidate text sequence.

[0100] In some embodiments, multiple candidate text sequences are generated based on multiple candidate inference texts of each unit text and the corresponding text character positions. The number of candidate text sequences is: k1*k2*k3*...*k n , where k n is the number of candidate inference texts corresponding to the unit text at text character position n. For example, assuming that there are token1 to token3, the candidate inference texts corresponding to token1 include token11 and token12, the candidate inference texts corresponding to token2 include token21, and the candidate inference texts corresponding to token3 include token31 and token32. The generated candidate text sequence includes: token11token21 token31, token11 token21 token32, token12 token21 token31, and token12token21 token32.

[0101] In some embodiments, reference Figure 6 , Figure 6 This is an optional flowchart of step S103 in the embodiment of the present application. Step S103 may include but is not limited to steps S501 to S504:

[0102] Step S501, constructing a candidate sequence combination tree;

[0103] Step S502, determining the node level of each unit text in the candidate sequence combination tree according to the text character position corresponding to each unit text;

[0104] Step S503, determining the node position of each candidate inference text corresponding to each unit text in the candidate sequence combination tree according to the node level corresponding to each unit text, and filling each candidate inference text into the corresponding node position;

[0105] Step S504: determine the text association relationship between the candidate inference texts according to the candidate text sequences, and establish an association mark in the candidate sequence combination tree according to the text association relationship.

[0106] In some embodiments, a candidate sequence combination tree is established based on each candidate text sequence. According to the node level corresponding to each unit text, the unit text with the front text character position has a higher node level. The node level corresponding to the unit text is determined as the node level of each candidate inference text. At this node level, the node position of each candidate inference text is determined, and each candidate inference text is filled into the corresponding node position to realize the construction of the candidate sequence combination tree. The candidate sequence combination tree is used to verify multiple candidate text sequences at one time, greatly improving the efficiency of model inference verification.

[0107] In some embodiments, reference Figure 7 , Figure 7 This is an optional flowchart of step S104 in the embodiment of the present application. Step S104 may include but is not limited to steps S601 to S602:

[0108] Step S601, input the candidate sequence combination tree into the tree-like attention mechanism network in the large model for decoding, and output multiple target reasoning texts and the sequence position corresponding to each target reasoning text;

[0109] Step S602, concatenating the target inference texts according to their sequence positions to generate a tree decoding output sequence.

[0110] In some embodiments, a tree attention network is used to decode the candidate sequence combination tree. Tree Attention is an attention mechanism that can efficiently capture information when processing tasks with complex data structures. The core idea is to reduce computational complexity and improve efficiency by limiting the scope of attention of each element. Tree Attention organizes sequence data into a tree structure so that each element only pays attention to other elements within a certain range of its neighbors. This mechanism enables Tree Attention to perform well in processing long sequence data, effectively capturing local information while reducing unnecessary calculations.

[0111] Tree attention jumps according to the tree decoding method. For example, suppose there is a candidate text sequence of "I am a teacher a student...", when decoding to "I am", it is identified that there are two candidate branches "Iam a teacher" and "I am a student". Then when decoding to I am a, if the large model predicts student, it can skip teacher and continue decoding directly to student, which can reduce the number of decoding times. Among them, "I", "am", "a" and "stuent" are all target inference texts. Multiple target inference texts are spliced ​​to generate a tree decoding output sequence, and the tree decoding output sequence is used as the output result of the large model.

[0112] In some embodiments, reference Figure 8 , Figure 8 This is an optional flowchart of step S105 in the embodiment of the present application. Step S105 may include but is not limited to steps S701 to S703:

[0113] Step S701, for each candidate text sequence, determining a consistent text sequence that matches the tree decoding output sequence from the candidate text sequence, and determining the text length corresponding to the consistent text sequence, wherein the consistent text sequence is a sequence corresponding to the text overlap portion of the candidate text sequence and the tree decoding output sequence;

[0114] Step S702, determining a target consistent text sequence from each consistent text sequence according to the text lengths corresponding to each consistent text sequence, wherein the text length corresponding to the target consistent text sequence is the longest;

[0115] Step S703: determine the candidate text sequence to which the target consistent text sequence belongs as the optimal text sequence.

[0116] In some embodiments, each candidate text sequence is verified according to the tree decoding output sequence generated by the tree attention mechanism network (Tree attention), and the sequence with the longest consistent text length overlapping with the tree decoding output sequence is determined from each candidate text sequence, that is, the above-mentioned target consistent text sequence.

[0117] The target consistency text sequence is determined as the optimal text sequence, and then the relevant model inference parameters of the optimal text sequence are used to update the model. For example, the head_logits corresponding to the optimal text sequence is determined, and the corresponding key and value in the multi-head self-attention mechanism network of the large model are updated. Among them, the association between key, value and head_logits is a cache mechanism in the multi-head self-attention mechanism. In order to improve the computational efficiency, the results of the previously calculated self-attention layer can be cached and reused when processing subsequent parts. The result cache of the self-attention layer usually contains the following parts: key: used to find the corresponding values, value: store the actual data, head_logits: weighted and scored in the self-attention calculation.

[0118] Reference Fig. 9 , Fig. 9 : is an optional structural diagram of a model reasoning verification device provided in an embodiment of the present application. The device can be used to implement the above-mentioned model reasoning verification method. The device may include:

[0119] The first module is used to obtain text prompt words;

[0120] The second module is used to use the large model to perform dynamic pruning reasoning on text prompt words to generate multiple candidate text sequences;

[0121] The third module is used to establish a corresponding candidate sequence combination tree according to each candidate text sequence;

[0122] The fourth module is used to perform tree decoding on the candidate sequence combination tree using the large model to determine the tree decoding output sequence;

[0123] The fifth module is used to verify the consistency of each candidate text sequence according to the tree decoding output sequence, and determine the optimal text sequence from multiple candidate text sequences.

[0124] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0125] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned model reasoning verification method when executing the computer program. The electronic device can be any smart terminal including a tablet computer.

[0126] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0127] See also Fig.10 , Fig.10 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:

[0128] The processor 901 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;

[0129] The memory 902 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 902 can store an operating system and other applications. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 902, and the processor 901 calls and executes the model reasoning verification method of the embodiment of this application;

[0130] Input / output interface 903, used to implement information input and output;

[0131] Communication interface 904, used to realize communication interaction between the device and other devices, which can be realized by wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);

[0132] A bus 905 that transmits information between the various components of the device (e.g., the processor 901, the memory 902, the input / output interface 903, and the communication interface 904);

[0133] The processor 901 , the memory 902 , the input / output interface 903 and the communication interface 904 are connected to each other in communication within the device via a bus 905 .

[0134] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the above-mentioned model reasoning verification method is implemented.

[0135] It can be understood that the contents of the above method embodiments are all applicable to the present storage medium embodiments, the functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0136] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0137] The embodiments of the present application provide a model reasoning verification method, device, electronic device and storage medium, which obtains text prompt words, uses a large model to perform dynamic pruning reasoning on the text prompt words, generates multiple candidate text sequences, establishes a corresponding candidate sequence combination tree according to each candidate text sequence, uses the large model to perform tree decoding on the candidate sequence combination tree, determines the tree decoding output sequence, and performs consistency verification on each candidate text sequence according to the tree decoding output sequence, and determines the optimal text sequence from multiple candidate text sequences. The embodiments of the present application can realize model reasoning verification, introduce dynamic pruning reasoning, reduce the number of model verifications, improve the efficiency of model reasoning verification, enhance the model reasoning effect, and increase the speed of model reasoning.

[0138] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0139] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

[0140] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0141] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0142] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0143] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0144] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0145] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0146] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0147] It should be appreciated that embodiments of the present invention may be implemented or enforced by computer hardware, a combination of hardware and software, or by computer instructions stored in a non-transitory computer-readable memory. The method may be implemented in a computer program using standard programming techniques including a non-transitory computer-readable storage medium configured with a computer program, wherein the storage medium so configured causes the computer to operate in a specific and predefined manner - according to the methods and drawings described in the specific embodiments. Each program may be implemented in a high-level procedural or object-oriented programming language to communicate with a computer system. However, if desired, the program may be implemented in an assembly or machine language. In any case, the language may be a compiled or interpreted language. In addition, the program may be run on a programmed ASIC for this purpose.

[0148] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.

[0149] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.

Claims

1. A model reasoning verification method, characterized in that: The method comprises the following steps: Get text prompt words; Using the large model to perform dynamic pruning reasoning on the text prompt words to generate multiple candidate text sequences; According to each of the candidate text sequences, a corresponding candidate sequence combination tree is established; Using the large model to perform tree decoding on the candidate sequence combination tree to determine a tree decoding output sequence; According to the tree decoding output sequence, consistency verification is performed on each of the candidate text sequences, and an optimal text sequence is determined from the multiple candidate text sequences.

2. The model reasoning verification method according to claim 1, characterized in that: The method of using the large model to dynamically prune the text prompt words to generate multiple candidate text sequences specifically includes: Dividing the text prompt word into text characters, determining each text character position and the unit text corresponding to each text character position; Input the unit text corresponding to each of the text character positions into the multi-head attention mechanism network included in the large model, and output a plurality of inference texts corresponding to each of the unit texts and the attention accumulation probability corresponding to each of the inference texts; According to the attention accumulation probability corresponding to each of the inference texts corresponding to each of the unit texts, dynamically determine a sampling threshold corresponding to each of the unit texts, and determine a plurality of candidate inference texts corresponding to the sampling threshold from the plurality of inference texts; According to the multiple candidate inference texts corresponding to each of the unit texts and the text character positions, text arrangement and combination are performed to generate multiple candidate text sequences.

3. The model reasoning verification method according to claim 2, characterized in that: The step of establishing a corresponding candidate sequence combination tree according to each of the candidate text sequences specifically includes: Constructing the candidate sequence combination tree; Determining the node level of each unit text in the candidate sequence combination tree according to the text character position corresponding to each unit text; According to the node level corresponding to each of the unit texts, determine the node position of each of the candidate inference texts corresponding to each of the unit texts in the candidate sequence combination tree, and fill each of the candidate inference texts into the corresponding node position; According to each of the candidate text sequences, a text association relationship between each of the candidate inference texts is determined, and according to the text association relationship, an association mark is established in the candidate sequence combination tree.

4. The model reasoning verification method according to claim 3, characterized in that: The step of performing tree decoding on the candidate sequence combination tree using the large model to determine the tree decoding output sequence specifically includes: Input the candidate sequence combination tree into the tree-like attention mechanism network in the large model for decoding, and output multiple target reasoning texts and the sequence position corresponding to each target reasoning text; According to the sequence position of each target inference text, each target inference text is concatenated to generate the tree decoding output sequence.

5. The model reasoning verification method according to claim 1, characterized in that: The step of performing consistency verification on each of the candidate text sequences according to the tree decoding output sequence and determining the optimal text sequence from the plurality of candidate text sequences specifically includes: For each of the candidate text sequences, determine a consistent text sequence that matches the tree-decoding output sequence from the candidate text sequences, and determine a text length corresponding to the consistent text sequence, wherein the consistent text sequence is a sequence corresponding to a text overlap portion between the candidate text sequence and the tree-decoding output sequence; Determine a target consistent text sequence from the consistent text sequences according to the text lengths corresponding to the consistent text sequences, wherein the text length corresponding to the target consistent text sequence is the longest; The candidate text sequence to which the target consistent text sequence belongs is determined as the optimal text sequence.

6. The model reasoning verification method according to claim 2, characterized in that: The method of dynamically determining a sampling threshold corresponding to each of the unit texts according to the attention accumulation probability corresponding to each of the inference texts corresponding to each of the unit texts, and determining a plurality of candidate inference texts corresponding to the sampling threshold from the plurality of inference texts specifically includes: Obtaining a preset attention accumulation probability threshold; According to the attention accumulation probability corresponding to each of the inference texts corresponding to each of the unit texts, determining a plurality of target texts from the plurality of inference texts, wherein the attention accumulation probability corresponding to the target text is greater than the attention accumulation probability threshold; Counting the number of the target texts, and dynamically setting the sampling threshold according to the number of the target texts, wherein the sampling threshold is less than or equal to the number of the target texts; According to the attention cumulative probability corresponding to each of the target texts, the attention cumulative probability is sorted, and a number of the candidate inference texts are determined from the multiple target texts, wherein the number of the candidate inference texts corresponds to the sampling threshold.

7. The model reasoning verification method according to claim 2, characterized in that: The step of performing text arrangement and combination according to the plurality of candidate inference texts and the text character positions corresponding to the unit texts to generate a plurality of candidate text sequences specifically includes: Determine the candidate text sequence position corresponding to each of the unit texts according to the text character position corresponding to each of the unit texts; The candidate inference texts corresponding to the unit texts are sequentially filled into the candidate text sequence positions corresponding to the unit texts in the form of permutations and combinations to generate the candidate text sequences.

8. A model reasoning verification device, characterized in that: The device comprises: The first module is used to obtain text prompt words; The second module is used to use the large model to perform dynamic pruning reasoning on the text prompt words to generate multiple candidate text sequences; The third module is used to establish a corresponding candidate sequence combination tree according to each of the candidate text sequences; The fourth module is used to perform tree decoding on the candidate sequence combination tree using the large model to determine the tree decoding output sequence; The fifth module is used to perform consistency verification on each of the candidate text sequences according to the tree decoding output sequence, and determine the optimal text sequence from the multiple candidate text sequences.

9. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the model reasoning verification method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the model reasoning verification method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Method for encoding a mesh model, encoded mesh model and method for decoding a mesh model

    CN103518387A

  • Auto-regression model parallel decoding method based on lexical tree dynamic generation

    CN118153523A

  • Auto-regression model parallel decoding method based on lexical tree early pruning

    CN118171635A

  • Method and system for realizing controllable text generation of large language model in medical field

    CN118210898A

  • Optimization method and device of large language model, electronic equipment and storage medium

    CN118364870A

Cited By

  • Parallel reasoning method and device, nonvolatile storage medium and electronic equipment

    CN121480716A

  • Model inference verification method and apparatus, electronic device, and storage medium

    WO2026091931A1