// 02 FIELD TOOLS
bertopic-rs
BERTopic in Rust, checked stage by stage against the Python original. It groups documents by meaning (embed them, reduce the embeddings with UMAP, cluster with HDBSCAN) and then names each group with the words that set it apart, by class-based TF-IDF. Because the groups come from embeddings and not from shared words, two paraphrases with no words in common land in the same topic. The embedder can be swapped, including for a language model's own hidden states, which reads out in words the topics a model's representations form.
How close it is
Each stage is tested against what the Python libraries produce on the same inputs. The vocabulary and counts match scikit-learn exactly, the embeddings match sentence-transformers at cosine 1.0000, HDBSCAN's labels are identical on the same tree, and gensim's coherence scores agree within 2e-14. On 20 Newsgroups (18,331 posts), three seeds each, the Rust pipeline's topics are as coherent and as close to the newsgroup labels as Python's, within the spread between seeds, and it fits in 8.4 seconds against Python's 20.7.
Two more crates come with it: topic-coherence, gensim's coherence measures for any topic model, and hlda, hierarchical LDA for comparison. Scored against the newsgroups' own hierarchy, BERTopic's topic tree is about seven times better than chance and hLDA's two to three. A consensus module fits several seeds and keeps only the topics most of them agree on, each addressed by its content so it can be found again across runs.
Stated honestly
- UMAP draws from its own random generator, so a seed gives a different, equally good layout from umap-learn's with that seed.
- Topic probabilities, seeded and zero-shot topics, guided models, merging topics, partial fits, save and load, and the visualisations are not ported.