Document Clustering
The phrase one or several topics means the method does not have to put each document into a single bin. The phrase usually without supervision means the topics are not handed to the method in advance. They have to be found from the documents themselves.
A Newsroom Archive With No Labels
Imagine a newsroom archive holding tens of thousands of articles that nobody has ever tagged. A reader who wants every article about the economy, or every article about a local election, has no easy way to find them. The archive is just a large pile of raw sentences with no category attached to any of them.
This situation is common. Customer reviews, support tickets, research abstracts, and social media posts all arrive as raw text with no category attached. Reading every item and labeling it by hand is slow, and for large collections it is impractical.
What do you think happens?
If a single news article is about both a city budget and a stadium project, should the method be forced to give it exactly one label?
Reveal answer
No, a document is allowed to touch more than one subject.
Topic modeling assigns each document to one or several topics. The task does not force every document into a single bin, so an article about two subjects can be related to both.
What Topic Modeling Means
Topic modeling is the task of assigning each document to one or several topics, usually without supervision.
Instead of asking a person to read everything and label it, topic modeling tries to discover what the documents are about. The technique is often applied to text data for exactly this kind of situation.
The phrase one or several topics means the method does not have to put each document into a single bin. The phrase usually without supervision means the topics are not handed to the method in advance. They have to be found from the documents themselves.
A familiar example comes from news. Articles might be grouped into topics such as politics, sports, and finance. An editor would recognize these as the sections of a newspaper. Topic modeling aims to produce this kind of grouping from the text of the articles, rather than from a list of section names that someone wrote down beforehand.
Tracing Raw Documents to Topics
It helps to follow the state of the data from start to finish. At the beginning, the collection is only raw text, and every document is unlabeled. No topic names exist yet. The method must produce the topics and the assignments together, starting from the documents alone.
- 1Start with an unlabeled collection in which each document is only raw text and no topic is attached to it
- 2Let the method look at the documents themselves to find the topics that they contain
- 3Represent each document in terms of those topics, so the document's state now records how strongly it relates to each one
- 4Read the result as topic assignments: each document is assigned one topic in the single-topic case, or several topics in the multi-topic case
Topic Modeling as the Umbrella Task
Topic modeling is a broad task, and it has two cases. In the first case, each document is assigned a single topic. In the second case, each document can have more than one topic. The first case is document clustering, which is a special case of topic modeling. The diagram below shows how the two cases sit under the same umbrella.
Because document clustering is a special case, everything the umbrella task does also applies to it, but the single-topic restriction is added. Keeping that restriction in mind is what lets you tell the two cases apart.
Single Topic Versus Several Topics
The clearest way to separate the two cases is to ask how many topics each document is assigned. In document clustering, the answer is exactly one. In decomposition-based topic modeling, the answer can be several, and each topic comes with its own degree of relatedness.
A Document as a Bundle of Topics
When a document is allowed several topics, it helps to picture the document as a bundle of topics rather than a single label. A stronger coefficient means a stronger connection between that document and that topic. The diagram below uses one hypothetical news article to show the idea. The three coefficient values are invented for teaching purposes and are not output from any real run.
Reading a document's topic bundle
A hypothetical stadium-funding article has these coefficients: politics 0.60, finance 0.35, sports 0.05. Which topics is the article related to, and how strongly?
- 1Identify the topics
Each component the method learned corresponds to one topic, so the three components here are politics, finance, and sports.
- 2Read each coefficient
The coefficient shows how strongly this document relates to that topic. Politics is 0.60, finance is 0.35, and sports is 0.05.
- 3Compare the strengths
Politics has the strongest connection, finance is a substantial second, and sports is weak. The article is not forced into a single bin.
- 4State the assignment
The article is related to politics and finance, with sports as a minor connection, which is the multi-topic reading of the document.
The document is a bundle of topics: strongly politics, moderately finance, and only weakly sports.
Notice what this reading does not claim. It does not say the article belongs to exactly one topic. Each topic receives its own degree of relatedness, and that is the practical meaning of a document having multiple topics.
Components, Coefficients, and LDA
The multi-topic case is linked to decomposition methods. In a decomposition method, the data is expressed in terms of a set of components. In topic modeling, each component the method learns corresponds to one topic. The representation of a single document then records how much of each component it contains, and those amounts are its coefficients.
Latent Dirichlet Allocation, usually abbreviated LDA, is the decomposition method people most often mean when they talk about topic modeling. In these terms, LDA is one specific way of learning the components, and each component is read as a topic. The shape of the result is the important takeaway: topics as components, and documents as coefficients over those components.
Mistakes Learners Make With Topic Modeling
Common mistake Treating topic modeling and document clustering as identical
What it looks likeSaying an article about a budget and a stadium belongs to exactly one group because the method is 'clustering'.
Why it failsDocument clustering is only the single-topic case. Topic modeling covers the multi-topic case too.
Do this insteadAsk first how many topics each document may have. If the answer is one, the task is clustering. If it can be several, the task is decomposition-based topic modeling.
Common mistake Assuming the topics are supplied in advance
What it looks likeExpecting the method to be given a list of sections such as politics, sports, and finance before it runs.
Why it failsTopic modeling is usually done without supervision, so the topics have to be found from the documents themselves.
Do this insteadDescribe the topics as things the method discovers from the text, not as labels a person supplied.
Common mistake Reading a coefficient as a yes or no answer
What it looks likeSeeing a finance coefficient of 0.35 and concluding the article is not about finance.
Why it failsA coefficient shows how strongly a document relates to a topic. It is a degree of relatedness, not a switch.
Do this insteadCompare the coefficients to see which topics are stronger or weaker for that document.
Common mistake Forgetting that each component corresponds to one topic, so the components are not documents themselves
Practice Reading a Topic Bundle
A hypothetical weather-and-transport article has these coefficients: weather 0.10, transport 0.80, politics 0.20. Which case of topic modeling does this description fit, and which topic is the strongest connection? Explain why the answer is not a single forced label.
Hints
- Ask whether the description allows more than one topic per document.
- Compare the coefficient values to find the strongest connection, and remember a coefficient is a degree of relatedness.
Key Takeaways
- Topic modeling assigns each document to one or several topics, usually without supervision, so the topics are discovered from the documents themselves.
- When each document has exactly one topic, the task is document clustering, which is a special case of topic modeling.
- When documents can have several topics, the task connects to decomposition methods, where each learned component corresponds to a topic.
- A document's coefficients over the components show how strongly that document relates to each topic.
- Latent Dirichlet Allocation is the decomposition method most often meant by topic modeling, with topics as components and documents as coefficient sets.