Why loading a trained model is taking so much time?

Once I have trained a NLU model using Python (Not with Rasa server, but with individual scripts)

reader = RasaReader()
data =reader.read_from_json(js=json_data) # training data loaded as dictionary
# this step takes 20~25 secs
trainer = Trainer(config._load_from_dict(get_train_config())) # train config loaded from dict
interpreter = trainer.train(data)

and load the model with the following code take again 20~25 secs,

interpreter = Interpreter.load('../bots/rasa_test/trainer_model_persist1')
print(interpreter.parse('How are you ?'))

Why is this happening ? :frowning_face: Is this expected ? :face_with_raised_eyebrow:

Also I want to train multiple models and serve them on demand by loading, So I am expecting a shorter load time.

Loading with dict (for training data and config) and loading from file takes the same amount of time and the results are same, so I believe I haven’t done any mistake here. If I am wrong kindly let me know :slight_smile:

Is there any other way of loading the models faster and better ? Please let me know! :slight_smile:

After few hours of debugging I have found that the time taking part is component loading! It takes approx of 23 secs! But I tried training and loading with the same set of data and code listed about with Python 3.6, now it is loading in 6 seconds! While debugging I tried to find the load time of each component. The first component only took ~5 seconds rest of them are taking just micro seconds. Then I tried a non time taking component individually which surprisingly took ~5 seconds, so my guess is that there is something else causing this delay. It would be nice if I could minimise the time taken for loading, since I am trying to serve different models on demand, which requires less load time. If there is some way I can do this let me know!