Ok, just writing some thoughts here without having tested anything
- If your āload_modelā is mostly IO bound, I think thatās a good fit for asyncio (which then makes it more of a Python problem than a Streamlit problem :)). Using a coroutine would load the model in the background when nothing else is happening.
- Now I donāt know about caching an async method though, there is a draft of something here: Caching asyncio functions but I personally did not have time to play with this. There are other posts relative to asyncio (eventually threading) in Streamlit if you want to check the search bar.
Iāll try to think about this more later on, just wanted to share this that will maybe get your on a new track