Forums

Cache BERT model (sentence_transformers) - prevent loading every time

Hey guys, I got my script to work now on virtualenv. But the script is loading the model every time I request the web app. Is there any possiblity to prevent the model to be loaded on every hit?

I found this https://stackoverflow.com/a/61057688 but I think this is not possible with the flask implementation of pythonanywhere?

Thank you.

You could consider a rewrite to move the model outside of the web app and use it in a script running in the background, like is suggested here.