SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2024.findings-naacl.145 · NAACL Findings · 2024

Role Prompting Guided Domain Adaptation with General Capability Preserve for Large Language Models

Rui Wang, Qi Zhu, Fei Mi, Hongru Wang, Kam-Fai Wong, Ruifeng Xu, Boyang Xue, Yi ♡▲

Open in the Atlas

Code that ran

7 of 15 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; 8 no recorded run), measured 2026-11-24; 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/2024.findings-naacl.145.json · badge: /api/ran/2024.findings-naacl.145.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
LianjiaTech/BELLE canonical (classifier label)
classifier basis: census
7 ran · 8 no recorded run
FunctionStatusWhere it lives
find_layers Ran
ran; our contract draft was wrong, not the code
LianjiaTech/BELLE/models/gptq/modelutils.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from squeezeailab/kvquant, is pointer only (licence: NONE) · get_code("a9e7f2cdf016b88b")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from squeezeailab/kvquant, and GitHub detected no licence in that repository 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.

get_bloom Ran
ran; our contract draft was wrong, not the code
LianjiaTech/BELLE/models/gptq/bloom.py
code served (permissive licence) · get_code("cd666c16d4aaa66d")
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 MockBloomForCausalLM. 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
from unittest.mock import Mock, patch
import sys

torch.manual_seed(0)

# Mock the transformers library to avoid actual model downloads
class MockBloomForCausalLM:
    def __init__(self, *args, **kwargs):
        self.seqlen = None
    
    @classmethod
    def from_pretrained(cls, model_name, torch_dtype=None):
        return cls()

# Create a mock module for transformers
mock_transformers = Mock()
mock_transformers.BloomForCausalLM = MockBloomForCausalLM

# Patch transformers before the function is called
sys.modules['transformers'] = mock_transformers

ARGS = {
    'model': 'bigscience/bloom-560m'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MockBloomForCausalLM — a MockBloomForCausalLM output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MockBloomForCausalLM 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
get_llama Ran
ran; our contract draft was wrong, not the code
LianjiaTech/BELLE/models/gptq/llama.py
code served (permissive licence) · get_code("88d590323ed219c8")
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 MockLlamaForCausalLM. 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
from unittest.mock import Mock, patch
import sys

torch.manual_seed(0)

# Create a mock LlamaForCausalLM class since we can't download the real model
class MockLlamaForCausalLM:
    def __init__(self, *args, **kwargs):
        self.seqlen = None
    
    @classmethod
    def from_pretrained(cls, model_name, torch_dtype=None):
        return cls()

# Patch the transformers import to return our mock
mock_transformers = Mock()
mock_transformers.LlamaForCausalLM = MockLlamaForCausalLM
sys.modules['transformers'] = mock_transformers

# The function expects a model identifier string (HuggingFace model name)
# We'll pass a simple string identifier
ARGS = {
    'model': 'meta-llama/Llama-2-7b'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MockLlamaForCausalLM — a MockLlamaForCausalLM output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MockLlamaForCausalLM 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
quantize Ran
ran; our contract draft was wrong, not the code
LianjiaTech/BELLE/models/gptq/quant.py
code served (permissive licence) · get_code("50ceff9d34d96d60")
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 Tensor, ndim 2, dtype family float, shape (2, 4) 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)

# x: tensor to quantize
x = torch.randn(2, 4)

# scale: scaling factor (tensor or float)
scale = torch.tensor(0.1)

# zero: zero point offset
zero = torch.tensor(0, dtype=torch.long)

# maxq: maximum quantization level
maxq = 255

ARGS = {
    "x": x,
    "scale": scale,
    "zero": zero,
    "maxq": maxq,
}
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 Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) 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
read_data Ran
ran; our contract draft was wrong, not the code
LianjiaTech/BELLE/eval/generation_html.py
code served (permissive licence) · get_code("d273809d732ec42f")
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. 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 tempfile
import os

# Create a temporary file with test data
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_path = temp_file.name

# Write some sample data that can be eval'd
test_data = [
    "{'x': 1, 'y': 2}",
    "{'x': 3, 'y': 4}",
    "[1, 2, 3]",
    "{'name': 'test', 'value': 42}"
]

for line in test_data:
    temp_file.write(line + '\n')

temp_file.close()

ARGS = {
    'path': temp_path
}
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 list — a list output has no array shape of its own; none is 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
write_result_chunk Ran
ran; our contract draft was wrong, not the code
LianjiaTech/BELLE/models/decrypt.py
code served (permissive licence) · get_code("abee36b2437e1ffd")
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 tuple. 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 io
import hashlib

