Views
No views yet
“In this section, we describe the instruction residual approach to simply regain the instruction following capabilities. We compute the instruction residual between an instruction following LLM (θ_{i,d_1,v_1}) and its corresponding base model (θ_{b,d_1}) in the parametric space as [ Θ_{r,v_1} = θ_{i,d_1,v_1} - θ_{b,d_1}. ] This tensor subtraction extracts the instruction-specific information, which can then be added to any base model.”
pytorch_model.safetensors — full-rank FP16 residual weights (~16 GB).config.json — configuration matching the Llama-3.1-8B architecture.README.md — this model card.1from transformers import AutoModelForCausalLM
2from safetensors.torch import load_file
3import torch
4
5# 1) Load base
6model = AutoModelForCausalLM.from_pretrained(
7 "meta-llama/Llama-3.1-8B",
8 torch_dtype=torch.float16,
9 device_map="auto",
10)
11
12# 2) Load residual
13residual_sd = load_file("pytorch_model.safetensors", device="cpu")
14
15# 3) Apply residual
16for name, delta in residual_sd.items():
17 param = dict(model.named_parameters())[name]
18 param.data += delta.to(param.device).to(param.dtype)
19
20# 4) Save or push
21model.save_pretrained("llama-3.1-8b-base-plus-instruct")examples/ folder.LICENSE file for details.1@misc{jindal2024balancingcontinuouspretraininginstruction,
2 title={Balancing Continuous Pre-Training and Instruction Fine-Tuning: Optimizing Instruction-Following in LLMs},
3 author={Ishan Jindal and Chandana Badrinath and Pranjal Bharti and Lakkidi Vinay and Sachin Dev Sharma},
4 year={2024},
5 eprint={2410.10739},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2410.10739},
9}