A large language model text generation sampling method and system based on a dynamic probability threshold, an electronic device, and a storage medium
By constructing a candidate set through ascending sorting and dynamic probability thresholding, the sampling method solves the problem of large language models' preference for high-probability words, enabling the exploration of the low-probability space and generating more diverse and creative texts.
Patent Information
- Application Number
- CN202611656652.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-26
- Publication Date
- 2026-11-24
AI Technical Summary
Existing large language models have sampling strategies that favor high-probability words, preventing them from actively exploring low-probability spaces and resulting in a lack of innovation in generated content.
A sampling method based on dynamic probability thresholds is adopted. A candidate set is constructed starting from low-probability words by sorting in ascending order. Combined with a preset exploration threshold and normalization technique, a dynamic candidate set is formed for random sampling.
It empowers the model to explore low-probability spaces, generates more diverse and creative text content, reduces the complexity of parameter tuning, and demonstrates good intelligent adaptability.
Smart Images

Figure CN123159284A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, specifically to a large language model text generation sampling method, system, electronic device, and storage medium based on dynamic probability thresholds. Background Technology
[0002] Large language models have become a core technology in the field of natural language processing. They generate text step by step by predicting the probability distribution of the next word based on the given context text. In this process, the sampling strategy plays a crucial role, directly determining how to select the final word from the probability distribution output by the model, thus profoundly affecting the determinism, diversity, and content quality of the generated text.
[0003] Currently, the industry has developed several mainstream sampling strategies. For example, temperature sampling controls the randomness of generation by adjusting a temperature coefficient to change the shape of the original probability distribution. Top-K sampling simply limits the sampling range to the K words with the highest probabilities. As an improvement, Top-P (also known as kernel sampling) dynamically determines a candidate set by accumulating probabilities. This candidate set consists of several words with the highest probabilities, and their cumulative probabilities exactly reach a preset threshold. In addition, there are more complex strategies such as typical sampling and Mirostat.
[0004] However, in-depth analysis reveals that all the aforementioned mainstream sampling methods share a common operational premise: they all first sort lexical units in descending order of their occurrence probability, and then select candidate lexical units starting from the end with the highest probability. This design paradigm implicitly assumes that high-probability lexical units are "good" and "reasonable," while low-probability lexical units are "bad" and "meaningless" and should be discarded.
[0005] This systematic preference for high-probability lexical units and exclusion of low-probability lexical units confines the output of large language models to a relatively conservative and predictable "safe zone." While this ensures the fluency and relevance of generated content in many scenarios, it also severely limits the model's exploratory capabilities and creativity. In scenarios requiring breakthrough thinking, such as scientific discovery, artistic creation, or brainstorming, truly novel and highly informative "inspirations" often lie hidden in the less favored low-probability regions. Therefore, existing large language models suffer from technical limitations in the sampling decision-making process, including a singular direction in candidate lexical unit selection and an inability to actively explore the low-probability space. Summary of the Invention
[0006] To address the problem that existing sampling strategies only focus on high-probability words, resulting in models being unable to explore low-probability spaces and generating content lacking innovation, this invention provides a large language model text generation sampling method, system, electronic device, and storage medium based on dynamic probability thresholds.
[0007] This invention discloses a large language model text generation sampling method based on dynamic probability thresholds, comprising: Obtain the original probability distribution associated with the next word to be generated; The obtained original probability distribution is sorted in ascending order according to the probability values of the word elements from smallest to largest, thus obtaining an ascending sort result; Using the ascending sorting results, by accumulating probabilities starting from the word with the lowest probability, a dynamic candidate set composed of low-probability words is determined when the accumulated probability first reaches or exceeds a preset exploration threshold. For each word in the final sampling candidate set, its original probability value is re-normalized to form an effective sampling probability distribution within the final sampling candidate set. Based on the formed sampling probability distribution, a word is randomly sampled from the final sampling candidate set as the output of the current step; The final sampling candidate set includes the dynamic candidate set.
[0008] Furthermore, the preset exploration threshold is a hyperparameter between 0 and 1.
[0009] Furthermore, after determining a dynamic candidate set composed of low-probability lexical terms, the method further includes: Based on the original probability distribution, a high-probability candidate set is determined by using the descending cumulative probability method; The dynamic candidate set is merged with the high-probability candidate set to form the final sampling candidate set.
[0010] Furthermore, obtaining the original probability distribution includes: The current context text sequence is input into a large language model based on the Transformer architecture, and the original probability distribution is obtained through forward propagation.
[0011] Furthermore, the method also includes: The output tokens are concatenated with the generated text sequence to form an updated text sequence, which is then used as the context for the next generation step.
[0012] This invention also discloses a large language model text generation sampling system based on dynamic probability thresholds, comprising: The probability distribution receiving module is used to obtain the original probability distribution associated with the next word to be generated; The ascending order sorting module is used to sort the original probability distribution in ascending order according to the probability values of the word elements from smallest to largest, thereby obtaining an ascending order sorting result. The dynamic candidate set determination module is used to determine a dynamic candidate set composed of low-probability words that, based on the ascending sorting result, accumulates probabilities starting from the word with the lowest probability and makes the accumulated probability reach or exceed a preset exploration threshold for the first time. The normalization module is used to re-normalize each word in the final sampling candidate set based on its original probability value, thereby forming an effective sampling probability distribution within the final sampling candidate set. The sampling output module is used to randomly sample a word from the final sampling candidate set according to the sampling probability distribution as the output of the current step; The final sampling candidate set includes the dynamic candidate set.
[0013] Furthermore, the system also includes: A high-probability candidate set determination module is used to determine a high-probability candidate set based on the original probability distribution using a descending cumulative probability method; The merging module is used to merge the dynamic candidate set with the high-probability candidate set to form the final sampling candidate set.
[0014] The present invention also provides an electronic device, including one or more processors and a memory, wherein the memory stores a computer program, and when the computer program is executed by the one or more processors, causes the one or more processors to perform the method as described in any of the preceding claims.
[0015] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method as described in any of the preceding claims.
[0016] Compared to existing technologies, this invention fundamentally changes the way large language model inference engines select lexical units through a sampling mechanism based on ascending cumulative probability. It no longer simply selects from the lexical units with the highest probability, but instead empowers the model to actively explore the low-probability space. This represents a direct improvement to the internal operating mechanism of the computer system, resulting in richer behavioral patterns for the inference engine.
[0017] The beneficial effects of this invention lie in its ability to provide opportunities for low-probability terms that are systematically ignored by traditional methods, thereby generating more diverse, creative, and unexpected text content. Simultaneously, through a single preset exploration threshold parameter, users can intuitively and conveniently control the aggressiveness of the exploration, reducing the complexity of parameter tuning. Furthermore, the size of the dynamic candidate set can adapt to the shape of the probability distribution, exploring a wider range when the distribution is sharp and relatively conservative when the distribution is flat, demonstrating good intelligent adaptability. Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating a large language model text generation sampling method based on dynamic probability thresholds, provided as an embodiment of the present invention.
[0019] Figure 2 The present invention provides a structural block diagram of a large language model text generation sampling system based on dynamic probability thresholds. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be described in detail below. Obviously, the described embodiments are merely some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0021] In the description of this invention, it should be understood that the terms "an," "a," etc., indicate the singular form but do not exclude the plural form unless explicitly defined in the context. For ease of understanding, this specification will define some core terms. Among them, "lexicon" refers to the basic unit in the vocabulary of the large language model, which can be a complete word, a subword, or a single character. "Original probability distribution" refers to the predicted probability distribution of the next lexicon, directly output by the large language model inference engine without any post-processing. "Preset exploration threshold" is a preset parameter between 0 and 1, used to control the range of candidate lexicons selected from the low-probability region. "Dynamic candidate set" is the set of lexicons selected from the low-probability region by the method of this invention for final sampling.
[0022] Currently, one of the core aspects of large language models in text generation is the sampling strategy. This strategy directly determines how to select the final output lexical units from the probability distribution predicted by the model, thus affecting the diversity, creativity, and coherence of the generated results. However, existing mainstream sampling strategies, such as Top-K sampling or Top-P (kernel) sampling, generally have an inherent technical limitation: they tend to select candidate lexical units from the head of the probability distribution, i.e., high-probability regions, while systematically excluding lexical units with lower probabilities. This paradigm of "preferring high probability and ignoring low probability" limits the model's output to a predictable and conventional range, making it difficult to actively explore regions that, although with lower probabilities, may contain innovative and information-rich content. This invention aims to solve the technical problem of the single direction of candidate lexical unit selection in existing technologies by introducing a new paradigm of constructing a candidate set from low-probability regions, thereby giving large language models the ability to explore the unknown and generate novel content.
[0023] Example 1 like Figure 1 As shown, this invention provides a large language model text generation sampling method based on dynamic probability thresholds, the detailed process of which is as follows. First, the step of obtaining the original probability distribution is performed, that is, obtaining the original probability distribution associated with the next word to be generated. This step is the data foundation of the entire sampling method. Specifically, the current context text sequence is input into a large language model, such as a large language model based on the Transformer architecture. The model performs forward propagation calculations through multiple Transformer layers within it, and finally generates an original probability distribution for all words in the vocabulary at its output layer. This distribution reflects the prediction confidence of the model for each possible next word given the current context. The original probability distribution obtained in this step is the direct input for all subsequent calculations and decisions.
[0024] After obtaining the original probability distribution, to enhance the robustness of the method, the distribution can be preprocessed. Specifically, to prevent words with a probability of zero from being forcibly included in the candidate set due to their extremely low probability, a very small positive value can be applied to the probability value of these words before sorting, for example... Subsequently, the method enters a crucial processing step: sorting the acquired original probability distribution in ascending order according to the probability values of the lexical units (words) from smallest to largest, thus obtaining an ascending sort result. During sorting, the mapping relationship between the original lexical unit indices and their sorted positions needs to be recorded so that the corresponding lexical units can be accurately reconstructed after determining the candidate set. This step is one of the core features that distinguishes this invention from existing technologies. Traditional sampling methods invariably use descending order to start screening from the lexical units with the highest probabilities. This invention, however, uses ascending order, placing the lexical units with the lowest probabilities at the beginning of the sequence, which creates the necessary prerequisite for subsequently constructing the candidate set from the "tail" of the probability distribution. This disruptive sorting method allows low-probability lexical units that would be immediately ignored in traditional methods to be given priority consideration in this invention. As a performance optimization, this sorting step does not necessarily require a complete sort of the entire vocabulary. Algorithms such as fast selection can be used first... Find the first condition that satisfies the cumulative probability condition in linear time complexity. 1 quantile, then only the one with the lowest probability Sort each element, thereby reducing the overall sorting cost from Significantly reduced.
[0025] The next step is to use the ascending sort result to determine a dynamic candidate set composed of low-probability words. Specifically, this step involves starting with the word with the lowest probability and accumulating its probability value in the original probability distribution one by one, continuously checking the accumulated probability sum. Accumulation stops when the accumulated probability sum first reaches or exceeds a preset exploration threshold. At this point, all the accumulated words together constitute a dynamic candidate set. For example, if the ascending probability sequence is... Then calculate the prefix cumulative sum. And find the smallest index. , making Then, the one with the lowest probability... each word element This forms a dynamic candidate set. The preset exploration threshold directly controls the scope of the exploration: the smaller the preset exploration threshold, the fewer lexical units the candidate set contains and the lower their probability, making the exploration more targeted; the larger the preset exploration threshold, the more lexical units the candidate set contains, resulting in a wider exploration scope. In a more preferred embodiment, the preset exploration threshold is not fixed but can be adaptively adjusted. For example, the threshold can be dynamically adjusted based on the perplexity of the generated text sequence, the semantic consistency score, or the currently performed task type label (such as "creative writing" or "fact-based question answering"), thereby achieving intelligent and adaptive control of the exploration level.
[0026] After determining the dynamic candidate set, since this set is only a subset of the complete vocabulary, the sum of the original probability values of each word element is usually not 1, and therefore cannot be directly used for probability sampling. Therefore, the following steps are performed: for each word element in the final sampling candidate set, its original probability value is re-normalized to form a sampling probability distribution effective within the dynamic candidate set. The final sampling candidate set includes the dynamic candidate set; in this embodiment, the final sampling candidate set is the dynamic candidate set.
[0027] Normalization is calculated by dividing the original probability value of each word in the candidate set by the sum of the original probability values of all words in the candidate set. Formally, for any word in the dynamic candidate set... Its new sampling probability It can be represented as: For words not belonging to the dynamic candidate set, their sampling probability is 0. This step ensures that the sum of the new sampling probabilities across the dynamic candidate set is 1, creating a legitimate probability space for subsequent random sampling. Besides the strategy of normalizing according to the original probability ratio, other optional probability adjustment strategies can be used. For example, uniform normalization can be used to ensure that all words in the dynamic candidate set have an equal probability of being selected; or weighted normalization can be used, which applies additional weights to words with lower original probabilities during the normalization process to further encourage exploration of extremely low probability regions.
[0028] The final execution step involves randomly sampling a word from the dynamic candidate set based on the formed sampling probability distribution as the output of the current step. This is a standard classification distribution sampling process, which can be implemented using efficient methods such as roulette wheel sampling or alias sampling. The sampled word is the final result of this round of text generation. This output word is then concatenated into the generated text sequence to form an updated text sequence. This updated sequence serves as the context for the next generation step and is re-inputted into the large language model, thus initiating a new round of autoregressive generation loop of "obtaining probability distribution - sorting - determining candidate set - normalization - sampling". Through this iterative feedback mechanism, the method of this invention can continuously explore low-probability regions, driving the model to generate coherent and creative text. In an interactive or iterative application scenario, this method also supports multi-round sampling and candidate set expansion. For example, if the lexical units generated by the initial sampling do not meet expectations or requirements, this embodiment can automatically or with user intervention increase the preset exploration threshold to expand the scope of the dynamic candidate set. Then, based on this expanded new candidate set, sampling is performed again to achieve a gradual and progressively open exploration process.
[0029] To illustrate the above method more specifically, a typical example is used for calculation and explanation below. Assume that in a certain generation step, the large language model, for a vocabulary containing only five lexical units {A, B, C, D, E}, outputs the following original probability distribution: P(A) = 0.01, P(B) = 0.04, P(C) = 0.10, P(D) = 0.25, P(E) = 0.60. We set a preset exploration threshold of 0.1. First, the original probability distribution is sorted in ascending order to obtain the sorted list of lexical units and their corresponding probability values and cumulative probabilities: the first is A, with a probability of 0.01 and a cumulative probability of 0.01; the second is B, with a probability of 0.04 and a cumulative probability of 0.05; the third is C, with a probability of 0.10 and a cumulative probability of 0.15; the fourth is D, with a probability of 0.25 and a cumulative probability of 0.40; and the fifth is E, with a probability of 0.60 and a cumulative probability of 1.00.
[0030] After obtaining the ascending sort results and cumulative probabilities, we search for the smallest set of words that causes the cumulative probability to first reach or exceed the preset exploration threshold of 0.1. We can see that when the third word C is accumulated, its cumulative probability... The value is 0.15, which is the first time it has been greater than or equal to 0.1. Therefore, we determine the size of the dynamic candidate set. The set consists of the three tokens with the lowest probabilities, i.e., the dynamic candidate set is {A, B, C}. This result shows that the proposed method successfully filters out a candidate range for exploration from the tail of the probability distribution.
[0031] Next, the probabilities of the words in the dynamic candidate set {A,B,C} are renormalized. The sum of the original probabilities of the words in the candidate set is 0.01 + 0.04 + 0.10 = 0.15. Therefore, the normalized sampling probability distribution is: ; ; Finally, based on this new sampling probability distribution, a word will be randomly sampled from the set {A,B,C} as the output. It is worth noting that although word A has the lowest original probability, it still has approximately 6.7% chance of being selected within the candidate set, which is impossible in traditional Top-P sampling, thus demonstrating the ability of this invention to enable the model to explore low-probability regions.
[0032] In certain application scenarios or probability distribution patterns, the method of the present invention may also include some optimized implementations. For example, to enhance the robustness of the method, especially when dealing with cases where the preset exploration threshold is extremely small or the probability distribution is extremely concentrated, a boundary protection mechanism can be introduced. Specifically, when determining the dynamic candidate set, if the size of the candidate set calculated based on the preset exploration threshold... If the probability is less than 1 (for example, when the preset exploration threshold is less than the probability of the word with the lowest probability), then the candidate set size is forcibly set to 1. In this way, it can be ensured that the dynamic candidate set contains at least one word, that is, the word with the lowest probability, thereby avoiding errors in the sampling process due to an empty candidate set.
[0033] The following example illustrates this boundary protection mechanism. Assume the original probability distribution is highly concentrated, containing only two terms: {A(0.11), B(0.89)}, and the preset exploration threshold is 0.1. After ascending sorting, A is the term with the lowest probability. Its cumulative probability... It has already exceeded the preset exploration threshold of 0.1, therefore The dynamic candidate set is {A}. After normalization, At this point, the sampling process degenerates into a deterministic output, inevitably selecting term A. This automatic degeneration into a deterministic output makes the method stable and reasonable when facing high-confidence predictions. If the preset exploration threshold is set to 0.9, then... It needs to continue to accumulate. ,at this time The dynamic candidate set is {A,B}, which contains all lexical units.
[0034] Example 2 Furthermore, to balance the exploratory nature and fluency of the generated text, the method of this invention can also be combined with traditional high-probability sampling strategies. As a preferred embodiment, after determining a dynamic candidate set composed of low-probability words using the ascending accumulation method of this invention, a high-probability candidate set can be additionally determined based on the same original probability distribution using a traditional descending accumulation probability method. For example, a conventional Top-P threshold (e.g., 0.9) can be set, accumulating in descending order starting from the word with the highest probability until the sum exceeds 0.9, thus obtaining a set composed of high-probability words. Subsequently, the low-probability dynamic candidate set determined by the method of this invention is merged with the high-probability candidate set determined by traditional methods (e.g., through a union operation) to form a final sampling candidate set. This merged set includes both high-probability words that ensure text fluency and relevance, and low-probability words that provide creativity and novelty. Finally, all words in this final sampling candidate set are uniformly renormalized based on their original probability values, and sampled according to the resulting final sampling probability distribution.
[0035] The method of this invention can also work in conjunction with another common sampling technique—temperature sampling. In this implementation, temperature sampling can be applied to the original probability distribution before executing the core process of this invention. Specifically, the log probabilities in the original probability distribution are divided by a temperature coefficient T, and then the probabilities are recalculated using the Softmax function. When T>1, the probability distribution becomes smoother, increasing the relative weight of low-probability words; when T<1, the distribution becomes sharper. The new probability distribution after temperature adjustment is then used as input for subsequent steps of this invention, such as ascending sorting and determining the dynamic candidate set. This collaborative strategy allows the shape of the entire probability distribution to be pre-adjusted by adjusting the temperature coefficient T, and then the sampling range from the low-probability region can be precisely controlled using the preset exploration threshold of this invention, providing richer combination and control methods.
[0036] To further highlight the advantages of this invention compared to existing technologies, the method of this invention is compared with the traditional Top-P sampling method below. We use the same original probability distribution as in the aforementioned embodiments: {A:0.01, B:0.04, C:0.10, D:0.25, E:0.60}. When the preset exploration threshold is set to a large value, such as 0.9, traditional Top-P sampling selects words in descending order, with a candidate set of {E, D, C}, because their cumulative probability 0.60 + 0.25 + 0.10 = 0.95 first exceeds 0.9. However, the method of this invention selects words in ascending order when the preset exploration threshold is 0.9, with a candidate set of {A, B, C, D, E}, which includes all words. The key difference lies in the situation when the preset exploration threshold is small. For example, when the preset exploration threshold is 0.1, traditional Top-P sampling selects the word with the highest probability, E (probability 0.60), with a candidate set of only {E}, exhibiting strong conservatism. When the preset exploration threshold is 0.1, as shown in the aforementioned embodiments, the candidate set of the method of this invention is {A, B, C}, which represents the three words with the lowest probabilities, demonstrating significant exploratory behavior. This comparison clearly shows that, under the same parameter control, Top-P sampling and the method of this invention have completely opposite candidate set selection directions. The smaller the preset exploration threshold, the more Top-P tends to produce deterministic high-probability outputs, while this invention focuses more on exploring a small range of low-probability regions. This intuitively proves that this invention successfully solves the technical problem of the single direction of candidate word selection in the prior art, providing a completely new dimension for the sampling mechanism of large language models.
[0037] Example 3 The above method embodiments can be implemented by a large language model text generation sampling system based on dynamic probability thresholds. For example... Figure 2As shown, the sampling system 10 can serve as a post-processing component of a large language model inference engine, specifically responsible for receiving the probability distribution output by the inference engine and deciding on the final output lexical units. The sampling system 10 includes a probability distribution receiving module 11, connected to the output of the large language model inference engine, used to acquire in real-time the original probability distribution associated with the next lexical unit to be generated. The sampling system 10 also includes an ascending order sorting module 12, which, after receiving the original probability distribution from the probability distribution receiving module 11, performs an ascending order sorting operation according to the probability values of each lexical unit in ascending order. A dynamic candidate set determination module 13, based on the ascending order sorting result, determines a dynamic candidate set composed of low-probability lexical units by accumulating probabilities starting from the lexical unit with the lowest probability, ensuring that the accumulated probability sum first reaches or exceeds a preset exploration threshold. If the final sampling candidate set only includes the dynamic candidate set, after the dynamic candidate set is determined, the normalization module 14 re-normalizes each lexical unit in the dynamic candidate set based on their original probability values, thereby forming a valid sampling probability distribution that is only effective within the dynamic candidate set. Finally, the sampling output module 15 randomly samples a lexical from the dynamic candidate set according to the sampling probability distribution generated by the normalization module 14, and feeds this lexical as the final output of the current generation step back to the inference engine or upper-layer application. These modules work together to fully implement the method described in this invention. In the specific hardware and software implementation architecture, to maximize efficiency, computationally intensive operations such as the ascending sorting module 12 and the dynamic candidate set determination module 13 can be executed on a graphics processing unit (GPU) and completed on the same device as the forward computation of the large language model to reduce data transfer overhead; while the relatively less computationally intensive normalization module 14 and sampling output module 15 can be executed on a central processing unit (CPU).
[0038] Furthermore, to implement the aforementioned hybrid sampling strategy, the sampling system 10 may also include a high-probability candidate set determination module and a merging module. The high-probability candidate set determination module operates in parallel, receiving the original probability distribution and using a traditional descending accumulation method to determine a high-probability candidate set. The merging module receives the low-probability set output by the dynamic candidate set determination module 13 and the high-probability set output by the high-probability candidate set determination module, and merges them into a final sampling candidate set. In this configuration, the normalization module 14 normalizes this merged final sampling candidate set, while the sampling output module 15 samples from this richer set, thus achieving a balance between exploration and utilization.
[0039] Example 4 This invention also provides an electronic device, which may be a server, personal computer, laptop computer, tablet computer, or smartphone. The electronic device includes one or more processors and a memory. The memory stores a computer program consisting of a series of computer instructions. When the one or more processors read and execute the computer program stored in the memory, the electronic device can implement all or part of the steps of the large language model text generation sampling method based on dynamic probability thresholds described in any of the foregoing embodiments. For example, it may perform operations such as obtaining the original probability distribution, ascending sorting, determining the dynamic candidate set, renormalization, and sampling output.
[0040] Example 5 This invention can also be embodied as a computer-readable storage medium. This storage medium can be non-volatile, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD), or it can be volatile, such as random access memory (RAM). This computer-readable storage medium stores a computer program product thereon, the program code contained therein, which, when executed by a processor, can implement any of the method embodiments disclosed in this invention. This means that the technical solutions of this invention can be distributed, installed, and run on various general-purpose computing devices in the form of software products.
[0041] The above description is only a preferred embodiment of the present invention. It should be noted that, for those skilled in the art, various improvements and modifications can be made to these embodiments without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A large language model text generation sampling method based on dynamic probability threshold, characterized in that, include: Obtain the original probability distribution associated with the next word to be generated; The obtained original probability distribution is sorted in ascending order according to the probability values of the word elements from smallest to largest, thus obtaining an ascending sort result; Using the ascending sorting results, by accumulating probabilities starting from the word with the lowest probability, a dynamic candidate set composed of low-probability words is determined when the accumulated probability first reaches or exceeds a preset exploration threshold. For each word in the final sampling candidate set, its original probability value is re-normalized to form an effective sampling probability distribution within the final sampling candidate set. Based on the formed sampling probability distribution, a word is randomly sampled from the final sampling candidate set as the output of the current step; The final sampling candidate set includes the dynamic candidate set.
2. The large language model text generation sampling method based on dynamic probability threshold according to claim 1, characterized in that, The preset exploration threshold is a hyperparameter between 0 and 1.
3. The large language model text generation sampling method based on dynamic probability threshold according to claim 1, characterized in that, After determining a dynamic candidate set composed of low-probability lexical terms, the method further includes: Based on the original probability distribution, a high-probability candidate set is determined by using the descending cumulative probability method; The dynamic candidate set is merged with the high-probability candidate set to form the final sampling candidate set.
4. The large language model text generation sampling method based on dynamic probability threshold according to claim 1, characterized in that, The acquisition of the original probability distribution includes: The current context text sequence is input into a large language model based on the Transformer architecture, and the original probability distribution is obtained through forward propagation.
5. The large language model text generation sampling method based on dynamic probability threshold according to claim 1, characterized in that, The method further includes: The output tokens are concatenated with the generated text sequence to form an updated text sequence, which is then used as the context for the next generation step.
6. A large language model text generation sampling system based on dynamic probability thresholds, characterized in that, include: The probability distribution receiving module is used to obtain the original probability distribution associated with the next word to be generated; The ascending order sorting module is used to sort the original probability distribution in ascending order according to the probability values of the word elements from smallest to largest, thereby obtaining an ascending order sorting result. The dynamic candidate set determination module is used to determine a dynamic candidate set composed of low-probability words that, based on the ascending sorting result, accumulates probabilities starting from the word with the lowest probability and makes the accumulated probability reach or exceed a preset exploration threshold for the first time. The normalization module is used to re-normalize each word in the final sampling candidate set based on its original probability value, thereby forming an effective sampling probability distribution within the final sampling candidate set. The sampling output module is used to randomly sample a word from the final sampling candidate set according to the sampling probability distribution as the output of the current step; The final sampling candidate set includes the dynamic candidate set.
7. The large language model text generation sampling system based on dynamic probability threshold according to claim 6, characterized in that, The system also includes: A high-probability candidate set determination module is used to determine a high-probability candidate set based on the original probability distribution using a descending cumulative probability method; The merging module is used to merge the dynamic candidate set with the high-probability candidate set to form the final sampling candidate set.
8. An electronic device, characterized in that, include: One or more processors; A memory on which computer programs are stored; When the computer program is executed by the one or more processors, the one or more processors cause the one or more processors to implement the method as described in any one of claims 1-5.
9. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the method as described in any one of claims 1-5.
