Command-Line Interface

Entrenar provides a powerful CLI for training, validation, quantization, and model merging—all without writing code.

Installation

cargo install entrenar

Or build from source:

cargo build --release
# Binary at target/release/entrenar

Quick Reference

entrenar train config.yaml              # Train from YAML config
entrenar validate config.yaml           # Validate config without training
entrenar info config.yaml               # Display config information
entrenar quantize model.json -o q4.json # Quantize a model
entrenar merge a.json b.json -o out.json # Merge models

Global Options

FlagDescription
-v, --verboseEnable verbose output
-q, --quietSuppress all output except errors
--helpPrint help information
--versionPrint version

Commands

train

Train a model from a YAML configuration file.

entrenar train <CONFIG> [OPTIONS]

Arguments:

ArgumentDescription
CONFIGPath to YAML configuration file

Options:

OptionDescription
-o, --output-dir <DIR>Override output directory
-r, --resume <PATH>Resume training from checkpoint
-e, --epochs <N>Override number of epochs
-b, --batch-size <N>Override batch size
-l, --lr <RATE>Override learning rate
--dry-runValidate config but don't train
--save-every <N>Save checkpoint every N steps
--log-every <N>Log metrics every N steps
--seed <N>Random seed for reproducibility

Examples:

# Basic training
entrenar train config.yaml

# Override hyperparameters
entrenar train config.yaml --epochs 50 --lr 0.0001 --batch-size 32

# Resume from checkpoint
entrenar train config.yaml --resume checkpoints/epoch_10.json

# Dry run to validate config
entrenar train config.yaml --dry-run

# Full example with all options
entrenar train config.yaml \
  --output-dir ./experiments/run1 \
  --epochs 100 \
  --batch-size 16 \
  --lr 1e-4 \
  --save-every 1000 \
  --log-every 100 \
  --seed 42 \
  --verbose

validate

Validate a configuration file without training.

entrenar validate <CONFIG> [OPTIONS]

Options:

OptionDescription
-d, --detailedShow detailed validation report

Examples:

# Quick validation
entrenar validate config.yaml

# Detailed report
entrenar validate config.yaml --detailed

Output:

✓ Configuration is valid
  Model: llama-7b
  Optimizer: adamw (lr=0.0001)
  Epochs: 10
  Batch size: 8
  LoRA: rank=64, alpha=16

info

Display information about a configuration.

entrenar info <CONFIG> [OPTIONS]

Options:

OptionDescription
-f, --format <FORMAT>Output format: text, json, yaml (default: text)

Examples:

# Human-readable output
entrenar info config.yaml

# JSON for scripting
entrenar info config.yaml --format json

# YAML output
entrenar info config.yaml --format yaml

quantize

Quantize a model to reduce size and memory footprint.

entrenar quantize <MODEL> -o <OUTPUT> [OPTIONS]

Arguments:

ArgumentDescription
MODELPath to model file

Options:

OptionDescription
-o, --output <PATH>Output path for quantized model (required)
-b, --bits <N>Quantization bits: 4 or 8 (default: 4)
-m, --method <METHOD>Method: symmetric, asymmetric (default: symmetric)
--per-channelUse per-channel quantization
--calibration-data <PATH>Path to calibration data for PTQ

Examples:

# 4-bit symmetric quantization (default)
entrenar quantize model.json -o model_q4.json

# 8-bit asymmetric quantization
entrenar quantize model.json -o model_q8.json --bits 8 --method asymmetric

# Per-channel with calibration
entrenar quantize model.json -o model_q4.json \
  --per-channel \
  --calibration-data calibration.json

Quantization Methods:

MethodDescriptionUse Case
symmetricZero-centered quantizationGeneral purpose, faster inference
asymmetricFull range quantizationBetter for non-symmetric weight distributions

merge

Merge multiple models using various algorithms.

entrenar merge <MODELS>... -o <OUTPUT> [OPTIONS]

Arguments:

ArgumentDescription
MODELSTwo or more model paths to merge

Options:

OptionDescription
-o, --output <PATH>Output path for merged model (required)
-m, --method <METHOD>Merge method (default: ties)
-w, --weight <FLOAT>Interpolation weight for SLERP (0.0-1.0)
-d, --density <FLOAT>Density threshold for TIES/DARE
--weights <LIST>Comma-separated weights for weighted average

Merge Methods:

MethodDescriptionParameters
tiesTrim, Elect Sign, Merge--density (default: 0.2)
dareDrop And REscale--density (default: 0.5)
slerpSpherical Linear Interpolation--weight (default: 0.5)
averageWeighted average--weights

Examples:

# TIES merge (default)
entrenar merge model_a.json model_b.json -o merged.json

# SLERP with custom weight
entrenar merge model_a.json model_b.json -o merged.json \
  --method slerp --weight 0.7

# DARE with density
entrenar merge model_a.json model_b.json -o merged.json \
  --method dare --density 0.3

# Weighted average of 3 models
entrenar merge a.json b.json c.json -o merged.json \
  --method average --weights "0.5,0.3,0.2"

Configuration File

The CLI works with YAML configuration files:

# config.yaml
model:
  path: llama-7b.gguf
  type: llama

data:
  train: train.parquet
  validation: val.parquet
  batch_size: 8

optimizer:
  name: adamw
  lr: 0.0001
  weight_decay: 0.01

training:
  epochs: 10
  output_dir: ./checkpoints
  save_interval: 1000

lora:
  enabled: true
  rank: 64
  alpha: 16
  target_modules: [q_proj, k_proj, v_proj, o_proj]

quantization:
  enabled: false
  bits: 4

See YAML Configuration for full schema.

Exit Codes

CodeMeaning
0Success
1Configuration error
2Runtime error
3I/O error

Environment Variables

VariableDescription
ENTRENAR_LOGLog level: error, warn, info, debug, trace
ENTRENAR_CONFIGDefault config file path
CUDA_VISIBLE_DEVICESGPU device selection

Shell Completion

Generate shell completions:

# Bash
entrenar --generate-completion bash > ~/.local/share/bash-completion/completions/entrenar

# Zsh
entrenar --generate-completion zsh > ~/.zfunc/_entrenar

# Fish
entrenar --generate-completion fish > ~/.config/fish/completions/entrenar.fish

Examples

Complete Training Workflow

# 1. Validate configuration
entrenar validate config.yaml --detailed

# 2. Dry run to check setup
entrenar train config.yaml --dry-run

# 3. Start training
entrenar train config.yaml --verbose

# 4. Resume if interrupted
entrenar train config.yaml --resume checkpoints/latest.json

# 5. Quantize final model
entrenar quantize checkpoints/final.json -o model_q4.json --bits 4

Model Merging Pipeline

# Train specialist models
entrenar train math_config.yaml
entrenar train code_config.yaml
entrenar train writing_config.yaml

# Merge specialists
entrenar merge \
  checkpoints/math_final.json \
  checkpoints/code_final.json \
  checkpoints/writing_final.json \
  -o merged_expert.json \
  --method ties \
  --density 0.3

# Quantize merged model
entrenar quantize merged_expert.json -o expert_q4.json

Programmatic Usage

The CLI types are also available programmatically:

use entrenar::config::cli::{Cli, Command, TrainArgs};
use clap::Parser;

fn main() {
    let cli = Cli::parse();

    match cli.command {
        Command::Train(args) => {
            println!("Training with config: {:?}", args.config);
        }
        Command::Validate(args) => {
            // ...
        }
        _ => {}
    }
}

Next Steps