A method and device for selecting pre-training data for a large language model

By employing multi-granularity segmentation and dynamic resource allocation, the dimensionality collapse problem in the pre-training of large language models is mitigated, data quality and computational efficiency are improved, different data distributions are adapted, and the performance of the model on multi-task and multimodal translation agents is enhanced.

CN123180167APending Publication Date: 2026-11-27NINGBO WIRELESS CITY OPERATION CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611590030.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-14
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing technologies neglect the overall distribution characteristics of multi-granular data during the pre-training process of large language models, resulting in severe dimensionality collapse, which affects the performance of the model on multi-task and multimodal translation agents, and is also computationally inefficient.

Method used

By performing multi-granular segmentation on the original corpus, extracting feature vectors using a pre-trained encoder, and combining feature covariance matrix analysis, resources are dynamically allocated to alleviate collapse. A greedy diversity selection and weighted fusion are adopted to achieve a differentiated selection strategy.

Benefits of technology

It significantly improves the diversity and effective rank of pre-training data, increases the average accuracy of downstream tasks, reduces redundant computational overhead, and enhances adaptability to different data distributions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123180167A_ABST
    Figure CN123180167A_ABST
Patent Text Reader

Abstract

The application discloses a selection method and device for pre-training data of a large language model, and relates to the technical field of data processing. The method comprises the following steps: dividing original corpus according to different granularity levels to generate a plurality of granularity segment sets, and performing feature extraction and standardization processing to obtain granularity feature vectors of the granularity levels; performing collapse evaluation on the granularity feature vectors of the granularity levels to obtain collapse severity scores of the granularity levels; converting the collapse severity scores into distribution weights of the granularity levels and performing budget distribution calculation to obtain selection budgets of the granularity levels; dynamically setting a selection threshold according to the collapse severity scores, and performing greedy diversity selection based on the selection threshold and the selection budgets in parallel to obtain selection results corresponding to the granularity levels; and performing weighted fusion and deduplication on the selection results corresponding to the granularity levels to obtain a pre-training data subset. The application can dynamically allocate selection resources according to actual collapse severity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a method and apparatus for selecting pre-training data for large language models. Background Technology

[0002] Pre-training large language models typically requires selecting high-quality training data from massive text corpora, as data quality directly determines the model's overall capability and generalization performance. In recent years, as the size of pre-training corpora has expanded from billions of words to trillions, efficiently selecting the most valuable subset for training under limited computing budgets has become a core challenge in data engineering.

[0003] Traditional data filtering methods often employ single-sample filtering strategies based on quality scores, such as using perplexity, n-gram repetition rate, or domain similarity to score each sample and retain high-scoring samples. However, while optimizing the quality of individual samples, these methods often neglect the overall distribution characteristics of the selected subset in the feature space. This is particularly true in the collection and extraction of corpora from dialects or less common languages ​​(such as Ningbo dialect), where the corpus structure often exhibits strong irregularities (e.g., a mixture of long stories, short dialogue fragments, and fragmented voice commands). Ignoring the overall distribution of multi-granular data leads to severe dimensionality collapse—that is, most feature dimensions are compressed into at least a few principal component directions, resulting in a severe lack of data diversity. Dimensionality collapse may cause models to perform well on specific tasks, but significantly degrades performance on multi-task or multimodal translation agent benchmarks that require extensive knowledge.

[0004] Therefore, how to effectively mitigate dimensionality collapse, maintain the diversity of training data, and take into account computational efficiency during the data selection process is a key issue that current pre-training data screening technology urgently needs to address. Summary of the Invention

[0005] To address the aforementioned technical problems, this invention proposes a method and apparatus for selecting pre-training data for large language models. This method can accurately focus on the granular level where dimensionality collapse is most severe, achieving superior mitigation of dimensionality collapse within the same budget. It reduces redundant computational overhead through intelligent allocation and enhances adaptability to different data distributions. This invention can be applied to the screening of pre-training data for large language models, the extraction and cleaning of multi-granularity corpora (covering long documents and short speech segments) of minority languages ​​or dialects (such as Ningbo dialect), and the optimization of data pipelines for large speech models and translation agents.

[0006] To achieve the above objectives, the technical solution of the present invention is as follows:

[0007] A method for selecting pre-training data for large language models includes the following steps:

[0008] The original corpus is segmented according to different granularity levels to generate multiple granularity fragment sets; a pre-trained encoder is used to extract features and standardize the text fragments in the multiple granularity fragment sets to obtain granular feature vectors at each granularity level.

[0009] Collapse assessment is performed on the granularity feature vectors of each granularity level to obtain the collapse severity score of each granularity level;

[0010] The collapse severity scores of each granularity level are converted into allocation weights for each granularity level using a power function that includes temperature parameters; budget allocation is calculated based on the total selection budget and the allocation weights for each granularity level to obtain the selection budget for each granularity level.

[0011] The selection threshold is dynamically set based on the collapse severity score of each granularity level. Greedy diversity selection is performed in parallel based on the selection threshold and selection budget of each granularity level to obtain the selection result corresponding to each granularity level.

[0012] The selection results corresponding to each granularity level are weighted, fused, and deduplicated to obtain a subset of pre-trained data.

[0013] Preferably, the different granularity levels include document level, paragraph level, and sentence level.

[0014] Preferably, the pre-trained encoder employs the Contriever model.

[0015] Preferably, the standardization process employs zero-mean unit variance standardization.

[0016] Preferably, a collapse assessment is performed on the granularity feature vectors of each granularity level to obtain a collapse severity score for each granularity level, including:

[0017] The covariance matrix of the eigenvectors of each granularity level is calculated, and the eigenvalue spectrum analysis is performed on the covariance matrix to extract the effective rank and Gini coefficient of each granularity level.

[0018] The collapse severity score for each particle size is obtained by weighting the effective rank and Gini coefficient of each particle size level.

[0019] Preferably, it further includes:

[0020] A lower bound constraint of the minimum budget at a single granularity is introduced to adjust the selection budget at each granularity level, thereby obtaining the adjusted selection budget at each granularity level.

[0021] Preferably, the selection threshold The calculation formula is as follows:

[0022] ,in, Based on the selection of threshold, The adjustment coefficient satisfies , For particle size The severity score of the collapse.

[0023] Preferably, the selection results corresponding to each granularity level are weighted, fused, and deduplicated to obtain a subset of pre-trained data, including:

[0024] Based on the selection results corresponding to each granularity level, a document-level selection index set is obtained. Paragraph-level selection index set and sentence-level selection index set ;

[0025] Mapping the paragraph-level selection index set and the sentence-level selection index set to a unified file-level index space establishes a mapping relationship from fine-grained indexing to coarse-grained indexing:

[0026] ,in, This represents the set of file-level indexes mapped from the paragraph-level selection results. This represents the set of file-level indexes obtained by mapping the sentence-level selection results. Indicates the first The first document in the document One paragraph, Indicates the first The document, the first The first paragraph One sentence. This is a document-level index; the document-level selection result itself is a set of document-level indexes, i.e. ;

[0027] A weighted merge is performed on the three granularity file-level index sets, and a merge score is calculated for each file. ,as follows:

[0028] ,in, For particle size The corresponding set of file-level indexes, For particle size The allocation weights, For indicator functions;

[0029] Sort the files in descending order according to the merged score, and select the top... Each file is used as the fusion result. :

[0030] ,in, To determine the proportion of the total budget, For floor operations, The total number of documents in the candidate corpus.

[0031] Based on the above, the present invention also discloses a selection device for pre-training data of large language models, comprising:

[0032] The feature extraction module is used to segment the original corpus according to different granularity levels to generate multiple granularity fragment sets; and to use a pre-trained encoder to extract features and standardize the text fragments in the multiple granularity fragment sets to obtain granular feature vectors at each granularity level.

[0033] The granularity-by-granularity collapse assessment module is used to assess the collapse of the granularity feature vectors at each granularity level and obtain the collapse severity score at each granularity level.

[0034] An adaptive resource allocation module is used to convert the collapse severity score of each granularity level into an allocation weight for each granularity level using a power function that includes a temperature parameter; and to perform budget allocation calculation based on the total selection budget and the allocation weight of each granularity level to obtain the selection budget for each granularity level.

[0035] The granularity-aware selection quality control module is used to dynamically set the selection threshold based on the collapse severity score of each granularity level, and to perform greedy diversity selection in parallel based on the selection threshold and selection budget of each granularity level to obtain the selection result corresponding to each granularity level.

[0036] The fusion module is used to perform weighted fusion and deduplication on the selection results corresponding to each granularity level to obtain a subset of pre-trained data.

[0037] Based on the above technical solution, the beneficial effects of the present invention are:

[0038] 1) Accurate identification of multi-granularity collapse differences: This invention uses eigenvalue spectrum analysis of the feature covariance matrix to quantify the collapse severity at the document, paragraph, and sentence levels. Compared with the DiSF method, this invention shows a particularly significant improvement in effective rank at the paragraph and sentence levels.

[0039] 2) Adaptive focusing on the most severely collapsed particle size: This invention dynamically allocates the selection budget according to the proportion of the collapse severity of each particle size, which can improve the overall effective rank to 40.7 and reduce the Gini coefficient to 0.543.

[0040] 3) Significantly improve the average accuracy of downstream tasks: Through overall collaborative optimization, this invention achieves better pre-training data quality under the same selection budget, and achieves an average accuracy of 53.2% for nine downstream tasks with a selection ratio of 1.5%, which is 0.5 percentage points higher than the basic DiSF method.

[0041] 4) Effectively alleviate feature dimension collapse: This invention achieves an overall effective rank of 40.7 by applying a stricter diversity screening threshold to the severely collapsed granularity, indicating that the feature space coverage of the selected data is more sufficient.

[0042] 5) Granularity perception threshold control to achieve differentiated selection strategy: This invention dynamically adjusts the diversity threshold of each particle size according to the severity of collapse. Particles with severe collapse are subject to stricter screening criteria, while particles with good diversity are subject to more relaxed conditions, which has a significant optimization effect on selection quality.

[0043] 6) Reduced Redundant Computational Overhead: This invention avoids wasting selection budget at granular levels with already good diversity through adaptive resource allocation, while improving selection efficiency through a batch parallel strategy. AGD takes 24.1 hours to select documents of 10 million, a 43.0% reduction compared to Uniform-Hier's 42.3 hours. It achieves multi-granularity adaptive selection with only about a 30% increase in time overhead (compared to the basic DiSF), balancing selection quality and computational efficiency.

[0044] 7) Enhanced adaptability to different data distributions: The granular collapse evaluation mechanism of this invention can automatically perceive the differences in collapse patterns at various granular levels across different datasets. For datasets with good document-level diversity but severe paragraph-level collapse, AGD automatically allocates more selection budget to the paragraph level; for datasets with significant sentence-level redundancy, it focuses on sentence-level selection. Comparison results of different allocation strategies show that the power function allocation strategy of this invention can dynamically adjust resource allocation according to the actual collapse state, achieving a better overall collapse mitigation effect compared to the fixed allocation strategy, and possessing good cross-dataset generalization ability.

[0045] 8) Modular architecture supports flexible expansion: This invention adopts a three-module serial architecture of "diagnosis-allocation-control," with each module having independent functions and clear interfaces. This modular design allows for flexible replacement of the implementation schemes of each module according to specific application scenarios to adapt to diverse data filtering needs. Attached Figure Description

[0046] Figure 1 This is a schematic diagram of a method for selecting pre-training data for large language models in one embodiment;

[0047] Figure 2 This is a timeline diagram of a method for selecting pre-training data for large language models in one embodiment;

[0048] Figure 3 This is a schematic diagram of the processing flow of the granular collapse assessment module in one embodiment;

[0049] Figure 4 This is a flowchart illustrating a method for selecting pre-training data for large language models applied to a cross-dataset transfer scenario in one embodiment.

[0050] Figure 5 This is a flowchart illustrating a method for selecting pre-training data for large language models, applied to the corpus collection, extraction, and cleaning scenario of the "Ningbo Dialect Large Model" project. Detailed Implementation

[0051] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.

[0052] like Figure 1 , Figure 2 As shown, this embodiment provides an Adaptive Granularity Diversity-driven Selection (AGD) method for selecting pre-training data for large language models. The AGD method consists of three core modules working together: 1) a granular collapse assessment module, which quantifies the collapse severity at three granularities—document level (e.g., long storytelling), paragraph level (e.g., daily conversation), and short sentence level (e.g., short interactive commands transcribed from ASR)—based on eigenvalue spectrum analysis of the feature covariance matrix, providing accurate diagnostic basis for subsequent resource allocation; 2) an adaptive resource allocation module, which dynamically allocates the selection budget proportionally based on the measured collapse severity at each granularity, ensuring that limited computing resources are precisely allocated to the granularities most in need of diversity intervention (e.g., highly redundant dialectal daily greetings); and 3) a granularity-aware selection quality control module, which applies stricter diversity screening thresholds to granularities with severe collapse and appropriately relaxes screening conditions for granularities with good diversity, achieving a differentiated selection strategy. This method includes the following steps:

[0053] Step 1: Segment the original corpus according to different granularity levels to generate multiple granularity fragment sets; use a pre-trained encoder to extract features and standardize the text fragments in the multiple granularity fragment sets to obtain granular feature vectors at each granularity level.

[0054] In this embodiment, tens of millions of documents in the SlimPajama dataset are used as the original corpus. Each document is segmented at three granular levels: document level, paragraph level, and sentence level. The document level uses the complete file as the unit, the paragraph level uses line breaks and indentation as separators, and the sentence level uses periods, question marks, and exclamation marks as separators, generating multiple sets of granular fragments.

[0055] The segmented text fragments are input into a pre-trained encoder (such as the Contriever model). Tokenization, forward inference, attention mask mean pooling, and zero-mean unit variance standardization are performed on the text fragments at three different granularity levels, respectively, transforming the text fragments at each granularity level into dimensionality. The standardized feature vector.

[0056] Specifically, given a collection of documents For each document Perform two different granularity segmentation operations: segmentation Sentence segmentation For each granularity level Pre-trained encoder Mapping text fragments to feature vectors:

[0057]

[0058] in, Indicates particle size Next A text fragment, For the forward propagation function of the pre-trained encoder, This represents mean pooling based on attention masks. This represents the standardization operation. The mean pooling operation is defined as follows:

[0059]

[0060] in, The token-level embedding matrix output by the encoder. For sequence length, For the first The attention mask value of each token. This is the mask vector.

[0061] Standardization transforms the feature vectors into a form with zero mean and unit variance, as follows:

[0062]

[0063] in, and Particle size The mean and variance of all eigenvectors. The numerical stability constant (usually taken as...) This standardization process ensures that the subsequent calculation of the covariance matrix is ​​not affected by differences in feature scales, making the collapse indices comparable across different granularities.

[0064] Step 2: Perform a collapse assessment on the granular feature vectors of each granularity level to obtain the collapse severity score for each granularity level.

[0065] In this embodiment, a granular collapse assessment module is used to calculate the feature covariance matrix for each granularity based on the standardized granular feature vectors. Then, based on the eigenvalue spectrum analysis of the feature covariance matrix, the dimensional collapse severity at the document, paragraph, and sentence levels is quantified. (See [link to relevant documentation]). Figure 3 .

[0066] For granularity First, calculate its eigencovariance matrix, as follows:

[0067]

[0068] in, For particle size The total number of text fragments below, These are the standardized eigenvectors. For the covariance matrix... Perform eigenvalue decomposition to obtain eigenvalues ​​sorted in descending order. ,in The feature dimension is defined as follows. This invention uses Effective Rank as a quantitative indicator of collapse severity, as follows:

[0069]

[0070] in Represented by natural constant The natural logarithm operation with base is... Represents the probability distribution of normalized eigenvalues As an argument, in terms of natural constants The natural logarithm of the base, when Time-defined limit value ; The singular spectral Shannon entropy represents the probability distribution of eigenvalues ​​and is used to quantify the eigencovariance matrix. The characteristic spectrum energy discrete distribution; Represented by natural constant An exponential function with base 0; The normalized eigenvalue probability distribution is defined as follows: The effective rank value range is: The smaller the value, the more severe the collapse; the larger the value, the richer the diversity of the feature representation.

[0071] In addition, the Gini coefficient is also used. As an auxiliary measure of collapse, the following is provided:

[0072]

[0073] in, Sort in ascending order This represents the total number of feature dimensions. The Gini coefficient ranges from [value missing]. The closer the value is to 1, the more uneven the distribution of the characteristic values, that is, the more severe the collapse.

[0074] Ultimately, granularity Collapse severity score Defined as effective rank With Gini coefficient The weighted combinations are as follows:

[0075]

[0076] in, Weight hyperparameters (default value) ), As a feature dimension. Collapse severity The range of values ​​is A higher value indicates a more severe collapse at that granularity, requiring more selective resource allocation. This design enables AGD to accurately perceive the true collapse state of each granularity, providing a reliable diagnostic basis for subsequent adaptive resource allocation.

[0077] One embodiment of a method for selecting pre-training data for large language models also provides a granular collapse evaluation approach. In addition to effective rank and Gini coefficient, eigenvalue variance or principal component score (the ratio of the largest eigenvalue to the sum of all eigenvalues) can be used as metrics for collapse severity. Granularity... The eigenvalue variance is defined as follows: A larger variance indicates a more discrete distribution of eigenvalues ​​and a more severe dimensionality collapse; among which, Indicates particle size The vector formed by all the eigenvalues ​​of the lower eigencovariance matrix. Indicates particle size The following features are covariance matrices arranged in descending order. 1 eigenvalue, index Granularity levels (corresponding to document level, paragraph level, and sentence level respectively), superscripts Indexed by feature value dimension. For feature dimension, Indicates particle size All The arithmetic mean of the eigenvalues. Granularity The principal component percentage is defined as follows: The closer the value is to 1, the more concentrated the variance is in the first principal component, and the more severe the dimensionality collapse; among them, Indicates particle size The proportion of principal components below, For particle size The largest eigenvalue (i.e., the first eigenvalue) of the lower eigencovariance matrix, the denominator Indicates particle size The sum of all eigenvalues ​​(i.e., the trace of the feature covariance matrix). This alternative is suitable for scenarios with high feature dimensionality and expensive precise eigenvalue decomposition, and can quickly estimate the collapse severity using approximate algorithms (such as stochastic SVD).

[0078] Step 3: Use a power function containing temperature parameters to convert the collapse severity score of each granularity level into the allocation weight of each granularity level; calculate the budget allocation based on the total selection budget and the allocation weight of each granularity level to obtain the selection budget of each granularity level.

[0079] In this embodiment, an adaptive resource allocation module is used to receive the collapse severity score of each granularity level and dynamically allocate the selection budget according to the collapse severity score of each granularity level, so that the severe collapse granularity can obtain more selection resources.

[0080] Total selection budget (usually the total amount of data) to Resources are allocated according to the proportion of collapse severity at each granularity to ensure that resources are directed to the granularity that most needs diverse intervention.

[0081] Given three granularity levels: document level, paragraph level, and sentence level. Collapse severity score The present invention first calculates the allocation weight of each particle size, as follows:

[0082]

[0083] in, This is the temperature parameter (default value 1.5), which controls the aggressiveness of the allocation. When When, the allocation tends to favor the granularity of severe collapse; when At that time, the distribution tends to be uniform; The time is allocated in a linear proportional manner. In this embodiment... default .

[0084] The selection budgets for each granularity level are as follows:

[0085]

[0086] in, Select a percentage of the total budget (e.g.) express ), To assign granularity The budget ratio. To ensure that each granularity obtains the minimum selection resources, this invention introduces a lower bound constraint to adjust the selection budget, as follows:

[0087]

[0088] in, Minimum budget for single granularity (default is) ,Right now If the total budget exceeds the limit after adding the lower bound constraint. Then, the budget for each granularity is reduced proportionally to meet the constraints.

[0089] This allocation strategy enables AGD to automatically allocate more selection budget to paragraph-level selection in datasets with minor document-level collapse but severe paragraph-level collapse, thus avoiding wasting computational resources at the already diversified document level.

[0090] One embodiment of a method for selecting pre-training data for large language models also provides an adaptive resource allocation method employing a threshold allocation strategy. Specifically, a collapse severity threshold is set. When the collapse severity score at a certain granularity exceeds the threshold, a fixed proportion of additional budget is allocated; otherwise, only the minimum budget is allocated. This strategy is suitable for scenarios with strict computational budget constraints, avoiding unnecessary selection overhead at the slightly collapsed granularity. Furthermore, a softmax-based probability allocation can be used to calculate the allocation weights for each granularity. ,in For temperature parameters, adjust Control the smoothness of the allocation.

[0091] Step 4: Dynamically set the selection threshold based on the collapse severity score of each granularity level, and perform greedy diversity selection in parallel based on the selection threshold and selection budget of each granularity level to obtain the selection result corresponding to each granularity level.

[0092] In this embodiment, a granularity-aware selection quality control module is employed to dynamically adjust the diversity selection threshold based on the collapse severity at each granularity level. Stricter diversity screening criteria are applied to granularities with severe collapse, while screening conditions are appropriately relaxed for granularities with good diversity. The selection stringency of each granularity is dynamically adjusted according to the collapse severity. The core idea is that granularities with more severe collapse require stronger diversity intervention; therefore, stricter selection thresholds should be used to exclude as many similar samples as possible.

[0093] This invention defines a correlation score based on the sum of squares of the off-diagonal elements of the feature covariance matrix, serving as an evaluation index for diversity quality. For granularity... candidate feature subset The correlation score is:

[0094]

[0095] in, The correlation matrix of standardized features, Normalization constant (default value) The lower the relevance score, the less redundancy between feature dimensions and the better the diversity.

[0096] This invention is based on the severity of the collapse. Dynamically set the selection threshold for each granularity ,as follows:

[0097]

[0098] in, Choose a threshold based on the base value (set to 0.05). The adjustment coefficient is set to satisfy η∈(0,1) (default value). ), For particle size The severity score of the collapse. When When the collapse is large (severe), select a threshold. Lowering the relevance score means stricter selection criteria; only samples with lower relevance scores will be selected. When the diversity is small, select a threshold. The increase allows more samples to pass the screening.

[0099] A greedy selection process with threshold adjustment is performed at each granularity level. Based on the DiSF greedy selection framework, samples that minimize the correlation score of the feature covariance matrix are selected iteratively at each granularity.

[0100] For granularity Given a set of candidate features ,granularity Select budget amount and selection threshold The greedy selection algorithm performs the following iterative process:

[0101]

[0102]

[0103] in, Indicates the first The set of samples selected during each iteration (Initially, a sample is randomly selected). In each iteration, the candidate sample that minimizes the increase in relevance score of the currently selected set is selected, until one of the following termination conditions is met: the number of selected samples reaches the budget. Or the current minimum relevance score is lower than the selection threshold. .

[0104] To improve selection efficiency under large-scale data, this invention adopts a batch parallel selection strategy. The candidate feature set is divided into multiple subsets according to the selection batch size (default 1024), and a greedy selection is performed independently on each subset, as follows:

[0105]

[0106] in, For batch size, The selection quantity for each batch is specified. The selection process for multiple batches is executed in parallel through multiple processes, making full use of multi-GPU computing resources. The selection results of each batch are merged into the final selection index set through the above-mentioned fusion and deduplication mechanism.

[0107] The iteration complexity of this greedy selection algorithm is O(n log n). ,in The feature dimension is used. Through a batch parallel strategy, the actual execution time is reduced to [missing value]. ,in The number of parallel processes enables AGD to maintain an efficient selection speed on large-scale pre-trained data (such as the billions of files in SlimPajama).

[0108] Step 5: Weighted fusion and deduplication of the selection results corresponding to each granularity level are performed to obtain a subset of pre-trained data.

[0109] In this embodiment, the selection index set for each granularity is obtained. , and Then, the following fusion operation is performed. First, the selection results at different granularities are mapped to a unified file-level index space. Since paragraphs and sentences belong to specific documents, this invention establishes a mapping relationship from fine-grained indexing to coarse-grained indexing:

[0110]

[0111] in, This represents the set of file-level indexes mapped from the paragraph-level selection results. This represents the set of file-level indexes obtained by mapping the sentence-level selection results. Indicates the first The first document in the document One paragraph, Indicates the first The document, the first The first paragraph One sentence. This is a document-level index; the document-level selection result itself is a set of document-level indexes, i.e. ;

[0112] Then, a weighted merge is performed on the three sets of file-level indexes at different granularities, as follows:

[0113]

[0114] The merge score for each file is as follows:

[0115]

[0116] in, For particle size The allocation weights; For particle size The corresponding file-level index set includes the file index set consisting of the document-level selection results themselves. The set of file-level indexes obtained by mapping paragraph-level selection results and the set of file-level indexes obtained by mapping sentence-level selection results. ; The document index number for the candidate corpus. For an indicator function, if and only if the file Included in granularity Corresponding file-level index set The value is 1 if the condition is met, and 0 otherwise. Total number of files. Merged index set. The total number of file indexes, which are obtained by merging the selection results from each granularity according to their weighted priorities, is strictly equal to the total budget. This fusion mechanism ensures that the selection contribution of each particle size is calculated by weighting its collapse severity, with particles that collapse more severely having a higher priority in the final merged result.

[0117] It should be understood that although the steps in the flowchart above are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart above may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0118] Comparative experiment

[0119] Table 1

[0120]

[0121] In the comparative experiments, the full names and descriptions of the various data selection methods involved are as follows: DiSF: Diversified File Selection based on feature decorrelation; ADO: Adaptive Data Optimization based on scaling law; T-SHIRT: Token-Selective Hierarchical Data Selection based on lexical selection; QuaDMix: Quality and Diversity Mixing; Uniform-Hier: Uniform Hierarchical Selection with fixed proportions; AGD (this invention): Adaptive Granularity Diversity-driven Selection for pre-trained data of large language models.

[0122] Table 1 shows the effective rank comparison of the above methods on the SlimPajama dataset with a selection budget of 1.5% across three granularities. AGD achieves high effective rank at the document, paragraph, and sentence levels through granular collapse diagnosis and adaptive resource allocation, with an overall effective rank of 40.7, outperforming all compared implementations. Specifically, the paragraph-level effective rank is 34.8% higher than DiSF, demonstrating AGD's precise focus on severely collapsed granularities. Regarding the Gini coefficient, AGD reduces it to 0.543, indicating a more uniform distribution of feature values ​​in the selected data and effective mitigation of dimensionality collapse.

[0123] Table 2

[0124]

[0125] Full Data: Unfiltered and unfiltered complete pre-trained corpus benchmark.

[0126] Table 2 shows the average accuracy of each method on nine downstream tasks after pre-training on the same 1.1B parameter model. These nine downstream tasks are recognized authoritative benchmark evaluation tasks for common sense reasoning and language understanding in the field of large-scale model pre-training, specifically including: ARC-Easy (basic set of scientific common sense reasoning), ARC-Challenge (challenge set of scientific common sense reasoning), OpenBookQA (open-book common sense question answering), PIQA (physical common sense reasoning), HellaSwag (contextual continuation common sense reasoning), WinoGrande (pronoun disambiguation reasoning), BoolQ (Boolean reading comprehension question answering), RACE (high school and college entrance examination reading comprehension test), and MMLU (multi-task multi-disciplinary integrated language comprehension benchmark). The average accuracy of each model was calculated under the same evaluation configuration (uniformly set to few or no samples within the Harness evaluation framework). AGD achieved an average accuracy of 53.2% with a selection ratio of 1.5%, an improvement of 0.8 percentage points compared to full-data training, 0.9 percentage points compared to Uniform-Hier, and 0.5 percentage points compared to the basic DiSF method. The results validate the significant optimization effect of adaptive granularity selection on the quality of pre-trained data under a limited budget.

[0127] In one embodiment, a training state-aware data selection method is also provided for cross-dataset migration scenarios. See [link to relevant documentation]. Figure 4 The specific process includes the following:

[0128] This implementation addresses cross-dataset migration scenarios, deploying on small to medium-sized computing nodes with a single GPU. The goal is to migrate the AGD method from a dataset with a pre-defined collapse pattern (source domain SlimPajama) to a new target domain dataset (such as a subset of social media and forums from RedPajama-V2). The challenge lies in the significant differences in text length distribution, domain composition, and expression style between the target domain and the source domain, leading to shifts in collapse patterns at various granularities. In the target domain, document-level collapse is severe due to repetitive user-generated content, while sentence-level collapse is relatively healthy due to the diversity of colloquial expressions. Simultaneously, the limited computing resources of a single GPU restrict batch parallelism, necessitating migration adaptation within limited computing power.

[0129] M1: Target Domain Corpus Loading and Multi-Granularity Segmentation. The original text file set of the target domain dataset is loaded into the computing node, and each file is segmented according to the same three-level segmentation strategy (document level, paragraph level, sentence level) as in Example 1. Considering the limited number of short paragraphs in social media texts, a single-sentence paragraph merging strategy is added to the paragraph-level segmentation logic. Short paragraphs with fewer than two consecutive sentences are merged into the previous paragraph, ensuring that the paragraph-level feature vectors have sufficient semantic information.

[0130] M2: Pre-trained encoder transfer and feature extraction. A Contriever pre-trained encoder is used to perform feature extraction on three sets of text fragments in the target domain with a batch size of 512. To address the large amount of informal expressions and URL links in the target domain text, a preprocessing filter is added during the tokenization stage to remove pure URLs, code snippets, and repetitive symbol sequences, ensuring that the encoder's output feature vectors are not affected by noisy tokens. The feature extraction process is executed sequentially on a single GPU, and the overall time consumption is proportional to the data size.

[0131] M3: Target Domain Granularity-by-Granularity Collapse Assessment. The covariance matrix is ​​calculated and eigenvalue decomposition is performed on the standardized eigenvectors of the three granularities of the target domain, extracting the effective rank and Gini coefficient. Due to the different text length distribution between the target domain and the source domain, the sample size for each granularity is... The differences were significant, and the collapse scores were normalized using a cross-granularity comparability calibrator. The evaluation results showed that the collapse pattern in the target domain was distinctly different from that in the source domain: document-level collapse severity... Highest, and sentence level The lowest value complements the collapse distribution of the source domain.

[0132] M4: Adaptive resource allocation in migration scenarios. Based on the measured collapse severity score of the target domain, the budget weights of each granularity are recalculated according to a power function allocation strategy. In this implementation, the document level receives the highest allocation weight due to its most severe collapse. Paragraph level received the next highest budget, while sentence level received only the lowest due to its good diversity. The adaptive allocation strategy reduced the overall collapse by 15.2% compared to uniform allocation, verifying the method's adaptability to different collapse distributions.

[0133] M5: Granularity-aware threshold dynamic adjustment. The threshold is recalculated and selected according to the collapse severity of each granularity within the target domain, using a dynamic threshold formula. The document level receives the lowest threshold due to severe collapse. Sentence-level sentences achieve higher thresholds due to their good diversity. Meanwhile, to address the single-GPU computing power constraint, the batch size was reduced from a preset value to a preset value, reducing the memory usage per batch and ensuring stable operation under limited video memory conditions.

[0134] M6: Batch-based greedy selection under single-GPU constraints. Performs batch-based greedy selection sequentially at each granularity on a single GPU compute node. Because the batch size is reduced to a preset value, the number of selections per batch is... The budget is halved accordingly, but the overall selection budget remains unchanged. To address the increased document-level budget, the number of document-level batches is increased to ensure selection sufficiency; sentence-level budgets are reduced to a minimum, resulting in only a small number of lightweight selection batches. Combined with the results of the preset requirements, the collaborative optimization of the three modules still contributes a significant improvement in effective rank.

[0135] M7: Weighted fusion and deduplication in migration scenarios. The selection results at the three granularities are recalculated and weighted accordingly. Weighted merging is performed. Since document-level selection has the highest weight in the target domain, it dominates the final merging, followed by paragraph-level selection, with sentence-level selection contributing the least. After merging, TopK filtering is performed to ensure the number of output indexes strictly equals the total budget. Based on pre-defined data, AGD achieves a very high level of overall effective rank, significantly improving upon uniform hierarchical selection.

[0136] M8: Transfer Effect Validation and Strategy Writeback. The model is pre-trained using a selected subset of target domain data and evaluated on nine downstream task benchmarks. Based on pre-defined data, AGD achieves the average accuracy of the target performance with a significant selection ratio. The collapse evaluation results of the target domain are compared and analyzed with those of the source domain, recording the offset direction and magnitude of the collapse mode, and feeding this information back to the resource allocation module to update the transfer adaptation strategy. This closed-loop mechanism enables AGD to continuously adapt to changes in different data distributions and possesses good cross-dataset generalization ability.

[0137] Implementation Results: This embodiment, while ensuring the final judgment and inference results, can significantly control the average communication overhead and inference load per page or per round. Furthermore, it can maintain stable link updates in dynamic collaborative scenarios with heterogeneity or missing modalities, making it highly suitable for promotion and deployment in real-world scenarios. For new access terminals, this invention can achieve rapid adaptation under cold start conditions, balancing personalized performance gains with maintaining generalization capabilities.

[0138] In one embodiment, a training state-aware data selection method is also provided for the corpus collection, extraction, and cleaning scenario of the "Ningbo Dialect Large Model" project. See [link to relevant documentation]. Figure 5 The specific process includes the following:

[0139] This implementation method addresses the corpus collection, extraction, and cleaning scenario of the "Ningbo Dialect Large Model" project. In this project, the collected corpus encompasses multi-granularity features: including long dialect storytelling passages (document / chapter level), daily conversational dialogues (paragraph level), and short voice interaction commands and vocabulary pronunciation fragments (sentence / short sentence level). The model's final applications support Automatic Speech Recognition (ASR), Text-to-Speech (TTS), and dialect translation agents. Given the varying redundancy levels of dialect data at different granularities (e.g., short sentence-level frequently used commands are highly repetitive and prone to collapse, while long stories have better diversity), deploying the AGD method can accurately identify and rationally allocate cleaning resources. The specific implementation steps are as follows:

[0140] M1: Dialect Corpus Loading and Multimodal Multigranular Segmentation. The Ningbo dialect corpus (including audio transcripts) collected in the field and crawled from the internet is loaded into the system, and multigranular segmentation is performed. Specifically for ASR speech recognition tasks and TTS text-to-speech / speech synthesis tasks, long speech segments and short dialogue instructions are split into long texts (chapter / segment level) and short speech corresponding texts (sentence level).

[0141] M2: Dialect Pre-trained Encoder Transfer and Feature Extraction. A text feature extractor specifically adapted for minority languages ​​or Pinyin / phonetic symbol enhancement (besides the Contriever encoder, other pre-trained text encoding models can be used, such as CLIP text encoder, intermediate layer representations of autoregressive models like GPT-2, or sentence embedding models based on the BERT series (such as Sentence-BERT))) is employed to map Ningbo dialect text and its transcription into high-dimensional features. Noise labels discovered during the cleaning and extraction stage are filtered out, and some acoustic features are simultaneously fused into the multimodal model as an auxiliary feature.

[0142] M3: Granularity-by-granularity collapse assessment of dialect corpora. This assesses the dimensional collapse of dialect data at various granularities. It is generally found that sentence-level or short-sentence-level corpora exhibit extremely high collapse severity due to the extensive repetition of high-frequency words (such as short greeting phrases) in Ningbo dialect; while long-document-level diversity of records of dialect storytelling is relatively good.

[0143] M4: Adaptive resource allocation for dialect tasks. After the system identifies severe collapse of sentence-level data, it adaptively allocates more of the budget (computing power and time) for corpus cleaning and diversity screening to the short sentence / short dialogue level to extract the most representative and non-redundant TTS / ASR training data; while allocating less budget to the document level.

[0144] M5: The granularity perception threshold of the translation agent is dynamically adjusted. For short sentence-level instruction corpora with severe collapse, an extremely strict diversity screening threshold is applied to eliminate a large number of similar everyday greetings, ensuring that the translation agent learns the richest possible dialect phrases; for long documents, the threshold is appropriately relaxed.

[0145] M6-M8: Granular Greedy Selection, Fusion, and Training Feedback. High-quality, highly diverse, and multi-granular dialect corpora, after screening and refinement, are fed into the backend large model pipeline for training. Evaluation metrics for the translation agent and the large speech model (such as ASR word error rate and TTS synthesis score) are fed back to the frontend evaluation module to further optimize the next corpus cleaning iteration.

[0146] Implementation Results: This embodiment deeply addresses the urgent needs of the Ningbo dialect large-scale model for corpus collection, refinement, and cleaning, resolving the issue of dimensionality collapse caused by high-frequency short phrases in ASR and TTS training of dialect data. By precisely allocating computing resources to the most redundant corpus granularity, it significantly improves the dialogue diversity and naturalness of speech synthesis in the dialect large-scale model's translation agent, making it highly suitable for supporting this project's application for various science and technology innovation awards.

[0147] Based on the same inventive concept, this application also provides an apparatus for implementing the above-described method for selecting pre-training data for large language models. The solution provided by this apparatus is similar to the implementation described in the above method, and therefore will not be repeated here.

[0148] In one embodiment, a selection device for pre-trained data of a large language model is also provided, comprising:

[0149] The feature extraction module is used to segment the original corpus according to different granularity levels to generate multiple granularity fragment sets; and to use a pre-trained encoder to extract features and standardize the text fragments in the multiple granularity fragment sets to obtain granular feature vectors at each granularity level.

[0150] The granularity-by-granularity collapse assessment module is used to assess the collapse of the granularity feature vectors at each granularity level and obtain the collapse severity score at each granularity level.

