SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2106.01317 · NAACL · 2021

Enriching Transformers with Structured Tensor-Product Representations for Abstractive Summarization

Jianfeng Gao, Hamid Palangi, Mohit Bansal, Asli Celikyilmaz, Paul Soulos, Roland Fernandez, Paul Smolensky, Unc Hill, Yichen Jiang, Sudha Rao, Caitlin Smith

arXiv · PDF · Open in the Atlas

Code that ran

5 of 5 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 2 have no contract verdict; 3 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/2106.01317.json · badge: /api/ran/2106.01317.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
jiangycTarheel/TPT-Summ canonical (classifier label)
classifier basis: census
5 ran · 0 no recorded run
FunctionStatusWhere it lives
calc_banned_bad_words_ids Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
jiangycTarheel/TPT-Summ/models/modeling_utils.py
code served (permissive licence) · get_code("49656b24dd2f6b62")
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. It ran in syntology-harvest-sandbox:v5-deps (sha256:6a292aa1aed1) at 2026-09-27T00:14:48Z. 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

torch.manual_seed(0)

# Analyzing the function:
# - prev_input_ids: iterable of sequences (used with .tolist()), appears to be a batch of token sequences
# - bad_words_ids: list of lists, where each inner list is a sequence of token ids
# 
# The function:
# 1. Iterates over prev_input_ids (batch)
# 2. For each sequence, checks if it matches prefixes in bad_words_ids
# 3. Calls .tolist() on prev_input_ids_slice, so it should be a tensor or array-like
# 4. Compares sequences using list slicing

# Create prev_input_ids as a batch of token sequences
# Shape: (batch_size=2, seq_len=4) - small tensors
prev_input_ids = torch.tensor([
    [1, 2, 3, 4],
    [5, 6, 7, 8]
], dtype=torch.long)

# Create bad_words_ids as a list of forbidden token sequences
# Each sequence has at least one token (enforced by assertion)
bad_words_ids = [
    [2, 3, 10],      # if prev tokens end with [2, 3], ban token 10
    [6, 7, 11],      # if prev tokens end with [6, 7], ban token 11
    [1, 12],         # if prev tokens end with [1], ban token 12
    [4, 13],         # if prev tokens end with [4], ban token 13
]

ARGS = {
    "prev_input_ids": prev_input_ids,
    "bad_words_ids": bad_words_ids,
}
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 list — a list output has no array shape of its own; none is stated
Environment
image syntology-harvest-sandbox:v5-deps (sha256:6a292aa1aed1); 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
calc_banned_ngram_tokens Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
jiangycTarheel/TPT-Summ/models/modeling_utils.py
code served (permissive licence) · get_code("f1cff4633a737beb")
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 2, dtype family int; no output shape is stated. It ran in syntology-harvest-sandbox:v5-deps (sha256:6a292aa1aed1) at 2026-09-27T00:14:48Z. 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
from torch import Tensor

torch.manual_seed(0)

# Construct arguments for calc_banned_ngram_tokens
# Parameters:
# - prev_input_ids: Tensor of shape (num_hypos, seq_len)
# - num_hypos: int, number of hypotheses
# - no_repeat_ngram_size: int, size of n-grams to avoid repeating
# - cur_len: int, current sequence length

num_hypos = 2
seq_len = 5
no_repeat_ngram_size = 3
cur_len = 4

# Create prev_input_ids tensor: (num_hypos, seq_len)
# Each hypothesis has a sequence of token ids
prev_input_ids = torch.tensor([
    [10, 20, 30, 40, 50],
    [15, 25, 35, 45, 55]
], dtype=torch.long)

ARGS = {
    "prev_input_ids": prev_input_ids,
    "num_hypos": num_hypos,
    "no_repeat_ngram_size": no_repeat_ngram_size,
    "cur_len": cur_len
}
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 list, ndim 2, dtype family int — 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 syntology-harvest-sandbox:v5-deps (sha256:6a292aa1aed1); 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
encode_file Ran
ran on a synthesized input
jiangycTarheel/TPT-Summ/utils.py
code served (permissive licence) · get_code("5f1c3ac292ac298c")
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 torch
import tempfile
import os

class MockTokenizer:
    def batch_encode_plus(self, texts, max_length, pad_to_max_length, return_tensors):
        # Return a mock tokenized output with input_ids and attention_mask
        batch_size = len(texts)
        if return_tensors == 'pt':
            return {
                'input_ids': torch.zeros((batch_size, max_length), dtype=torch.long),
                'attention_mask': torch.ones((batch_size, max_length), dtype=torch.long)
            }
        else:
            return {
                'input_ids': [[0] * max_length],
                'attention_mask': [[1] * max_length]
            }

# Create a temporary text file with some sample data
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_file.write("This is a test sentence.\n")
temp_file.write("Another test line here.\n")
temp_file.write("Final test example.\n")
temp_file.close()

tokenizer = MockTokenizer()
data_path = temp_file.name
max_length = 10
pad_to_max_length = True
return_tensors = 'pt'
max_examples = 2

ARGS = {
    'tokenizer': tokenizer,
    'data_path': data_path,
    'max_length': max_length,
    'pad_to_max_length': pad_to_max_length,
    'return_tensors': return_tensors,
    'max_examples': max_examples
}
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 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
get_inverse_sqrt_schedule_with_warmup Ran
ran on a synthesized input
jiangycTarheel/TPT-Summ/optim_utils.py
code served (permissive licence) · get_code("c26ce97b2f9cb903")
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 LambdaLR. 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 torch.optim import SGD

torch.manual_seed(0)

# Create a minimal model
model = nn.Linear(4, 3)

# Create an optimizer
optimizer = SGD(model.parameters(), lr=0.1)

# Define arguments
ARGS = {
    "optimizer": optimizer,
    "num_warmup_steps": 100,
    "last_epoch": -1
}
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 LambdaLR — a LambdaLR output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a LambdaLR 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
top_k_top_p_filtering Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
jiangycTarheel/TPT-Summ/models/modeling_utils.py
code served (permissive licence) · get_code("8e873fc150477bd1")
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 2, dtype family float; no output shape is stated. It ran in syntology-harvest-sandbox:v5-deps (sha256:6a292aa1aed1) at 2026-09-27T00:14:48Z. 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.functional as F

torch.manual_seed(0)

# Create small logits tensor: (batch_size=2, vocab_size=4)
logits = torch.randn(2, 4)

# Define ARGS dictionary with all parameters
ARGS = {
    "logits": logits,
    "top_k": 2,
    "top_p": 0.9,
    "filter_value": -float('Inf'),
    "min_tokens_to_keep": 1
}
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 2, dtype family float — no output shape is stated: no later run recorded an output shape for this sample (observed_output and metamorphic_properties carry none; shape_contract and output_contract record ndim only)
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 syntology-harvest-sandbox:v5-deps (sha256:6a292aa1aed1); 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 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 3 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 1 the same month, 3 later) and 2 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
top_k_top_p_filtering 21 other papers
4 dated earlier, 1 the same month, 16 later
1909.11942 (2019-09)
ALBERT: A Lite BERT for Self-supervised Learning of Language Representations
2005.00796 (2020-05)
A Simple Language Model for Task-Oriented Dialogue
2009.06367 (2020-09)
GeDi: Generative Discriminator Guided Sequence Generation
and 18 more not named here
calc_banned_ngram_tokens 8 other papers
1 dated earlier, 7 later
1910.13461 (2019-10)
BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension
2109.04096 (2021-09)
A Three-Stage Learning Framework for Low-Resource Knowledge-Grounded Dialogue Generation
2109.08828 (2021-09)
Perspective-taking and Pragmatics for Generating Empathetic Responses Focused on Emotion Causes
and 5 more not named here
calc_banned_bad_words_ids 2 other papers
2 later
2109.08828 (2021-09)
Perspective-taking and Pragmatics for Generating Empathetic Responses Focused on Emotion Causes
2025.findings-emnlp.70 (2025 (year only))
Flexible Thinking for Multimodal Emotional Support Conversation via Reinforcement Learning

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

Abstractive summarization, the task of generating a concise summary of input documents, requires: (1) reasoning over the source document to determine the salient pieces of information scattered across the long document, and (2) composing a cohesive text by reconstructing these salient facts into a shorter summary that faithfully reflects the complex relations connecting these facts. In this paper, we adapt TP-TRANSFORMER (Schlag et al., 2019), an architecture that enriches the original Transformer (Vaswani et al., 2017) with the explicitly compositional Tensor Product Representation (TPR), for the task of abstractive summarization. The key feature of our model is a structural bias that we introduce by encoding two separate representations for each token to represent the syntactic structure (with role vectors) and semantic content (with filler vectors) separately. The model then binds the role and filler vectors into the TPR as the layer output. We argue that the structured intermediate representations enable the model to take better control of the contents (salient facts) and structures (the syntax that connects the facts) when generating the summary. Empirically, we show that our TP-TRANSFORMER outperforms the Transformer and the original TP-TRANSFORMER significantly on several abstractive summarization datasets based on both automatic and human evaluations. On several syntactic and semantic probing tasks, we demonstrate the emergent structural information in the role vectors and improved syntactic interpretability in the TPR layer outputs. 1

For agents

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

get_harvested_code_for_paper("2106.01317")
get_code_for_paper("2106.01317")
have("2106.01317")

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

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

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

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

Connect an agent — have() is free.