How to improve language model ex: BERT on unseen text in training? so I am using pre-trained language model for binary classification. I fine-tune the model by training on data my downstream task. The results are good almost 98% F-measure.
However, when I remove a specific similar sentence from the training data and add it to my test data, the classifier fails to predict the class of that sentence. For example, sentiment analysis task

"I love the movie more specifically the acting was great"

I removed from training all sentences containing the words " more specifically" and surprisingly in the test set they were all misclassified, so the precision decreased by a huge amount.
Any ideas on how can I further fine-tune/improve my model to work better on unseen text in training to avoid the problem I described above? (of course without feeding the model on sentences containing the words "more specifically")
Note: I observed the same performance regardless of the language model in use (BERT, RoBERTa etc).
 A: I'm not clear on the problem.
You say "The results are good almost 98% F-measure." Is that on a test set, independent of the training data? If so then I am confused by "when I remove a specific similar sentence from the training data and add it to my test data, the classifier fails to predict the class of that sentence".
If you mean that the achieves 98% F-measure on its training data, but not on test data that it has not been trained on, then that is a clear case of overfitting.
The fix for overfitting is more data - or if you can't get more data,  abit of noise or another form of regularization.
A: Interesting. There are reasons why this sentence is hard to process, so some training examples may be needed.
Grammatically, it is two sentences not one - both "loved" and "was" are root words, not dependent on any other. There is no punctuation to indicate this. If your model was pretrained on well formed sentences, then it is not surprising that it is struggling.
Secondly, the use of the word "specifically" is an unusual one. It indicates that the following sentence is more specific than the preceding one, but neither are stated as a complement. i.e. it has a similar meaning to, but is stated differently to, "I love the movie, and to be specific I love the acting."
This use of specific is similar to the German use of "Hoffentlich" / the US English "Hopefully", where the listener is suppose to understand that the hopeful person is the (unnamed) speaker. This is not standard usage in British English.
One approach would be to train with similar sentence using adverbs other than "specifically", e.g.

*

*I love this movie more generally I love everything with Tom Cruise in it.

*I did not like this move more precisely I hated the ending

*I hate that book more emphatically I loathe it

A: So now you have one model that works OK on sentences that contain "more specifically", and one that works on other sentences.
Then the right predictor would seem to be:
model1(sentence) if 'more specifically' in sentence else model2(sentence)

If your goal is simply to make good predictions, then that would seem to ge good enough. Maybe the condition can be generalised a little to regexp 'more \w+ly ', or maybe not. I suspect that the non-grammatical nature of the sentence may be part of the issue.
Alternatively, if you want to know you have made a single neural net model, you could take the second model, then retrain it with the movies test set and a low learning rate. That might improve it, without making it forget its success on these sentence. Or not!
