AutoTrain 文档

AutoTrain API

您正在查看的是需要从源码安装。如果您希望使用常规的 pip 安装,请查看最新的稳定版本 (v0.8.24)。
Hugging Face's logo
加入 Hugging Face 社区

并获得增强的文档体验

开始使用

AutoTrain API

借助 AutoTrain API,您可以运行自己的 AutoTrain 实例,并使用它在 Hugging Face Spaces 基础设施上训练模型(本地训练即将推出)。此 API 专为与 AutoTrain 兼容的模型和数据集设计,它提供了一个简单的接口,只需最少的配置即可训练模型。

快速入门

要开始使用 AutoTrain API,您只需按照“本地运行”部分中的讨论安装 autotrain-advanced,然后运行 autotrain app 命令即可。

$ autotrain app --port 8000 --host 127.0.0.1

然后,您可以在 http://127.0.0.1:8000/docs 访问 API 参考文档。

用法示例

curl -X POST "http://127.0.0.1:8000/api/create_project" \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer hf_XXXXX" \
     -d '{
           "username": "abhishek",
           "project_name": "my-autotrain-api-model",
           "task": "llm:orpo",
           "base_model": "meta-llama/Meta-Llama-3-8B-Instruct",
           "hub_dataset": "argilla/distilabel-capybara-dpo-7k-binarized",
           "train_split": "train",
           "hardware": "spaces-a10g-large",
           "column_mapping": {
               "text_column": "chosen",
               "rejected_text_column": "rejected",
               "prompt_text_column": "prompt"
           },
           "params": {
               "block_size": 1024,
               "model_max_length": 4096,
               "max_prompt_length": 512,
               "epochs": 1,
               "batch_size": 2,
               "lr": 0.00003,
               "peft": true,
               "quantization": "int4",
               "target_modules": "all-linear",
               "padding": "right",
               "optimizer": "adamw_torch",
               "scheduler": "linear",
               "gradient_accumulation": 4,
               "mixed_precision": "fp16",
               "chat_template": "chatml"
           }
         }'
< > 在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.