nemo_automodel.components.models.deepseek_v41.processing
nemo_automodel.components.models.deepseek_v41.processing
DeepSeek-V4.1 image sizing, row-major token spans, and standard chat processor.
Module Contents
Classes
Functions
Data
API
One image’s patches and placement in a padded text batch.
Bases: ProcessorMixin
Processor for V4.1 text and local image SFT, using the released chat mode.
Tool schemas/calls, reasoning traces, and internal task formatting must be
encoded with DeepSeek’s full encoder before calling this processor on text.
apply_chat_template rejects those fields instead of silently losing them.
Parameters:
Fast tokenizer containing the configured image placeholder.
Typed checkpoint configuration with image and vision settings.
Expand image placeholders and concatenate patches without pseudo token IDs.
Parameters:
Rendered prompt or prompts containing one image placeholder per image.
PIL images grouped per prompt, or one prompt’s flat image list.
"pt" for PyTorch token tensors or None for token lists.
False, True/"longest", or "max_length"; padding is on the right.
Whether max_length removes trailing text and complete trailing images.
Token limit after image expansion. Cutting through an image raises.
Hugging Face tokenizer keyword arguments.
Returns: BatchFeature
BatchFeature with input_ids/attention_mask/vision_token_types of shape
Render the standard-chat subset of DeepSeek’s released encoding.py.
Render standard chat-mode system/user/assistant messages and local images.
Parameters:
Hugging Face chat messages or batches thereof, using string content or ordered text/image content blocks.
Whether to expand images and tokenize the rendered prompts.
Whether tokenization returns the complete processor batch.
None or "pt" for the tokenization result.
Append the assistant header after a final user or mid-conversation system message, matching official chat mode.
Arguments forwarded to the image/token processor.
Hugging Face chat-template options. Non-chat modes and tools raise explicitly; pre-render them with the full official encoder.
Returns: str | list[str] | list[list[int]] | torch.Tensor | BatchFeature
Prompt string(s), token IDs [batch, sequence], or BatchFeature with
Load the checkpoint’s fast tokenizer and nested vision configuration.
Persist the model’s image settings alongside the tokenizer and processor.
Parameters:
Output directory for the Hugging Face artifacts.
Hugging Face ProcessorMixin save options.
Returns: list[str]
Processor artifact paths returned by ProcessorMixin.save_pretrained.
Bases: typing.TypedDict
Load the local/PIL/byte image forms emitted by the VLM datasets.
Apply the released aspect-preserving resize and exact row-major token budget.
Load, resize, normalize, and flatten one image into RGB patches.
Returns: torch.Tensor
BF16 patches of shape [vit_height * vit_width, 3, patch_size, patch_size]
Validate and partition processor tensors into ordered image inputs.
Parameters:
Tensor of shape [all_patches, 3, patch_size, patch_size], concatenated in batch-row then image-span order.
Integer tensor of shape [images, 2] storing ViT height and width for each image in the same order.
Integer tensor of shape [batch, sequence], with TEXT=-1 outside complete image spans and types 0 through 3 inside.
Configured spatial ratio mapping the ViT grid to the language model’s image rows and columns.
Returns: DeepseekV41ImageInput
Ordered image records. Each patches/types tensor is a read-only view