TigerBot 是一个多语言多任务的大规模语言模型(LLM)。
![]() |
23 hours ago | |
---|---|---|
apps | 2 weeks ago | |
docs | 1 month ago | |
image | 23 hours ago | |
opencompass | 1 week ago | |
other_infer | 1 day ago | |
train | 1 month ago | |
.gitignore | 2 months ago | |
.project | 3 months ago | |
.pydevproject | 3 months ago | |
LICENSE | 3 months ago | |
README.md | 23 hours ago | |
README_en.md | 4 days ago | |
flash_attention.py | 3 weeks ago | |
infer.py | 3 days ago | |
requirements.txt | 2 weeks ago |
A cutting-edge foundation for your very own LLM.
以世界级的基础大模型,贡献于中国式的创新。
🌐 TigerBot • 🤗 Hugging Face • 💻ModelScope
中文 | English
## 最新发布 - [9/15/2023] Tigerbot-70b-chat(v2)和Tigerbot-13b-chat(v3)更新发布: [[tigerbot-70b-chat](https://huggingface.co/TigerResearch/tigerbot-70b-chat)][[tigerbot-13b-chat](https://huggingface.co/TigerResearch/tigerbot-13b-chat)] - 用更少但更高质量的数据,约5M指令完成数据,覆盖100+任务类型,符合自然用户分布; - 用10K人类标注数据进行多维度对齐,包括:事实性,创造性,丰富性,安全性和格式等; - 在10+项基准评测中,中英文综合能力均超过上一版本和Llama-2,达到SOTA. 
[9/06/2023] Tigerbot-70b发布,继续开源和免费商用: [paper][tigerbot-70b-base][tigerbot-70b-chat]:fire:
[8/25/2023] TigerBot更新13b-base模型: [huggingface][测评]
[8/21/2023] TigerBot更新发布7b和13b base/chat模型: [测评]
[8/19/2023] TigerBot推理(tigerbot.com和tigerbot-api)启用 TGI,达到3x QPS和2x 响应速度。
https://github.com/TigerResearch/TigerBot/assets/32117316/0a8c11b9-6a10-4e37-80e8-45b482e76c51
[8/08/2023] TigerBot 2023.08 (V3) release: 虎博很高兴的发布TigerBot-13B大模型,在Llama-2的基础上以虎博积累的技术和数据继续训练,不但保持了Llama-2出色的英文能力,更是在中文能力上填补了Llama-2的不足,各项主流中文任务中超过Llama-2的49%,在开源同类模型中具有竞争力。:fire: [paper]
python infer.py --model_path TigerResearch/tigerbot-13b-chat
使用。[测评][huggingface][8/03/2023] TigerBot 兼容 OpenAI 接口。[tigerbot-api]
[7/26/2023] TigerBot 开放 search-api [tigerbot-api]
[7/08/2023] TigerBot 2023.07 (V2) release [paper] :fire:
tigerbot-7b-base (v2), 在 1.5TB 高质量数据上充分预训练(千卡耗时 4 周,算力成本~ 300 万),在中英文公开数据测评优于 bloom/llama 同等模型 15-30%;[测评][huggingface]
tigerbot-7b-sft (v2), 在 base-v2 基础上微调的 sft-v2 在 2000 万/20G 高质量清洗和配比的数据上充分训练,在 9 项公开语料测评上优于 sft-v1 9.3%;[测评][huggingface]
新模型可通过以下代码加载:
import transformers
# 下载过旧版的用户需要指定`force_download=True`避免使用旧版缓存
model_sft = transformers.AutoModelForCausalLM.from_pretrained('TigerResearch/tigerbot-7b-sft', force_download=True)
model_base = transformers.AutoModelForCausalLM.from_pretrained('TigerResearch/tigerbot-7b-base', force_download=True)
tigerbot 开启搜索模式,对接主流中英文搜索引擎,和结构化工具(如天气,股市,计算器等),打开 LLM+search 的应用场景,同时开放 chat-api with internet search switch;[TigerBot with search mode (default off) :earth_asia:][paper]
tigerbot 开启流式生成模式,同时开放 chat-api with streaming switch; [TigerBot][TigerBot-API]
tigerbot-api 全新升级,开放 LLM 应用开发常用的 api 工具,包括:LLM (chat, plugin, finetune), text (embedding, summarization, pdf2text), vision (text2image)。[TigerBot-API]
[6/27/2023] PEFT TigerBot with QLoRA: 在单张 3090 上使用 qlora 微调 tigerbot-7b-sft,加速 16 倍,和/或减少 GPU3/4,同时防止了对下游数据的过拟合。[code] [paper] [model]
[6/26/2023] TigerBot now is on desktop! 使用 TigerBot 和 Svelte 框架制作的聊天机器人,感谢 @SaraiQX !
[6/20/2023] Tigerbot 的云端 api 如何在 langchian 中替代 openai 来应用(sample code) 感谢 @wordweb !
TigerBot 是一个多语言多任务的大规模语言模型(LLM)。根据 OpenAI InstructGPT 论文在公开 NLP 数据集上的自动评测,TigerBot-7B 达到 OpenAI 同样大小模型的综合表现的 96%,并且这只是我们的 MVP,在此我们将如下探索成果开源:
我们在 BLOOM 基础上,在模型架构和算法上做了如下优化:
conda create --name tigerbot python=3.8
conda activate tigerbot
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
git clone https://github.com/TigerResearch/TigerBot
cd TigerBot
pip install -r requirements.txt
Model | Version | Architecture | Disk size (GB) | Note |
---|---|---|---|---|
tigerbot-70b-base | v1 [huggingface][modelscope] | llama-2 | 129 | From llama-2-70b weights |
tigerbot-70b-chat | v2 [huggingface][modelscope] | llama-2 | 129 | From tigerbot-70b-base v1 |
v1 [huggingface] | llama-2 | 129 | From tigerbot-70b-base v1 | |
tigerbot-70b-chat-4bit | v2 [huggingface] | llama-2 | 37 | From tigerbot-70b-chat v2 |
v1 [huggingface] | llama-2 | 37 | From tigerbot-70b-chat v1 | |
tigerbot-13b-base | v2 [huggingface][modelscope] | llama-2 | 26.6 | From llama-2-13b weights |
v1 [huggingface] | llama-2 | 26.6 | From llama-2-13b weights | |
tigerbot-13b-chat | v3 [huggingface][modelscope] | llama-2 | 26.6 | From tigerbot-13b-base v2 |
v2 [huggingface] | llama-2 | 26.6 | From tigerbot-13b-base v2 | |
v1 [huggingface] | llama-2 | 26.6 | From tigerbot-13b-base v1 | |
tigerbot-13b-chat-8bit | v2 [huggingface] | llama-2 | 18.5 | From tigerbot-13b-chat v2 |
tigerbot-13b-chat-4bit | v2 [huggingface] | llama-2 | 11.5 | From tigerbot-13b-chat v2 |
tigerbot-7b-base | v3 [huggingface][modelscope] | llama-2 | 13.9 | From llama-2-7b weights |
v2 [huggingface] | bloom | 16.2 | From bloom weights | |
v1 [huggingface] | bloom | 16.2 | From bloom weights | |
tigerbot-7b-chat | v3 [huggingface][modelscope] | llama-2 | 13.9 | From tigerbot-7b-base v3 |
v2 [huggingface] | bloom | 16.2 | From tigerbot-7b-base v2 | |
v1 [huggingface] | bloom | 16.2 | From tigerbot-7b-base v1 | |
tigerbot-7b-chat-8bit | v3 [huggingface] | llama-2 | 10.8 | From tigerbot-7b-chat v3 |
tigerbot-7b-chat-4bit | v3 [huggingface] | llama-2 | 6.5 | From tigerbot-7b-chat v3 |
tigerbot-180b-sft | v1 [huggingface] | bloom | 347.6 | From bloom weights |
启动训练前安装 DeepSpeed
git clone git@github.com:microsoft/DeepSpeed.git
cd DeepSpeed
rm -rf build
TORCH_CUDA_ARCH_LIST="8.0" DS_BUILD_CPU_ADAM=1 DS_BUILD_UTILS=1 pip install . \
--global-option="build_ext" --global-option="-j8" --no-cache -v \
--disable-pip-version-check 2>&1 | tee build.log
TORCH_CUDA_ARCH_LIST 根据你运行的 GPU 架构做调整,获取 TORCH_CUDA_ARCH_LIST
CUDA_VISIBLE_DEVICES=0 python -c "import torch; print(torch.cuda.get_device_capability())"
如果返回的结果是(8, 0),那么 TORCH_CUDA_ARCH_LIST="8.0"
启动tigerbot-7b
训练至少需要 1 x A100 (40GB), 启动tigerbot-180b
至少需要 16 x A100 (40GB)
deepspeed \
--include="localhost:0,1,2,3" \
./train_clm.py \
--deepspeed ./ds_config/ds_config_zero3.json \
--model_name_or_path TigerResearch/tigerbot-7b-base \
--dataset_name TigerResearch/dev_pretrain \
--do_train \
--output_dir ./ckpt-clm \
--overwrite_output_dir \
--preprocess_num_workers 8 \
--num_train_epochs 5 \
--learning_rate 1e-5 \
--evaluation_strategy steps \
--eval_steps 10 \
--bf16 True \
--save_strategy steps \
--save_steps 10 \
--save_total_limit 2 \
--logging_steps 10 \
--tf32 True \
--per_device_train_batch_size 2 \
--per_device_eval_batch_size 2
启动tigerbot-7b
训练至少需要 1 x A100 (40GB), 启动tigerbot-180b
至少需要 16 x A100 (40GB)
deepspeed \
--include="localhost:0,1,2,3" \
./train_sft.py \
--deepspeed ./ds_config/ds_config_zero3.json \
--model_name_or_path TigerResearch/tigerbot-7b-base \
--dataset_name TigerResearch/dev_sft \
--do_train \
--output_dir ./ckpt-sft \
--overwrite_output_dir \
--preprocess_num_workers 8 \
--num_train_epochs 5 \
--learning_rate 1e-5 \
--evaluation_strategy steps \
--eval_steps 10 \
--bf16 True \
--save_strategy steps \
--save_steps 10 \
--save_total_limit 2 \
--logging_steps 10 \
--tf32 True \
--per_device_train_batch_size 2 \
--per_device_eval_batch_size 2
你可以在该命令行中进行模型推理对话,输入 clear
可以清空对话历史,输入 exit
终止推理对话。
启动命令行模型推理命如下:
tigerbot-7b-sft
推理可在 1 张 RTX3090 上进行, tigerbot-7b-sft-4bit-128g
量化版本模型需要参照量化模块的推理代码。
CUDA_VISIBLE_DEVICES=0 python infer.py --model_path ${MODEL_DIR}
如果要启用流式输出,请将infer.py
换成infer_stream.py
,输出将从一次性输出变成逐句输出。
CUDA_VISIBLE_DEVICES=0 python ./other_infer/infer_stream.py --model_path ${MODEL_DIR}
如果要启用 web 界面进行问答,将web_demo.py
第 12 行的 model_path 对应的模型路径改成你的模型所在路径即可,然后运行下面的命令启用 web 界面。
CUDA_VISIBLE_DEVICES=0 python ./apps/web_demo.py
tigerbot-7b-base
则用续写(非问答)的推理代码。
CUDA_VISIBLE_DEVICES=0 python ./other_infer/infer_pretrain.py --model_path ${PRETRAIN_MODEL_DIR}
tigerbot-180b-sft
推理可在 5 张 A100(80G)上进行
CUDA_VISIBLE_DEVICES=0,1,2,3,4 python infer.py --model_path ${MODEL_DIR}
如果要启用 api,需要先安装 fastapi,将 193 行的模型路径改成你的,然后运行服务。
pip install "fastapi[all]"
python ./apps/api.py
之后可以测试客户端通过 web 服务调用 api
python ./apps/client.py
也可以客户端通过 web 服务异步调用 api
python ./apps/async_client.py
也可以通过之前的 web 页面来调用 web 服务生成文字。
python ./apps/web_api_demo.py
ev
此方式为在线量化与推理
CUDA_VISIBLE_DEVICES=0 python other_infer/quant_infer.py --model_path ${MODEL_DIR} --wbit 8
动态量化准确率会低于使用gptq等量化好的模型,我们使用AutoGPTQ实现量化:
# 安装auto-gptq
pip install auto-gptq
# 启动推理
CUDA_VISIBLE_DEVICES=0 python other_infer/gptq_infer.py --model_path ${MODEL_PATH}
MODEL_PATH
为量化模型路径,如 TigerResearch/tigerbot-13b-chat-8bit
使用exllama加载[TigerResearch/tigerbot-13b-chat-4bit]进行推理,推理速度加快
# 安装exllama_lib
pip install exllama_lib@git+https://github.com/taprosoft/exllama.git
# 启动推理
CUDA_VISIBLE_DEVICES=0 python other_infer/exllama_infer.py --model_path ${MODEL_PATH}
MODEL_PATH
为量化模型路径,如 TigerResearch/tigerbot-13b-chat-4bit
使用以上量化方式,请将transformers、bitsandbytes等包升级到最新版(目前transformers==4.33.1和bitsandbytes==0.41.1可以正常使用)
pip install -U transformers bitsandbytes
如果遇到安装autogptq等库编译失败等问题,可以尝试以下代码
SETUPTOOLS_USE_DISTUTILS=stdlib pip install -v .
我们使用经典的中英文benchmark自动评测,共13项任务,涵盖代码,常识推理,阅读理解,数学,自然语言理解等。我们基于opencompass建立自动评测体系(感谢@opencompass)
# 安装
cd opencompass
pip install -e .
# 下载数据集到 data/ 处
wget https://github.com/InternLM/opencompass/releases/download/0.1.1/OpenCompassData.zip
unzip OpenCompassData.zip
#运行测评任务:
CUDA_VISIBLE_DEVICES=0,1,2 python run.py configs/eval_tigerbot_13b.py -w outputs/tigerbot-13b-base --max-partition-size 30000
总分为各类任务的平均分,每类任务包括英文或者中文任务。各类任务得分参考 模型测评细分项
chat模型测评结果
base模型测评结果
模型历史版本测评
base模型测评结果
chat模型测评结果
V1版SFT和base模型测评结果
在 7 项英文 NLP 任务上,对 SFT 模型进行测评,以 OpenAI-InstructGPT-6B-SFT 为基准,归一化并平均各模型的得分,结果如下:
在 7 项英文 NLP 任务和 4 项中文 NLP 任务上,对 Pretrain 模型进行测评,以 bloom-7b1 为基准,归一化并平均各模型的得分,结果如下:
| 类型 | 磁盘占用 | 来源 | | ---------- | -------- | ---- | | 中文书籍 | 12G | 自研 | | 中文互联网 | 25G | 自研 | | 中文百科 | 19G | 自研 | | 英文书籍 | 22G | 开源 | | 英文互联网 | 6.9G | 开源 | | 英文百科 | 22G | 开源 | | 总量 | 106G | |
cong.fu@tigerbot.com
wei.cai@tigerbot.com
致谢
局限性与免责声明
当前模型可能存在生成幻觉、误导性、或歧视性内容。请谨慎使用 TigerBot 系列模型生成的内容,请勿将生成的有害内容进行传播。
如需将模型公开使用或者商用,模型服务所产生的不良影响或者有害言论由服务方负责,本项目开发者不承担任何因使用本项目(包含但不限于数据、模型、代码等)导致的危害或损失。