SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1907.04907 · 2019

Topic Modeling in Embedding Spaces

arXiv · PDF · Open in the Atlas

Code that ran

10 of 13 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, 2 violated it and 7 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/1907.04907.json · badge: /api/ran/1907.04907.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
adjidieng/ETM canonical (classifier label)
classifier basis: classifier_2025
3 ran · 0 no recorded run
lffloyd/embedded-topic-model community (classifier label)
classifier basis not recorded on the link
4 ran · 2 no recorded run
fumiyo0607/ETM community (classifier label)
classifier basis not recorded on the link
3 ran · 1 no recorded run
FunctionStatusWhere it lives
contains_numeric Ran
ran, violated the contract we drafted
adjidieng/ETM/scripts/data_20ng.py
code served (permissive licence) · get_code("4a1ddf649b3c6fca")
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 torch
import numpy as np

torch.manual_seed(0)

# The function contains_numeric takes a single parameter 'w' (a word/string)
# and checks if any character in it is a digit using isdigit()
# It returns True if any digit is found, False otherwise

# Create test arguments
w_with_digit = "hello123"
w_without_digit = "hello"

# We'll use the version with a digit as the primary test case
ARGS = {
    "w": "hello123"
}
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 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
contains_punctuation Ran
ran, violated the contract we drafted
adjidieng/ETM/scripts/data_20ng.py
code served (permissive licence) · get_code("41dabfe9feb53af6")
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 string

def contains_punctuation(w):
    return any((char in string.punctuation for char in w))

ARGS = {
    "w": "hello!"
}
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
create_bow_dataset Ran
ran on a synthesized input
lffloyd/embedded-topic-model/embedded_topic_model/utils/preprocessing.py
code served (permissive licence) · get_code("f251c5fc43302f37")
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 dict. 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 numpy as np

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

# Create a small dataset with a few documents
dataset = [
    "hello world this is a test",
    "another document with some words",
    "third document here with more content",
]

# Create a vocabulary from the dataset
vocabulary = [
    "hello",
    "world",
    "this",
    "is",
    "a",
    "test",
    "another",
    "document",
    "with",
    "some",
    "words",
    "third",
    "here",
    "more",
    "content",
]

