> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monostate.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 命令结构

> 理解 AITraining CLI 语法

# 命令结构

AITraining CLI 对所有命令遵循一致的模式。

## 基本语法

```bash theme={null}
aitraining <command> [options]
```

## 可用命令

| 命令                      | 描述                                          |
| ----------------------- | ------------------------------------------- |
| `llm`                   | 训练大语言模型 (LLMs)                              |
| `chat`                  | 启动聊天界面进行推理                                  |
| `api`                   | 启动训练 API 服务器                                |
| `text-classification`   | 训练文本分类模型                                    |
| `text-regression`       | 训练文本回归模型                                    |
| `image-classification`  | 训练图像分类模型                                    |
| `image-regression`      | 训练图像回归模型                                    |
| `token-classification`  | 训练 NER/标记分类                                 |
| `seq2seq`               | 训练序列到序列模型                                   |
| `tabular`               | 训练表格数据模型                                    |
| `sentence-transformers` | 训练句子嵌入模型                                    |
| `object-detection`      | 训练目标检测模型                                    |
| `vlm`                   | 训练视觉-语言模型                                   |
| `extractive-qa`         | 训练抽取式 QA 模型                                 |
| `tools`                 | 实用工具：`merge-llm-adapter`、`convert_to_kohya` |
| `setup`                 | 初始设置和配置                                     |
| `spacerunner`           | 在 Hugging Face Spaces 上运行训练                 |

<Note>
  **SpaceRunner 要求**：`spacerunner` 命令需要指定 `--project-name`、`--script-path`、`--username`、`--token` 和 `--backend`。
</Note>

## 获取帮助

### 通用帮助

```bash theme={null}
aitraining --help
```

### 命令特定帮助

```bash theme={null}
aitraining llm --help
```

### 训练器特定帮助

对于 LLM 训练，查看特定训练器的参数：

```bash theme={null}
aitraining llm --trainer sft --help
aitraining llm --trainer dpo --help
aitraining llm --trainer orpo --help
aitraining llm --trainer ppo --help
```

或使用预览模式：

```bash theme={null}
aitraining llm --preview-trainer dpo --help
```

## 全局选项

这些选项是真正的全局选项（在顶层工作）：

| 选项                | 描述            |
| ----------------- | ------------- |
| `--help`, `-h`    | 显示帮助消息        |
| `--version`, `-v` | 显示版本          |
| `--config`        | 从 YAML 配置文件加载 |

<Note>
  `--backend` 选项在大多数训练命令上可用，但按命令注册，不是全局的。有关后端详细信息，请参阅[全局选项](/cli/global-options)。
</Note>

## 配置文件使用

使用 YAML 配置而不是命令行参数：

```bash theme={null}
aitraining --config training_config.yaml
```

## 示例

### 基本 LLM 训练

```bash theme={null}
aitraining llm --train \
  --model google/gemma-3-270m \
  --data-path ./data \
  --project-name my-model \
  --trainer sft
```

### 使用 LoRA

```bash theme={null}
aitraining llm --train \
  --model meta-llama/Llama-3.2-1B \
  --data-path ./data \
  --project-name my-lora-model \
  --peft \
  --lora-r 16 \
  --lora-alpha 32
```

### 文本分类

```bash theme={null}
aitraining text-classification \
  --model bert-base-uncased \
  --data-path ./reviews.csv \
  --text-column text \
  --target-column label \
  --project-name sentiment-model
```

## 交互模式

不带参数运行以启动交互式向导：

```bash theme={null}
aitraining
```

或显式地：

```bash theme={null}
aitraining llm --interactive
```

## 下一步

<CardGroup cols={2}>
  <Card title="LLM 训练" href="/cli/llm-training">
    LLM 训练完整指南
  </Card>

  <Card title="YAML 配置" href="/cli/yaml-configs">
    使用配置文件
  </Card>
</CardGroup>
