AutoTrain 文档
本地训练快速入门指南
您正在查看的是需要从源码安装。如果您想使用常规的 pip 安装,请查看最新的稳定版本(v0.8.24)。
加入 Hugging Face 社区
并获得增强的文档体验
开始使用
本地训练快速入门指南
本快速入门指南适用于本地安装和使用。如果您想在 Hugging Face Spaces 上使用 AutoTrain,请参阅 AutoTrain on Hugging Face Spaces 部分。
您可以使用 pip 安装 AutoTrain Advanced
$ pip install autotrain-advanced
建议在虚拟环境中安装 autotrain-advanced,以避免与其他包发生冲突。注意:AutoTrain 不会安装 pytorch、torchaudio、torchvision 或任何其他大型依赖。您需要单独安装它们。
$ conda create -n autotrain python=3.10
$ conda activate autotrain
$ pip install autotrain-advanced
$ conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
$ conda install -c "nvidia/label/cuda-12.1.0" cuda-nvcc
$ conda install xformers -c xformers
$ python -m nltk.downloader punkt
$ pip install flash-attn --no-build-isolation # if you want to use flash-attn
$ pip install deepspeed # if you want to use deepspeed
运行 AutoTrain 用户界面 (UI)
要在本地运行 autotrain 应用,您可以使用以下命令
$ export HF_TOKEN=your_hugging_face_write_token
$ autotrain app --host 127.0.0.1 --port 8000
这将在 http://127.0.0.1:8000
上启动应用。
使用 AutoTrain 命令行界面 (CLI)
也可以使用命令行界面 (CLI)
$ export HF_TOKEN=your_hugging_face_write_token
$ autotrain --help
这将显示可以使用的 CLI 命令
usage: autotrain <command> [<args>]
positional arguments:
{
app,
llm,
setup,
api,
text-classification,
text-regression,
image-classification,
tabular,
spacerunner,
seq2seq,
token-classification
}
commands
options:
-h, --help show this help message and exit
--version, -v Display AutoTrain version
--config CONFIG Optional configuration file
For more information about a command, run: `autotrain <command> --help`
建议在使用 CLI 进行训练时,只使用 autotrain --config CONFIG_FILE
命令。
最终用户会感兴趣的 autotrain 命令是
app
: 启动 AutoTrain UIllm
: 训练一个语言模型text-classification
: 训练一个文本分类模型text-regression
: 训练一个文本回归模型image-classification
: 训练一个图像分类模型tabular
: 训练一个表格数据模型spacerunner
: 使用 SpaceRunner 训练任何自定义模型seq2seq
: 训练一个序列到序列模型token-classification
: 训练一个词元分类模型
注意:如果您使用首选的 autotrain --config CONFIG_FILE
命令来训练模型,则不需要上述命令。