# Construct the ARGS dictionary with all parameters
ARGS = {
    "dataset": dataset,
    "vocabulary": vocabulary,
    "debug_mode": False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy, sklearn — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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_batch Ran
ran on a synthesized input
lffloyd/embedded-topic-model/embedded_topic_model/utils/data.py
code served (permissive licence) · get_code("d0bc25d4fe5b2259")
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, shape (2, 10) 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 numpy as np
import torch

torch.manual_seed(0)

# Small stand-in data structures
vocab_size = 10
batch_size = 2
num_docs = 4
max_doc_length = 3
device = 'cpu'
emsize = 300

# Create tokens: list of arrays where each array contains word indices
tokens = [
    np.array([1, 3, 5]),           # doc 0: 3 words
    np.array([2, 4]),              # doc 1: 2 words
    np.array([0, 6, 7, 8]),        # doc 2: 4 words
    np.array([9])                  # doc 3: 1 word
]

# Create counts: list of arrays where each array contains word counts
counts = [
    np.array([2.0, 1.0, 3.0]),     # counts for doc 0
    np.array([1.0, 2.0]),          # counts for doc 1
    np.array([3.0, 1.0, 2.0, 1.0]), # counts for doc 2
    np.array([5.0])                # counts for doc 3
]

# Create indices for batches (which documents to fetch)
ind = [0, 2]  # fetch documents 0 and 2

ARGS = {
    'tokens': tokens,
    'counts': counts,
    'ind': ind,
    'vocab_size': vocab_size,
    'device': device,
    'emsize': emsize
}
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 Tensor, ndim 2, dtype family float, shape (2, 10) — shape (2, 10) 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_data Ran
ran on a synthesized input
fumiyo0607/ETM/data.py
code served (permissive licence) · get_code("cb6924aa7a38f376")
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 tuple. 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 os
import pickle
import scipy.io
import tempfile
import numpy as np

# Create a temporary directory with mock .mat and .pkl files
tmpdir = tempfile.mkdtemp()

# Create mock vocabulary pickle file
vocab = ['word0', 'word1', 'word2', 'word3', 'word4']
with open(os.path.join(tmpdir, 'vocab.pkl'), 'wb') as f:
    pickle.dump(vocab, f)

# Helper function to create mock .mat files
def create_mock_mat(filepath, key_name, data_shape):
    data = np.random.randint(0, 10, size=data_shape)
    scipy.io.savemat(filepath, {key_name: data})

# Create training data
create_mock_mat(os.path.join(tmpdir, 'bow_tr_tokens.mat'), 'tokens', (5, 3))
create_mock_mat(os.path.join(tmpdir, 'bow_tr_counts.mat'), 'counts', (5, 3))

# Create validation data
create_mock_mat(os.path.join(tmpdir, 'bow_va_tokens.mat'), 'tokens', (4, 3))
create_mock_mat(os.path.join(tmpdir, 'bow_va_counts.mat'), 'counts', (4, 3))

# Create test data
create_mock_mat(os.path.join(tmpdir, 'bow_ts_tokens.mat'), 'tokens', (3, 3))
create_mock_mat(os.path.join(tmpdir, 'bow_ts_counts.mat'), 'counts', (3, 3))

# Create test hold-out split 1 data
create_mock_mat(os.path.join(tmpdir, 'bow_ts_h1_tokens.mat'), 'tokens', (2, 3))
create_mock_mat(os.path.join(tmpdir, 'bow_ts_h1_counts.mat'), 'counts', (2, 3))

# Create test hold-out split 2 data
create_mock_mat(os.path.join(tmpdir, 'bow_ts_h2_tokens.mat'), 'tokens', (2, 3))
create_mock_mat(os.path.join(tmpdir, 'bow_ts_h2_counts.mat'), 'counts', (2, 3))

ARGS = {
    'path': tmpdir
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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_document_frequency Ran
ran on a synthesized input
fumiyo0607/ETM/utils.py
code served (permissive licence) · get_code("bf0882a49ad15968")
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 tuple, ndim 1, dtype family int; 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

torch.manual_seed(0)

# The function expects:
# - data: a list of tensors (documents)
# - wi: a value to search for in documents (scalar or tensor element)
# - wj: optional, another value to search for

# Create sample document data as a list of tensors
# Each document is a 1D tensor containing word indices
doc1 = torch.tensor([[1, 2, 3, 4]])  # shape (1, 4)
doc2 = torch.tensor([[2, 5, 1]])     # shape (1, 3)
doc3 = torch.tensor([[3, 4, 5, 1, 2]]) # shape (1, 5)
doc4 = torch.tensor([[7]])            # shape (1, 1)

data = [doc1, doc2, doc3, doc4]

# Word indices to search for
wi = 1
wj = 2

ARGS = {
    "data": data,
    "wi": wi,
    "wj": wj
}
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 tuple, ndim 1, dtype family int — a tuple 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_document_frequency Ran
ran on a synthesized input
lffloyd/embedded-topic-model/embedded_topic_model/utils/metrics.py
code served (permissive licence) · get_code("5c806f2fc9361a06")
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 tuple, ndim 1, dtype family int; 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

torch.manual_seed(0)

# The function expects:
# - data: an iterable of documents (tensors)
# - wi: a value to search for in documents
# - wj: optional second value to search for

# Create sample data: list of documents where each document is a tensor
# Documents can contain integer values (word indices)
data = [
    torch.tensor([1, 2, 3, 4]),
    torch.tensor([2, 3, 5]),
    torch.tensor([1, 3, 4, 5]),
    torch.tensor([1, 2, 4])
]

# wi and wj are word indices (scalars that will be checked with "in" operator)
wi = 1
wj = 2

ARGS = {
    "data": data,
    "wi": wi,
    "wj": wj
}
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 tuple, ndim 1, dtype family int — a tuple 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_topic_coherence Ran
ran on a synthesized input
lffloyd/embedded-topic-model/embedded_topic_model/utils/metrics.py
code served (permissive licence) · get_code("285be6a543ea1959")
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 float64, ndim 0, 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 numpy as np
import torch

torch.manual_seed(0)

# beta: array-like of shape (num_topics, vocab_size)
# The function calls beta[k].argsort()[-top_n:][::-1], so it needs to support indexing and argsort()
# Using numpy arrays
num_topics = 3
vocab_size = 12
beta = np.random.rand(num_topics, vocab_size)

# data: list of documents
# Each document is checked with "if wi in doc", so it needs to support the 'in' operator
# The function also calls document.squeeze(0) and checks document.shape[0]
# Using list of numpy arrays (word indices in each document)
data = [
    np.array([0, 1, 2, 3]),
    np.array([[4, 5, 6, 7]]),
    np.array([1, 3, 5, 8]),
    np.array([[0, 2, 9, 10]]),
]

# vocab: vocabulary (not directly used in the function body, but passed as parameter)
# Since it's not used, we can pass a simple list or dict
vocab = list(range(vocab_size))

# top_n: number of top words to consider
top_n = 5

ARGS = {
    "beta": beta,
    "data": data,
    "vocab": vocab,
    "top_n": top_n,
}
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 float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
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
nearest_neighbors Ran
ran on a synthesized input
fumiyo0607/ETM/utils.py
code served (permissive licence) · get_code("012ab4b07ace5799")
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 numpy as np

# Create a simple embeddings object that mimics what the function expects
class SimpleEmbeddings:
    def __init__(self, data):
        self.data = data

# Set seed for reproducibility
torch.manual_seed(0)

# Create small embedding vectors (5 words, 4 dimensions)
embedding_matrix = torch.randn(5, 4)
embeddings = SimpleEmbeddings(embedding_matrix)

# Create vocabulary
vocab = ["cat", "dog", "bird", "fish", "tree"]

# The function will look up "cat" (index 0) and find similar words
word = "cat"

ARGS = {
    "word": word,
    "embeddings": embeddings,
    "vocab": vocab
}
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, 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
remove_empty Ran
ran; our contract draft was wrong, not the code
adjidieng/ETM/scripts/data_20ng.py
code served (permissive licence) · get_code("b3318b8a57645f16")
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. 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 numpy as np

torch.manual_seed(0)

# Construct arguments for remove_empty function
# The function takes in_docs and filters out empty lists

in_docs = [
    [1, 2, 3],
    [],
    [4, 5],
    [],
    ["a", "b", "c"],
    []
]

ARGS = {
    "in_docs": in_docs
}
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 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
create_etm_datasets Not yet run
unverified (harvested, no recorded run)
lffloyd/embedded-topic-model/embedded_topic_model/utils/preprocessing.py
code served (permissive licence) · get_code("a692c1d9b72b7a4e")
How it ran

no invocation recorded.

get_batch Not yet run
unverified (harvested, no recorded run)
fumiyo0607/ETM/data.py
code served (permissive licence) · get_code("979dc555a8df7690")
How it ran

no invocation recorded.

get_topic_diversity Not yet run
unverified (harvested, no recorded run)
lffloyd/embedded-topic-model/embedded_topic_model/utils/metrics.py
code served (permissive licence) · get_code("8158ac38282924d6")
How it ran

no invocation recorded.

Also present in other papers' code

Of 13 samples lifted from this paper's linked repositories, 13 carry a function identity and 0 do not. Of the 13 distinct functions with an identity, 1 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 1 the same month, 0 later) and 12 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
get_document_frequency 1 other paper
1 the same month
1907.05545 (2019-07)
The Dynamic Embedded Topic Model

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

Topic modeling analyzes documents to learn meaningful patterns of words. However, existing topic models fail to learn interpretable topics when working with large and heavy-tailed vocabularies. To this end, we develop the Embedded Topic Model (ETM), a generative model of documents that marries traditional topic models with word embeddings. In particular, it models each word with a categorical distribution whose natural parameter is the inner product between a word embedding and an embedding of its assigned topic. To fit the ETM, we develop an efficient amortized variational inference algorithm. The ETM discovers interpretable topics even with large vocabularies that include rare words and stop words. It outperforms existing document models, such as latent Dirichlet allocation (LDA), in terms of both topic quality and predictive performance.

For agents

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

get_harvested_code_for_paper("1907.04907")
get_code_for_paper("1907.04907")
have("1907.04907")

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

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

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

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

Connect an agent — have() is free.