SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2409.19540 · 2024

LoRKD: Low-Rank Knowledge Decomposition for Medical Foundation Models

arXiv · PDF · Open in the Atlas

Code that ran

10 of 13 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (6 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 6 have no contract verdict; 3 failures of our instrument; 3 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/2409.19540.json · badge: /api/ran/2409.19540.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
tdlhl/LoRKD canonical (classifier label)
classifier basis: classifier_2025
8 ran · 3 no recorded run
mediabrain-sjtu/lorkd canonical (classifier label)
classifier basis: classifier_2025
2 ran · 0 no recorded run
FunctionStatusWhere it lives
BaseBERT Ran
ran on a synthesized input · constructed an object; no result was computed
tdlhl/LoRKD/model/query_generator.py
code served (permissive licence) · get_code("b8c367e3d51d88b5")
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 an instance of its own class, BaseBERT: the run constructed the object and did not call it, so no result was computed. 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 unittest.mock import MagicMock

torch.manual_seed(0)

# Create a mock BertModel since we can't download pretrained models
class MockBertModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.config = MagicMock()
        self.config.hidden_size = 768
        # Create a simple layer that outputs the right shape
        self.linear = nn.Linear(10, 768)
    
    def forward(self, **kwargs):
        # Expect input_ids in kwargs
        batch_size = kwargs.get('input_ids', torch.zeros(2, 10)).shape[0]
        # Return mock output with last_hidden_state of shape [batch_size, seq_len, 768]
        output = MagicMock()
        output.last_hidden_state = torch.randn(batch_size, 5, 768)
        return output

# Mock the from_pretrained method
original_from_pretrained = nn.Module.from_pretrained if hasattr(nn.Module, 'from_pretrained') else None

def mock_from_pretrained(checkpoint):
    return MockBertModel()

# Monkey patch BertModel
from transformers import BertModel
BertModel.from_pretrained = mock_from_pretrained

# Create sample arguments
basebert_checkpoint = "bert-base-uncased"

ARGS = {
    "basebert_checkpoint": basebert_checkpoint,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type BaseBERT — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a BaseBERT 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
Knowledge_Encoder Ran
ran on a synthesized input · constructed an object; no result was computed
tdlhl/LoRKD/model/query_generator.py
code served (permissive licence) · get_code("2751ff6367a1ba60")
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 an instance of its own class, Knowledge_Encoder: the run constructed the object and did not call it, so no result was computed. 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)

# Create a minimal text_tower that accepts text input and returns 768-dim features
class MinimalTextTower(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(10, 768)
    
    def forward(self, text):
        # text is expected to be a tensor, we'll project it to 768 dims
        return self.linear(text)

# Instantiate the text tower
text_tower = MinimalTextTower()

# Create sample inputs for forward pass
# text: batch_size=2, feature_dim=10 (will be projected to 768 by text_tower)
text = torch.randn(2, 10)

# modality: batch_size=2, values in range [0, 3] since modality_embed has 4 embeddings
modality = torch.tensor([0, 1], dtype=torch.long)

ARGS = {
    "text_tower": text_tower,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Knowledge_Encoder — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Knowledge_Encoder 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
LoRALayer Ran
ran on a synthesized input · constructed an object; no result was computed
mediabrain-sjtu/lorkd/peft/lora_fast_shufflenet.py
pointer only (licence: NONE) · get_code("dc1bf240658da664")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, mediabrain-sjtu/lorkd when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

MedCPT Ran
ran on a synthesized input · constructed an object; no result was computed
tdlhl/LoRKD/model/query_generator.py
code served (permissive licence) · get_code("b50742ef9e3c7903")
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 an instance of its own class, MedCPT: the run constructed the object and did not call it, so no result was computed. 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 AutoModel

torch.manual_seed(0)

# Create a mock model that mimics AutoModel behavior
class MockTransformerModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(10, 768)
    
    def forward(self, **kwargs):
        # Return a mock output with last_hidden_state
        # batch_size=2, seq_len=5, hidden_dim=768
        batch_size = 2
        seq_len = 5
        hidden_dim = 768
        last_hidden_state = torch.randn(batch_size, seq_len, hidden_dim)
        return type('Output', (), {'last_hidden_state': last_hidden_state})()

# Patch AutoModel.from_pretrained to return our mock model
original_from_pretrained = AutoModel.from_pretrained
def mock_from_pretrained(checkpoint, **kwargs):
    return MockTransformerModel()

AutoModel.from_pretrained = mock_from_pretrained

# Create sample inputs for forward pass
text_input = {
    'input_ids': torch.randint(0, 1000, (2, 5)),
    'attention_mask': torch.ones(2, 5)
}

modality_input = torch.tensor([0, 1])

ARGS = {
    'cpt_checkpoint': 'mock-checkpoint'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MedCPT — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a MedCPT 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
MultiLoraConv2d Ran
ran on a synthesized input · constructed an object; no result was computed
mediabrain-sjtu/lorkd/peft/lora_fast_shufflenet.py
pointer only (licence: NONE) · get_code("81774072bef023f0")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, mediabrain-sjtu/lorkd when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

Random_Embed Ran
ran on a synthesized input · constructed an object; no result was computed
tdlhl/LoRKD/model/query_generator.py
code served (permissive licence) · get_code("37f1dea898fdd023")
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 an instance of its own class, Random_Embed: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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
import json
import tempfile
import os

torch.manual_seed(0)

# Create a temporary label2index mapping file
temp_dir = tempfile.mkdtemp()
label2index_path = os.path.join(temp_dir, 'label2index.json')

label2index_data = {
    'label_a': 0,
    'label_b': 1,
    'label_c': 2,
    'label_d': 3,
    'label_e': 4
}

with open(label2index_path, 'w') as f:
    json.dump(label2index_data, f)

ARGS = {
    'label2index_mapping': label2index_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Random_Embed — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Random_Embed 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
compute_average_gradient Ran
ran, honoured the contract we drafted
tdlhl/LoRKD/model/query_generator.py
code served (permissive licence) · get_code("62a601fb5fbbf828")
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 float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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 SimpleModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.linear2 = nn.Linear(3, 2)
    
    def forward(self, x):
        return self.linear2(self.linear1(x))

# Create module and perform a forward and backward pass to generate gradients
module = SimpleModule()
x = torch.randn(2, 4)
y = torch.randn(2, 2)
loss_fn = nn.MSELoss()
output = module(x)
loss = loss_fn(output, y)
loss.backward()

ARGS = {
    "module": module
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
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
get_window_size Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
tdlhl/LoRKD/model/SwinUNETR.py
code served (permissive licence) · get_code("168646537c6adfff")
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 tuple, ndim 2, dtype family int; 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

torch.manual_seed(0)

ARGS = {
    "x_size": (8, 12, 16),
    "window_size": (4, 4, 4),
    "shift_size": (2, 2, 2),
}
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 tuple, ndim 2, dtype family int — a tuple 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
window_partition Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
tdlhl/LoRKD/model/SwinUNETR.py
code served (permissive licence) · get_code("80ada9d6ef99fa0d")
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 Tensor, ndim 3, dtype family float, shape (8, 16, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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

torch.manual_seed(0)

# Test case 1: 4D tensor (batch, height, width, channels)
x_4d = torch.randn(2, 8, 8, 3)
window_size_4d = (4, 4)

# Test case 2: 5D tensor (batch, depth, height, width, channels)
x_5d = torch.randn(2, 4, 8, 8, 3)
window_size_5d = (2, 4, 4)

# Use the 4D case as the primary test
ARGS = {
    "x": x_4d,
    "window_size": window_size_4d
}
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 Tensor, ndim 3, dtype family float, shape (8, 16, 3) — shape (8, 16, 3) as a later run recorded it
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
window_reverse Ran
ran; our contract draft was wrong, not the code
tdlhl/LoRKD/model/SwinUNETR.py
code served (permissive licence) · get_code("68a071c415424018")
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 Tensor, ndim 5, dtype family float, shape (2, 4, 8, 6, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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)

# For 4D case: windows tensor should have shape (b * num_windows, window_size[0] * window_size[1] * window_size[2] * channels)
# dims = (b, d, h, w) where d is depth, h is height, w is width
# window_size = (window_d, window_h, window_w)

# 4D case setup
b_4d = 2
d = 4
h = 8
w = 6
window_size_4d = (2, 2, 2)  # (window_d, window_h, window_w)
channels = 3

# Calculate number of windows and reshape windows tensor
num_windows_d = d // window_size_4d[0]  # 2
num_windows_h = h // window_size_4d[1]  # 4
num_windows_w = w // window_size_4d[2]  # 3
total_windows_4d = num_windows_d * num_windows_h * num_windows_w  # 24

# windows shape: (b * num_windows, window_d * window_h * window_w * channels)
windows_4d = torch.randn(b_4d * total_windows_4d, window_size_4d[0] * window_size_4d[1] * window_size_4d[2] * channels)
dims_4d = (b_4d, d, h, w)

# 3D case setup
b_3d = 2
h_3d = 8
w_3d = 6
window_size_3d = (2, 2)  # (window_h, window_w)
channels_3d = 3

# Calculate number of windows for 3D
num_windows_h_3d = h_3d // window_size_3d[0]  # 4
num_windows_w_3d = w_3d // window_size_3d[1]  # 3
total_windows_3d = num_windows_h_3d * num_windows_w_3d  # 12

# windows shape: (b * num_windows, window_h * window_w * channels)
windows_3d = torch.randn(b_3d * total_windows_3d, window_size_3d[0] * window_size_3d[1] * channels_3d)
dims_3d = (b_3d, h_3d, w_3d)

# Use 4D case for ARGS
ARGS = {
    "windows": windows_4d,
    "window_size": window_size_4d,
    "dims": dims_4d
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 5, dtype family float, shape (2, 4, 8, 6, 3) — shape (2, 4, 8, 6, 3) as a later run recorded it
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
MyTokenizer Not yet run
unverified (harvested, no recorded run)
tdlhl/LoRKD/model/query_generator.py
code served (permissive licence) · get_code("b35da59b916d1985")
How it ran

no invocation recorded.

Query_Generator Not yet run
unverified (harvested, no recorded run)
tdlhl/LoRKD/model/query_generator.py
code served (permissive licence) · get_code("e1006ccc2b5c4dda")
How it ran

no invocation recorded.

Text_Tower Not yet run
unverified (harvested, no recorded run)
tdlhl/LoRKD/model/query_generator.py
code served (permissive licence) · get_code("3018fbd4e2cbb9cc")
How it ran

no invocation recorded.

Also present in other papers' code

Of 13 samples lifted from this paper's linked repositories, 13 carry a function identity and 0 do not. Of the 13 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 2 later) and 10 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
get_window_size 26 other papers
21 dated earlier, 4 later, 1 same year, order not determinable · 7 only as an assembly brick
2103.14030 (2021-03)
Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
2106.13230 (2021-06)
Video Swin Transformer
2111.14821 (2021-11)
End-to-End Referring Video Object Segmentation with Multimodal Transformers
and 23 more not named here
window_partition 7 other papers
5 dated earlier, 1 later, 1 same year, order not determinable
2204.00631 (2022-04)
UNetFormer: A Unified Vision Transformer Model and Pre-Training Framework for 3D Medical Image Segmentation
2211.02701 (2022-11)
MONAI: An open-source framework for deep learning in healthcare
2305.19467 (2023-05)
Synthetic CT Generation from MRI using 3D Transformer-based Denoising Diffusion Model
and 4 more not named here
window_reverse 3 other papers
3 dated earlier
2204.00631 (2022-04)
UNetFormer: A Unified Vision Transformer Model and Pre-Training Framework for 3D Medical Image Segmentation
2405.18356 (2024-05)
Universal and Extensible Language-Vision Models for Organ Segmentation and Tumor Detection from Abdominal Computed Tomography
2407.16697 (2024-07)
AbdomenAtlas: A Large-Scale, Detailed-Annotated, & Multi-Center Dataset for Efficient Transfer Learning and Open Algorithmic Benchmarking

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

The widespread adoption of large-scale pre-training techniques has significantly advanced the development of medical foundation models, enabling them to serve as versatile tools across a broad range of medical tasks. However, despite their strong generalization capabilities, medical foundation models pre-trained on large-scale datasets tend to suffer from domain gaps between heterogeneous data, leading to suboptimal performance on specific tasks compared to specialist models, as evidenced by previous studies. In this paper, we explore a new perspective called "Knowledge Decomposition" to improve the performance on specific medical tasks, which deconstructs the foundation model into multiple lightweight expert models, each dedicated to a particular anatomical region, with the aim of enhancing specialization and simultaneously reducing resource consumption. To accomplish the above objective, we propose a novel framework named Low-Rank Knowledge Decomposition (LoRKD), which explicitly separates gradients from different tasks by incorporating low-rank expert modules and efficient knowledge separation convolution. The low-rank expert modules resolve gradient conflicts between heterogeneous data from different anatomical regions, providing strong specialization at lower costs. The efficient knowledge separation convolution significantly improves algorithm efficiency by achieving knowledge separation within a single forward propagation. Extensive experimental results on segmentation and classification tasks demonstrate that our decomposed models not only achieve state-of-the-art performance but also exhibit superior transferability on downstream tasks, even surpassing the original foundation models in task-specific evaluations. The code is available at here.

For agents

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

get_harvested_code_for_paper("2409.19540")
get_code_for_paper("2409.19540")
have("2409.19540")

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

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

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

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

Connect an agent — have() is free.