Hi! Brand new to Streamlit and trying to figure out how to convert something I built in Google Colab to Streamlit.

I am trying to allow a user to input a set of words, and receive as output a word most similar to the set. To do this, I’m using gensim.downloader to pull in word2vec-google-news-300 and using the “most_similar” function. I am trying to cache this process in a function “load_model()” function so that the user does not need to download the gensim model every time they want to input a new word to try.

However, it is not working (it seems to stall out every time and never reach success). Any suggestions?

def load_model():
    with st.spinner('Downloading word2vec model... please hold...'):
        model = api.load('word2vec-google-news-300')
    return model

def main():
    model = load_model()

Hi @hschreib, welcome to the Streamlit community!

Are you developing this locally on your machine or is this app deployed somewhere? Is there a GitHub repo we can look at to see the setup?


Hi @randyzwitch,

Thanks for the response! I am developing this locally on my machine for now but hoping to make it easy to deploy and have others use (hence my interest in Streamlit!).

I don’t have a Github repo yet with the local code, but you can see what I originally built for Google Colab here: mcit-hackathon/mcit_hackathon_codenames_word2vec.ipynb at main · hschrei7/mcit-hackathon · GitHub

(it is essentially the same, but the Google Colab uses some other, worse widgets/UI that I’m trying to improve via Streamlit!)


1 Like

I believe I fixed this issue by putting


above the load_model function

1 Like