| |
| title: "Command Line Interface (CLI)" |
| format: |
| html: |
| toc: true |
| toc-expand: 2 |
| toc-depth: 3 |
| execute: |
| enabled: false |
| |
|
|
| The Axolotl CLI provides a streamlined interface for training and fine-tuning large language models. This guide covers |
| the CLI commands, their usage, and common examples. |
|
|
|
|
| |
|
|
| All Axolotl commands follow this general structure: |
|
|
| ```bash |
| axolotl <command> [config.yml] [options] |
| ``` |
|
|
| The config file can be local or a URL to a raw YAML file. |
|
|
| |
|
|
| |
|
|
| Downloads example configurations and deepspeed configs to your local machine. |
|
|
| ```bash |
| |
| axolotl fetch examples |
|
|
| |
| axolotl fetch deepspeed_configs |
|
|
| |
| axolotl fetch examples |
| ``` |
|
|
| |
|
|
| Preprocesses and tokenizes your dataset before training. This is recommended for large datasets. |
|
|
| ```bash |
| |
| axolotl preprocess config.yml |
|
|
| |
| CUDA_VISIBLE_DEVICES="0" axolotl preprocess config.yml |
|
|
| |
| axolotl preprocess config.yml |
|
|
| |
| axolotl preprocess config.yml |
| ``` |
|
|
| Configuration options: |
|
|
| ```yaml |
| dataset_prepared_path: Local folder for saving preprocessed data |
| push_dataset_to_hub: HuggingFace repo to push preprocessed data (optional) |
| ``` |
|
|
| |
|
|
| Trains or fine-tunes a model using the configuration specified in your YAML file. |
|
|
| ```bash |
| |
| axolotl train config.yml |
|
|
| |
| axolotl train config.yml \ |
| |
| |
| |
|
|
| |
| axolotl train config.yml |
|
|
| |
| axolotl train config.yml |
| ``` |
|
|
| It is possible to run sweeps over multiple hyperparameters by passing in a sweeps config. |
|
|
| ```bash |
| |
| axolotl train config.yml |
| ``` |
|
|
| Example sweep config: |
| ```yaml |
| _: |
| |
| - load_in_8bit: false |
| load_in_4bit: false |
| adapter: lora |
| - load_in_8bit: true |
| load_in_4bit: false |
| adapter: lora |
|
|
| |
| learning_rate: [0.0003, 0.0006] |
| lora_r: |
| - 16 |
| - 32 |
| lora_alpha: |
| - 16 |
| - 32 |
| - 64 |
| ``` |
|
|
|
|
|
|
| |
|
|
| Runs inference using your trained model in either CLI or Gradio interface mode. |
|
|
| ```bash |
| |
| axolotl inference config.yml |
|
|
| |
| axolotl inference config.yml |
|
|
| |
| axolotl inference config.yml |
| |
|
|
| |
| cat prompt.txt | axolotl inference config.yml \ |
| |
| ``` |
|
|
| |
|
|
| Merges trained LoRA adapters into the base model. |
|
|
| ```bash |
| |
| axolotl merge-lora config.yml |
|
|
| |
| axolotl merge-lora config.yml |
|
|
| |
| CUDA_VISIBLE_DEVICES="" axolotl merge-lora config.yml |
| ``` |
|
|
| Configuration options: |
|
|
| ```yaml |
| gpu_memory_limit: Limit GPU memory usage |
| lora_on_cpu: Load LoRA weights on CPU |
| ``` |
|
|
| |
|
|
| Merges sharded FSDP model checkpoints into a single combined checkpoint. |
|
|
| ```bash |
| |
| axolotl merge-sharded-fsdp-weights config.yml |
| ``` |
|
|
| |
|
|
| Evaluates a model's performance using metrics specified in the config. |
| |
| ```bash |
| # Basic evaluation |
| axolotl evaluate config.yml |
| ``` |
| |
| ### lm-eval |
| |
| Runs LM Evaluation Harness on your model. |
| |
| ```bash |
| # Basic evaluation |
| axolotl lm-eval config.yml |
| ``` |
| |
| Configuration options: |
| |
| ```yaml |
| # List of tasks to evaluate |
| lm_eval_tasks: |
| - arc_challenge |
| - hellaswag |
| lm_eval_batch_size: # Batch size for evaluation |
| output_dir: # Directory to save evaluation results |
| ``` |
| |
| ## Legacy CLI Usage |
| |
| While the new Click-based CLI is preferred, Axolotl still supports the legacy module-based CLI: |
| |
| ```bash |
| # Preprocess |
| python -m axolotl.cli.preprocess config.yml |
| |
| # Train |
| accelerate launch -m axolotl.cli.train config.yml |
| |
| # Inference |
| accelerate launch -m axolotl.cli.inference config.yml \ |
| --lora_model_dir="./outputs/lora-out" |
| |
| # Gradio interface |
| accelerate launch -m axolotl.cli.inference config.yml \ |
| --lora_model_dir="./outputs/lora-out" --gradio |
| ``` |
| |
| ::: {.callout-important} |
| When overriding CLI parameters in the legacy CLI, use same notation as in yaml file (e.g., `--lora_model_dir`). |
| |
| **Note:** This differs from the new Click-based CLI, which uses dash notation (e.g., `--lora-model-dir`). Keep this in mind if you're referencing newer documentation or switching between CLI versions. |
| ::: |
|
|
| |
|
|
| Axolotl supports running training and inference workloads on Modal cloud infrastructure. This is configured using a |
| cloud YAML file alongside your regular Axolotl config. |
|
|
| |
|
|
| Create a cloud config YAML with your Modal settings: |
|
|
| ```yaml |
| |
| provider: modal |
| gpu: a100 |
| gpu_count: 1 |
| timeout: 86400 |
| branch: main |
|
|
| volumes: |
| - name: axolotl-cache |
| mount: /workspace/cache |
| - name: axolotl-data |
| mount: /workspace/data |
| - name: axolotl-artifacts |
| mount: /workspace/artifacts |
|
|
| env: |
| - WANDB_API_KEY |
| - HF_TOKEN |
| ``` |
|
|
| |
|
|
| Commands that support the |
|
|
| ```bash |
| |
| axolotl preprocess config.yml |
|
|
| |
| axolotl train config.yml |
|
|
| |
| axolotl train config.yml |
|
|
| |
| axolotl lm-eval config.yml |
| ``` |
|
|
| |
|
|
| ```yaml |
| provider: |
| gpu: |
| gpu_count: |
| memory: |
| timeout: |
| timeout_preprocess: |
| branch: |
| docker_tag: |
| volumes: |
| env: |
| secrets: |
| ``` |
|
|