For a given x, define the transition matrix for position i as , and let * denote component-wise matrix product.
then where α i and β i the forward and backward state-cost vectors defined by we can use a forward pass to compute the α i and a backward bass to compute the β i and accumulate the feature expectations.