Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Update readme #21

Merged
merged 49 commits into from
Aug 9, 2023
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
f9ee340
Update README.md
LZHgrla Aug 7, 2023
b051d75
Update README.md
LZHgrla Aug 7, 2023
9c05c7b
Update README.md
LZHgrla Aug 7, 2023
b871a55
Update README.md
LZHgrla Aug 7, 2023
de05d20
Update README.md
LZHgrla Aug 7, 2023
1a4c75b
Update README.md
LZHgrla Aug 7, 2023
78e4f9e
Update README.md
LZHgrla Aug 7, 2023
ec836b2
Update README.md
LZHgrla Aug 7, 2023
9d00c16
Update README.md
LZHgrla Aug 7, 2023
607e617
Update README.md
LZHgrla Aug 7, 2023
5d47957
Update README.md
LZHgrla Aug 7, 2023
d3dc599
Update README.md
LZHgrla Aug 7, 2023
a0b0751
Update README.md
LZHgrla Aug 7, 2023
78eb46e
Update README.md
LZHgrla Aug 7, 2023
c06acef
Update README.md
LZHgrla Aug 7, 2023
788a331
Update README.md
LZHgrla Aug 7, 2023
3eb6c73
Update README.md
LZHgrla Aug 7, 2023
9de847f
Update README.md
LZHgrla Aug 7, 2023
de46f90
Update README.md
LZHgrla Aug 7, 2023
921c9b3
Update README.md
LZHgrla Aug 7, 2023
36f28d3
Update README.md
LZHgrla Aug 7, 2023
22a322f
Update README.md
LZHgrla Aug 7, 2023
24b5fc7
Update README.md
LZHgrla Aug 7, 2023
74a4bbf
Update README.md
LZHgrla Aug 7, 2023
2fc1c26
Update README.md
LZHgrla Aug 7, 2023
30a0636
Update README.md
LZHgrla Aug 7, 2023
aa98455
Update README.md
LZHgrla Aug 7, 2023
aad1465
Update README.md
LZHgrla Aug 7, 2023
c9a7896
[Docs] Update readme (#3)
HIT-cwh Aug 7, 2023
2a152aa
fix pre-commit
LZHgrla Aug 7, 2023
477a1cd
Update README.md
LZHgrla Aug 7, 2023
94d1b17
Update README.md
LZHgrla Aug 7, 2023
5648b79
fix pre-commit
LZHgrla Aug 7, 2023
d62f71f
WIP: delete internlm
HIT-cwh Aug 7, 2023
3c39806
WIP: delete internlm
HIT-cwh Aug 7, 2023
5f25c1e
Update README.md
LZHgrla Aug 7, 2023
598ec15
Update README.md
LZHgrla Aug 7, 2023
fe6617a
Update README.md
LZHgrla Aug 7, 2023
2469350
Update README.md
LZHgrla Aug 8, 2023
99b05f1
Update README.md
LZHgrla Aug 8, 2023
f843fe3
fix pre-commit
LZHgrla Aug 8, 2023
e5fb082
Update README.md
LZHgrla Aug 8, 2023
2113f0f
Update README.md
LZHgrla Aug 8, 2023
5df2d21
Merge branch 'pppppM:main' into update_readme
LZHgrla Aug 8, 2023
a675385
add example colab
Aug 8, 2023
64735c3
Update README.md
LZHgrla Aug 9, 2023
3551c15
fix pre-commit
LZHgrla Aug 9, 2023
fcb2862
Update README.md
LZHgrla Aug 9, 2023
9c16e35
Update README.md
LZHgrla Aug 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 175 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,186 @@
# MMChat

<div align="center">

[![docs](https://readthedocs.org/projects/opencompass/badge)](https://opencompass.readthedocs.io/en)
[![license](https://img.shields.io/github/license/InternLM/opencompass.svg)](https://github.com/InternLM/opencompass/blob/main/LICENSE)
[![PyPI](https://badge.fury.io/py/opencompass.svg)](https://pypi.org/project/opencompass/)

[📘Documentation](https://opencompass.readthedocs.io/en/latest/) |
[🤔Reporting Issues](https://github.com/InternLM/opencompass/issues/new/choose)

English | [简体中文](README_zh-CN.md)

</div>

## 🌟 Demos

- QLoRA fine-tune for InternLM-7B [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1yzGeYXayLomNQjLD4vC6wgUHvei3ezt4?usp=sharing)
- Chat with Llama2-7B-Plugins [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](<>)
- Use MMChat in HuggingFace training pipeline [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1eBI9yiOkX-t7P-0-t9vS8y1x5KmWrkoU?usp=sharing)

## 🧭 Introduction

MMChat is a toolkit for quickly fine-tuning LLM, developed by the [MMRazor](https://github.com/open-mmlab/mmrazor) and [MMDeploy](https://github.com/open-mmlab/mmdeploy) teams. It has the following core features:

- Embrace [HuggingFace](https://huggingface.co) and provide fast support for new models, datasets, and algorithms.
- Provide a comprehensive solution and related models for [MOSS plugins datasets](https://github.com/OpenLMLab/MOSS/tree/main/SFT_data).
- Support arbitrary combinations of multiple datasets during fine-tuning.
- Compatible with [DeepSpeed](https://github.com/microsoft/DeepSpeed), enabling the efficient fine-tuning of LLM on multiple GPUs.
- Support [QLoRA](http://arxiv.org/abs/2305.14314), enabling the efficient fine-tuning of LLM using free resources on Colab.

> 💥 [MMRazor](https://github.com/open-mmlab/mmrazor) and [MMDeploy](https://github.com/open-mmlab/mmdeploy) teams have also collaborated in developing [LMDeploy](https://github.com/InternLM/lmdeploy), a toolkit for for compressing, deploying, and serving LLM. Welcome to subscribe to stay updated with our latest developments.

## 🔥 Supports

<table>
<tbody>
<tr align="center" valign="middle">
<td>
<b>Models</b>
</td>
<td>
<b>Datasets</b>
</td>
<td>
<b>Strategies</b>
</td>
<td>
<b>Algorithms</b>
</td>
</tr>
<tr valign="top">
<td align="left" valign="top">
<ul>
<li><a href="configs/internlm/internlm_7b">InternLM</a></li>
<li><a href="configs/internlm/internlm_chat_7b">InternLM-Chat</a></li>
<li><a href="configs/llama/llama_7b">Llama</a></li>
<li><a href="configs/llama/llama2_7b">Llama2</a></li>
<li><a href="configs/llama/llama2_7b_chat">Llama2-Chat</a></li>
<li><a href="configs/qwen/qwen_7b">Qwen</a></li>
<li><a href="configs/qwen/qwen_7b_chat">Qwen-Chat</a></li>
<li><a href="configs/baichuan/baichuan_7b">Baichuan-7B</a></li>
<li><a href="configs/baichuan/baichuan_13b_base">Baichuan-13B-Base</a></li>
<li><a href="configs/baichuan/baichuan_13b_chat">Baichuan-13B-Chat</a></li>
<li>...</li>
</ul>
</td>
<td>
<ul>
<li><a href="configs/_base_/datasets/moss_003_sft_all.py">MOSS-003-SFT</a></li>
<li><a href="configs/_base_/datasets/arxiv.py">Arxiv GenTitle</a></li>
<li><a href="configs/_base_/datasets/open_orca.py">OpenOrca</a></li>
<li><a href="configs/_base_/datasets/alpaca.py">Alpaca en</a> / <a href="configs/_base_/datasets/alpaca_zh.py">zh</a></li>
<li><a href="configs/_base_/datasets/oasst1.py">oasst1</a></li>
<li><a href="configs/_base_/datasets/cmd.py">Chinese Medical Dialogue</a></li>
<li>...</li>
</ul>
</td>
<td>
<ul>
<li>(Distributed) Data Parallel</li>
<li><a href="https://github.com/microsoft/DeepSpeed">Deepspeed</a> 🚀</li>
</ul>
</td>
<td>
<ul>
<li>Full parameter fine-tune</li>
<li><a href="http://arxiv.org/abs/2106.09685">LoRA</a></li>
<li><a href="http://arxiv.org/abs/2305.14314">QLoRA</a></li>
<li>...</li>
</ul>
</td>
</tr>
</tbody>
</table>

## 🛠️ Quick Start

### Installation

1. 安装 Pytorch (https://pytorch.org/get-started/locally/)
2. 安装 MMChat
Below are quick steps for installation:

```shell
conda create -n mmchat python=3.10
conda activate mmchat
git clone XXX
cd MMChat
pip install -v -e .
```
pip install -r requirements.txt
pip install -e .
```

### TODO
### Chat [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](<>)

<img src="https://github.com/InternLM/lmdeploy/assets/36994684/20159556-7711-4b0d-9568-6884998ad66a">

MMChat provides the tools to chat with pretrained / fine-tuned LLMs.

- For example, we can start the chat with Llama2-7B-Plugins by

```shell
python ./tools/chat_hf.py meta-llama/Llama-2-7b --adapter XXX --bot-name Llama2 --prompt plugins --with-plugins --command-stop-word "<eoc>" --answer-stop-word "<eom>" --no-streamer
```

For more usages, please see [TODO](<>).

### Fine-tune [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1yzGeYXayLomNQjLD4vC6wgUHvei3ezt4?usp=sharing)

MMChat supports the efficient fine-tune (*e.g.*, QLoRA) for Large Language Models (LLM).

Taking the QLoRA fine-tuning as an example, we can start it by

- For example, we can start the QLoRA fine-tuning of InternLM-7B with oasst1 dataset by
```shell
# On a single GPU
python ./tools/train.py ./configs/internlm/internlm_7b/internlm_7b_qlora_oasst1.py
# On multiple GPUs
bash ./tools/dist_train.sh ./configs/internlm/internlm_7b/internlm_7b_qlora_oasst1.py ${GPU_NUM}
```

For more usages, please see [TODO](<>).

### Deploy

- **Step 0**, convert the pth adapter to HuggingFace adapter, by

```shell
python ./tools/model_converters/adapter_pth2hf.py \
${CONFIG_FILE} \
${PATH_TO_PTH_ADAPTER} \
${SAVE_PATH_TO_HF_ADAPTER}
```

- **Step 1**, merge the HuggingFace adapter to the pretrained LLM, by

```shell
python ./tools/model_converters/merge_lora_hf.py \
${NAME_OR_PATH_TO_HF_MODEL} \
${NAME_OR_PATH_TO_HF_ADAPTER} \
${SAVE_PATH}
```

- **Step 2**, deploy the merged LLM with any other framework, such as [LMDeploy](https://github.com/InternLM/lmdeploy) 🚀.

```shell
pip install lmdeploy
python -m lmdeploy.pytorch.chat ${NAME_OR_PATH_TO_HF_MODEL} \
--max_new_tokens 256 \
--temperture 0.8 \
--top_p 0.95 \
--seed 0
```

🎯 We are woking closely with [LMDeploy](https://github.com/InternLM/lmdeploy), to implement the deployment of **dialogues with plugins**!

### Evaluation

- We recommend using [OpenCompass](https://github.com/InternLM/opencompass), a comprehensive and systematic LLM evaluation library, which currently supports 50+ datasets with about 300,000 questions.

##### 基础功能
## 🔜 Roadmap

- [x] MMEngine 加载 HF Dataset
- [x] MMEngine 加载 HF Model & Tokenizer
- [ ] DeepSpeed Config
- [ ] FSDP Config
- [ ] MMLU 评测
- [ ] PTH -> HF Checkpoint 转换脚本
- [ ] Attention Score 可视化
## 🎖️ Acknowledgement

##### 算法
- [Llama 2](https://github.com/facebookresearch/llama)
- [QLoRA](http://arxiv.org/abs/2305.14314)
- [LMDeploy](https://github.com/InternLM/lmdeploy)

- [x] SFT
- [ ] Alpaca SFT Setting & 精度对齐
- [x] QLora SFT
- [ ] QLora SFT Setting & 精度对齐
- [ ] QLora RLHF
- [ ] Distill Finetune
## 🎫 License