SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2210.00660 · ICLR · 2023

A Non-monotonic Self-terminating Language Model

Eugene Choi

arXiv · PDF · Open in the Atlas

Code that ran

8 of 13 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 8 have no contract verdict; 0 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/2210.00660.json · badge: /api/ran/2210.00660.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
nyu-dl/non-monotonic-self-terminating-lm canonical (classifier label)
classifier basis not recorded on the link
8 ran · 5 no recorded run
FunctionStatusWhere it lives
get_hit_rate Ran
ran on a synthesized input
nyu-dl/non-monotonic-self-terminating-lm/src/gpt2/utils.py
code served (permissive licence) · get_code("b32d066c54551f37")
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 defaultdict. 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 collections import defaultdict

torch.manual_seed(0)

# Construct small tensors for testing
batch_size = 2
vocab_size = 4
seq_length = 3

# lprobs: log probabilities, shape (batch_size, seq_length, vocab_size)
# These are log probabilities over vocabulary for each position
lprobs = torch.randn(batch_size, seq_length, vocab_size)

# targets: target token indices, shape (batch_size, seq_length)
# Values should be in range [0, vocab_size) or -100 for padding
targets = torch.tensor([
    [0, 1, -100],
    [2, 3, 1]
], dtype=torch.long)

# pad: the padding token index
pad = -100

# hit_thresholds: list of thresholds to compute hit rates at
hit_thresholds = [1, 10, 20, 30]

ARGS = {
    "lprobs": lprobs,
    "targets": targets,
    "pad": pad,
    "hit_thresholds": hit_thresholds
}
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 defaultdict — a defaultdict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a defaultdict 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
len_stats Ran
ran on a synthesized input
nyu-dl/non-monotonic-self-terminating-lm/src/gpt2/metrics.py
code served (permissive licence) · get_code("36c913a6cd4fdee4")
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, ndim 2, dtype family int; 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 numpy as np

# Define arguments for len_stats function
# The function takes:
# - decoded: list of sequences or convertible to list
# - target: list of sequences or convertible to list
# - eos_token: a token value to mark end of sequence

# Create sample data as lists of token sequences
# Using small integer tokens with eos_token = 0
decoded = [
    [5, 3, 2, 0, 7],      # sequence with eos_token at index 3
    [1, 2, 3, 4, 5]       # sequence without eos_token
]

target = [
    [5, 3, 0, 8, 9],      # sequence with eos_token at index 2
    [1, 2, 3, 0]          # sequence with eos_token at index 3
]

eos_token = 0

ARGS = {
    "decoded": decoded,
    "target": target,
    "eos_token": eos_token
}
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, ndim 2, dtype family int — a tuple 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
load_bucketing_dataset Ran
ran on a synthesized input
nyu-dl/non-monotonic-self-terminating-lm/src/gpt2/data.py
code served (permissive licence) · get_code("434f32cbf1822fbf")
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 GPT2Config

torch.manual_seed(0)

# Create a small GPT2Config
model_config = GPT2Config(
    n_positions=128,  # token_limit in the code
    vocab_size=50,
    n_embd=16,
    n_layer=2,
    n_head=2
)

# Create sample data - list of lists of token IDs
# Each inner list represents a sequence of tokens
dataset_dict = {
    'train': {
        'input_ids': [
            [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],  # length 10
            [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],  # length 12
            [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],  # length 15
            [1, 2, 3, 4, 5, 6, 7, 8],  # length 8
        ]
    },
    'val': {
        'input_ids': [
            [1, 2, 3, 4, 5, 6, 7, 8, 9],  # length 9
            [1, 2, 3, 4, 5, 6, 7],  # length 7
        ]
    }
}

# Create a simple args object
class Args:
    context_length = 5

args = Args()

# Pad token ID (typically 0 for many tokenizers)
pad_token_id = 0

ARGS = {
    'dataset_dict': dataset_dict,
    'model_config': model_config,
    'pad_token_id': pad_token_id,
    'args': args
}
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
load_optimizers Ran
ran on a synthesized input
nyu-dl/non-monotonic-self-terminating-lm/src/gpt2/utils.py
code served (permissive licence) · get_code("bc4ed6ef124441ec")
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, 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 argparse
import torch
import torch.nn as nn
from transformers import GPT2LMHeadModel, get_scheduler

torch.manual_seed(0)

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

model = MinimalModel()

# Create args namespace with all required parameters
args = argparse.Namespace(
    weight_decay=0.01,
    learning_rate=1e-4,
    adam_epsilon=1e-8,
    lr_scheduler_type='linear',
    num_warmup_steps=100,
    max_train_steps=1000,
    model_load_dir=None
)

