By: Martin Feldkircher (Vienna College of Worldwide Research), Márton Kardos (Aarhus College, Denmark), and Petr Koráb (Textual content Mining Tales)
1.
Subject modelling has not too long ago progressed in two instructions. The improved statistical strategies stream of Python packages focuses on extra sturdy, environment friendly, and preprocessing-free fashions, producing fewer junk subjects (e.g., FASTopic). The opposite depends on the facility of generative language fashions to extract intuitively comprehensible subjects and their descriptions (e.g., TopicGPT [6], LlooM [5]).
Because of analysis on statistical strategies for modelling textual content representations from transformers, junk subjects are the exception quite than the norm in newer fashions. In the meantime, novel, LLM-based approaches are difficult our long-standing views about what a subject mannequin is and what it will possibly do. Human-readable subject names and descriptions at the moment are turning into increasingly an anticipated results of a well-designed subject modelling pipeline.
As thrilling as these developments are, subject modelling is much from being a solved downside. Neural subject fashions will be quite unstable and typically exhausting for customers to belief due to their black-box nature. LLM-powered strategies produce spectacular outcomes, however can at occasions increase questions on belief, because of hallucinations and sensitivity to semantically irrelevant modifications in enter. That is particularly an issue for the banking sector, the place (un)certainty is important. Operating massive language fashions can be an enormous infrastructural and computational burden, and would possibly find yourself costing massive sums of cash even for smaller datasets.
Our earlier tutorial offers an in depth introduction to how LLMs improve conventional subject modeling by mechanically labeling subject names. On this article, we mix present subject modeling strategies with focused LLM help. In our view, a mixture of current advances in language modeling and classical machine studying can present customers with the very best of each worlds: a pipeline that mixes the capabilities of enormous language fashions with the computational effectivity, trustworthiness, and stability of probabilistic ML.
This text explains three recent topic-modelling strategies that must be a part of the NLP toolkit in 2026. We’ll work out:
Tips on how to use textual content prompts to specify what subject fashions ought to give attention to (i.e., seeded subject fashions).
How LLM-generated summaries could make subject fashions extra correct.
How generative fashions can be utilized to label subjects and supply their descriptions.
How these strategies can be utilized to achieve insights from central banking communication.
We illustrate these on the central financial institution communication speeches corpus from the European Central Financial institution. The sort of textual content is lengthy, fastidiously structured, and extremely repetitive — precisely the sort of knowledge the place customary subject fashions wrestle and the place interpretability is important. By combining seeded subject modelling with LLM-assisted doc summarization and evaluation, we present the best way to extract centered, secure, and economically significant subjects with out compromising transparency or scalability.
2. Instance Knowledge
We use the press convention communications of the European Central Financial institution (ECB) as instance textual content knowledge. Since 2002, the ECB’s Governing Council has met on the primary Thursday of every month, and its communication of the assembly’s end result follows the two-step construction ([2]).
The way it works: First, at 13:45 CET, the ECB releases a quick financial coverage resolution (MPD) assertion, which accommodates solely restricted textual data. Second, at 14:30 CET, the ECB President delivers an introductory assertion throughout a press convention. This fastidiously ready doc explains the rationale behind coverage choices, outlines the ECB’s evaluation of financial situations, and offers steering on future coverage concerns. The introductory assertion usually lasts about quarter-hour and is adopted by a 45-minute Q&A session.
For this text, we use the introductory statements, scraped straight from the ECB web site (launched with a versatile knowledge licence). The dataset accommodates 279 statements, and here’s what it seems to be like:
Picture 1: ECB communication dataset. Supply: Picture by authors.
3. Seeded Subject Modelling
Historically, subject fashions give attention to figuring out probably the most informative subjects in a dataset. A naive strategy practitioners take is to suit a bigger mannequin, then, normally manually, filter out subjects irrelevant to their knowledge query.
What in case you may situation a subject mannequin to solely extract related subjects to your knowledge query? That is exactly what seeded subject modelling is used for.
In some strategies, this implies deciding on a set of key phrases that replicate your query. However within the framework we discover on this article, you may specify your curiosity in free-text utilizing a seed phrase that tells the mannequin what to give attention to.
3.1 KeyNMF Mannequin
We’ll use the cutting-edge contextual KeyNMF subject mannequin ([3]). It’s, in lots of points, similar to older subject fashions, because it formulates subject discovery by way of matrix factorization. In different phrases, when utilizing this mannequin, you assume that subjects are latent components, that your paperwork include to a lesser or higher extent, which decide and clarify the content material of these paperwork.
KeyNMF is contextual as a result of, in contrast to older fashions, it makes use of context-sensitive transformer representations of textual content. To know how seeded modelling works, we have to acquire a primary understanding of the mannequin. The modelling course of occurs within the following steps:
We encode our paperwork into dense vectors utilizing a sentence-transformer.
We encode the vocabulary of those paperwork into the identical embedding area.
For every doc, we extract the highest N key phrases by taking the phrases which have the very best cosine similarity to the doc embedding.
Phrase significance for a given doc is then the cosine similarity, pruned at zero. These scores are organized right into a key phrase matrix, the place every row is a doc, and columns correspond to phrases.
The key phrase matrix is decomposed right into a topic-term matrix and a document-topic matrix utilizing Nonnegative Matrix Factorization.
The final KeyNMF, whereas completely ample for locating subjects in a corpus, shouldn’t be probably the most appropriate selection if we have to use the mannequin for a selected query. To make this occur, we first need to specify a seed phrase, a phrase that minimally signifies what we’re involved in. For instance, when analysing the ECB communication dataset, this could possibly be “Growth of the Eurozone”.
As sentence-transformers can encode this seed phrase, we will use it to retrieve paperwork which might be related to our query:
We encode the seed phrase into the identical embedding area as our paperwork and vocabulary.
To make our mannequin extra attentive to paperwork that include related data, we compute a doc relevance rating by computing cosine similarity to the seed embedding. We prune, once more, at zero.
To magnify the seed’s significance, one can apply a seed exponent. This entails elevating the doc relevance scores to the facility of this exponent.
We multiply the key phrase matrix’s entries by the doc relevance.
We then, as earlier than, use NMF to decompose this, now conditioned, key phrase matrix.
The benefits of this strategy are that it’s:
1) extremely versatile, and
2) can save a whole lot of handbook work.
Watch out: some embedding fashions will be delicate to phrasing and would possibly retrieve completely different document-importance scores for a similar doc with a barely completely different seed phrase. To cope with this, we suggest that you simply use one of many paraphrase fashions from sentence-transformers, as a result of they’ve intentionally been educated to be phrasing invariant, and produce high-quality subjects with KeyNMF.
3.3 Tips on how to use Seeded KeyNMF
KeyNMFand its seeded model can be found on PyPI within the Turftopic package deal, in a scikit-learn-compatible kind. To specify what you have an interest in, merely initialize the mannequin with a seed phrase:
from sentence-transformers import SentenceTransformer
from turftopic import KeyNMF
# Encode paperwork utilizing a sentence-transformer
encoder = SentenceTransformer("paraphrase-mpnet-base-v2")
embeddings = encoder.encode(paperwork, show_progress_bar=True)
# Initialize KeyNMF with 4 subjects and a seed phrase
mannequin = KeyNMF(
n_components=4,
encoder=encoder,
seed_phrase="Growth of the Eurozone",
seed_exponent=3.0,
)
# Match mannequin
mannequin.match(corpus)
# Print modelled subjects
mannequin.print_topics()
We will see that the mannequin returns subject IDs with typical key phrases which might be clearly associated to the Euro and the Eurozone:
Picture 3: Seed KeyNMF mannequin output.Supply: picture by authors.
4. LLM-assisted Subject Modeling
Discovering interpretable subjects from a corpus is a tough process, and it typically requires greater than only a statistical mannequin that finds patterns within the uncooked knowledge. LLMs serve subject modelling in two essential areas:
Studying a doc and figuring out the suitable points within the textual content primarily based on a selected knowledge query.
Decoding the subject mannequin’s output within the related context.
Within the following textual content, we are going to now discover 1) how LLMs enhance processing paperwork for a subject mannequin and a couple of) how generative fashions enhance understanding and decoding the mannequin outcomes.
One of many Achilles’ heels of the sentence transformers we incessantly use for subject evaluation is their quick context size. Encoder fashions that may learn significantly longer contexts have hardly ever been evaluated for his or her efficiency in subject modeling. Due to this fact, we didn’t know whether or not or how these bigger transformer fashions work in a subject modelling pipeline. One other difficulty is that they produce higher-dimensional embeddings, which regularly negatively have an effect on unsupervised machine studying fashions ([4]). It will possibly both be as a result of Euclidean distances get inflated in higher-dimensional area, or as a result of the variety of parameters surges with enter dimensionality, making parameter restoration harder.
We will clear up these points by:
Chunking paperwork into smaller sections that match into the context window of a sentence transformer. Sadly, chunking may end up in textual content chunks which might be wildly out of context, and it’d take appreciable effort to chunk paperwork at semantically smart boundaries.
Utilizing generative fashions to summarize the contents of those paperwork. LLMs excel at this process and can even take away all sorts of tokenization-based noise and irrelevant data from texts which may hinder our subject mannequin.
Let’s now summarise the trade-offs of utilizing LLM-generated summaries in subject modelling within the following picture.
Picture 5: Advantages and disadvantages of LLM-assisted doc processing within the subject modelling pipeline. Supply: picture by authors.
The really useful technique for LLM-assisted doc preprocessing is a two-step:
Prepare a subject mannequin with easy preprocessing, or no preprocessing in any respect.
While you discover that subject fashions have a tough time decoding your corpus, utilizing LLM-based summarisation is usually a sensible choice if the trade-offs work positively in your particular challenge.
4.1.1. Doc Summarization in Code
Let’s now have a look at how we will summarize paperwork utilizing an LLM. On this instance, we are going to use GPT-5-nano, however Turftopic additionally permits operating domestically run open LLMs. We suggest utilizing open LLMs domestically, if doable, because of decrease prices and higher knowledge privateness.
import pandas as pd
from tqdm import tqdm
from turftopic.analyzers import OpenAIAnalyzer, LLMAnalyzer
# Loading the info
knowledge = pd.read_parquet("knowledge/ecb_data.parquet")
content material = record(knowledge["content"])
# We write a immediate that can extract the related data
# We ask the mannequin to separate data to key factors in order that
# they turn into simpler to mannequin
summary_prompt="Summarize the next press convention from
the European Central Financial institution right into a set of key factors separated by
two newline characters. Reply with the abstract solely, nothing else.
n {doc}"
# Formalize a summarized
summarizer = OpenAIAnalyzer("gpt-5-nano", summary_prompt=summary_prompt)
summaries = []
# Summarize dataframe, observe code execution
for doc in tqdm(knowledge["content"], desc="Summarising paperwork..."):
abstract = summarizer.summarize_document(doc)
# We print summaries as we go as a sanity verify, to verify
# the immediate works
print(abstract)
summaries.append(abstract)
# Acquire summaries right into a dataframe
summary_df = pd.DataFrame(
{
"id": knowledge["id"],
"date": knowledge["date"],
"writer": knowledge["author"],
"title": knowledge["title"],
"abstract": summaries,
}
)
Subsequent, we are going to match a easy KeyNMF mannequin on the important thing factors in these summaries, and let the mannequin uncover the variety of subjects utilizing the Bayesian Info Criterion. This strategy works very nicely on this case, however watch out that computerized subject quantity detection has its shortcomings. Take a look at the Subject Mannequin Leaderboard to achieve extra data on how fashions carry out at detecting the variety of subjects.
import numpy as np
import pandas as pd
from sentence_transformers import SentenceTransformer
from turftopic import KeyNMF
# Create corpus from textual content summaries (not authentic texts)
corpus = record(summary_df["summary"])
# Acquire key factors by segmenting at double line breaks
factors = []
for doc in corpus:
_points = doc.break up("nn")
doc_points = [p for p in _points if len(p.strip().removeprefix(" - "))]
factors.lengthen(doc_points)
# Inform KeyNMF to mechanically detect the variety of subjects utilizing BIC
mannequin = KeyNMF("auto", encoder="paraphrase-mpnet-base-v2")
doc_topic = mannequin.fit_transform(factors)
# Print subject IDs with high phrases
mannequin.print_topics()
Listed below are the KeyNMF outcomes educated on doc summaries:
Picture 6: KeyNMF 10-topic outcomes educated on doc summaries. Supply: picture by authors.
4.3. Subject Evaluation with LLMs
In a typical topic-analysis pipeline, a person would first practice a subject mannequin, then spend time decoding what the mannequin has found, label subjects manually, and at last present a quick description of the sorts of paperwork the subject accommodates. That is time-consuming, particularly in corpora with many recognized subjects.
This half can now be finished by LLMs that may simply generate human-readable subject names and descriptions. We’ll use the identical Analyzer API from Turftopic to realize this:
We apply the analyzer to the introductory statements issued by the ECB, which accompany every financial coverage resolution. These statements are ready fastidiously and comply with a comparatively customary construction. Listed below are the labelled subject names with their descriptions and high phrases printed from analysis_result:
Picture 7: Subject Evaluation utilizing GPT-5-nano in Turftopic. Supply: picture by authors.
Subsequent, let’s present the prevalence of the labelled KeyNMF’ subject names over time. It’s how intensely these subjects had been mentioned within the ECB press conferences over the past 25 years:
from datetime import datetime
import plotly.categorical as px
from scipy.sign import savgol_filter
# create dataframe from labelled subjects,
# mix with timestamp from date column
time_df = pd.DataFrame(
dict(
date=timestamps,
**dict(zip(analysis_result.topic_names, doc_topic.T /
doc_topic.sum(axis=1)))
)
).set_index("date")
# group dataframe to month-to-month frequency
time_df = time_df.groupby(by=[time_df.index.month, time_df.index.year]).imply()
time_df.index = [datetime(year=y, month=m, day=1) for m, y in time_df.index]
time_df = time_df.sort_index()
# show dataframe with Plotly
for col in time_df.columns:
time_df[col] = savgol_filter(time_df[col], 12, 2)
fig = px.line(
time_df.sort_index(),
template="plotly_white",
)
fig.present()
Right here is the labelled subject mannequin dataframe displayed in yearly frequency:
Picture 8: Subject Evaluation utilizing GPT-5-nano in Turftopic over time. Supply: Picture by authors.
Mannequin leads to context: The financial union subject was most outstanding within the early 2000s (see [5] for extra data). The financial coverage and charge resolution subject peaks on the finish of the worldwide monetary disaster round 2011, a interval throughout which the ECB (some commentators argue mistakenly) raised rates of interest. The timing of the inflation and inflation expectations subject additionally corresponds with financial developments: it rises sharply round 2022, when vitality costs pushed inflation into double-digit territory within the euro space for the primary time since its creation.
5. Abstract
Let’s now summarize the important thing factors of the article. The necessities and code for this tutorial are on this repo.
SeededKeyNMF subject mannequin combines textual content prompts with the newest subject mannequin to pay attention modelling on a sure downside.
Summarizing knowledge for subject modeling reduces coaching time, nevertheless it has drawbacks that must be thought-about in a challenge.
The Tutftopic Python package deal implements systematic descriptions and labels with current LLMs into a subject modelling pipeline.
[2] Carlo Altavilla, Luca Brugnolini, Refet S. Gürkaynak, Roberto Motto and Giuseppe Ragusa. 2019. Measuring euro space financial coverage. In: Journal of Financial Economics, Quantity 108, pp 162-179.
[3] Ross Deans Kristensen-McLachlan, Rebecca M.M. Hicke, Márton Kardos, and Mette Thunø. 2024. Context is Key(NMF): Modelling Topical Info Dynamics in Chinese language Diaspora Media. In: CHR 2024: Computational Humanities Analysis Convention, December 4–6, 2024, Aarhus, Denmark.
[4] Márton Kardos, Jan Kostkan, Kenneth Enevoldsen, Arnault-Quentin Vermillet, Kristoffer Nielbo, and Roberta Rocca. 2025. S3 – Semantic Sign Separation. In: Proceedings of the 63rd Annual Assembly of the Affiliation for Computational Linguistics (Quantity 1: Lengthy Papers), pages 633–666, Vienna, Austria. Affiliation for Computational Linguistics.
[6] Michelle S. Lam, Janice Teoh, James A. Landay, Jeffrey Heer, and Michael S. Bernstein. 2024. Idea Induction: Analyzing Unstructured Textual content with Excessive-Stage Ideas Utilizing LLooM. In: Proceedings of the 2024 CHI Convention on Human Elements in Computing Methods (CHI ’24). Affiliation for Computing Equipment, New York, NY, USA, Article 766, 1–28. https://doi.org/10.1145/3613904.3642830.
[7] Chau Minh Pham, Alexander Hoyle, Simeng Solar, Philip Resnik, and Mohit Iyyer. 2024. TopicGPT: A Immediate-based Subject Modeling Framework. In Proceedings of the 2024 Convention of the North American Chapter of the Affiliation for Computational Linguistics: Human Language Applied sciences (Quantity 1: Lengthy Papers), pages 2956–2984, Mexico Metropolis, Mexico. Affiliation for Computational Linguistics.