Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: wrong attention mask calculation resulted in wrong embeddings #14496

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

maziyarpanahi
Copy link
Member

@maziyarpanahi maziyarpanahi commented Jan 6, 2025

This pull request includes several updates to the attention mask logic across multiple classes in the com.johnsnowlabs.ml.ai package. The changes primarily involve modifying the condition used to set the attention mask values.

Updates to attention mask logic:

  • BGE.scala: Changed the condition for setting attention mask values from x < 0L to x == 0L in both getSentenceEmbeddingFromOv and getSentenceEmbeddingFromOnnx methods. [1] [2]
  • E5.scala: Updated the attention mask condition from x < 0L to x == 0L in the getSentenceEmbeddingFromOnnx method. [1] [2]
  • MPNet.scala: Modified the attention mask condition from x < this.paddingTokenId to x == this.paddingTokenId in the getSentenceEmbeddingFromOv and getSentenceEmbeddingFromOnnx methods. [1] [2]
  • Mxbai.scala: Changed the attention mask condition from x < 0L to x == 0L in the getSentenceEmbeddingFromOnnx method.
  • Nomic.scala: Updated the attention mask condition from x < 0L to x == 0L in the getSentenceEmbeddingFromOnnx method. [1] [2]
  • SnowFlake.scala: Modified the attention mask condition from x < 0L to x == 0L in both getSentenceEmbeddingFromOv and getSentenceEmbeddingFromOnnx methods. [1] [2]
  • UAE.scala: Changed the attention mask condition from x < 0L to x == 0L in both getSentenceEmbeddingFromOpenvino and getSentenceEmbeddingFromOnnx methods. [1] [2] [3]

@maziyarpanahi maziyarpanahi self-assigned this Jan 6, 2025
@maziyarpanahi maziyarpanahi added bug-fix DON'T MERGE Do not merge this PR labels Jan 6, 2025
Copy link
Contributor

@ahmedlone127 ahmedlone127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-fix DON'T MERGE Do not merge this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants