Mitigating The Effect of Class Imbalance in Data with Hierarchical and Dependable Structure
This paper proposes a Hierarchy-Aware RoBERTa framework that leverages learnable parent-class embeddings to effectively mitigate class imbalance in CWE vulnerability classification, demonstrating that incorporating hierarchical structure outperforms traditional oversampling techniques which often degrade model performance.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you are a detective trying to sort a massive pile of clues about computer security flaws. These flaws are organized in a giant family tree called the Common Weakness Enumeration (CWE). At the top of the tree are broad categories like "Base" (the big picture), and as you go down, the branches get more specific, ending in tiny, rare leaves like "Compound" or "Pillar."
The problem? The detective's evidence bag is totally unbalanced. There are hundreds of clues for the big, common categories, but only a handful for the rare, specific ones. It's like having a library with 500 books about "Fruit" but only 5 books about "Dragonfruit." If you try to teach a computer to sort these, it gets lazy and just guesses "Fruit" every time, because that's what it sees most often.
The "Fake Clue" Experiment (What Didn't Work)
To fix this, many experts tried a trick called oversampling. They took the few rare clues and tried to invent new, fake ones to make the numbers look equal. They used two popular methods: SMOTE and ADASYN.
Think of this like a chef trying to make a soup taste like it has more rare spices. Instead of finding more real spices, they take two existing spice grains, blend them together, and hope the new mixture tastes authentic.
The paper tested this on different types of "detectives" (computer models):
- The Old-School Detectives (Random Forest and SVM): These models are like detectives who look at simple lists of facts. When fed the fake blended spices, they got a tiny boost. Their accuracy went from 0.65 to 0.69 for the Random Forest, and the Support Vector Machine (SVM) stayed steady around 0.71–0.72. It helped a little, but not much.
- The High-Tech Detectives (CNN and BiGRU): These are smarter, deep-learning models that understand how words flow together. When the researchers fed them the fake blended spices, the results were a disaster. The CNN's accuracy crashed from 0.71 down to 0.55 with SMOTE and 0.51 with ADASYN. The BiGRU fell from 0.70 to 0.53 and 0.44.
Why? The paper argues that these high-tech models are like chefs who can taste the difference between real spice and a fake blend. When you mix two different computer "words" together to make a fake one, you break the rules of the family tree. You might create a "Variant" that claims to be a child of a "Base," but the fake blend doesn't actually respect that parent-child relationship. It's like trying to make a "Dragonfruit" by blending an "Apple" and a "Banana." The result isn't a Dragonfruit; it's a confusing mess that confuses the detective.
The "Family Tree" Solution (What Actually Worked)
Instead of making fake clues, the authors built a new detective called Hierarchy-Aware RoBERTa.
Imagine this detective has a special map of the family tree in their pocket. They don't just read the clue; they also check the map to see, "Wait, if this clue is about a 'Base' weakness, the answer must be related to that parent."
The model works like this:
- It reads the text description of the flaw (using a powerful tool called SecureBERT).
- It grabs a "Parent ID" from the family tree (like knowing the clue belongs to the "Base" branch).
- It combines the text reading with the map location to make a final guess.
The Results:
This new detective didn't need any fake clues at all. It achieved a weighted F1-score of 0.76 without any data augmentation.
- Compare this to the standard BERT model, which scored 0.74.
- Most importantly, look at the rare "Class" category. The standard BERT model only got an F1-score of 0.49 for this rare group. The new Hierarchy-Aware model boosted that to 0.60.
The Bottom Line
The paper suggests that when you have a structured family tree of data, trying to "fake" more data by blending existing pieces (oversampling) is a bad idea. It works okay for simple models but breaks the more advanced ones.
Instead, the best approach is to teach the model to respect the family tree structure from the start. By giving the model a "map" of the parent-child relationships, it can figure out the rare, tricky cases much better than by just stuffing the training data with synthetic noise.
However, the authors are careful to note that even their best detective still struggles with the rarest categories, like "Compound" and "Pillar," which had only 8 and 5 samples respectively. For these extremely rare groups, the F1-score remained 0.00 across all models, suggesting that when there is almost no data at all, even a family tree map isn't enough to solve the mystery.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.