External Publication
Visit Post

How can i build a High Quality dataset?

Hugging Face Forums [Unofficial] June 14, 2026
Source

Hmm, probably:


No, I would not say that n-gram models automatically perform better just because the input text is shorter.

A 5-gram model is local in a different sense: it mainly uses the previous 4 tokens/words when estimating the next one. So it can score a long article, but the score is still built from many local n-gram probabilities.

Also, perplexity is normally length-normalized. For example, Jurafsky and Martin’s n-gram chapter describes perplexity as a normalized version of the probability of the test set. So a long text is not automatically invalid just because it is long.

The real issue is not:

long text is bad for n-gram models

The real issue is:

whole-document averaging can hide local garbage

For example, if an article is:

good paragraph
good paragraph
good paragraph
bad reference tail

then the whole-article average perplexity may still look acceptable because the good paragraphs dominate the score.

So I would separate training and filtering :

Step Unit I would use
Train Good KenLM clean paragraphs or clean articles are both okay
Train Bad KenLM bad tails, broken references, noisy chunks
Score/filter candidates paragraph-level or sliding-window level
Detect local garbage sentence/window level
Final CPT packing merge clean paragraphs and add EOS/document separators

So yes: if the long articles are already clean, training KenLM on them is fine.

But for filtering, I would avoid relying only on a single whole-article score. I would score smaller units too:

article score
paragraph scores
sliding-window scores

A practical rule:

Use long clean text for training.
Use local scores for filtering.

This also fits the Good/Bad KenLM idea. The Rethinking KenLM paper uses a Good KenLM trained on high-quality data and a Bad KenLM trained on low-quality data. That does not require all input texts to be short; the important part is that the Good model learns the pattern of text you want, and the Bad model learns the pattern of text you want to remove.

So my short version would be:

Long clean text is fine for training KenLM. Whole-document averaging is the danger. For filtering Persian CPT data, use paragraph-level or sliding-window scoring so local reference garbage does not get hidden by good surrounding text.

Discussion in the ATmosphere

Loading comments...