CRF中的前向和前向后向算法

Forward and forward-backward algorithms in CRF

在关于CRF的论文中(如this or this), authors all mention the forward-backward algorithm, yet implementations in GitHub (or the basic implementation in PyTorch tutorial)似乎只使用前向算法来计算负对数似然来用SGD优化。

如果我想在 BiLSTM 特征上训练 NER,并且我将进行的唯一查询类型就像 "given a sentence, find the named entities",我是否需要前向-后向算法?或者更一般地说,这两种算法有什么区别,什么时候使用哪一种?

BiLSTM 为您提供更多上下文和可能更好的结果。考虑以下示例:

  1. 泰迪熊是熊形的毛绒玩具。
  2. 泰迪·罗斯福是美国第 26 任总统。

第一种情况"teddy"不是NE,第二种情况"Teddy"是NE。 BiLSTM 会更好地注意到这一点,因为它不仅可以查看过去的状态,还可以查看未来的状态(即 "bear" 和 "Roosevelt")。

来自关于 BiLSTM 的维基百科:

"General procedures for training are as follows: For forward pass, forward states and backward states are passed first, then output neurons are passed. For backward pass, output neurons are passed first, then forward states and backward states are passed next. After forward and backward passes are done, the weights are updated"

我认为PyTorch教程中之所以只使用前向算法是因为计算配分函数时只需要前向或后向传递。不过需要前后向算法来计算边际概率。