Pramodith:

What would I need to do in cleaning the data, my vocabulary is pretty small and I have a corresponding unique index for each word. Is there anything else that I need to be doing?


That is definitely a good start. Are your sentences all of good quality and your labels accurate?



 Pramodith:

Also, the surprising thing is that the loss grows from 500 to a really big value in 3 epochs and then starts returning NaN.


That is really not normal. The loss shouldn’t grow in the first epoch, and yet I can’t see any glaring errors in the code you have shown.
Maybe there are too few units in your model.
Maybe the learning rate is far too high.
I’m at a loss to know what else to suggest.