SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2101.02402 · AAAI · 2021

Compound Word Transformer: Learning to Compose Full-Song Music over Dynamic Directed Hypergraphs

Yi-Hsuan Yang, Wen-Yi Hsiao, Jen-Yu Liu, Yin-Cheng Yeh

arXiv · PDF · Open in the Atlas

Code that ran

4 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 4 have no contract verdict; 0 failures of our instrument; 5 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/2101.02402.json · badge: /api/ran/2101.02402.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
yuer867/emo-disentanger community
Papers with Code archive
4 ran · 5 no recorded run
FunctionStatusWhere it lives
MultiHeadCrossAttn Ran
ran on a synthesized input
yuer867/emo-disentanger/stage1_compose/model/optimus_txl_decoder.py
code served (permissive licence) · get_code("e74a0089372f5f25")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float, shape (3, 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
import torch.nn as nn

INIT_ARGS = {
    'n_head': 2,
    'd_model': 4,
    'd_head': 2,
    'dropout': 0.1,
    'dropatt': 0.1,
    'pre_lnorm': False,
}

ARGS = {
    'h': torch.randn(3, 2, 4),
    'c': torch.randn(5, 2, 4),
    'attn_mask': None,
    'h_pos_embed': None,
    'c_pos_embed': None,
}

if __name__ == '__main__':
    from torch_test_class import MultiHeadCrossAttn
    
    model = MultiHeadCrossAttn(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Expected shape: {ARGS['h'].shape}")
    assert output.shape == ARGS['h'].shape, f"Shape mismatch: {output.shape} vs {ARGS['h'].shape}"
    print("Test passed!")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch, torch_test_class — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (3, 2, 4) — shape (3, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
RelLearnableMultiHeadAttn Ran
ran on a synthesized input
yuer867/emo-disentanger/stage1_compose/model/optimus_txl_decoder.py
code served (permissive licence) · get_code("fa5d0870ee5677a9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, 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 numpy as np
from scipy.linalg import toeplitz

INIT_ARGS = {
    'n_head': 2,
    'd_model': 4,
    'd_head': 3,
    'dropout': 0.1,
    'dropatt': 0.0,
    'tgt_len': 5,
    'ext_len': 2,
    'mem_len': 3,
    'pre_lnorm': False
}

# Create input tensors for forward pass
qlen = INIT_ARGS['tgt_len']
bsz = 2
d_model = INIT_ARGS['d_model']
n_head = INIT_ARGS['n_head']
d_head = INIT_ARGS['d_head']
klen = qlen + INIT_ARGS['mem_len']

# Input tensor w: (qlen, bsz, d_model)
w = torch.randn(qlen, bsz, d_model)

# Relative positional embeddings r_emb: (klen, n_head, d_head)
r_emb = torch.randn(klen, n_head, d_head)

# Relative position biases
r_w_bias = torch.randn(n_head, d_head)
r_bias = torch.randn(klen, n_head)

# Attention mask (optional)
attn_mask = torch.zeros(qlen, klen).byte()
attn_mask[:qlen, :qlen] = torch.triu(attn_mask[:qlen, :qlen], diagonal=1)

# Memory tensor (optional)
mems = torch.randn(INIT_ARGS['mem_len'], bsz, d_model)

ARGS = {
    'w': w,
    'r_emb': r_emb,
    'r_w_bias': r_w_bias,
    'r_bias': r_bias,
    'attn_mask': attn_mask,
    'mems': mems
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, scipy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
RelPartialLearnableMultiHeadAttn Ran
ran on a synthesized input
yuer867/emo-disentanger/stage1_compose/model/optimus_txl_decoder.py
code served (permissive licence) · get_code("8a40eebd3f2277dd")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, 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

# INIT_ARGS for RelPartialLearnableMultiHeadAttn.__init__
INIT_ARGS = {
    'n_head': 2,
    'd_model': 8,
    'd_head': 4,
    'dropout': 0.1,
    'dropatt': 0.1,
    'tgt_len': None,
    'ext_len': None,
    'mem_len': None,
    'pre_lnorm': False
}

# ARGS for RelPartialLearnableMultiHeadAttn.forward
# w: (qlen, bsz, d_model)
# r: (rlen, d_model) - positional encodings
# r_w_bias: (n_head, d_head) - learnable bias for content-based attention
# r_r_bias: (n_head, d_head) - learnable bias for position-based attention
# attn_mask: optional attention mask
# mems: optional memory from previous segment
# return_avg_attn: whether to return average attention weights

qlen = 3
bsz = 2
d_model = INIT_ARGS['d_model']
n_head = INIT_ARGS['n_head']
d_head = INIT_ARGS['d_head']
klen = 5  # length including memory
mlen = 2  # memory length
rlen = qlen + mlen  # relative position length

ARGS = {
    'w': torch.randn(qlen, bsz, d_model),
    'r': torch.randn(rlen, d_model),
    'r_w_bias': torch.randn(n_head, d_head),
    'r_r_bias': torch.randn(n_head, d_head),
    'attn_mask': torch.zeros(qlen, klen).bool(),
    'mems': torch.randn(mlen, bsz, d_model),
    'return_avg_attn': False
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 3, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
WordEmbedding Ran
ran on a synthesized input
yuer867/emo-disentanger/stage1_compose/model/optimus_txl_decoder.py
code served (permissive licence) · get_code("169c0b8a3fa64163")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float, shape (2, 5, 12) 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
import torch.nn as nn

INIT_ARGS = {
    'n_token': 16,
    'd_embed': 8,
    'd_proj': 12,
    'emb_scale': 0.5,
    'pad_idx': None,
}

ARGS = {
    'inp_tokens': torch.randint(0, 16, (2, 5)),
}

if __name__ == '__main__':
    model = nn.Module()
    
    class WordEmbedding(nn.Module):
        def __init__(self, n_token, d_embed, d_proj, emb_scale=0.5, pad_idx=None):
            super(WordEmbedding, self).__init__()
            self.n_token = n_token
            self.d_embed = d_embed
            self.d_proj = d_proj
            self.emb_scale = d_proj ** emb_scale
            if pad_idx is None:
                pad_idx = n_token - 1
            self.emb_lookup = nn.Embedding(n_token, d_embed, padding_idx=pad_idx)
            if d_proj != d_embed:
                self.emb_proj = nn.Linear(d_embed, d_proj, bias=False)
            else:
                self.emb_proj = None

        def forward(self, inp_tokens):
            inp_emb = self.emb_lookup(inp_tokens)
            if self.emb_proj is not None:
                inp_emb = self.emb_proj(inp_emb)
            return inp_emb.mul_(self.emb_scale)
    
    model = WordEmbedding(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Output dtype: {output.dtype}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 3, dtype family float, shape (2, 5, 12) — shape (2, 5, 12) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
OptimusTXLDecoder Not yet run
unverified (harvested, no recorded run)
yuer867/emo-disentanger/stage1_compose/model/optimus_txl_decoder.py
code served (permissive licence) · get_code("4e77f33db530a79a")
How it ran

no invocation recorded.

RelLearnableDecoderLayer Not yet run
unverified (harvested, no recorded run)
yuer867/emo-disentanger/stage1_compose/model/optimus_txl_decoder.py
code served (permissive licence) · get_code("1b3864723e0753c3")
How it ran

no invocation recorded.

RelMultiHeadAttn Not yet run
unverified (harvested, no recorded run)
yuer867/emo-disentanger/stage1_compose/model/optimus_txl_decoder.py
code served (permissive licence) · get_code("f0aec7eb13b95e92")
How it ran

no invocation recorded.

RelPartialLearnableDecoderLayer Not yet run
unverified (harvested, no recorded run)
yuer867/emo-disentanger/stage1_compose/model/optimus_txl_decoder.py
code served (permissive licence) · get_code("bd98b4c481a677b5")
How it ran

no invocation recorded.

SegmentEmbeddingProj Not yet run
unverified (harvested, no recorded run)
yuer867/emo-disentanger/stage1_compose/model/optimus_txl_decoder.py
code served (permissive licence) · get_code("65e3c462206adcba")
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, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 later) and 8 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
RelLearnableDecoderLayer
brick of this paper's assembly: model
2 other papers
1 dated earlier, 1 later
1901.02860 (2019-01)
Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context
2207.06881 (2022-07)
Recurrent Memory Transformer

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

To apply neural sequence models such as the Transformers to music generation tasks, one has to represent a piece of music by a sequence of tokens drawn from a finite set of pre-defined vocabulary. Such a vocabulary usually involves tokens of various types. For example, to describe a musical note, one needs separate tokens to indicate the note's pitch, duration, velocity (dynamics), and placement (onset time) along the time grid. While different types of tokens may possess different properties, existing models usually treat them equally, in the same way as modeling words in natural languages. In this paper, we present a conceptually different approach that explicitly takes into account the type of the tokens, such as note types and metric types. And, we propose a new Transformer decoder architecture that uses different feed-forward heads to model tokens of different types. With an expansion-compression trick, we convert a piece of music to a sequence of compound words by grouping neighboring tokens, greatly reducing the length of the token sequences. We show that the resulting model can be viewed as a learner over dynamic directed hypergraphs. And, we employ it to learn to compose expressive Pop piano music of full-song length (involving up to 10K individual tokens per song), both conditionally and unconditionally. Our experiment shows that, compared to state-of-the-art models, the proposed model converges 5 to 10 times faster at training (i.e., within a day on a single GPU with 11 GB memory), and with comparable quality in the generated music.

For agents

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

get_harvested_code_for_paper("2101.02402")
get_code_for_paper("2101.02402")
have("2101.02402")

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

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

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

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

Connect an agent — have() is free.