Adds gemma3 embedding support#209
Open
wesc wants to merge 5 commits into
Open
Conversation
(cherry picked from commit 3095231)
(cherry picked from commit 056c4a6)
- Cleaned up gemma3.py by removing commented-out code related to HuggingFace token. - Updated the token placeholder in bert.rs to reflect the correct usage of "hf_key". - Minor adjustments in gemma3.rs to remove unnecessary code for clarity. (cherry picked from commit 2b3c8da)
The dev merge reworked EmbeddingModel.from_pretrained_hf to drop the WhichModel argument and auto-detect the architecture from config.json (Gemma3TextModel). Update the example call to the new signature. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Add 768→3072→768 dense projection head between mean-pool and L2-norm - Switch the transformer to bidirectional attention with a padding mask - Apply per-layer RoPE: local base freq for sliding layers, global for full-attention layers - Add golden test against sentence-transformers output verified to ~1e-6
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.
Adds gemma3 embedding support.
Completed work started from #173. I cherry-picked commits from the referenced branch into this branch, and authored w/ Claude the completed implementation. I pulled embeddinggemma from HF and generated golden vectors from sentence-transformers. You will find tests checking the first 6 dims of those vectors as per what appears to be custom in the rest of the repo.