Repository navigation
Conversation
dkuku
marked this pull request as draft
September 29, 2026 20:27
dkuku
force-pushed
the
feature/embedding-gemma
branch
2 times, most recently
from
September 29, 2026 20:34
d2276ec to
6d86b0d
Compare
dkuku
commented
Sep 29, 2026
| pytorch_state | ||
| # Prepend path-specific prefix if configured. This avoids key collisions when | ||
| # loading multiple state dict files that share internal tensor names (e.g. "linear.weight") | ||
| case path_prefixes[path] do |
Contributor
Author
There was a problem hiding this comment.
Context on :path_prefixes for the reviewer:
Unlike models directly from huggingface/transformers where weights reside in a single root model.safetensors, EmbeddingGemma (google/embeddinggemma-300m) comes from SentenceTransformers and splits the architecture across subdirectories:
- Root
model.safetensorscontains the Gemma 3 backbone. 2_Dense/model.safetensorscontains the 1st linear bottleneck projection (768 -> 3072).3_Dense/model.safetensorscontains the 2nd linear bottleneck projection (3072 -> 768).
Because both 2_Dense and 3_Dense internally name their tensors linear.weight, merging them directly via Map.merge/2 would cause key collisions and overwrite the 1st dense layer. The :path_prefixes option prepends the folder name (2_Dense. / 3_Dense.) to disambiguate them.
If you have a preferred alternative design for handling modular / multi-directory checkpoints in Bumblebee, I'm happy to adapt or refactor this!
dkuku
force-pushed
the
feature/embedding-gemma
branch
from
September 30, 2026 17:32
6d86b0d to
c24a566
Compare
dkuku
force-pushed
the
feature/embedding-gemma
branch
from
September 30, 2026 20:08
c24a566 to
da3abd0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Stacked PR: This PR is stacked on top of #468 (
feature/gemma3-bidirectional).Please review #468 first. Once #468 is merged into
main, the diff here will automatically update to only show theEmbeddingGemmaadditions.This PR adds support for
EmbeddingGemma(google/embeddinggemma-300m), a lightweight text embedding model based on Gemma 3.Model Architecture
In the SentenceTransformers and HuggingFace ecosystem, EmbeddingGemma consists of:
2_Denseand3_Dense), projectingChanges
Bumblebee.Text.EmbeddingGemmawith:basearchitecture producing:embedding,:pooled_state, and:hidden_state.{prefix, path}tuples inBumblebee.Conversion.PyTorchParamsso subdirectory weights (2_Dense/model.safetensorsand3_Dense/model.safetensors) load without key collisions.extra_params_files/2callback inBumblebee.Text.EmbeddingGemmaand handled directory loading inBumblebee.load_model.EmbeddingGemmainBumblebee.load_model/load_specarchitecture mapping and registeredembeddinggemmatokenizer mapping to:gemma.sentence-transformerswithunsloth/embeddinggemma-300m.Reference verification (Python)
Output verified against PyTorch
sentence-transformerswithatol: 1.0e-4usingunsloth/embeddinggemma-300m:Bumblebee output: