Instructions
- Use pytorch==1.1.0 and Include the above flair folder in your code repo. Do not use flair downloaded using pip
- Run test.py to check for NER task using CoNLL 2003 Dataset
from flair.embeddings import CharacterCNNEmbeddings
embeddings = CharacterCNNEmbeddings()To import SpanBERT embeddings. First download SpanBERT(large & cased) from the Spanbert Github repo. Let "/path/to/spanbert_hf" be the path to unzipped spanbert_hf folder.
from flair.embeddings import SpanBertEmbeddings
embeddings = SpanBertEmbeddings("/path/to/spanbert_hf")The following architectures have been tried out for the experiments.
from flair.models.sequence_tagger_CNN import SequenceTagger_CNN
# word embeddings -> cnn -> maxpool -> CRF
tagger: SequenceTagger_CNN = SequenceTagger_CNN(hidden_size=200,
embeddings=embeddings,
tag_dictionary=tag_dictionary,
tag_type=tag_type,
use_crf=True)
# word embeddings -> muti-channel cnns -> maxpool -> CRF
tagger: SequenceTagger_CNN = SequenceTagger_CNN(hidden_size=200,
embeddings=embeddings,
tag_dictionary=tag_dictionary,
tag_type=tag_type,
use_crf=True,
use_multichannels=True)
# word embeddings -> cnn -> maxpool -> LSTM -> CRF
from flair.models.sequence_tagger_combo import SequenceTagger
#from flair.models import SequenceTagger
tagger: SequenceTagger = SequenceTagger(hidden_size=200,
embeddings=embeddings,
tag_dictionary=tag_dictionary,
tag_type=tag_type,
use_crf=True)- word embeddings -> cnn -> maxpool -> CRF -
- word embeddings -> muti-channel cnns -> maxpool -> CRF
- word embeddings -> cnn -> maxpool -> blstm -> CRF
Check out this paper . To import fei_lu's model write
from flair.models.sequence_tagger_fielu import SequenceTagger
#from flair.models import SequenceTagger
tagger: SequenceTagger = SequenceTagger(hidden_size=200,
embeddings=embeddings,
tag_dictionary=tag_dictionary,
tag_type=tag_type,
use_crf=True)