SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2205.11166 · ACL Findings · 2022

Prompt Tuning for Discriminative Pre-trained Language Models

Maosong Sun, Zhiyuan Liu, Jianyong Wang, Yuan Yao, Bowen Dong, Ao Zhang, Ruobing Xie, Zhengyan Zhang, Leyu Lin

arXiv · PDF · Open in the Atlas

Code that ran

7 of 12 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (4 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 2 failures of our instrument; 5 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/2205.11166.json · badge: /api/ran/2205.11166.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
thunlp/DPT community
Papers with Code archive
7 ran · 5 no recorded run
FunctionStatusWhere it lives
AGNewsProcessor Ran
ran on a synthesized input
thunlp/DPT/src/TextClassification/textcls/models/prompt_model.py
code served (permissive licence) · get_code("b5904cd2cd0fafdc")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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 os
import tempfile
import csv
from transformers import DataProcessor, InputExample

class AGNewsProcessor(DataProcessor):
    """Processor for the AGNews data set (GLUE version)."""

    def get_example_from_tensor_dict(self, tensor_dict):
        """See base class."""
        return InputExample(tensor_dict['idx'].numpy(), tensor_dict['sentence'].numpy().decode('utf-8'), None, str(tensor_dict['label'].numpy()))

    def _read_csv(self, input_file, quotechar=None):
        """Reads a tab separated value file."""
        with open(input_file, 'r', encoding='utf-8-sig') as f:
            return list(csv.reader(f, delimiter=','))

    def get_train_examples(self, data_dir):
        """See base class."""
        return self._create_examples(self._read_csv(os.path.join(data_dir, 'train.csv')), 'train')

    def get_dev_examples(self, data_dir):
        """See base class."""
        return self._create_examples(self._read_csv(os.path.join(data_dir, 'test.csv')), 'dev')

    def get_test_examples(self, data_dir):
        """See base class."""
        return self._create_examples(self._read_csv(os.path.join(data_dir, 'test.csv')), 'test')

    def get_labels(self):
        """See base class."""
        return ['1', '2', '3', '4']

    @classmethod
    def get_label_texts(cls):
        return ['World ,', 'Sports ,', 'Business ,', 'science and technology ,']

    def _create_examples(self, lines, set_type):
        """Creates examples for the training, dev and test sets."""
        examples = []
        for i, line in enumerate(lines):
            guid = '%s-%s' % (set_type, i)
            text_a = ' '.join(line[1:])
            label = line[0]
            examples.append(InputExample(guid=guid, text_a=text_a, text_b=None, label=label))
        return examples


# Create temporary directory with test CSV files
temp_dir = tempfile.mkdtemp()

# Create train.csv
train_csv_path = os.path.join(temp_dir, 'train.csv')
with open(train_csv_path, 'w', newline='', encoding='utf-8') as f:
    writer = csv.writer(f)
    writer.writerow(['1', 'World', 'news', 'today'])
    writer.writerow(['2', 'Sports', 'update', 'now'])

# Create test.csv
test_csv_path = os.path.join(temp_dir, 'test.csv')
with open(test_csv_path, 'w', newline='', encoding='utf-8') as f:
    writer = csv.writer(f)
    writer.writerow(['3', 'Business', 'report', 'here'])
    writer.writerow(['4', 'Science', 'discovery', 'made'])

INIT_ARGS = {}

ARGS = {
    'data_dir': temp_dir
}

METHOD = 'get_train_examples'

# Construct and call
processor = AGNewsProcessor(**INIT_ARGS)
result = getattr(processor, METHOD)(**ARGS)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
CoLAProcessor Ran
ran on a synthesized input · constructed an object; no result was computed
thunlp/DPT/src/TextClassification/textcls/models/prompt_model.py
code served (permissive licence) · get_code("f7230cfb9b36d3c4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, CoLAProcessor: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import tempfile
from transformers import DataProcessor, InputExample

# Create a temporary directory with mock TSV files
temp_dir = tempfile.mkdtemp()

# Create mock train.tsv file
train_tsv_path = os.path.join(temp_dir, 'train.tsv')
with open(train_tsv_path, 'w') as f:
    f.write("index\tlabel\tunused\tsentence\n")
    f.write("0\t1\tunused_col\tThis is a grammatical sentence .\n")
    f.write("1\t0\tunused_col\tThis sentence are not grammatical .\n")

# Create mock dev.tsv file
dev_tsv_path = os.path.join(temp_dir, 'dev.tsv')
with open(dev_tsv_path, 'w') as f:
    f.write("index\tlabel\tunused\tsentence\n")
    f.write("0\t1\tunused_col\tAnother valid sentence .\n")
    f.write("1\t0\tunused_col\tAnother invalid sentence are .\n")

# CoLAProcessor has no __init__ parameters beyond self
ARGS = {}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type CoLAProcessor — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a CoLAProcessor 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
IMDbProcessor Ran
ran on a synthesized input · constructed an object; no result was computed
thunlp/DPT/src/TextClassification/textcls/models/prompt_model.py
code served (permissive licence) · get_code("ce45acf0ec906436")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, IMDbProcessor: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import tempfile
import csv
from transformers import DataProcessor, InputExample

# Create a temporary directory with CSV files for testing
temp_dir = tempfile.mkdtemp()

# Create Train.csv
train_file = os.path.join(temp_dir, 'Train.csv')
with open(train_file, 'w', newline='', encoding='utf-8') as f:
    writer = csv.writer(f)
    writer.writerow(['This is a great movie', '1'])
    writer.writerow(['This is a terrible movie', '0'])

# Create Valid.csv
valid_file = os.path.join(temp_dir, 'Valid.csv')
with open(valid_file, 'w', newline='', encoding='utf-8') as f:
    writer = csv.writer(f)
    writer.writerow(['It was okay', '1'])

# Create Test.csv
test_file = os.path.join(temp_dir, 'Test.csv')
with open(test_file, 'w', newline='', encoding='utf-8') as f:
    writer = csv.writer(f)
    writer.writerow(['Not good', '0'])

# IMDbProcessor constructor takes no arguments
ARGS = {}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type IMDbProcessor — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a IMDbProcessor 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
TrecProcessor Ran
ran on a synthesized input · constructed an object; no result was computed
thunlp/DPT/src/TextClassification/textcls/models/prompt_model.py
code served (permissive licence) · get_code("0a817115675763c5")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, TrecProcessor: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import tempfile
import csv
from transformers import DataProcessor, InputExample

# Create a temporary directory with test CSV files
temp_dir = tempfile.mkdtemp()

# Create train.csv
train_file = os.path.join(temp_dir, 'train.csv')
with open(train_file, 'w', newline='', encoding='utf-8') as f:
    writer = csv.writer(f)
    writer.writerow(['0', 'What is the capital of France?'])
    writer.writerow(['1', 'John Smith is a person'])
    writer.writerow(['2', 'USA is a country'])

# Create test.csv
test_file = os.path.join(temp_dir, 'test.csv')
with open(test_file, 'w', newline='', encoding='utf-8') as f:
    writer = csv.writer(f)
    writer.writerow(['3', 'How tall is the Eiffel Tower?'])
    writer.writerow(['4', 'Paris is located in France'])

# TrecProcessor has no __init__ parameters beyond the inherited ones
# The class itself is instantiable without arguments
ARGS = {
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type TrecProcessor — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a TrecProcessor 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
YahooProcessor Ran
ran on a synthesized input · constructed an object; no result was computed
thunlp/DPT/src/TextClassification/textcls/models/prompt_model.py
code served (permissive licence) · get_code("daf59baccdb52ea8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, YahooProcessor: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import tempfile
import csv
from transformers import DataProcessor, InputExample

# Create a temporary directory with test CSV files
temp_dir = tempfile.mkdtemp()

# Create a minimal train.csv file
train_csv_path = os.path.join(temp_dir, 'train.csv')
with open(train_csv_path, 'w', newline='', encoding='utf-8') as f:
    writer = csv.writer(f)
    writer.writerow(['1', 'this', 'is', 'a', 'test'])
    writer.writerow(['2', 'another', 'test', 'row'])

# Create a minimal test.csv file
test_csv_path = os.path.join(temp_dir, 'test.csv')
with open(test_csv_path, 'w', newline='', encoding='utf-8') as f:
    writer = csv.writer(f)
    writer.writerow(['3', 'test', 'data'])
    writer.writerow(['4', 'more', 'test', 'data'])

# YahooProcessor is a DataProcessor subclass and doesn't require constructor arguments
processor = DataProcessor()

# The class itself only needs to be instantiated
ARGS = {}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type YahooProcessor — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a YahooProcessor output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
tokenize_all_data_with_labels Ran
ran; our contract draft was wrong, not the code
thunlp/DPT/src/TextClassification/textcls/models/prompt_model.py
code served (permissive licence) · get_code("3fc1b95381f8ad18")
How it ran

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

import torch
import numpy as np

class MockTokenizer:
    def __init__(self):
        self.vocab = {
            '[CLS]': 101,
            '[SEP]': 102,
            '[PAD]': 0,
            'hello': 1,
            'world': 2,
            'this': 3,
            'is': 4,
            'a': 5,
            'test': 6,
            'label': 7,
            'token': 8,
        }
    
    def tokenize(self, text):
        if text is None:
            return []
        words = text.lower().split()
        tokens = []
        for word in words:
            if word in self.vocab:
                tokens.append(word)
            else:
                tokens.append('token')
        return tokens
    
    def convert_tokens_to_ids(self, tokens):
        ids = []
        for token in tokens:
            ids.append(self.vocab.get(token, 0))
        return ids

tokenizer = MockTokenizer()

data = [
    ('hello world', 'this is a test'),
    ('hello', None),
]

label_tokens = ['[CLS]', 'label', '[SEP]']

max_len = 20

label_positions = [0, 1, 2]

ARGS = {
    'data': data,
    'tokenizer': tokenizer,
    'label_tokens': label_tokens,
    'max_len': max_len,
    'label_positions': label_positions,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
tokenize_sentence_pair Ran
ran; our contract draft was wrong, not the code
thunlp/DPT/src/TextClassification/textcls/models/prompt_model.py
code served (permissive licence) · get_code("73ef3b2bed4d1799")
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.

class MockTokenizer:
    def tokenize(self, sentence):
        if sentence is None:
            return []
        return sentence.split()

ARGS = {
    "tokenizer": MockTokenizer(),
    "sentence_pair": ("hello world test", "this is a sentence"),
    "max_len": 20,
    "occupied_len": 0,
}
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
BeginWithLabels Not yet run
unverified (harvested, no recorded run)
thunlp/DPT/src/TextClassification/textcls/models/prompt_model.py
code served (permissive licence) · get_code("d983d14088d5f77c")
How it ran

no invocation recorded.

DBpediaProcessor Not yet run
unverified (harvested, no recorded run)
thunlp/DPT/src/TextClassification/textcls/models/prompt_model.py
code served (permissive licence) · get_code("cab60337b12ac588")
How it ran

no invocation recorded.

Sst2Processor Not yet run
unverified (harvested, no recorded run)
thunlp/DPT/src/TextClassification/textcls/models/prompt_model.py
code served (permissive licence) · get_code("ebe613d902d97b5a")
How it ran

no invocation recorded.

Sst5Processor Not yet run
unverified (harvested, no recorded run)
thunlp/DPT/src/TextClassification/textcls/models/prompt_model.py
code served (permissive licence) · get_code("8f91276efd0d5efa")
How it ran

no invocation recorded.

YelpProcessor Not yet run
unverified (harvested, no recorded run)
thunlp/DPT/src/TextClassification/textcls/models/prompt_model.py
code served (permissive licence) · get_code("c5167763b85b8da8")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 12 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.

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 works have shown promising results of prompt tuning in stimulating pre-trained language models (PLMs) for natural language processing (NLP) tasks. However, to the best of our knowledge, existing works focus on prompt-tuning generative PLMs that are pre-trained to generate target tokens, such as BERT (Devlin et al., 2019). It is still unknown whether and how discriminative PLMs, e.g., ELECTRA (Clark et al., 2020), can be effectively prompt-tuned. In this work, we present DPT, the first prompt tuning framework for discriminative PLMs, which reformulates NLP tasks into a discriminative language modeling problem. Comprehensive experiments on text classification and question answering show that, compared with vanilla fine-tuning, DPT achieves significantly higher performance, and also prevents the unstable problem in tuning large PLMs in both full-set and low-resource settings. The source code and experiment details of this paper can be obtained from https: //github.com/thunlp/DPT.

For agents

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

get_harvested_code_for_paper("2205.11166")
get_code_for_paper("2205.11166")
have("2205.11166")

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

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

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

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

Connect an agent — have() is free.