Skip to content

Commit 577e4e8

Browse files
authored
Merge pull request #104 from tanmayshishodia/feature/lora
LoRA and DoRA PEFT support for Fine-Tuning TimesFM
2 parents 89a84eb + 55f71de commit 577e4e8

15 files changed

+1985
-2
lines changed

.gitignore

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
.venv/
22
dist/
3-
**__pycache__/** */
3+
__pycache__/
4+
checkpoints/
5+
wandb/
6+
datasets/
7+
results/
8+
timesfm_jax.egg-info/

environment.yml

+3
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ dependencies:
1616
- jax[cuda12]==0.4.26
1717
- einshape
1818
- scikit-learn
19+
- typer
20+
- wandb
21+
- pytest

environment_cpu.yml

+3
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ dependencies:
1616
- jax[cpu]==0.4.26
1717
- einshape
1818
- scikit-learn
19+
- typer
20+
- wandb
21+
- pytest

peft/README.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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

Comments
 (0)