SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2402.12842 · 2024

PromptKD: Distilling Student-Friendly Knowledge for Generative Language Models via Prompt Tuning

arXiv · PDF · Open in the Atlas

Code that ran

8 of 10 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; 2 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 5 failures of our instrument; 2 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/2402.12842.json · badge: /api/ran/2402.12842.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
gmkim-ai/promptkd canonical (classifier label)
classifier basis: census
8 ran · 2 no recorded run
FunctionStatusWhere it lives
add_data_args Ran
ran; our contract draft was wrong, not the code
gmkim-ai/promptkd/arguments.py
code served (permissive licence) · get_code("a692be6eb021f68d")
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 ArgumentParser. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import argparse

def add_data_args(parser: argparse.ArgumentParser):
    group = parser.add_argument_group('data', 'data configurations')
    group.add_argument('--data-dir', type=str, default=None)
    group.add_argument('--processed-data-dir', type=str, default=None)
    group.add_argument('--force-process', action='store_true')
    group.add_argument('--force-process-demo', action='store_true')
    group.add_argument('--data-process-workers', type=int, default=-1)
    group.add_argument('--train-num', type=int, default=-1)
    group.add_argument('--train-ratio', type=float, default=1)
    group.add_argument('--dev-num', type=int, default=-1)
    group.add_argument('--dev-ratio', type=float, default=1)
    group.add_argument('--gen-num', type=int, default=-1)
    group.add_argument('--data-names', type=str, default=None)
    group.add_argument('--prompt-type', type=str, default=None)
    group.add_argument('--num-workers', type=int, default=1)
    group.add_argument('--max-prompt-length', type=int, default=512)
    group.add_argument('--min-prompt-length', type=int, default=128)
    group.add_argument('--json-data', action='store_true')
    group.add_argument('--bin-data', action='store_true')
    group.add_argument('--txt-data', action='store_true')
    group.add_argument('--prompt-data-dir', type=str)
    group.add_argument('--lm-data-dir', type=str)
    group.add_argument('--eval-ppl', action='store_true')
    group.add_argument('--eval-rw', action='store_true')
    group.add_argument('--eval-gen', action='store_true')
    group.add_argument('--only-prompt', action='store_true')
    return parser

ARGS = {
    'parser': argparse.ArgumentParser()
}
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 ArgumentParser — a ArgumentParser output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ArgumentParser 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
add_model_args Ran
ran; our contract draft was wrong, not the code
gmkim-ai/promptkd/arguments.py
code served (permissive licence) · get_code("de5974eab2121c2c")
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 ArgumentParser. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import argparse
import torch

torch.manual_seed(0)

# Create a parser and call the function to understand what it does
parser = argparse.ArgumentParser()

# The function add_model_args modifies the parser by adding argument groups
# We need to construct a valid ArgumentParser as the only argument

ARGS = {
    'parser': argparse.ArgumentParser(description='Test parser for model args')
}
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 ArgumentParser — a ArgumentParser output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ArgumentParser 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
calc_batch Ran
ran, honoured the contract we drafted
gmkim-ai/promptkd/evaluate_exposure_bias.py
code served (permissive licence) · get_code("a2088913a75c72ec")
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, 12) 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
import torch.nn.functional as F

torch.manual_seed(0)

# Small tokenizer stand-in
class MockTokenizer:
    def __init__(self):
        self.pad_token_id = 0
        self.vocab_size = 100

tokenizer = MockTokenizer()

