SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2207.02098 · 2022

Neural Networks and the Chomsky Hierarchy

arXiv · PDF · Open in the Atlas

Code that ran

8 of 9 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; 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/2207.02098.json · badge: /api/ran/2207.02098.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
deepmind/neural_networks_chomsky_hierarchy canonical (classifier label)
classifier basis not recorded on the link
8 ran · 1 no recorded run
FunctionStatusWhere it lives
add_sampling_to_autoregressive_model Ran
ran on a synthesized input
deepmind/neural_networks_chomsky_hierarchy/experiments/utils.py
code served (permissive licence) · get_code("8499470338732e14")
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 jax
import jax.numpy as jnp
from jax import nn as jnn
import haiku as hk
import chex

def simple_autoregressive_model(x, y):
    """A minimal autoregressive model that takes input x and target y."""
    # Simple model that just returns logits based on y
    batch_size = y.shape[0]
    output_size = y.shape[-1]
    
    # Create a simple linear transformation
    output_length = y.shape[1] if len(y.shape) > 2 else 1
    
    # Return logits of same shape as y
    return jnp.ones_like(y) * 0.5

# Test the model works with Haiku
def wrapped_model(x, y):
    return simple_autoregressive_model(x, y)

# Create test data
batch_size = 2
seq_length = 3
input_size = 4
output_size = 5

# Input x: shape (batch, time, input_size)
x_test = jnp.ones((batch_size, seq_length, input_size))

# Target y: shape (batch, time, output_size)
y_test = jnp.ones((batch_size, seq_length, output_size))

# Create the wrapped model
def init_fn(x, y):
    return wrapped_model(x, y)

