SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2408.13656 · 2024

Localize-and-Stitch: Efficient Model Merging via Sparse Task Arithmetic

arXiv · PDF · Open in the Atlas

Code that ran

7 of 7 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; 7 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/2408.13656.json · badge: /api/ran/2408.13656.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
yifei-he/localize-and-stitch canonical (classifier label)
classifier basis: census
6 ran · 0 no recorded run
uiuctml/localize-and-stitch canonical (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
FunctionStatusWhere it lives
create_log_dir Ran
ran; our contract draft was wrong, not the code
yifei-he/localize-and-stitch/vision/src/main_dataless_localize_stitch.py
code served (permissive licence) · get_code("3053d2bdc3ea5c89")
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 Logger. The image it ran in was not recorded. If your copy returns the same type 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 os
import tempfile

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

ARGS = {
    'path': temp_dir,
    'filename': 'log.txt'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Logger — a Logger output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Logger output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
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
input_example_to_string Ran
ran; our contract draft was wrong, not the code
yifei-he/localize-and-stitch/language/src/dataset.py
code served (permissive licence) · get_code("e768e25ca95f70cd")
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, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type 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.

class Example:
    def __init__(self, text_a, text_b=None):
        self.text_a = text_a
        self.text_b = text_b

example_with_text_b = Example("Hello world", "This is text b")
example_without_text_b = Example("Hello world", None)

ARGS = {
    "example": example_with_text_b,
    "sep_token": "[SEP]"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
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
input_example_to_tuple Ran
ran; our contract draft was wrong, not the code
yifei-he/localize-and-stitch/language/src/dataset.py
code served (permissive licence) · get_code("fbef70dc7c700501")
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, through the batch API) 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 logging
import pandas as pd

logger = logging.getLogger(__name__)

# Create a simple example class that mimics the structure needed
class Example:
    def __init__(self, text_a, text_b=None):
        self.text_a = text_a
        self.text_b = text_b

# Test case 1: example with both text_a and text_b
example_both = Example(text_a="Hello world", text_b="Goodbye world")

# Test case 2: example with only text_a
example_single = Example(text_a="Hello world", text_b=None)

# Test case 3: example with None text_a and None text_b
example_empty = Example(text_a=None, text_b=None)

# Use the most complete example for the ARGS dict
ARGS = {
    "example": example_both
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — 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
parse_data_arguments Ran
ran; our contract draft was wrong, not the code
yifei-he/localize-and-stitch/language/args.py
code served (permissive licence) · get_code("b2160a3a2b890e58")
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, through the batch API) and returned Namespace. The image it ran in was not recorded. If your copy returns the same type 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 argparse

# The function parse_data_arguments takes a single parameter: dataset_name
# It is a string representing the name of a dataset (e.g., 'SST-2', 'CoLA', etc.)

ARGS = {
    'dataset_name': 'SST-2'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Namespace — a Namespace output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Namespace output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
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
select_trainable_parameters Ran
ran; our contract draft was wrong, not the code
uiuctml/localize-and-stitch/language/main_localize_stitch.py
code served (permissive licence) · get_code("883ebc0d4d55db02")
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 dict. The image it ran in was not recorded. If your copy returns the same type 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

torch.manual_seed(0)

class SimpleEncoder(nn.Module):
    def __init__(self):
        super().__init__()
        self.layer = nn.Sequential(
            nn.Linear(4, 8),
            nn.ReLU(),
            nn.Linear(8, 3)
        )

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.encoder = SimpleEncoder()
        self.decoder = nn.Linear(3, 2)
        self.other_layer = nn.Linear(2, 1)
    
    def forward(self, x):
        x = self.encoder.layer(x)
        x = self.decoder(x)
        x = self.other_layer(x)
        return x

model = SimpleModel()

ARGS = {
    "model": model
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
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
text_classification_metrics Ran
ran; our contract draft was wrong, not the code
yifei-he/localize-and-stitch/language/src/processors.py
code served (permissive licence) · get_code("b62076c5483738dc")
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, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type 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 numpy as np

torch.manual_seed(0)

# Construct arguments for text_classification_metrics
task_name = "sentiment"

# Create predictions and labels as numpy arrays
# The function compares them with == and calls .mean()
preds = np.array([0, 1, 0, 1], dtype=np.int64)
labels = np.array([0, 1, 1, 1], dtype=np.int64)

ARGS = {
    "task_name": task_name,
    "preds": preds,
    "labels": labels,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
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
tokenize_multipart_input Ran
ran; our contract draft was wrong, not the code
yifei-he/localize-and-stitch/language/src/dataset.py
code served (permissive licence) · get_code("e3eed9fd49cd08fb")
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, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type 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
from transformers import AutoTokenizer

# Create a minimal stand-in tokenizer class
class MockTokenizer:
    def __init__(self):
        self.cls_token_id = 101
        self.mask_token_id = 103
        self.sep_token_id = 102
        self.pad_token_id = 0
        self.vocab_size = 1000
    
    def encode(self, text, add_special_tokens=False):
        # Simple mock: return a list of token ids based on text length
        tokens = text.split()
        return [hash(token) % 100 + 100 for token in tokens]
    
    def convert_tokens_to_ids(self, token):
        if isinstance(token, str):
            return hash(token) % 100 + 100
        return token

# Create input arguments
tokenizer = MockTokenizer()

input_text_list = [
    "This is a sample text.",
    "Another example sentence here."
]

max_length = 128

task_name = "text_classification"

prompt = False

template = None

label_word_list = None

first_sent_limit = None

other_sent_limit = None

gpt3 = False

truncate_head = False

support_labels = None

ARGS = {
    "input_text_list": input_text_list,
    "max_length": max_length,
    "tokenizer": tokenizer,
    "task_name": task_name,
    "prompt": prompt,
    "template": template,
    "label_word_list": label_word_list,
    "first_sent_limit": first_sent_limit,
    "other_sent_limit": other_sent_limit,
    "gpt3": gpt3,
    "truncate_head": truncate_head,
    "support_labels": support_labels,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas, torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
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 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 4 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 1 the same month, 0 later) and 3 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.

FunctionAlso present inEarliest-datedOthers named
input_example_to_string 9 other papers
9 dated earlier
2110.01256 (2021-10)
Revisiting Self-Training for Few-Shot Learning of Language Model
2110.06274 (2021-10)
LiST: Lite Prompted Self-training Makes Parameter-Efficient Few-shot Learners
2202.11451 (2022-02)
Zero-shot Cross-lingual Transfer of Prompt-based Tuning with a Unified Multilingual Prompt
and 6 more not named here
input_example_to_tuple 9 other papers
9 dated earlier
2110.01256 (2021-10)
Revisiting Self-Training for Few-Shot Learning of Language Model
2110.06274 (2021-10)
LiST: Lite Prompted Self-training Makes Parameter-Efficient Few-shot Learners
2202.11451 (2022-02)
Zero-shot Cross-lingual Transfer of Prompt-based Tuning with a Unified Multilingual Prompt
and 6 more not named here
text_classification_metrics 6 other papers
6 dated earlier
2110.01256 (2021-10)
Revisiting Self-Training for Few-Shot Learning of Language Model
2110.06274 (2021-10)
LiST: Lite Prompted Self-training Makes Parameter-Efficient Few-shot Learners
2205.01308 (2022-05)
Contrastive Learning for Prompt-Based Few-Shot Language Learners
and 3 more not named here
create_log_dir 4 other papers
3 dated earlier, 1 the same month
2310.02575 (2023-10)
AdaMerging: Adaptive Model Merging for Multi-Task Learning
2405.17461 (2024-05)
EMR-MERGING: Tuning-Free High-Performance Model Merging
2407.07089 (2024-07)
Fine-Tuning Attention Modules Only: Enhancing Weight Disentanglement in Task Arithmetic
and 1 more not named here

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

Model merging offers an effective strategy to combine the strengths of multiple finetuned models into a unified model that preserves the specialized capabilities of each. Existing methods merge models in a global manner, performing arithmetic operations across all model parameters. However, such global merging often leads to task interference, degrading the performance of the merged model. In this work, we introduce Localize-and-Stitch, a novel approach that merges models in a localized way. Our algorithm works in two steps: i) Localization: identify tiny ($1\%$ of the total parameters) localized regions in the finetuned models containing essential skills for the downstream tasks, and ii) Stitching: reintegrate only these essential regions back into the pretrained model for task synergy. We demonstrate that our approach effectively locates sparse regions responsible for finetuned performance, and the localized regions could be treated as compact and interpretable representations of the finetuned models (tasks). Empirically, we evaluate our method on various vision and language benchmarks, showing that it outperforms existing model merging methods under different data availability scenarios. Beyond strong empirical performance, our algorithm also facilitates model compression and preserves pretrained knowledge, enabling flexible and continual skill composition from multiple finetuned models with minimal storage and computational overhead. Our code is available at https://github.com/uiuctml/Localize-and-Stitch.

For agents

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

get_harvested_code_for_paper("2408.13656")
get_code_for_paper("2408.13656")
have("2408.13656")

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

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

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

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

Connect an agent — have() is free.