Giter Club home page Giter Club logo

openllama2's Introduction

OpenLLaMA2


OpenLLaMA2

Logo

A Deepspeed/Ray based High-performance LLaMA2 SFT/RLHF framework!

GitHub Contributors Issues Issues GitHub pull requests GitHub stars
Open-source ChatGPT / Comprehensive / Lightweight / Easy-to-use

The code is open-source, feel free to use it, contributions are welcome! Note: The license of the model depends on the provider of the model.

Latest News

  • 2023/9/7: Add pre-commit
  • 2023/9/6: Support FlashAttention2
  • 2023/8/26: Support wandb logs
  • 2023/8/22: Support ceval
  • 2023/8/20: Add some PPO vs SFT examples
  • 2023/8/18: support LLaMA2 7B PPO training on Single A100, add pre-trained SFT/RM checkpoints
  • 2023/8/13: LLaMA2 7B + SFT+ RM + PPO + DeepSpeed training features finished
  • 2023/07/30: OpenLLaMA2 project officially launched

OpenLLaMA2 Project

OpenLLaMA2 aims to develop a high-performance distributed LLaMA2 SFT/RLHF training framework.

The sister project of this project is chinese-llama2 ↗, which aims to fine-tune the Chinese LLaMA2 using SFT/RLHF.

Features

  • [✔️] A fast LLaMA2 SFT/PPO Training Framework based on DeepSpeed.
  • [✔️] Multi-nodes training scripts for Slurm.
  • [✔️] Wandb log.
  • [✔️] Support conda env.
  • [✔️] FlashAttention2.
  • [WIP] Multi-nodes RLHF based on Ray.
  • [WIP] Multiple RM models.
  • [WIP] Rejection Sampling.
  • [WIP] Support QLora.
  • [WIP] Support DPO.
  • [WIP] Better docs and examples
  • [WIP] Develop the RLHF datasets ↗ for Multiple reward models.
  • [WIP] Train a chinese-llama2 ↗ RLHF model.
  • [TODO] Support Context Distillation.
  • [TODO] Inference kernel fusion (such as DS inference)
  • [TODO] Large-scale model (> 70B) support with ZeRO++ and FasterTransformer inference.

Running LLaMA2 Example

  • Verified envs

You can build openllama2 from nvidia-docker(recomended) or from conda envs.

Clone the repository: 
git clone https://github.com/openllmai/OpenLLaMA2.git

# Download the pre-trained SFT/RM checkpoints (Optional)
git lfs install
git clone https://huggingface.co/chuyi777/openllama2_checkpoint
  • Single-node training with nvidia-docker
cd examples/scripts

# install nvidia-docker (Optional)
./nvidia_docker_install.sh

# launch nvidia container
./docker_run.sh

# cd in container
cd /openllama2/examples/scripts

# build OpenLLaMA2 (i.e, pip install)
./build_openllama2.sh

# huggingface login 
~/.local/bin/huggingface-cli login

# train SFT model
./train_sft_llama.sh

# train RM model
./train_rm_llama.sh

# train PPO model
./train_ppo_llama.sh
  • Multi-nodes training on Slurm
cd examples/scripts

# huggingface login on Slurm 
pip install transformers
huggingface-cli login

# Moidfy the Slurm Account/Nodes ... in `train_llama_slurm.sh`

# For SFT, RM, and PPO training stage:
# Modify the variable `training_script` in `train_llama_slurm.sh` to
readonly training_script="train_sft_llama.sh"
readonly training_script="train_rm_llama.sh"
readonly training_script="train_ppo_llama.sh"

# set `GPUS_PER_NODE` in `train_llama_slurm.sh`
readonly GPUS_PER_NODE=8

# run multi-nodes training script
# train_llama_slurm.sh will load the training args from `training_script`
sbatch ./train_llama_slurm.sh
  • build openllama2 from conda envs

If you really don't want to use nvidia-docker, we also provide tutorials for building openllama2 from a conda environment. (We prefer nvidia-docker to avoid errors caused by the environment.)

# we need conda
conda create -n llama2 python=3.10
# so, we need install some package manualy: when installing torch, you may need to match the corresponding cuda version.
pip install packaging ninja
pip install torch --index-url https://download.pytorch.org/whl/cu118
# check ninjia
ninja --version
echo $? 
# install flash-attn: may take some time
pip install flash-attn=2.1.1 --no-build-isolation
./build_openllama2.sh
# enjoy it!

Inference

After completing the training, you can evaluate your model by using the inference script:

./inference_llama.sh { model_path } "Please introduce the GTA5 game."

Pull Request

If you want to contribute code please format the code using the following command,

pip install pre-commit
pre-commit install
git add .
git commit -m "xxx"

References & Acknowledgements

We would like to express our gratitude to the following projects and organizations for their contributions to the field of AI and NLP:

Join Us

How to Join?

  1. Email us at [email protected](official email) or [email protected]/[email protected](PIC). Please include the following details:
    • Your name
    • Your GitHub username
    • Your areas of interest
    • Your skills and experience related to NLP and/or AI
  2. You can also join us through the official GitHub OpenLLaMA2 ↗ project page. Just create an issue about your interest to contribute and we will get back to you.

What can you do?

  1. Join the team and participate in the development of the OpenLLaMA2 project.
  2. Contribute to the project by submitting pull requests.
  3. Help improve documentation, fix bugs, or create new features.
  4. Share the project and help us grow the community.

Sponsor Us

Your sponsorship can help us maintain and improve OpenLLaMA2. If you find this project useful, please consider sponsoring us. You can sponsor us on Open Collective ↗.

Starchart

Star History Chart

Contributors

A big thank you to all our contributors! If you want to contribute, feel free to make a pull request or create an issue.

Citation

@misc{openllmai23,
   author = {OpenLLMAI},
   title = {OpenLLaMA2},
   year={2023},
   howpublished = {\url{https://github.com/OpenLLMAI/OpenLLaMA2}}
}

OpenLLaMA2 © 2023 OpenLLMAI. All Rights Reserved.

openllama2's People

Contributors

hijkzzz avatar catqaq avatar chuqi9527 avatar dabney777 avatar wwxfromtju avatar suc16 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.