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

Model not saved after training #99

Closed
iamyihwa opened this issue Aug 30, 2018 · 6 comments
Closed

Model not saved after training #99

iamyihwa opened this issue Aug 30, 2018 · 6 comments

Comments

@iamyihwa
Copy link

iamyihwa commented Aug 30, 2018

I have trained a NER however there was no model saved after the training was completed.

From what I have seen in sequence_tagger_trainer.py, save_model = True by default, and I didn't give any change to that.

SequenceTagger and SequenceTaggerTrainer were used.

This is the part of codes used to train.
image

trainer.train('resources/taggers/poa-ner', learning_rate=0.1, mini_batch_size=2, max_epochs=20)
When I look at the content of the directory where I saved the training data, there is no model which ends in .pt.

[ec2-user@ip-172-31-28-32 poa-ner]$ ls
loss.txt  test.tsv

For this case, I had to reduce the mini_batch_size = 2, because the sentence was very very long. ( About 3000 words long each. In fact it was a whole document, because in this document, there are dependencies between sentences, so our teammate wanted to put it together.. I don't know if using whole document as a sentence is a good idea or not.. any ideas on that also? ). I wonder if this could have been the cause of the problem?

The training seems to have completed okay ..
image

@stefan-it
Copy link
Member

Have you installed the latest version of flair? The save_model = True default was recently introduced with #86, so with a version prior to #86 the model was not saved :(

@iamyihwa
Copy link
Author

iamyihwa commented Aug 30, 2018

@stefan-it You are right!! Actually I installed with pip, but I was looking at the codes on the git repository (the most recent version!), and in fact my version has that save_model = False!
I will do that !

So I guess instead of installing through pip, I should git clone from master branch.
Uhm ... I realize now that I made a couple of changes to the flair locally (e.g. accepting different type of embedding, etc.) , so I just decided to set save_model = True in the file sequence_tagger_trainer.py.
Are there lots of differences btwn pip version and master branch? other than this one?

@stefan-it
Copy link
Member

stefan-it commented Aug 30, 2018

Exactly, you can clone the master branch and then just use pip install --user -e . - then the cloned version of flair will be installed :)

@iamyihwa
Copy link
Author

thanks @stefan-it ! Will try that! :-)

@alanakbik
Copy link
Collaborator

@iamyihwa It's probably better to split the document into sentences and use a larger mini-batch-size. We find that a mini-batch-size of 16 or 32 generally works best if you have enough data.

Also, I note that test_mode is set to True in your code. If you want the best results, it's better to set test_mode to False because then the data gets shuffled at each epoch. You should use test_mode=True only for debugging.

So, better use:

trainer = SequenceTaggerTrainer(tagger, corpus, test_mode=False)

Or leave out the test_mode parameter since it is False by default.

@iamyihwa
Copy link
Author

iamyihwa commented Aug 30, 2018

@alanakbik thanks!!!
will try with those!
just changed test_mode = False!

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

No branches or pull requests

3 participants