EmbeddingGemma2TextEmbedderPreprocessor classkeras_hub.models.EmbeddingGemma2TextEmbedderPreprocessor(
tokenizer,
image_converter=None,
audio_converter=None,
video_converter=None,
sequence_length=512,
truncate="round_robin",
**kwargs
)
EmbeddingGemma2 text embedder preprocessor.
Turns raw text, images, videos and audio into the inputs of
keras_hub.models.EmbeddingGemma2Backbone. Text is tokenized and packed
to sequence_length; each image, video or audio clip is converted by the
matching converter and its placeholder token in the text is expanded to
the right number of soft tokens, with the positions of those tokens
returned as vision_indices / audio_indices.
Inputs are a dict with any of the keys "texts", "images",
"videos", "audio", or a bare string / list of strings. A modality
given without text gets a prompt made of its placeholder alone.
Unbatched inputs (a single string, a rank-3 image, a rank-4 video, a
rank-1 waveform) return unbatched outputs.
Two limits apply: one image per prompt (a rank-3 image, or a rank-4
batch with one image per example), and "images" and "videos" cannot
be combined in a single call — pass them in separate calls. Both raise a
ValueError.
Python lists and NumPy arrays run through a pure-Python path that does
not need TensorFlow; inside tf.data the TensorFlow path is used.
Arguments
EmbeddingGemma2Tokenizer instance.EmbeddingGemma2ImageConverter, or None to
disable image inputs.EmbeddingGemma2AudioConverter, or None to
disable audio inputs.EmbeddingGemma2VideoConverter, or None to
disable video inputs.max_soft_tokens per image or video frame, and up to
750 per 30 s audio clip), and a ValueError is raised when
packing would truncate any of them. Defaults to 512.keras_hub.layers.MultiSegmentPacker. Defaults to
"round_robin".Examples
preprocessor = (
keras_hub.models.EmbeddingGemma2TextEmbedderPreprocessor.from_preset(
"embedding_gemma2"
)
)
preprocessor("What is the capital of France?")
preprocessor({"texts": ["<|image|> describe this"], "images": [image]})
from_preset methodEmbeddingGemma2TextEmbedderPreprocessor.from_preset(
preset, config_file="preprocessor.json", **kwargs
)
Instantiate a keras_hub.models.Preprocessor 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 Preprocessor subclass, you can run cls.presets.keys() to
list all built-in presets available on the class.
As there are usually multiple preprocessing classes for a given model,
this method should be called on a specific subclass like
keras_hub.models.BertTextClassifierPreprocessor.from_preset().
Arguments
Examples
# Load a preprocessor for Gemma generation.
preprocessor = keras_hub.models.CausalLMPreprocessor.from_preset(
"gemma_2b_en",
)
# Load a preprocessor for Bert classification.
preprocessor = keras_hub.models.TextClassifierPreprocessor.from_preset(
"bert_base_en",
)
| 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. |
tokenizer propertykeras_hub.models.EmbeddingGemma2TextEmbedderPreprocessor.tokenizer
The tokenizer used to tokenize strings.
image_converter propertykeras_hub.models.EmbeddingGemma2TextEmbedderPreprocessor.image_converter
The image converter used to preprocess image data.
audio_converter propertykeras_hub.models.EmbeddingGemma2TextEmbedderPreprocessor.audio_converter
The audio converter used to preprocess audio data.
video_converter propertykeras_hub.models.EmbeddingGemma2TextEmbedderPreprocessor.video_converter
The video converter used to preprocess video data.