# Create a file-like object for writing
fp = io.BytesIO()

# Create a hasher object (using hashlib.md5 as an example)
hasher = hashlib.md5()

# Create pending list with tuples of (chunk_idx, chunk_data)
# chunk_data should be bytes since fp.write() expects bytes
pending = [
    (0, b"chunk_0_data"),
    (1, b"chunk_1_data"),
    (2, b"chunk_2_data"),
]

# Initial write chunk index
w_chunk_idx = 0

ARGS = {
    "fp": fp,
    "w_chunk_idx": w_chunk_idx,
    "pending": pending,
    "hasher": hasher,
}
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 tuple — a tuple output has no array shape of its own; none is 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
xor_bytes Ran
ran; our contract draft was wrong, not the code
LianjiaTech/BELLE/models/decrypt.py
code served (permissive licence) · get_code("9638c3be1c6b03d1")
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 bytes. 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)

# Analyze the function:
# - data: needs to support len() and zip iteration (bytes-like)
# - key: needs to support len() and zip iteration (bytes-like)
# The function XORs data with a repeated key pattern

# Create small byte objects
data = b"hello"  # 5 bytes
key = b"ab"     # 2 bytes

ARGS = {
    "data": data,
    "key": key
}
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 bytes — a bytes output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a bytes 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
bloom_pack Not yet run
unverified (harvested, no recorded run)
LianjiaTech/BELLE/models/gptq/bloom.py
code served (permissive licence) · get_code("3861600d453a9d43")
How it ran

no invocation recorded.

bloom_sequential Not yet run
unverified (harvested, no recorded run)
LianjiaTech/BELLE/models/gptq/bloom.py
code served (permissive licence) · get_code("f1450934dfa7e840")
How it ran

no invocation recorded.

get_c4 Not yet run
unverified (harvested, no recorded run)
LianjiaTech/BELLE/models/gptq/datautils.py
code served (permissive licence) · get_code("91dba77fa391e15e")
How it ran

no invocation recorded.

get_ptb Not yet run
unverified (harvested, no recorded run)
LianjiaTech/BELLE/models/gptq/datautils.py
code served (permissive licence) · get_code("c1c9acf2a2b2ad95")
How it ran

no invocation recorded.

get_wikitext2 Not yet run
unverified (harvested, no recorded run)
LianjiaTech/BELLE/models/gptq/datautils.py
code served (permissive licence) · get_code("58476252d7ce923b")
How it ran

no invocation recorded.

llama_pack Not yet run
unverified (harvested, no recorded run)
LianjiaTech/BELLE/models/gptq/llama.py
code served (permissive licence) · get_code("7f1c42c308933cd9")
How it ran

no invocation recorded.

llama_sequential Not yet run
unverified (harvested, no recorded run)
LianjiaTech/BELLE/models/gptq/llama.py
code served (permissive licence) · get_code("5f5434220ca9b107")
How it ran

no invocation recorded.

load_quant Not yet run
unverified (harvested, no recorded run)
LianjiaTech/BELLE/models/gptq/bloom_inference.py
code served (permissive licence) · get_code("4b1d6ad992ab7654")
How it ran

no invocation recorded.

Also present in other papers' code

Of 15 samples lifted from this paper's linked repositories, 15 carry a function identity and 0 do not. Of the 15 distinct functions with an identity, 15 are also present in other papers whose code we hold (15 with at least one paper dated earlier, 0 the same month, 4 later) and 0 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
find_layers 27 other papers
8 dated earlier, 4 later, 14 same year, order not determinable, 1 undated
2203.13474 (2022-03)
CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis
2023.emnlp-main.892 (2023 (year only))
Z-FOLD: A Frustratingly Easy Post-Training Quantization Scheme for LLMs
2307.09288 (2023-07)
Llama 2: Open Foundation and Fine-Tuned Chat Models
and 24 more not named here
quantize 6 other papers
2 dated earlier, 1 later, 3 same year, order not determinable
2307.15290 (2023-07)
ChatHome: Development and Evaluation of a Domain-Specific Language Model for Home Renovation
2310.00034 (2023-10)
PB-LLM: Partially Binarized Large Language Models
2402.17946 (2024-02)
SparseLLM: Towards Global Pruning of Pre-trained Language Models
and 3 more not named here
get_bloom 5 other papers
3 dated earlier, 1 later, 1 same year, order not determinable
2301.00774 (2023-01)
SparseGPT: Massive Language Models Can Be Accurately Pruned in One-Shot
2307.15290 (2023-07)
ChatHome: Development and Evaluation of a Domain-Specific Language Model for Home Renovation
2310.09499 (2023-10)
One-Shot Sensitivity-Aware Mixed Sparsity Pruning for Large Language Models
and 2 more not named here
get_llama 5 other papers
2 dated earlier, 1 later, 2 same year, order not determinable
2307.15290 (2023-07)
ChatHome: Development and Evaluation of a Domain-Specific Language Model for Home Renovation
2310.09499 (2023-10)
One-Shot Sensitivity-Aware Mixed Sparsity Pruning for Large Language Models
2406.00800 (2024-06)
MagR: Weight Magnitude Reduction for Enhancing Post-Training Quantization
and 2 more not named here
write_result_chunk 2 other papers
2 dated earlier
2305.15062 (2023-05)
Lawyer LLaMA Technical Report
2307.15290 (2023-07)
ChatHome: Development and Evaluation of a Domain-Specific Language Model for Home Renovation
xor_bytes 2 other papers
2 dated earlier
2305.15062 (2023-05)
Lawyer LLaMA Technical Report
2307.15290 (2023-07)
ChatHome: Development and Evaluation of a Domain-Specific Language Model for Home Renovation
bloom_pack 1 other paper
1 dated earlier
2307.15290 (2023-07)
ChatHome: Development and Evaluation of a Domain-Specific Language Model for Home Renovation
bloom_sequential 1 other paper
1 dated earlier
2307.15290 (2023-07)
ChatHome: Development and Evaluation of a Domain-Specific Language Model for Home Renovation
get_c4 1 other paper
1 dated earlier
2307.15290 (2023-07)
ChatHome: Development and Evaluation of a Domain-Specific Language Model for Home Renovation
get_ptb 1 other paper
1 dated earlier
2307.15290 (2023-07)
ChatHome: Development and Evaluation of a Domain-Specific Language Model for Home Renovation
get_wikitext2 1 other paper
1 dated earlier
2307.15290 (2023-07)
ChatHome: Development and Evaluation of a Domain-Specific Language Model for Home Renovation
llama_pack 1 other paper
1 dated earlier
2307.15290 (2023-07)
ChatHome: Development and Evaluation of a Domain-Specific Language Model for Home Renovation
llama_sequential 1 other paper
1 dated earlier
2307.15290 (2023-07)
ChatHome: Development and Evaluation of a Domain-Specific Language Model for Home Renovation
load_quant 1 other paper
1 dated earlier
2307.15290 (2023-07)
ChatHome: Development and Evaluation of a Domain-Specific Language Model for Home Renovation
read_data 1 other paper
1 dated earlier
2307.15290 (2023-07)
ChatHome: Development and Evaluation of a Domain-Specific Language Model for Home Renovation

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-24.

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 growing interest in Large Language Models (LLMs) for specialized applications has revealed a significant challenge: when tailored to specific domains, LLMs tend to experience catastrophic forgetting, compromising their general capabilities and leading to a suboptimal user experience. Additionally, crafting a versatile model for multiple domains simultaneously often results in a decline in overall performance due to confusion between domains. In response to these issues, we present the RolE Prompting Guided Multi-Domain Adaptation (REGA) strategy. This novel approach effectively manages multi-domain LLM adaptation through three key components: 1) Self-Distillation constructs and replays general-domain exemplars to alleviate catastrophic forgetting. 2) Role Prompting assigns a central prompt to the general domain and a unique role prompt to each specific domain to minimize inter-domain confusion during training. 3) Role Integration reuses and integrates a small portion of domainspecific data to the general-domain data, which are trained under the guidance of the central prompt. The central prompt is used for a streamlined inference process, removing the necessity to switch prompts for different domains. Empirical results demonstrate that REGA effectively alleviates catastrophic forgetting and inter-domain confusion. This leads to improved domain-specific performance compared to standard fine-tuned models, while still preserving robust general capabilities.

For agents

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

get_harvested_code_for_paper("2024.findings-naacl.145")
get_code_for_paper("2024.findings-naacl.145")
have("2024.findings-naacl.145")

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

curl https://syntology.ai/api/ran/2024.findings-naacl.145.json

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

[![Syntology run record](https://syntology.ai/api/ran/2024.findings-naacl.145.svg)](https://syntology.ai/paper/2024.findings-naacl.145)

Connect an agent — have() is free.