SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2406.01563 · NeurIPS · 2024

LOFIT: Localized Fine-tuning on LLM Representations

Greg Durrett, Xi Ye, Fangcong Yin

arXiv · PDF · Open in the Atlas

Code that ran

2 of 2 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 2 failures of our instrument; 0 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2406.01563.json · badge: /api/ran/2406.01563.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
fc2869/lo-fit canonical (classifier label)
classifier basis: classifier_2025
2 ran · 0 no recorded run
FunctionStatusWhere it lives
evaluate_clutrr Ran
ran; our contract draft was wrong, not the code
fc2869/lo-fit/utils/evaluate.py
code served (permissive licence) · get_code("8ff8bc85e0bcfecb")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import os
import tempfile

torch.manual_seed(0)

# Create a minimal tokenizer stand-in
class MinimalTokenizer:
    def __init__(self):
        self.padding_side = 'left'
    
    def __call__(self, texts, return_tensors=None, padding=False):
        # Return a dict with input_ids and attention_mask
        batch_size = len(texts)
        max_len = 10
        input_ids = torch.randint(0, 100, (batch_size, max_len))
        attention_mask = torch.ones(batch_size, max_len)
        return {
            'input_ids': input_ids,
            'attention_mask': attention_mask
        }
    
    def batch_decode(self, token_ids, skip_special_tokens=False):
        # Return decoded strings with the expected format
        batch_size = token_ids.shape[0]
        results = []
        for i in range(batch_size):
            # Format: "prompt's\nresponse. extra"
            results.append(f"The person's\nmother. some extra text")
        return results

# Create a minimal model
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(10, 10)
        self.device_type = 'cpu'
    
    @property
    def device(self):
        return torch.device(self.device_type)
    
    def generate(self, input_ids, attention_mask, max_new_tokens=16, do_sample=False):
        batch_size = input_ids.shape[0]
        # Return generated token ids
        return torch.randint(0, 100, (batch_size, 15))

# Create eval dataset
eval_dataset = {
    'prompt': [
        "Who is the mother of Alice?",
        "Who is the father of Bob?"
    ],
    'target_text': [
        "mother",
        "father"
    ]
}

# Create model and tokenizer
model = MinimalModel()
tokenizer = MinimalTokenizer()

# Create temporary directory for output
temp_dir = tempfile.mkdtemp()

ARGS = {
    'eval_dataset': eval_dataset,
    'model_name': 'test_model',
    'model': model,
    'tokenizer': tokenizer,
    'fname': temp_dir,
    'batch_size': 2,
    'max_new_tokens': 16,
    'apply_chat_template': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
evaluate_mquake Ran
ran; our contract draft was wrong, not the code
fc2869/lo-fit/utils/evaluate.py
code served (permissive licence) · get_code("47c0e5b02289d3b1")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import os
import tempfile

torch.manual_seed(0)

# Create a minimal tokenizer stand-in
class MinimalTokenizer:
    def __init__(self):
        self.padding_side = 'left'
    
    def __call__(self, texts, return_tensors=None, padding=False):
        # Return a dict with input_ids and attention_mask
        batch_size = len(texts)
        seq_len = 8
        return {
            'input_ids': torch.randint(0, 1000, (batch_size, seq_len)),
            'attention_mask': torch.ones(batch_size, seq_len)
        }
    
    def batch_decode(self, token_ids, skip_special_tokens=False):
        # Return decoded strings with the expected format
        batch_size = token_ids.shape[0]
        results = []
        for i in range(batch_size):
            results.append(f"Question {i}?\nA: answer{i}")
        return results

# Create a minimal model
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
        self.device_name = 'cpu'
    
    @property
    def device(self):
        return torch.device(self.device_name)
    
    def generate(self, input_ids, attention_mask, max_new_tokens=16, do_sample=False):
        # Return token ids of shape (batch_size, seq_len)
        batch_size = input_ids.shape[0]
        return torch.randint(0, 1000, (batch_size, 12))

# Create eval dataset
eval_dataset = {
    'prompt': [
        'What is the capital of France?',
        'What is 2+2?'
    ],
    'labels': [
        ['Paris', 'paris'],
        ['4', 'four']
    ]
}

# Create temporary directory for outputs
temp_dir = tempfile.mkdtemp()

# Build ARGS dict
ARGS = {
    'eval_dataset': eval_dataset,
    'model_name': 'test-model',
    'model': MinimalModel(),
    'tokenizer': MinimalTokenizer(),
    'fname': temp_dir,
    'batch_size': 2,
    'max_new_tokens': 16,
    'apply_chat_template': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 2 samples lifted from this paper's linked repositories, 2 carry a function identity and 0 do not. Of the 2 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 2 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Recent work in interpretability shows that large language models (LLMs) can be adapted for new tasks in a learning-free way: it is possible to intervene on LLM representations to elicit desired behaviors for alignment. For instance, adding certain bias vectors to the outputs of certain attention heads is reported to boost the truthfulness of models. In this work, we show that localized fine-tuning serves as an effective alternative to such representation intervention methods. We introduce a framework called Localized Fine-Tuning on LLM Representations (LOFIT), which identifies a subset of attention heads that are most important for learning a specific task, then trains offset vectors to add to the model's hidden representations at those selected heads. LOFIT localizes to a sparse set of heads (3% -10%) and learns the offset vectors from limited training data, comparable to the settings used for representation intervention. For truthfulness and reasoning tasks, we find that LOFIT's intervention vectors are more effective for LLM adaptation than vectors from representation intervention methods such as Inference-time Intervention. We also find that the localization step is important: selecting a taskspecific set of attention heads can lead to higher performance than intervening on heads selected for a different task. Finally, across 7 tasks we study, LOFIT achieves comparable performance to other parameter-efficient fine-tuning methods such as LoRA, despite modifying 20x-200x fewer parameters than these methods. 1

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2406.01563")
get_code_for_paper("2406.01563")
have("2406.01563")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2406.01563.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2406.01563.svg)](https://syntology.ai/paper/2406.01563)

Connect an agent — have() is free.