training and inference algorithms used in the CRF engine