SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2307.01878 · ICLR · 2023

KDSTM: Neural Semi-supervised Topic Modeling with Knowledge Distillation

Weijie Xu, Francis Iannacci, Xiaoyu Jiang, Jay Desai, Bin Han, Fuqin Yan

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 (1 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 1 failure of our instrument; 2 no recorded run), measured 2026-11-23; 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/2307.01878.json · badge: /api/ran/2307.01878.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
yumeng5/WeSTClass canonical (classifier label)
classifier basis: census
5 ran · 1 no recorded run
JoeZJH/Labeled-LDA-Python community
Papers with Code archive
1 ran · 1 no recorded run
FunctionStatusWhere it lives
NpEncoder Ran
ran on a synthesized input · constructed an object; no result was computed
JoeZJH/Labeled-LDA-Python/model/labeled_lda.py
code served (permissive licence) · get_code("89637f53f16ac549")
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, NpEncoder: 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 numpy as np
import json

class NpEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, np.integer):
            return int(obj)
        elif isinstance(obj, np.floating):
            return float(obj)
        elif isinstance(obj, np.ndarray):
            return obj.tolist()
        else:
            return super(NpEncoder, self).default(obj)

# The NpEncoder class inherits from json.JSONEncoder
# The __init__ method of JSONEncoder accepts optional parameters like:
# - skipkeys, ensure_ascii, check_circular, allow_nan, sort_keys, indent, separators, default
# Since NpEncoder doesn't override __init__, we can pass standard JSONEncoder parameters

# Test data to encode
test_data = {
    "int_array": np.array([1, 2, 3]),
    "float_array": np.array([1.5, 2.5, 3.5]),
    "int_scalar": np.int64(42),
    "float_scalar": np.float32(3.14),
    "nested": {
        "matrix": np.array([[1, 2], [3, 4]])
    }
}

