allennlp.modules.conditional_random_field

Conditional random field

class allennlp.modules.conditional_random_field.ConditionalRandomField(num_tags: int) → None[source]

Bases: torch.nn.modules.module.Module

This module uses the “forward-backward” algorithm to compute the log-likelihood of its inputs assuming a conditional random field model.

See, e.g. http://www.cs.columbia.edu/~mcollins/fb.pdf

Parameters:

num_tags : int, required

The number of tags.

forward(inputs: torch.FloatTensor, tags: torch.FloatTensor, mask: torch.ByteTensor = None) → torch.FloatTensor[source]

Computes the log likelihood.

viterbi_tags(logits: torch.autograd.variable.Variable, mask: torch.autograd.variable.Variable) → typing.List[typing.List[int]][source]

Uses viterbi algorithm to find most likely tags for the given inputs.