SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2109.03630 · EMNLP · 2021

Discrete and Soft Prompting for Multilingual Models

Mengjie Zhao, Hinrich Schütze

arXiv · PDF · Open in the Atlas

Code that ran

4 of 5 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, 1 violated it and 3 have no contract verdict; 0 failures of our instrument; 1 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/2109.03630.json · badge: /api/ran/2109.03630.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
mprompting/xlmrprompt canonical (classifier label)
classifier basis: census
4 ran · 1 no recorded run
FunctionStatusWhere it lives
encode_example_to_feature Ran
ran on a synthesized input
mprompting/xlmrprompt/finetuning/data_loader/bert_formatting.py
code served (permissive licence) · get_code("7672828bfb6e50c0")
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 BertInputFeature. 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
from transformers import AutoTokenizer

class MockExample:
    def __init__(self, uid, text_a, text_b, label):
        self.uid = uid
        self.text_a = text_a
        self.text_b = text_b
        self.label = label

class MockTokenizer:
    def __init__(self):
        self.pad_token_id = 0
        self.vocab_size = 1000
    
    def encode(self, text, add_special_tokens=False, max_length=512, truncation=True):
        # Return a simple mock token sequence
        tokens = [i % self.vocab_size for i in range(len(text.split()))]
        return tokens
    
    def num_special_tokens_to_add(self, pair=False):
        # [CLS] + [SEP] for single, [CLS] + [SEP] + [SEP] for pair
        return 3 if pair else 2
    
    def build_inputs_with_special_tokens(self, parts_a, parts_b):
        # [CLS] + parts_a + [SEP] + parts_b + [SEP]
        input_ids = [101] + parts_a + [102]
        if parts_b:
            input_ids = input_ids + parts_b + [102]
        return input_ids
    
    def create_token_type_ids_from_sequences(self, parts_a, parts_b):
        # 0 for first sequence, 1 for second sequence
        token_type_ids = [0] * (len(parts_a) + 2)
        if parts_b:
            token_type_ids = token_type_ids + [1] * (len(parts_b) + 1)
        return token_type_ids

example = MockExample(
    uid="example_001",
    text_a="the quick brown fox",
    text_b="jumps over the lazy dog",
    label="positive"
)

tokenizer = MockTokenizer()

max_seq_len = 32
label_list = ["positive", "negative", "neutral"]

ARGS = {
    "example": example,
    "tokenizer": tokenizer,
    "max_seq_len": max_seq_len,
    "label_list": label_list,
    "loud": False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type BertInputFeature — a BertInputFeature output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a BertInputFeature 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
str2bool Ran
ran, violated the contract we drafted
mprompting/xlmrprompt/finetuning/finetuning_parameters.py
code served (permissive licence) · get_code("f017532fc389cbfe")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned 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 argparse

def str2bool(v):
    if v.lower() in ('yes', 'true', 't', 'y', '1'):
        return True
    elif v.lower() in ('no', 'false', 'f', 'n', '0'):
        return False
    else:
        raise argparse.ArgumentTypeError('Boolean value expected.')

# Setup code to construct valid arguments
ARGS = {
    'v': 'true'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
truncate Ran
ran on a synthesized input
mprompting/xlmrprompt/finetuning/data_loader/bert_formatting.py
code served (permissive licence) · get_code("de4d375e6fe86346")
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 torch
import numpy as np

class MockTokenizer:
    def __init__(self):
        self._special_tokens_count = 2
    
    def num_special_tokens_to_add(self, pair):
        if pair:
            return self._special_tokens_count
        return 1

tokenizer = MockTokenizer()
parts_a = [101, 2054, 2003, 2009]
parts_b = [1045, 2572, 102]
max_seq_len = 10

ARGS = {
    "tokenizer": tokenizer,
    "parts_a": parts_a,
    "parts_b": parts_b,
    "max_seq_len": max_seq_len
}
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 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
wrap_sampler Ran
ran on a synthesized input
mprompting/xlmrprompt/finetuning/data_loader/wrap_sampler.py
code served (permissive licence) · get_code("0bcdf3e6c28713cd")
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 LanguageDataset. 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.utils.data import SequentialSampler, DataLoader, RandomSampler

torch.manual_seed(0)

# Create a minimal dataset class
class MinimalDataset:
    def __init__(self, size):
        self.size = size
        self.data = [(torch.randn(4), torch.randint(0, 2, (1,))) for _ in range(size)]
    
    def __len__(self):
        return self.size
    
    def __getitem__(self, idx):
        return self.data[idx]

# Create a minimal language dataset with the required splits
class LanguageDataset:
    def __init__(self):
        self.trn_egs = MinimalDataset(8)
        self.val_egs = MinimalDataset(4)
        self.tst_egs = MinimalDataset(4)

# Instantiate the language dataset
language_dataset = LanguageDataset()

ARGS = {
    'trn_batch_size': 2,
    'infer_batch_size': 2,
    'language': 'english',
    'language_dataset': language_dataset,
}
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 LanguageDataset — a LanguageDataset output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a LanguageDataset 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
seqcls_collocate Not yet run
unverified (harvested, no recorded run)
mprompting/xlmrprompt/finetuning/future/collocate_fns.py
code served (permissive licence) · get_code("fb514d69cc8ab225")
How it ran

no invocation recorded.

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 1 the same month, 1 later) and 4 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
str2bool 82 other papers
47 dated earlier, 2 the same month, 32 later, 1 same year, order not determinable
1510.03055 (2015-10)
A Diversity-Promoting Objective Function for Neural Conversation Models
1703.06490 (2017-03)
Generating Multi-label Discrete Patient Records using Generative Adversarial Networks
1710.10467 (2017-10)
Generalized End-to-End Loss for Speaker Verification
and 79 more not named here

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

It has been shown for English that discrete and soft prompting perform strongly in fewshot learning with pretrained language models (PLMs). In this paper, we show that discrete and soft prompting perform better than finetuning in multilingual cases: Crosslingual transfer and in-language training of multilingual natural language inference. For example, with 48 English training examples, finetuning obtains 33.74% accuracy in crosslingual transfer, barely surpassing the majority baseline (33.33%). In contrast, discrete and soft prompting outperform finetuning, achieving 36.43% and 38.79%. We also demonstrate good performance of prompting with training data in multiple languages other than English.

For agents

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

get_harvested_code_for_paper("2109.03630")
get_code_for_paper("2109.03630")
have("2109.03630")

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

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

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

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

Connect an agent — have() is free.