Semantic Signal Separation (\(S^3\))
Semantic Signal Separation tries to recover dimensions/axes along which most of the semantic variations can be explained. A topic in \(S^3\) is an axis of semantics in the corpus. This makes the model able to recover more nuanced topical content in documents, but is not optimal when you expect topics to be groupings of documents.
\(S^3\) is one of the fastest topic models out there, even rivalling vanilla NMF, when not accounting for embedding time. It also typically produces very high quality topics, and our evaluations indicate that it performs significantly better when no preprocessing is applied to texts.
How does \(S^3\) work?
Step 1: Document-embedding Decomposition
The first step is to decompose the embedding matrix using ICA, this step discovers the underlying semantics axes as latent independent components in the embeddings.
See formula
- Let the encodings of documents in the corpus be \(X\).
- Decompose \(X\) using FastICA: \(X = AS\), where \(A\) is the mixing matrix and \(S\) is the document-topic-matrix.
Step 2: Term Importance Estimation
Term importances for each topic are calculated by encoding the entire vocabulary of the corpus using the same embedding model, then recovering the strength of each latent component in the word embedding matrix. The strength of the components in the words will be interpreted as the words' importance in a given topic.
See formula
- Let the matrix of word encodings be \(V\).
- Calculate the pseudo-inverse of the mixing matrix \(C = A^{+}\), where \(C\) is the unmixing matrix.
- Project word embeddings onto the semantic axes by multiplying them with unmixing matrix: \(W = VC^T\). \(W^T\) is then the topic-term matrix (
model.components_).
There are three distinct methods to calculate term importances from word projections:
Choose a word importance method
from turftopic import SemanticSignalSeparation
model = SemanticSignalSeparation(n_components=10, feature_importance="axial")
The importance of word \(j\) for topic \(t\) is: \(\beta_{tj} = W_{jt}\)
from turftopic import SemanticSignalSeparation
model = SemanticSignalSeparation(n_components=10, feature_importance="angular")
\(\beta_{tj} = cos(\Theta) = \frac{W_{jt}}{||W_j||}\)
from turftopic import SemanticSignalSeparation
model = SemanticSignalSeparation(n_components=10, feature_importance="combined")
\(\beta_{tj} = \frac{(W_{jt})^3}{||W_j||}\)
Dynamic Topic Modeling
\(S^3\) can also be used as a dynamic topic model. Temporally changing components are found using the following steps:
- Fit a global \(S^3\) model over the whole corpus.
- Estimate unmixing matrix for each time-slice by fitting a linear regression from the embeddings in the time slice to the document-topic-matrix for the time slice estimated by the global model.
- Estimate term importances for each time slice the same way as the global model.
from datetime import datetime
from turftopic import SemanticSignalSeparation
ts: list[datetime] = [datetime(year=2018, month=2, day=12), ...]
corpus: list[str] = ["First document", ...]
model = SemanticSignalSeparation(10).fit_dynamic(corpus, timestamps=ts, bins=10)
model.plot_topics_over_time()
Info
Topics over time in \(S^3\) are treated slightly differently to most other models. This is because topics are not proportional in \(S^3\), and can tip below zero. In the timeslices where a topic is below zero, its negative definition is displayed.
Model Refitting
Unlike most other models in Turftopic, \(S^3\) can be refit using different parameters and random seeds without needing to initialize the model from scratch. This makes \(S^3\) incredibly convenient for exploring different numbers of topics, or adjusting the number of iterations.
Refitting the model takes a fraction of the time of initializing a new one and fitting it, as the vocabulary doesn't have to be learned or encoded by the model again.
from turftopic import SemanticSignalSeparation
model = SemanticSignalSeparation(5, random_state=42)
model.fit(corpus)
print(len(model.topic_names))
# 5
model.refit(corpus, n_components=10, random_state=30)
print(len(model.topic_names))
# 10
Interpretation
Negative terms
Terms, which rank lowest on a topic have meaning in \(S^3\). Whenever interpreting semantic axes, you should probably consider both ends of the axis. As such, when you print or export topics from \(S^3\), the lowest ranking terms will also be shown along with the highest ranking ones.
Here's an example on ArXiv ML papers:
from turftopic import SemanticSignalSeparation
from sklearn.feature_extraction.text import CountVectorizer
model = SemanticSignalSeparation(5, vectorizer=CountVectorizer(), random_state=42)
model.fit(corpus)
model.print_topics(top_k=5)
| Positive | Negative | |
|---|---|---|
| 0 | clustering, histograms, clusterings, histogram, classifying | reinforcement, exploration, planning, tactics, reinforce |
| 1 | textual, pagerank, litigants, marginalizing, entailment | matlab, waveforms, microcontroller, accelerometers, microcontrollers |
| 2 | sparsestmax, denoiseing, denoising, minimizers, minimizes | automation, affective, chatbots, questionnaire, attitudes |
| 3 | rebmigraph, subgraph, subgraphs, graphsage, graph | adversarial, adversarially, adversarialization, adversary, security |
| 4 | clustering, estimations, algorithm, dbscan, estimation | cnn, deepmind, deeplabv3, convnet, deepseenet |
Concept Compass
If you want to gain a deeper understanding of terms' relation to axes, you can produce a concept compass. This involves plotting terms in a corpus along two semantic axes.
In order to use the compass in Turftopic you will need to have plotly installed:
pip install plotly
You can display a compass based on a fitted model like so:
fig = model.plot_concept_compass(topic_x=1, topic_y=4)
fig.show()
Image Compass
In multimodal contexts, you can also plot images along two chosen axes by using plot_image_compass().
model = SemanticSignalSeparation(10)
model.fit_multimodal(corpus, images=images)
fig = model.plot_image_compass(topic_x=0, topic_y=1)
fig.show()
Citation
Please cite Turftopic and Kardos et al. (2025) when using \(S^3\) in Turftopic:
@article{
Kardos2025,
title = {Turftopic: Topic Modelling with Contextual Representations from Sentence Transformers},
doi = {10.21105/joss.08183},
url = {https://doi.org/10.21105/joss.08183},
year = {2025},
publisher = {The Open Journal},
volume = {10},
number = {111},
pages = {8183},
author = {Kardos, Márton and Enevoldsen, Kenneth C. and Kostkan, Jan and Kristensen-McLachlan, Ross Deans and Rocca, Roberta},
journal = {Journal of Open Source Software}
}
@inproceedings{kardos-etal-2025-s3,
title = "$S^3$ - Semantic Signal Separation",
author = "Kardos, M{\'a}rton and
Kostkan, Jan and
Enevoldsen, Kenneth and
Vermillet, Arnault-Quentin and
Nielbo, Kristoffer and
Rocca, Roberta",
editor = "Che, Wanxiang and
Nabende, Joyce and
Shutova, Ekaterina and
Pilehvar, Mohammad Taher",
booktitle = "Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
month = jul,
year = "2025",
address = "Vienna, Austria",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2025.acl-long.32/",
doi = "10.18653/v1/2025.acl-long.32",
pages = "633--666",
ISBN = "979-8-89176-251-0",
abstract = "Topic models are useful tools for discovering latent semantic structures in large textual corpora. Recent efforts have been oriented at incorporating contextual representations in topic modeling and have been shown to outperform classical topic models. These approaches are typically slow, volatile, and require heavy preprocessing for optimal results. We present Semantic Signal Separation ($S^3$), a theory-driven topic modeling approach in neural embedding spaces. $S^3$ conceptualizes topics as independent axes of semantic space and uncovers these by decomposing contextualized document embeddings using Independent Component Analysis. Our approach provides diverse and highly coherent topics, requires no preprocessing, and is demonstrated to be the fastest contextual topic model, being, on average, 4.5x faster than the runner-up BERTopic. We offer an implementation of $S^3$, and all contextual baselines, in the Turftopic Python package."
}
API Reference
turftopic.models.decomp.SemanticSignalSeparation
Bases: ContextualModel, DynamicTopicModel, MultimodalModel
Separates the embedding matrix into 'semantic signals' with component analysis methods. Topics are assumed to be dimensions of semantics.
from turftopic import SemanticSignalSeparation
corpus: list[str] = ["some text", "more text", ...]
model = SemanticSignalSeparation(10).fit(corpus)
model.print_topics()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_components |
int
|
Number of topics. |
10
|
encoder |
Union[Encoder, str, MultimodalEncoder]
|
Model to encode documents/terms, all-MiniLM-L6-v2 is the default. |
'sentence-transformers/all-MiniLM-L6-v2'
|
vectorizer |
Optional[CountVectorizer]
|
Vectorizer used for term extraction. Can be used to prune or filter the vocabulary. |
None
|
decomposition |
Optional[TransformerMixin]
|
Custom decomposition method to use.
Can be an instance of FastICA or PCA, or basically any dimensionality
reduction method. Has to have |
None
|
max_iter |
int
|
Maximum number of iterations for ICA. |
200
|
feature_importance |
Literal['axial', 'angular', 'combined']
|
Defines whether the word's position on an axis ('axial'), it's angle to the axis ('angular') or their combination ('combined') should determine the word's importance for a topic. |
'combined'
|
random_state |
Optional[int]
|
Random state to use so that results are exactly reproducible. |
None
|
trf_kwargs |
Keyword arguments to apply when loading the Encoder model. |
None
|
|
encode_kwargs |
Keyword arguments to apply encoding documents with the encoder. |
None
|
Source code in turftopic/models/decomp.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 | |
angular_components_
property
Reweights words based on their angle in ICA-space to the axis base vectors.
angular_temporal_components_
property
Reweights words based on their angle in ICA-space to the axis base vectors in a dynamic model.
concept_compass(topic_x, topic_y)
[DEPRECATED] will be removed in version 1.0.0. See plot_concept_compass().
Source code in turftopic/models/decomp.py
933 934 935 936 937 938 939 940 941 942 | |
estimate_components(feature_importance)
Reestimates components based on the chosen feature_importance method.
Source code in turftopic/models/decomp.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
merge_models(models, match_threshold=0.7, merge_method='asymmetric_mean', weighted=True, return_merge_graph=False)
classmethod
Merges multiple SemanticSignalSeparation models together. The original models will not be modified.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
models |
list[SemanticSignalSeparation]
|
SemanticSignalSeparation models to merge together. |
required |
match_threshold |
Cosine similarity threshold, above which topics are to be considered the same. |
0.7
|
|
merge_method |
str | Callable
|
Method for merging the two topic models.
- |
'asymmetric_mean'
|
weighted |
Indicates whether the merge aggregation should be weighted by the number of documents the two models have seen. |
True
|
|
return_merge_graph |
bool
|
Indicates whether the merge graph should be returned. |
False
|
Returns:
| Type | Description |
|---|---|
SemanticSignalSeparation
|
Merged model. |
Graph(OPTIONAL)
|
igraph directed Graph over merges. |
Source code in turftopic/models/decomp.py
831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 | |
merge_with(other, match_threshold=0.7, merge_method='asymmetric_mean', weighted=True)
Updates topic model by merging it with another one trained on the new data.
!!! warning: Only static properties of a model will be taken into account when merging. Attributes associated with top exemplars and temporal data will be DELETED from the model. The model will be modified in-place. We recommend that you save the original model to disk to avoid losing data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other |
SemanticSignalSeparation
|
Other SemanticSignalSeparation model to merge this one with. |
required |
match_threshold |
Cosine similarity threshold, above which topics are to be considered the same. |
0.7
|
|
merge_method |
str | Callable
|
Method for merging the two topic models.
- |
'asymmetric_mean'
|
weighted |
Indicates whether the merge aggregation should be weighted by the number of documents the two models have seen. |
True
|
Returns:
| Type | Description |
|---|---|
Self
|
|
Source code in turftopic/models/decomp.py
763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 | |
plot_concept_compass(topic_x, topic_y)
Display a compass of concepts along two semantic axes. In order for the plot to be concise and readable, terms are randomly selected on a grid of the two topics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
topic_x |
Union[int, str]
|
Index or name of the topic to display on the X axis. |
required |
topic_y |
Union[str, int]
|
Index or name of the topic to display on the Y axis. |
required |
Returns:
| Type | Description |
|---|---|
Figure
|
Plotly interactive plot of the concept compass. |
Source code in turftopic/models/decomp.py
944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 | |
refit(raw_documents, y=None, embeddings=None, n_components=None, max_iter=None, random_state=None)
Refits model with the given parameters. This is significantly faster than fitting a new model from scratch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_documents |
Corpus on which the model is based. |
required | |
y |
Ignored, exists for API compatibility. |
None
|
|
embeddings |
Ignored, embeddings are already stored, exists for compatibility. |
None
|
|
n_components |
Optional[int]
|
Number of topics. |
None
|
max_iter |
Optional[int]
|
Maximum number of iterations for ICA. |
None
|
random_state |
Optional[int]
|
Random state to use so that results are exactly reproducible. |
None
|
Returns:
| Type | Description |
|---|---|
Refitted model.
|
|
Source code in turftopic/models/decomp.py
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 | |
refit_transform(raw_documents, y=None, embeddings=None, n_components=None, max_iter=None, random_state=None)
Refits model with the given parameters. This is significantly faster than fitting a new model from scratch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_documents |
Corpus on which the model is based. |
required | |
y |
Ignored, exists for API compatibility. |
None
|
|
embeddings |
Optional[ndarray]
|
Ignored, embeddings are already stored, exists for compatibility. |
None
|
n_components |
Optional[int]
|
Number of topics. |
None
|
max_iter |
Optional[int]
|
Maximum number of iterations for ICA. |
None
|
random_state |
Optional[int]
|
Random state to use so that results are exactly reproducible. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray of shape (n_documents, n_topics)
|
Document-topic matrix. |
Source code in turftopic/models/decomp.py
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | |
refit_transform_dynamic(raw_documents, timestamps, embeddings=None, bins=10, n_components=None, max_iter=None, random_state=None)
Refits \(S^3\) to be a dynamic model.
Source code in turftopic/models/decomp.py
625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 | |
transform(raw_documents, embeddings=None)
Infers topic importances for new documents based on a fitted model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_documents |
Documents to fit the model on. |
required | |
embeddings |
Optional[ndarray]
|
Precomputed document encodings. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray of shape (n_dimensions, n_topics)
|
Document-topic matrix. |
Source code in turftopic/models/decomp.py
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 | |