
以 BitTorrent 风格在家运行大语言模型。
微调与推理速度比卸载快高达 10 倍
使用分布式 Llama 3.1(高达 405B)、Mixtral(8x22B)、Falcon(40B+)或 BLOOM(176B)生成文本,并针对您的任务进行微调 — 直接在您的台式机或 Google Colab 上即可完成:
from transformers import AutoTokenizer
from petals import AutoDistributedModelForCausalLM
# 选择 https://health.petals.dev 上可用的任意模型
model_name = "meta-llama/Meta-Llama-3.1-405B-Instruct"
# 连接到托管模型层的分布式网络
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoDistributedModelForCausalLM.from_pretrained(model_name)
# 像在本地计算机上一样运行模型
inputs = tokenizer("A cat sat", return_tensors="pt")["input_ids"]
outputs = model.generate(inputs, max_new_tokens=5)
print(tokenizer.decode(outputs[0])) # A cat sat on a mat...
🦙 想运行 Llama? 请先申请访问权限获取其权重,然后在加载模型前在终端运行 huggingface-cli login。或者直接在我们的聊天机器人应用中试用。
🔏 隐私说明。 您的数据将在公共集群中借助其他人的帮助进行处理。了解更多关于隐私的信息请点击此处。对于敏感数据,您可以在信任的人之间建立私有集群。
💬 有任何问题? 欢迎在我们的 Discord 中联系我们!
Petals 是一个社区运行的系统 — 我们依赖于人们共享他们的 GPU。您可以帮助服务一个可用模型,或者从 🤗 Model Hub 托管一个新模型!
例如,以下是如何在您的 GPU 上托管 Llama 3.1 (405B) Instruct 的一部分:
🦙 想托管 Llama? 请先申请访问权限获取其权重,然后在加载模型前在终端运行 huggingface-cli login。
🐧 Linux + Anaconda。 对于 NVIDIA GPU 运行以下命令(或参考此指南配置 AMD GPU):
conda install pytorch pytorch-cuda=11.7 -c pytorch -c nvidia
pip install git+https://github.com/bigscience-workshop/petals
python -m petals.cli.run_server meta-llama/Meta-Llama-3.1-405B-Instruct
🪟 Windows + WSL。 请遵循我们 Wiki 上的此指南。
🐋 Docker。 对于 NVIDIA GPU 运行我们的 Docker 镜像(或参考此指南配置 AMD GPU):
sudo docker run -p 31330:31330 --ipc host --gpus all --volume petals-cache:/cache --rm \
learningathome/petals:main \
python -m petals.cli.run_server --port 31330 meta-llama/Meta-Llama-3.1-405B-Instruct
🍏 macOS + Apple M1/M2 GPU。 安装 Homebrew,然后运行以下命令:
brew install python
python3 -m pip install git+https://github.com/bigscience-workshop/petals
python3 -m petals.cli.run_server meta-llama/Meta-Llama-3.1-405B-Instruct
📚 了解更多(如何使用多个 GPU、开机自启动服务器等)
🔒 安全性。 托管服务器不会允许他人在您的计算机上运行自定义代码。了解更多信息请点击此处。
💬 有任何问题? 欢迎在我们的 Discord 中联系我们!
🏆 感谢您! 一旦您加载并托管了 10 个以上的模块,我们可以在集群监控器上显示您的名字或链接以示感谢。您可以使用 --public_name YOUR_NAME 来指定它们。
基础教程:
实用工具:
高级指南:
请参阅我们论文的 第 3.3 节。
请参阅关于贡献的常见问题。
Alexander Borzunov, Dmitry Baranchuk, Tim Dettmers, Max Ryabinin, Younes Belkada, Artem Chumachenko, Pavel Samygin, and Colin Raffel.
Petals: Collaborative Inference and Fine-tuning of Large Models.
Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 3: System Demonstrations). 2023.
@inproceedings{borzunov2023petals,
title = {Petals: Collaborative Inference and Fine-tuning of Large Models},
author = {Borzunov, Alexander and Baranchuk, Dmitry and Dettmers, Tim and Riabinin, Maksim and Belkada, Younes and Chumachenko, Artem and Samygin, Pavel and Raffel, Colin},
booktitle = {Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 3: System Demonstrations)},
pages = {558--568},
year = {2023},
url = {https://arxiv.org/abs/2209.01188}
}
Alexander Borzunov, Max Ryabinin, Artem Chumachenko, Dmitry Baranchuk, Tim Dettmers, Younes Belkada, Pavel Samygin, and Colin Raffel.
Distributed inference and fine-tuning of large language models over the Internet.
Advances in Neural Information Processing Systems 36 (2023).
@inproceedings{borzunov2023distributed,
title = {Distributed inference and fine-tuning of large language models over the {I}nternet},
author = {Borzunov, Alexander and Ryabinin, Max and Chumachenko, Artem and Baranchuk, Dmitry and Dettmers, Tim and Belkada, Younes and Samygin, Pavel and Raffel, Colin},
booktitle = {Advances in Neural Information Processing Systems},
volume = {36},
pages = {12312--12331},
year = {2023},
url = {https://arxiv.org/abs/2312.08361}
}
本项目是 BigScience 研究研讨会的一部分。