Skip to content

vincezengqiang/OpenLLaMA2

 
 

Repository files navigation

OpenLLaMA2


OpenLLaMA2

Logo

A High-performance LLaMA2 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

OpenLLaMA2 Project

OpenLLaMA2 aims to develop a high-performance LLaMA2 RLHF training framework (for > 30B models).

The sister project of this project is chinese-llama2 ↗, which aims to fine-tune a Chinese LLaMA2 based on OpenLLaMA2.

Features

  • [✔️] A fast LLaMA2 SFT/PPO Training Framework based on DeepSpeed.
  • [✔️] Multi-nodes training scripts for Slurm.
  • [✔️] Wandb log.
  • [✔️] Support conda env.
  • [✔️] FlashAttention2.
  • [✔️] Support DPO (direct-preference-optimization).
  • [WIP] Distributed RLHF based on HTTP server (for > 30B models).
  • [WIP] Distributed RLHF based on Ray (for > 30B models).
  • [WIP] Rejection Sampling.
  • [WIP] Multiple Reward models.
  • [WIP] Support QLora.
  • [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] Large-scale model (> 70B) support with ZeRO++ and TRT-LLM 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 }

Contribution

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.

About

A High-performance LLaMA2 RLHF framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.3%
  • Shell 0.7%