[0151] An adaptive resource allocation module is used to convert the collapse severity score of each granularity level into an allocation weight for each granularity level using a power function that includes a temperature parameter; and to perform budget allocation calculation based on the total selection budget and the allocation weight of each granularity level to obtain the selection budget for each granularity level.

[0152] The granularity-aware selection quality control module is used to dynamically set the selection threshold based on the collapse severity score of each granularity level, and to perform greedy diversity selection in parallel based on the selection threshold and selection budget of each granularity level to obtain the selection result corresponding to each granularity level.

[0153] The fusion module is used to perform weighted fusion and deduplication on the selection results corresponding to each granularity level to obtain a subset of pre-trained data.

[0154] In the above embodiments, each module of the selection device for pre-training data of a large language model can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0155] The above are merely preferred embodiments of the present application and are not intended to limit the embodiments of the present application. For those skilled in the art, the embodiments of the present application can have various modifications and variations. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the embodiments of the present application should be included within the protection scope of the embodiments of the present application.

Claims

1. A method for selecting pre-training data for large language models, characterized in that, Includes the following steps: The original corpus is segmented according to different granularity levels to generate multiple granularity fragment sets; a pre-trained encoder is used to extract features and standardize the text fragments in the multiple granularity fragment sets to obtain granular feature vectors at each granularity level. Collapse assessment is performed on the granularity feature vectors of each granularity level to obtain the collapse severity score of each granularity level; The collapse severity scores of each granularity level are converted into allocation weights for each granularity level using a power function that includes a temperature parameter. Budget allocation is calculated based on the total selection budget and the allocation weights of each granularity level to obtain the selection budget for each granularity level; The selection threshold is dynamically set based on the collapse severity score of each granularity level. Greedy diversity selection is performed in parallel based on the selection threshold and selection budget of each granularity level to obtain the selection result corresponding to each granularity level. The selection results corresponding to each granularity level are weighted, fused, and deduplicated to obtain a subset of pre-trained data.

2. The method for selecting pre-training data for large language models according to claim 1, characterized in that, The different granularity levels include document level, paragraph level, and sentence level.

3. The method for selecting pre-training data for large language models according to claim 1, characterized in that, The pre-trained encoder uses the Contriever model.

4. The method for selecting pre-training data for large language models according to claim 1, characterized in that, The standardization process employs zero-mean, unit variance standardization.

5. The method for selecting pre-training data for large language models according to claim 1, characterized in that, Collapse assessment is performed on the granularity feature vectors of each granularity level to obtain a collapse severity score for each granularity level, including: The covariance matrix of the eigenvectors of each granularity level is calculated, and the eigenvalue spectrum analysis is performed on the covariance matrix to extract the effective rank and Gini coefficient of each granularity level. The collapse severity score for each particle size is obtained by weighting the effective rank and Gini coefficient of each particle size level.

6. The method for selecting pre-training data for large language models according to claim 1, characterized in that, Also includes: By introducing a lower bound constraint of the minimum budget at a single granularity, the selection budget at each granularity level is adjusted to obtain the adjusted selection budget at each granularity level.

7. The method for selecting pre-training data for large language models according to claim 1, characterized in that, The selection threshold The calculation formula is as follows: ,in, Based on the selection of threshold, The adjustment coefficient satisfies , For particle size The severity score of the collapse.

8. The method for selecting pre-training data for large language models according to claim 1, characterized in that, The selection results corresponding to each granularity level are weighted, fused, and deduplicated to obtain a subset of pre-training data, including: Based on the selection results corresponding to each granularity level, a document-level selection index set is obtained. Paragraph-level selection index set and sentence-level selection index set ; Mapping the paragraph-level selection index set and the sentence-level selection index set to a unified file-level index space establishes a mapping relationship from fine-grained indexing to coarse-grained indexing: ,in, This represents the set of file-level indexes mapped from the paragraph-level selection results. This represents the set of file-level indexes obtained by mapping the sentence-level selection results. Indicates the first The first document in the document One paragraph, Indicates the first The document, the first The first paragraph One sentence. This is a document-level index; the document-level selection result itself is a set of document-level indexes, i.e. ; A weighted merge is performed on the three granularity file-level index sets, and a merge score is calculated for each file. ,as follows: ,in, For particle size The corresponding set of file-level indexes, For particle size The allocation weights, For indicator functions; Sort the files in descending order according to the merged score, and select the top... Each file is used as the fusion result. : ,in, To determine the proportion of the total budget, For floor operations, The total number of documents in the candidate corpus.

9. A selection device for pre-training data of large language models, characterized in that, include: The feature extraction module is used to segment the original corpus according to different granularity levels to generate multiple granularity fragment sets; and to use a pre-trained encoder to extract features and standardize the text fragments in the multiple granularity fragment sets to obtain granular feature vectors at each granularity level. The granularity-by-granularity collapse assessment module is used to assess the collapse of the granularity feature vectors at each granularity level and obtain the collapse severity score at each granularity level. An adaptive resource allocation module is used to convert the collapse severity scores of each granularity level into allocation weights for each granularity level using a power function that includes temperature parameters. Budget allocation is calculated based on the total selection budget and the allocation weights of each granularity level to obtain the selection budget for each granularity level; The granularity-aware selection quality control module is used to dynamically set the selection threshold based on the collapse severity score of each granularity level, and to perform greedy diversity selection in parallel based on the selection threshold and selection budget of each granularity level to obtain the selection result corresponding to each granularity level. The fusion module is used to perform weighted fusion and deduplication on the selection results corresponding to each granularity level to obtain a subset of pre-trained data.