vlm_encoder
vlm_encoder
¶
VLM encoder with separate vision and language blocks (CLIP-style).
VLMEncoder
¶
VLMEncoder(input_keys, pretrained, frozen, pooling_method, model_name=value, attention_type=value, model_dtype=None, lora_config=None)
Bases: LanguageEncoderMixin, RGBEncoderMixin, Encoder
VLM encoder with separate vision and language outputs.
Initialize the VLM encoder.
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 encoder weights. |
required |
pooling_method
|
str
|
Feature pooling strategy for vision and language outputs. |
required |
model_name
|
str
|
HuggingFace model identifier for the VLM. |
value
|
attention_type
|
str
|
Attention implementation (e.g. SDPA, eager). |
value
|
model_dtype
|
str | None
|
Precision string from experiment config (e.g. |
None
|
lora_config
|
LoRAAdaptation | None
|
Optional LoRA adapter configuration. |
None
|
Source code in src/versatil/models/encoding/encoders/cross_modal/vision_language/vlm_encoder.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
encode
¶
Encode images and text through the VLM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
dict[str, Tensor]
|
Dict with camera images as (B, C, H, W) per camera key, tokenized text as (B, S), and optional padding mask. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Tensor]
|
Dict with per-camera RGB features, language features, and padding mask. |
Source code in src/versatil/models/encoding/encoders/cross_modal/vision_language/vlm_encoder.py
validate_input_metadata
¶
Validate that camera keys have camera metadata and token keys are not images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Observation key being validated. |
required |
metadata
|
BaseMetadata
|
Metadata from the observation space for this key. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Error message if incompatible, None if valid. |
Source code in src/versatil/models/encoding/encoders/cross_modal/vision_language/vlm_encoder.py
get_output_specification
¶
Return the output feature names and dimensions for this encoder.
Returns:
| Type | Description |
|---|---|
list[FeatureMetadata]
|
List of FeatureMetadata with per-camera vision features, language features, |
list[FeatureMetadata]
|
and the language padding mask. |
Source code in src/versatil/models/encoding/encoders/cross_modal/vision_language/vlm_encoder.py
get_vocab_size
¶
Get the vocabulary size of the text encoder.
Returns:
| Type | Description |
|---|---|
int
|
Vocabulary size of the language model component |