SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2407.06071 · NeurIPS · 2024

From Loops to Oops: Fallback Behaviors of Language Models Under Uncertainty

Jonathan Berant, Ori Yoran, Maor Ivgi, Mor Geva

arXiv · PDF · Open in the Atlas

Code that ran

9 of 12 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, 2 violated it and 0 have no contract verdict; 7 failures of our instrument; 3 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/2407.06071.json · badge: /api/ran/2407.06071.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
mivg/fallbacks canonical (classifier label)
classifier basis: census
6 ran · 2 no recorded run
Mivg/fallbacks canonical (classifier label)
classifier basis: classifier_2025
3 ran · 1 no recorded run
FunctionStatusWhere it lives
clean_sample Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
mivg/fallbacks/utils/degeneration_detector.py
code served (permissive licence) · get_code("1321602fe1a91715")
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 torch.nn as nn

class SimpleTokenizer:
    def decode(self, tokens):
        # Return a string with spaces between tokens
        return ' '.join(str(t) for t in tokens)

# Create a simple tokenizer
tokenizer = SimpleTokenizer()

# Create a simple raw sample (list of token IDs)
raw_sample = [101, 2054, 2003, 102]

# Set ignore_enumeration to False so the function returns early
ignore_enumeration = False

ARGS = {
    'raw_sample': raw_sample,
    'tokenizer': tokenizer,
    'ignore_enumeration': ignore_enumeration
}
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
ends_in_punctuation Ran
ran, violated the contract we drafted
mivg/fallbacks/utils/degeneration_detector.py
code served (permissive licence) · get_code("4976dd040a789ec3")
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 ends_in_punctuation(s):
    """
    Check if a string ends in punctuation
    """
    return any((s.endswith(p) for p in string.punctuation))


ARGS = {
    "s": "Hello, world!"
}
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
extract_answers Ran
ran; our contract draft was wrong, not the code
Mivg/fallbacks/run_hallucinations_check.py
code served (permissive licence) · get_code("808e0a22c84796cd")
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 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 re
from enum import Enum

ENUM_ITEM_PATTERN = re.compile('^(\\d+)\\.\\s*(.*)$')

BAD_FORMAT = 4
TOPIC_CHANGE = 5
EOS = 6

class AnswerListStatus(Enum):
    FULL = -1
    BAD_FORMAT = BAD_FORMAT
    TOPIC_CHANGE = TOPIC_CHANGE
    EOS = EOS

MINIMUM_ANSWERS = 3

# Construct valid arguments for extract_answers function
ARGS = {
    "result": "2. First answer\n3. Second answer\n4. Third answer\n5. Fourth answer",
    "require_max_answers": False,
    "require_enumerated_answers": False,
    "max_answers": 500,
    "max_words_for_eos": 150,
    "return_before_after": False,
}
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 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_generate_for_pipeline Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
mivg/fallbacks/run_hallucinations_check.py
code served (permissive licence) · get_code("fe2f94dc0eff579c")
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 torch
from torch.nn.functional import log_softmax

torch.manual_seed(0)

# Create a mock tokenizer
class MockTokenizer:
    def batch_decode(self, indices):
        # indices is a tensor of shape (top_k,)
        # return a list of token strings
        return [f"token_{idx.item()}" for idx in indices]

