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 lately progressed in two instructions. The improved statistical strategies stream of Python packages focuses on extra strong, environment friendly, and preprocessing-free fashions, producing fewer junk matters (e.g., FASTopic). The opposite depends on the facility of generative language fashions to extract intuitively comprehensible matters and their descriptions (e.g., TopicGPT [6], LlooM [5]).
Due to analysis on statistical strategies for modelling textual content representations from transformers, junk matters are the exception relatively 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 may do. Human-readable matter names and descriptions at the moment are changing into increasingly more an anticipated results of a well-designed matter modelling pipeline.
As thrilling as these developments are, matter modelling is way from being a solved downside. Neural matter fashions could be relatively unstable and typically exhausting for customers to belief due to their black-box nature. LLM-powered strategies produce spectacular outcomes, however can at instances increase questions on belief, resulting from hallucinations and sensitivity to semantically irrelevant modifications in enter. That is particularly an issue for the banking sector, the place (un)certainty is crucial. Operating massive language fashions can be an enormous infrastructural and computational burden, and may find yourself costing massive sums of cash even for smaller datasets.
Our previous tutorial offers an in depth introduction to how LLMs improve conventional matter modeling by routinely labeling matter names. On this article, we mix present matter modeling strategies with focused LLM help. In our view, a mixture of latest advances in language modeling and classical machine studying can present customers with one of the best of each worlds: a pipeline that mixes the capabilities of huge language fashions with the computational effectivity, trustworthiness, and stability of probabilistic ML.
This text explains three contemporary topic-modelling methods that must be a part of the NLP toolkit in 2026. We’ll determine:
Find out how to use textual content prompts to specify what matter fashions ought to give attention to (i.e., seeded matter fashions).
How LLM-generated summaries could make matter fashions extra correct.
How generative fashions can be utilized to label matters and supply their descriptions.
How these methods 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. Such a textual content is lengthy, fastidiously structured, and extremely repetitive — precisely the form of knowledge the place commonplace matter fashions wrestle and the place interpretability is crucial. By combining seeded matter modelling with LLM-assisted doc summarization and evaluation, we present the way to extract targeted, secure, and economically significant matters with out compromising transparency or scalability.
2. Instance Information
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 final result follows the two-step construction ([2]).
The way it works: First, at 13:45 CET, the ECB releases a short financial coverage choice (MPD) assertion, which accommodates solely restricted textual info. 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 selections, outlines the ECB’s evaluation of financial circumstances, and offers steerage on future coverage concerns. The introductory assertion sometimes lasts about quarter-hour and is adopted by a 45-minute Q&A session.
For this text, we use the introductory statements, scraped instantly from the ECB web site (launched with a flexible data licence). The dataset accommodates 279 statements, and here’s what it appears to be like like:
Picture 1: ECB communication dataset. Supply: Picture by authors.
3. Seeded Subject Modelling
Historically, matter fashions give attention to figuring out probably the most informative matters in a dataset. A naive method practitioners take is to suit a bigger mannequin, then, often manually, filter out matters irrelevant to their knowledge query.
What when you may situation a subject mannequin to solely extract related matters to your knowledge query? That is exactly what seeded matter 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’ll be able to 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 matter mannequin ([3]). It’s, in lots of features, similar to older matter fashions, because it formulates matter discovery by way of matrix factorization. In different phrases, when utilizing this mannequin, you assume that matters are latent elements, that your paperwork comprise 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 fundamental 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 house.
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 sufficient for locating matters in a corpus, isn’t probably the most appropriate alternative if we have to use the mannequin for a particular query. To make this occur, we first should specify a seed phrase, a phrase that minimally signifies what we’re all in favour of. For instance, when analysing the ECB communication dataset, this could possibly be “Enlargement of the Eurozone”.
As sentence-transformers can encode this seed phrase, we will use it to retrieve paperwork which are related to our query:
We encode the seed phrase into the identical embedding house as our paperwork and vocabulary.
To make our mannequin extra attentive to paperwork that comprise related info, 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 method are that it’s:
1) extremely versatile, and
2) can save quite a lot of handbook work.
Watch out: some embedding fashions could be delicate to phrasing and may 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 just use one of many paraphrase models from sentence-transformers, as a result of they’ve intentionally been skilled to be phrasing invariant, and produce high-quality matters with KeyNMF.
3.3 Find out how to use Seeded KeyNMF
KeyNMFand its seeded model can be found on PyPI within the Turftopic bundle, 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 matters and a seed phrase
mannequin = KeyNMF(
n_components=4,
encoder=encoder,
seed_phrase="Enlargement of the Eurozone",
seed_exponent=3.0,
)
# Match mannequin
mannequin.match(corpus)
# Print modelled matters
mannequin.print_topics()
We will see that the mannequin returns matter IDs with typical key phrases which are 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 matters from a corpus is a tough process, and it usually requires greater than only a statistical mannequin that finds patterns within the uncooked knowledge. LLMs serve matter modelling in two foremost areas:
Studying a doc and figuring out the fitting features within the textual content based mostly on a particular knowledge query.
Deciphering the subject mannequin’s output within the related context.
Within the following textual content, we’ll now discover 1) how LLMs enhance processing paperwork for a subject mannequin and a pair of) how generative fashions enhance understanding and deciphering the mannequin outcomes.
One of many Achilles’ heels of the sentence transformers we ceaselessly use for matter 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 matter modeling. Subsequently, 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 frequently negatively have an effect on unsupervised machine studying fashions ([4]). It could possibly both be as a result of Euclidean distances get inflated in higher-dimensional house, or as a result of the variety of parameters surges with enter dimensionality, making parameter restoration harder.
We will remedy 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 are wildly out of context, and it would 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 varieties of tokenization-based noise and irrelevant info from texts which may hinder our matter mannequin.
Let’s now summarise the trade-offs of utilizing LLM-generated summaries in matter modelling within the following picture.
Picture 5: Advantages and downsides of LLM-assisted doc processing within the matter modelling pipeline. Supply: picture by authors.
The advisable technique for LLM-assisted doc preprocessing is a two-step:
Practice a subject mannequin with easy preprocessing, or no preprocessing in any respect.
Once you discover that matter fashions have a tough time deciphering your corpus, utilizing LLM-based summarisation generally is a good selection if the trade-offs work positively in your particular undertaking.
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’ll use GPT-5-nano, however Turftopic additionally permits working regionally run open LLMs. We suggest utilizing open LLMs regionally, if potential, resulting from 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 info
# We ask the mannequin to separate info to key factors in order that
# they turn out to be 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 test, to ensure
# the immediate works
print(abstract)
summaries.append(abstract)
# Accumulate 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’ll match a easy KeyNMF mannequin on the important thing factors in these summaries, and let the mannequin uncover the variety of matters utilizing the Bayesian Information Criterion. This method works very properly on this case, however watch out that automated matter quantity detection has its shortcomings. Try the Topic Model Leaderboard to achieve extra info on how fashions carry out at detecting the variety of matters.
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"])
# Accumulate key factors by segmenting at double line breaks
factors = []
for doc in corpus:
_points = doc.cut up("nn")
doc_points = [p for p in _points if len(p.strip().removeprefix(" - "))]
factors.prolong(doc_points)
# Inform KeyNMF to routinely detect the variety of matters utilizing BIC
mannequin = KeyNMF("auto", encoder="paraphrase-mpnet-base-v2")
doc_topic = mannequin.fit_transform(factors)
# Print matter IDs with prime phrases
mannequin.print_topics()
Listed below are the KeyNMF outcomes skilled on doc summaries:
Picture 6: KeyNMF 10-topic outcomes skilled on doc summaries. Supply: picture by authors.
4.3. Subject Evaluation with LLMs
In a typical topic-analysis pipeline, a consumer would first practice a subject mannequin, then spend time deciphering what the mannequin has found, label matters manually, and at last present a short description of the varieties of paperwork the subject accommodates. That is time-consuming, particularly in corpora with many recognized matters.
This half can now be accomplished by LLMs that may simply generate human-readable matter names and descriptions. We’ll use the identical Analyzer API from Turftopic to attain this:
We apply the analyzer to the introductory statements issued by the ECB, which accompany every financial coverage choice. These statements are ready fastidiously and observe a comparatively commonplace construction. Listed below are the labelled matter names with their descriptions and prime 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’ matter names over time. It’s how intensely these matters had been mentioned within the ECB press conferences over the past 25 years:
from datetime import datetime
import plotly.specific as px
from scipy.sign import savgol_filter
# create dataframe from labelled matters,
# 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 matter mannequin dataframe displayed in yearly frequency:
Picture 8: Subject Evaluation utilizing GPT-5-nano in Turftopic over time. Supply: Picture by authors.
Mannequin ends in context: The financial union matter was most outstanding within the early 2000s (see [5] for extra info). The financial coverage and fee choice matter 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 matter 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 matter mannequin combines textual content prompts with the most recent matter mannequin to pay attention modelling on a sure downside.
Summarizing knowledge for matter modeling reduces coaching time, but it surely has drawbacks that must be thought of in a undertaking.
The Tutftopic Python bundle implements systematic descriptions and labels with latest LLMs into a subject modelling pipeline.
[2] Carlo Altavilla, Luca Brugnolini, Refet S. Gürkaynak, Roberto Motto and Giuseppe Ragusa. 2019. Measuring euro area monetary policy. 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 Information Dynamics in Chinese 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 Signal 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-Degree Ideas Utilizing LLooM. In: Proceedings of the 2024 CHI Convention on Human Elements in Computing Techniques (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 Prompt-based Topic 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.