speechbrain.lobes.models.flair.sequencetagger moduleο
Models and tooling for sequence tagging using Flair
Authors * Sylvain de Langen 2024
Summaryο
Classes:
Sequence tagger using the flair toolkit, e.g. for part-of-speech (POS) extraction. |
Referenceο
- class speechbrain.lobes.models.flair.sequencetagger.FlairSequenceTagger(model: flair.models.SequenceTagger)[source]ο
Bases:
object
Sequence tagger using the flair toolkit, e.g. for part-of-speech (POS) extraction.
- Parameters:
model (SequenceTagger) β The Flair sequence tagger model. If you do not have one initialized, use
from_hf()
instead.
- static from_hf(source, save_path='./model_checkpoints', filename='pytorch_model.bin') FlairSequenceTagger [source]ο
Fetches and load a flair PyTorch model according to the
speechbrain.utils.fetching.fetch()
semantics. The model will be saved into a unique subdirectory insave_path
.- Parameters:
source (str) β The location of the model (a directory or HF repo, for instance).
save_path (str, optional) β The saving location for the model (i.e. the root for the download or symlink location).
filename (str, optional) β The filename of the model. The default is the usual filename for this kind of model.
- Return type:
- __call__(inputs: List[str] | List[List[str]]) List[List[str]] [source]ο
Tag a batch of sentences.
- Parameters:
inputs (list of sentences (str or list of tokens)) β Sentences to tag, in the form of batches of lists of tokens (list of str) or a str. In the case of token lists, tokens do not need to be already tokenized for this specific sequence tagger.
- Returns:
For each sentence, the sequence of extracted tags as `str`s.
- Return type: