SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2210.06464 · NeurIPS · 2022

Predictive Querying for Autoregressive Neural Sequence Models

Stephan Mandt, Alex Boyd, Padhraic Smyth, Sam Showalter

arXiv · PDF · Open in the Atlas

Code that ran

7 of 13 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 5 failures of our instrument; 6 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.06464.json · badge: /api/ran/2210.06464.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
ajboyd2/prob_seq_queries canonical (classifier label)
classifier basis: classifier_2025
7 ran · 6 no recorded run
FunctionStatusWhere it lives
BSNode Ran
ran on a synthesized input · constructed an object; no result was computed
ajboyd2/prob_seq_queries/seq_queries/sample.py
code served (permissive licence) · get_code("01f54e99a9a60e27")
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, BSNode: 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 torch
import torch.nn as nn
from collections import defaultdict

torch.manual_seed(0)

# Create a minimal tree object with id_to_char mapping
class MinimalTree:
    def __init__(self):
        self.id_to_char = {0: 'a', 1: 'b', 2: 'c', 3: 'd'}

# Create minimal tensors for log conditionals (2D, will be flattened)
log_q_conditionals = torch.randn(2, 4)
log_p_conditionals = torch.randn(2, 4)

# Create hidden state as a tuple of tensors (for LSTM-like)
hidden_state = (torch.randn(1, 4), torch.randn(1, 4))

# Create a parent node (None for root, but can be another BSNode)
parent_node = None

# Symbol is typically an integer token
symbol = 0

# Depth is an integer
depth = 0

# Tree object
tree = MinimalTree()

ARGS = {
    'symbol': symbol,
    'parent': parent_node,
    'log_q_conditionals': log_q_conditionals,
    'log_p_conditionals': log_p_conditionals,
    'hidden_state': hidden_state,
    'tree': tree,
    'depth': depth,
}
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 BSNode — 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 BSNode 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
BeamSearchSampleTree Ran
ran on a synthesized input · constructed an object; no result was computed
ajboyd2/prob_seq_queries/seq_queries/sample.py
code served (permissive licence) · get_code("84afed32bac6237d")
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, BeamSearchSampleTree: 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 torch
from collections import defaultdict

torch.manual_seed(0)

# Create a minimal text_dict with required keys
text_dict = {
    'id_to_char': {
        0: '<BOS>',
        1: 'a',
        2: 'b',
        3: 'c',
        4: 'd',
    },
    'char_to_id': {
        '<BOS>': 0,
        'a': 1,
        'b': 2,
        'c': 3,
        'd': 4,
    }
}

