|
| 1 | +# Fine-Tuning Pipeline |
| 2 | + |
| 3 | +This folder contains a generic fine-tuning pipeline designed to support multiple PEFT fine-tuning strategies. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Supported Fine-Tuning Strategies**: |
| 8 | + - **Full Fine-Tuning**: Adjusts all parameters of the model during training. |
| 9 | + - **[Linear Probing](https://arxiv.org/abs/2302.11939)**: Fine-tunes only the residual blocks and the embedding layer, leaving other parameters unchanged. |
| 10 | + - **[LoRA (Low-Rank Adaptation)](https://arxiv.org/abs/2106.09685)**: A memory-efficient method that fine-tunes a small number of parameters by decomposing the weight matrices into low-rank matrices. |
| 11 | + - **[DoRA (Directional LoRA)](https://arxiv.org/abs/2402.09353v4)**: An extension of LoRA that decomposes pre-trained weights into magnitude and direction components. It uses LoRA for directional adaptation, enhancing learning capacity and stability without additional inference overhead. |
| 12 | + |
| 13 | +## Usage |
| 14 | +### Fine-Tuning Script |
| 15 | +The provided finetune.py script allows you to fine-tune a model with specific configurations. You can customize various parameters to suit your dataset and desired fine-tuning strategy. |
| 16 | + |
| 17 | +Example Usage: |
| 18 | + |
| 19 | +```zsh |
| 20 | +source finetune.sh |
| 21 | +``` |
| 22 | +This script runs the finetune.py file with a predefined set of hyperparameters for the model. You can adjust the parameters in the script as needed. |
| 23 | + |
| 24 | +### Available Options |
| 25 | +Run the script with the --help flag to see a full list of available options and their descriptions: |
| 26 | +```zsh |
| 27 | +python3 finetune.py --help |
| 28 | +``` |
| 29 | +Script Configuration |
| 30 | +You can modify the following key parameters directly in the finetune.sh script: |
| 31 | +Fine-Tuning Strategy: Toggle between full fine-tuning, LoRA \[`--use-lora`\], DoRA [\[`--use-dora`\]], or Linear Probing \[`--use-linear-probing`\]. |
| 32 | + |
| 33 | +### Performance Comparison |
| 34 | +The figure below compares the performance of LoRA/DoRA against Linear Probing under the following conditions: |
| 35 | + |
| 36 | +<img width="528" alt="image" src="https://github.com/user-attachments/assets/6c9f820b-5865-4821-8014-c346b9d632a5"> |
| 37 | + |
| 38 | +- Training data split: 60% train, 20% validation, 20% test. |
| 39 | +- Benchmark: context_len=128, horizon_len=96 |
| 40 | +- Fine-tuning: context_len=128, horizon_len=128 |
| 41 | +- Black: Best result. |
| 42 | +- Blue: Second best result. |
0 commit comments