# Small model that mimics transformer output
class MockModel(nn.Module):
    def __init__(self, vocab_size=100, hidden_dim=4):
        super().__init__()
        self.hidden_dim = hidden_dim
        self.vocab_size = vocab_size
        self.embedding = nn.Embedding(vocab_size, hidden_dim)
        self.lm_head = nn.Linear(hidden_dim, vocab_size)
    
    def forward(self, input_ids, attention_mask=None, position_ids=None, use_cache=False):
        x = self.embedding(input_ids)
        logits = self.lm_head(x)
        
        class Output:
            pass
        
        output = Output()
        output.logits = logits
        return output
    
    def generate(self, input_ids, attention_mask=None, generation_config=None, 
                 min_length=None, max_new_tokens=None, **kwargs):
        batch_size = input_ids.shape[0]
        seq_len = input_ids.shape[1]
        # Generate some dummy token ids
        new_tokens = torch.randint(1, self.vocab_size, (batch_size, max_new_tokens or 5))
        sequences = torch.cat([input_ids, new_tokens], dim=1)
        
        class GenOutput:
            pass
        
        gen_output = GenOutput()
        gen_output.sequences = sequences
        return gen_output

# Generation config stand-in
class MockGenerationConfig:
    pass

generation_config = MockGenerationConfig()

# Args configuration
class MockArgs:
    def __init__(self):
        self.model_type = 'gpt2'
        self.max_length = 20
        self.eb_sample_times = 2
        self.teacher_peft_path = None
        self.prompt_len = 3

args = MockArgs()

# Create models
model = MockModel(vocab_size=100, hidden_dim=4)
teacher_model = MockModel(vocab_size=100, hidden_dim=4)

# Create model batch
batch_size = 2
query_seq_len = 8
query_ids = torch.randint(1, 100, (batch_size, query_seq_len))
attention_mask_batch = torch.ones(batch_size, query_seq_len, dtype=torch.long)
model_batch = {
    'input_ids': query_ids,
    'attention_mask': attention_mask_batch,
    'use_cache': False
}

# Construct ARGS dict
ARGS = {
    'args': args,
    'tokenizer': tokenizer,
    'generation_config': generation_config,
    'model': model,
    'teacher_model': teacher_model,
    'model_batch': model_batch,
    'gen_model_type': 'base',
    'st_change': False
}
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, 12) — shape (2, 12) 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
exact_match Ran
ran, violated the contract we drafted
gmkim-ai/promptkd/rouge_metric.py
code served (permissive licence) · get_code("61c5ad3a7b3c5731")
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 bool, 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 string

def normalize_answer(s):
    """Lower text and remove punctuation, and extra whitespace."""

    def white_space_fix(text):
        return ' '.join(text.split())

    def remove_punc(text):
        exclude = set(string.punctuation)
        return ''.join((ch for ch in text if ch not in exclude))

    def lower(text):
        return text.lower()
    return white_space_fix(remove_punc(lower(s)))

def exact_match(prediction, ground_truth, xlingual=False):
    return normalize_answer(prediction) == normalize_answer(ground_truth)


ARGS = {
    "prediction": "Hello, World!",
    "ground_truth": "hello world",
    "xlingual": False
}
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 bool, 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_inputs Ran
ran; our contract draft was wrong, not the code
gmkim-ai/promptkd/evaluate_exposure_bias.py
code served (permissive licence) · get_code("a71327fc1087c21e")
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

torch.manual_seed(0)

# Stand-in tokenizer class
class MockTokenizer:
    def __init__(self):
        self.pad_token_id = 0

# Stand-in args class
class MockArgs:
    def __init__(self, model_type='gpt2'):
        self.model_type = model_type

# Create tokenizer
tokenizer = MockTokenizer()

# Create full_ids tensor (batch_size=2, seq_len=4)
# Use values > 0 to avoid all being pad tokens
full_ids = torch.tensor([
    [1, 2, 3, 0],
    [5, 6, 0, 0]
], dtype=torch.long)

# Create args
args = MockArgs(model_type='gpt2')

ARGS = {
    'args': args,
    'full_ids': full_ids,
    'tokenizer': tokenizer
}
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
get_learning_rate_scheduler Ran
ran; our contract draft was wrong, not the code
gmkim-ai/promptkd/train_promptkd.py
code served (permissive licence) · get_code("846c4335c1b51b91")
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 LambdaLR. 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 torch.optim import Adam

torch.manual_seed(0)

# Create a minimal model
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

# Create optimizer
model = MinimalModel()
optimizer = Adam(model.parameters(), lr=0.001)

