Closed threefoldo closed 5 years ago
In my opinion, the model and vocabulary should be saved separately. Consider the following example, we trained many models inherited from BaseModel
and they shared the same vocabulary, obviously, saving vocabulary from the model can save many space. And in other words, saving separately can be favorable for later maintenance.
I agree that BaseModel should only consider the model, no data. However, high level class like BiDAFPlusSQuad and BertCoQA cannot work without data, and their data is different, BiDAFPlusSQuad needs pretrained embedding, BertCoQA doesn't. What I suggest here is a better way to let users know what data are necessary to save and rebuild, the example code has little information about that.
Thanks, @yukyang, that should solve all my questions.
A minor error in the new "model_save_load.md", train_batch_generator and eval_batch_generator are unnecessary during inference, it should only use test_batch_generator, which is not declared.
The 'load' and 'save' methods in BaseModel only deal with the model, other related data like 'vocab' is not processed. So, to load a model from file, the vocabulary needs to be rebuilt or loaded separately, which is not ideal. It's better to save and load all related stuff.
Class vocabulary has 'load' and 'save' methods, but all data are save in JSON. It's larger and easy to corrupt. I don't see the benefit of using JSON format here.