Skip to content

Refactor + update BaseEmbedder emebedding methods - #855

Merged
MaartenGr merged 7 commits into
MaartenGr:masterfrom
zachschillaci27:refactor-embedders
Dec 19, 2022
Merged

MaartenGr merged 7 commits into
MaartenGr:masterfrom
zachschillaci27:refactor-embedders

Conversation

@zachschillaci27

Copy link
Copy Markdown
Contributor

Refactor and update the various BaseEmbedder subclasses, specifically focusing on the embed methods. The changes are summarized for each subclass below:

  • FlairBackend: Replace unused index with _
  • GensimBackend: Change handling of out-of-vocabulary words from assigning the zero vector to skipping. Directly compute the mean over word vectors using a list comprehension.
  • SentenceTransformerBackend: Directly return embeddings.
  • SpacyBackend: Avoid bare except (risky) and change handling of empty documents. Though I'm not certain the empty document checks are necessary - what were the original exceptions being raised?
  • USEBackend: Directly return embeddings.

Please let me know if you have any comments or feedback!

@MaartenGr

Copy link
Copy Markdown
Owner

Thank you for the PR and apologies for the late reply. I'll take some time to look things over.

@MaartenGr

Copy link
Copy Markdown
Owner

Other than the things mentioned above, there are some real nice refactors there!

@zachschillaci27

Copy link
Copy Markdown
Contributor Author

Other than the things mentioned above, there are some real nice refactors there!

Thanks! Let me know if you would like me to change anything

@MaartenGr

Copy link
Copy Markdown
Owner

Thanks! Let me know if you would like me to change anything

Yes, the things I mentioned above would be great if you could update them.

@zachschillaci27

Copy link
Copy Markdown
Contributor Author

Thanks! Let me know if you would like me to change anything

Yes, the things I mentioned above would be great if you could update them.

Sorry, not sure I see any comments. Where did you write them? 😅

Comment thread bertopic/backend/_flair.py Resolved
Comment thread bertopic/backend/_gensim.py Resolved
Comment thread bertopic/backend/_use.py Resolved
@MaartenGr

Copy link
Copy Markdown
Owner

Sorry, not sure I see any comments. Where did you write them? 😅

Oops, my bad! You should see them now.

@MaartenGr
MaartenGr merged commit e7b7658 into MaartenGr:master Dec 19, 2022
@MaartenGr

Copy link
Copy Markdown
Owner

@zachschillaci27 Thanks for the work! I just merged it 😄

@MaartenGr MaartenGr mentioned this pull request Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants