MaartenGr / MaartenGr/BERTopic
Zero shot topic modelling
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.8k
- Forks
- 920
- Avg merge
- 22h 24m
- Merged PRs (30d)
- 5
Description
### Have you searched existing issues? 🔎
- [X] I have searched and found no existing issues
### Desribe the bug
Getting a value error for undefined reason,
ValueError: Found array with 0 sample(s) (shape=(0, 1536)) while a minimum of 1 is required.
i have checked embeddings are working fine for test results.
```
import openai
from bertopic.representation import OpenAI
from bertopic import BERTopic
from langchain.embeddings import OpenAIEmbeddings
# Then use the following
my_key = "12323m2em2rm,2lr,2.f,."
client = openai.OpenAI(api_key = my_key)
embedding_model = OpenAIBackend(client, "text-embedding-ada-002")
summarization_prompt = """
I have a topic that is described by the following keywords: [KEYWORDS]
In this topic, the following documents are a small but representative subset of all documents in the topic:
[DOCUMENTS]
Based on the information above, please give a description of this topic in a one statement in the following format:
topic:
"""
# embedding_model = OpenAIBackend(client, "text-embedding-ada-002")
representation_model = OpenAI(client = client, model="gpt-4o", chat=True, prompt=summarization_prompt,
nr_docs=5, delay_in_seconds=3)
vectorizer_model = CountVectorizer(min_df=1)
topic_model = BERTopic(
embedding_model=embedding_model,
min_topic_size=25,
zeroshot_topic_list=zeroshot_topic_list,
zeroshot_min_similarity=0,
representation_model=representation_model
)
topics =topic_model.fit_transform(df['title'].values)
```
### Reproduction
```python
from bertopic import BERTopic
```
### BERTopic Version
0.16.3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file or complete reproduction is provided. Start by tracing BERTopic.fit_transform through the zero-shot topic modelling path and reproduce the reported empty-array ValueError with the supplied configuration. Done means identifying the cause of the zero-sample array and documenting or correcting the behavior with a verified reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100