The Command-Line Interface (CLI) is a crucial feature in fairseq2, offering users a powerful and flexible way to interact with the framework.
With the CLI, you can quickly and easily execute tasks, customize recipes and configurations, and perform complex operations such as sweep runs and benchmarking.
# Get help about available commands
fairseq2-h
# Get help about a specific command group (e.g. recipe lm)
fairseq2lm-h
# Get help about a specific command (e.g. recipe lm::instruction_finetune)
fairseq2lminstruction_finetune-h
# List available configuration presets for a recipe (e.g. recipe lm::instruction_finetune)
fairseq2lminstruction_finetune--list-preset-configs
# Dump the default configuration for a recipe (e.g. recipe lm::instruction_finetune)
fairseq2lminstruction_finetune--dump-config
# Run a recipe with default settings (e.g. recipe lm::instruction_finetune)
fairseq2lminstruction_finetune<OUTPUT_DIR>
# Run a recipe with a custom config file (e.g. recipe lm::instruction_finetune)
fairseq2lminstruction_finetune<OUTPUT_DIR>--config-file<YOUR_CONFIG>.yaml
You can specify one or multiple YAML config files:
# Single config file
fairseq2lminstruction_finetune<OUTPUT_DIR>--config-fileconfig1.yaml
# Multiple config files (merged from left to right)
fairseq2lminstruction_finetune<OUTPUT_DIR>--config-filebase.yaml--config-fileoverride.yaml
Use set: and del: directives for more advanced configuration:
# Add a new configuration value
fairseq2lminstruction_finetune<OUTPUT_DIR>--configset:new_param=value
# Remove a configuration value
fairseq2lminstruction_finetune<OUTPUT_DIR>--configdel:unwanted_param
Sweep tags help organize different runs by creating subdirectories based on configuration values.
The default sweep tag will be generated with the format "ps_{preset}.ws_{world_size}.{hash}".
You can customize the sweep tag format with the --sweep-format argument:
# Use a custom sweep tag format
fairseq2lmpreference_finetune<OUTPUT_DIR>--config-fileconfig.yaml--sweep-format="lr_{optimizer.config.lr}/criterion_{criterion.name}"# If you don't want the sweep tag, you can use --no-sweep-dir
fairseq2lmpreference_finetune<OUTPUT_DIR>--config-fileconfig.yaml--no-sweep-dir
The following features are available in fairseq2 sweep tags generator:
fairseq2 provides commands to manage and inspect assets:
# List all available assets
fairseq2assetslist
# List assets filtered by type
fairseq2assetslist--typemodel
fairseq2assetslist--typedataset
fairseq2assetslist--typetokenizer
# Show details of a specific asset
fairseq2assetsshowllama3_1_8b_instruct
fairseq2 provides utilities for working with LLaMA models:
# Convert fairseq2 LLaMA checkpoints to reference format
fairseq2llamaconvert_checkpoint<MODEL_NAME><INPUT_DIR><OUTPUT_DIR>
# Write LLaMA configurations in Hugging Face format
fairseq2llamawrite_hf_config<MODEL_NAME><OUTPUT_DIR>