# Create a mock model with generate method
class MockModel(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = torch.nn.Linear(4, 8)
    
    def generate(self, *args, **kwargs):
        # Return a mock GenerateOutput with sequences and scores
        batch_size = 1
        seq_length = 3
        vocab_size = 8
        
        # Create mock sequences
        sequences = torch.randint(0, vocab_size, (batch_size, seq_length))
        
        # Create mock scores - tuple of tensors, one per generated token
        # Each score tensor should be (batch_size, vocab_size)
        scores = tuple(
            torch.randn(batch_size, vocab_size) for _ in range(seq_length)
        )
        
        # Create a mock output object
        class GenerateOutput:
            def __init__(self, sequences, scores):
                self.sequences = sequences
                self.scores = scores
        
        return GenerateOutput(sequences, scores)

# Create a mock pipeline
class MockPipeline:
    def __init__(self):
        self.model = MockModel()
        self.tokenizer = MockTokenizer()

# Create instances
pipeline = MockPipeline()
scores = []
top = 5

ARGS = {
    "pipeline": pipeline,
    "scores": scores,
    "top": top
}
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 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_params_and_model Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
Mivg/fallbacks/scripts/create_paper_plots.py
code served (permissive licence) · get_code("fc69a31389986f33")
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 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 re

def get_params_and_model(file, model_types, params, tokens=None):
    model_name = None
    try:
        model_name = re.search('.*prompts_(.*)_\\d+T.*', file).group(1).replace('+', '/')
    except:
        pass
    if model_name is None:
        try:
            model_name = re.search('.*results_(.*)_.*', file).group(1).replace('+', '/')
        except:
            raise ValueError(f'Could not find model name in file {file}')
    match = re.search('(\\d+(\\.\\d+)?)(m|b)', file, re.IGNORECASE)
    if match:
        if match.group(3).lower() == 'm':
            param = float(match.group(1)) * 1000000.0
        else:
            param = float(match.group(1)) * 1000000000.0
        params.append(param)
    else:
        params.append(None)
    if 'llama2' in file.lower() or 'llama-2' in file.lower():
        model_types.append('Llama2')
    elif 'llama3' in file.lower() or 'llama-3' in file.lower():
        model_types.append('Llama3')
    elif 'pythia' in file.lower() and 'deduped' in file.lower():
        model_types.append('pythia-deduped')
    elif 'pythia' in file.lower():
        model_types.append('Pythia')
    elif 'olmo' in file.lower():
        if '1bstep738020' in file.lower() or '7bstep557000' in file.lower():
            model_types.append('OLMo')
        else:
            model_types.append('OLMo-premature')
    elif 'dolly' in file.lower():
        model_types.append('Dolly')
    else:
        raise ValueError(f'Unknown model type for file {file}')
    if tokens is not None:
        if 'olmo' in model_name.lower():
            if 'instruct' in model_name.lower() or 'sft' in model_name.lower():
                tokens.append(None)
            else:
                match = re.search('tokens(\\d+)B', model_name, re.IGNORECASE)
                if match:
                    tokens.append(int(match.group(1)))
                else:
                    raise ValueError(f'Could not find tokens in model name {model_name}')
        elif 'pythia' in model_name.lower():
            match = re.search('step(\\d+)', model_name, re.IGNORECASE)
            if match:
                tokens.append(int(match.group(1)) * 2097152 / 1000000000.0)
            else:
                tokens.append(143000 * 2097152 / 1000000000.0)
        elif 'dolly' in model_name.lower():
            tokens.append(143000 * 2097152 / 1000000000.0)
            params[-1] = 2800000000.0 if params[-1] == 3000000000.0 else 6900000000.0 if params[-1] == 7000000000.0 else params[-1]
        else:
            tokens.append(None)
    return model_name

ARGS = {
    'file': 'results_pythia_step1000_7b.txt',
    'model_types': [],
    'params': [],
    'tokens': []
}
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 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
is_valid_fact Ran
ran, violated the contract we drafted
mivg/fallbacks/open_ended_evaluator.py
code served (permissive licence) · get_code("f7cc1f5104a407c1")
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 torch

def is_valid_fact(fact: str):
    fact = fact.lower()
    if 'the sentence' in fact and ('does not contain' in fact or 'does not provide' in fact) and ('fact' in fact):
        return False
    return True

ARGS = {
    'fact': 'This is a valid fact about the world'
}
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 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
load_model_and_tokenizer Ran
ran; our contract draft was wrong, not the code
mivg/fallbacks/utils/utils.py
code served (permissive licence) · get_code("03f72536317546c1")
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
from transformers import AutoTokenizer, AutoModelForCausalLM

torch.manual_seed(0)

# Create a minimal stand-in model that satisfies AutoModelForCausalLM interface
class MockCausalLMModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def forward(self, input_ids, **kwargs):
        return self.linear(input_ids.float())

# Create a minimal stand-in tokenizer
class MockTokenizer:
    def __init__(self):
        self.vocab_size = 1000
        self.pad_token_id = 0
    
    def encode(self, text):
        return [1, 2, 3]
    
    def decode(self, ids):
        return "decoded text"

# Monkey-patch AutoTokenizer.from_pretrained to return our mock
original_tokenizer_method = AutoTokenizer.from_pretrained
def mock_from_pretrained_tokenizer(model_name, **kwargs):
    return MockTokenizer()

# Monkey-patch AutoModelForCausalLM.from_pretrained to return our mock
original_model_method = AutoModelForCausalLM.from_pretrained
def mock_from_pretrained_model(model_name, **kwargs):
    return MockCausalLMModel()

AutoTokenizer.from_pretrained = staticmethod(mock_from_pretrained_tokenizer)
AutoModelForCausalLM.from_pretrained = staticmethod(mock_from_pretrained_model)

ARGS = {
    "model_name": "gpt2"
}
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
read_jsonl_to_list Ran
ran; our contract draft was wrong, not the code
mivg/fallbacks/utils/utils.py
code served (permissive licence) · get_code("2d5f654e9c61426f")
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 JSONL file with sample data
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test_data.jsonl")

# Write sample JSONL data
sample_data = [
    {"id": 1, "text": "first example", "value": 42},
    {"id": 2, "text": "second example", "value": 100},
    {"id": 3, "text": "third example", "value": -5}
]

with open(temp_file, 'w') as f:
    for item in sample_data:
        f.write(json.dumps(item) + '\n')

ARGS = {
    "file_path": temp_file
}
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
sort_by Ran
ran; our contract draft was wrong, not the code
Mivg/fallbacks/scripts/create_paper_plots.py
code served (permissive licence) · get_code("472ca68ee68861b4")
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 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 torch
import numpy as np
from collections import defaultdict

# The function sort_by takes a 'key' parameter and returns a function f
# The function f processes rows (dicts) with keys like 'parameters', 'tokens', and other keys
# The rows contain string values for 'parameters' (e.g., "7M", "13B")
# and numeric/string values for other keys

# Create sample row data that the returned function will process
row_base = {
    'parameters': '7M',
    'tokens': 100,
    'model_type': 'base',
    'other_metric': 'SFT = 0.5'
}

row_large = {
    'parameters': '13B',
    'tokens': 500,
    'model_type': 'SFT',
    'other_metric': 'base = 1.2'
}

# The key parameter should be one of: 'parameters', 'tokens', or another key
# Let's test with different keys
key_value = 'parameters'

ARGS = {
    'key': key_value
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — 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
generate_predictions Not yet run
unverified (harvested, no recorded run)
mivg/fallbacks/run_hallucinations_check.py
code served (permissive licence) · get_code("7136968f74981fc8")
How it ran

no invocation recorded.

get_tokenizer_encode_decode Not yet run
unverified (harvested, no recorded run)
mivg/fallbacks/utils/degeneration_detector.py
code served (permissive licence) · get_code("c9db7bee70245214")
How it ran

no invocation recorded.

prepare_results_dataframe Not yet run
unverified (harvested, no recorded run)
Mivg/fallbacks/scripts/create_paper_plots.py
code served (permissive licence) · get_code("2520b075c722cf7f")
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

Large language models (LLMs) often exhibit undesirable behaviors, such as hallucinations and sequence repetitions. We propose to view these behaviors as fallbacks that models exhibit under epistemic uncertainty, and investigate the connection between them. We categorize fallback behaviors -sequence repetitions, degenerate text, and hallucinations -and extensively analyze them in models from the same family that differ by the amount of pretraining tokens, parameter count, or the inclusion of instruction-following training. Our experiments reveal a clear and consistent ordering of fallback behaviors, across all these axes: the more advanced an LLM is (i.e., trained on more tokens, has more parameters, or instruction-tuned), its fallback behavior shifts from sequence repetitions, to degenerate text, and then to hallucinations. Moreover, the same ordering is observed during the generation of a single sequence, even for the best-performing models; as uncertainty increases, models shift from generating hallucinations to producing degenerate text and finally sequence repetitions. Lastly, we demonstrate that while common decoding techniques, such as random sampling, alleviate unwanted behaviors like sequence repetitions, they increase harder-to-detect hallucinations.

For agents

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

get_harvested_code_for_paper("2407.06071")
get_code_for_paper("2407.06071")
have("2407.06071")

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

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

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

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

Connect an agent — have() is free.