Why is my code running so much slower on streamlit than locally?

Regardless of the runtime, Streamlit is really a great tool. I hope the official team can promote it more, because I didn’t know about Streamlit during my time at university!

Here is my question:

I wrote a script for text corpus augmentation, and it takes about 5 seconds to enhance a piece of text locally, but it takes about 12 seconds on Streamlit. Is there any way to improve this?