-
Notifications
You must be signed in to change notification settings - Fork 191
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
Fine-tune BERT on SQuAD train then SQuAD dev #7
Comments
It would be a good thing to report for each model training:
Also, using ML Flow Tracking might be easier for us to track different models. |
I have fetched one of the url for
It's just a weights file and a a model config file:
I will adapt Then, it seems if args.do_train:
# Save a trained model and the associated configuration
# Load a trained model and config that you have fine-tuned
else:
model = BertForQuestionAnswering.from_pretrained(args.bert_model) The function
To predict with model fine tuned on SQuAD v1.1, we need to do:
With |
@andrelmfarias Should I try this and let you know if it works? |
@fmikaelian I think if you do not select the option --do_train, it is only going to predict on Don't we need to change the script in order to do the fine-tune on squad-dev? |
@andrelmfarias Yes, you are right the code snippet above is only for prediction. I can try to generate predictions on a sample You can try to do the second fine-tuning on squad-dev to validate the workflow? Don't forget to report your actions and commands ✍️. |
Ideas for second fine-tuning: if args.do_train and args.bert_model != 'models/bert_qa_squad_v1.1':
# Save a trained model and the associated configuration
model_to_save = model.module if hasattr(model, 'module') else model # Only save the model it-self
output_model_file = os.path.join(args.output_dir, WEIGHTS_NAME)
torch.save(model_to_save.state_dict(), output_model_file)
output_config_file = os.path.join(args.output_dir, CONFIG_NAME)
with open(output_config_file, 'w') as f:
f.write(model_to_save.config.to_json_string()) # Load a trained model and config that you have fine-tuned
config = BertConfig(output_config_file)
model = BertForQuestionAnswering(config)
model.load_state_dict(torch.load(output_model_file))
else:
model = BertForQuestionAnswering.from_pretrained(args.bert_model) |
Some errors when re-training with saved model 'models/bert_qa_squad_v1.1' using run_squad.py script:
It seems to be some error related to the non-existance of tokenizer with the saved model. I solved the problem by running a own-made script run_squad_fine-tunned.py which will be commited to the repo. The usage of run_squad-fine-tunned.py for retrain a saved model is as below:
|
The error traceback for For the tokenizer error, did you look at the BertTokenizer class in the I'd like to see what you changed in the script. Changing the script is a strategy that we should debate. Maybe we just need to drop the vocab file of the |
The command I ran was the following:
Yes, I looked at the BertTokenizer class. I understand the argument that is fed to the BertTokenizer is either the path to the saved model or the name of one of the models in PRETRAINED_VOCAB_ARCHIVE_MAP. (args.bert_model at Line 883 in run_squad.py ). If there is no I am committing the new script in a new branch so that we can take a look at it. There are no major changes and it is easy to understand. |
@andrelmfarias You released model |
@fmikaelian I understood we would use this model to do a 2nd fine-tune on the BNP dataset, as after this fine-tune on the dev set, the model would be able to generalise more (had seen more samples). I imagine however that the performance might not increase that much in comparison to the model trained on SQUAD train. We can discuss it. |
I've just released the model trained with the sklearn wrapper: https://github.com/fmikaelian/cdQA/releases/tag/bert_qa_squad_v1.1_sklearn Meaning you can load it and predict directly. You might need to reset some parameters like |
I could make predictions but didnt evaluated it yet (see #70). |
Use output weights of first BERT fine-tuned on SQuAD train as input starter weights for new BERT fine-tuned on SQuAD dev.
https://github.com/huggingface/pytorch-pretrained-BERT#squad
The text was updated successfully, but these errors were encountered: