Hidden Markov Model for training