All Products
Search
Document Center

Platform For AI:LLM-N-Gram Repetition Filter (DLC)

Last Updated:Apr 01, 2026

LLM pretraining corpora often contain texts with excessive repeated character sequences or word phrases — a signal of low-quality or garbled content. The LLM-N-Gram Repetition Filter (DLC) component detects and removes such texts by calculating their N-gram repetition ratio. Add it to a Machine Learning Designer pipeline to clean your LLM pretraining data before model training.

Input data must be in JSON Lines format: each line is a valid JSON object, but the file as a whole is not.

Supported computing resources

Deep Learning Containers (DLC)

How it works

The component moves an N-character window across a text to generate sequences of N characters or words. Each sequence is called an N-gram. It then calculates the repetition ratio using this formula:

Repetition ratio = Cumulative frequency of N-grams that appear more than once
                   ÷ Total frequency of all N-grams

Texts whose repetition ratio falls outside the configured min–max range are filtered out.

For word-level N-grams, all words are converted to lowercase before the ratio is calculated.

Configure the component

On the Pipeline page of Machine Learning Designer, configure the LLM-N-Gram Repetition Filter (DLC) component.

Filter types

The component supports two independent filter types. Enable one or both depending on your data quality requirements.

Filter typeDetectsKey parameters
Character-level N-gramRepeated character sequences (e.g., repeated substrings, garbled text)Length N, Minimum Ratio Value, Maximum Ratio Value
Word-level N-gramRepeated word sequences (e.g., duplicated phrases, boilerplate text)Length N, Minimum Ratio, Maximum Ratio

Fields Setting tab

ParameterRequiredDescriptionDefault
Target Process FieldYesThe JSON field name containing the text to filter
Whether to Filter with Character-level N-Gram Repetition RatioNoEnable character-level N-gram filtering. When enabled, configure Length N, Minimum Ratio Value, and Maximum Ratio Value.Unselected
Whether to Filter with Word-level N-Gram Repetition RatioNoEnable word-level N-gram filtering. When enabled, configure Length N, Minimum Ratio, and Maximum Ratio.Unselected
OSS Directory for Saving Output DataNoThe Object Storage Service (OSS) bucket path for storing output data. If left blank, the default workspace path is used.

Character-level N-gram sub-parameters (visible when the character-level filter is enabled):

ParameterValid valuesDescription
Length NPositive integerThe length of each N-gram sequence
Minimum Ratio Value0.0–1.0Texts with a repetition ratio below this threshold are filtered out
Maximum Ratio Value0.0–1.0Texts with a repetition ratio above this threshold are filtered out

Word-level N-gram sub-parameters (visible when the word-level filter is enabled):

ParameterValid valuesDescription
Length NPositive integerThe length of each N-gram sequence
Minimum Ratio0.0–1.0Texts with a repetition ratio below this threshold are filtered out
Maximum Ratio0.0–1.0Texts with a repetition ratio above this threshold are filtered out

Tuning tab

ParameterRequiredDescriptionDefault
Number of ProcessesNoNumber of parallel processes for data processing8

Select Resource Group tab

Resource group typeRequiredDescription
Public Resource GroupNoSpecify the instance type (CPU or GPU), number of instances, and virtual private cloud (VPC)
Dedicated resource groupNoSpecify the number of vCPUs, memory, shared memory, GPUs, and instances
Maximum Running DurationNoIf the job exceeds this duration, it is terminated