đ English Universal Part-of-Speech Tagging in Flair (fast model)
This project offers a fast universal part - of - speech tagging model for English, which is integrated with Flair. It effectively addresses the need for accurate part - of - speech tagging in English text, providing high - quality tagging results.
⨠Features
- High Accuracy: Achieves an F1 - Score of 98,47 on the Ontonotes dataset.
- Comprehensive Tagging: Predicts a wide range of universal POS tags, including adjectives, adpositions, adverbs, and more.
- Based on Advanced Techniques: Built upon Flair embeddings and LSTM - CRF.
Property |
Details |
Model Type |
Fast universal part - of - speech tagging model for English |
Training Data |
Ontonotes |
tag |
meaning |
ADJ |
adjective |
ADP |
adposition |
ADV |
adverb |
AUX |
auxiliary |
CCONJ |
coordinating conjunction |
DET |
determiner |
INTJ |
interjection |
NOUN |
noun |
NUM |
numeral |
PART |
particle |
PRON |
pronoun |
PROPN |
proper noun |
PUNCT |
punctuation |
SCONJ |
subordinating conjunction |
SYM |
symbol |
VERB |
verb |
X |
other |
đĻ Installation
Requires: Flair (pip install flair
)
đģ Usage Examples
Basic Usage
from flair.data import Sentence
from flair.models import SequenceTagger
tagger = SequenceTagger.load("flair/upos-english-fast")
sentence = Sentence("I love Berlin.")
tagger.predict(sentence)
print(sentence)
print('The following NER tags are found:')
for entity in sentence.get_spans('pos'):
print(entity)
This yields the following output:
Span [1]: "I" [â Labels: PRON (0.9996)]
Span [2]: "love" [â Labels: VERB (1.0)]
Span [3]: "Berlin" [â Labels: PROPN (0.9986)]
Span [4]: "." [â Labels: PUNCT (1.0)]
So, the word "I" is labeled as a pronoun (PRON), "love" is labeled as a verb (VERB) and "Berlin" is labeled as a proper noun (PROPN) in the sentence "I love Berlin".
đ Documentation
Training: Script to train this model
The following Flair script was used to train this model:
from flair.data import Corpus
from flair.datasets import ColumnCorpus
from flair.embeddings import WordEmbeddings, StackedEmbeddings, FlairEmbeddings
corpus: Corpus = ColumnCorpus(
"resources/tasks/onto-ner",
column_format={0: "text", 1: "pos", 2: "upos", 3: "ner"},
tag_to_bioes="ner",
)
tag_type = 'upos'
tag_dictionary = corpus.make_tag_dictionary(tag_type=tag_type)
embedding_types = [
FlairEmbeddings('news-forward-fast'),
FlairEmbeddings('news-backward-fast'),
]
embeddings = StackedEmbeddings(embeddings=embedding_types)
from flair.models import SequenceTagger
tagger = SequenceTagger(hidden_size=256,
embeddings=embeddings,
tag_dictionary=tag_dictionary,
tag_type=tag_type)
from flair.trainers import ModelTrainer
trainer = ModelTrainer(tagger, corpus)
trainer.train('resources/taggers/upos-english-fast',
train_with_dev=True,
max_epochs=150)
đ License
Please cite the following paper when using this model.
@inproceedings{akbik2018coling,
title={Contextual String Embeddings for Sequence Labeling},
author={Akbik, Alan and Blythe, Duncan and Vollgraf, Roland},
booktitle = {{COLING} 2018, 27th International Conference on Computational Linguistics},
pages = {1638--1649},
year = {2018}
}
đĄ Usage Tip
The Flair issue tracker is available here.