Elamur Research

Optimizing GPT-2 Pretraining on BabyLM Corpus with Difficulty-based Sentence Reordering

Paper · 2023 · Nasim Borazjanizadeh

Summary

What should a language learner see together when training data are scarce? Nasim Borazjanizadeh trains GPT-2 from scratch on BabyLM Strict-Small and asks whether the same collection of texts can teach more grammar if its sentences are prepared or ordered differently. The outcome is average zero-shot accuracy on BLiMP, a benchmark that tests whether a system prefers a grammatically acceptable English sentence to a closely matched unacceptable alternative. The study starts with a formatting problem. Some sentences in gutenberg span several lines, and the training loop treats lines as separate samples. Joining the fragments before training raises GPT-2’s BLiMP score from 73.40% to 75.05%. The official BabyLM baselines score 69.47% for RoBERTa-base, 62.63% for OPT-125, and 58.83% for T5-base. The experiments use this benchmark to assess what can be learned from a small corpus about English.

In an initial curriculum, easier sentences are available earlier and can be sampled more often. The author argues that using length as a difficulty cue gives too much exposure to short examples, including speech fragments. The paper introduces average sentence rarity, or ASR, to rank sentences by the average corpus frequency of their words. It then shifts from controlling the progression of the whole training corpus to placing similarly difficult sentences together in individual training contexts. In 20 runs, the author sorts one of the 10 datasets by either sentence rarity, which incorporates length, or ASR, which averages over it. The other 9 datasets use their base preparation. GPT-2 trains for six epochs with a context of 128 tokens and a batch size of 64 in the main setup. Changing the initialization seed in repeated baseline runs produced BLiMP variation of up to 0.6%, so the reported experiments use seed 1.

Sorting changes which sentences become neighbors. The author measures that change with local coherence, the average similarity of a sentence to its neighbors in a seven-sentence window. The similarities come from a separate, pretrained SimCSE encoder. Every sorted dataset loses coherence by this measure. Among the sorted variants, however, those with higher coherence tend to produce higher BLiMP scores. The Spearman rank correlation is 0.693 for sentence rarity and 0.559 for ASR. The strongest sorting-only result is 75.77%, obtained by sorting aochildes by sentence rarity. This comparison uses sentence meaning as an indirect measure of the context that survives reordering, through semantic similarity.

ASR also helps find material worth inspecting. In gutenberg, the easiest end of the ordering brings together lines dominated by very common items, including strings of numbers. After sorting and deduplicating that dataset, the author uses manual inspection to decide which lines to remove. Cutting 3200 lines produces the submitted run, which scores 75.84% on BLiMP, over 6% above the released baselines as described in the paper, and has a perplexity of 54.8 on the BabyLM test data. Sorting two or more datasets yields no BLiMP improvement in the reported experiments. The study therefore makes a case for considering the relationship between examples when changing a curriculum. Its coherence measure captures meaning, while BLiMP tests grammar, and the proposed next step is an ordering rule that considers both individual difficulty and similarity between neighbors.

Deep dive: Optimizing GPT-2 Pretraining on BabyLM Corpus with Difficulty-based Sentence Reordering

This study tests how repairing, sorting, and cleaning BabyLM training sentences affects GPT-2’s zero-shot performance on English grammar. · about 30 minutes to read

The problem and its context

What can change when the data budget is fixed?

A small training corpus limits the range of examples a learner can encounter. It also makes the treatment of the examples already present consequential. A sentence can be supplied as a complete stretch of language, split into fragments, or placed beside examples that come from an entirely different source. The words may be substantially the same in these cases, but the context available when predicting them changes. BabyLM Strict-Small gave the author a setting in which to examine this issue. The training data for GPT-2 came exclusively from that track, so changes in preparation and order offered ways to investigate whether more could be learned from the available collection.

The practical question concerns the arrangement of input for a language model. GPT-2 learns to predict tokens using preceding tokens in its context. A useful distinction in the paper is between a unit stored in the corpus and a unit read during training. A stored line becomes a sample, but a training sequence can contain material from several samples. The learner can therefore receive words from the end of one line and the beginning of another in the same context, even when their original relationship has changed. Reordering involves deciding which material is available together as well as deciding what is encountered earlier in training.

The sources make those choices matter in different ways. The corpus includes transcribed conversations and written sources. The author describes short utterances in aochildes that omit or misplace elements such as pronouns and verbs. Such utterances are intelligible as part of a conversation, where a speaker can leave information implicit, yet an isolated line gives the learner fewer cues about the construction. The paper describes wikipedia as having longer, more conventionally grammatical sentences with less unnecessary repetition. The connection with developmentally plausible data comes through child-directed speech.

The author draws that description of aochildes partly from BabyBERTa. Here the point of comparing sources is to question a difficulty rule. A short utterance can be easy to rank as short and still be a poor example of the grammatical contrast a benchmark will later test. Conversely, a longer written sentence may impose more prediction steps while displaying the relevant parts of a construction explicitly. Ranking by length assigns a place in the curriculum before considering either difference.

How earlier curricula decided what to present

The paper takes its starting point from curriculum learning as described by Bengio and colleagues. The basic proposal is to begin with relatively easy examples and introduce harder ones as learning advances. This requires choices about what makes an example hard, how soon more difficult examples become available, and what happens to earlier examples after that point. An ordering by itself answers only the first of those questions. A sampling schedule turns that ordering into a pattern of exposure during training.

The competence-based procedure attributed to Platanios and colleagues uses estimated learner competence to determine how far into a difficulty-ranked collection the sampler may reach. The paper applies a square-root schedule under which the pool of eligible examples expands at a decreasing rate. It considers two difficulty heuristics from that work. Sentence length treats short examples as easy. Sentence rarity uses word probabilities to rank examples, so a sentence’s score reflects both how common its words are and how many of them there are. The author’s concern is that both rules can put many short samples into the early eligible pool.

That concern depends on the distinction between availability and exposure. Once an easy example enters the pool, it can be drawn again as the pool grows. A difficult example that becomes eligible later has fewer opportunities to appear. If the position of a sentence is mostly determined by its length, the schedule can turn a length preference in the ranking into an exposure preference across training. The author suspected that this would be a poor match for parts of BabyLM containing short, fragmented speech. The proposed average-frequency measure was intended to weaken that dependence without discarding word frequency as a cue.

A separate concern arises even if the ranking is satisfactory. When a curriculum gathers examples with similar scores, the resulting neighbors may have originated in different conversations, stories, or articles. Similar difficulty guarantees something about the ranking rule and leaves open whether the sentences discuss the same subject or express related ideas. The paper’s approach is to examine both the distribution of difficulty and the continuity of the text that can fit inside a context.

Why the study concentrates on BLiMP

BLiMP evaluates sensitivity to closely matched alternatives constructed around particular grammatical phenomena. The choice between the alternatives supplies a focused test. A pretrained system can be scored directly on its preferences, which is why the paper calls the evaluation zero-shot. A high score means that the system frequently favors the acceptable member of the pair according to the benchmark. That makes BLiMP suitable for studying whether changes to the training corpus affect preferences about syntax and grammar.

The paper gives a practical reason for choosing this target. Other evaluations in the BabyLM pipeline, including (Super)GLUE and held-out MSGS, require additional training on task-specific examples and would have exceeded the resources available for this study. BLiMP supplied the signal used to assess the preprocessing and curriculum choices. The results are consequently about grammar preferences under that protocol, with a separate perplexity measurement for the submitted run. The other evaluations would have required fine-tuning.

This choice also shapes what counts as a potentially useful example. Spoken and written data can serve different learning goals. The paper asks how their treatment affects a benchmark of grammatical acceptability, and its observations about fragments and informal speech are arguments about that target. A corpus feature can have a measurable effect in this setting without receiving a general verdict about its value as language data.

The method, step by step

Repair the sample units before changing their order

The starting operation is to read a source file one line at a time. Each line is initially a sample. A manual inspection showed why this was a poor fit for gutenberg: a full sentence could be distributed over several lines. If those lines were shuffled separately, the beginning of a sentence and its continuation could be sent to different training sequences. A fragment could instead appear next to text from another sentence. The repair joins the pieces in the source file so that the complete sentence occupies a single line.

This gives the complete sentence a stable identity as a sample. Its words stay together through the shuffling of sample indices, subject to the later division of the token stream into fixed-length sequences. The repair also changes where the packing operation can insert a separator, because that operation inserts a marker between samples. A line break that occurred inside a sentence previously created an opportunity for a boundary in the training representation. Merging the lines removes that boundary between the fragments. The raw-data GPT-2 run is the comparison that retains the original line breaks. The repaired version supplies the base gutenberg input for the other experiments.

The author first compares GPT-2, BERT, and RoBERTa under the paper’s common settings and standard training procedures. GPT-2 reaches convergence sooner and does slightly better on BLiMP in that preliminary comparison. The remaining training experiments use GPT-2, which fixes the architecture while the paper varies the data preparation or the ordering. This preliminary comparison is distinct from the comparison with the official BabyLM baselines, which are separately reported challenge entries.

Pack samples into contexts and choose a checkpoint

The data loader uses batches of size 64. Each sample is tokenized, meaning that it is converted into the units the learner reads. Within a batch, the samples are joined into a stream with an end-of-sequence token between them. The stream is divided into sequences of the chosen context length. A separator identifies the meeting point of samples within a sequence, and the sequence can still include tokens from several samples. The distinction between a corpus word used for a difficulty count and a training token used for packing follows from tokenization.

The window used for the main experiments is 128 tokens. The preliminary comparison also considers 64, 256, and 512. A 64-token context lowers the BLiMP score, while the two longer settings offer no reported improvement over 128 and consume more GPU memory and training time. The author chooses 128 as the smallest option in that comparison that maintains performance. This setting has a direct bearing on the experiment. A context must be long enough to contain parts of several samples for their relative ordering to change what they contribute to one another.

In the base training runs and the leave-one-dataset-out runs, the loader shuffles sample indices at every epoch. An epoch is a pass through the training data as prepared for that run. The main GPT-2 setup uses six epochs, with convergence generally around the fifth. The training loop evaluates on its evaluation data every 500 steps, uses gradient accumulation of 1, and picks the checkpoint with the lowest evaluation loss for BLiMP. In effect, the training evaluation decides which saved state enters the grammar test. The paper also uses BLiMP to compare the resulting configurations with one another.

The author repeated some baseline runs while changing the seed used before initialization. The reported BLiMP variation reached 0.6% in otherwise identical setups. This motivated the choice of seed 1 for the runs discussed in the paper. A common seed makes those comparisons easier to interpret by holding the initialization choice fixed. The repeated runs also give a sense of the scale of score variation the author encountered before making that choice.

Test an easy-to-hard schedule

The whole-corpus curriculum begins by giving the examples a difficulty ranking. Sentence length, abbreviated SL, puts shorter examples at the easy end. Sentence rarity, abbreviated SR, builds a sentence-level likelihood from the product of unigram probabilities for its words. A unigram probability here concerns an individual word. Multiplying over the sentence means that word frequency and the number of factors both influence the result. An example containing many common words can become less probable as more factors enter the product. The paper also uses the label SA for sentence rarity in its later tables and figure.

The square-root competence function supplies the schedule for drawing from the ranked data. At training time (t), the eligible portion reflects the competence assigned to that point relative to competence at convergence. As more examples become available, additions to the pool slow down. Earlier examples can be drawn multiple times while the author builds the training corpus. For this experiment, the completed corpus is presented in its prescribed sequence with shuffling disabled and a training budget of 1 epoch. That pass is over the constructed corpus, which already reflects repeated sampling by the competence function.

Changing the schedule in that way changes the number of appearances an example can have. This gives the difficulty rule a larger role than it plays in a simple sort. Under the competence schedule, a preference for short examples can repeatedly expose the learner to the kinds of short examples that the inspection identified as fragmented. In a simple sort, a preference for short examples instead affects where they are placed and which neighbors they have. The main experiment later uses the second kind of intervention.

Estimate average sentence rarity

The rationale for looking at word frequency is that rare words have fewer observed contexts in a small corpus. The paper argues that they may require repeated exposure and that the estimates used to learn their representations may fluctuate more. This motivates treating the prevalence of the words in a sentence as one clue to its difficulty. The paper first defines a count across all positions in the corpus.

f̂(wⱼ) ≔ ∑ᵢ₌₁ᴹ ∑ₖ₌₁ᴺⁱ 𝟙[wᵢₖ = wⱼ]

Here f̂(wⱼ) is the count of the word type wⱼ. The index j identifies a distinct word in the corpus. The outer sum, marked by the first ∑, runs over sentence indices i, from 1 through M, the number of sentences. The inner sum runs over positions k, from 1 through Nⁱ, the number of words in sentence i. The word at position k in that sentence is wᵢₖ. The symbol 𝟙 is an indicator. Its bracketed equality yields 1 when the two words match and 0 otherwise. The symbol ≔ introduces the definition.

The count gives a lookup value for each word. Each occurrence in the sentence being scored contributes that word’s lookup value, including repeated occurrences of the same word. ASR then aggregates those values as follows.

dₐᵥgᵣₐᵣᵢₜᵧ(sᵢ) ≔ (−1/Nⁱ) ∑ₖ₌₁ᴺⁱ f̂(wᵢₖ)

The expression on the left is the average sentence rarity score for sᵢ, sentence i. In the sum ∑, the index k traverses the Nⁱ word positions of that sentence. At each position, f̂(wᵢₖ) retrieves the count defined above for the word that occurs there. Dividing by the number of positions takes their mean. The −1 factor gives the difficulty expression its sign, / indicates division, and ≔ again defines the quantity. With the negative sign as written, a larger mean count gives a smaller numeric difficulty value. The experimental description makes the intended ordering clear by placing sentences dominated by common words at the easy end.

Using a mean removes the automatic effect of multiplying in another factor for every new word. Length can still be associated with vocabulary in a particular dataset. A longer passage may contain a different mixture of words, and the mean can change when a word is added. What makes ASR length-independent in the paper’s sense is the normalization by the number of words. If two sentences have the same mean word frequency, having more positions gives neither sentence an additional length penalty.

The averaging rule also explains why the author later uses ASR for cleaning. A sentence can rank as easy because it contains frequent words that carry very little meaning in combination. Where an entire group of such lines occurs, the ranking makes them easier to find. Their position in the list depends on the distribution of their words, leaving a separate judgment about the quality of the text to the human reviewer.

Restrict the reordering to one source

