JoLA: Joint Localization and Activation Editing for Low-Resource Fine-Tuning
Project description
JoLA: Joint Localization and Activation Editing for Low-Resource Fine-Tuning
Code for the paper "JoLA: Joint Localization and Activation Editing for Low-Resource Fine-Tuning"
Paper: http://arxiv.org/abs/2502.01179
Authors: Wen Lai$^{1,2}$, Alexander Fraser$^{1,2}$, Ivan Titov$^{3,4}$
$^1$ Technical University of Munich, $^2$ Munich Center for Machine Learning, $^3$ University of Edinburgh, $^4$ University of Amsterdam
Email: wen.lai@tum.de
Overview
Parameter-efficient fine-tuning (PEFT) methods, such as LoRA, are commonly used to adapt LLMs. However, their effectiveness is often limited in low-resource scenarios with only a few hundred examples. Recent advances in interpretability research have inspired the emergence of activation editing techniques, which modify the activations of specific model components. These methods, due to their extremely small parameter counts, show promise for small datasets. However, their performance is highly dependent on identifying the correct modules to edit and often lacks stability across different datasets. In this paper, we propose Joint Localization and Activation Editing (JoLA), a method that jointly learns (1) which heads in the Transformer to edit; (2) whether the intervention should be additive, multiplicative, or both and (3) the intervention parameters themselves - vectors applied as additive offsets or multiplicative scalings to the head output. Through evaluations on three benchmarks spanning commonsense reasoning, natural language understanding, and natural language generation, we demonstrate that JoLA consistently outperforms existing methods.
Installation
- Install
jolafrom pip:
pip install jola
- or, install our latest
jolafrom pip+git:
pip install git+https://github.com/wenlai-lavine/jola.git
Training JoLA with a few codes
from jola import JoLAConfig, JoLAModel, JoLATrainer, data_from_list
from transformers import AutoTokenizer, TrainingArguments
# set default=False, if you want to specify the parameters in JoLA; you need to set the configuration by providing a yaml file (example: config.yaml).
jola_config = JoLAConfig(default=True)
# load tokenizer
jola_tokenizer = AutoTokenizer.from_pretrained(**jola_config["model_config"])
# Load models
jola_model = JoLAModel.jola_from_pretrained(**jola_config["model_config"])
# unfreeze jola parameters
jola_model.unfreeze_jola_params()
# set in training mode
jola_model.model.train()
# examples from ARC-e
training_examples = [
"Which statement best explains why photosynthesis is the foundation of most food webs?\n\nAnswer1: Sunlight is the source of energy for nearly all ecosystems. Answer2: Most ecosystems are found on land instead of in water. Answer3: Carbon dioxide is more available than other gases. Answer4: The producers in all ecosystems are plants.", "answer1",
"Which piece of safety equipment is used to keep mold spores from entering the respiratory system?\n\nAnswer1: safety goggles Answer2: breathing mask Answer3: rubber gloves Answer4: lead apron.", "answer2",
... ...
]
# data setting, data loader
data_collator = make_data_collator(tokenizer=jola_tokenizer)
# dataset setting
jola_dataset = JoLADataset(train_list=training_examples)
jola_data = jola_dataset.data_from_list()
# training arguments
training_args = TrainingArguments(**jola_config["training_config"])
# trainer
jola_trainer = JoLATrainer(
jola_model,
train_dataset=jola_data['train'],
eval_dataset = jola_data['valid'],
tokenizer=jola_tokenizer,
data_collator = data_collator,
args=training_args,
callbacks=[early_stopping_callback],
gate_scheduler=jola_config["jola_config"]["gate_scheduler"]
)
jola_trainer.train()
Experiments in Paper
Dataset
We evaluate on commonsense reasoning, natural language understanding and natural language generation benchmarks.
- Commonsense Reasoning
- The same as Hu et al., 2023
- 8 Tasks: ARC-c / ARC-e / BoolQ / HellaSwag / OBQA / PIQA / SIQA / WinoGrande
- Download Link
- Natural Language Understanding
- We use MMLU-Pro Benchmark (Wang et al., 2024)
- 14 Domains: Biology, Business, Chemistry, Computer Science, Economics, Engineering, Health, History, Law, Math, Philosophy, Physics, Psychology, and Others
- Download Link
- Natural Language Generation
- We use GEM Benchmark (Gehrmann et al., 2022)
- We use 4 tasks: CommonGen / E2E_NLG / Web_NLG / Xsum
- Download Link
- Prompt Template from PromptSource
Training and Evaluation
- please use your own
config.yaml python examples/run_jola.py
Citation
Please cite our paper if it's helpful to your work!
@article{lai2025joint,
title={Joint Localization and Activation Editing for Low-Resource Fine-Tuning},
author={Lai, Wen and Fraser, Alexander and Titov, Ivan},
journal={arXiv preprint arXiv:2502.01179},
year={2025}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jola-0.0.1.tar.gz.
File metadata
- Download URL: jola-0.0.1.tar.gz
- Upload date:
- Size: 42.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e622feda8fdaf34ddd1c3ee245ba089d2123118629b2aa3dbf7eb5679f5a56f
|
|
| MD5 |
29d9e5dea21f82b7d0d1e90239a745f5
|
|
| BLAKE2b-256 |
40186950604b0dda4089641d63065679340a19130f961b3c786920145407ec02
|
File details
Details for the file jola-0.0.1-py3-none-any.whl.
File metadata
- Download URL: jola-0.0.1-py3-none-any.whl
- Upload date:
- Size: 43.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaaa1bb72b431c2201ed49ca936f62156d20fef76f153a8ce59d1ff8592c21f7
|
|
| MD5 |
01bfb51c9f4b36ce8f4551de7d5a6f20
|
|
| BLAKE2b-256 |
d923759232f3da72fb661f59e6ccebcaee4a6b3a0b2c86b194dd4e675f4d14d0
|