/ad-470-group2

Primary LanguageJupyter NotebookMIT LicenseMIT

ad-470-group2

Project 3

Contains a one page web app with a question answering bot. This bot connects with the Wikipedia API and attempts to answer questions posed by the user. You can play with the app at https://server-ejyiaysa3q-uc.a.run.app/
Built with:

  • Flask
  • Tailwindcss
  • HuggingFace BERT model pretrained on the SQuAD2.0 data set
  • SQLite3
  • Docker
  • Google Cloud Run

Update styles with tailwindcss

If you make any changes to tailwindcss, run the following before running with Docker

tailwindcss -i ./static/src/main.css -o ./static/dist/main.css --minify

Run locally

Pre-reqs

Change main.py to look like below:
image

There's a known issue with installing tokenizers for Huggingface on M1 macs. I tried different workarounds for a few hours, but couldn't get it running.

Note: this may not be necessary on non-M1 macs.

Steps

Create virtual env

cd project-3/server
python3 -m venv venv

Active virtual env

source tutorial-env/bin/venv

Install packages

pip3 install -r requirements.txt

Start the app

FLASK_APP=main.py FLASK_ENV=development flask run

Run with Docker

Pre-reqs

You must have Docker installed before you proceed

Steps

From the root of the repo:

cd project-3/server
docker build --tag ad470-g2-p3-test .
docker run -d -p 8080:8080 ad470-g2-p3-test

Visit localhost:8080

Run with Cloud Run

Pre-reqs

  • The gcloud cli.
  • You must have access to our google cloud project, ad470-p3. Submit an issue or email dan.jack@hey.com if you need access.

Steps

cd project-3/server
gcloud config set project ad470-p3
gcloud builds submit --tag gcr.io/ad470-p3/server
gcloud run deploy --image gcr.io/ad470-p3/server

Press Enter when prompted for Service name

Once deployed, you can view logs for the server on Google Cloud Platform