Logisx / LLMath-QLoRA

End-to-end MLOps LLM instruction finetuning based on PEFT & QLoRA to solve math problems.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Logo

πŸ“‹ Table of Contents

πŸš€ LLM Instruction tuning for school math questions

End-to-end MLOps LLM instruction finetuning based on PEFT & QLoRA to solve math problems.

Python PyTorch JupyterLab Transformers Docker DVC MLflow FastAPI AWS CI/CD MIT License

Demo

πŸ“Š Model & Dataset

Base LLM: OpenLLaMA
Dataset: Grade School Math Instructions Dataset

🧰 Tech Stack

  • NLP: PyTorch, Hugging Face Transformers, Accelerate, PEFT
  • Research: Jupyter Lab, MLflow
  • Framework: FastAPI
  • Deployment: Docker, Amazon Web Services (AWS), GitHub Actions
  • Version Control: Git, DVC, GitHub

πŸ“ Project structure

Project structure template can be found here.

β”œβ”€β”€ LICENSE
β”œβ”€β”€ Makefile                  <- Makefile with commands like `make data` or `make train`
β”œβ”€β”€ README.md                 <- The top-level README for developers using this project.
β”œβ”€β”€ requirements.txt          <- The requirements file for reproducing the analysis environment, e.g.
β”‚                                 generated with `pip freeze > requirements.txt`
|
β”œβ”€β”€ config                    <- Stores pipelines' configuration files
|   β”œβ”€β”€ data-config.yaml
|   β”œβ”€β”€ model-config.yaml
|   └── model-parameters.yaml
|
β”œβ”€β”€ data
β”‚   β”œβ”€β”€ external              <- Data from third party sources.
β”‚   β”œβ”€β”€ interim               <- Intermediate data that has been transformed.
β”‚   β”œβ”€β”€ processed             <- The final, canonical data sets for modeling.
β”‚   └── raw                   <- The original, immutable data dump.
β”‚
β”œβ”€β”€ assets                    <- Store public assets for readme file
β”œβ”€β”€ docs                      <- A default Sphinx project; see sphinx-doc.org for details
β”‚
β”œβ”€β”€ models                    <- Trained and serialized models, model predictions, or model summaries
β”‚
β”œβ”€β”€ notebooks                 <- Jupyter notebooks for research.
β”‚
β”œβ”€β”€ setup.py                  <- Make this project pip installable with `pip install -e`
β”œβ”€β”€ src                       <- Source code for use in this project.
β”‚   β”œβ”€β”€ __init__.py           <- Makes src a Python module
β”‚   β”‚
|   β”œβ”€β”€ logging               <- Define loggers for the app
|   β”œβ”€β”€ utils
|   |   β”œβ”€β”€ __init__.py
|   |   └── common.py         <- Functions for common utilities
|   |
β”‚   β”œβ”€β”€ data                  <- Scripts to download or generate data
|   |   β”œβ”€β”€ components        <- Classes for pipelines
|   |   β”œβ”€β”€ pipeline          <- Scripts for data aggregation
|   |   β”œβ”€β”€ configuration.py  <- Class to manage config files
|   |   β”œβ”€β”€ entity.py         <- Stores configuration dataclasses
β”‚   β”‚   └── make_dataset.py   <- Script to run data pipelines
β”‚   β”‚
β”‚   └── models                <- Scripts to train models and then use trained models to make
β”‚       β”‚                         predictions
|       β”œβ”€β”€ components        <- Classes for pipelines
|       β”œβ”€β”€ pipeline          <- Scripts for data aggregation
|       β”œβ”€β”€ configuration.py  <- Class to manage config files
|       β”œβ”€β”€ entity.py         <- Stores configuration dataclasses
β”‚       β”œβ”€β”€ predict_model.py  <- Script to run prediction pipeline
β”‚       └── train_model.py    <- Script to run model pipelines
β”‚
β”œβ”€β”€ main.py                   <- Script to run model training pipeline
β”œβ”€β”€ app.py                    <- Script to start FastApi app
|
β”œβ”€β”€ .env.example              <- example .env structure
β”œβ”€β”€ Dockerfile                <- configurates Docker container image
β”œβ”€β”€ .github
|   └── workflows
|       └── main.yaml         <- CI/CD config 
|
β”œβ”€β”€ .gitignore                <- specify files to be ignored by git
β”œβ”€β”€ .dvcignore                <- specify files to be ignored by dvc
|
β”œβ”€β”€ .dvc                      <- dvc config 
β”œβ”€β”€ dvc.lock                  <- store dvc tracked information
└── dvc.yaml                  <- specify pipeline version control

πŸ’» Run Locally

  1. Clone the project
  git clone https://github.com/Logisx/LLMath-QLoRA
  1. Go to the project directory
  cd my-project
  1. Install dependencies
  pip install -r requirements.txt
  1. Start the app
  python app.py

πŸ—ΊοΈ Roadmap

  1. Testing features: Develop unit tests and integrations test
  2. Hyperparameter tuning: Train a better model by hyperparameter tuning
  3. User interface: Create a frienly app interface

βš–οΈ License

MIT License

πŸ”— Links

linkedin

πŸ“š References & Citations

@article{cobbe2021gsm8k,
  title={Training Verifiers to Solve Math Word Problems},
  author={Cobbe, Karl and Kosaraju, Vineet and Bavarian, Mohammad and Chen, Mark and Jun, Heewoo and Kaiser, Lukasz and Plappert, Matthias and Tworek, Jerry and Hilton, Jacob and Nakano, Reiichiro and Hesse, Christopher and Schulman, John},
  journal={arXiv preprint arXiv:2110.14168},
  year={2021}
}
@software{openlm2023openllama,
  author = {Geng, Xinyang and Liu, Hao},
  title = {OpenLLaMA: An Open Reproduction of LLaMA},
  month = May,
  year = 2023,
  url = {https://github.com/openlm-research/open_llama}
}
@software{together2023redpajama,
  author = {Together Computer},
  title = {RedPajama-Data: An Open Source Recipe to Reproduce LLaMA training dataset},
  month = April,
  year = 2023,
  url = {https://github.com/togethercomputer/RedPajama-Data}
}
@article{touvron2023llama,
  title={Llama: Open and efficient foundation language models},
  author={Touvron, Hugo and Lavril, Thibaut and Izacard, Gautier and Martinet, Xavier and Lachaux, Marie-Anne and Lacroix, Timoth{\'e}e and Rozi{\`e}re, Baptiste and Goyal, Naman and Hambro, Eric and Azhar, Faisal and others},
  journal={arXiv preprint arXiv:2302.13971},
  year={2023}
}

About

End-to-end MLOps LLM instruction finetuning based on PEFT & QLoRA to solve math problems.

License:MIT License


Languages

Language:Jupyter Notebook 88.5%Language:Python 10.0%Language:Makefile 1.4%Language:Dockerfile 0.0%