SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2207.06366 · 2022

N-Grammer: Augmenting Transformers with latent n-grams

arXiv · PDF · Open in the Atlas

Code that ran

6 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 1 violated it and 3 have no contract verdict; 2 failures of our instrument; 0 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.06366.json · badge: /api/ran/2207.06366.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
tensorflow/lingvo canonical (classifier label)
classifier basis not recorded on the link
5 ran · 0 no recorded run
yiyixuxu/n-grammer-flax community (classifier label)
classifier basis not recorded on the link
1 ran · 0 no recorded run
FunctionStatusWhere it lives
GetFlops Ran
ran on a synthesized input
tensorflow/lingvo/lingvo/core/activations.py
code served (permissive licence) · get_code("6af7b11f92a34c6c")
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 int, ndim 0, dtype family int, 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

ARGS = {
    'activation_name': 'RELU'
}
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 int, ndim 0, dtype family int, 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
ImportAllParams Ran
ran, violated the contract we drafted
tensorflow/lingvo/lingvo/model_imports.py
code served (permissive licence) · get_code("9ec960083b074b30")
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 sys

# The function ImportAllParams takes three parameters:
# 1. task_root: string (default _TASK_ROOT = 'lingvo.tasks')
# 2. task_dirs: tuple of strings (default _TASK_DIRS = ('asr', 'image', 'lm', 'milan', 'mt', 'punctuator'))
# 3. require_success: bool (default False)

# Looking at the function body:
# - task_root is used in string formatting: '{}.{}.params.params'.format(task_root, task)
# - task_dirs is iterated over in a for loop
# - require_success is used in an if condition to determine whether to raise an exception
# - The function calls _Import with module names constructed from task_root and task_dirs

# Since this is a module import function and we can't actually import lingvo modules,
# we'll provide realistic but non-existent module paths that will fail gracefully.
# The function handles ModuleNotFoundError internally.

ARGS = {
    'task_root': 'lingvo.tasks',
    'task_dirs': ('asr', 'image', 'lm', 'milan', 'mt', 'punctuator'),
    'require_success': False
}
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
ImportParams Ran
ran on a synthesized input
tensorflow/lingvo/lingvo/model_imports.py
code served (permissive licence) · get_code("ca4beda520280fb9")
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 sys
from io import StringIO

# Setup: Capture stderr to avoid cluttering output
old_stderr = sys.stderr
sys.stderr = StringIO()

# The function ImportParams takes:
# - model_name: str (required)
# - task_root: str (optional, defaults to 'lingvo.tasks')
# - require_success: bool (optional, defaults to True)

# Looking at the function body:
# 1. model_name is checked to contain '.' and not start with 'test.'
# 2. It's used with string operations: rpartition, _InsertParams, f-strings
# 3. task_root is used in an f-string to construct a module path
# 4. require_success is used in a boolean condition

# Valid model_name: must contain '.', not start with 'test.'
# We'll use a name that won't actually import successfully to test the logic
model_name = "fake.model.name"

# task_root: a string that serves as the root for task modules
task_root = "lingvo.tasks"

# require_success: False so it doesn't raise an error when imports fail
require_success = False

ARGS = {
    'model_name': model_name,
    'task_root': task_root,
    'require_success': require_success,
}
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
get_bigram_ids Ran
ran on a synthesized input
yiyixuxu/n-grammer-flax/n_grammer_flax/n_grammer_flax.py
code served (permissive licence) · get_code("47af72600eb7ee27")
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 int, shape (2, 4, 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.numpy as jnp
import numpy as np

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

# Create small test tensors
batch_size = 2
seq_length = 4
num_heads = 3
vocab_size = 10

# Create uni-gram ids: shape [B, L, H]
ids = np.random.randint(0, vocab_size, size=(batch_size, seq_length, num_heads), dtype=np.int32)

# Create segment_pos: shape [B, L]
# This indicates position in a segment (0 means start of new segment)
segment_pos = np.array([
    [1, 1, 0, 1],
    [1, 0, 1, 1]
], dtype=np.int32)

ARGS = {
    "ids": ids,
    "vocab_size": vocab_size,
    "segment_pos": segment_pos
}
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 3, dtype family int, shape (2, 4, 3) — shape (2, 4, 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
stateless_cache_dataset Ran
ran; our contract draft was wrong, not the code
tensorflow/lingvo/lingvo/compat.py
code served (permissive licence) · get_code("e1e9fb4c30469b3c")
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 tensorflow as tf
import numpy as np

# Create a simple input dataset
input_dataset = tf.data.Dataset.range(5)

# Define ARGS dictionary with the filename parameter
ARGS = {
    'filename': ''
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — 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
stateless_shuffle_dataset Ran
ran; our contract draft was wrong, not the code
tensorflow/lingvo/lingvo/compat.py
code served (permissive licence) · get_code("f1ff841d96a18fdc")
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 tensorflow as tf
import numpy as np

# Create a simple input dataset
input_data = tf.data.Dataset.range(10)

# Define ARGS dictionary with all parameters for stateless_shuffle_dataset
ARGS = {
    'buffer_size': 5,
    'seed': 42,
    'reshuffle_each_iteration': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — 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

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 0 later) and 3 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
ImportAllParams 1 other paper
1 dated earlier
1902.08295 (2019-02)
Lingvo: a Modular and Scalable Framework for Sequence-to-Sequence Modeling
stateless_cache_dataset 1 other paper
1 dated earlier
1902.08295 (2019-02)
Lingvo: a Modular and Scalable Framework for Sequence-to-Sequence Modeling
stateless_shuffle_dataset 1 other paper
1 dated earlier
1902.08295 (2019-02)
Lingvo: a Modular and Scalable Framework for Sequence-to-Sequence Modeling

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

Transformer models have recently emerged as one of the foundational models in natural language processing, and as a byproduct, there is significant recent interest and investment in scaling these models. However, the training and inference costs of these large Transformer language models are prohibitive, thus necessitating more research in identifying more efficient variants. In this work, we propose a simple yet effective modification to the Transformer architecture inspired by the literature in statistical language modeling, by augmenting the model with n-grams that are constructed from a discrete latent representation of the text sequence. We evaluate our model, the N-Grammer on language modeling on the C4 data-set as well as text classification on the SuperGLUE data-set, and find that it outperforms several strong baselines such as the Transformer and the Primer. We open-source our model for reproducibility purposes in Jax.

For agents

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

get_harvested_code_for_paper("2207.06366")
get_code_for_paper("2207.06366")
have("2207.06366")

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

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

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

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

Connect an agent — have() is free.