Quantifying and Alleviating Distribution Shifts in Foundation Models on Review Classiﬁcation
Abstract
This work quantiﬁes the extent to which accuracy degrades on review classiﬁcation when state-of-the-art Transformer models are subjected to distribution shifts, and offers a solution to signiﬁcantly decrease this degradation.
We ﬁnd differences in the extent of degradation depending on the independent variable across which the shift is created.
Speciﬁcally, in our experiments time and sentiment shifts show upto 10% drops in accuracy; whereas shifts between industry and product sectors show 20-40% drops in accuracy.
We provide ablation experiments with different Transformer architectures, such as BERT, T5 and Jurassic-I, and study their relationship with this degradation.
The suggested solution reuses the base of the model trained on one distribution, in addition to ﬁne-tuning the ﬁnal dense layer in the model to support the new distribution that is seen once the model is deployed.
This uses just 100-300 samples compared to the previous 10,000 samples from the unseen distribution, while decreasing the accuracy drops in half.
Introduction
We report the impact of distribution shifts on the accuracy of review classiﬁcation when using
Transformer models.
More speciﬁcally, we look at the task of classifying customer reviews as fake or real based only on the review text, while reporting the extent of the drop in accuracy when the model tries to predict labels for distributions other than the one it was trained on.
Investigating the performance deltas due to distribution shifts for this task is signiﬁcant not only because of the dearth of labelled data sets but also to gain insight into the information encoded by the Transformer embeddings and what steps may be taken to make their decisions more robust to possible shifts.
Our results show that the extent of the degradation in accuracy depends primarily on the independent variable across which the shift is created.
We use the available metadata to narrow down four independent variables that give us balanced training and testing data set splits while differing along the chosen variable.
For each of these, we train and test across all four permutations of splits.
The distribution shifts investigated are: (1) Industry Type - hotel and restaurant reviews, (2) Time - old (pre-2014) and new (post-2014) reviews, (3) Product Type - Japanese and Italian restaurant reviews, and (4) Sentiment - positive and negative reviews.
Since one of our goals is to gain insights into Transformer model selection for tasks that require robustness across distribution shifts, we use three popular constructs for Transformers: encoder only BERT [1] (Bidirectional Encoder Representations from Transformers) models, an encoder and decoder T5 [2] model, and the Jurassic-I [3] model with n-shot training.
Subsequently, to address this problem of accuracy degradation due to distribution shifts, we suggest and report results from our solution of conventional ﬁne-tuning - ﬁrst training on the known distribution, then freezing weights for all but the ﬁnal layer in the model, and tuning weights for this ﬁnal layer with a much smaller subset of the new distribution (100-300 review text samples compared to the previous 10,000 samples) to allow the model a chance at using the generalizable patterns it saw in the ﬁrst distribution, while also enabling it to create distribution-speciﬁc insights for the new distribution.
Previous Work.
Detecting fake reviews is a well known task, the economic implications of which have been analysed thoroughly in previous work [4], but with the growth of the industry for hiring and selling fake reviews, detecting fake reviews at scale has become a trade of its own and one particularly suited for the use of natural language processing [5].
We build on the same motivation by combining this NLP task of review classiﬁcation with methodology partly based on existing work outside of NLP [6] that sets up structure for analysing implications of distribution shifts, and creating insights for model selection, and red ﬂags in model training.
Moreover, the architecture for our BERT instances are inspired by previous work [7] that created BERT models for review data sets.
Our ﬁnal (modiﬁed) model speciﬁcations are in the Implementation Details section, where we build on previous work by using a richer data set, trying three sizes of BERT, a T5 model, and then, most importantly, investigating and interpreting the performance of these models on distribution shifts.
We also take inspiration from two notable works [8, 9], to suggest and report results from a solution of ﬁne-tuning the model based on a small subset of the distribution-shifted data.
Methods
For our study, we used the following methodology (illustrated in the Fig. 1) that was partly based on previous work [6] on distribution shifts: (1) We began by standardising the review text to make them compliant with the pre-trained Transformer models’ expected input, making sure all steps here were applicable to any other source’s review texts.
(2) We then ﬁnetuned our pre-trained Transformer models, evaluating the performance of the models on an out-of-sample test set in the same distribution, to ascertain how well the model does when it sees reviews similar to the ones it was trained on.
This gives us baseline benchmarks (upper-bounds) to assess our distribution shift metrics.
We made sure to achieve state of the art performance in this problem space by employing Transformer models that were previously shown to be most successful with the task.
For each of the aforementioned distribution shifts, we train and test within the same distribution (e.g. train and test both on prereviews), as well as train and test across the distribution shifts (e.g. train on pre-2014 reviews and test on post-2014 reviews).
We do so for all the different permutations for these shifts - employing BERT (3 size instances), T5, and Jurassic-I (with n-shot learning).
(4) Lastly, we use the created models that were trained on one distribution, freeze the weights for all but the last layer, and ﬁne-tune this layer based on a small subset of 100-300 review text samples from the new distribution.
It is important to note here that ﬁne-tuning is sensitive to the train set size, and our experiments only explore results while the split percentage is held constant.
We do this for each split that was explored in the previous step, this time employing only the BERT and T5 instances in order to report this method as a solution to the degradation.
We use two labelled datasets: the ﬁrst is for restaurant reviews from Yelp [10], and the second is for hotel reviews [11] which combines internet sources like Expedia, Hotels.com, Orbitz, Priceline, and TripAdvisor.
Both datasets have the review text, fake/real labels, as well as some metadata.
The metadata was used to ﬁnd the independent variables along which we could split the data to create distribution shifts.
Since our goal is to look at the generalizability of the models we create, and its translations to a different distribution (e.g. from a variety of sources), we decided to limit our input features to standardised review text only.
We chose these datasets to work in conjunction, because they are both collections of consumer reviews, but are different in that the customers are restaurant clients in one and hotel clients in the other.
We, therefore, found these datasets to be common enough
[Table] [Table]
to cross validate transfer learning, and at the same time, different enough to create an interesting distribution shift.
Implementation Details
The BERT instances we use are: (1) LARGE BERT (uncased-base) (L-12_H-768_A-12) (2) SMALL BERT (uncased-base) (L-4_H-256_A-4), and (3) mobile BERT (uncased-base) (L-24_H-128_B-512_A-4_F-4_OPT).
Each has an additional dense, dropout, and pooling layer added on top.
We also experiment with a ﬁne-tuned t5-small model, which is pre-trained on six attention modules.
Finally, for Jurassic-1, we investigated the effects of distribution shifts in n-shot learning, and as such did not need to add any modiﬁcations or ﬁnetune the model.
Results
BERT and T5.
From Table 1, we see the Transformer models do not translate well when exploring a distribution shift across industries and products speciﬁcally.
While the models baselines are relatively high for the in-distribution testing (indicating that the datasets have no inherent problems in them), the models see a severe degradation in accuracy when trained and tested across these two distributions.
The degradation is possibly a result of industry or product speciﬁc vocabulary used while reviewing.
On the other hand, the results for time and sentiment shifts are promising in that the accuracy has relatively small drops when going from within the same distribution to a new distribution.
This means that patterns in fake reviews are relatively constant across time and perhaps more surprisingly sentiment.
After the distribution shift, large BERT has the best accuracy, and T has the smallest drop in accuracy.
We believe the results are a reﬂection of the fact that vocabulary and other text distribution characteristics are not affected by time as much as they are by topic.
In terms of sentiment, an interesting thing to note is that a higher accuracy is observed when training on negative reviews compared to positive reviews - which is possibly explained by the fact that negative reviews are on average 50% longer than than positive reviews.
From Table 2, we see very promising results since degradation in product and industry shifted data is much improved when we use our solution of ﬁne-tuning the ﬁnal layer in the model with 100review text samples, consistently reducing the drop in accuracy by approximately half.
This suggests that the models are able to pick up generalisable features across the shift, but need to see more examples from the new distribution to get closer to the upper bound accuracies.
We see similar results for ﬁne-tuning in sentiment-shifts too, where there are clear boosts in accuracy, but these still trail the baselines by 5-10%.
For time-shifted data, however, the ﬁne-tuning does not help the accuracies, perhaps because the drops were negligible to begin with.
Jurassic-I Few Shot Distribution Shifts.
From Table 3, we see very similar results for Jurassic-I (compared to what we saw for BERT and T5).
Overall, the shifts in industry and product are the most problematic for Jurassic-I to handle.
The key differences are seen in the fact that Jurassic-I handles sentiment shifts more consistently than BERT or T5, but does worse on time-shifts.
The
[Table]
other insight of note is that increasing the number of shots in the few shot learning deﬁnitely helps improve the baseline accuracies (when the model is trained and tested on the same distribution), but makes the distribution-shifted accuracies worse - intuitively this is because the model is getting even more used to the speciﬁcs of the train data as the number of shots is increasing - making it harder for it to generalise to the shifted data.
Conclusion
We report the extent of the degradation of review classiﬁcation accuracy for state-of-the-art Transformer models that are subjected to distribution shifts.
Promising results are seen for the time and sentiment shifts, with all the models generalising to the shifted test sets reasonably well.
On the other hand, industry and product shifted accuracies suffered greatly compared to the observed baseline metrics.
For these two shifts in particular, the conventional solution of using a small subset of samples from the new distribution helps improve the accuracy considerably and consistently, indicating that this is a viable solution to allow models to continue to use generalisable patterns found in the training phase, and creating distribution-speciﬁc patterns in the ﬁne-tuning phase.
This study helps us quantify on the implications of distribution shifts in NLP classiﬁcation tasks by highlighting the limitations of the Transformer models and their sensitivity to the characteristics of the training set, while creating insights for model selection and the requirement for adaptive training depending on the foreseeable distribution shift that a Transformer model is expected to encounter once deployed.