SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2401.14113 · AAAI · 2024

On the Affinity, Rationality, and Diversity of Hierarchical Topic Modeling

Anh Luu, Thong Nguyen, Xiaobao Wu, Cong-Duy Nguyen, Chaoqun Liu, Yichao Feng, Fengjun Pan

arXiv · PDF · Open in the Atlas

Code that ran

7 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (5 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 1 failure 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/2401.14113.json · badge: /api/ran/2401.14113.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
bobxwu/traco marked official in Papers with Code
Papers with Code archive
4 ran · 2 no recorded run
bobxwu/topmost community
Papers with Code archive
3 ran · 1 no recorded run
FunctionStatusWhere it lives
CDDecoder Ran
ran on a synthesized input · constructed an object; no result was computed
bobxwu/traco/TraCo/models/TraCo.py
pointer only (licence: NONE) · get_code("9e70565457da2ef9")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, bobxwu/traco when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

CDDecoder Ran
ran on a synthesized input · constructed an object; no result was computed
bobxwu/topmost/topmost/models/hierarchical/TraCo/TraCo.py
code served (permissive licence) · get_code("716e6ea5aa2e5043")
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, CDDecoder: 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
from torch import nn
import torch.nn.functional as F

torch.manual_seed(0)

# Create a minimal utils module with get_topk_tensor function
class utils:
    @staticmethod
    def get_topk_tensor(tensor, topk):
        """Return a tensor with only top-k values, rest are zero"""
        batch_size, vocab_size = tensor.shape
        values, indices = torch.topk(tensor, k=min(topk, vocab_size), dim=1)
        result = torch.zeros_like(tensor)
        result.scatter_(1, indices, values)
        return result

# Define CDDecoder class
class CDDecoder(nn.Module):

    def __init__(self, num_layers, vocab_size, bias_p, bias_topk):
        super().__init__()
        self.num_layers = num_layers
        self.bias_p = bias_p
        self.bias_topk = bias_topk
        self.decoder_bn_list = nn.ModuleList([nn.BatchNorm1d(vocab_size, affine=False) for _ in range(num_layers)])
        self.bias_vectors = nn.ParameterList([])
        for _ in range(num_layers):
            bias_vector = nn.Parameter(nn.init.xavier_uniform_(torch.empty(1, vocab_size)))
            self.bias_vectors.append(bias_vector)

    def forward(self, input_bow, theta_list, beta_list):
        topk_bias_list = list()
        all_recon_loss = 0.0
        for layer_id in range(self.num_layers):
            topk_bias = utils.get_topk_tensor(beta_list[layer_id], topk=self.bias_topk).sum(0)
            topk_bias = topk_bias.detach()
            topk_bias_list.append(topk_bias)
        for layer_id in range(self.num_layers):
            topk_bias = 0.0
            if layer_id > 0:
                topk_bias += topk_bias_list[layer_id - 1]
            if layer_id < self.num_layers - 1:
                topk_bias += topk_bias_list[layer_id + 1]
            topk_mask = (topk_bias > 0).float()
            bias = self.bias_p * topk_bias * topk_mask + self.bias_vectors[layer_id] * (1 - topk_mask)
            recon = self.decoder_bn_list[layer_id](torch.matmul(theta_list[layer_id], beta_list[layer_id]))
            recon = recon + bias
            recon = F.softmax(recon, dim=-1)
            recon_loss = -(input_bow * (recon + 1e-12).log()).sum(axis=1)
            recon_loss = recon_loss.mean()
            all_recon_loss += recon_loss
        all_recon_loss /= self.num_layers
        return all_recon_loss

# Setup parameters
num_layers = 2
vocab_size = 4
bias_p = 0.5
bias_topk = 2

# Create input tensors for forward pass
batch_size = 2
input_bow = torch.rand(batch_size, vocab_size)
input_bow = input_bow / input_bow.sum(dim=1, keepdim=True)  # normalize to probability

# Create theta_list (batch_size x num_topics for each layer)
num_topics = 3
theta_list = [torch.rand(batch_size, num_topics) for _ in range(num_layers)]

# Create beta_list (num_topics x vocab_size for each layer)
beta_list = [torch.rand(num_topics, vocab_size) for _ in range(num_layers)]

ARGS = {
    'num_layers': num_layers,
    'vocab_size': vocab_size,
    'bias_p': bias_p,
    'bias_topk': bias_topk,
}
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 CDDecoder — 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 CDDecoder 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
Encoder Ran
ran on a synthesized input · constructed an object; no result was computed
bobxwu/traco/TraCo/models/TraCo.py
pointer only (licence: NONE) · get_code("d3a87665bc06777c")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, bobxwu/traco when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

MLPEncoder Ran
ran on a synthesized input · constructed an object; no result was computed
bobxwu/topmost/topmost/models/hierarchical/TraCo/TraCo.py
code served (permissive licence) · get_code("c72f23962bed8ecd")
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, MLPEncoder: 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
from torch import nn

torch.manual_seed(0)

ARGS = {
    "vocab_size": 16,
    "num_topic": 8,
    "hidden_dim": 12,
    "dropout": 0.2
}
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 MLPEncoder — 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 MLPEncoder 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
TPD Ran
ran on a synthesized input · constructed an object; no result was computed
bobxwu/topmost/topmost/models/hierarchical/TraCo/TraCo.py
code served (permissive licence) · get_code("e5cdd9b2e3fb9ab5")
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, TPD: 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
from torch import nn

torch.manual_seed(0)

# Create a mock utils module with pairwise_euclidean_distance function
class Utils:
    @staticmethod
    def pairwise_euclidean_distance(x, y):
        # Compute pairwise euclidean distance between x and y
        # x: (n, d), y: (m, d) -> output: (n, m)
        x_norm = (x ** 2).sum(dim=1, keepdim=True)
        y_norm = (y ** 2).sum(dim=1, keepdim=True)
        dist = x_norm + y_norm.t() - 2 * torch.matmul(x, y.t())
        dist = torch.clamp(dist, min=0.0)
        return torch.sqrt(dist)

utils = Utils()

# Create topic embeddings for multiple layers with distinct sizes
# Layer 0: (2, 4), Layer 1: (3, 4), Layer 2: (2, 4)
topic_embeddings_list = [
    torch.randn(2, 4),
    torch.randn(3, 4),
    torch.randn(2, 4),
]

ARGS = {
    "sinkhorn_alpha": 1.0,
    "sinkhorn_max_iter": 100,
    "stopThr": 0.005,
}
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 TPD — 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 TPD 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
get_topk_tensor Ran
ran; our contract draft was wrong, not the code
bobxwu/traco/TraCo/models/TraCo.py
pointer only (licence: NONE) · get_code("e0c605268af07ab4")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, bobxwu/traco when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

pairwise_euclidean_distance Ran
ran, honoured the contract we drafted
bobxwu/traco/TraCo/models/TraCo.py
pointer only (licence: NONE) · get_code("c242951c54b4aa3e")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, bobxwu/traco when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

TPD Not yet run
unverified (harvested, no recorded run)
bobxwu/traco/TraCo/models/TraCo.py
pointer only (licence: NONE) · get_code("55495a17a86bbfb4")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, bobxwu/traco when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

TraCo Not yet run
unverified (harvested, no recorded run)
bobxwu/traco/TraCo/models/TraCo.py
pointer only (licence: NONE) · get_code("ac0b74f7db21b2fb")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, bobxwu/traco when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

TraCo Not yet run
unverified (harvested, no recorded run)
bobxwu/topmost/topmost/models/hierarchical/TraCo/TraCo.py
code served (permissive licence) · get_code("ccd803d7ff830522")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 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, 0 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
MLPEncoder
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2304.03544 (2023-04)
InfoCTM: A Mutual Information Maximization Perspective of Cross-Lingual Topic 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

Hierarchical topic modeling aims to discover latent topics from a corpus and organize them into a hierarchy to understand documents with desirable semantic granularity. However, existing work struggles with producing topic hierarchies of low affinity, rationality, and diversity, which hampers document understanding. To overcome these challenges, we in this paper propose Transport Plan and Context-aware Hierarchical Topic Model (TraCo). Instead of early simple topic dependencies, we propose a transport plan dependency method. It constrains dependencies to ensure their sparsity and balance, and also regularizes topic hierarchy building with them. This improves affinity and diversity of hierarchies. We further propose a context-aware disentangled decoder. Rather than previously entangled decoding, it distributes different semantic granularity to topics at different levels by disentangled decoding. This facilitates the rationality of hierarchies. Experiments on benchmark datasets demonstrate that our method surpasses state-of-the-art baselines, effectively improving the affinity, rationality, and diversity of hierarchical topic modeling with better performance on downstream tasks.

For agents

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

get_harvested_code_for_paper("2401.14113")
get_code_for_paper("2401.14113")
have("2401.14113")

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

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

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

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

Connect an agent — have() is free.