-
Notifications
You must be signed in to change notification settings - Fork 95
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
Add bge-m3 and Nomic 1.5 embeddings. #1182
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
pyproject.toml
Outdated
@@ -86,6 +89,7 @@ hdbscan = { version = "^0.8.33", optional = true } | |||
|
|||
[tool.poetry.extras] | |||
all = [ | |||
"bge", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these have to be pypi packages, not aliases to groups
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
embeddings = self._model.encode(doc, convert_to_tensor=True) | ||
# Extract the dense vectors from the model. | ||
embeddings = F.layer_norm(embeddings, normalized_shape=(embeddings.shape[1],)) | ||
embeddings = embeddings[:, : self._matryoshka_dim] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are dimensions sorted by importance , like PCA ? curious why we can just take the last 256/512 dimensions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats the magic of matryoshka_dim.. it's not PCA exactly, afaict it's baked into the loss function: https://aniketrege.github.io/blog/2024/mrl/
Fixes #1148
I added two versions of the Nomic 1.5 embeddings, which use matryoshka_dim dims, see: https://huggingface.co/nomic-ai/nomic-embed-text-v1.5
Demo: https://lilacai-nikhil-staging.hf.space/datasets#local/glue_ax_map&schemaCollapsed=false