The later design asks whether the learner benefits when samples of comparable difficulty occur in the same training context. It sorts within one source dataset and then builds a corpus with that dataset and the 9 base datasets. The sorted dataset is deduplicated in the processing of the difficulty-sorted runs. This operation is repeated with both SR and ASR for each choice of source. The rest of the corpus uses the base preparation, including repaired gutenberg where applicable.

The choice to work within one source follows the author’s concern about mixing dissimilar text. Text from a single dataset can still span many topics, so source membership provides only a rough constraint on the neighbors the sort can create. It limits the change relative to moving sentences freely across all sources. Packing then makes the arrangement relevant to learning by putting multiple samples into one training context. The experiment evaluates different arrangements indirectly, through the performance of GPT-2 trained with each selected dataset in its new order.

Preparing and evaluating a single-source BabyLM curriculum

The steps in order.

Preparing and evaluating a single-source BabyLM curriculumStep 1: Join Gutenberg sentence fragments into complete lines1. Join Gutenberg sentence fragments into complete linesStep 2: Choose one dataset for reordering2. Choose one dataset for reorderingStep 3: Remove duplicate inputs from the selected dataset3. Remove duplicate inputs from the selected datasetStep 4: Rank its sentences by a difficulty measure4. Rank its sentences by a difficulty measureStep 5: Combine the sorted dataset with the base datasets5. Combine the sorted dataset with the base datasetsStep 6: Tokenize and pack samples into training contexts6. Tokenize and pack samples into training contextsStep 7: Train GPT-2 and select a checkpoint7. Train GPT-2 and select a checkpointStep 8: Evaluate grammatical preferences on BLiMP8. Evaluate grammatical preferences on BLiMP

The flow describes the single-source sorting branch. The competence-based branch constructs its own training corpus through repeated sampling. The cleaning branch adds manual inspection and removal after ranking with ASR. In the single-source experiments, the new neighbors are chosen by difficulty. Coherence is measured separately to characterize the arrangement that results.

Measure how much meaning remains nearby

The paper uses local coherence to estimate whether a sentence sits near others that discuss related material. It gives a contrast between text about engines and conversation between parents and children about lunch. Successive sentences in an article about engines might develop the same subject. An utterance about lunch can have clear links to its own conversation while sharing little subject matter with a sentence about engines. An ordering that places passages by estimated difficulty can bring together examples with similar vocabulary frequencies even when their meanings differ in this way.

To quantify relatedness, the author uses sup-simcse-roberta-large, a pretrained encoder from SimCSE. It turns each sentence into a numerical representation called a sentence embedding. Cosine similarity compares the directions of two such representations. The score is supplied by the external encoder, independently of the GPT-2 runs that are later evaluated on BLiMP. The paper thereby uses one system to characterize the inputs and another to test what can be learned from those inputs.

The neighborhood is chosen with training context in mind. In the packing analysis, a 128-token sequence contains material from an average of 8.512 inputs across the BabyLM datasets. For the 80% longer portion of the inputs, the paper reports an average of 6.55. Taking the longer portion as more relevant to the BLiMP question, the author selects a window of seven sentences. This is a fixed approximation to the amount of neighboring material a training sequence can contain. The actual packing can fit different numbers of samples, depending on how many tokens each contributes.

c(sᵢ) ≔ (1/6) ∑ₖ sim(sᵢ, sᵢ₊ₖ),   k ∈ {−3, −2, −1, 1, 2, 3}

Here c(sᵢ) is local coherence for the central sentence sᵢ, and ≔ defines it. The operator ∑ adds a similarity for each included offset k. The membership sign ∈ and the braces specify the positions being used. Negative offsets select preceding sentences and positive offsets select following sentences. The subscript i+k gives the neighbor’s position by adding its offset to the center index. The function sim returns cosine similarity between the embeddings of the two sentences in its parentheses. The comma there separates the arguments. The factor 1/6 averages over the six neighbors, with the center left out of the comparisons.

The next operation pools these central-sentence scores into an estimate for a dataset. To save the resources needed to score every sentence, the paper reports an average based on 1,000 distinct sentences drawn at random from each dataset. It applies the procedure to the original and sorted versions of the datasets. The resulting expected local coherence describes a typical neighborhood under the chosen encoder and window. It is a measure of the arrangement in the source data. The prediction contexts seen by GPT-2 come from the token packing, which supplies the motivation for the window without being reproduced exactly by it.

Use the easy end of ASR to find text for review

The author inspects the ends of the ASR ordering and looks for lines whose vocabulary frequencies are extreme for reasons unrelated to the quality of a sentence. In gutenberg, the easy end isolates lines containing a few words and long strings of numbers, which the paper suggests are Project Gutenberg catalog identifiers. Other easy-ranked inputs can be dominated by common items such as articles or pronouns while developing little meaning. The paper identifies gutenberg, bnc_spoken, and cbt as the targets for the cleaning experiments.

ASR supplies the order for inspection. The removal decision uses a manual rule. For every 200 lines, the author examines 10 lines and removes the preceding 200 if more than 1 of the 10 is judged grammatically incoherent or semantically meaningless. The lines cut in this operation are counted after duplicate removal. Each resulting dataset is then combined with the 9 base datasets for training. The comparison run for each source uses the ASR-sorted version from before this cleaning step.

The hard end of the ASR list can also surface meaningless text, this time because it contains many rare words. The paper reports that removing such material offered no BLiMP improvement. One proposed explanation is that even a poor context may be among the few in which a rare word appears. Taking it out could reduce the examples available for learning that word. For frequent words, the author conjectures that the learner has more useful occurrences to draw on and that some repetitive, uninformative uses contribute noise. Those explanations motivate the focus on the easy end. The experiment itself records what happens after cutting the reviewed lines.

Experiments and results

The score and the baseline comparisons

The training collection is BabyLM Strict-Small, and the main reported score is average accuracy across BLiMP’s zero-shot tasks. On a matched pair, the grammar benchmark checks whether the system prefers the acceptable member. The average then summarizes its choices across the benchmark’s tasks. The paper uses this aggregate to compare data treatments. Its results place each configuration on a common scale while leaving the distribution of gains across particular grammatical phenomena open.

There are two useful GPT-2 starting points. The raw run trains on all the track’s datasets with the original gutenberg line breaks and obtains 73.40% on BLiMP. The repaired run trains on 9 datasets in their base form and uses complete sentence lines for gutenberg. It reaches 75.05%. That score becomes the reference for the leave-one-out ablations and the difficulty experiments. It represents a data treatment already motivated by inspecting the corpus. Comparing subsequent runs with it asks whether they add to the gain from a straightforward repair.

The released BabyLM systems provide a separate point of comparison. RoBERTa-base, the strongest of the reported official entries, scores 69.47%. OPT-125 scores 62.63%, and T5-base scores 58.83%. These scores put the raw and repaired GPT-2 settings in the context of the challenge. Since the official entries involve different architectures, the paired raw and repaired GPT-2 runs are the more direct comparison for the effect of the gutenberg preparation.

BLiMP zero-shot accuracy for selected BabyLM Strict-Small baselines

The GPT-2 baseline with repaired Gutenberg sentences leads the comparison.

BLiMP zero-shot accuracy for selected BabyLM Strict-Small baselinesOfficial OPT-125: 62.63Official OPT-12562.63Official RoBERTa-base: 69.47Official RoBERTa-base69.47GPT-2 with raw Gutenberg: 73.40GPT-2 with raw Gutenberg73.40GPT-2 with merged Gutenberg sentences (this paper): 75.05GPT-2 with merged Gutenberg sentences(this paper)75.05
The numbers
System or settingaccuracy %
Official OPT-12562.63
Official RoBERTa-base69.47
GPT-2 with raw Gutenberg73.40
GPT-2 with merged Gutenberg sentences (this paper)75.05

The repaired score is an important reference even though the preliminary architecture comparison gave the author a reason to use GPT-2. Architecture selection and line repair answer different questions. The former identifies a practical base for the experiments. The latter changes what that base learns from by keeping complete sentences intact as samples. The subsequent curriculum comparisons start where the line repair leaves off.

Changing the ranking inside the competence schedule

With the repaired corpus and the competence-based schedule, sentence length yields 69.93% on BLiMP. Sentence rarity raises the score to 71.49%. Average sentence rarity is strongest under that schedule at 74.51%. The progression is in the direction the author expected when introducing ASR. The score is higher when the heuristic explicitly divides out the number of words, so the difficulty ranking has less reason to give short examples priority solely for their length.

BLiMP zero-shot accuracy by difficulty rule for a BabyLM Strict-Small competence curriculum

Average sentence rarity gives the strongest result within the competence-based schedule.

BLiMP zero-shot accuracy by difficulty rule for a BabyLM Strict-Small competence curriculumSentence length: 69.93Sentence length69.93Sentence rarity: 71.49Sentence rarity71.49Average sentence rarity (this paper): 74.51Average sentence rarity (this paper)74.51
The numbers
System or settingaccuracy %
Sentence length69.93
Sentence rarity71.49
Average sentence rarity (this paper)74.51

The strongest result in this comparison still falls below the 75.05% repaired baseline. The ranking change improves the tested competence-based approach, while the schedule as a whole fails to beat the simpler data preparation. That set of results motivates testing a different intervention. The author takes difficulty as a possible basis for packing similar examples together and stops using the schedule to repeatedly sample a growing pool drawn from the whole corpus.

Sorting one dataset and checking its new neighbors

The main ordering experiment covers 20 runs, each of which uses one sorted dataset and the 9 base datasets. Across the runs, 8 exceed the repaired GPT-2 baseline of 75.05%. Every run exceeds 73.40%, the result with the raw gutenberg input. The repaired baseline is the more informative denominator for this question because all these comparisons benefit from the corpus preparation introduced earlier.

The best ordering-only result is 75.77%, achieved by sorting aochildes with SR. The paper reports a 0.72% increase on BLiMP for that configuration relative to the repaired baseline. Sorting the same source with ASR yields 74.85%. This is a case where switching the ranking changes which side of the repaired baseline a run falls on. The best ASR ordering result among the single-source runs is 75.59% for cbt. Sorting gutenberg with ASR alone gives 74.71%, preparing the ground for the later comparison with manual cleaning of that same ordered dataset.

There is also a pronounced change in the diagnostic scores, even for rearrangements that improve BLiMP. In aochildes, expected local coherence is 0.303 in the original order, 0.149 with SR, and 0.152 with ASR. For gutenberg it is 0.307 in the original order, 0.121 with SR, and 0.120 with ASR. In wikipedia, the corresponding values are 0.400, 0.124, and 0.127. These examples show two features of the table. Both sorting rules have substantially lower coherence than the original orders, and the rule that retains slightly higher coherence depends on the dataset. The paper sees broadly comparable performance between SR and ASR on this diagnostic.

The next comparison relates each sorted dataset’s expected local coherence to the BLiMP score of the GPT-2 run that used it. The author uses Spearman’s rank correlation, which compares the ordering of the values in one measurement with the ordering in another. Higher-ranking datasets for coherence tend also to lead to higher-ranking training runs for BLiMP. The coefficient is 0.693 for SR and 0.559 for ASR. These are separate comparisons within the respective sorting rules. The values describe an association between a characteristic of the sorted source and the performance of the system trained on the whole corpus with that source included.

The original order has higher measured coherence across the corpus sources, yet sorting some sources still improves performance. The comparisons support considering both effects of a sort. Grouping examples by difficulty can be helpful for a particular dataset, while breaking naturally related sequences may limit the benefit. The rank correlations say that higher residual coherence accompanies better scores among the rearrangements. They do not specify how much of the difference in any particular run came from its neighbors.

Cleaning after sorting

The cleaning results compare each ASR-sorted source with a version that has also undergone the manual removal procedure. In bnc_spoken, cutting 4600 lines changes BLiMP accuracy from 75.37% to 75.53%. In cbt, cutting 800 lines changes it from 75.59% to 75.69%. The paper describes the improvements for those sources as negligible. The noticeably different case is gutenberg, where cutting 3200 lines changes the score from 74.71% to 75.84%.

BLiMP zero-shot accuracy before and after ASR-guided cleaning in BabyLM Strict-Small

Gutenberg shows the largest improvement after cleaning and gives the strongest score.

BLiMP zero-shot accuracy before and after ASR-guided cleaning in BabyLM Strict-Smallbnc_spoken sorted: 75.37bnc_spoken sorted75.37bnc_spoken sorted and cleaned: 75.53bnc_spoken sorted and cleaned75.53cbt sorted: 75.59cbt sorted75.59cbt sorted and cleaned: 75.69cbt sorted and cleaned75.69gutenberg sorted: 74.71gutenberg sorted74.71gutenberg sorted and cleaned (this paper): 75.84gutenberg sorted and cleaned (thispaper)75.84
The numbers
System or settingaccuracy %
bnc_spoken sorted75.37
bnc_spoken sorted and cleaned75.53
cbt sorted75.59
cbt sorted and cleaned75.69
gutenberg sorted74.71
gutenberg sorted and cleaned (this paper)75.84

The removed line counts refer to material cut after deduplication. They show the scale of each operation, while the scores show the consequences of training on the resulting corpora. The largest cut occurs in bnc_spoken, and the largest improvement occurs in gutenberg. The author suggests that the lines removed from gutenberg contained a higher share of meaningless inputs. The line counts cannot establish that explanation by themselves, since the inspection rule is based on samples of lines and the resulting BLiMP score is measured after retraining.

The repaired, ASR-sorted, and cleaned gutenberg configuration is the challenge submission. Its 75.84% is the highest BLiMP average reported in the paper. The abstract describes that result as an improvement of over 6% compared with the released BabyLM baselines. The paper also gives a perplexity of 54.8 for the submitted configuration on the BabyLM test datasets. Perplexity reflects predictive uncertainty on those test texts, while BLiMP measures preferences between grammatical alternatives. The paper reports the perplexity for the submission without providing a series of matched perplexity comparisons for the other data treatments.

What the ablations show

Removing whole sources identifies their contribution in this corpus

The leave-one-out study consists of 10 training runs. Each uses nine of the base datasets and omits the remaining source. The reference is the full repaired corpus, whose GPT-2 score is 75.05%. Every omission produces a lower BLiMP score. Excluding aochildes leaves 74.40%, the highest score among the omissions. Excluding wikipedia leaves 72.70%, the lowest. The run without open_subtitles reaches 72.81%, and omitting the repaired gutenberg leaves 73.48%. These comparisons measure the contribution of each source in combination with the others under the specified preparation and training setup.

The author uses aochildes and wikipedia to motivate a hypothesis about short examples. In the author’s inspection, aochildes contains informal utterances and more fragments, whereas wikipedia supplies longer, conventionally grammatical sentences. A grammar benchmark built from acceptability contrasts gives a reason to expect informative differences between those types of inputs. The leave-one-out result is consistent with that expectation. The removal, however, also changes the volume of training data and the available words, topics, and styles. It yields a source-level comparison, with length and grammatical form varying together with those other properties.

