SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2403.08293 · ACL · 2024

Generative Pretrained Structured Transformers: Unsupervised Syntactic Language Models at Scale

Wei Wu, Xiang Hu, Kewei Tu, Qingyang Zhu, Pengyu Ji

arXiv · PDF · Open in the Atlas

Code that ran

4 of 7 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; 2 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/2403.08293.json · badge: /api/ran/2403.08293.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
alipay/StructuredLM_RTDT canonical (classifier label)
classifier basis: census
2 ran · 2 no recorded run
ant-research/structuredlm_rtdt marked official in Papers with Code
Papers with Code archive
2 ran · 1 no recorded run
FunctionStatusWhere it lives
GenerativeR2D2 Ran
ran on a synthesized input · constructed an object; no result was computed
ant-research/structuredlm_rtdt/model/generative_r2d2.py
code served (permissive licence) · get_code("a784d2110f131468")
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, GenerativeR2D2: 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
import torch.nn.functional as F
from dataclasses import dataclass
from typing import Optional

torch.manual_seed(0)

# Create minimal R2D2 mock that has the required methods and attributes
class MockR2D2(nn.Module):
    def __init__(self, input_dim, embedding_dim, vocab_size):
        super().__init__()
        self.input_dim = input_dim
        self.embedding_dim = embedding_dim
        self.vocab_size = vocab_size
        self.parser = MockParser()
        self.parser_loss_fn = nn.CrossEntropyLoss()
        
    def forward(self, r2d2_input_ids, chunk_masks, input_ids, masks, r2d2_embeddings, 
                group_ids, max_input_len, atom_spans, coeff=1.0, temperature=1.0, 
                span_ids=None, eos_labels=None, external_vocab_ids=None):
        # Return: ctx, outside_tgt, ldr_repr, position_ids, tgt_ids, token_indices, ext_ids, split_targets, l_height
        batch_size = max(group_ids) + 1
        seq_len = r2d2_embeddings.shape[1]
        
        ctx = torch.randn(batch_size * seq_len, self.embedding_dim)
        outside_tgt = torch.randint(0, self.vocab_size, (batch_size * seq_len,))
        ldr_repr = torch.randn(batch_size, seq_len, self.input_dim)
        position_ids = torch.arange(seq_len).unsqueeze(0).repeat(batch_size, 1)
        tgt_ids = torch.randint(0, self.vocab_size, (batch_size, seq_len))
        token_indices = torch.randint(0, seq_len, (batch_size, 3))
        ext_ids = torch.zeros(batch_size, seq_len, dtype=torch.long)
        split_targets = torch.zeros(batch_size, seq_len, dtype=torch.long)
        l_height = torch.zeros(batch_size, seq_len, dtype=torch.long)
        
        return ctx, outside_tgt, ldr_repr, position_ids, tgt_ids, token_indices, ext_ids, split_targets, l_height
    
    def parser_loss(self, ctx):
        return torch.tensor(0.1)
    
    def outside_embeddings(self, ctx):
        return ctx.view(-1, self.embedding_dim)

class MockParser(nn.Module):
    def __init__(self):
        super().__init__()
    
    def forward(self, x):
        return x

# Create minimal GPT mock
class MockGPT(nn.Module):
    def __init__(self, hidden_dim):
        super().__init__()
        self.hidden_dim = hidden_dim
        self.linear = nn.Linear(hidden_dim, hidden_dim)
    
    def forward(self, inputs_embeds=None, position_ids=None, past_key_values=None):
        batch_size = inputs_embeds.shape[0]
        seq_len = inputs_embeds.shape[1]
        last_hidden_state = self.linear(inputs_embeds)
        
        class Output:
            pass
        
        output = Output()
        output.last_hidden_state = last_hidden_state
        return output

# Set up parameters
embedding_dim = 8
r2d2_input_dim = 6
vocab_size = 16
batch_size = 2
seq_len = 4

# Create models
r2d2_model = MockR2D2(r2d2_input_dim, embedding_dim, vocab_size)
gpt_model = MockGPT(embedding_dim)

# Build ARGS dictionary
ARGS = {
    'r2d2': r2d2_model,
    'gpt': gpt_model,
    'vocab_size': vocab_size,
    'r2d2_input_dim': r2d2_input_dim,
    'embedding_dim': embedding_dim,
    'dropout_rate': 0.2,
    'ext_vocab_size': 0
}
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 GenerativeR2D2 — 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 GenerativeR2D2 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
R2D2GenOutput Ran
ran on a synthesized input · constructed an object; no result was computed
ant-research/structuredlm_rtdt/model/generative_r2d2.py
code served (permissive licence) · get_code("1e812e0a70ef2d48")
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, R2D2GenOutput: 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

torch.manual_seed(0)

ARGS = {
    "struct_loss": torch.tensor([0.5], dtype=torch.float32),
    "non_struct_loss": torch.tensor([0.3], dtype=torch.float32),
    "action_logits": torch.randn(2, 4),
    "logits": torch.randn(2, 8),
    "hidden_states": torch.randn(2, 4),
    "cls_hidden_states": torch.randn(2, 4),
    "tgt_ids": torch.tensor([[1, 2], [3, 4]], dtype=torch.long),
    "pred": torch.randn(2, 3),
    "splits": torch.tensor([[0, 1], [1, 2]], dtype=torch.long),
    "gpt_loss": torch.tensor([0.2], dtype=torch.float32),
    "action_loss": torch.tensor([0.1], dtype=torch.float32),
    "inside_outside_loss": torch.tensor([0.15], dtype=torch.float32),
    "parser_loss": torch.tensor([0.25], dtype=torch.float32),
    "glue_finetune_loss": torch.tensor([0.18], dtype=torch.float32),
    "past_kv": torch.randn(2, 4),
}
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 R2D2GenOutput — 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 R2D2GenOutput 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
reshape_for_broadcast Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
alipay/StructuredLM_RTDT/model/Llama_flash_attn.py
code served (permissive licence) · get_code("f170e96bed9e0da5")
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 4, dtype family float, shape (1, 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 torch

torch.manual_seed(0)

# Create freqs_cis tensor with shape (seq_len, dim)
# Using shape (3, 4) where 3 is sequence length and 4 is dimension
freqs_cis = torch.randn(3, 4)

# Create x tensor with shape (batch, seq_len, ..., dim)
# Using shape (2, 3, 5, 4) where:
# - 2 is batch size
# - 3 matches freqs_cis.shape[0] (sequence length)
# - 5 is an intermediate dimension
# - 4 matches freqs_cis.shape[1] (feature dimension)
x = torch.randn(2, 3, 5, 4)

ARGS = {
    "freqs_cis": freqs_cis,
    "x": x,
}
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 4, dtype family float, shape (1, 3, 1, 4) — shape (1, 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
rotate_half Ran
ran; our contract draft was wrong, not the code
alipay/StructuredLM_RTDT/model/Llama_flash_attn.py
code served (permissive licence) · get_code("e03d53ba9d4f9ae5")
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 Tensor, ndim 2, dtype family float, shape (2, 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)

# The function takes a single parameter 'x' which is a tensor
# It accesses x[..., :x.shape[-1] // 2] and x[..., x.shape[-1] // 2:]
# So x needs to be a tensor with a last dimension that can be split in half
# Let's create a small tensor with batch size 2 and feature dimension 4

x = torch.randn(2, 4)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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, shape (2, 4) — shape (2, 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
apply_rotary_emb Not yet run
unverified (harvested, no recorded run)
alipay/StructuredLM_RTDT/model/Llama_flash_attn.py
code served (permissive licence) · get_code("a1ac0c11d14eec67")
How it ran

no invocation recorded.

load_model Not yet run
unverified (harvested, no recorded run)
ant-research/structuredlm_rtdt/model/generative_r2d2.py
code served (permissive licence) · get_code("68f9327845ca9499")
How it ran

no invocation recorded.

load_tf_weights_in_gpt2 Not yet run
unverified (harvested, no recorded run)
alipay/StructuredLM_RTDT/model/gpt2_flash_attn.py
code served (permissive licence) · get_code("3665fea6427d655d")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 4 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 1 the same month, 2 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
rotate_half 360 other papers
94 dated earlier, 8 the same month, 249 later, 6 same year, order not determinable, 3 undated · 30 only as an assembly brick
1901.02860 (2019-01)
Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context
2203.08913 (2022-03)
Memorizing Transformers
2302.13971 (2023-02)
LLaMA: Open and Efficient Foundation Language Models
and 357 more not named here
load_tf_weights_in_gpt2 11 other papers
4 dated earlier, 7 later
2310.09753 (2023-10)
When can transformers reason with abstract symbols?
2312.16682 (2023-12)
Some things are more CRINGE than others: Iterative Preference Optimization with the Pairwise Cringe Loss
2402.04852 (2024-02)
Multi-Patch Prediction: Adapting LLMs for Time Series Representation Learning
and 8 more not named here
R2D2GenOutput
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
2203.00281 (2022-03)
Fast-R2D2: A Pretrained Recursive Neural Network based on Pruned CKY for Grammar Induction and Text Representation
load_model
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
2203.00281 (2022-03)
Fast-R2D2: A Pretrained Recursive Neural Network based on Pruned CKY for Grammar Induction and Text Representation

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

A syntactic language model (SLM) incrementally generates a sentence with its syntactic tree in a left-to-right manner. We present Generative Pretrained Structured Transformers (GPST), an unsupervised SLM at scale capable of being pre-trained from scratch on raw texts with high parallelism. GPST circumvents the limitations of previous SLMs such as relying on gold trees and sequential training. It consists of two components, a usual SLM supervised by a uni-directional language modeling loss, and an additional composition model, which induces syntactic parse trees and computes constituent representations, supervised by a bi-directional language modeling loss. We propose a representation surrogate to enable joint parallel training of the two models in a hard-EM fashion. We pre-train GPST on OpenWebText, a corpus with 9 billion tokens, and demonstrate the superiority of GPST over GPT-2 with a comparable size in numerous tasks covering both language understanding and language generation. Meanwhile, GPST also significantly outperforms existing unsupervised SLMs on left-to-right grammar induction, while holding a substantial acceleration on training. 1

For agents

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

get_harvested_code_for_paper("2403.08293")
get_code_for_paper("2403.08293")
have("2403.08293")

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

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

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

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

Connect an agent — have() is free.