Class Imbalance in Training Data
Data coverage is about whether the training data spans the kinds of inputs and behaviors a model will meet, not only how much data exists.
Why Having Enough Data Is Not Enough
When people judge a training dataset, they often start with a simple question: how much data is there? Size matters, but it is not the whole story. Data coverage is about whether the training data spans the kinds of inputs and behaviors a model will meet, not only how much data exists. A dataset can be large and still leave whole areas of the problem untouched.
This article follows a model through a small thought experiment. You will trace what the model has seen, find where its experience runs out, and then see how new data can be generated to extend that experience. Along the way you will also meet class imbalance, the situation where one label has many examples and another has very few.
What do you think happens?
A team has collected 1,000 customer messages to train a model. Almost all messages are of middle length, a few are very short, and none are very long. What has the model learned about?
Reveal answer
Only middle-length messages, with very short and very long regions left empty
The model can only learn from what it sees. Since the very short and very long regions of the input space are empty in the data, the model has no direct experience with them, and its behavior there is hard to predict.
Tracing the Coverage Gaps in Message Length
Start with the team's 1,000 customer messages. When they sort the messages by length, the pattern is clear: most fall in the middle range, a few are very short, and none are very long. Each time the team asks what the model has learned, the honest answer is that it has learned about middle-length messages. The very short and very long regions are empty.
Notice what this walkthrough reveals. The coverage gap is defined by a characteristic of the inputs, here their length, rather than by the total count. A dataset of a thousand examples can still have a hole in it. Improving coverage therefore means finding the specific characteristics that are missing and adding data that carries them.
Finding the gap in a support-chat classifier
A support-chat classifier is trained mostly on messages of ordinary length. Where are its gaps, and what would it struggle with?
- 1Name the characteristic
The relevant characteristic here is message length, because the training data was collected and sorted by length.
- 2Check the regions
Ask whether very short and very long messages appear in the data. If a region is empty or nearly empty, the model has little direct experience there.
- 3Predict the weakness
The model may do well on typical messages and still struggle when a customer sends a single word or a long, winding complaint.
- 4Locate the problem correctly
The problem is not that the data is wrong. The data simply does not cover the ground the model will need to walk.
The gaps lie at the extremes of message length. The fix is to add data with those characteristics, not simply to add more ordinary messages.
Filling Gaps with Targeted Generation
The question this article asks is practical: when the data you already have does not cover an area well enough, can you create new data that does? The source answers yes. Data synthesis generates data with targeted characteristics, either to improve performance or to get a model to express specific behaviors. The method is to choose the characteristic first and then generate data that carries it.
The source gives two concrete illustrations of this targeting. In the first, you generate very short texts or very long texts, which fills the length gap from the previous section. In the second, you create conversations that contain toxic phrases for a toxic detection model, so that the detector sees the kind of content it must recognize.
Targeting also works in the opposite direction. The source notes that if real-world data is toxic, you can synthesize safe data instead. The goal is then not more examples of a problem but examples of the desired behavior that the real data lacks. Whether you want more of a characteristic or less of it, the underlying move is the same: decide what the data should look like and generate toward that description.
Expressing a Behavior Versus Challenging a Model
Synthetic data can be used for two different purposes that are easy to confuse. In one, the data is built to show a model a behavior you want it to express. In the other, the data is built to challenge the model, and such data is called an adversarial example. The source defines an adversarial example as synthetic data designed to challenge a model's performance, and notes that AI is commonly used to produce them.
| Aspect | Synthetic data expressing a behavior | Adversarial examples |
|---|---|---|
| Purpose | Get a model to express a specific behavior | Test and expose a model's weaknesses |
| Targeted characteristic | The desired behavior or the characteristic to add, such as safe content or a missing length | Difficulty for the model, built to be hard in a way that exposes weaknesses |
| What the data looks like | Examples that carry the wanted behavior | Examples deliberately built to be hard for the model |
| What it tells you about the model | Whether the model can produce or recognize the behavior | How robust the model is under pressure |
| Source example | Safe data synthesized to replace toxic real data, or model-written datasets that test 154 AI behaviors | Factually inconsistent summaries generated with large language models to train detectors of factual inconsistency |
Two purposes for synthetic data, as the source describes them
A concrete case from the source makes the adversarial idea clearer. Gekhman et al. (2022), in their work on TrueTeacher, used large language models to generate factually inconsistent summaries. Those summaries were then used to train models to detect factual inconsistency. The synthetic data is deliberately wrong in a specific way, and that deliberate wrongness is exactly what the detector needs to learn to notice.
The source also describes a broader use. Perez et al. (2022), in Discovering Language Model Behaviors with Model-Written Evaluations, discussed data synthesis techniques for generating datasets that test 154 different AI behaviors. These included personality traits, political views, ethical stances, and social biases. The authors reported that in head-to-head comparisons, language-model-generated datasets approached the quality of human-written ones, and sometimes exceeded them.
Rare Classes and Class Imbalance
Coverage problems are not only about the shape of the inputs. They can also be about how labels are distributed. Class imbalance describes the situation where classes in the data are unequally distributed: one class has many examples and another has very few. A model trained on such data sees the common class constantly and the rare class seldom, so the rare class is the one it is most likely to be underprepared for.
The source states that it is possible to generate data for the rare class to address the challenges of class imbalance. The intended effect is that the rare class gains examples so that the classes are represented more evenly. The source does not prescribe a particular target ratio, so the right amount of generated data depends on the task.
{'common': 900, 'rare': 30}
{'common': 900, 'rare': 150}Mistakes Learners Make with Coverage
Common mistake Assuming that a large dataset has good coverage
What it looks likeA team with 1,000 messages concludes the model is ready because the count looks impressive.
Why it failsCoverage is about whether the data spans the kinds of inputs the model will meet. The thousand messages in the example were all of middle length.
Do this insteadSort or inspect the data by the relevant characteristics and check which regions are empty.
Common mistake Adding more ordinary examples to fix a gap in an extreme region
What it looks likeMore middle-length messages are collected to help the model with very long complaints.
Why it failsAdding more data with the characteristics the model already has does not supply the missing ones.
Do this insteadName the missing characteristic first, then generate or collect data that carries it.
Common mistake Treating adversarial examples as training data for the wanted behavior
What it looks likeA team generates deliberately hard inputs and assumes they demonstrate the behavior the product should show.
Why it failsAn adversarial example is designed to challenge a model and expose weaknesses. Synthetic data that expresses a behavior is designed to show it.
Do this insteadDecide whether the goal is to express a behavior or to test robustness, and generate data for that purpose.
Common mistake Assuming there is a universal target ratio for rare classes
Why it failsThe source does not prescribe a particular ratio, and the right amount depends on the task.
Do this insteadSet the target for the specific task and check whether the rare class is now represented well enough for it.
Checking Your Understanding of Gaps
A support-chat classifier has been trained only on messages of ordinary length. Name the coverage gap, state the characteristic you would target, and describe the kind of synthetic data you would generate to fill it.
Hints
- Look at which message lengths the training data does and does not include.
- The source gives the example of generating very short texts or very long texts.
- Describe the data in terms of its characteristic, not just its count.
Summary of Coverage and Synthetic Data
- 1Data coverage is about whether the training data spans the kinds of inputs and behaviors a model will meet, not only how much data exists.
- 2Gaps are defined by characteristics such as length, so a dataset of a thousand examples can still have a hole in it.
- 3Data synthesis generates data with targeted characteristics, either to improve performance or to get a model to express specific behaviors.
- 4Adversarial examples are synthetic data designed to challenge a model and expose its weaknesses, which is different from data that expresses a wanted behavior.
- 5Generating data for a rare class can address class imbalance, though the source does not prescribe a target ratio.
At a glance
- Data coverage is about whether the training data spans the kinds of inputs and behaviors a model will meet, not only how much data exists.
- Gaps are defined by characteristics such as length, so a dataset of a thousand examples can still have a hole in it.
- Data synthesis generates data with targeted characteristics, either to improve performance or to get a model to express specific behaviors.
- Adversarial examples are synthetic data designed to challenge a model and expose its weaknesses, which is different from data that expresses a wanted behavior.
- Generating data for a rare class can address class imbalance, though the source does not prescribe a target ratio.