I don’t see any obvious wrong with your code. Admittedly, I rarely use packing, but it looks alright. So here just some ideas/questions:


Can you overfit your model on a (very) small sample dataset, i.e., do you get a training accuracy from 100% with say just 10-100 sentences? If not, then something fundamental is not working with your training.


For initial debugging, I would comment out the Dropout layers, just to minimize and cause for issues – although there shouldn’t be. But for trying to overfit the model, they are not needed.


Can you post the training loop? While the model looks alright, much can go wrong in the training part.


You don’t say how big your dataset is, and it’s difficult to judge its “nature”. Anecdotally, I’ve noticed that text classifier take a while to learn before showing improvements in accuracy. But yeah, 30 epochs should probably do to some improvement.


I assume you do proper text preprocessing such lowercasing, removing quotation marks, and ignore rare words (not stopwords!) to minimize the vocabulary.


You probably have noticed, right now you cannot simply set bidirectional=True or n_layers>1 since it messes up with your input for the linear layer at the end. Just a comment for the future.