Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top2Vec learns jointly embedded topic, document and word vectors.
| Date | Stars |
|---|---|
| 2026-07-24 | 3102 |
| 2026-07-25 | 3101 |
| 2026-07-28 | 3101 |
| 2026-07-30 | 3101 |
| 2026-08-06 | 3101 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
[](https://pypi.org/project/top2vec/)
[](https://github.com/ddangelov/Top2Vec/blob/master/LICENSE)
[](https://top2vec.readthedocs.io/en/latest/?badge=latest)
[](http://arxiv.org/abs/2008.09470)
<!---->
<p align="center">
<img src="https://raw.githubusercontent.com/ddangelov/Top2Vec/master/images/top2vec_logo.svg" alt="" width=600 height="whatever">
</p>
# Contextual Top2Vec Overview
Paper: [Topic Modeling: Contextual Token Embeddings Are All You Need](https://aclanthology.org/2024.findings-emnlp.790.pdf)
The Top2Vec library now supports a new contextual version, allowing for deeper topic modeling capabilities. **Contextual Top2Vec**, enables the model to generate **contextual token embeddings** for each document, identifying multiple topics per document and even detecting topic segments within a document. This enhancement is useful for capturing a nuanced understanding of topics, especially in documents that cover multiple themes.
### Key Features of Contextual Top2Vec
- **`contextual_top2vec` flag**: A new parameter, `contextual_top2vec`, is added to the Top2Vec class. When set to `True`, the model uses contextual token embeddings. Only the following embedding models are supported:
- `all-MiniLM-L6-v2`
- `all-mpnet-base-v2`
- **Topic Spans**: C-Top2Vec automatically determines the number of topics and finds topic segments within documents, allowing for a more granular topic discovery.
### Simple Usage Example
Here is a simple example of how to use Contextual Top2Vec:
```python
from top2vec import Top2Vec
# Create a Contextual Top2Vec model
top2vec_model = Top2Vec(documents=documents,
ngram_vocab=True,
contextual_top2vec=True)
```
### New Methods for Contextual Top2Vec
#### `get_document_topic_distribution()`
```python
get_document_topic_distribution() -> np.ndarray
```
- **Description**: Retrieves the topic distribution for each document.
- **Returns**: A `numpy.ndarray` of shape `(num_documents, num_topics)`. Each row represents the **probability distribution of topics** for a document.
#### `get_document_topic_relevance()`
```python
get_document_topic_relevance() -> np.ndarray
```
- **Description**: Provides the relevance of each topic for each document.
- **Returns**: A `numpy.ndarray` of shape `(num_documents, num_topics)`. Each row indicates the **relevance scores of topics** for a document.
#### `get_document_token_topic_assignment()`
```python
get_document_token_topic_assignment() -> List[Document]
```
- **Description**: Retrieves token-level topic assignments for each document.
- **Returns**: A list of `Document` objects, each containing topics with **token assignments and scores** for each token.
#### `get_document_tokens()`
```python
get_document_tokens() -> List[List[str]]
```
- **Description**: Returns the tokens for each document.
- **Returns**: A list of lists where each sublist contains the **tokens for a given document**.
### Usage Note
The **contextual version** of Top2Vec requires specific embedding models, and the new methods provide insights into the distribution, relevance, and assignment of topics at both the document and token levels, allowing for a richer understanding of the data.
> Warning: Contextual Top2Vec is still in **beta**. You may encounter issues or unexpected behavior, and the functionality may change in future updates.
Citation
--------
```
@inproceedings{angelov-inkpen-2024-topic,
title = "Topic Modeling: Contextual Token Embeddings Are All You Need",
author = "Angelov, Dimo and
Inkpen, Diana",
editor = "Al-Onaizan, Yaser and
Bansal, Mohit and
Chen, Yun-Nung",
Excerpt of 21,132 characters
Read on GitHub347
Graham Clendenning
2
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:2de98af90370e1c7, topic:semantic-search
matched fp:2de98af90370e1c7, topic:sentence-transformers