This is the code accompanying this post. You can try the app here. Built using Streamlit and deployed on Heroku
Note: Heroku app is deployed using tensorflow framework, which doesn't play nicely with streamlit caching. For best experiences use pytorch framework. I have added a conditional decorator to avoid model reloading & effecient caching. However, the slug size for pytorch is above 850MB which far exceeds heroku's allowed slug size (500MB).
- Transformers
- Streamlit
All the experiments are run on python 3.8.0
.
- Clone the repository
- If you do not have python3.8 installed. Run the below steps for easy installation using asdf. asdf allows us to manage multiple runtime versions such for different languages such as
nvm
,rbenv
,pyenv
, etc using a CLI tool- Install asdf using this guide
- Now install
python3.8.0
asdf plugin add python asdf install python 3.8.0 asdf local python 3.8.0 # sets python3.8 as interpreter for the project
- Check the set python version
asdf current python
- Install poetry. Poetry is a python dependency management & packaging tool. Allows us to declare project libraries dependency & manage them
asdf plugin add poetry asdf install poetry latest # current 1.0.10; might need sudo asdf local poetry 1.0.10
- Install all dependencies
poetry install
- (Optional) Explicitly instantiate the env
source "$( poetry env list --full-path | grep Activated | cut -d' ' -f1 )/bin/activate"
- To run the application -
streamlit run app.py
- Change
config
dictionary values inconfig.py
as required
framework: tf/pt # choose tensorflow or pytorch framework
NUM_SENT: int # number of wiki sentences for context