Data Pruning and Compute Budgets
Raw scraped data often contains formatting tokens such as HTML and Markdown, and removing them can improve accuracy while cutting input length.
Why Raw Data Needs Cleaning
A model learns whatever patterns are present in the examples it receives. If those examples contain stray markup, content the model should never use, or records that are simply poor, the model absorbs those problems along with everything useful. This is the reason data preparation is a decision-making step, not a formality. Before training begins, the people preparing the data must decide what stays, what goes, and what might be worth keeping in a smaller form.
What do you think happens?
Suppose a scraped training set still contains HTML tags such as paragraph and link markup. What does the model do with those tags?
Reveal answer
It absorbs them as patterns, along with the useful text.
A model learns whatever patterns are present in the examples it receives. Unless the goal is to teach the model to read markup, stray tags are noise that the model can pick up alongside the content it should learn.
This article follows that decision-making from start to finish. It covers three jobs: cleaning data that is not usable as it stands, detecting records that are low in quality even though they are allowed, and filtering a collection that is larger than the project can afford to use. The stages are not independent choices. Each one hands a smaller and cleaner collection to the next.
Stripping Markup from Scraped Text
Many public datasets are assembled by collecting text from across the internet. Web pages are written in markup languages, so text pulled from them often arrives wrapped in HTML tags. These tags can be angle-bracketed page structure, styling hints, or links. Unless the goal is to teach a model to read those tags, they are noise. The first cleaning task is therefore to remove extraneous formatting tokens, including HTML and Markdown markup that ended up inside the text itself.
The source states that removing these formatting tokens can improve accuracy while cutting input length. The diagram below traces what happens to one scraped fragment. The markup tags are the parts that change; the readable text stays.
Cleaning one scraped product review
A scraped record contains the review text wrapped in a paragraph tag, followed by a link tag. Decide what the cleaned record should contain before training.
- 1Identify the formatting tokens
The paragraph tag and the link tag are page structure, not content the model needs to learn from. They are classed as formatting tokens and are removed.
- 2Keep the readable text
The sentence describing the product is the useful content. It stays in the record unchanged.
- 3Check the shorter result
The input is now shorter, because the tags no longer take up characters. This matches the source's point that removing formatting tokens cuts input length.
The cleaned record contains only the review sentence. The tags are gone, so the model sees the content without the page structure around it.
Enforcing Project Policies
Cleaning also means enforcing rules. Data has to be checked against the policies that govern the project, and anything that does not comply has to be removed. The source names several categories that fall under this heading: personally identifiable information (PII), sensitive data, copyrighted material, and content considered toxic. Techniques for handling these categories are covered in an earlier chapter on privacy and safety, so this article focuses on the filtering step itself.
Non-compliant material is not always a whole record. Sometimes it is a set of fields. A dataset may contain columns the project is not permitted to use, such as a zip code, a name, or a gender value. Those fields should be dropped before the model sees the data, even when the rest of the record is perfectly usable. The source's guidance is that removing a field is often better than removing the whole record, because the usable part of the record is preserved.
Finding Low-Quality Records
After compliance cleaning, the data may still contain records that are poor in quality even though they are allowed and properly formatted. The source points to a method for finding them that combines two activities. The first is looking closely at the data by hand. The second is turning what is noticed into rules that can be applied across the whole collection. The two approaches work together: manual inspection reveals patterns, and those patterns become heuristics.
Ordering the Cleaning Stages
The steps described so far form a sequence. Formatting tokens are removed first, compliance rules are enforced and non-compliant fields are dropped, and heuristics and manual findings remove low-quality records. Only then does the collection reach an optional filtering stage. That stage is for projects that have more data than they can use. The diagram shows the order the source implies, with each stage passing a smaller and cleaner collection to the next.
Trimming a Dataset That Is Too Large
Sometimes the problem is not bad data but too much of it. The source notes that if there is more data than you need or can afford to use, for example because of your compute budget, you can filter further. Two techniques are named. Active learning selects the examples that are most helpful for the model to learn from. Importance sampling selects the examples that are most important to the task. Both are ways of keeping a subset chosen on purpose, rather than a random or arbitrary portion.
The diagram shows the general shape of this selection. Every example in the pool is judged, the examples that score as most helpful or most important are kept, and the rest are set aside. The result is a smaller collection that still reflects the choices made about what matters. The method is only as sound as the judgement behind the scores, which is the subject of the next section.
Why Metric Quality Decides Filtering Value
Both active learning and importance sampling depend on a single requirement, which the source states directly: their efficiency depends on whether you have a good way to evaluate the importance of each training example. Choosing examples is only as good as the measure used to judge them. A weak measure keeps the wrong examples, and a strong measure lets a much smaller set carry most of the value.
The reason this matters is that a pruning score works like a cutoff. Records scoring above the line are kept and records below it are removed. If the score is accurate, the good examples land above the line and the poor ones below it. If the score is noisy, some valuable examples fall below the cutoff and are discarded, while some poor examples rise above it and are kept. In both cases the cutoff itself does not change; only the quality of the score decides which records end up on each side.
The source ties the value of this work to cost. Meta researchers, in their study of data pruning (Sorscher and colleagues, 2022), concluded that discovering good data-pruning metrics can significantly reduce the resource costs of modern deep learning. The practical message is that a good metric is an investment, because it determines how much of a large dataset can be dropped without losing the examples that matter.
Common Mistakes in Data Pruning
Common mistake Keeping formatting tokens because they look harmless
What it looks likeA scraped review still contains its paragraph and link tags when it is sent for training.
Why it failsUnless the goal is to teach a model to read markup, the tags are noise, and the model can absorb them as patterns.
Do this insteadRemove HTML and Markdown markup from the text before training, keeping the readable content.
Common mistake Removing a whole record when only one field is non-compliant
What it looks likeA record is deleted entirely because one column holds a zip code the project may not use.
Why it failsThe rest of the record may be perfectly usable, and deleting it discards that value.
Do this insteadDrop the non-compliant field and keep the rest of the record, where the policies allow it.
Common mistake Applying a heuristic without checking its context
What it looks likeA rule flags a record as low quality without considering where it appeared in an annotation session.
Why it failsThe source notes that some heuristics depend on context such as position in an annotation session, so ignoring context can misjudge records.
Do this insteadRecord the relevant context and build the rule so that it takes that context into account.
Common mistake Treating any pruning score as accurate
What it looks likeA noisy score is used to cut a large dataset in half without checking whether it ranks examples well.
Why it failsA weak measure keeps the wrong examples and can discard valuable ones, so the filtered set may perform worse.
Do this insteadCheck that the metric genuinely reflects the importance of each example before relying on it to make cuts.
Common mistake Filtering a dataset that already fits the budget
Ordering a Cleaning Pipeline
A team has a large scraped dataset that is too big for its compute budget. Put these actions in the order the source implies: enforce project policies, filter by quality, remove formatting tokens, select a subset by importance, drop non-compliant fields. Explain why the subset selection comes last.
Hints
- Start with the raw text. Which action changes the text itself before anything else can be judged?
- The source describes filtering further only when there is more data than the project can afford to use.
- Subset selection depends on a good measure of importance, so the data should be clean and compliant before scores are trusted.
Key Takeaways
- Raw scraped data often contains formatting tokens such as HTML and Markdown, and removing them cuts input length and can improve accuracy.
- Data must comply with project policies. Non-compliant fields are often best dropped on their own, keeping the rest of the record.
- Manual inspection reveals patterns that are turned into heuristics, some of which depend on context such as position in an annotation session.
- Active learning and importance sampling select a deliberate subset when data exceeds the compute budget, and both depend on a good measure of each example's importance.
- The quality of a pruning metric decides how much data can be removed safely, which is why a good metric is an investment in cost savings.