Skip to content

Commit 898185f

Browse files
Merge branch 'main' into contextual_encoder
2 parents b52dff8 + 5359e3c commit 898185f

12 files changed

Lines changed: 360 additions & 10 deletions

File tree

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
| [Topic Analysis](https://x-tabdeveloping.github.io/turftopic/analyzers/) | :robot: LLM-generated names and descriptions, :wave: Manual Topic Naming |
1616
| [Informative Topic Descriptions](https://x-tabdeveloping.github.io/turftopic/vectorizers/) | :key: Keyphrases, Noun-phrases, Lemmatization, Stemming |
1717

18-
1918
## Basics
2019
[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/x-tabdeveloping/turftopic/blob/main/examples/basic_example_20newsgroups.ipynb)
2120

@@ -228,6 +227,26 @@ topicwizard.visualize(corpus, model=model)
228227

229228
Alternatively you can use the [Figures API](https://x-tabdeveloping.github.io/topicwizard/figures.html) in topicwizard for individual HTML figures.
230229

230+
## Citation
231+
232+
Please cite us when using Turftopic:
233+
234+
```bibtex
235+
@article{
236+
Kardos2025,
237+
title = {Turftopic: Topic Modelling with Contextual Representations from Sentence Transformers},
238+
doi = {10.21105/joss.08183},
239+
url = {https://doi.org/10.21105/joss.08183},
240+
year = {2025},
241+
publisher = {The Open Journal},
242+
volume = {10},
243+
number = {111},
244+
pages = {8183},
245+
author = {Kardos, Márton and Enevoldsen, Kenneth C. and Kostkan, Jan and Kristensen-McLachlan, Ross Deans and Rocca, Roberta},
246+
journal = {Journal of Open Source Software}
247+
}
248+
```
249+
231250
## References
232251
- Kardos, M., Kostkan, J., Vermillet, A., Nielbo, K., Enevoldsen, K., & Rocca, R. (2024, June 13). $S^3$ - Semantic Signal separation. arXiv.org. https://arxiv.org/abs/2406.09556
233252
- Wu, X., Nguyen, T., Zhang, D. C., Wang, W. Y., & Luu, A. T. (2024). FASTopic: A Fast, Adaptive, Stable, and Transferable Topic Modeling Paradigm. ArXiv Preprint ArXiv:2405.17978.

docs/FASTopic.md

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,59 @@
11
# FASTopic
22

3-
FASTopic is a neural topic model based on Dual Semantic-relation Reconstruction.
3+
FASTopic (Wu et al., 2024) is a neural topic model based on Dual Semantic-relation Reconstruction.
44

5-
> Turftopic contains an implementation repurposed for our API, but the implementation is mostly from the [original FASTopic package](https://github.com/BobXWu/FASTopic).
5+
<figure>
6+
<img src="../images/fastopic.png", title="", style="width:1050px;padding:0px;border:none;"></img>
7+
<figcaption> Figure 1: Schematic Overview of the FASTopic Model.<br> <i>Figure from Wu et al. (2024)</i> </figcaption>
8+
</figure>
69

7-
:warning: This part of the documentation is still under construction :warning:
10+
FASTopic, instead of reconstructing Bag-of-words, like classical topic models or VAE-based models do, reconstructs the relations between topics words and documents.
811

9-
## References
12+
Wu et al. (2025) express semantic relations for this model using the Embedding Transport Plan (ETP) method.
13+
14+
The model uses a combined loss function that helps the model learn semantic relations between topic and word embeddings, and learn to reconstruct these relations.
15+
16+
## Usage
17+
18+
```python
19+
from turftopic import FASTopic
20+
21+
documents = [...]
22+
23+
model = FASTopic(10)
24+
doc_topic_matrix = model.fit_transform(documents)
25+
model.print_topics()
26+
```
27+
28+
## Citation
29+
30+
Please cite the authors of the paper, and Turftopic when using the FASTopic model:
31+
32+
```bibtex
33+
@inproceedings{
34+
wu2024fastopic,
35+
title={{FAST}opic: Pretrained Transformer is a Fast, Adaptive, Stable, and Transferable Topic Model},
36+
author={Xiaobao Wu and Thong Thanh Nguyen and Delvin Ce Zhang and William Yang Wang and Anh Tuan Luu},
37+
booktitle={The Thirty-eighth Annual Conference on Neural Information Processing Systems},
38+
year={2024},
39+
url={https://openreview.net/forum?id=7t6aq0Fa9D}
40+
}
41+
42+
@article{
43+
Kardos2025,
44+
title = {Turftopic: Topic Modelling with Contextual Representations from Sentence Transformers},
45+
doi = {10.21105/joss.08183},
46+
url = {https://doi.org/10.21105/joss.08183},
47+
year = {2025},
48+
publisher = {The Open Journal},
49+
volume = {10},
50+
number = {111},
51+
pages = {8183},
52+
author = {Kardos, Márton and Enevoldsen, Kenneth C. and Kostkan, Jan and Kristensen-McLachlan, Ross Deans and Rocca, Roberta},
53+
journal = {Journal of Open Source Software}
54+
}
55+
```
1056

11-
Wu, X., Nguyen, T., Zhang, D. C., Wang, W. Y., & Luu, A. T. (2024). FASTopic: A Fast, Adaptive, Stable, and Transferable Topic Modeling Paradigm. ArXiv Preprint ArXiv:2405.17978.
1257

1358
## API Reference
1459

docs/GMM.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,26 @@ from sklearn.decomposition import IncrementalPCA
9494
model = GMM(20, dimensionality_reduction=IncrementalPCA(20))
9595
```
9696

97+
## Citation
98+
99+
Please cite Turftopic when using GMM in publications:
100+
101+
```bibtex
102+
@article{
103+
Kardos2025,
104+
title = {Turftopic: Topic Modelling with Contextual Representations from Sentence Transformers},
105+
doi = {10.21105/joss.08183},
106+
url = {https://doi.org/10.21105/joss.08183},
107+
year = {2025},
108+
publisher = {The Open Journal},
109+
volume = {10},
110+
number = {111},
111+
pages = {8183},
112+
author = {Kardos, Márton and Enevoldsen, Kenneth C. and Kostkan, Jan and Kristensen-McLachlan, Ross Deans and Rocca, Roberta},
113+
journal = {Journal of Open Source Software}
114+
}
115+
```
116+
97117
## API Reference
98118

99119
::: turftopic.models.gmm.GMM

docs/KeyNMF.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# KeyNMF
22

3-
KeyNMF is a topic model that relies on contextually sensitive embeddings for keyword retrieval and term importance estimation,
3+
KeyNMF (Kristensen-McLachlan et al., 2024) is a topic model that relies on contextually sensitive embeddings for keyword retrieval and term importance estimation,
44
while taking inspiration from classical matrix-decomposition approaches for extracting topics.
55

66
<figure>
@@ -513,6 +513,44 @@ model = KeyNMF(10, encoder=encoder)
513513

514514
Setting the default prompt to `query` is especially important, when you are precomputing embeddings, as `query` should always be your default prompt to embed documents with.
515515

516+
## Citation
517+
518+
Please cite Turftopic and Kristensen-McLachlan et al. (2024) when using KeyNMF:
519+
520+
```bibtex
521+
@article{
522+
Kardos2025,
523+
title = {Turftopic: Topic Modelling with Contextual Representations from Sentence Transformers},
524+
doi = {10.21105/joss.08183},
525+
url = {https://doi.org/10.21105/joss.08183},
526+
year = {2025},
527+
publisher = {The Open Journal},
528+
volume = {10},
529+
number = {111},
530+
pages = {8183},
531+
author = {Kardos, Márton and Enevoldsen, Kenneth C. and Kostkan, Jan and Kristensen-McLachlan, Ross Deans and Rocca, Roberta},
532+
journal = {Journal of Open Source Software}
533+
}
534+
535+
@inproceedings{keynmf,
536+
title = "Context is Key(NMF):: Modelling Topical Information Dynamics in Chinese Diaspora Media",
537+
abstract = "Does the People{\textquoteright}s Republic of China (PRC) interfere with European elections through ethnic Chinese diaspora media? This question forms the basis of an ongoing research project exploring how PRC narratives about European elections are represented in Chinese diaspora media, and thus the objectives of PRC news media manipulation. In order to study diaspora media ef{\"I}ciently and at scale, it is necessary to use techniques derived from quantitative text analysis, such as topic modelling. In this paper, we present a pipeline for studying information dynamics in Chinese media. Firstly, we present KeyNMF, a new approach to static and dynamic topic modelling using transformer-based contextual embedding models. We provide benchmark evaluations to demonstrate that our approach is competitive on a number of Chinese datasets and metrics. Secondly, we integrate KeyNMF with existing methods for describing information dynamics in complex systems. We apply this pipeline to data from five news sites, focusing on the period of time leading up to the 2024 European parliamentary elections. Our methods and results demonstrate the effectiveness of KeyNMF for studying information dynamics in Chinese media and lay groundwork for further work addressing the broader research questions.",
538+
keywords = "Chinese, contextual topic models, information dynamics, keywords, novelty",
539+
author = "Kristensen-McLachlan, \{Ross Deans\} and Hicke, \{Rebecca Marie Matouschek\} and M{\'a}rton Kardos and Mette Thun{\o}",
540+
year = "2024",
541+
month = dec,
542+
language = "English",
543+
volume = "3834",
544+
series = "CEUR Workshop Proceedings",
545+
publisher = "CEUR-WS",
546+
pages = "829--847",
547+
editor = "Haverals, \{Wouter \} and Koolen, \{Marijn \} and Thompson, \{Laure \}",
548+
booktitle = "Proceedings of the Computational Humanities Research Conference 2024",
549+
address = "Germany",
550+
}
551+
```
552+
553+
516554
## API Reference
517555

518556
::: turftopic.models.keynmf.KeyNMF

docs/SensTopic.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,26 @@ model.print_topics()
162162
| 4 | tennis, competing, federer, wimbledon, iaaf, olympic, tournament, athlete, rugby, olympics |
163163
| 5 | gdp, stock, economy, earnings, investments, investment, invest, exports, finance, economies |
164164

165+
## Citation
166+
167+
Please cite Turftopic when using the SensTopic model:
168+
169+
```bibtex
170+
@article{
171+
Kardos2025,
172+
title = {Turftopic: Topic Modelling with Contextual Representations from Sentence Transformers},
173+
doi = {10.21105/joss.08183},
174+
url = {https://doi.org/10.21105/joss.08183},
175+
year = {2025},
176+
publisher = {The Open Journal},
177+
volume = {10},
178+
number = {111},
179+
pages = {8183},
180+
author = {Kardos, Márton and Enevoldsen, Kenneth C. and Kostkan, Jan and Kristensen-McLachlan, Ross Deans and Rocca, Roberta},
181+
journal = {Journal of Open Source Software}
182+
}
183+
```
184+
165185

166186
## API Reference
167187

docs/Topeax.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Topeax
22

3-
Topeax is a probabilistic topic model based on the Peax clustering model, which finds topics based on peaks in point density in the embedding space. The model can recover the number of topics automatically.
3+
Topeax (Kardos, 2026) is a probabilistic topic model based on the Peax clustering model, which finds topics based on peaks in point density in the embedding space. The model can recover the number of topics automatically.
44

55
In the following example I run a Topeax model on the BBC News corpus, and plot the steps of the algorithm to inspect how our documents have been clustered and why:
66

@@ -123,6 +123,36 @@ topeax.plot_components_datamapplot()
123123
<figcaption> Figure 5: Datapoints colored by mixture components on a datamapplot. </figcaption>
124124
</figure>
125125

126+
## Citation
127+
128+
Please cite Turftopic and Kardos (2026) when using the Topeax model:
129+
130+
```bibtex
131+
@article{
132+
Kardos2025,
133+
title = {Turftopic: Topic Modelling with Contextual Representations from Sentence Transformers},
134+
doi = {10.21105/joss.08183},
135+
url = {https://doi.org/10.21105/joss.08183},
136+
year = {2025},
137+
publisher = {The Open Journal},
138+
volume = {10},
139+
number = {111},
140+
pages = {8183},
141+
author = {Kardos, Márton and Enevoldsen, Kenneth C. and Kostkan, Jan and Kristensen-McLachlan, Ross Deans and Rocca, Roberta},
142+
journal = {Journal of Open Source Software}
143+
}
144+
145+
@misc{kardos2026topeaximprovedclustering,
146+
title={Topeax -- An Improved Clustering Topic Model with Density Peak Detection and Lexical-Semantic Term Importance},
147+
author={Márton Kardos},
148+
year={2026},
149+
eprint={2601.21465},
150+
archivePrefix={arXiv},
151+
primaryClass={cs.AI},
152+
url={https://arxiv.org/abs/2601.21465},
153+
}
154+
```
155+
126156
## API Reference
127157

128158
::: turftopic.models.topeax.Topeax

docs/clustering.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,50 @@ _See Figure 1_
403403
!!! info
404404
If you are not running Turftopic from a Jupyter notebook, make sure to call `fig.show()`. This will open up a new browser tab with the interactive figure.
405405

406+
## Citation
407+
408+
Please cite Turftopic when using clustering models:
409+
410+
```bibtex
411+
412+
@article{
413+
Kardos2025,
414+
title = {Turftopic: Topic Modelling with Contextual Representations from Sentence Transformers},
415+
doi = {10.21105/joss.08183},
416+
url = {https://doi.org/10.21105/joss.08183},
417+
year = {2025},
418+
publisher = {The Open Journal},
419+
volume = {10},
420+
number = {111},
421+
pages = {8183},
422+
author = {Kardos, Márton and Enevoldsen, Kenneth C. and Kostkan, Jan and Kristensen-McLachlan, Ross Deans and Rocca, Roberta},
423+
journal = {Journal of Open Source Software}
424+
}
425+
```
406426

427+
In addition, cite Grootendorst (2022) or Angelov (2020) when using BERTopic or Top2Vec respectively:
428+
429+
```bibtex
430+
@misc{grootendorst2022bertopicneuraltopicmodeling,
431+
title={BERTopic: Neural topic modeling with a class-based TF-IDF procedure},
432+
author={Maarten Grootendorst},
433+
year={2022},
434+
eprint={2203.05794},
435+
archivePrefix={arXiv},
436+
primaryClass={cs.CL},
437+
url={https://arxiv.org/abs/2203.05794},
438+
}
439+
440+
@misc{angelov2020top2vecdistributedrepresentationstopics,
441+
title={Top2Vec: Distributed Representations of Topics},
442+
author={Dimo Angelov},
443+
year={2020},
444+
eprint={2008.09470},
445+
archivePrefix={arXiv},
446+
primaryClass={cs.CL},
447+
url={https://arxiv.org/abs/2008.09470},
448+
}
449+
```
407450

408451
## API Reference
409452

docs/ctm.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Variational Autoencoding Topic Models
22

3-
Topic models based on Variational Autoencoding are generative models based on ProdLDA (citation) enhanced with contextual representations.
3+
Topic models based on Variational Autoencoding are generative models based on ProdLDA (Bianchi et al, 2021) enhanced with contextual representations.
44

55
<figure>
66
<img src="../images/CTM_plate.png" width="60%" style="margin-left: auto;margin-right: auto;">
@@ -56,6 +56,46 @@ This has a number of implications, most notably:
5656

5757
Turftopic, similarly to Clustering models might not contain some model specific utilites, that CTM boasts.
5858

59+
## Citation
60+
61+
Please cite Turftopic and Bianchi et al. (2021) when using Autoencoding models in Turftopic
62+
```bibtex
63+
64+
@article{
65+
Kardos2025,
66+
title = {Turftopic: Topic Modelling with Contextual Representations from Sentence Transformers},
67+
doi = {10.21105/joss.08183},
68+
url = {https://doi.org/10.21105/joss.08183},
69+
year = {2025},
70+
publisher = {The Open Journal},
71+
volume = {10},
72+
number = {111},
73+
pages = {8183},
74+
author = {Kardos, Márton and Enevoldsen, Kenneth C. and Kostkan, Jan and Kristensen-McLachlan, Ross Deans and Rocca, Roberta},
75+
journal = {Journal of Open Source Software}
76+
}
77+
78+
@inproceedings{bianchi-etal-2021-pre,
79+
title = "Pre-training is a Hot Topic: Contextualized Document Embeddings Improve Topic Coherence",
80+
author = "Bianchi, Federico and
81+
Terragni, Silvia and
82+
Hovy, Dirk",
83+
editor = "Zong, Chengqing and
84+
Xia, Fei and
85+
Li, Wenjie and
86+
Navigli, Roberto",
87+
booktitle = "Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 2: Short Papers)",
88+
month = aug,
89+
year = "2021",
90+
address = "Online",
91+
publisher = "Association for Computational Linguistics",
92+
url = "https://aclanthology.org/2021.acl-short.96/",
93+
doi = "10.18653/v1/2021.acl-short.96",
94+
pages = "759--766",
95+
abstract = "Topic models extract groups of words from documents, whose interpretation as a topic hopefully allows for a better understanding of the data. However, the resulting word groups are often not coherent, making them harder to interpret. Recently, neural topic models have shown improvements in overall coherence. Concurrently, contextual embeddings have advanced the state of the art of neural models in general. In this paper, we combine contextualized representations with neural topic models. We find that our approach produces more meaningful and coherent topics than traditional bag-of-words topic models and recent neural models. Our results indicate that future improvements in language models will translate into better topic models."
96+
}
97+
```
98+
5999
## API Reference
60100

61101
::: turftopic.models.ctm.AutoEncodingTopicModel

docs/cvp.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,40 @@ fig.show()
110110
<figcaption> Figure 2: Concepts evolving over tokens in the first document. </figcaption>
111111
</figure>
112112

113+
114+
## Citation
115+
116+
Please cite Lyngbæk et al. (2025) and Turftopic when using Concept Vector Projection in publications:
117+
118+
```bibtex
119+
@article{
120+
Kardos2025,
121+
title = {Turftopic: Topic Modelling with Contextual Representations from Sentence Transformers},
122+
doi = {10.21105/joss.08183},
123+
url = {https://doi.org/10.21105/joss.08183},
124+
year = {2025},
125+
publisher = {The Open Journal},
126+
volume = {10},
127+
number = {111},
128+
pages = {8183},
129+
author = {Kardos, Márton and Enevoldsen, Kenneth C. and Kostkan, Jan and Kristensen-McLachlan, Ross Deans and Rocca, Roberta},
130+
journal = {Journal of Open Source Software}
131+
}
132+
133+
@incollection{Lyngbaek2025,
134+
title = {Continuous Sentiment Scores for Literary and Multilingual
135+
Contexts},
136+
author = {Laurits Lyngbaek and Pascale Feldkamp and Yuri Bizzoni and Kristoffer L. Nielbo and Kenneth Enevoldsen},
137+
year = {2025},
138+
booktitle = {Computational Humanities Research 2025},
139+
publisher = {Anthology of Computers and the Humanities},
140+
pages = {480--497},
141+
editor = {Taylor Arnold and Margherita Fantoli and Ruben Ros},
142+
doi = {10.63744/nVu1Zq5gRkuD}
143+
}
144+
```
145+
146+
113147
## API Reference
114148

115149

docs/images/fastopic.png

116 KB
Loading

0 commit comments

Comments
 (0)