# ChatGLM Efficient Tuning
[![GitHub Repo stars](https://img.shields.io/github/stars/hiyouga/ChatGLM-Efficient-Tuning?style=social)](https://github.com/hiyouga/ChatGLM-Efficient-Tuning/stargazers)
[![GitHub Code License](https://img.shields.io/github/license/hiyouga/ChatGLM-Efficient-Tuning)](LICENSE)
[![GitHub last commit](https://img.shields.io/github/last-commit/hiyouga/ChatGLM-Efficient-Tuning)](https://github.com/hiyouga/ChatGLM-Efficient-Tuning/commits/main)
[![PyPI](https://img.shields.io/pypi/v/glmtuner)](https://pypi.org/project/glmtuner/)
[![GitHub pull request](https://img.shields.io/badge/PRs-welcome-blue)](https://github.com/hiyouga/ChatGLM-Efficient-Tuning/pulls)
Fine-tuning ð¤[ChatGLM-6B](https://github.com/THUDM/ChatGLM-6B) model with ð¤[PEFT](https://github.com/huggingface/peft).
ð Join our [WeChat](assets/wechat.jpg).
\[ English | [ä¸æ](README_zh.md) \]
If you have any questions, please refer to our [Wikið](https://github.com/hiyouga/ChatGLM-Efficient-Tuning/wiki).
## Notice
This repo will **not be maintained** in the future. Please follow **[LLaMA-Efficient-Tuning](https://github.com/hiyouga/LLaMA-Efficient-Tuning)** for fine-tuning the language models (including ChatGLM2-6B).
## Changelog
[23/07/15] Now we develop an all-in-one Web UI for training, evaluation and inference. Try `train_web.py` to fine-tune ChatGLM-6B model in your Web browser. Thank [@KanadeSiina](https://github.com/KanadeSiina) and [@codemayq](https://github.com/codemayq) for their efforts in the development.
[23/07/09] Now we release [FastEdit](https://github.com/hiyouga/FastEdit)â¡ð©¹, an easy-to-use package for editing the factual knowledge of large language models efficiently. Please follow [FastEdit](https://github.com/hiyouga/FastEdit) if you are interested.
[23/06/25] Now we align the [demo API](src/api_demo.py) with the [OpenAI's](https://platform.openai.com/docs/api-reference/chat) format where you can insert the fine-tuned model in arbitrary ChatGPT-based applications.
[23/06/25] Now we support fine-tuning the [ChatGLM2-6B](https://github.com/THUDM/ChatGLM2-6B) model with our framework!
[23/06/05] Now we support 4-bit LoRA training (aka [QLoRA](https://github.com/artidoro/qlora)). Try `--quantization_bit 4` argument to work with 4-bit quantized model. (experimental feature)
[23/06/01] We implemented a framework supporting the efficient tuning of LLaMA and BLOOM models. Please follow [LLaMA-Efficient-Tuning](https://github.com/hiyouga/LLaMA-Efficient-Tuning) if you are interested.
[23/05/19] Now we support using the development set to evaluate the model while training. Try `--dev_ratio` argument to specify the size of development set.
[23/04/29] Now we support training ChatGLM with **Reinforcement Learning with Human Feedback (RLHF)** ! We provide several examples to run RLHF training, please refer to the `examples` folder for details.
[23/04/20] Our repo achieved 100 stars within 12 days! Congratulations!
[23/04/19] Now we support **merging the weights** of fine-tuned models trained by LoRA! Try `--checkpoint_dir checkpoint1,checkpoint2` argument for continually fine-tuning the models.
[23/04/18] Now we support training the **quantized models** using three fine-tuning methods! Try `quantization_bit` argument for training the model in 4/8 bits.
[23/04/12] Now we support **training from checkpoints**! Use `--checkpoint_dir` argument to specify the checkpoint model to fine-tune from.
[23/04/11] Now we support training with **combined datasets**! Try `--dataset dataset1,dataset2` argument for training with multiple datasets.
## Datasets
- For supervised fine-tuning:
- [Stanford Alpaca (en)](https://github.com/tatsu-lab/stanford_alpaca)
- [Stanford Alpaca (zh)](https://github.com/ymcui/Chinese-LLaMA-Alpaca)
- [GPT-4 Generated Data (en&zh)](https://github.com/Instruction-Tuning-with-GPT-4/GPT-4-LLM)
- [Open Assistant (multilingual)](https://huggingface.co/datasets/OpenAssistant/oasst1)
- [Self-cognition (zh)](data/self_cognition.json)
- [ShareGPT (zh)](https://huggingface.co/datasets/QingyiSi/Alpaca-CoT/tree/main/Chinese-instruction-collection)
- [RefGPT (zh)](https://github.com/sufengniu/RefGPT)
- [Guanaco Dataset (multilingual)](https://huggingface.co/datasets/JosephusCheung/GuanacoDataset)
- [BELLE 2M (zh)](https://huggingface.co/datasets/BelleGroup/train_2M_CN)
- [BELLE 1M (zh)](https://huggingface.co/datasets/BelleGroup/train_1M_CN)
- [BELLE 0.5M (zh)](https://huggingface.co/datasets/BelleGroup/train_0.5M_CN)
- [BELLE Dialogue 0.4M (zh)](https://huggingface.co/datasets/BelleGroup/generated_chat_0.4M)
- [BELLE School Math 0.25M (zh)](https://huggingface.co/datasets/BelleGroup/school_math_0.25M)
- [BELLE Multiturn Chat 0.8M (zh)](https://huggingface.co/datasets/BelleGroup/multiturn_chat_0.8M)
- [Firefly 1.1M (zh)](https://huggingface.co/datasets/YeungNLP/firefly-train-1.1M)
- [LIMA (en)](https://huggingface.co/datasets/GAIR/lima)
- [CodeAlpaca 20k (en)](https://huggingface.co/datasets/sahil2801/CodeAlpaca-20k)
- [Alpaca CoT (multilingual)](https://huggingface.co/datasets/QingyiSi/Alpaca-CoT)
- [Web QA (zh)](https://huggingface.co/datasets/suolyer/webqa)
- [UltraChat (en)](https://github.com/thunlp/UltraChat)
- [WebNovel (zh)](https://huggingface.co/datasets/zxbsmk/webnovel_cn)
- For reward modelling:
- [HH-RLHF (en)](https://huggingface.co/datasets/Anthropic/hh-rlhf)
- [Open Assistant (multilingual)](https://huggingface.co/datasets/OpenAssistant/oasst1)
- [GPT-4 Generated Data (en&zh)](https://github.com/Instruction-Tuning-with-GPT-4/GPT-4-LLM)
Please refer to [data/README.md](data/README.md) for details.
Some datasets require confirmation before using them, so we recommend logging in with your Hugging Face account using these commands.
```bash
pip install --upgrade huggingface_hub
huggingface-cli login
```
## Fine-Tuning Methods
Our script now supports the following fine-tuning methods:
- [LoRA](https://arxiv.org/abs/2106.09685)
- Fine-tuning the low-rank adapters of the model.
- [P-Tuning V2](https://github.com/THUDM/P-tuning-v2)
- Fine-tuning the prefix encoder of the model.
- [Freeze](https://arxiv.org/abs/2012.14913)
- Fine-tuning the MLPs in the last n blocks of the model.
- Full Tuning
- Fine-tuning all the parameters of the model.
## Requirement
- Python 3.8+ and PyTorch 1.13.1+
- ð¤Transformers, Datasets, Accelerate, PEFT and TRL
- fire, protobuf, cpm-kernels and sentencepiece
- jieba, rouge-chinese and nltk (used at evaluation)
- gradio and matplotlib (used in train_web.py)
- uvicorn, fastapi and sse-starlette (used in api_demo.py)
And **powerful GPUs**!
## Getting Started
### Data Preparation (optional)
Please refer to `data/example_dataset` for checking the details about the format of dataset files. You can either use a single `.json` file or a [dataset loading script](https://huggingface.co/docs/datasets/dataset_script) with multiple files to create a custom dataset.
Note: please update `data/dataset_info.json` to use your custom dataset. About the format of this file, please refer to `data/README.md`.
### Dependence Installation (optional)
```bash
git lfs install
git clone https://github.com/hiyouga/ChatGLM-Efficient-Tuning.git
conda create -n chatglm_etuning python=3.10
conda activate chatglm_etuning
cd ChatGLM-Efficient-Tuning
pip install -r requirements.txt
```
If you want to enable the quantized LoRA (QLoRA) on the Windows platform, you will be required to install a pre-built version of `bitsandbytes` library, which supports CUDA 11.1 to 12.1.
```bash
pip install https://github.com/jllllll/bitsandbytes-windows-webui/releases/download/wheels/bitsandbytes-0.39.1-py3-none-win_amd64.whl
```
### All-in-one Web UI
```bash
CUDA_VISIBLE_DEVICES=0 python src/train_web.py
```
Currently the web UI only supports training on **a single GPU**.
### Fine-tuning with a Single GPU
```bash
CUDA_VISIBLE_DEVICES=0 python src/train_bash.py \
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
详细调试内容见文件内ReadMe文档 1、Chat GLM2模型下载 2、ChatGLM-Efficient-Tuning(Chat GLM版本1微调)框架 3、修改数据集 4、进行模型微调训练 5、进行模型微调测试 6、进行模型输出 7、ChatGLM2-6B-main加载微调后模型验证 注:环境自己搭建,我的用anadconda创建的,先搭pytorch的GPU版,再添加相关模块,本地部署教程多自行部署
资源推荐
资源详情
资源评论
收起资源包目录
ChatGLM2-6B(windows本地微调实践) (200个子文件)
启动.bat 34B
ReadMe.docx 901KB
.gitattributes 66B
cloudflare-tunnel-to-colab.ipynb 3KB
covid_doctor_7.jpg 196KB
alter_self_cognition_1.jpg 159KB
wechat.jpg 142KB
covid_doctor_9.jpg 141KB
ads_generation_3.jpg 137KB
ads_generation_2.jpg 91KB
ads_generation_5.jpg 86KB
covid_doctor_6.jpg 85KB
trainer_state.jpg 80KB
ads_generation_1.jpg 80KB
alter_self_cognition_2.jpg 78KB
covid_doctor_8.jpg 69KB
alter_self_cognition_3.jpg 66KB
ads_generation_6.jpg 60KB
covid_doctor_3.jpg 56KB
covid_doctor_2.jpg 55KB
covid_doctor_1.jpg 54KB
ads_generation_4.jpg 46KB
covid_doctor_4.jpg 38KB
covid_doctor_5.jpg 27KB
school_math_0.25M.json 125.57MB
refgpt_zh_50k_p1.json 97.68MB
refgpt_zh_50k_p2.json 79.35MB
sharegpt_zh_27k.json 77.9MB
comparison_data_v2.json 77.7MB
oaast_rm.json 53.48MB
alpaca_gpt4_data_en.json 41.37MB
alpaca_gpt4_data_zh.json 33.47MB
oaast_sft.json 32.68MB
comparison_gpt4_data_en.json 27MB
comparison_gpt4_data_zh.json 23.33MB
alpaca_data_en_52k.json 21.72MB
alpaca_data_zh_51k.json 17.94MB
lima.json 2.85MB
oaast_rm_zh.json 1.64MB
oaast_sft_zh.json 1.02MB
lwc_cognition.json 18KB
self_cognition.json 18KB
dataset_info.json 6KB
examples.json 1KB
LICENSE 11KB
README.md 19KB
README_zh.md 19KB
covid_doctor.md 9KB
ads_generation.md 6KB
alter_self_cognition.md 5KB
README.md 2KB
README_zh.md 1KB
locales.py 13KB
trainer.py 10KB
runner.py 8KB
loader.py 8KB
preprocess.py 7KB
collator.py 6KB
parser.py 6KB
misc.py 5KB
sft.py 5KB
app.py 4KB
stream_chat.py 4KB
trainer.py 4KB
data_args.py 4KB
utils.py 4KB
loader.py 4KB
adapter.py 4KB
workflow.py 4KB
hh_rlhf_en.py 4KB
finetuning_args.py 3KB
model_args.py 3KB
callbacks.py 3KB
workflow.py 3KB
belle_multiturn.py 3KB
chat.py 3KB
workflow.py 3KB
ultra_chat.py 3KB
trainer.py 2KB
trainer.py 2KB
common.py 2KB
eval.py 2KB
save_and_load.py 2KB
metric.py 2KB
protocol.py 2KB
translate_hh_rlhf.py 2KB
setup.py 2KB
top.py 2KB
ploting.py 2KB
convert_comparison.py 2KB
generating_args.py 2KB
utils.py 2KB
chatbot.py 2KB
interface.py 2KB
example_dataset.py 1KB
infer.py 1KB
cli_demo.py 1KB
manager.py 1KB
web_demo.py 1KB
export.py 861B
共 200 条
- 1
- 2
资源评论
芷水无棱
- 粉丝: 2047
- 资源: 36
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功