MaartenGr / MaartenGr/BERTopic

RuntimeError: The size of tensor a (678) must match the size of tensor b (512) at non-singleton dimension 1

Open
#1,852 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.8k
Forks
920
Avg merge
22h 24m
Merged PRs (30d)
5

Description

Hi!, I'm using the pipeline to load the model of BiomedNLP-BiomedBERT-base-uncased-abstract-fulltext from huggingface, but it seems to have gone wrong. The following is my code and the bug. Please help me.

embedding_model = pipeline("feature-extraction", model=r"D:\A-编程\生物医药\BiomedNLP-BiomedBERT-base-uncased-abstract-fulltext")
topic_model = BERTopic(
language='english',
embedding_model=embedding_model,
#verbose=True
)
topics,probilities=topic_model.fit_transform(df_value['text'].tolist())

RuntimeError: The size of tensor a (678) must match the size of tensor b (512) at non-singleton dimension 1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported failure with the BiomedNLP-BiomedBERT-base-uncased-abstract-fulltext pipeline and the BERTopic configuration shown in the issue. Trace the call from embedding_model through topic_model.fit_transform and inspect where tensor dimensions 678 and 512 are produced. Done means the documented setup runs without this size-mismatch RuntimeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
huggingface, python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.