EmbeddingGemma2TextEmbedder classkeras_hub.models.EmbeddingGemma2TextEmbedder(
backbone, preprocessor=None, pooling_mode="mean", normalize=True, **kwargs
)
An end-to-end EmbeddingGemma2 model for generating sentence embeddings.
This model attaches a mean-pooling and L2 normalization head to an
EmbeddingGemma2Backbone instance, mapping from the backbone outputs to
fixed-size sentence embeddings suitable for semantic similarity, clustering,
and retrieval tasks.
This model can optionally be configured with a preprocessor layer, in
which case it will automatically apply preprocessing to raw inputs during
fit(), predict(), and evaluate(). This is done by default when
creating the model with from_preset().
Arguments
keras_hub.models.EmbeddingGemma2Backbone instance.keras_hub.models.EmbeddingGemma2TextEmbedderPreprocessor or
None. If None, this model will not apply preprocessing, and
inputs should be preprocessed before calling the model."mean" is supported. Defaults to "mean".True.from_preset methodEmbeddingGemma2TextEmbedder.from_preset(preset, load_weights=True, **kwargs)
Instantiate a keras_hub.models.Task from a model preset.
A preset is a directory of configs, weights and other file assets used
to save and load a pre-trained model. The preset can be passed as
one of:
'bert_base_en''kaggle://user/bert/keras/bert_base_en''hf://user/bert_base_en''./bert_base_en'For any Task subclass, you can run cls.presets.keys() to list all
built-in presets available on the class.
This constructor can be called in one of two ways. Either from a task
specific base class like keras_hub.models.CausalLM.from_preset(), or
from a model class like
keras_hub.models.BertTextClassifier.from_preset().
If calling from the a base class, the subclass of the returning object
will be inferred from the config in the preset directory.
Arguments
True, saved weights will be loaded into
the model architecture. If False, all weights will be
randomly initialized.Examples
# Load a Gemma generative task.
causal_lm = keras_hub.models.CausalLM.from_preset(
"gemma_2b_en",
)
# Load a Bert classification task.
model = keras_hub.models.TextClassifier.from_preset(
"bert_base_en",
num_classes=2,
)
| Preset | Parameters | Description |
|---|---|---|
| embedding_gemma2 | 744.37M | EmbeddingGemma 2: 744M-parameter, 24-layer multimodal embedding model built on Gemma 4. Embeds text, images, video and audio into a 768-dimensional space. |
backbone propertykeras_hub.models.EmbeddingGemma2TextEmbedder.backbone
A keras_hub.models.Backbone model with the core architecture.
preprocessor propertykeras_hub.models.EmbeddingGemma2TextEmbedder.preprocessor
A keras_hub.models.Preprocessor layer used to preprocess input.