Skip to content

EmbeddingGemma-2 support - #246

Closed
danielhanchen wants to merge 3 commits into
masterfrom
embeddinggemma-2-support
Closed

danielhanchen wants to merge 3 commits into
masterfrom
embeddinggemma-2-support

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

EmbeddingGemma 2 support (google/embeddinggemma-2), by @ngxson.

The two commits by @ngxson are cherry-picked unchanged:

  • model: add embeddinggemma2: the gemma-embedding2 architecture, its graph and the converter.
  • add mtmd support: images and audio through the existing Gemma 4 vision and audio projectors.

Together they come to +324 / -2 across 10 files, the same lines as the upstream change.

One small extra commit adapts the graph to this tree, which does not have two newer upstream helpers yet:

  • load_swa_pattern is written out inline.
  • build_inp_embd(tok_embd, scale) becomes build_inp_embd + ggml_scale, matching gemma4.cpp here.

Testing

llama-embedding on the BF16 GGUF, compared with a build of the upstream change:

Input Result
~1,300-token document identical output
short query cosine 0.999996

Both give 768-dim, mean-pooled output.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T15:58:17.985195Z 061e554 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 061e554f5b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread conversion/gemma.py
Comment on lines +958 to +960
def modify_tensors(self, data_torch: Tensor, name: str, bid: int | None) -> Iterable[tuple[str, Tensor]]:
# same towers as Gemma4, but the tensor names have no "model." prefix
yield from super().modify_tensors(data_torch, "model." + name, bid)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Filter text weights before converting the multimodal projector

When --mmproj is used on an EmbeddingGemma2 checkpoint, its text tensors have bare names such as layers.*, ple.*, and embedding_projection, so the inherited MmprojModel.filter_tensors() does not discard them because it only recognizes language_model.* as text. This method then prefixes every surviving name with model. and the superclass routes every non-audio tensor through the vision mapping, causing conversion to fail on the first text tensor with an unmappable-name error. Override filter_tensors() to retain only the vision/audio tower tensors before this renaming.

Useful? React with 👍 / 👎.

@danielhanchen

Copy link
Copy Markdown
Member Author

Superseded by #247, which carries the same commits on base/upstream-b9a5a00b8 for the pin set instead of putting source into master.

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