The gradient of Equation (1) can be written as follows: Calculating E p(Y|x,λ) as well as the partition function Z(x) is not always tractable.
for linear-chain CRFs, a dynamic programming algorithm similar in nature to the forward-backward algorithm in HMMs has already been developed for an efficient calculation (Lafferty et al., 2001).