device = 'cpu'

ARGS = {
    'model': model,
    'args': args,
    'device': device
}
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 tuple, ndim 1, dtype family float — a tuple 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
ngram_metrics Ran
ran on a synthesized input
nyu-dl/non-monotonic-self-terminating-lm/src/gpt2/metrics.py
code served (permissive licence) · get_code("a7070e94e5c3b4d5")
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 defaultdict. 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 nltk import ngrams
from collections import Counter, defaultdict

torch.manual_seed(0)

# sequences: should be a list of sequences (lists of tokens)
# Each sequence is a list of integers representing tokens
sequences = [
    [1, 2, 3, 4, 5, 0],  # sequence with eos_token at end
    [2, 3, 4, 2, 3, 0],  # sequence with repetition and eos_token
    [1, 1, 1, 1, 0],     # sequence with many repeats
]

# eos_token: end-of-sequence token (an integer)
eos_token = 0

ARGS = {
    "sequences": sequences,
    "eos_token": eos_token,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
nltk, numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type defaultdict — a defaultdict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a defaultdict 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
random_prefixes Ran
ran on a synthesized input
nyu-dl/non-monotonic-self-terminating-lm/src/wiki2/data.py
code served (permissive licence) · get_code("4cfc3a3f37aabff6")
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 LMDataset. 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 torch.utils.data import Dataset, DataLoader

torch.manual_seed(0)

class Dictionary(object):

    def __init__(self, dataset, include_valid: bool=True, special_tokens: list=['<pad>', '<unk>', '<bos>', '<cpad>', '<eos>']):
        self.tokens = []
        self.ids = {}
        self.counts = {}
        for seq in dataset['train']['text']:
            seq = seq.strip()
            if len(seq) != 0:
                for w in seq.split(' '):
                    self.add_token(w)
        if include_valid:
            for seq in dataset['validation']['text']:
                seq = seq.strip()
                if len(seq) != 0:
                    for w in seq.split(' '):
                        self.add_token(w)
        assert len(special_tokens) > 0 and special_tokens[-1] == '<eos>'
        for token in special_tokens:
            self.add_token(token)

    def add_token(self, word: str):
        if word not in self.tokens:
            self.tokens.append(word)
            self.counts[word] = 0
            _w_id = len(self.tokens) - 1
            self.ids[word] = _w_id
        else:
            self.counts[word] += 1

    def get_id(self, word: str) -> int:
        return self.ids[word]

    def get_token(self, idx: int) -> str:
        return self.tokens[idx]

    def decode_idx_seq(self, ids: list) -> list:
        return [self.tokens[idx] for idx in ids]

    def encode_token_seq(self, seq: list) -> list:
        return [self.ids[word] if word in self.ids else self.ids['<unk>'] for word in seq]

    def __len__(self):
        return len(self.tokens)


class LMDataset(Dataset):

    def __init__(self, list_of_token_lists: list):
        self.input_tensors = []
        self.target_tensors = []
        for sample in list_of_token_lists:
            self.input_tensors.append(torch.LongTensor([sample[:-1]]))
            self.target_tensors.append(torch.LongTensor([sample[1:]]))

    def __len__(self):
        return len(self.input_tensors)

    def __getitem__(self, idx: int):
        return (self.input_tensors[idx], self.target_tensors[idx])


def random_prefixes(vocab: Dictionary, context_len: int, num_prefixes: int) -> LMDataset:
    if num_prefixes == -1:
        num_prefixes = 1000
    prefixes = torch.randint(len(vocab), (num_prefixes, context_len))
    special_tokens = ['<pad>', '<unk>', '<bos>', '<eos>', '<cpad>']
    for tok in special_tokens:
        if tok in vocab.counts:
            id_ = vocab.get_id(tok)
            prefixes[prefixes == id_] = 6
    bos = torch.tensor([vocab.get_id('<bos>')] * num_prefixes).unsqueeze(1)
    prefixes = torch.cat((bos, prefixes), 1).tolist()
    dataset = LMDataset(prefixes)
    return dataset


# Create a minimal vocab (Dictionary object)
fake_dataset = {
    'train': {
        'text': ['hello world', 'foo bar baz']
    },
    'validation': {
        'text': ['test example']
    }
}

vocab = Dictionary(fake_dataset, include_valid=True, special_tokens=['<pad>', '<unk>', '<bos>', '<cpad>', '<eos>'])

ARGS = {
    'vocab': vocab,
    'context_len': 3,
    'num_prefixes': 2
}
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 LMDataset — a LMDataset output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a LMDataset output the recorded ndim 4 and dtype family int 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
setup Ran
ran on a synthesized input
nyu-dl/non-monotonic-self-terminating-lm/src/wiki2/utils.py
code served (permissive licence) · get_code("040d9549898a931a")
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, 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 torch
import torch.nn as nn
import argparse

torch.manual_seed(0)

# Define a minimal model class that satisfies the function's usage
class MinimalRNNModel(nn.Module):
    def __init__(self, args):
        super().__init__()
        self.vocab_size = args.vocab_size
        self.embedding = nn.Embedding(args.vocab_size, args.embedding_dim, padding_idx=args.pad_idx)
        self.linear = nn.Linear(args.embedding_dim, args.vocab_size)
    
    def forward(self, x):
        x = self.embedding(x)
        x = self.linear(x)
        return x

# Create args namespace with all required attributes
args = argparse.Namespace(
    loss='mle',
    pad_idx=0,
    optimizer='adamw',
    lr=0.001,
    weight_decay=0.01,
    momentum_sgd=0.9,
    vocab_size=10,
    embedding_dim=4
)

device = torch.device('cpu')

ARGS = {
    'model_class': MinimalRNNModel,
    'device': device,
    'args': 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 tuple, ndim 1, dtype family float — a tuple 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
setup_expr Ran
ran on a synthesized input
nyu-dl/non-monotonic-self-terminating-lm/src/wiki2/utils.py
code served (permissive licence) · get_code("7353f175fe8bd701")
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 Namespace. 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 argparse
import os
import tempfile
import torch
import numpy as np

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

# Create the args namespace with all required parameters
args = argparse.Namespace(
    save_base_dir=temp_dir,
    expr_name="test_experiment",
    dry_run=False,
    seed=42
)

ARGS = {
    "args": args
}
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 Namespace — a Namespace output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Namespace 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_dataloaders_and_vocab Not yet run
unverified (harvested, no recorded run)
nyu-dl/non-monotonic-self-terminating-lm/src/wiki2/data.py
code served (permissive licence) · get_code("9cce3c5427ef25eb")
How it ran

no invocation recorded.

load_dataloaders Not yet run
unverified (harvested, no recorded run)
nyu-dl/non-monotonic-self-terminating-lm/src/gpt2/data.py
code served (permissive licence) · get_code("33a309795c61e227")
How it ran

no invocation recorded.

load_tokenized_dataset Not yet run
unverified (harvested, no recorded run)
nyu-dl/non-monotonic-self-terminating-lm/src/wiki2/data.py
code served (permissive licence) · get_code("de888cd7f1abc772")
How it ran

no invocation recorded.

parse_args Not yet run
unverified (harvested, no recorded run)
nyu-dl/non-monotonic-self-terminating-lm/src/gpt2/preprocess.py
code served (permissive licence) · get_code("326bcb6d1668d2d9")
How it ran

no invocation recorded.

parse_args_and_preprocess Not yet run
unverified (harvested, no recorded run)
nyu-dl/non-monotonic-self-terminating-lm/src/gpt2/preprocess.py
code served (permissive licence) · get_code("951fa67666e1db26")
How it ran

no invocation recorded.

Also present in other papers' code

Of 13 samples lifted from this paper's linked repositories, 13 carry a function identity and 0 do not. Of the 13 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 13 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 large-scale neural autoregressive sequence models have shown impressive performances on a variety of natural language generation tasks. However, their generated sequences often exhibit degenerate properties such as non-termination, undesirable repetition, and premature termination, when generated with decoding algorithms such as greedy search, beam search, top-k sampling, and nucleus sampling. In this paper, we focus on the problem of non-terminating sequences resulting from an incomplete decoding algorithm. We first define an incomplete probable decoding algorithm which includes greedy search, top-k sampling, and nucleus sampling, beyond the incomplete decoding algorithm originally put forward by Welleck et al. (2020). We then propose a non-monotonic self-terminating language model, which significantly relaxes the constraint of monotonically increasing termination probability in the originally proposed self-terminating language model by Welleck et al. (2020), to address the issue of non-terminating sequences when using incomplete probable decoding algorithms. We prove that our proposed model prevents non-terminating sequences when using not only incomplete probable decoding algorithms but also beam search. We empirically validate our model on sequence completion tasks with various architectures.

For agents

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

get_harvested_code_for_paper("2210.00660")
get_code_for_paper("2210.00660")
have("2210.00660")

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

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

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

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

Connect an agent — have() is free.