Skip to content

Repository files navigation

keyphrase-extraction

Sequence Labelling with BiLSTM-CNN-CRF

Instructions

  1. Use pytorch==1.1.0 and Include the above flair folder in your code repo. Do not use flair downloaded using pip
  2. Run test.py to check for NER task using CoNLL 2003 Dataset
To import character embeddings
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")

Architectures

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)
  1. word embeddings -> cnn -> maxpool -> CRF
  2. -
  3. word embeddings -> muti-channel cnns -> maxpool -> CRF
  4. word embeddings -> cnn -> maxpool -> blstm -> CRF

Fei-Lu's model

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)

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

8 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages