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

# FinetuningConfig

> API reference for finetuning configuration

## FinetuningConfig

<ParamField path="base_model_path" type="str" required>
  Path to the pre-trained model checkpoint or Hugging Face model identifier to finetune from.
</ParamField>

<ParamField path="data_configs" type="FinetuningDataConfig | List[FinetuningDataConfig]" required>
  Data configuration(s) for finetuning tasks. Supports multi-task finetuning scenarios.
</ParamField>

<ParamField path="finetuning_config" type="FinetuningOptimizationConfig" required>
  Finetuning-specific optimization parameters with typically lower learning rates.
</ParamField>

<ParamField path="model_config" type="ModelConfig" required>
  Model architecture configuration. Must match the base model architecture.
</ParamField>

<ParamField path="meta_config" type="MetaConfig" default="Uses MetaConfig defaults">
  Metadata and run-specific parameters for the finetuning experiment.
</ParamField>

## FinetuningOptimizationConfig

<ParamField path="total_training_steps" type="int" required>
  Total number of finetuning steps. Typically much lower than full training (500-5000 steps).
</ParamField>

<ParamField path="max_learning_rate" type="float" required>
  Maximum learning rate for finetuning. Recommended range: 1e-5 to 5e-4 (lower than full training).
</ParamField>

<ParamField path="global_batch_size" type="int" required>
  Global batch size for finetuning. Can be smaller than full training due to fewer steps.
</ParamField>

<ParamField path="learning_rate_schedule" type="str | callable" default="linear">
  Learning rate scheduling strategy for finetuning:

  * `"linear"`: Linear decay (recommended for finetuning)
  * `"cosine"`: Cosine annealing
  * `"constant"`: Constant learning rate
  * Custom function with signature: `(learning_rate, current_step, total_steps) → decayed_rate`
</ParamField>

<ParamField path="warmup_steps" type="int" default="50">
  Number of learning rate warmup steps. Typically 5-10% of total finetuning steps.
</ParamField>

<ParamField path="weight_decay" type="float" default="0.01">
  L2 regularization coefficient. Important for preventing overfitting in finetuning.
</ParamField>

<ParamField path="gradient_accumulation_steps" type="int" default="1">
  Number of steps to accumulate gradients before updating. Useful for effective larger batch sizes.
</ParamField>

<ParamField path="freeze_layers" type="List[str] | None" default="None">
  List of layer patterns to freeze during finetuning. Example: `["embeddings", "layer.0", "layer.1"]`
</ParamField>

<ParamField path="lora_config" type="LoRAConfig | None" default="None">
  Low-Rank Adaptation configuration for parameter-efficient finetuning.
</ParamField>

<ParamField path="optimizer_type" type="str" default="AdamW">
  Optimizer algorithm. Options: `"AdamW"`, `"Adam"`, `"SGD"`
</ParamField>

<ParamField path="clip_grad" type="float" default="1.0">
  Gradient clipping threshold. Important for stability in finetuning.
</ParamField>

## LoRAConfig

<ParamField path="rank" type="int" default="16">
  Rank of the adaptation matrices. Higher rank = more parameters but better expressiveness.
</ParamField>

<ParamField path="alpha" type="float" default="32">
  LoRA scaling parameter. Controls the magnitude of the adaptation.
</ParamField>

<ParamField path="dropout" type="float" default="0.1">
  Dropout probability for LoRA layers.
</ParamField>

<ParamField path="target_modules" type="List[str] | None" default="Auto-detected">
  List of module names to apply LoRA to. If None, automatically targets attention and MLP layers.
</ParamField>

<ParamField path="bias" type="str" default="none">
  Bias handling strategy:

  * `"none"`: No bias adaptation
  * `"all"`: Adapt all biases
  * `"lora_only"`: Only adapt LoRA biases
</ParamField>

## FinetuningDataConfig

<ParamField path="data_paths" type="str | List[str]" required>
  Path(s) to finetuning data files. Should be formatted according to your task type.
</ParamField>

<ParamField path="task_type" type="str" default="text_generation">
  Type of finetuning task:

  * `"text_generation"`: Generative language modeling
  * `"classification"`: Text classification
  * `"instruction_following"`: Instruction-tuning
  * `"code_generation"`: Code completion/generation
  * `"time_series_forecasting"`: Time series tasks
