AutoTrain 文档

AutoTrain API

您正在查看 main 版本,该版本需要从源代码安装。如果您想要常规的 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 上更新