From a3133fe99b3fed97c914d23e2250bb45b46e7ed7 Mon Sep 17 00:00:00 2001 From: Alan Akbik Date: Sun, 29 Aug 2021 22:57:28 +0200 Subject: [PATCH 1/3] Update TRANSFORMER_EMBEDDINGS.md --- resources/docs/embeddings/TRANSFORMER_EMBEDDINGS.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/docs/embeddings/TRANSFORMER_EMBEDDINGS.md b/resources/docs/embeddings/TRANSFORMER_EMBEDDINGS.md index 8b3b43943..f7b01a496 100644 --- a/resources/docs/embeddings/TRANSFORMER_EMBEDDINGS.md +++ b/resources/docs/embeddings/TRANSFORMER_EMBEDDINGS.md @@ -64,21 +64,21 @@ from flair.embeddings import TransformerWordEmbeddings sentence = Sentence('The grass is green.') # use only last layers -embeddings = TransformerWordEmbeddings('bert-base-uncased', layers='-1') +embeddings = TransformerWordEmbeddings('bert-base-uncased', layers='-1', layer_mean=False) embeddings.embed(sentence) print(sentence[0].embedding.size()) sentence.clear_embeddings() # use last two layers -embeddings = TransformerWordEmbeddings('bert-base-uncased', layers='-1,-2') +embeddings = TransformerWordEmbeddings('bert-base-uncased', layers='-1,-2', layer_mean=False) embeddings.embed(sentence) print(sentence[0].embedding.size()) sentence.clear_embeddings() # use ALL layers -embeddings = TransformerWordEmbeddings('bert-base-uncased', layers='all') +embeddings = TransformerWordEmbeddings('bert-base-uncased', layers='all', layer_mean=False) embeddings.embed(sentence) print(sentence[0].embedding.size()) ``` @@ -90,7 +90,7 @@ torch.Size([1536]) torch.Size([9984]) ``` -I.e. the size of the embedding increases the mode layers we use. +I.e. the size of the embedding increases the mode layers we use (but ONLY if layer_mean is set to False, otherwise the length is always the same). ### Pooling operation From 63e67d6ffdb0acbb822c022ac6fe095bed3e2314 Mon Sep 17 00:00:00 2001 From: Alan Akbik Date: Sun, 29 Aug 2021 23:02:38 +0200 Subject: [PATCH 2/3] Update TUTORIAL_6_CORPUS.md --- resources/docs/TUTORIAL_6_CORPUS.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/docs/TUTORIAL_6_CORPUS.md b/resources/docs/TUTORIAL_6_CORPUS.md index d84596249..19fd70739 100644 --- a/resources/docs/TUTORIAL_6_CORPUS.md +++ b/resources/docs/TUTORIAL_6_CORPUS.md @@ -178,8 +178,7 @@ The `MultiCorpus` inherits from `Corpus`, so you can use it like any other corpu Flair supports many datasets out of the box. It automatically downloads and sets up the data the first time you call the corresponding constructor ID. -The following datasets are supported (click category to -expand): +The following datasets are supported (**click category to expand**):
Named Entity Recognition (NER) datasets From b2bf60f28699419a19faf59aafb746ec94d89e50 Mon Sep 17 00:00:00 2001 From: Alan Akbik Date: Sun, 29 Aug 2021 23:04:44 +0200 Subject: [PATCH 3/3] Update TUTORIAL_7_TRAINING_A_MODEL.md --- resources/docs/TUTORIAL_7_TRAINING_A_MODEL.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/resources/docs/TUTORIAL_7_TRAINING_A_MODEL.md b/resources/docs/TUTORIAL_7_TRAINING_A_MODEL.md index 213824dfe..a70226dad 100644 --- a/resources/docs/TUTORIAL_7_TRAINING_A_MODEL.md +++ b/resources/docs/TUTORIAL_7_TRAINING_A_MODEL.md @@ -211,9 +211,7 @@ tutorials on both for difference). The rest is exactly the same as before! The best results in text classification use fine-tuned transformers with `TransformerDocumentEmbeddings` as shown in the code below: -(If you don't have a big GPU to fine-tune transformers, try `DocumentPoolEmbeddings` or `DocumentRNNEmbeddings` instead - -- sometimes they work just as well!) +(If you don't have a big GPU to fine-tune transformers, try `DocumentPoolEmbeddings` or `DocumentRNNEmbeddings` instead; sometimes they work just as well!) ```python import torch