-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
When fine-tuning language model, I got AttributeError: 'int' object has no attribute 'item' #1115
Comments
Hello @khoaipx - I cannot reproduce the error on my side. I've tried fine-tuning the 'news-forward-fast' model on some small text and it seems to work. Could it be an issue with your corpus? |
Hi, @alanakbik, Here is my model and corpus data. Please help me to explain why my code got error! |
Hi @khoaipx the problem is that your corpus uses a lot of characters that are not in the default dictionary, which contains only basic latin characters. You need to generate your own character dictionary by following the steps outlined here. |
The existing model is trained with my own dictionary. In my code, I used the dictionary of that existing model |
Hello @khoaipx - the problem is that your validation dataset is too small - it needs to have enough characters for at least 2 mini-batches. I'll put in a PR that raises an exception to warn if the evaluation dataset is too small. |
As of Flair 0.4.4, there is a new multilingual Flair model with a very large character dictionary. To fine-tune it, use this code: from flair.embeddings import FlairEmbeddings
from flair.models import LanguageModel
from flair.trainers.language_model_trainer import LanguageModelTrainer, TextCorpus
# are you training a forward or backward LM?
is_forward_lm = True
# load the multilingual language model
language_model: LanguageModel = FlairEmbeddings('multi-forward').lm
# initialize corpus with dictionary of the multilingual language model
corpus = TextCorpus(corpus_path, language_model.dictionary, is_forward_lm, character_level=True)
# train your language model
trainer = LanguageModelTrainer(language_model, corpus)
trainer.train(
stored_path,
sequence_length=100,
mini_batch_size=100,
learning_rate=20,
patience=10,
max_epochs=300,
checkpoint=True,
) |
…ion-data GH-1115: Add warning if validation data too small
Describe the bug
I fine-tuned an trained language model, but I got below error:
AttributeError: 'int' object has no attribute 'item'
To Reproduce
Screenshots
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: