Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix flert hidden context breaks reduced vocab #3370

Merged

Conversation

helpmefindaname
Copy link
Collaborator

@helpmefindaname helpmefindaname commented Nov 6, 2023

closes #3368

@alanakbik
Copy link
Collaborator

Minimal script to reproduce the error:

import flair
from flair.data import Corpus
from flair.datasets import WNUT_17
from flair.embeddings import TransformerWordEmbeddings
from flair.models import TokenClassifier
from flair.trainers import ModelTrainer

flair.device = "cpu"
flair.set_seed(123)

# error thrown for [xlm-roberta-base, xlm-roberta-large, roberta-base], but not for [bert-base-uncased]
transformer_model = "roberta-base"

corpus: Corpus = WNUT_17().downsample(0.01)

label_dictionary = corpus.make_label_dictionary("ner")

embeddings = TransformerWordEmbeddings(
    model=transformer_model, layers="-1", subtoken_pooling="first", fine_tune=False, use_context=True
)

tagger = TokenClassifier(embeddings=embeddings, label_dictionary=label_dictionary, label_type="ner")

trainer = ModelTrainer(tagger, corpus)

trainer.fine_tune(
    "./results/",
    max_epochs=1,
    reduce_transformer_vocab=True,
)

(I could reproduce the error for roberta-based models, but not bert-based models.)

@alanakbik alanakbik merged commit 0a582db into master Dec 5, 2023
1 check passed
@alanakbik alanakbik deleted the fix_reduce_transformer_vocab_with_flert_hidden_context branch December 5, 2023 04:41
@alanakbik
Copy link
Collaborator

Thanks @helpmefindaname for fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Reduce transformer vocab of XLM-RoBERTa
2 participants