# Create args object as a simple namespace-like class
class Args:
    def __init__(self):
        self.total_iters = None
        self.train_iters_per_epoch = 100
        self.epochs = 5
        self.lr_decay_style = 'constant'
        self.warmup_iters = 10
        self.lr_min = 1e-5

args = Args()

ARGS = {
    'args': args,
    'optimizer': optimizer
}
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 LambdaLR — a LambdaLR output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a LambdaLR 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
normalize_answer Ran
ran; our contract draft was wrong, not the code
gmkim-ai/promptkd/rouge_metric.py
code served (permissive licence) · get_code("52a9f448d8cbd82a")
How it ran

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

import string

def normalize_answer(s):
    """Lower text and remove punctuation, and extra whitespace."""

    def white_space_fix(text):
        return ' '.join(text.split())

    def remove_punc(text):
        exclude = set(string.punctuation)
        return ''.join((ch for ch in text if ch not in exclude))

    def lower(text):
        return text.lower()
    return white_space_fix(remove_punc(lower(s)))

ARGS = {
    "s": "Hello, World!  This is a TEST."
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
rouge Ran
ran, honoured the contract we drafted
gmkim-ai/promptkd/rouge_metric.py
code served (permissive licence) · get_code("dda096fc09fd5f24")
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 numpy as np
from rouge_score import rouge_scorer

torch.manual_seed(0)

# The function takes prediction and ground_truth as strings
# It uses the default_rouge_scorer which calls .score(prediction=..., target=...)
# This expects string inputs

prediction = "The quick brown fox jumps over the lazy dog"
ground_truth = "A fast brown fox leaps over a lazy dog"

ARGS = {
    "prediction": prediction,
    "ground_truth": ground_truth,
    "xlingual": False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, rouge_score, 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
add_runtime_args Not yet run
unverified (harvested, no recorded run)
gmkim-ai/promptkd/arguments.py
code served (permissive licence) · get_code("3399622f0eac30dd")
How it ran

no invocation recorded.

all_gather Not yet run
unverified (harvested, no recorded run)
gmkim-ai/promptkd/utils.py
code served (permissive licence) · get_code("b0cb93ee3f5f771a")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 1 later) and 8 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
normalize_answer 12 other papers
8 dated earlier, 3 later, 1 same year, order not determinable
2204.07705 (2022-04)
SUPER-NATURALINSTRUCTIONS: Generalization via Declarative Instructions on 1600+ NLP Tasks
2212.03813 (2022-12)
Robustness of Learning from Task Instructions
2023.findings-emnlp.836 (2023 (year only))
Ensemble-Instruct: Generating Instruction-Tuning Data with a Heterogeneous Mixture of LMs
and 9 more not named here
exact_match 1 other paper
1 dated earlier
2312.02614 (2023-12)
Prompt Optimization via Adversarial In-Context Learning

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

Repositories linked to this paper

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

Abstract

Recent advancements in large language models (LLMs) have raised concerns about inference costs, increasing the need for research into model compression. While knowledge distillation (KD) is a prominent method for this, research on KD for generative language models like LLMs is relatively sparse, and the approach of distilling student-friendly knowledge, which has shown promising performance in KD for classification models, remains unexplored in generative language models. To explore this approach, we propose PromptKD, a simple yet effective method that utilizes prompt tuning - for the first time in KD - to enable generative language models to transfer student-friendly knowledge. Unlike previous works in classification that require fine-tuning the entire teacher model for extracting student-friendly knowledge, PromptKD achieves similar effects by adding a small number of prompt tokens and tuning only the prompt with student guidance. Extensive experiments on instruction-following datasets show that PromptKD achieves state-of-the-art performance while adding only 0.0007% of the teacher's parameters as prompts. Further analysis suggests that distilling student-friendly knowledge alleviates exposure bias effectively throughout the entire training process, leading to performance enhancements.

For agents

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

get_harvested_code_for_paper("2402.12842")
get_code_for_paper("2402.12842")
have("2402.12842")

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

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

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

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

Connect an agent — have() is free.