Research code for fine-tuning, merging, and evaluating OFT adapters for causal language models. The main experiment path is:
src/merging.py: core OFT/Riemannian merging methods.src/geometry.py: manifold operations used by merging.src/dataset/dataset.py: task list, prompt formatting, and dataloaders.src/finetune/finetune.py: fine-tune task adapters.src/compute_fim.py: compute Fisher matrices.src/scripts/perform_merging.py: create merged adapters/models.src/loss/compute_eval_loss.py: evaluate target-token loss.src/analysis/ and src/plots/: analysis and figures.scripts/: SLURM wrappers for cluster runs.pip install -r requirements.txt
pip install -e .
Model, adapter, and Fisher paths are configured in src/paths.py. By default the
repo expects base models under data/models/ and task adapters in folders named
like:
data/models/Llama-3.1-8B_OFT_dataset_adapters
data/models/Qwen-2.5-3B_OFT_dataset_adapters
Update FISHERS_DIR in src/paths.py before running Fisher-based workflows.
List tasks:
python -m src.finetune.finetune --list-tasks
Fine-tune one adapter:
python -m src.finetune.finetune --model-family llama3.1 --task coqa
Compute Fisher matrices:
python -m src.compute_fim --model-family llama3.1 --task-index 0
Merge adapters:
python -m src.scripts.perform_merging \
--model_family llama3.1 \
--merge_method gradients \
--merge_mode standard_rescaled \
--output_dir outputs/merged/llama3.1_standard_rescaled
Evaluate loss:
python -m src.loss.compute_eval_loss \
--model llama3.1 \
--model-source adapter \
--peft-model outputs/merged/llama3.1_standard_rescaled/merged_adapter
Run tests:
pytest
Most heavy workflows assume CUDA, Hugging Face access, and enough GPU memory for
the selected model family. The SLURM scripts in scripts/ are useful templates,
but contain cluster-specific partitions and paths that may need editing.
Generated models, adapters, Fisher tensors, caches, and evaluation outputs should stay out of git.
2 commits
Python
95.4%
Jupyter Notebook
3.3%
Research code for fine-tuning, merging, and evaluating OFT adapters for causal language models. The main experiment path is:
src/merging.py: core OFT/Riemannian merging methods.src/geometry.py: manifold operations used by merging.src/dataset/dataset.py: task list, prompt formatting, and dataloaders.src/finetune/finetune.py: fine-tune task adapters.src/compute_fim.py: compute Fisher matrices.src/scripts/perform_merging.py: create merged adapters/models.src/loss/compute_eval_loss.py: evaluate target-token loss.src/analysis/ and src/plots/: analysis and figures.scripts/: SLURM wrappers for cluster runs.pip install -r requirements.txt
pip install -e .
Model, adapter, and Fisher paths are configured in src/paths.py. By default the
repo expects base models under data/models/ and task adapters in folders named
like:
data/models/Llama-3.1-8B_OFT_dataset_adapters
data/models/Qwen-2.5-3B_OFT_dataset_adapters
Update FISHERS_DIR in src/paths.py before running Fisher-based workflows.
List tasks:
python -m src.finetune.finetune --list-tasks
Fine-tune one adapter:
python -m src.finetune.finetune --model-family llama3.1 --task coqa
Compute Fisher matrices:
python -m src.compute_fim --model-family llama3.1 --task-index 0
Merge adapters:
python -m src.scripts.perform_merging \
--model_family llama3.1 \
--merge_method gradients \
--merge_mode standard_rescaled \
--output_dir outputs/merged/llama3.1_standard_rescaled
Evaluate loss:
python -m src.loss.compute_eval_loss \
--model llama3.1 \
--model-source adapter \
--peft-model outputs/merged/llama3.1_standard_rescaled/merged_adapter
Run tests:
pytest
Most heavy workflows assume CUDA, Hugging Face access, and enough GPU memory for
the selected model family. The SLURM scripts in scripts/ are useful templates,
but contain cluster-specific partitions and paths that may need editing.
Generated models, adapters, Fisher tensors, caches, and evaluation outputs should stay out of git.
2 commits
Python
95.4%
Jupyter Notebook
3.3%