</ParamField>

<ParamField path="max_sequence_length" type="int" default="512">
  Maximum sequence length for finetuning examples. Shorter than training can speed up finetuning.
</ParamField>

<ParamField path="validation_split" type="float" default="0.1">
  Portion of data reserved for validation during finetuning.
</ParamField>

<ParamField path="training_objective" type="str | callable" default="cross_entropy">
  Loss function specification:

  * `"cross_entropy"`: Cross-entropy loss for text generation
  * `"classification"`: Classification loss with label smoothing
  * `"mse"`: Mean Squared Error for regression tasks
  * Custom callable loss function
</ParamField>

<ParamField path="data_preprocessing" type="dict | None" default="None">
  Task-specific preprocessing options:

  * For instruction tuning: `{"format": "alpaca", "prompt_template": "..."}`
  * For classification: `{"label_column": "label", "text_column": "text"}`
  * For code: `{"language": "python", "max_context_length": 1024}`
</ParamField>

<ParamField path="sampling_weight" type="float | None" default="Equal weight among all data configs">
  Relative sampling weight for this data source in multi-task finetuning scenarios.
</ParamField>

<ParamField path="features" type="str | List[str] | callable | List[callable] | None" default="None">
  Feature engineering functions for specialized finetuning tasks.
</ParamField>

## MetaConfig

Configuration for experiment metadata and checkpointing behavior.

<ParamField path="name" type="str" default="trial-run">
  Name identifier for this finetuning experimental run.
</ParamField>

<ParamField path="seed" type="int" default="42">
  Random seed for reproducible finetuning.
</ParamField>

<ParamField path="save_path" type="str" default="current working directory / run_name">
  Directory path for saving finetuned model checkpoints.
</ParamField>

<ParamField path="model_save_frequency" type="int" default="-1">
  Frequency (in steps) for saving model checkpoints. Set to -1 to save only at the end of finetuning.
</ParamField>

<ParamField path="max_checkpoints" type="int" default="-1">
  Maximum number of model checkpoints to retain. Set to -1 for no limit.
</ParamField>

<ParamField path="wandb_config" type="WandbConfig | None" default="None">
  Weights & Biases logging configuration for finetuning experiment tracking and visualization.
</ParamField>

## WandbConfig

Configuration for Weights & Biases experiment tracking and logging during finetuning.

<ParamField path="project" type="str" required>
  Weights & Biases project name for organizing finetuning experiments.
</ParamField>

<ParamField path="entity" type="str | None" default="None">
  Weights & Biases team/organization name. If None, uses the default entity associated with your API key.
</ParamField>

<ParamField path="run_name" type="str | None" default="None">
  Custom run name for the finetuning experiment. If None, uses the MetaConfig name or auto-generates one.
</ParamField>

<ParamField path="tags" type="List[str] | None" default="None">
  List of tags to associate with the finetuning run for easy filtering and organization.
</ParamField>

<ParamField path="notes" type="str | None" default="None">
  Optional notes or description for the finetuning experiment run.
</ParamField>

<ParamField path="log_model" type="bool" default="True">
  Whether to log the finetuned model as a Weights & Biases artifact for version control. Defaults to True for finetuning.
</ParamField>

<ParamField path="log_frequency" type="int" default="50">
  Frequency (in steps) for logging metrics to Weights & Biases. Lower default for finetuning due to fewer total steps.
</ParamField>

<ParamField path="log_gradients" type="bool" default="False">
  Whether to log gradient histograms (can impact performance).
</ParamField>

<ParamField path="log_parameters" type="bool" default="False">
  Whether to log parameter histograms (can impact performance).
</ParamField>

<ParamField path="watch_model" type="str | None" default="None">
  Model watching mode for logging gradients and parameters:

  * `"gradients"`: Log gradient histograms
  * `"parameters"`: Log parameter histograms
  * `"all"`: Log both gradients and parameters
  * `None`: Disable model watching
</ParamField>

<ParamField path="config" type="dict | None" default="None">
  Additional configuration dictionary to log to Weights & Biases.
</ParamField>

<ParamField path="log_lora_weights" type="bool" default="True">
  Whether to log LoRA adapter weights as artifacts when using LoRA finetuning.
</ParamField>
