SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2505.07437 · 2025

LEAD: Iterative Data Selection for Efficient LLM Instruction Tuning

arXiv · PDF · Open in the Atlas

Code that ran

19 of 21 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 14 have no contract verdict; 5 failures of our instrument; 2 no recorded run), measured 2026-11-23; 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/2505.07437.json · badge: /api/ran/2505.07437.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
HKUSTDial/LEAD canonical (classifier label)
classifier basis not recorded on the link
19 ran · 2 no recorded run
FunctionStatusWhere it lives
assign_dataset_task_ids Ran
ran on a synthesized input
HKUSTDial/LEAD/src/offline/clustering.py
code served (permissive licence) · get_code("45c349e9550f0ef9")
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

torch.manual_seed(0)

# Create a list of data items with 'dataset' keys
# Each item is a dict that contains a 'dataset' field
data_items = [
    {'dataset': 'imagenet', 'data': torch.randn(2, 4)},
    {'dataset': 'cifar10', 'data': torch.randn(2, 4)},
    {'dataset': 'imagenet', 'data': torch.randn(2, 4)},
    {'dataset': 'mnist', 'data': torch.randn(2, 4)},
    {'dataset': 'cifar10', 'data': torch.randn(2, 4)},
]

ARGS = {
    'data_items': data_items
}
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 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
calculate_cosine_similarity Ran
ran on a synthesized input
HKUSTDial/LEAD/src/online/utilityChange.py
code served (permissive licence) · get_code("0228778589332787")
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. 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, 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)

# Create two parameter update vectors as small tensors
# These represent delta_theta_ik (current parameter change) and delta_theta_i_1 (previous parameter change)
delta_theta_ik = torch.randn(4)
delta_theta_i_1 = torch.randn(4)

ARGS = {
    "delta_theta_ik": delta_theta_ik,
    "delta_theta_i_1": delta_theta_i_1,
}
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
calculate_param_changes Ran
ran on a synthesized input
HKUSTDial/LEAD/src/online/utilityChange.py
code served (permissive licence) · get_code("2f2560c89f620a6b")
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. 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, 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)

# Create two small tensors representing old and new parameters
old_params = torch.randn(4, 3)
new_params = torch.randn(4, 3)

ARGS = {
    "old_params": old_params,
    "new_params": new_params,
}
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
categorical_draw Ran
ran on a synthesized input
HKUSTDial/LEAD/src/online/exp3.py
code served (permissive licence) · get_code("6cf648b17d975e07")
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 int, ndim 0, dtype family int, 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 numpy as np

np.random.seed(0)

# categorical_draw takes a probability distribution and draws from it
# The function uses len(probs) and passes probs to np.random.choice as the p parameter
# So probs should be a 1D array-like of probabilities that sum to 1

probs = np.array([0.1, 0.2, 0.3, 0.4])

ARGS = {
    "probs": probs
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, 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
create_prompt_with_llama2_chat_format Ran
ran; our contract draft was wrong, not the code
HKUSTDial/LEAD/src/eval/templates.py
pointer only (licence: MIT); the stored copy get_code serves, from Blue-Raincoat/SelectIT, is pointer only (licence: NONE) · get_code("5637030b6f66a7c5")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from Blue-Raincoat/SelectIT, 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.

create_prompt_with_olmo_chat_format Ran
ran on a synthesized input
HKUSTDial/LEAD/src/eval/templates.py
pointer only (licence: MIT); the stored copy get_code serves, from THU-KEG/ADELIE, is pointer only (licence: NONE) · get_code("45e2cc1022c95249")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from THU-KEG/ADELIE, 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.

create_prompt_with_tulu_chat_format Ran
ran; our contract draft was wrong, not the code
HKUSTDial/LEAD/src/eval/templates.py
pointer only (licence: MIT); the stored copy get_code serves, from Blue-Raincoat/SelectIT, is pointer only (licence: NONE) · get_code("661a1d8a5c30c318")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from Blue-Raincoat/SelectIT, 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.

dispatch_openai_chat_requesets Ran
ran on a synthesized input
HKUSTDial/LEAD/src/eval/dispatch_openai_requests.py
code served (permissive licence) · get_code("64d6138fb03f75c7")
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 coroutine. 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 asyncio
from typing import Any, List, Dict
from unittest.mock import AsyncMock, MagicMock


# Create a mock async client that simulates OpenAI API responses
class MockAsyncCompletion:
    @staticmethod
    async def create(model: str, messages: List[Dict[str, Any]], **kwargs) -> str:
        # Simulate an async OpenAI API response
        await asyncio.sleep(0.01)  # Simulate network delay
        return f"Response for {len(messages)} messages"


class MockAsyncClient:
    def __init__(self):
        self.chat = MagicMock()
        self.chat.completions = MockAsyncCompletion()


# Set up global mock client
aclient = MockAsyncClient()


# Construct valid arguments for the function
messages_list = [
    [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is 2+2?"}
    ],
    [
        {"role": "system", "content": "You are a math tutor."},
        {"role": "user", "content": "Explain calculus."}
    ]
]

model = "gpt-4"

completion_kwargs = {
    "temperature": 0.7,
    "max_tokens": 150,
    "top_p": 0.9
}

ARGS = {
    "messages_list": messages_list,
    "model": model,
    **completion_kwargs
}
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 coroutine — a coroutine output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a coroutine 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
dispatch_openai_prompt_requesets Ran
ran on a synthesized input
HKUSTDial/LEAD/src/eval/dispatch_openai_requests.py
code served (permissive licence) · get_code("5bbc896a72379511")
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 coroutine. 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 asyncio
from typing import Any, List, Dict
from unittest.mock import AsyncMock, MagicMock

# Create a mock async client that behaves like OpenAI's async client
mock_aclient = MagicMock()

# Create mock completion responses
async def mock_completion(*args, **kwargs):
    # Simulate OpenAI API response
    return MagicMock(choices=[MagicMock(text="This is a mock response.")])

# Set up the mock to return coroutines
mock_aclient.completions.create = AsyncMock(side_effect=mock_completion)

# Inject the mock into the function's namespace
import sys
current_module = sys.modules[__name__]

# Create minimal valid arguments
prompt_list = [
    "What is the capital of France?",
    "Explain quantum computing."
]

model = "gpt-3.5-turbo"

completion_kwargs = {
    "temperature": 0.7,
    "max_tokens": 100,
    "top_p": 0.95
}

ARGS = {
    "prompt_list": prompt_list,
    "model": model,
    "completion_kwargs": completion_kwargs
}
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 coroutine — a coroutine output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a coroutine 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
encode_with_messages_format Ran
ran on a synthesized input
HKUSTDial/LEAD/src/online/template.py
code served (permissive licence) · get_code("1d1694af124350b8")
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
from transformers import AutoTokenizer

torch.manual_seed(0)

# Create a minimal tokenizer stand-in that has the required methods and attributes
class MinimalTokenizer:
    def __init__(self):
        self.eos_token = '</s>'
    
    def __call__(self, text, return_tensors=None, max_length=None, truncation=False):
        # Simple tokenization: split by spaces and add special tokens
        tokens = text.split()
        token_ids = [hash(token) % 1000 for token in tokens]  # Simple hash-based token IDs
        
        if max_length and len(token_ids) > max_length:
            token_ids = token_ids[:max_length]
        
        if return_tensors == 'pt':
            input_ids = torch.tensor([token_ids], dtype=torch.long)
            return type('TokenizerOutput', (), {'input_ids': input_ids})()
        
        return {'input_ids': token_ids}

# Create tokenizer instance
tokenizer = MinimalTokenizer()

# Create example with required fields
example = {
    'messages': [
        {'role': 'system', 'content': 'You are a helpful assistant.'},
        {'role': 'user', 'content': 'What is machine learning?'},
        {'role': 'assistant', 'content': 'Machine learning is a subset of AI.'}
    ],
    'task': 1,
    'idf_cluster': 2,
    'dataset_id': 3,
    'query_token': 4,
    'cross_entropy': 0.5
}

max_seq_length = 128

ARGS = {
    'example': example,
    'tokenizer': tokenizer,
    'max_seq_length': max_seq_length
}
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 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
encode_with_messages_format_wo_conv Ran
ran on a synthesized input
HKUSTDial/LEAD/src/online/template.py
code served (permissive licence) · get_code("7289ececedcd890f")
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
from transformers import AutoTokenizer

torch.manual_seed(0)

# Create a minimal tokenizer stand-in that has the required methods
class MinimalTokenizer:
    def __init__(self):
        self.eos_token = '</s>'
    
    def __call__(self, text, return_tensors=None, max_length=None, truncation=False):
        # Simple tokenization: split by spaces and assign token IDs
        tokens = text.split()
        token_ids = [i + 1 for i in range(len(tokens))]
        
        if max_length and len(token_ids) > max_length:
            token_ids = token_ids[:max_length]
        
        if return_tensors == 'pt':
            input_ids = torch.tensor([token_ids])
            return type('TokenizerOutput', (), {'input_ids': input_ids})()
        
        return token_ids

tokenizer = MinimalTokenizer()

# Create an example with messages
example = {
    'messages': [
        {
            'role': 'system',
            'content': 'You are a helpful assistant'
        },
        {
            'role': 'user',
            'content': 'Hello how are you'
        },
        {
            'role': 'assistant',
            'content': 'I am doing well thank you'
        }
    ]
}

max_seq_length = 128

ARGS = {
    'example': example,
    'tokenizer': tokenizer,
    'max_seq_length': max_seq_length
}
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 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
encode_with_prompt_completion_format Ran
ran on a synthesized input
HKUSTDial/LEAD/src/online/template.py
code served (permissive licence) · get_code("57148174b9cdbbea")
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
from unittest.mock import Mock

torch.manual_seed(0)

# Create a minimal tokenizer mock that has the methods/attributes used
class MinimalTokenizer:
    def __init__(self):
        self.eos_token = "</s>"
    
    def __call__(self, text, return_tensors=None, max_length=None, truncation=False):
        # Return a mock object with input_ids attribute
        # Simulate tokenization: just create small tensors
        token_count = min(len(text.split()) + 2, max_length) if max_length else len(text.split()) + 2
        result = Mock()
        result.input_ids = torch.randint(0, 100, (1, token_count))
        return result

# Create example data
example_train = {
    'input': 'What is the capital of France?',
    'output': 'Paris is the capital of France.'
}

example_eval = {
    'input': 'What is the capital of Germany?'
}

tokenizer = MinimalTokenizer()
max_seq_length = 32

# Define ARGS dict with all parameters
ARGS = {
    'example': example_train,
    'tokenizer': tokenizer,
    'max_seq_length': max_seq_length,
    'mode': 'train'
}
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 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
generate_completions Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
HKUSTDial/LEAD/src/eval/utils.py
code served (permissive licence) · get_code("cdbcc01805fac313")
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. 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 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
from transformers import PreTrainedModel, PreTrainedTokenizer

torch.manual_seed(0)

# Minimal mock tokenizer
class MockTokenizer:
    def __init__(self):
        self.eos_token_id = 2
        self.pad_token_id = 0
        self.bos_token_id = 1
    
    def __call__(self, texts, padding=None, return_tensors=None, add_special_tokens=True):
        # Return a mock tokenization result
        batch_size = len(texts) if isinstance(texts, list) else 1
        seq_len = 5
        
        class TokenizationResult:
            def __init__(self):
                self.input_ids = torch.randint(3, 10, (batch_size, seq_len))
                self.attention_mask = torch.ones(batch_size, seq_len)
        
        return TokenizationResult()
    
    def batch_decode(self, token_ids, skip_special_tokens=True):
        # Return mock decoded strings
        batch_size = token_ids.shape[0]
        return ["mock output " + str(i) for i in range(batch_size)]

# Minimal mock model
class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
        self.device_obj = torch.device('cpu')
    
    @property
    def device(self):
        return self.device_obj
    
    def generate(self, input_ids, attention_mask, eos_token_id, stopping_criteria=None, **kwargs):
        batch_size = input_ids.shape[0]
        num_return_sequences = kwargs.get('num_return_sequences', 1)
        # Generate mock output tokens
        output_length = input_ids.shape[1] + 3
        outputs = torch.randint(3, 10, (batch_size * num_return_sequences, output_length))
        return outputs

model = MockModel()
tokenizer = MockTokenizer()

prompts = [
    "This is a test prompt.",
    "Another test prompt."
]

stop_id_sequences = [[2], [0, 2]]

ARGS = {
    'model': model,
    'tokenizer': tokenizer,
    'prompts': prompts,
    'batch_size': 2,
    'stop_id_sequences': stop_id_sequences,
    'add_special_tokens': True,
    'disable_tqdm': True,
    'max_new_tokens': 10,
    'num_return_sequences': 1,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm, transformers — 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
get_next_word_predictions Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
HKUSTDial/LEAD/src/eval/utils.py
code served (permissive licence) · get_code("d134c88af0236263")
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. 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
from unittest.mock import Mock

torch.manual_seed(0)

# Build a minimal model that satisfies function requirements
class MinimalLanguageModel(nn.Module):
    def __init__(self, vocab_size=100, hidden_size=4):
        super().__init__()
        self.linear = nn.Linear(hidden_size, vocab_size)
        self.device_obj = Mock()
        self.device_obj.type = 'cpu'
    
    @property
    def device(self):
        return self.device_obj
    
    def forward(self, input_ids, attention_mask):
        # input_ids: (batch_size, seq_len)
        # Return logits of shape (batch_size, seq_len, vocab_size)
        batch_size, seq_len = input_ids.shape
        hidden = torch.randn(batch_size, seq_len, 4)
        logits = self.linear(hidden)
        return Mock(logits=logits)

# Build a minimal tokenizer that satisfies function requirements
class MinimalTokenizer:
    def __init__(self, vocab_size=100):
        self.vocab_size = vocab_size
    
    def __call__(self, texts, padding='longest', return_tensors='pt', add_special_tokens=True):
        if isinstance(texts, str):
            texts = [texts]
        max_len = max(len(text.split()) for text in texts) + 2
        batch_size = len(texts)
        input_ids = torch.randint(0, self.vocab_size, (batch_size, max_len))
        attention_mask = torch.ones(batch_size, max_len)
        return Mock(input_ids=input_ids, attention_mask=attention_mask)
    
    def convert_ids_to_tokens(self, ids):
        if isinstance(ids, torch.Tensor):
            ids = ids.tolist()
        if isinstance(ids, list):
            return [f'token_{id}' for id in ids]
        return f'token_{ids}'

model = MinimalLanguageModel(vocab_size=100, hidden_size=4)
tokenizer = MinimalTokenizer(vocab_size=100)
prompts = ["Hello world", "How are you"]
candidate_token_ids = torch.tensor([5, 10, 15, 20])

ARGS = {
    'model': model,
    'tokenizer': tokenizer,
    'prompts': prompts,
    'candidate_token_ids': candidate_token_ids,
    'batch_size': 1,
    'return_token_predictions': False,
    'add_special_tokens': True,
    'disable_tqdm': True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — 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
get_perplexity_and_embedding_part_text Ran
ran; our contract draft was wrong, not the code
HKUSTDial/LEAD/src/offline/difficulty_score.py
code served (permissive licence) · get_code("652eac296628dd5e")
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. 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

torch.manual_seed(0)

# Create a minimal tokenizer stand-in
class MinimalTokenizer:
    def __init__(self):
        self.vocab_size = 100
    
    def encode(self, text, return_tensors=None, truncation=False, max_length=None):
        # Return a simple encoding based on text length
        # Simulate tokenization by creating token ids
        token_ids = [1, 2, 3, 4, 5][:max_length] if max_length else [1, 2, 3, 4, 5]
        if return_tensors == 'pt':
            return torch.tensor([token_ids], dtype=torch.long)
        return token_ids

# Create a minimal language model
class MinimalLM(nn.Module):
    def __init__(self, vocab_size=100, hidden_size=8):
        super().__init__()
        self.embedding = nn.Embedding(vocab_size, hidden_size)
        self.linear = nn.Linear(hidden_size, vocab_size)
    
    def forward(self, input_ids, labels=None):
        # Embed input
        x = self.embedding(input_ids)  # (batch, seq_len, hidden)
        # Get logits
        logits = self.linear(x)  # (batch, seq_len, vocab_size)
        
        # Compute loss if labels provided
        loss = None
        if labels is not None:
            loss_fn = nn.CrossEntropyLoss(ignore_index=-100, reduction='mean')
            loss = loss_fn(logits.view(-1, logits.size(-1)), labels.view(-1))
        
        # Return object with loss and logits attributes
        class Output:
            pass
        output = Output()
        output.loss = loss
        output.logits = logits
        return output

tokenizer = MinimalTokenizer()
model = MinimalLM(vocab_size=100, hidden_size=8)
model.eval()

text = "hello world test example"
target_span = "world test"
max_length = 512

ARGS = {
    'tokenizer': tokenizer,
    'model': model,
    'text': text,
    'target_span': target_span,
    'max_length': max_length
}
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 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
load_data Ran
ran on a synthesized input
HKUSTDial/LEAD/src/offline/clustering.py
code served (permissive licence) · get_code("30348ef4ac1d9f07")
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 json
import numpy as np
import tempfile
import os

# Create a temporary JSONL file with test data
temp_dir = tempfile.mkdtemp()
input_file = os.path.join(temp_dir, "test_data.jsonl")

# Write test data to JSONL file
test_data = [
    {"idf": 0.5, "text": "sample document one"},
    {"idf": 1.2, "text": "sample document two"},
    {"idf": 0.8, "text": "sample document three"},
]

with open(input_file, 'w', encoding='utf-8') as f:
    for item in test_data:
        f.write(json.dumps(item) + '\n')

ARGS = {
    "input_file": input_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — 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
load_data Ran
ran on a synthesized input
HKUSTDial/LEAD/src/offline/difficulty_score.py
code served (permissive licence) · get_code("157e4633d9e5ccce")
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 json
import tempfile
import os

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

# Write test data to the temporary file
test_data = [
    {'dataset': 'statQA', 'question': 'What is 2+2?', 'answer': '4'},
    {'dataset': 'other', 'question': 'What is 3+3?', 'answer': '6'},
    {'dataset': 'another', 'question': 'What is 4+4?', 'answer': '8'},
    {'dataset': 'statQA', 'question': 'What is 5+5?', 'answer': '10'},
]

for item in test_data:
    temp_file.write(json.dumps(item) + '\n')

temp_file.close()

ARGS = {
    'data_path': temp_file_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, 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
perform_clustering Ran
ran on a synthesized input
HKUSTDial/LEAD/src/offline/clustering.py
code served (permissive licence) · get_code("ead339ee380ea819")
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 numpy as np
from sklearn.cluster import KMeans

# Set random seed for reproducibility
np.random.seed(42)

# Create small synthetic data for clustering
# X should be a 2D numpy array with shape (n_samples, n_features)
# Using 10 samples and 4 features to keep it tiny
X = np.random.randn(10, 4)

# Define the arguments dictionary
ARGS = {
    "X": X,
    "n_clusters": 7,
    "random_state": 42,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn — 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
retry_on_exception Ran
ran on a synthesized input
HKUSTDial/LEAD/src/eval/utils.py
code served (permissive licence) · get_code("83f3d617be77562f")
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 function. 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 time
import functools

def retry_on_exception(max_attempts=4, delay=1, backoff=2):
    """
    Retry a function on exception. Useful for HF API calls that may fail due to
    network issues. E.g., https://beaker.org/ex/01J69P87HJQQ7X5DXE1CPWF974
    `huggingface_hub.utils._errors.HfHubHTTPError: 429 Client Error`

    We can test it with the following code.
    @retry_on_exception(max_attempts=4, delay=1, backoff=2)
    def test():
        raise Exception("Test exception")

    test()
    """

    def decorator(func):

        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            attempts = 0
            local_delay = delay
            while attempts < max_attempts:
                try:
                    return func(*args, **kwargs)
                except Exception as e:
                    attempts += 1
                    if attempts == max_attempts:
                        raise e
                    print(f'Attempt {attempts} failed. Retrying in {local_delay} seconds...')
                    time.sleep(local_delay)
                    local_delay *= backoff
            return None
        return wrapper
    return decorator


# Test function that succeeds on second attempt
call_count = 0

@retry_on_exception(max_attempts=4, delay=0.01, backoff=2)
def test_function():
    global call_count
    call_count += 1
    if call_count < 2:
        raise ValueError("Simulated failure")
    return "Success"


ARGS = {
    "max_attempts": 4,
    "delay": 0.01,
    "backoff": 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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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_model_params_vector Not yet run
unverified (harvested, no recorded run)
HKUSTDial/LEAD/src/online/utilityChange.py
code served (permissive licence) · get_code("298ba0aff249df55")
How it ran

no invocation recorded.

get_perplexity_and_embedding_whole_text Not yet run
unverified (harvested, no recorded run)
HKUSTDial/LEAD/src/offline/difficulty_score.py
code served (permissive licence) · get_code("e6e19cb6234cc995")
How it ran

no invocation recorded.

Also present in other papers' code

Of 21 samples lifted from this paper's linked repositories, 21 carry a function identity and 0 do not. Of the 21 distinct functions with an identity, 7 are also present in other papers whose code we hold (7 with at least one paper dated earlier, 0 the same month, 2 later) and 14 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_next_word_predictions 10 other papers
8 dated earlier, 2 later
2401.15006 (2024-01)
Airavata: Introducing Hindi Instruction-tuned LLM
2401.16405 (2024-01)
Scaling Sparse Fine-Tuning to Large Language Models
2402.16705 (2024-02)
SelectIT: Selective Instruction Tuning for LLMs via Uncertainty-Aware Self-Reflection
and 7 more not named here
generate_completions 5 other papers
4 dated earlier, 1 later
2402.16705 (2024-02)
SelectIT: Selective Instruction Tuning for LLMs via Uncertainty-Aware Self-Reflection
2405.05008 (2024-05)
ADELIE: Aligning Large Language Models on Information Extraction
2410.24175 (2024-10)
Constraint Back-translation Improves Complex Instruction Following of Large Language Models
and 2 more not named here
get_perplexity_and_embedding_part_text 3 other papers
3 dated earlier
2308.12032 (2023-08)
From Quantity to Quality: Boosting LLM Performance with Self-Guided Data Selection for Instruction Tuning
2410.05725 (2024-10)
KnowledgeSG: Privacy-Preserving Synthetic Text Generation with Knowledge Distillation from Server
2410.09335 (2024-10)
Rethinking Data Selection at Scale: Random Selection is Almost All You Need
get_perplexity_and_embedding_whole_text 3 other papers
3 dated earlier
2308.12032 (2023-08)
From Quantity to Quality: Boosting LLM Performance with Self-Guided Data Selection for Instruction Tuning
2410.05725 (2024-10)
KnowledgeSG: Privacy-Preserving Synthetic Text Generation with Knowledge Distillation from Server
2410.09335 (2024-10)
Rethinking Data Selection at Scale: Random Selection is Almost All You Need
create_prompt_with_llama2_chat_format 2 other papers
2 dated earlier
2402.16705 (2024-02)
SelectIT: Selective Instruction Tuning for LLMs via Uncertainty-Aware Self-Reflection
2405.05008 (2024-05)
ADELIE: Aligning Large Language Models on Information Extraction
create_prompt_with_olmo_chat_format 2 other papers
2 dated earlier
2402.16705 (2024-02)
SelectIT: Selective Instruction Tuning for LLMs via Uncertainty-Aware Self-Reflection
2405.05008 (2024-05)
ADELIE: Aligning Large Language Models on Information Extraction
create_prompt_with_tulu_chat_format 1 other paper
1 dated earlier
2402.16705 (2024-02)
SelectIT: Selective Instruction Tuning for LLMs via Uncertainty-Aware Self-Reflection

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

Repositories linked to this paper

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

Abstract

Instruction tuning has emerged as a critical paradigm for improving the capabilities and alignment of large language models (LLMs). However, existing iterative model-aware data selection methods incur significant computational overhead, as they rely on repeatedly performing full-dataset model inference to estimate sample utility for subsequent training iterations, creating a fundamental efficiency bottleneck. In this paper, we propose LEAD, an efficient iterative data selection framework that accurately estimates sample utility entirely within the standard training loop, eliminating the need for costly additional model inference. At its core, LEAD introduces Instance-Level Dynamic Uncertainty (IDU), a theoretically grounded utility function combining instantaneous training loss, gradient-based approximation of loss changes, and exponential smoothing of historical loss signals. To further scale efficiently to large datasets, LEAD employs a two-stage, coarse-to-fine selection strategy, adaptively prioritizing informative clusters through a multi-armed bandit mechanism, followed by precise fine-grained selection of high-utility samples using IDU. Extensive experiments across four diverse benchmarks show that LEAD significantly outperforms state-of-the-art methods, improving average model performance by 6.1%-10.8% while using only 2.5% of the training data and reducing overall training time by 5-10x.

For agents

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

get_harvested_code_for_paper("2505.07437")
get_code_for_paper("2505.07437")
have("2505.07437")

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

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

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

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

Connect an agent — have() is free.