The aochildes results also illustrate the difference between omitting text and rearranging it. Its removal yields the smallest drop in the omission series. SR sorting of the same source gives the highest score in the ordering-only series. When the source is omitted, its examples contribute no contexts. When it is sorted, its examples can still appear, but the position and selection of nearby samples change. The two tests therefore give evidence about different decisions. A source’s measured contribution under its base preparation does not determine how much it can benefit from a new arrangement.

Restoring full sentences gives a direct preparation comparison

The raw and repaired gutenberg runs vary the line preparation within the same GPT-2 setup. This offers a close comparison for the impact of the unit stored in the data file. With individually shuffled fragments, a continuation can be detached from the words that make it part of a single grammatical unit. Merging gives the line-based loader access to the sentence in one sample. The movement from 73.40% to 75.05% supports the importance of that preparation for BLiMP in these runs.

The repair affects both the text that can survive shuffling and the location of inserted end-of-sequence boundaries. Those changes belong to the same intervention in the experiment. The resulting improvement establishes what the repair as a whole accomplished. It also helps explain why the paper treats context as more than the ordering of complete sentences. There is context inside each of those sentences, and losing it before packing begins can alter what the learner reads.

The context-length comparison tests a further part of packing. At 64 tokens, BLiMP performance declined. The reported comparisons at 256 and 512 did not improve the BLiMP score relative to 128, although they demanded more time and memory. These comparisons justify the setting chosen for the main runs. They also put the coherence diagnostic in perspective. The selected window was based on the distribution of input counts inside a 128-token sequence, so its rationale depends on the actual packing regime used in the experiments.

Changing the ranking and changing the schedule test different mechanisms

Inside the competence-based curriculum, ASR gives a higher BLiMP score than either length or SR. Because these runs share the form of their competence schedule, the comparison supports changing the difficulty heuristic when using that schedule. It is consistent with the proposed explanation that a rule favoring short sentences can repeatedly sample fragments early in training. The paper does not track the exposure of particular types of fragments in the constructed curricula, so the score comparison supports the explanation indirectly.

In single-source sorting, SR is the rule behind the best result, even though ASR does better within the competence-based runs. A length-sensitive score can have different effects when it determines neighbors instead of the chances of repeated selection. The author suggests that SR can bring together examples of similar lengths and that this might help account for the stronger coherence association under SR. The measurements identify the two rank correlations. The explanation about sentence length remains a hypothesis because the experiment does not independently vary length matching while holding the neighbors’ meaning fixed.

The coherence comparison itself helps locate a cost of sorting that is visible before training. For example, the original simple_wikipedia order has expected local coherence of 0.348, compared with 0.108 after SR sorting and 0.115 after ASR sorting. Its corresponding BLiMP scores in the sorting runs are 74.29% and 74.32%. Those runs illustrate the kind of low-coherence rearrangement that the author sees as a candidate for a more local sort. The suggested alternative is to rearrange at a finer unit, such as an individual story in children_stories, so neighboring examples are more likely to retain a common subject. That alternative is a proposal arising from the analysis.

Cleaning tests an additional use of the ranking

Cleaning is evaluated against an ASR-sorted version of the same source. This matters because sorting alone already changes the training sequence. For gutenberg, the sorted-only score is below the repaired full-corpus reference, whereas the sorted-and-cleaned score exceeds it. A conclusion based only on the final best run would miss how much the interpretation depends on the removal step. The comparison holds the kind of ranking and the target source in common while changing which examples enter training.

Results from the other cleaned datasets temper the explanation. The same inspection strategy yields smaller improvements in bnc_spoken and cbt. The author attributes the more substantial gutenberg improvement to the kind of material identified there, particularly lines containing long strings of numbers. The paper also reports that removing hard-ranked, rare-word-heavy material did not improve performance. Taken together, these observations give the author a reason to use ASR as an inspection aid for specific noise patterns. They give weaker evidence for treating a high concentration of common words as a universal deletion rule.

Limitations

Limits the author identifies

The author highlights a mismatch between the coherence diagnostic and the outcome. SimCSE supplies a measure of semantic relatedness, and BLiMP supplies a measure of grammatical acceptability. Two adjacent sentences can discuss the same topic while illustrating quite different constructions. Conversely, two sentences with similar constructions can concern unrelated subjects. The author says no reliable sentence-pair measure of grammatical similarity was known to them. This leaves open whether arranging by grammatical resemblance would track BLiMP more closely than arranging by meaning.

The author also proposes approaching that mismatch from the evaluation side. A test of semantic understanding would correspond more directly to a diagnostic based on semantic similarity. The resources available for the paper limited both this exploration and the use of the BabyLM evaluations that require fine-tuning. Consequently, the experiments substantiate claims about the chosen grammar score. The submitted run’s perplexity adds a separate indication of predictive fit on the BabyLM test data, with the comparisons among curricula still centered on BLiMP.