ARGS = {
    'model': wrapped_model,
    'single_output': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
chex, haiku, jax — 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
apply_rotary_encoding Ran
ran on a synthesized input
deepmind/neural_networks_chomsky_hierarchy/models/positional_encodings.py
code served (permissive licence) · get_code("262898e7bad989f2")
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 ArrayImpl, ndim 6, dtype family float, shape (2, 3, 2, 3, 1, 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 jax.numpy as jnp
import numpy as np

# Create small tensors for testing
batch_size = 2
seq_length = 3
head_dim = 4

# x: shape (batch, seq_length, heads, head_dim)
# Following the function's einsum 'bthd,dD->bthD', we need x.shape[-1] to be even
x = jnp.ones((batch_size, seq_length, 1, head_dim), dtype=jnp.float32)

# position: shape (batch, seq_length, 1, 1) based on how it's used in the function
# It's broadcast with inv_freq which has shape (1, 1, 1, head_dim)
position = jnp.arange(seq_length, dtype=jnp.float32)
position = position[None, :, None, None]  # shape (1, seq_length, 1, 1)
position = jnp.broadcast_to(position, (batch_size, seq_length, 1, 1))

max_time = 10000

ARGS = {
    "x": x,
    "position": position,
    "max_time": max_time,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jax, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 6, dtype family float, shape (2, 3, 2, 3, 1, 4) — shape (2, 3, 2, 3, 1, 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
compute_sliding_window_mask Ran
ran on a synthesized input
deepmind/neural_networks_chomsky_hierarchy/models/transformer.py
code served (permissive licence) · get_code("1cb4ff823f79cdaf")
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 ArrayImpl, ndim 2, dtype family float, shape (5, 5) 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 jax.numpy as jnp

# Define arguments for compute_sliding_window_mask
ARGS = {
    "sequence_length": 5,
    "attention_window": 3,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
chex, jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 2, dtype family float, shape (5, 5) — shape (5, 5) 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
make_model_with_targets_as_input Ran
ran on a synthesized input
deepmind/neural_networks_chomsky_hierarchy/experiments/utils.py
code served (permissive licence) · get_code("fb6190a3aabacb45")
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 jax
import jax.numpy as jnp
from jax import nn as jnn
import inspect

# Set seed for reproducibility
jax.config.update('jax_platform_name', 'cpu')

# Define a simple model function that takes one-hot encoded input
def simple_model(x, input_length=None):
    """Simple model that processes input and returns output of same shape."""
    # Just return a learned transformation of the input
    # x shape: (batch_size, time_steps, feature_size)
    return jnp.sum(x, axis=-1, keepdims=True) * jnp.ones_like(x)

# Alternative model without input_length parameter
def simple_model_no_length(x):
    """Simple model without input_length parameter."""
    return jnp.sum(x, axis=-1, keepdims=True) * jnp.ones_like(x)

# Build ARGS dictionary with all parameters
ARGS = {
    "model": simple_model,
    "computation_steps_mult": 2,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
chex, jax — 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
range_evaluation Ran
ran on a synthesized input
deepmind/neural_networks_chomsky_hierarchy/experiments/range_evaluation.py
code served (permissive licence) · get_code("442971a494ee0b61")
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 jax
import jax.numpy as jnp
import haiku as hk
import numpy as np
from typing import Mapping
import dataclasses

# Set seeds for reproducibility
np.random.seed(0)

# Define a simple Haiku model
def simple_model(x):
    """Simple feedforward model for testing."""
    x = hk.Linear(8)(x)
    x = jax.nn.relu(x)
    x = hk.Linear(4)(x)
    return x

# Create transformed model
model = hk.transform(simple_model)

# Initialize parameters with a dummy batch
dummy_input = jnp.ones((2, 4))  # batch_size=2, input_dim=4
rng = jax.random.PRNGKey(0)
params = model.init(rng, dummy_input)

# Define accuracy function
def accuracy_fn(outputs, targets):
    """Simple accuracy function comparing outputs and targets."""
    # outputs shape: (batch_size, 4)
    # targets shape: (batch_size, 4)
    # Return accuracy per sample
    predictions = jnp.argmax(outputs, axis=-1)
    targets_idx = jnp.argmax(targets, axis=-1)
    matches = predictions == targets_idx
    return matches.astype(jnp.float32)

# Define sample_batch function
def sample_batch(rng_key, batch_size, length):
    """Generate a batch of samples."""
    # Generate random input and output
    input_data = jax.random.normal(rng_key, shape=(batch_size, 4))
    output_data = jax.random.normal(
        jax.random.fold_in(rng_key, 1),
        shape=(batch_size, 4)
    )
    return {
        'input': input_data,
        'output': output_data
    }

# Create EvaluationParams
@dataclasses.dataclass
class EvaluationParams:
    """The parameters used for range evaluation of networks."""
    model: hk.Transformed
    params: hk.Params
    accuracy_fn: callable
    sample_batch: callable
    max_test_length: int
    total_batch_size: int
    sub_batch_size: int
    is_autoregressive: bool = False

eval_params = EvaluationParams(
    model=model,
    params=params,
    accuracy_fn=accuracy_fn,
    sample_batch=sample_batch,
    max_test_length=3,
    total_batch_size=4,
    sub_batch_size=2,
    is_autoregressive=False
)

ARGS = {
    'eval_params': eval_params,
    'use_tqdm': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
absl, haiku, jax, numpy, tqdm — 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
relative_shift Ran
ran on a synthesized input
deepmind/neural_networks_chomsky_hierarchy/models/positional_encodings.py
code served (permissive licence) · get_code("09fd3bf2295c9d89")
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 ArrayImpl, ndim 4, dtype family float, shape (2, 2, 2, 3) 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 jax
import jax.numpy as jnp
import chex

# Set seed for reproducibility
key = jax.random.PRNGKey(0)

# Create test logits for the non-causal case
# Shape: [batch, batch, T_q, T_v + T_q]
# Let's use T_q=2, T_v=3, so total_len = 5
# We need shape [batch, batch, 2, 5] for the vmap(vmap(fn)) application
batch_size = 2
tq = 2
tv = 3
total_len = tq + tv

# Generate random logits with the right shape
logits_non_causal = jax.random.normal(key, shape=(batch_size, batch_size, tq, total_len))

# For the causal case, logits should be [batch, batch, T_q, T_v]
logits_causal = jax.random.normal(key, shape=(batch_size, batch_size, tq, tv))

ARGS = {
    "logits": logits_non_causal,
    "attention_length": tv,
    "causal": False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
chex, jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 4, dtype family float, shape (2, 2, 2, 3) — shape (2, 2, 2, 3) 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
shift_right Ran
ran on a synthesized input
deepmind/neural_networks_chomsky_hierarchy/models/transformer.py
code served (permissive licence) · get_code("f543902537c379f7")
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 ArrayImpl, ndim 3, dtype family float, shape (2, 3, 5) 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 jax.numpy as jnp
import jax.nn as jnn
import chex

# Create a small one-hot encoded input
# Shape: (batch_size=2, sequence_length=3, num_classes=4)
batch_size = 2
sequence_length = 3
num_classes = 4

# Create one-hot encoded tensor
x = jnp.zeros((batch_size, sequence_length, num_classes))
# Manually set some one-hot values
x = x.at[0, 0, 0].set(1.0)
x = x.at[0, 1, 2].set(1.0)
x = x.at[0, 2, 1].set(1.0)
x = x.at[1, 0, 3].set(1.0)
x = x.at[1, 1, 1].set(1.0)
x = x.at[1, 2, 2].set(1.0)

output_size = 4

ARGS = {
    "x": x,
    "output_size": output_size
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
chex, jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 3, dtype family float, shape (2, 3, 5) — shape (2, 3, 5) 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
sinusoid_position_encoding Ran
ran on a synthesized input
deepmind/neural_networks_chomsky_hierarchy/models/positional_encodings.py
code served (permissive licence) · get_code("565e280575548c15")
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 ndarray, ndim 2, dtype family float, shape (20, 16) 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 numpy as np

ARGS = {
    "sequence_length": 8,
    "hidden_size": 16,
    "memory_length": 4,
    "max_timescale": 10000.0,
    "min_timescale": 2.0,
    "clamp_length": 0,
    "causal": False,
}
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 ndarray, ndim 2, dtype family float, shape (20, 16) — shape (20, 16) 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
layer_norm Not yet run
unverified (harvested, no recorded run)
deepmind/neural_networks_chomsky_hierarchy/models/transformer.py
code served (permissive licence) · get_code("5d83309868b4e1a6")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 3 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 3 later) and 6 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
layer_norm 2 other papers
1 dated earlier, 1 later
2205.05055 (2022-05)
Data Distributional Properties Drive Emergent In-Context Learning in Transformers
2302.03067 (2023-02)
Memory-Based Meta-Learning on Non-Stationary Distributions
compute_sliding_window_mask 1 other paper
1 later
2302.03067 (2023-02)
Memory-Based Meta-Learning on Non-Stationary Distributions
sinusoid_position_encoding 1 other paper
1 later
2302.03067 (2023-02)
Memory-Based Meta-Learning on Non-Stationary Distributions

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

Reliable generalization lies at the heart of safe ML and AI. However, understanding when and how neural networks generalize remains one of the most important unsolved problems in the field. In this work, we conduct an extensive empirical study (20'910 models, 15 tasks) to investigate whether insights from the theory of computation can predict the limits of neural network generalization in practice. We demonstrate that grouping tasks according to the Chomsky hierarchy allows us to forecast whether certain architectures will be able to generalize to out-of-distribution inputs. This includes negative results where even extensive amounts of data and training time never lead to any non-trivial generalization, despite models having sufficient capacity to fit the training data perfectly. Our results show that, for our subset of tasks, RNNs and Transformers fail to generalize on non-regular tasks, LSTMs can solve regular and counter-language tasks, and only networks augmented with structured memory (such as a stack or memory tape) can successfully generalize on context-free and context-sensitive tasks.

For agents

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

get_harvested_code_for_paper("2207.02098")
get_code_for_paper("2207.02098")
have("2207.02098")

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

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

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

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

Connect an agent — have() is free.