Abstract
Deep learning models in Natural Language Processing (NLP) frequently exploit spurious correlations—superficial shortcuts in training data—rather than learning the underlying causal logic of language. This leads to significant performance degradation on out-of-distribution (OOD) data. We introduce SALAD (Structure-Aware and LLM-driven Augmented Data), a novel framework designed to mitigate this issue. SALAD generates structure-aware positive samples by identifying and masking non-causal tokens and produces counterfactual negative samples using Large Language Models (LLMs) guided by causal word identification. By training models via contrastive learning with triplet loss, SALAD forces the latent space to prioritize causal structures. Our evaluation across sentiment analysis, sexism detection, and natural language inference shows that SALAD significantly improves robustness and generalization, often surpassing human-annotated counterfactual data.
Introduction
Modern NLP models are often "lazy learners," latching onto statistical shortcuts rather than semantic understanding. For instance, a sentiment classifier might associate a specific director's name with a positive label simply because they appear frequently in positive reviews in the training set. While effective for in-distribution testing, these models fail when encountering OOD scenarios where such correlations do not hold.
Counterfactual Data Augmentation (CAD) aims to address this by creating "flipped" examples (e.g., changing a positive review to a negative one with minimal edits). However, manual CAD is prohibitively expensive, and previous automated methods often lacked the precision to maintain semantic coherence or target the correct causal features. SALAD addresses these challenges by combining structural linguistic analysis with the generative power of LLMs.
Methodology
The SALAD framework consists of a three-stage pipeline designed to refine the model's representation space through contrastive learning.
1. Structure-Aware Positive Data Generation
To help the model recognize the "skeleton" of a sentence, SALAD identifies non-causal words—tokens that do not fundamentally alter the label (e.g., pronouns, conjunctions). This is achieved by measuring the accuracy reduction when specific Part-of-Speech (POS) tags are removed. Words belonging to tags with minimal impact are replaced with an [UNK] token. This process creates a "positive" sample that retains the core causal meaning while removing potential shortcut features.
2. LLM-Driven Counterfactual Negative Data Generation
Negative samples are generated using an LLM (e.g., GPT-4o-mini). To ensure the LLM modifies the correct parts of the sentence, it is provided with the "causal words" identified in the previous step. The prompt instructs the LLM to perform minimal edits to flip the sentiment or label while preserving as much of the original text as possible. This ensures the counterfactual is a high-quality, near-neighbor in the input space with a different label.
3. Contrastive Learning with Triplet Loss
The model is trained using a triplet loss function ($L_{CL}$) alongside a standard cross-entropy loss ($L_{CE}$). The contrastive objective "pulls" the original sentence ($x$) and its structure-aware positive version ($x^+$) closer in the latent space while "pushing" the counterfactual negative sample ($x^-$) away. This dual objective encourages the model to ignore non-essential tokens and focus on the causal structure.
Experimental Results
SALAD was evaluated on three tasks: Sentiment Classification (IMDb), Sexism Detection, and Natural Language Inference (SNLI).
Robustness and Generalization
In sentiment analysis, SALAD achieved an overall accuracy of 93.05%, significantly outperforming the RoBERTa-large baseline (88.16%) and existing augmentation methods like EDA (91.49%) and SSMBA (91.08%). Notably, SALAD demonstrated superior performance on OOD datasets; for example, on SST2, it reached 92.68% accuracy compared to the baseline's 79.41%.
Comparison with Human Augmentation
Remarkably, SALAD's automated pipeline performed comparably to, and in some cases better than, human-augmented data (Human-CAD). In the sentiment analysis task, SALAD's 93.05% overall accuracy exceeded Human-CAD's 90.73%, suggesting that structured LLM-driven augmentation can effectively replace expensive manual labeling for robustness tasks.
Cross-Domain Performance
Cross-domain experiments (training on one domain and testing on another) further validated the framework. SALAD reached an average accuracy of 91.61%, indicating that the learned representations are truly generalizable and not overfit to specific dataset artifacts.
Conclusion
SALAD provides a scalable and effective framework for improving NLP model robustness. By leveraging structural information to guide LLM-based counterfactual generation and employing contrastive learning, it successfully steers models away from spurious correlations. Future work will explore the impact of LLM biases on augmented data and the application of SALAD to more complex reasoning tasks.
Summary updated