A reinforcement training method for improving the paragraph text parsing capability of a large language model
By optimizing training data through beta distribution and information entropy evaluation, and combining it with a position-aware loss weighting mechanism, the problem of insufficient understanding ability of large language models in the middle region is solved, achieving more efficient long text parsing ability and robustness.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- UNIV OF SCI & TECH OF CHINA
- Filing Date
- 2026-02-10
- Publication Date
- 2026-04-24
AI Technical Summary
Large language models are prone to the Lost in the Middle phenomenon when processing extremely long texts. Insufficient data sampling coverage and mismatch between loss function and position encoding lead to a decline in the model's ability to understand the middle region and unstable training.
A beta distribution is used to generate a dynamic scaling factor for constructing a dual-window mid-section. Combined with information entropy evaluation and adaptive window drift optimization mechanism, optimized training samples are generated. Iterative training is then performed through a position-aware mid-section loss weighting mechanism to ensure that the model pays attention to and learns mid-section information.
It significantly improves the model's retrieval and understanding accuracy in the middle position, shortens the number of training steps, enhances the model's adaptability and robustness to documents of different lengths, and achieves more efficient long text parsing capabilities.
Smart Images

Figure CN121683809B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of natural language processing and generative large language models, and more specifically, to an enhancement training method for improving the mid-segment text parsing capability of large language models. Background Technology
[0002] With the rapid development of artificial intelligence technology, large language models, such as the Llama series and GPT series, are increasingly widely used in scenarios such as financial analysis, legal contract interpretation, scientific paper understanding, and enterprise knowledge base management. In these practical applications, models often need to process extremely long texts, typically 4K-8K tokens, far exceeding their pre-training context window, such as a 50-page legal contract, a 30-page academic paper, or a retrieval augmentation generation (RAG) task containing multiple documents.
[0003] When processing long texts, researchers have discovered a common problem: the Lost in the Middle phenomenon. Specifically, when key information is located at the beginning or end of the text, the model typically understands and responds accurately; however, when key information is located in the middle, the model's understanding and retrieval accuracy drop significantly, exhibiting a U-shaped performance curve—low in the middle and high at both ends. This performance gap widens further in longer sequences; for example, in a sequence of 10K tokens, the retrieval accuracy for key information in the middle may be 40% lower than that at the beginning.
[0004] To address this issue, researchers proposed the CREAM (Continuity-Relativity indexing with gAussian Middle) method. CREAM divides the context into three parts—Head, Middle, and Tail—by performing position indexing operations within a pre-trained context window, and enhances the model's focus on the middle content through truncated Gaussian sampling. Experiments demonstrate that the CREAM method performs exceptionally well when scaling from 4K to 32K contexts, and its training cost is significantly lower than other methods that require training on the target length.
[0005] However, in-depth application revealed two key limitations of the CREAM method in solving the lost middle problem:
[0006] First, the data sampling coverage is insufficient. Although CREAM introduces Gaussian sampling to enhance the intermediate regions, its data construction strategy is relatively simple, using only a single central window for sampling, and lacks adaptability to different length scales. This results in insufficient observation density of the intermediate regions during model training, especially when dealing with ultra-long sequences of 16K+, where the coverage of the intermediate regions is severely inadequate. Furthermore, the fixed-position sampling method makes the model prone to positional dependence and lacks robustness to positional changes.
[0007] Secondly, there is a mismatch between the loss function and the positional encoding. CREAM still uses a uniform weighting strategy in its loss function design, which fails to adequately strengthen the learned signal in the intermediate region. When the context length is expanded, the position-phase mapping changes, and traditional methods fail to ensure that the loss weighting is consistent with the phase geometry of the RoPE (Rotary Positional Embedding) rotation encoding, resulting in a position-phase mismatch during training, leading to training instability and performance degradation.
[0008] Therefore, there is an urgent need for a method that can simultaneously optimize data sampling strategies and loss function design, and collaboratively solve the lost middle section problem from both the data and algorithm levels, so that large language models can truly have the ability to efficiently process ultra-long texts.
[0009] No effective solutions have yet been proposed to address the problems in the relevant technologies. Summary of the Invention
[0010] In response to the problems in related technologies, this invention proposes an enhanced training method to improve the mid-segment text parsing capability of large language models, thereby overcoming the aforementioned technical problems existing in the current related technologies.
[0011] Therefore, the specific technical solution adopted by the present invention is as follows:
[0012] An enhancement training method to improve the mid-segment text parsing ability of a large language model, the method includes the following steps:
[0013] S1. Generate a dynamic scaling factor through beta distribution, construct a mid-section double window based on the dynamic scaling factor to obtain the window position, extract and splice from the original long text corpus based on the window position to obtain preliminary training samples, and generate a position identifier sequence.
[0014] S2. Based on the preliminary training samples, obtain the middle section of text content, estimate the word frequency of the text content, and generate local information entropy. Based on the local information entropy, evaluate the middle section information density of the preliminary training samples. Trigger the adaptive window drift optimization mechanism through the information density evaluation results to optimize the preliminary training samples, obtain the optimized samples, and simultaneously generate the updated position identifier sequence.
[0015] S3. Input the optimized samples and the updated location identifier sequence into the large language model, and iteratively train the large language model through a location-aware mid-segment loss weighting mechanism to obtain the optimized large language model.
[0016] Furthermore, a dynamic scaling factor is generated through beta distribution. Based on this dynamic scaling factor, a mid-section dual-window structure is constructed to obtain the window positions. Based on these window positions, samples are extracted and concatenated from the original long text corpus to obtain preliminary training samples. A position identifier sequence is then generated, including:
[0017] S11. Generate a dynamic scaling factor based on the beta distribution of preset shape parameters, and determine the actual sequence length of the training samples by combining the pre-acquired target extended context length and the preset length scaling range.
[0018] S12. Construct a mid-segment double window based on the actual sequence length of the training samples to obtain the window division length, and determine the start and end positions of the window by combining the jitter mechanism.
[0019] S13. Extract and concatenate word sequences from the original long text corpus based on window position to obtain preliminary training samples, and generate a preliminary training sample position identifier sequence by combining each word position identifier.
[0020] Furthermore, a mid-segment double window is constructed based on the actual sequence length of the training samples to obtain the window division length, and the start and end positions of the window are determined by combining the jitter mechanism, including:
[0021] S121. Combine the actual sequence length of the training samples with the preset head retention length and tail retention length to perform length allocation, and obtain the total length of the middle section;
[0022] S122. Divide the total length of the middle section into left and right window lengths to obtain the division length of the left and right windows of the middle section. Determine the theoretical center of the text based on the total length of the original long text corpus. Sample within a uniformly distributed preset jitter range to obtain the center jitter value.
[0023] S123. The sum of the theoretical center and the center jitter value is taken as the center of the middle section, and the starting and ending positions of the left and right windows of the middle section are determined by combining them with the total length of the original long text corpus, the length retained at the beginning, the length retained at the end, and the division length of the left and right windows of the middle section.
[0024] Furthermore, based on the initial training samples, the text content of the middle section is obtained, word frequency estimation is performed on the text content, and local information entropy is generated. The information density of the middle section of the initial training samples is evaluated based on the local information entropy. The information density evaluation result triggers an adaptive window drift optimization mechanism to optimize the initial training samples, resulting in optimized samples. Simultaneously, an updated position identifier sequence is generated, including:
[0025] S21. Obtain the text content corresponding to the middle left and right windows based on the preliminary training samples, and calculate the occurrence probability of each word element based on the text content. Estimate the information density of the occurrence probability of each word element to obtain the local information entropy.
[0026] S22. Compare the local information entropy with the preset information entropy threshold, and evaluate the information density of the left and right windows in the middle section based on the comparison result to obtain the information density evaluation result.
[0027] S23. Based on the information density evaluation results, obtain the invalid window to be optimized. The invalid window to be optimized triggers the adaptive window drift optimization mechanism to optimize the initial training samples, obtain the optimized samples, and synchronously update the location identifier sequence to obtain the updated location identifier sequence.
[0028] Furthermore, based on the probability of occurrence of each word element in the text content, the information density of the probability of occurrence of each word element is estimated, resulting in the local information entropy, which includes:
[0029] Determine the lexicon set and vocabulary size based on the text content, and calculate the probability of occurrence of each lexicon in the lexicon set;
[0030] The information entropy of the occurrence probability of each word in the word set is aggregated to obtain the initial information entropy. The initial information entropy is then normalized by combining the logarithmic vocabulary size to obtain the local information entropy.
[0031] Furthermore, the information density of the left and right windows in the middle section is evaluated based on the comparison results, including:
[0032] If the comparison result shows that the local information entropy is less than the preset information entropy threshold, then the information density of the corresponding window is low, and it is determined that the corresponding window in the preliminary training samples needs to be optimized.
[0033] If the comparison result shows that the local information entropy is greater than or equal to the preset information entropy threshold, then the information density of the corresponding window is high, and it is determined that the corresponding window in the initial training samples does not need to be optimized.
[0034] Furthermore, the invalid windows to be optimized trigger an adaptive window drift optimization mechanism to optimize the initial training samples, resulting in optimized samples including:
[0035] Determine the center position of the invalid window to be optimized. Starting from the center position of the invalid window, use the adaptive window drift optimization mechanism to shift the window to the left and right sides of the center position by a preset window drift step size, and calculate the local information entropy of the window corresponding to each offset position to obtain the set of entropy values of the offset positions.
[0036] Select the offset position with the largest entropy value from the set of offset positions as the optimized window center. Use the optimized window center to re-truncate the original long text corpus and generate optimized samples.
[0037] Furthermore, the optimized samples and updated location identifier sequences are input into the large language model, and iterative training of the large language model is achieved through a location-aware mid-segment loss weighting mechanism, resulting in an optimized large language model including:
[0038] S31. Input the optimized sample into the large language model, and input the updated position identifier sequence into the position encoding layer of the large language model. Then, perform forward propagation through the large language model to obtain the initial prediction score.
[0039] S32. Determine the Gaussian weight distribution based on the updated location identifier sequence, and calculate the location-aware loss based on the Gaussian weight distribution to obtain the weighted total loss.
[0040] S33. Based on the weighted total loss, the gradient of the parameters of the large language model is calculated through backpropagation, and the parameters of the large language model are iteratively updated using an optimizer to obtain the optimized large language model.
[0041] Furthermore, by performing forward propagation through a large language model, the initial prediction scores are obtained, including:
[0042] The updated location identifier sequence is scaled using a linear interpolation function to obtain the actual location;
[0043] The actual position is encoded based on rotational position coding to obtain encoded position data, and the initial prediction score is calculated by a multi-layer converter.
[0044] Furthermore, a Gaussian weight distribution is determined based on the updated location identifier sequence, and the location-aware loss is calculated based on the Gaussian weight distribution to obtain the weighted total loss, which includes:
[0045] S321. Based on the updated location identifier sequence, calculate the geometric weighted center of the optimized sample in the original long text corpus;
[0046] S322. Based on the geometric weighting center, and combining the peak intensity coefficient and Gaussian width coefficient, calculate the Gaussian weight for each position in the updated position identifier sequence to obtain the Gaussian weight distribution:
[0047] S323. Combine the Gaussian weight distribution with the standard cross-entropy loss vector to calculate the weighted total loss.
[0048] The beneficial effects of this invention are as follows:
[0049] 1. This invention addresses the dual challenges of getting lost in the middle by combining information density assessment with position-aware training. It ensures the high value of the middle section of the training samples through information entropy verification and strengthens the focus on the middle section information through loss weighting. This results in a significant and balanced improvement in the retrieval and understanding accuracy of the model when processing information in the middle position of the sequence, successfully flattening the originally concave U-shaped performance curve and overcoming the training performance bottleneck.
[0050] 2. The weighted enhancement of key positions in this invention makes the model learning more targeted, avoids a lot of meaningless background noise, thereby shortening the number of training steps required to achieve the same accuracy and making training convergence faster.
[0051] 3. This invention enables the model to adapt to documents of various lengths through a dynamic sampling mechanism at the data end; the information entropy optimization mechanism enables the model to learn to focus on information-rich areas rather than fixed location centers, thereby exhibiting stronger generalization ability and robustness when facing real long texts of financial or scientific documents with a large number of tables and formulas in different fields and formats, thus enhancing generalization and robustness.
[0052] 4. This invention is entirely innovative at the training strategy level, without involving any changes to the main structure of the model. It has low computational overhead, and the optimized model can be directly and seamlessly integrated into existing large language model inference frameworks. It is fully compatible with mainstream RoPE context extension methods, has extremely low industrial implementation threshold and extremely high practical value, and can achieve low-cost integration and compatibility. Attached Figure Description
[0053] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0054] Figure 1 This is a flowchart of an enhanced training method for improving the mid-segment text parsing capability of a large language model according to an embodiment of the present invention;
[0055] Figure 2 This is a general technical roadmap for an enhanced training method to improve the mid-segment text parsing capability of a large language model according to an embodiment of the present invention. Detailed Implementation
[0056] To further illustrate the various embodiments, the present invention provides accompanying drawings, which are part of the disclosure of the present invention. These drawings are mainly used to illustrate the embodiments and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these drawings, those skilled in the art should be able to understand other possible implementation methods and the advantages of the present invention.
[0057] According to an embodiment of the present invention, an enhanced training method is provided to improve the mid-segment text parsing capability of a large language model.
[0058] The present invention will now be further described in conjunction with the accompanying drawings and specific embodiments, such as... Figure 1 As shown, the reinforcement training method for improving the mid-segment text parsing ability of a large language model according to an embodiment of the present invention includes the following steps:
[0059] S1. Generate a dynamic scaling factor through beta distribution, construct a mid-section double window based on the dynamic scaling factor to obtain the window position, extract and splice from the original long text corpus based on the window position to obtain preliminary training samples, and generate a position identifier sequence.
[0060] Specifically, a dynamic scaling factor is generated through beta distribution. A mid-section double-window structure is constructed based on this dynamic scaling factor to obtain the window positions. Based on these window positions, data is extracted and concatenated from the original long text corpus to obtain preliminary training samples. A position identifier sequence is then generated, including:
[0061] S11. Generate a dynamic scaling factor based on the beta distribution of preset shape parameters, and determine the actual sequence length of the training samples by combining the pre-acquired target extended context length and the preset length scaling range.
[0062] S12. Construct a mid-segment double window based on the actual sequence length of the training samples to obtain the window division length, and determine the start and end positions of the window by combining the jitter mechanism.
[0063] Specifically, a mid-segment double window is constructed based on the actual sequence length of the training samples to obtain the window division length, and the start and end positions of the window are determined by combining a jitter mechanism, including:
[0064] S121. Combine the actual sequence length of the training samples with the preset head retention length and tail retention length to perform length allocation, and obtain the total length of the middle section;
[0065] S122. Divide the total length of the middle section into left and right window lengths to obtain the division length of the left and right windows of the middle section. Determine the theoretical center of the text based on the total length of the original long text corpus. Sample within a uniformly distributed preset jitter range to obtain the center jitter value.
[0066] S123. The sum of the theoretical center and the center jitter value is taken as the center of the middle section, and the starting and ending positions of the left and right windows of the middle section are determined by combining them with the total length of the original long text corpus, the length retained at the beginning, the length retained at the end, and the division length of the left and right windows of the middle section.
[0067] S13. Extract and concatenate word sequences from the original long text corpus based on window position to obtain preliminary training samples, and generate a preliminary training sample position identifier sequence by combining each word position identifier.
[0068] Specifically, the initial construction of training samples is the starting point of this invention. Its main purpose is to break the fixed sampling pattern in the data preparation stage and train the model to adapt to different lengths and positional layouts. Traditionally, when training long text models, long articles are simply cut into fixed-length segments. This method has two problems: first, the segments may avoid the core parts of the article, resulting in the model rarely practicing the middle section; second, the fixed cutting method can lead to stereotypes about text positions. This invention aims to break this fixed pattern and proactively create diverse training scenarios for the model that contain rich middle section information. The initial construction of training samples includes three sub-mechanisms: a dynamic scale sampling mechanism, a dual-core window construction mechanism, and a center point position jitter mechanism.
[0069] Unlike traditional fixed-length sampling, dynamic scaling mechanisms introduce a dynamic scaling factor based on a beta distribution. This means that in each training round, the sample lengths produced by the system are random and reasonably distributed, ranging from short fragments to extremely long sequences, allowing the model to maintain its understanding across different scales. Specifically, the system randomly determines the actual length of the sample around the target length based on a pre-defined probability distribution biased towards the center value.
[0070] The specific algorithm is as follows: Let the target extended context length be... L target This parameter represents the maximum processable sequence length the model is expected to achieve during training. The system first starts with parameters ( α , β Sampling a scaling factor in the Beta distribution of ) r :
[0071] ;
[0072] Among them, shape parameters α and β Used to control the distribution pattern. For example, when α = βWhen the value is 3, the distribution exhibits a unimodal symmetrical shape, with sampled values tending to concentrate around 0.5. Subsequently, the actual sequence length of this training sample is calculated. L s :
[0073] ;
[0074] here, c min and c max These are the upper and lower limits of the length scaling range, for example... c min =0.9, c max =1.1, round means rounding to the nearest integer. Therefore, L s Will L target Reasonable fluctuations in the vicinity force the model to adapt to positional relationships under different compression ratios, enhancing its robustness to various actual document lengths.
[0075] For the dual-core window construction mechanism, when extracting long document content, this invention does not extract only one center point, but simultaneously constructs two adjacent or non-adjacent mid-segment windows in a single sample. This design greatly increases the opportunity for the model to encounter cross-paragraph logical relationships in a single training iteration.
[0076] The specific algorithm is as follows: After determining the sample length... L s Then, the system needs to retrieve the original long document, whose length... L doc The system intelligently selects content rather than simply extracting continuous segments. This mechanism will learn the total mid-segment length. L m Divide the document into two windows, left and right, to cover the central area of the front and back parts of the document.
[0077] Length allocation includes setting the head retention length as... L h The tail length is retained as L t The total length of the middle section is then... L m = L s - L h - L t .Will L m Divided into left window length L left =⌊ Lm / 2⌋ and the length of the right window L right = L m - L left .
[0078] Window position calculation includes setting the theoretical center of the document as... C = L doc / 2. To avoid overfitting the model to the absolute center point, a center jitter value is introduced. j Sampling from a uniform distribution: j ~Uniform(- J , J ),in J This is the preset jitter range.
[0079] The starting position is determined, including the starting position of the left window. and the starting position of the right window The calculation is as follows:
[0080] ;
[0081] ;
[0082] The max and min operations ensure that the window position does not exceed the document boundaries. The corresponding ending position is:
[0083] ;
[0084] ;
[0085] This design allows a single training sample to simultaneously contain two text blocks from near the middle of a document, but which may not be adjacent. This not only doubles the exposure of information in the middle section, but also forces the model to learn to handle potential cross-paragraph semantic relationships, simulating the structure of a real long document.
[0086] Regarding the center point position jitter mechanism, this mechanism has already been implemented through parameters in the aforementioned window position calculation. j Implementation. Its core lies in the calculated theoretical center point. C Apply a tiny, random offset. This offset... j exist[- J , J The model selects regions uniformly and randomly within a given interval. This ensures that the model focuses on a dynamically changing area of interest around the center during each training iteration, rather than a mathematically absolute center. This effectively prevents the model from developing numerical dependencies on fixed coordinates, significantly improving its adaptability and generalization ability to fluctuations in information location.
[0087] Finally, based on the results of the three sub-mechanisms mentioned above, the module completes sample concatenation and location identifier generation. The module extracts tokens from the original document and concatenates them into training samples in the following order. S :
[0088] ;
[0089] Here, ⊕ represents the sequence concatenation operation.
[0090] At the same time, the system generates and S The exact global location identifier sequence P that corresponds to each Token:
[0091] ;
[0092] This sequence P serves as the absolute benchmark for all subsequent position-aware operations, ensuring the spatial accuracy of the training signal.
[0093] S2. Based on the preliminary training samples, obtain the middle section of text content, estimate the word frequency of the text content, and generate local information entropy. Based on the local information entropy, evaluate the middle section information density of the preliminary training samples. Trigger the adaptive window drift optimization mechanism through the information density evaluation results to optimize the preliminary training samples, obtain the optimized samples, and simultaneously generate the updated position identifier sequence.
[0094] Specifically, based on the initial training samples, the text content of the middle section is obtained. The frequency of word occurrences in the text content is estimated, and local information entropy is generated. The information density of the middle section of the initial training samples is evaluated based on the local information entropy. The information density evaluation result triggers an adaptive window drift optimization mechanism to optimize the initial training samples, resulting in optimized samples. Simultaneously, an updated position identifier sequence is generated, including:
[0095] S21. Obtain the text content corresponding to the middle left and right windows based on the preliminary training samples, and calculate the occurrence probability of each word based on the text content. Estimate the information density of the occurrence probability of each word to obtain the local information entropy.
[0096] Specifically, based on the probability of occurrence of each word element in the text content, the information density of the probability of occurrence of each word element is estimated, resulting in the local information entropy, which includes:
[0097] Determine the lexicon set and vocabulary size based on the text content, and calculate the probability of occurrence of each lexicon in the lexicon set;
[0098] The information entropy of the occurrence probability of each word in the word set is aggregated to obtain the initial information entropy. The initial information entropy is then normalized by combining the logarithmic vocabulary size to obtain the local information entropy.
[0099] S22. Compare the local information entropy with the preset information entropy threshold, and evaluate the information density of the left and right windows in the middle section based on the comparison result to obtain the information density evaluation result.
[0100] Specifically, the evaluation of the information density of the left and right windows in the middle section based on the comparison results includes:
[0101] If the comparison result shows that the local information entropy is less than the preset information entropy threshold, then the information density of the corresponding window is low, and it is determined that the corresponding window in the preliminary training samples needs to be optimized.
[0102] If the comparison result shows that the local information entropy is greater than or equal to the preset information entropy threshold, then the information density of the corresponding window is high, and it is determined that the corresponding window in the initial training samples does not need to be optimized.
[0103] S23. Based on the information density evaluation results, obtain the invalid window to be optimized. The invalid window to be optimized triggers the adaptive window drift optimization mechanism to optimize the initial training samples, obtain the optimized samples, and synchronously update the location identifier sequence to obtain the updated location identifier sequence.
[0104] Specifically, the invalid windows to be optimized trigger an adaptive window drift optimization mechanism to optimize the initial training samples, resulting in optimized samples including:
[0105] Determine the center position of the invalid window to be optimized. Starting from the center position of the invalid window, use the adaptive window drift optimization mechanism to shift the window to the left and right sides of the center position by a preset window drift step size, and calculate the local information entropy of the window corresponding to each offset position to obtain the set of entropy values of the offset position.
[0106] Select the offset position with the largest entropy value from the set of offset positions as the optimized window center. Use the optimized window center to re-truncate the original long text corpus and generate optimized samples.
[0107] Specifically, for the sample validation and optimization module based on local information entropy, the middle section of the physical location may contain information-sparse segments, such as large blank spaces, repetitive formatting, or meaningless placeholders. Reinforcing training with such content would waste model capacity and interfere with the learning process. Therefore, this module, after generating initial training samples, introduces an optimization algorithm based on local information entropy detection and adaptive window drift to validate and optimize the samples. Its core objective is to ensure that the middle window used for reinforcement training is not only centered in position but also possesses high information density and training value.
[0108] The specific algorithm is as follows: Local information entropy calculation includes calculating the normalized information entropy of the text content in the left and right middle windows obtained from the initial training samples. H ( W (), as a core indicator for measuring information density within a window:
[0109] ;
[0110] in, V It is the size of the entire vocabulary. V W It is a window W The only set of tokens that appear within, p ( x ) is Token x exist W Frequency of occurrence within. H ( W The higher the value, the more random and rich the token distribution of the window content, and the greater the information density.
[0111] Validity threshold determination includes setting an information entropy threshold. t entropy .like H ( W left )< t entropy or H ( W right )< t entropy If the information density in the middle section is too low, it may be due to large blank spaces or repeated characters, and the sample is determined to be a sample to be optimized, triggering the adaptive optimization process; otherwise, the original sample is used directly.
[0112] For adaptive window drift optimization, when a window is determined to have low information density, the sample is not discarded directly, but the adaptive drift optimization algorithm is triggered. This algorithm uses the center position of the current invalid window... C old Starting from the left and right sides, explore with a preset step size Δ. d For example, with 512 tokens, calculate the offset position for each token. k Local information entropy of the corresponding window H (Window( C old + k And select the position with the largest entropy value as the new window center. C new :
[0113] ;
[0114] Utilizing the optimized center C new The text is re-extracted, and an optimized window is generated. This process ensures that the most information-rich areas are found and replaced within a local area of the document.
[0115] For process integration and sample reconstruction, the aforementioned optimization process is applied to the left and right windows respectively. After optimization, the system, based on the new window positions, re-extracts the header, optimized left middle section, optimized right middle section, and footer from the original document, and concatenates them to form the final training samples. S opt Simultaneously update and generate a corresponding, accurate, real-world global location identifier sequence. P opt .
[0116] Through this module, the present invention ensures that every piece of training data fed into the model is not only in the middle in terms of position, but also has a rich amount of information and training value in terms of content, thereby improving training efficiency and the final performance of the model from the data source.
[0117] S3. Input the optimized samples and the updated location identifier sequence into the large language model, and iteratively train the large language model through a location-aware mid-segment loss weighting mechanism to obtain the optimized large language model.
[0118] Specifically, the optimized samples and updated location identifier sequences are input into the large language model, and iterative training of the large language model is achieved through a location-aware mid-segment loss weighting mechanism, resulting in an optimized large language model including:
[0119] S31. Input the optimized sample into the large language model, and input the updated position identifier sequence into the position encoding layer of the large language model. Then, perform forward propagation through the large language model to obtain the initial prediction score.
[0120] Specifically, the initial prediction scores obtained through forward propagation using a large language model include:
[0121] The updated location identifier sequence is scaled using a linear interpolation function to obtain the actual location;
[0122] The actual position is encoded based on rotational position coding to obtain encoded position data, and the initial prediction score is calculated by a multi-layer converter.
[0123] S32. Determine the Gaussian weight distribution based on the updated location identifier sequence, and calculate the location-aware loss based on the Gaussian weight distribution to obtain the weighted total loss.
[0124] S33. Based on the weighted total loss, the gradient of the parameters of the large language model is calculated through backpropagation, and the parameters of the large language model are iteratively updated using an optimizer to obtain the optimized large language model.
[0125] Specifically, a Gaussian weight distribution is determined based on the updated location identifier sequence, and the location-aware loss is calculated based on the Gaussian weight distribution to obtain the weighted total loss, which includes:
[0126] S321. Based on the updated location identifier sequence, calculate the geometric weighted center of the optimized sample in the original long text corpus;
[0127] S322. Based on the geometric weighting center, and combining the peak intensity coefficient and Gaussian width coefficient, calculate the Gaussian weight for each position in the updated position identifier sequence to obtain the Gaussian weight distribution:
[0128] S323. Combine the Gaussian weight distribution with the standard cross-entropy loss vector to calculate the weighted total loss.
[0129] Specifically, for the position-aware mid-section loss weighting module, this is the core algorithmic step of this solution. Its purpose is to adjust the loss function so that the model pays more attention to high-difficulty tokens located in the middle of the sequence. The model in this invention specifically refers to a Decoder-only generative large language model based on the Transformer architecture, such as Llama, Qwen, and the GPT series. These models employ Rotary Positional Embedding (RoPE). In conventional model training, the penalty (i.e., loss value) is equal regardless of the model's position in the text, such as the beginning, middle, or end. This module changes this rule; it applies different weights to prediction errors based on the token's position in the text, explicitly telling the model that errors in the middle of the text are more costly and require greater attention.
[0130] Specifically, the system reads the real rotation position encoding index corresponding to each token in real time. Based on these indices, the system constructs a smooth, Gaussian-shaped weight distribution with the physical midpoint of the current valid text sequence as the peak. During the operation, the closer a character is to the center of the sequence, the greater the penalty for its prediction error. This position-aware differential weighting guides the model's gradient updates to focus on parsing the logic of the middle section. Furthermore, because this scheme explicitly utilizes the real logical position identifiers of the training samples, even with data padding or cache concatenation, the weighted region can still accurately align with the real middle section of the text, effectively avoiding numerical drift during training.
[0131] The specific algorithm is as follows: The module input is the model prediction result and the real location identifier P, and the output is the weighted loss value. The weighted center and Gaussian weights are calculated based on the real location, including for a given set of... N A sample of valid tokens, whose position identifier sequence is: First, calculate the geometric weighted center (i.e., weighted anchor point) of the sample in the original document space. m :
[0132] ;
[0133] this m The value represents the physical midpoint of the current training segment in the original text. Next, for each position in the sequence... p i Calculate a Gaussian weight w i :
[0134] ;
[0135] in, l (middle_loss_lambda) is the peak intensity coefficient, a hyperparameter greater than 0, which controls the maximum enhancement amplitude at the center position, for example... l =0.3. The larger the value, the more the loss of the middle token is amplified.
[0136] s Gaussian width: Controls the width of the area of interest. It can be set to the same value as the effective sample length.
[0137] ;
[0138] The Gaussian width is set to be proportional to the effective length of the sample, for example... s = c L eff ,in c It is the width factor, for example c =1 / 6. The larger the width, the more gently the weight decays from the center to both ends.
[0139] For RoPE-aware alignment mechanisms, this step is crucial for ensuring stable and effective training. Rotation Position Encoding (RoPE) encodes position information as phase. When expanding the context, such as using Linear, NTK, or YaRN interpolation, the input position identifier P is first processed by a scaling function within the model. f scale ( Mapped to the actual location used for RoPE calculations PIn this invention, linear interpolation is used as the scaling strategy, and the specific calculation formula for its scaling function is as follows:
[0140] ;
[0141] in: p Original location identifier; L base This represents the original context length of the base model; L target Extend the context length for the target; P 'This is the actual location used for RoPE calculations after scaling.
[0142] This module calculates weights. w i At that time, the original real location identifier before scaling is used directly. p i To calculate and m The distance. Since the loss calculation and RoPE encoding share the same set of original position inputs P, the positional geometry that the loss function senses and tries to reinforce originates from the same coordinate system as the phase geometry that the model's attention mechanism relies on. This ensures strict consistency between the training signal and the model's internal state, avoiding signal mismatch and training drift caused by interpolation scaling.
[0143] For weighted loss calculation and gradient propagation, let the model's standard cross-entropy loss vector for this sample be... The weighted total loss calculated in this module is... for:
[0144] ;
[0145] During the back propagation process, located at p i ≈ m The loss of (middle section) tokens l i With greater weight w i Magnification, therefore for the final gradient ∇ i The contribution ratio increased significantly. This systematically guides the optimizer in updating model parameters. i At the same time, priority should be given to reducing the prediction error of the model in the middle region.
[0146] According to another embodiment of the present invention, an enhancement training system for improving the mid-segment text parsing capability of a large language model is also provided, the system comprising:
[0147] The data augmentation sampling module is used to generate a dynamic scaling factor through beta distribution, construct a mid-section double window based on the dynamic scaling factor to obtain the window position, extract and splice from the original long text corpus based on the window position to obtain preliminary training samples, and generate a position identifier sequence.
[0148] The information entropy-based sample verification and optimization module is used to obtain the middle section of text content based on the initial training samples, estimate the word frequency of the text content, generate local information entropy, evaluate the middle section information density of the initial training samples based on the local information entropy, and trigger an adaptive window drift optimization mechanism to optimize the initial training samples through the information density evaluation results, obtain the optimized samples, and simultaneously generate an updated position identifier sequence.
[0149] The location-aware mid-segment loss weighting module is used to input the optimized samples and the updated location identifier sequence into the large language model, and to iteratively train the large language model through the location-aware mid-segment loss weighting mechanism to obtain the optimized large language model.
[0150] In summary, this invention proposes a reinforcement training method to enhance the mid-section text parsing capability of large language models, aiming to eliminate the mid-section loss phenomenon in long text processing. This method, by redesigning the construction of training data and optimizing the loss weights during training, ensures that the model, like a human reader, not only focuses on the beginning and end of the text but also keenly captures the core information embedded in the middle of the sequence. Without changing the model's basic architecture, this method achieves higher accuracy and more robust long text parsing capabilities, significantly improving the model's practical performance in complex long document question answering.
[0151] The core idea of this invention is to collaboratively solve this problem by improving two key aspects of the model training process: first, improving the preparation method of training data; and second, improving the feedback mechanism during model learning. This method mainly consists of three core modules: a data augmentation sampling module, an information entropy-based sample validation and optimization module, and a position-aware mid-range loss weighting module. For example... Figure 2As shown, its workflow can be summarized as follows: First, the system dynamically constructs training samples with broad coverage and high diversity from a long text corpus using a data augmentation sampling module, and generates accurate real-world location identifiers for each sample. Next, an information entropy-based sample validation and optimization module evaluates the information density of the sampled mid-section windows and intelligently optimizes or resamples low-quality samples to ensure the effectiveness of the training data. Subsequently, these optimized samples are input into a large-scale language model for forward computation. Finally, a location-aware loss weighting module applies a Gaussian weight distribution centered on the mid-section of the sequence to the prediction error based on the sample's location identifier, thereby guiding the model's gradient update to focus on understanding and parsing mid-section information. Through repeated iterations of this process, the model gradually builds a powerful ability to analyze mid-section information in long texts.
[0152] The end-to-end collaborative training strategy, namely the present invention, deeply integrates the aforementioned data augmentation sampling module, information entropy-based sample verification and optimization module, and location-aware mid-segment loss weighting module to form a complete closed-loop training process.
[0153] For the base model architecture, the base model applicable to this invention is an autoregressive large language model based on the Transformer decoder architecture, such as the Llama, GPT, and Qwen series. Its essential modules include an input embedding layer that converts the input token ID sequence into word vectors; a multi-layer Transformer decoding block where each layer contains a multi-head self-attention mechanism, i.e., using RoPE positional encoding; a feedforward neural network; residual connections; and layer normalization, such as RMSnorm. The language model head maps the top-level hidden states to a probability distribution over the vocabulary.
[0154] The detailed logical steps of its training iteration include step 1: initialization, i.e., loading the long text corpus. D Base model M θ Set target length L target Total number of iterations T Initialize data sampling parameters Information entropy threshold τ entropy Window drift step size Δ d Loss weighting parameters and RoPE scaling type S Step 2: Data Sampling, Validation, and Optimization, i.e., 2.1 Basic Sampling: For each sample in the current training batch, the data augmentation sampling module performs sampling based on parameters. From the corpus D The initial token sequence (tokens) is generated in the process. rawand the corresponding real location identifier sequence pos_ids raw 2.2 Information Entropy Verification and Optimization: The information entropy-based sample verification and optimization module is invoked, which calculates tokens. raw Local information entropy of the left and right windows H ( W If the entropy value is lower than the threshold τ entropy If the window position is correct, adaptive window drift optimization is triggered, generating a new window position and re-truncating the text; otherwise, the original window is retained, and the optimized training batch data tokens and pos_ids are finally output; Step 3: Model forward propagation, that is, inputting tokens into the model. M θ Simultaneously, pos_ids are input into the model's position encoding layer. The model is then scaled according to the configured RoPE scaling type. S The pos_ids are scaled and positional codes are generated. After multi-layer Transformer computation, the predicted logits are output. Step 4: Calculate the position-aware loss, i.e., the position-aware mid-segment loss weighting module calculates the geometric center of each sample based on pos_ids. m The model employs a Gaussian weight distribution and then calculates the weighted cross-entropy loss (Loss). Step 5: Backpropagation and parameter update, i.e., calculating the loss (Loss) with respect to the model parameters. i The gradient is calculated and updated using an optimizer such as AdamW. i Step 6: Loop through the loop, repeating steps 2 through 5 until the total number of iterations is reached. T The final output is the optimized model. .
[0155] The synergy of this invention is manifested in data, optimization, and loss closure. The data augmentation sampling module provides diverse data candidates; the information entropy-based sample validation and optimization module filters and optimizes data according to quality, ensuring the validity of the input data; and the location-aware mid-section loss weighting module applies a stronger learning signal to key areas in high-quality data, namely the mid-section. These three components are tightly linked through location identification, a core information flow. Integration with specific scenarios includes applications in areas such as financial analysis and information entropy thresholding. t entropy The window drift strategy can be specifically adjusted based on domain-specific text features, such as the density of formulas and tables, making the optimization process more aligned with domain characteristics. The model's input is the original long document. After optimization using this training strategy, its internal parameters establish a stronger representation and association ability for segments in high-information-density documents, thereby outputting more accurate results in downstream tasks such as question answering and summarizing.
[0156] The method proposed in this invention includes the following steps: (1) Reading the original long text corpus and using the data augmentation sampling module, i.e., generating preliminary training samples and corresponding real location identifiers through Beta scale adjustment, dual-window sampling, and center jitter; (2) Calculating the local information entropy of the middle window of the preliminary samples using the information entropy-based sample verification and optimization module. If the entropy value is lower than the threshold, an adaptive window drift optimization algorithm is triggered to generate a new window position with higher information density, and the final training samples and location identifiers are reconstructed accordingly; (3) The model performs forward propagation and calculates the initial prediction score for each token; (4) Applying the middle weighted loss weights according to the real location identifiers; (5) Updating the model parameters and performing iterative training.
[0157] This paper uses intelligent financial research report analysis and Q&A as a specific application scenario for illustration. The first step is scenario-based needs analysis and training objective determination. The pain point is that financial research reports are typically complex in structure and lengthy, with core investment viewpoints, risk warnings, and financial data analysis often scattered in the middle and later parts of the document, making it a typical scenario where information gets lost in the middle. The base model chosen is the versatile Llama2-13B model. The target expansion capability is set as follows: L target =32768 (32K) to fully cover the target research report length. Training data preparation involves collecting tens of thousands of publicly available historical securities research reports to construct a domain corpus. D finance The second step: Implementing the training process based on this invention, that is, configuring and executing the training process according to the above scenario, i.e., configuring the data augmentation sampling module, the specific code is as follows:
[0158] “sampling_config ={
[0159] "alpha": 3.0, # Beta Distribution parameters a Controlling the length sampling distribution pattern
[0160] 'beta': 3.0, # Beta Distribution parameters β ,and α Common control distribution concentration
[0161] 'L_head': 64, #Head length to retain L h Unit: tokens
[0162] "L_tail': 64, # Tail length to retain L t Unit: tokens
[0163] "jitter_range':256, #Jitter range at the center J Unit: tokens
[0164] 'length_scale_range':(θ.85, 1.15) # Length scaling range c min , c max )
[0165] }".
[0166] The configuration of the sample validation and optimization module based on information entropy is shown in the following code:
[0167] "entropy_optimization_config ={
[0168] "entropy_threshold':0.65, #Information entropy threshold τ entropy
[0169] "drift_step':512 #Adaptive drift step size Δ d Unit: tokens
[0170] }".
[0171] The location-aware loss weighting module is configured, and the specific code is as follows:
[0172] "loss_weighting_config ={
[0173] 'middle_loss_lambda':0.32, # Peak intensity coefficient λ, controls the weighted intensity of the middle loss.
[0174] 'sigma_ratio':1 / 6, # Gaussian width coefficient γ, σ=γ L eff
[0175] 'use_rope_aware_position': True # Enable RoPE - aware Alignment mechanism
[0176] }".
[0177] Training execution begins by starting the training script; the system will automatically start from... D financeThe first step involves extracting research reports and fine-tuning them using the above configuration for up to 2000 steps. The third step is effect verification and quantitative evaluation, which involves objectively assessing the training effect by constructing a dedicated testing benchmark, FinBench-Long, containing 500 long research reports that were not used in the training, for example, reports between 16K and 32K in length. Each report is pre-labeled with 20 questions, which are evenly divided into four groups based on the position of the answers in the document: the first quarter; the second quarter (early middle section); the third quarter (late middle section); and the last quarter.
[0178] The trained model was compared with the following baseline models, and the results are shown in Table 1 below:
[0179] Table 1 Comparison Test Results
[0180]
[0181] Step 4: Results Analysis. As shown in Table 1, the model (D) trained using the method of this invention achieved a question-answering accuracy of 78.5% in the later stages, an improvement of approximately 26 percentage points compared to the baseline CREAM method (C) of 52.6%, representing a significant improvement. Simultaneously, the model's performance was evenly improved across all positions, achieving an overall accuracy of 80.6%, with the performance curve becoming flatter.
[0182] In conclusion, this implementation case, through a specific financial scenario, detailed parameter configuration, and quantified test data, fully demonstrates the entire process of the method of this invention, from problem definition and training implementation to effect verification. The results prove that the collaborative training strategy proposed in this invention can significantly and evenly improve the ability of large language models to parse information in the middle of long texts, providing an efficient, reliable, and easily implementable technical solution to overcome the key bottleneck of lost information in the middle, and has clear industrial application value.
[0183] In summary, by utilizing the above-mentioned technical solution of this invention, the present invention addresses the dual challenges of getting lost in the middle by combining information density assessment and position-aware training. It ensures the high value of the middle section of the training samples through information entropy verification and strengthens the focus on middle section information through loss weighting. This significantly and evenly improves the retrieval and understanding accuracy of the model when processing information in the middle of a sequence, successfully flattening the originally concave U-shaped performance curve and overcoming the training performance bottleneck. The weighted strengthening of key positions in this invention makes the model's learning more targeted, avoiding a large amount of meaningless background noise, thereby shortening the number of training steps required to achieve the same accuracy and making training convergence faster. This invention also utilizes dynamic data processing... The state sampling mechanism enables the model to adapt to documents of various lengths; the information entropy optimization mechanism teaches the model to focus on information-rich areas rather than fixed location centers, thus exhibiting stronger generalization ability and robustness when facing real long texts in different fields and formats, such as financial or scientific documents containing a large number of tables and formulas, thereby enhancing generalization and robustness; this invention innovates entirely at the training strategy level without involving any changes to the main structure of the model, with low computational overhead, and the optimized model can be directly and seamlessly integrated into existing large language model inference frameworks, fully compatible with mainstream RoPE context extension methods, with extremely low industrial implementation threshold and extremely high practical value, enabling low-cost integration and compatibility.
[0184] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A reinforcement training method to improve the mid-segment text parsing ability of a large language model, characterized in that, The method includes: S1. Generate a dynamic scaling factor through beta distribution, construct a mid-section double window based on the dynamic scaling factor to obtain the window position, extract and splice from the original long text corpus based on the window position to obtain preliminary training samples, and generate a position identifier sequence. S2. Based on the preliminary training samples, obtain the middle section of text content, estimate the word frequency of the text content, and generate local information entropy. Based on the local information entropy, evaluate the middle section information density of the preliminary training samples. Trigger the adaptive window drift optimization mechanism through the information density evaluation results to optimize the preliminary training samples, obtain the optimized samples, and simultaneously generate the updated position identifier sequence. S3. Input the optimized samples and the updated location identifier sequence into the large language model, and iteratively train the large language model through a location-aware mid-segment loss weighting mechanism to obtain the optimized large language model.
2. The reinforcement training method for improving the mid-segment text parsing ability of a large language model according to claim 1, characterized in that, The process involves generating a dynamic scaling factor through beta distribution, constructing a mid-section dual-window based on the dynamic scaling factor to obtain window positions, extracting and concatenating data from the original long text corpus based on these window positions to obtain preliminary training samples, and generating position identifier sequences including: S11. Generate a dynamic scaling factor based on the beta distribution of preset shape parameters, and determine the actual sequence length of the training samples by combining the pre-acquired target extended context length and the preset length scaling range. S12. Construct a mid-segment double window based on the actual sequence length of the training samples to obtain the window division length, and determine the start and end positions of the window by combining the jitter mechanism. S13. Extract and concatenate word sequences from the original long text corpus based on window position to obtain preliminary training samples, and generate a preliminary training sample position identifier sequence by combining each word position identifier.
3. The reinforcement training method for improving the mid-segment text parsing ability of a large language model according to claim 2, characterized in that, The step of constructing a mid-segment double window based on the actual sequence length of the training samples, obtaining the window division length, and determining the start and end positions of the window using a jitter mechanism includes: S121. Combine the actual sequence length of the training samples with the preset head retention length and tail retention length to perform length allocation, and obtain the total length of the middle section; S122. Divide the total length of the middle section into left and right window lengths to obtain the division length of the left and right windows of the middle section. Determine the theoretical center of the text based on the total length of the original long text corpus. Sample within a uniformly distributed preset jitter range to obtain the center jitter value. S123. The sum of the theoretical center and the center jitter value is taken as the center of the middle section, and the starting and ending positions of the left and right windows of the middle section are determined by combining them with the total length of the original long text corpus, the length retained at the beginning, the length retained at the end, and the division length of the left and right windows of the middle section.
4. The reinforcement training method for improving the mid-segment text parsing ability of a large language model according to claim 1, characterized in that, The process involves obtaining the middle section of text content based on preliminary training samples, estimating the frequency of word occurrences within the text content, generating local information entropy, evaluating the middle section information density of the preliminary training samples based on the local information entropy, and triggering an adaptive window drift optimization mechanism based on the information density evaluation results to optimize the preliminary training samples, resulting in optimized samples. Simultaneously, an updated position identifier sequence is generated, including: S21. Obtain the text content corresponding to the middle left and right windows based on the preliminary training samples, and calculate the occurrence probability of each word based on the text content. Estimate the information density of the occurrence probability of each word to obtain the local information entropy. S22. Compare the local information entropy with the preset information entropy threshold, and evaluate the information density of the left and right windows in the middle section based on the comparison result to obtain the information density evaluation result. S23. Based on the information density evaluation results, obtain the invalid window to be optimized. The invalid window to be optimized triggers the adaptive window drift optimization mechanism to optimize the initial training samples, obtain the optimized samples, and synchronously update the location identifier sequence to obtain the updated location identifier sequence.
5. The reinforcement training method for improving the mid-segment text parsing ability of a large language model according to claim 4, characterized in that, The process of calculating the occurrence probability of each word based on text content, estimating the information density of the occurrence probability of each word, and obtaining the local information entropy includes: Determine the lexicon set and vocabulary size based on the text content, and calculate the probability of occurrence of each lexicon in the lexicon set; The information entropy of the occurrence probability of each word in the word set is aggregated to obtain the initial information entropy. The initial information entropy is then normalized by combining the logarithmic vocabulary size to obtain the local information entropy.
6. The reinforcement training method for improving the mid-segment text parsing ability of a large language model according to claim 4, characterized in that, The evaluation of the information density of the left and right windows in the middle section based on the comparison results includes: If the comparison result shows that the local information entropy is less than the preset information entropy threshold, then the information density of the corresponding window is low, and it is determined that the corresponding window in the preliminary training samples needs to be optimized. If the comparison result shows that the local information entropy is greater than or equal to the preset information entropy threshold, then the information density of the corresponding window is high, and it is determined that the corresponding window in the initial training samples does not need to be optimized.
7. The reinforcement training method for improving the mid-segment text parsing ability of a large language model according to claim 4, characterized in that, The invalid window to be optimized triggers an adaptive window drift optimization mechanism to optimize the initial training samples, resulting in optimized samples including: Determine the center position of the invalid window to be optimized. Starting from the center position of the invalid window, use the adaptive window drift optimization mechanism to shift the window to the left and right sides of the center position by a preset window drift step size, and calculate the local information entropy of the window corresponding to each offset position to obtain the set of entropy values of the offset positions. Select the offset position with the largest entropy value from the set of offset positions as the optimized window center. Use the optimized window center to re-truncate the original long text corpus and generate optimized samples.
8. The reinforcement training method for improving the mid-segment text parsing ability of a large language model according to claim 1, characterized in that, The process involves inputting the optimized samples and updated location identifier sequences into the large language model, and iteratively training the large language model using a location-aware mid-segment loss weighting mechanism to obtain the optimized large language model, which includes: S31. Input the optimized sample into the large language model, and input the updated position identifier sequence into the position encoding layer of the large language model. Then, perform forward propagation through the large language model to obtain the initial prediction score. S32. Determine the Gaussian weight distribution based on the updated location identifier sequence, and calculate the location-aware loss based on the Gaussian weight distribution to obtain the weighted total loss. S33. Based on the weighted total loss, the gradient of the parameters of the large language model is calculated through backpropagation, and the parameters of the large language model are iteratively updated using an optimizer to obtain the optimized large language model.
9. The reinforcement training method for improving the mid-segment text parsing ability of a large language model according to claim 8, characterized in that, The initial prediction score obtained through forward propagation using a large language model includes: The updated location identifier sequence is scaled using a linear interpolation function to obtain the actual location; The actual position is encoded based on rotational position coding to obtain encoded position data, and the initial prediction score is calculated by a multi-layer converter.
10. The reinforcement training method for improving the mid-segment text parsing ability of a large language model according to claim 8, characterized in that, The step of determining the Gaussian weight distribution based on the updated location identifier sequence and calculating the location-aware loss based on the Gaussian weight distribution to obtain the weighted total loss includes: S321. Based on the updated location identifier sequence, calculate the geometric weighted center of the optimized sample in the original long text corpus; S322. Based on the geometric weighting center, and combining the peak intensity coefficient and Gaussian width coefficient, calculate the Gaussian weight for each position in the updated position identifier sequence to obtain the Gaussian weight distribution: S323. Combine the Gaussian weight distribution with the standard cross-entropy loss vector to calculate the weighted total loss.
Citation Information
Patent Citations
Two-stage training method for lightweight Chinese-English bilingual large language model
CN119514636A
Text entity recognition model construction method and equipment based on large model data enhancement
CN120995985A