ARGS = {
    "skipkeys": False,
    "ensure_ascii": True,
    "check_circular": True,
    "allow_nan": True,
    "sort_keys": False,
    "indent": None,
    "separators": None,
    "default": None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type NpEncoder — 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 NpEncoder 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
clean_str Ran
ran on a synthesized input
yumeng5/WeSTClass/load_data.py
code served (permissive licence) · get_code("aff9156b5262f81c")
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 str. 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 re

def clean_str(string):
    string = re.sub('[^A-Za-z0-9(),.!?_\\"\\\'\\`]', ' ', string)
    string = re.sub("\\'s", " 's", string)
    string = re.sub('\\"', ' " ', string)
    string = re.sub("\\'ve", " 've", string)
    string = re.sub("n\\'t", " n't", string)
    string = re.sub("\\'m", " 'm", string)
    string = re.sub("\\'re", " 're", string)
    string = re.sub("\\'d", " 'd", string)
    string = re.sub("\\'ll", " 'll", string)
    string = re.sub(',', ' , ', string)
    string = re.sub('\\.', ' . ', string)
    string = re.sub('!', ' ! ', string)
    string = re.sub('\\$', ' $ ', string)
    string = re.sub('\\(', ' \\( ', string)
    string = re.sub('\\)', ' \\) ', string)
    string = re.sub('\\?', ' \\? ', string)
    string = re.sub('\\s{2,}', ' ', string)
    return string.strip().lower()

ARGS = {
    "string": "Hello, world! This is a test. I'm happy you're here (aren't you?)."
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
f1 Ran
ran on a synthesized input
yumeng5/WeSTClass/model.py
code served (permissive licence) · get_code("02b9090cc2f7dd5e")
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 numpy as np

# Construct arguments for the f1 function
# The function takes y_true and y_pred as numpy arrays
# y_true: ground truth labels
# y_pred: predicted labels

# Create small numpy arrays with distinct sizes for clarity
y_true = np.array([0, 1, 1, 0, 2, 1, 0, 2], dtype=np.int64)
y_pred = np.array([0, 1, 0, 0, 2, 1, 1, 2], dtype=np.int64)

ARGS = {
    "y_true": y_true,
    "y_pred": y_pred
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, 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
preprocess_doc Ran
ran; our contract draft was wrong, not the code
yumeng5/WeSTClass/load_data.py
code served (permissive licence) · get_code("390f3d16f6c22e3d")
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 re

def clean_str(string):
    string = re.sub('[^A-Za-z0-9(),.!?_\\"\\\'\\`]', ' ', string)
    string = re.sub("\\'s", " 's", string)
    string = re.sub('\\"', ' " ', string)
    string = re.sub("\\'ve", " 've", string)
    string = re.sub("n\\'t", " n't", string)
    string = re.sub("\\'m", " 'm", string)
    string = re.sub("\\'re", " 're", string)
    string = re.sub("\\'d", " 'd", string)
    string = re.sub("\\'ll", " 'll", string)
    string = re.sub(',', ' , ', string)
    string = re.sub('\\.', ' . ', string)
    string = re.sub('!', ' ! ', string)
    string = re.sub('\\$', ' $ ', string)
    string = re.sub('\\(', ' \\( ', string)
    string = re.sub('\\)', ' \\) ', string)
    string = re.sub('\\?', ' \\? ', string)
    string = re.sub('\\s{2,}', ' ', string)
    return string.strip().lower()

def preprocess_doc(data):
    data = [s.strip() for s in data]
    data = [clean_str(s) for s in data]
    return data

ARGS = {
    "data": [
        "  Hello, World! This is a test.  ",
        "  What's your name? It's great!  ",
        "  I'll go to the store (soon).  "
    ]
}
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 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
read_file Ran
ran on a synthesized input
yumeng5/WeSTClass/load_data.py
code served (permissive licence) · get_code("d38d5642834c1922")
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 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 csv
import tempfile
import os
import numpy as np

# Create a temporary directory with test CSV files
temp_dir = tempfile.mkdtemp()

# Create agnews dataset
agnews_dir = os.path.join(temp_dir, 'agnews')
os.makedirs(agnews_dir, exist_ok=True)
with open(os.path.join(agnews_dir, 'dataset.csv'), 'w', newline='', encoding='utf-8') as f:
    writer = csv.writer(f)
    writer.writerow(['1', 'World News', 'Breaking story about global events'])
    writer.writerow(['2', 'Sports Update', 'Latest sports scores and highlights'])
    writer.writerow(['3', 'Business Report', 'Market trends and economic analysis'])

# Create yelp dataset
yelp_dir = os.path.join(temp_dir, 'yelp')
os.makedirs(yelp_dir, exist_ok=True)
with open(os.path.join(yelp_dir, 'dataset.csv'), 'w', newline='', encoding='utf-8') as f:
    writer = csv.writer(f)
    writer.writerow(['1', 'Great restaurant experience'])
    writer.writerow(['2', 'Amazing food and service'])
    writer.writerow(['3', 'Would definitely come back'])

ARGS = {
    'data_dir': os.path.join(temp_dir, 'agnews'),
    'with_evaluation': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — 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 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
seed_expansion Ran
ran on a synthesized input
yumeng5/WeSTClass/gen.py
code served (permissive licence) · get_code("a93dc96d10365f5e")
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 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 numpy as np
import os
import tempfile

# Create a temporary directory for write_path
temp_dir = tempfile.mkdtemp() + '/'

# Parameters:
# - word_sup_array: list of lists of word indices
# - prob_sup_array: list of lists of probabilities
# - sz: target size for expansion
# - write_path: path to write results
# - vocabulary_inv: list mapping indices to words
# - embedding_mat: numpy array of embeddings

# Small vocabulary
vocabulary_inv = ['word0', 'word1', 'word2', 'word3', 'word4']

# Embedding matrix: vocab_sz x embedding_dim
# Using 5x4 (5 words, 4-dim embeddings)
embedding_mat = np.random.randn(5, 4).astype(np.float32)

# word_sup_array: 2 classes with word indices
word_sup_array = [
    np.array([0, 1]),      # class 0: words 0 and 1
    np.array([2, 3, 4])    # class 1: words 2, 3, 4
]

# prob_sup_array: probabilities for each word in each class
prob_sup_array = [
    np.array([0.6, 0.4]),           # class 0 probabilities
    np.array([0.5, 0.3, 0.2])       # class 1 probabilities
]

# Target expansion size
sz = 3

# Write path
write_path = temp_dir

ARGS = {
    'word_sup_array': word_sup_array,
    'prob_sup_array': prob_sup_array,
    'sz': sz,
    'write_path': write_path,
    'vocabulary_inv': vocabulary_inv,
    'embedding_mat': embedding_mat
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family int — 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
LldaModel Not yet run
unverified (harvested, no recorded run)
JoeZJH/Labeled-LDA-Python/model/labeled_lda.py
code served (permissive licence) · get_code("f7ee076ad2cb57e4")
How it ran

no invocation recorded.

dot_product Not yet run
unverified (harvested, no recorded run)
yumeng5/WeSTClass/model.py
code served (permissive licence) · get_code("748cc128f5cb04c4")
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, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 0 later) and 6 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
dot_product 1 other paper
1 dated earlier
2010.01653 (2020-10)
An Empirical Study on Large-Scale Multi-Label Text Classification Including Few and Zero-Shot Labels
preprocess_doc 1 other paper
1 dated earlier
1812.11270 (2018-12)
Weakly-Supervised Hierarchical Text Classification

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-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

In text classification tasks, fine tuning pretrained language models like BERT and GPT-3 yields competitive accuracy; however, both methods require pretraining on large text datasets. In contrast, general topic modeling methods possess the advantage of analyzing documents to extract meaningful patterns of words without the need of pretraining. To leverage topic modeling's unsupervised insights extraction on text classification tasks, we develop the Knowledge Distillation Semisupervised Topic Modeling (KDSTM). KDSTM requires no pretrained embeddings, few labeled documents and is efficient to train, making it ideal under resource constrained settings. Across a variety of datasets, our method outperforms existing supervised topic modeling methods in classification accuracy, robustness and efficiency and achieves similar performance compare to state of the art weakly supervised text classification methods.

For agents

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

get_harvested_code_for_paper("2307.01878")
get_code_for_paper("2307.01878")
have("2307.01878")

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

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

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

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

Connect an agent — have() is free.