Saving and Loading ULMFit model

Hi All,

I need to use a trained ULMFit model, to make a real-time prediction, possibly provide the model as API service maybe.

How can we save the ULMFit model and then use new it for the prediction on a new data set?
I got this working in one way, as in this thread, Load ULMFit model.

This basically rebuilds the model and then loads the weights for the trained model.
However, rebuilding the model requires Textdata object to be built, which required training data(or validation data). Is it possible to just save the whole “learn” object ( final object in, and reload it just for making prediction purpose? I tried pickle.dump() to save, but that throws up picking error.

Or it’s there a better way to save and use this model?


@jeremy, sorry to bother you but do you best practices for this? I think a lot of users want to use ulmfit as an API service.

1 Like

I would also be interested in a workaround/solution for this

1 Like