ELMoEmbeddingsのときはallennlp==0.9.0

NLPフレームワークのFlairでELMoの言語モデルを使おうとすると、from flair.embeddings import ELMoEmbeddingsをして関数を呼び出す必要があるのだが、allennlpがインストールされてい ...
RuntimeError: The size of tensor a (1104) must match the size of tensor b (512) at non-singleton dimension 1

Hugging FaceのTransformersを使って,事前学習済モデルを読み込んで推定させるとタイトルのようなエラーがでることがある.
このエラーはBERTにおけるトークン(サブワード)の最大長512を超えた文が入力 ...
OptunaでFlair NERのパラメーターチューニング

とある仕事で,固有表現抽出器の性能をぎりぎりまで向上させる必要があったため,自作のコーパスに対してFlairでNERを学習し,Optunaでハイパーパラメータチューニングを行なった.本記事ではそのときのコードを示す.
Em ...
Flairのtraining.logからmicro recallとprecisionを算出するコード

FlairでNERを実施した際,training.logというのが出力されるのだが,これにはmicro F1は載っているが,micro recallとprecisionは載っていない.このため,ログファイルからTP, FP, FNを読 ...
FlairでサクッとNERを実行するコード [Python]

from flair.data import Corpusfrom flair.datasets import ColumnCorpusfrom flair.models import SequenceTaggerfrom flair.tr ...
Flair trainer.trainのパラメータ一覧 [Python]

“””
Trains any class that implements the flair.nn.Model interface.
:param base_path: Main p ...
Flairで文をembedding

from flair.data import Sentencefrom flair.embeddings import CharacterEmbeddings# init embeddingembedding = CharacterEmbe ...
FlairでELMoをEmbeddingとして使う

from flair.data import Corpusfrom flair.embeddings import TokenEmbeddings, WordEmbeddings, StackedEmbeddingsfrom flair.d ...
Flairのtag_dictionaryをハードコーディングで入力

datapath = "/path/to/BIO" # train.tsv, test.tsv, devel.tsvが入っているフォルダcorpus: Corpus = loadCorpus(datapath)tag_type = "ner ...
自作ELMoで単語をEmbeddingした後,Numpyに戻す[Flair][NLP]

from flair.embeddings import ELMoEmbeddingsfrom flair.data import Sentence# ELMoのモデルは各自で用意options = '/home/ubuntu/elmo-e ...