bridge.models.glm_vl.data.collate_fn#
GLM VL collator implementations.
Module Contents#
Functions#
Flatten text-only structured assistant content for GLM chat templates. |
|
Build GLM-4.5V role boundaries and exclude its empty thinking prefix. |
|
Build GLM-4.5V loss spans using a virtual final turn terminator. |
|
Collate function for GLM-4.5V model. |
Data#
API#
- bridge.models.glm_vl.data.collate_fn.GLM4V_ASSISTANT_START#
ā<|assistant|>\nā
- bridge.models.glm_vl.data.collate_fn.GLM4V_ASSISTANT_END#
ā<|endoftext|>ā
- bridge.models.glm_vl.data.collate_fn.GLM4V_EMPTY_THINK#
ā
\nā
- bridge.models.glm_vl.data.collate_fn.GLM4V_NEXT_ROLE_MARKERS#
(ā<|system|>\nā, ā<|user|>\nā, ā<|observation|>\nā)
- bridge.models.glm_vl.data.collate_fn._normalize_glm4v_assistant_content(
- example: dict[str, Any],
Flatten text-only structured assistant content for GLM chat templates.
- bridge.models.glm_vl.data.collate_fn._glm4v_assistant_mask_boundary_config(
- processor: Any,
Build GLM-4.5V role boundaries and exclude its empty thinking prefix.
- bridge.models.glm_vl.data.collate_fn._build_glm4v_assistant_loss_mask(
- example: dict,
- input_ids: torch.Tensor,
- processor: Any,
- skipped_tokens: torch.Tensor,
- boundary_config: megatron.bridge.data.conversation_processing.AssistantMaskBoundaryConfig,
Build GLM-4.5V loss spans using a virtual final turn terminator.
- bridge.models.glm_vl.data.collate_fn.glm4v_collate_fn(
- examples: list,
- processor,
- *,
- visual_keys: object = None,
- min_pixels: int | None = None,
- max_pixels: int | None = None,
- sequence_length: int | None = None,
- pad_to_max_length: bool = False,
- pad_to_multiple_of: int = 128,
- enable_in_batch_packing: bool = False,
- in_batch_packing_pad_to_multiple_of: int = 1,
Collate function for GLM-4.5V model.
GLM-4.5V requires
mm_token_type_idsto distinguish image (1) and video (2) tokens from text (0) when computing 3D MRoPE positions. The processor returns this field by default (return_mm_token_type_ids=Truein Glm4vProcessor defaults). We wrap all visual tensors ā includingmm_token_type_idsā in- Class:
GenericVisualInputsso they flow throughvlm_step.pyto the model.