bridge.models.qwen_vl.modelling_qwen3_vl.token_classification#
Module Contents#
Classes#
Qwen3.5 VL model with replicated per-token classification postprocessing. |
Functions#
Project token logits and compute non-vocabulary-parallel loss when requested. |
Data#
API#
- bridge.models.qwen_vl.modelling_qwen3_vl.token_classification.TokenClassificationOutput: TypeAlias#
None
- bridge.models.qwen_vl.modelling_qwen3_vl.token_classification._token_classification_output_processor(
- *,
- hidden_states: torch.Tensor,
- output_layer: torch.nn.Module,
- output_weight: torch.Tensor | None,
- labels: torch.Tensor | None,
- runtime_gather_output: bool | None,
- **_: Any,
Project token logits and compute non-vocabulary-parallel loss when requested.
- class bridge.models.qwen_vl.modelling_qwen3_vl.token_classification.Qwen3VLForTokenClassification#
Bases:
megatron.bridge.models.qwen_vl.modelling_qwen3_vl.model.Qwen3VLModelQwen3.5 VL model with replicated per-token classification postprocessing.
- forward(
- input_ids: torch.Tensor | None,
- position_ids: torch.Tensor | None = None,
- attention_mask: torch.Tensor | None = None,
- labels: torch.Tensor | None = None,
- loss_mask: torch.Tensor | None = None,
- inference_params: megatron.core.InferenceParams | None = None,
- packed_seq_params: megatron.core.packed_seq_params.PackedSeqParams | None = None,
- extra_block_kwargs: dict[str, object] | None = None,
- pixel_values: torch.Tensor | None = None,
- pixel_values_videos: torch.Tensor | None = None,
- image_grid_thw: torch.Tensor | None = None,
- video_grid_thw: torch.Tensor | None = None,
- image_input_mask: torch.Tensor | None = None,
- video_input_mask: torch.Tensor | None = None,
- cp_img_num: list[int] | None = None,
- images_padded: list[bool] | None = None,
- inference_context: object | None = None,
- runtime_gather_output: bool | None = None,
- mm_token_type_ids: torch.Tensor | None = None,
- **kwargs: object,
Run the VLM and apply token-classification logits or per-token loss.
- Parameters:
input_ids – Input token IDs.
position_ids – Optional Qwen MRoPE position IDs.
attention_mask – Optional language-model attention mask.
labels – Optional token-classification labels.
loss_mask – Optional per-token supervision mask.
inference_params – Megatron inference state; currently unsupported by Qwen3VL.
packed_seq_params – Optional packed-sequence metadata.
extra_block_kwargs – Extra transformer-block keyword arguments.
pixel_values – Optional image patch values.
pixel_values_videos – Optional video patch values.
image_grid_thw – Image temporal/height/width grid metadata.
video_grid_thw – Video temporal/height/width grid metadata.
image_input_mask – Positions receiving image embeddings.
video_input_mask – Positions receiving video embeddings.
cp_img_num – Per-context-parallel-rank image counts.
images_padded – Whether individual images were padded.
inference_context – Compatibility placeholder for inference context.
runtime_gather_output – Runtime output-gather override.
mm_token_type_ids – Multimodal token type IDs retained for API compatibility.
**kwargs – Additional language-model keyword arguments.
- Returns:
Token logits or per-token losses; context-parallel and non-last-stage paths may return a loss-mask tuple or a stage-output dictionary.
- Raises:
ValueError – If a caller tries to override the reserved output processor.