ARGS = {
    'text_dict': text_dict,
    'default_size': 5,
    'uses_attention': 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 BeamSearchSampleTree — 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 BeamSearchSampleTree 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
_hidden_state_select Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
ajboyd2/prob_seq_queries/seq_queries/sample.py
code served (permissive licence) · get_code("2788500c55cb2165")
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 6, 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

torch.manual_seed(0)

# Test case 1: uses_attention=True, is_root=True
# state should be a tuple of tuples, where each inner tuple contains (h1, h2)
# h1 and h2 should be tensors where we can index with [i] and unsqueeze
state_attention_root = tuple([
    (torch.randn(2, 4, 5, 6), torch.randn(2, 4, 5, 6)),
    (torch.randn(2, 4, 5, 6), torch.randn(2, 4, 5, 6))
])

# Test case 2: uses_attention=False, isinstance(state, tuple)=True
# state should be a tuple of tensors where we can index with [..., i, :]
state_tuple = (
    torch.randn(2, 3, 4, 5),
    torch.randn(2, 3, 4, 5)
)

# Test case 3: uses_attention=False, isinstance(state, tuple)=False
# state should be a tensor where we can index with [..., i, :]
state_tensor = torch.randn(2, 3, 4, 5)

# Create ARGS for the function with uses_attention=True, is_root=True
ARGS = {
    'state': state_attention_root,
    'i': 0,
    'is_root': True,
    'uses_attention': True
}
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 6, 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
_tup_cpu Ran
ran; our contract draft was wrong, not the code
ajboyd2/prob_seq_queries/seq_queries/sample.py
code served (permissive licence) · get_code("953f276962847553")
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

torch.manual_seed(0)

# Test case 1: tuple of tuples (pairs of tensors)
tup_of_tuples = (
    (torch.randn(2, 4), torch.randn(2, 3)),
    (torch.randn(2, 4), torch.randn(2, 3))
)

# Test case 2: tuple of tensors
tup_of_tensors = (
    torch.randn(2, 4),
    torch.randn(2, 3),
    torch.randn(2, 5)
)

# Test case 3: single tensor
single_tensor = torch.randn(2, 4)

# Test case 4: empty tuple
empty_tup = ()

# Test case 5: None
none_val = None

ARGS = {
    "tup": tup_of_tuples,
    "force": 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 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
_tup_cpu_gpt2 Ran
ran; our contract draft was wrong, not the code
ajboyd2/prob_seq_queries/seq_queries/sample.py
code served (permissive licence) · get_code("5bd55c74b63a005b")
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

torch.manual_seed(0)

# Case 1: Empty tuple (falsy)
empty_tup = ()

# Case 2: Tuple of (tensor, tensor) pairs
t1 = torch.randn(2, 4)
t2 = torch.randn(2, 3)
t3 = torch.randn(2, 5)
t4 = torch.randn(2, 6)

tuple_of_pairs = ((t1, t2), (t3, t4))

# Case 3: Single tensor (not a tuple)
single_tensor = torch.randn(2, 4)

# Test with force=False (default) - will return tuple of pairs as-is since it's a tuple
# Test with force=True - will call .cpu() on each element

ARGS = {
    "tup": tuple_of_pairs,
    "force": 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 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
min_variance_top_k Ran
ran; our contract draft was wrong, not the code
ajboyd2/prob_seq_queries/seq_queries/sample.py
code served (permissive licence) · get_code("b0160851016bd79c")
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 1, dtype family float, shape (4,) 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

torch.manual_seed(0)

# Construct a small logits tensor
# The function expects logits that will be exponentiated to get probabilities
logits = torch.randn(4, dtype=torch.float32)

# Build ARGS dict with all parameters
ARGS = {
    "logits": logits,
    "min_var_reduction": 0.0,
    "filter_value": -float('Inf'),
    "is_log_prob": False,
    "max_num_tree_beams": 3,
}
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 1, dtype family float, shape (4,) — shape (4,) 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
top_k_top_p_filtering Ran
ran; our contract draft was wrong, not the code
ajboyd2/prob_seq_queries/seq_queries/sample.py
code served (permissive licence) · get_code("d111355f8bf308f3")
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 1, dtype family float, shape (10,) 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

torch.manual_seed(0)

# Create a small logits tensor with shape (vocabulary_size,)
# The function expects logits of shape (vocab_size,) for batch size 1
logits = torch.randn(10)

ARGS = {
    "logits": logits,
    "top_k": 5,
    "top_p": 0.9,
    "min_var": False,
    "filter_value": -float('Inf'),
    "is_log_prob": 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 1, dtype family float, shape (10,) — shape (10,) 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
beam_search_is_hybrid Not yet run
unverified (harvested, no recorded run)
ajboyd2/prob_seq_queries/seq_queries/sample.py
code served (permissive licence) · get_code("485281e3d11416fa")
How it ran

no invocation recorded.

beam_search_lower_bound Not yet run
unverified (harvested, no recorded run)
ajboyd2/prob_seq_queries/seq_queries/sample.py
code served (permissive licence) · get_code("9e8a897fff3a55d9")
How it ran

no invocation recorded.

get_optimizer Not yet run
unverified (harvested, no recorded run)
ajboyd2/prob_seq_queries/scripts/train/amazon.py
code served (permissive licence) · get_code("4e56934b09a04cad")
How it ran

no invocation recorded.

train Not yet run
unverified (harvested, no recorded run)
ajboyd2/prob_seq_queries/scripts/train/amazon.py
code served (permissive licence) · get_code("d5586c4a77b49699")
How it ran

no invocation recorded.

tree_is_estimate_attn Not yet run
unverified (harvested, no recorded run)
ajboyd2/prob_seq_queries/seq_queries/sample.py
code served (permissive licence) · get_code("81646133d69707bb")
How it ran

no invocation recorded.

tree_is_estimate_rnn Not yet run
unverified (harvested, no recorded run)
ajboyd2/prob_seq_queries/seq_queries/sample.py
code served (permissive licence) · get_code("80a1ab04938e54b2")
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

In reasoning about sequential events it is natural to pose probabilistic queries such as "when will event A occur next" or "what is the probability of A occurring before B", with applications in areas such as user modeling, medicine, and finance. However, with machine learning shifting towards neural autoregressive models such as RNNs and transformers, probabilistic querying has been largely restricted to simple cases such as next-event prediction. This is in part due to the fact that future querying involves marginalization over large path spaces, which is not straightforward to do efficiently in such models. In this paper we introduce a general typology for predictive queries in neural autoregressive sequence models and show that such queries can be systematically represented by sets of elementary building blocks. We leverage this typology to develop new query estimation methods based on beam search, importance sampling, and hybrids. Across four large-scale sequence datasets from different application domains, as well as for the GPT-2 language model, we demonstrate the ability to make query answering tractable for arbitrary queries in exponentially-large predictive path-spaces, and find clear differences in cost-accuracy tradeoffs between search and sampling methods.

For agents

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

get_harvested_code_for_paper("2210.06464")
get_code_for_paper("2210.06464")
have("2210.06464")

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

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

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

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

Connect an agent — have() is free.