跳转到主要内容

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 包时会包含 AITraining CLI。

安装

使用 pip

pip install aitraining torch torchvision torchaudio

使用 uv(推荐)

uv pip install aitraining torch torchvision torchaudio

验证安装

检查 CLI 是否正常工作:
aitraining --version
您应该会看到版本号。

首次运行

不带参数运行 aitraining 会启动交互式向导:
aitraining
这将显示 Monostate 横幅并启动配置向导。

GPU 设置

对于 GPU 训练,请确保已安装 CUDA 且 PyTorch 可以检测到您的 GPU:
import torch
print(torch.cuda.is_available())  # Should print True
print(torch.cuda.device_count())  # Number of GPUs

Apple Silicon (M1/M2/M3)

在 Apple Silicon Mac 上,MPS 会自动使用:
import torch
print(torch.backends.mps.is_available())  # Should print True

环境变量

常见环境变量:
变量描述
HF_TOKENHugging Face token,用于私有模型/数据集
WANDB_API_KEYWeights & Biases API 密钥,用于日志记录
CUDA_VISIBLE_DEVICES指定要使用的 GPU
在运行训练之前设置这些变量:
export HF_TOKEN="your_token_here"
export WANDB_API_KEY="your_key_here"

下一步

命令结构

学习 CLI 命令语法

LLM 训练

训练语言模型