Giter Club home page Giter Club logo

mlops's Introduction

Applied ML · MLOps · Production
Join 20K+ developers in learning how to responsibly deliver value with ML.

     

If you need refresh yourself on ML algorithms, check out our Made Wit ML repository (🔥  Among the top ML repositories on GitHub)


📦  Product 🔢  Data 📈  Modeling
Objective Labeling Baselines
Solution Preprocessing Evaluation
Iteration Exploratory data analysis Experiment tracking
Splitting Optimization
Augmentation
📝  Scripting (cont.) 📦  Interfaces ✅  Testing
Organization Styling Command-line Code
Packaging Makefile RESTful API Data
Documentation Logging Models
♻️  Reproducibility 🚀  Production (cont.)
Git Dashboard Deployment
Pre-commit CI/CD workflows Monitoring
Versioning Feature stores
Docker

📆  New lessons every month!
Subscribe for our monthly updates on new content.


Directory structure

app/
├── api.py        - FastAPI app
└── cli.py        - CLI app
├── schemas.py    - API model schemas
tagifai/
├── config.py     - configuration setup
├── data.py       - data processing components
├── eval.py       - evaluation components
├── main.py       - training/optimization pipelines
├── models.py     - model architectures
├── predict.py    - inference components
├── train.py      - training components
└── utils.py      - supplementary utilities

Documentation for this application can be found here.

Workflows

Use existing model

  1. Set up environment.
export venv_name="venv"
make venv name=${venv_name} env="dev"
source ${venv_name}/bin/activate
  1. Pull latest model.
dvc pull
  1. Run Application
make app env="dev"

You can interact with the API directly or explore via the generated documentation at http://0.0.0.0:5000/docs.

Update model (CI/CD)

Coming soon after CI/CD lesson where the entire application will be retrained and deployed when we push new data (or trigger manual reoptimization/training). The deployed model, with performance comparisons to previously deployed versions, will be ready on a PR to push to the main branch.

Update model (manual)

  1. Set up the development environment.
export venv_name="venv"
make venv name=${venv_name} env="dev"
source ${venv_name}/bin/activate
  1. Pull versioned data and model artifacts.
dvc pull
  1. Optimize using distributions specified in tagifai.main.objective. This also writes the best model's params to config/params.json
tagifai optimize \
    --params-fp config/params.json \
    --study-name optimization \
    --num-trials 100

We'll cover how to train using compute instances on the cloud from Amazon Web Services (AWS) or Google Cloud Platforms (GCP) in later lessons. But in the meantime, if you don't have access to GPUs, check out the optimize.ipynb notebook for how to train on Colab and transfer to local. We essentially run optimization, then train the best model to download and transfer it's artifacts.

  1. Train a model (and save all it's artifacts) using params from config/params.json and publish metrics to model/performance.json. You can view the entire run's details inside experiments/{experiment_id}/{run_id} or via the API (GET /runs/{run_id}).
tagifai train-model \
    --params-fp config/params.json \
    --model-dir model \
    --experiment-name best \
    --run-name model
  1. Predict tags for an input sentence. It'll use the best model saved from train-model but you can also specify a run-id to choose a specific model.
tagifai predict-tags --text "Transfer learning with BERT"  # test with CLI app
make app env="dev"  # run API and test as well
  1. View improvements Once you're done training the best model using the current data version, best hyperparameters, etc., we can view performance difference.
tagifai diff
  1. Commit to git This will clean and update versioned assets (data, experiments), run tests, styling, etc.
git add .
git commit -m ""
git tag -a <TAG_NAME> -m ""
git push origin <BRANCH_NAME>

Commands

Docker

make docker  # docker build -t tagifai:latest -f Dockerfile .
             # docker run -p 5000:5000 --name tagifai tagifai:latest

Application

make app  # uvicorn app.api:app --host 0.0.0.0 --port 5000 --reload --reload-dir tagifai --reload-dir app
make app-prod  # gunicorn -c config/gunicorn.py -k uvicorn.workers.UvicornWorker app.api:app

Streamlit dashboard

make streamlit  # streamlit run streamlit/app.py

MLFlow

make mlflow  # mlflow server -h 0.0.0.0 -p 5000 --backend-store-uri stores/model/

Mkdocs

make docs  # python -m mkdocs serve

Testing

make great-expectations  # great_expectations checkpoint run [projects, tags]
make test  # pytest --cov tagifai --cov app --cov-report html
make test-non-training  # pytest -m "not training"

Start Jupyterlab

python -m ipykernel install --user --name=tagifai
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install @jupyterlab/toc
jupyter lab

You can also run all notebooks on Google Colab.

FAQ

Why is this free?

While this content is for everyone, it's especially targeted towards people who don't have as much opportunity to learn. I firmly believe that creativity and intelligence are randomly distributed but opportunity is siloed. I want to enable more people to create and contribute to innovation.

Who is the author?

  • I've deployed large scale ML systems at Apple as well as smaller systems with constraints at startups and want to share the common principles I've learned along the way.
  • I created Made With ML so that the community can explore, learn and build ML and I learned how to build it into an end-to-end product that's currently used by over 20K monthly active users.
  • Connect with me on Twitter and LinkedIn

To cite this course, please use:
@article{madewithml,
    title  = "Applied ML - Made With ML",
    author = "Goku Mohandas",
    url    = "https://madewithml.com/courses/mlops/"
    year   = "2021",
}

mlops's People

Contributors

gokumohandas avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.