Beyond one-hot encoding for LSTM model in Keras
You are looking for top-k categorical accuracy. This is actually implemented in keras, but you might want to change the k, which can be done with partial function. This is the related link.