The other explicit limitation concerns scale. When the author reorders two or more datasets, the reported experiments produce no BLiMP improvement. A larger rearrangement can create more contexts filled with examples of similar difficulty, while also creating more juxtapositions of text with different topics and grammatical styles. The author offers this as a possible explanation for the failure to scale the intervention across sources. The paper does not report detailed scores for these multi-dataset attempts, so the finding bounds what was demonstrated with the method rather than quantifying where the decline begins.

The conclusion is also explicit about the role of local coherence. Similarity was computed after the difficulty-based order had been chosen. The method did not use a similarity term to decide which sentence would follow another. The planned development, as the author describes it, is a metric or ordering rule that considers sentence difficulty alongside similarity between sentences. The reported correlations motivate that proposal and leave its performance to a further experiment.

Limits visible in the design

A positive association across sorted datasets falls short of isolating the effect of semantic coherence. Each point corresponds to a different source being sorted, and those sources differ in topic, style, lexical distribution, and original coherence. The plotted value is the coherence remaining after the sort, which depends on both the source and the change imposed on it. A higher value might accompany some other favorable property of the source or its arrangement. A comparison that varied coherence while keeping the difficulty distribution and source fixed would address causality more directly. The published comparisons establish the association under the tested choices.

The right and left neighbors in the coherence window also provide an approximation to what the learner can use. GPT-2 predicts from preceding tokens. A following sentence can inform the diagnostic score for a central sentence while being unavailable when GPT-2 predicts tokens in that central sentence. It can still participate in the same training sequence and receive context from what comes before it. The symmetric measure is therefore best read as a description of local grouping. The count of examples contributing to any particular sequence also varies with token length, and a fixed window at the sentence level does not reproduce all of those boundaries.

The sorted runs remove duplicate inputs, which creates a further difference from the base setup. Deduplication can change exposure counts and the material that ends up next to a sentence. As a consequence, a difference against the base run reflects the implemented sorting workflow, which includes duplicate removal. The paper offers no separate duplicate-removal score that would allow the contribution of that step to be read off independently. The before-and-after cleaning comparisons are closer in this respect because the reported cuts come after duplicate removal in the sorted data.

Holding the seed fixed improves the comparability of individual runs while leaving the stability of their ordering across seeds uncertain. The preliminary baseline variation of up to 0.6% gives a reason for caution with closely spaced results, especially the small improvements for bnc_spoken and cbt after cleaning. It comes from a subset of baseline runs and is not an uncertainty interval for any of the reported configurations. The paper identifies which run scored highest with the chosen seed. It does not establish how often that ordering would recur across fresh initializations.

Manual review is also part of the best-performing workflow. The review samples lines from an end of the ranking and makes a decision about a larger block. As a result, the resulting intervention depends on human judgment about meaning and grammar as well as on ASR. The paper compares the sorted corpus with its cleaned counterpart. It leaves open how the result would change if cleaning were done in the original order, if the same number of lines were removed by another criterion, or if a different reviewer selected the cuts. The result for gutenberg supports this particular combination of ranking and review.

Finally, the main results concern GPT-2 on one training track, evaluated primarily with one aggregate grammar score. An average can improve even when particular grammatical phenomena do not, and the paper does not break down which BLiMP tasks account for the gains. The preliminary comparison with other architectures supports the choice of GPT-2 for the study. It supplies no corresponding evidence about whether those architectures would respond in the same way to the cleaning or curriculum.

What came after

There is no documented follow-up to trace here. The paper’s own proposed continuation is to make sentence similarity part of the ordering decision. Its experiments use word frequencies to determine difficulty and assess the resulting neighbors afterwards. A joint ordering rule would give both properties a role before training, so that an easy-to-hard progression could still keep related sentences within reach of one another. The paper also suggests a narrower experiment within a source, such as sorting sentences within a single story, where the available candidates already share some context. Both proposals follow from the observed cost of rearrangement. Their effect on BLiMP or on semantic understanding remains an open empirical question.

Cite

Cite as Nasim Borazjanizadeh. 2023. Optimizing GPT-2 Pretraining on BabyLM Corpus with Difficulty-based Sentence Reordering. Proceedings of the BabyLM Challenge at the 27th Conference on Computational Natural Language Learning.

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.18653/v1/2023.conll-babylm.32

@inproceedings{nasim2023optimizing,
  title = {{Optimizing GPT-2 Pretraining on BabyLM Corpus with Difficulty-based Sentence Reordering}},
  author = {Nasim Borazjanizadeh},
  booktitle = {Proceedings of the BabyLM Challenge at the 27th Conference on Computational Natural Language Learning},
  year = {2023},
  doi = {10.18653/v1/2023.conll-babylm.32},
  url = {https://doi.org/10.18653/v1/2023.conll-babylm.32}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/borazjanizadeh-2023-optimizing-gpt-2-pretraining-babylm/