paligemma
paligemma
¶
PaliGemma VLM component for VLA decoders.
PaliGemmaVLM
¶
PaliGemmaVLM(input_keys, pretrained, frozen, model_name=value, attention_type=value, model_dtype=None, max_text_length=None, lora_config=None)
Bases: HuggingFaceGenerativeVLM
PaliGemma VLM with per-camera sequential image encoding.
Each camera image is encoded through SigLIP + multi-modal projector
separately, then concatenated with language embeddings before the Gemma
language-model pass. Scaling follows the HF reference: text embeddings are
scaled by sqrt(hidden_dimension) inside Gemma's embedding module, image
tokens enter unscaled.
Initialize the PaliGemma VLM component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_keys
|
str | list[str]
|
Input keys for cameras and tokenized text. |
required |
pretrained
|
bool
|
Whether to load pretrained HuggingFace weights. |
required |
frozen
|
bool
|
Whether to freeze all model weights. |
required |
model_name
|
str
|
HuggingFace model identifier for PaliGemma. |
value
|
attention_type
|
str
|
Attention implementation (e.g. SDPA, eager). |
value
|
model_dtype
|
str | None
|
Precision string from experiment config (e.g. |
None
|
max_text_length
|
int | None
|
Maximum text sequence length. Defaults to model's max_position_embeddings if None. |
None
|
lora_config
|
LoRAAdaptation | None
|
Optional LoRA adapter configuration. |
None
|
Source code in src/versatil/models/decoding/generative_language_models/vision_language/paligemma.py
forward_language_model
¶
forward_language_model(input_ids=None, inputs_embeds=None, attention_mask=None, past_key_values=None, use_cache=False, cache_position=None, position_ids=None, output_hidden_states=True)
Run the Gemma language tower with PaliGemma 1-indexed positions.
Source code in src/versatil/models/decoding/generative_language_models/vision_language/paligemma.py
get_explainability_targets
¶
Return the projector output used as PaliGemma visual context.
PaliGemma encodes each camera independently with SigLIP and projects
patch tokens into the Gemma hidden size through multi_modal_projector.
For multi-camera inputs this layer is invoked once per camera, and the
base VLM is_multi_camera flag lets the explainability runner select
the requested camera invocation.
Returns:
| Type | Description |
|---|---|
list[VisionExplanationTarget]
|
One token-sequence target over PaliGemma image tokens. |