SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2311.01449 · 2023

TopicGPT: A Prompt-based Topic Modeling Framework

arXiv · PDF · Open in the Atlas

Code that ran

6 of 8 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; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 5 failures of our instrument; 2 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/2311.01449.json · badge: /api/ran/2311.01449.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
chtmp223/topicgpt canonical (classifier label)
classifier basis: census
6 ran · 2 no recorded run
FunctionStatusWhere it lives
calculate_metrics Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
chtmp223/topicgpt/topicgpt_python/utils.py
code served (permissive licence) · get_code("0d8395537f4bf2da")
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 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 pandas as pd
import numpy as np
from sklearn import metrics

# Create a small pandas DataFrame with true and predicted labels
np.random.seed(0)

# Generate sample data with 8 documents
n_samples = 8
true_labels = np.array([0, 0, 1, 1, 2, 2, 0, 1])
pred_labels = np.array([0, 0, 1, 2, 2, 1, 0, 1])

df = pd.DataFrame({
    'true_col': true_labels,
    'pred_col': pred_labels
})

ARGS = {
    'true_col': 'true_col',
    'pred_col': 'pred_col',
    'df': df
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas, sklearn — 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 float — 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
calculate_purity Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
chtmp223/topicgpt/topicgpt_python/utils.py
code served (permissive licence) · get_code("f481d4c84485e414")
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 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 pandas as pd
import numpy as np
from sklearn import metrics

# Create a small DataFrame with ground-truth and predicted labels
np.random.seed(0)

# Create sample data with 8 documents
n_samples = 8
true_labels = np.array([0, 0, 1, 1, 2, 2, 0, 1])
pred_labels = np.array([0, 0, 1, 2, 2, 1, 0, 1])

df = pd.DataFrame({
    'true_col': true_labels,
    'pred_col': pred_labels
})

ARGS = {
    'true_col': 'true_col',
    'pred_col': 'pred_col',
    'df': df
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas, sklearn — 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 float — 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
construct_document Ran
ran; our contract draft was wrong, not the code
chtmp223/topicgpt/topicgpt_python/generation_2.py
code served (permissive licence) · get_code("763ee147a3b9a342")
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

class MockAPIClient:
    """Mock API client that implements the methods used by construct_document"""
    
    def estimate_token_count(self, text):
        """Estimate token count by dividing text length by 4 (rough approximation)"""
        if isinstance(text, str):
            return len(text) // 4
        return 0
    
    def truncating(self, text, max_tokens):
        """Truncate text to approximately max_tokens"""
        # Each token is roughly 4 characters
        max_chars = max_tokens * 4
        return text[:max_chars]


# Create test data
api_client = MockAPIClient()

docs = [
    "This is the first document. It contains some sample text for testing purposes.",
    "This is the second document. It also has some content that needs to be processed.",
    "Third document here with additional information to include in the construction process.",
    "Fourth and final document for this test setup."
]

context_len = 500

ARGS = {
    "api_client": api_client,
    "docs": docs,
    "context_len": context_len
}
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
filter_topics_by_count Ran
ran; our contract draft was wrong, not the code
chtmp223/topicgpt/topicgpt_python/generation_2.py
code served (permissive licence) · get_code("fad0d8ab6a03e768")
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 pandas as pd

class Node:
    def __init__(self, name, count, children=None):
        self.name = name
        self.count = count
        self.children = children if children is not None else []

# Create a small DataFrame with 100 rows (so 1% threshold = count > 1)
df = pd.DataFrame({
    'doc_id': range(100),
    'text': ['document'] * 100
})

# Create nodes with various counts
# Threshold will be len(df) * 0.01 = 100 * 0.01 = 1.0
node_high_count_no_children = Node('topic_A', count=5, children=[])
node_low_count_no_children = Node('topic_B', count=1, children=[])
node_high_count_with_children = Node('topic_C', count=10, children=[Node('child', 2)])
node_low_count_with_children = Node('topic_D', count=0, children=[Node('child', 1)])

all_nodes = [
    node_high_count_no_children,
    node_low_count_no_children,
    node_high_count_with_children,
    node_low_count_with_children
]

ARGS = {
    'all_nodes': all_nodes,
    'df': df
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — 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_topics Ran
ran; our contract draft was wrong, not the code
chtmp223/topicgpt/topicgpt_python/refinement.py
code served (permissive licence) · get_code("f86a64a16a9ec389")
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 TopicTree. 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.

class TopicNode:
    def __init__(self, name, count, lvl, parent=None):
        self.name = name
        self.count = count
        self.lvl = lvl
        self.parent = parent
        self.children = []

class TopicTree:
    def __init__(self):
        self.root = TopicNode("root", 0, 0)

# Create a small topic tree with some low-frequency and high-frequency topics
topics_tree = TopicTree()

# Add some children to root (level 1 nodes)
child1 = TopicNode("topic_1", 5, 1, parent=topics_tree.root)
child2 = TopicNode("topic_2", 50, 1, parent=topics_tree.root)
child3 = TopicNode("topic_3", 8, 1, parent=topics_tree.root)
child4 = TopicNode("topic_4", 100, 1, parent=topics_tree.root)

topics_tree.root.children = [child1, child2, child3, child4]

# Add a level 2 node (should not be removed even if low count)
grandchild = TopicNode("subtopic_1", 2, 2, parent=child1)
child1.children = [grandchild]

ARGS = {
    "topics_root": topics_tree,
    "verbose": True,
    "threshold": 0.1
}
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 TopicTree — a TopicTree output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a TopicTree 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
topic_parser Ran
ran, honoured the contract we drafted
chtmp223/topicgpt/topicgpt_python/correction.py
code served (permissive licence) · get_code("d66fe8cc3264e216")
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 2, 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 pandas as pd
import regex as re


class TopicTree:
    """Stand-in TopicTree class that provides get_root_descendants_name method."""
    
    def __init__(self, valid_topics):
        self.valid_topics = valid_topics
    
    def get_root_descendants_name(self):
        """Return list of valid topic names."""
        return self.valid_topics


# Create valid topics
valid_topics = [
    "Machine Learning",
    "Data Science",
    "Python Programming",
    "Deep Learning"
]

# Create TopicTree object
root_topics = TopicTree(valid_topics)

# Create DataFrame with responses column containing topic assignments
# Format: "[1] Topic Name: description" (matching the regex pattern)
responses_data = [
    "[1] Machine Learning: supervised learning\n[2] Data Science: data analysis",
    "[1] Deep Learning: neural networks",
    "no topics here at all",
    "[1] Hallucinated Topic: this topic does not exist\n[2] Python Programming: coding",
    "[1] Python Programming: writing code",
]

df = pd.DataFrame({
    "responses": responses_data
})

# Build ARGS dictionary
ARGS = {
    "root_topics": root_topics,
    "df": df,
    "verbose": False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas, regex — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 2, 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
metric_calc Not yet run
unverified (harvested, no recorded run)
chtmp223/topicgpt/topicgpt_python/metrics.py
code served (permissive licence) · get_code("1b7b70ef4c91a44b")
How it ran

no invocation recorded.

parse_document_topics Not yet run
unverified (harvested, no recorded run)
chtmp223/topicgpt/topicgpt_python/generation_2.py
code served (permissive licence) · get_code("3610ddd84bb37b93")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 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.

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 is a well-established technique for exploring text corpora. Conventional topic models (e.g., LDA) represent topics as bags of words that often require "reading the tea leaves" to interpret; additionally, they offer users minimal control over the formatting and specificity of resulting topics. To tackle these issues, we introduce TopicGPT, a prompt-based framework that uses large language models (LLMs) to uncover latent topics in a text collection. TopicGPT produces topics that align better with human categorizations compared to competing methods: it achieves a harmonic mean purity of 0.74 against human-annotated Wikipedia topics compared to 0.64 for the strongest baseline. Its topics are also interpretable, dispensing with ambiguous bags of words in favor of topics with natural language labels and associated free-form descriptions. Moreover, the framework is highly adaptable, allowing users to specify constraints and modify topics without the need for model retraining. By streamlining access to high-quality and interpretable topics, TopicGPT represents a compelling, human-centered approach to topic modeling.

For agents

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

get_harvested_code_for_paper("2311.01449")
get_code_for_paper("2311.01449")
have("2311.01449")

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

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

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

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

Connect an agent — have() is free.