nemo_automodel.components.models.kimi_k3.processing
nemo_automodel.components.models.kimi_k3.processing
Local K3 image processing and the standard Hugging Face processor contract.
Module Contents
Classes
Functions
Data
API
Bases: BaseImageProcessor
Checkpoint-compatible RGB patches, including resize and alpha compositing.
Parameters:
Image settings from the checkpoint’s preprocessor_config.json.
Hugging Face image-processor metadata.
Expose spatial merging to the native media-token validator.
Apply the checkpoint’s background to transparent PIL images.
Resize, pad, normalize and flatten images in input order.
Parameters:
PIL images, local paths, raw bytes, or data URLs.
Hugging Face output tensor format.
Hugging Face preprocessing options; K3 uses checkpoint settings.
Returns: BatchFeature
FP32 tensor of shape [patches, 3, patch_size, patch_size], with images and their patches in row-major order.
Bases: ProcessorMixin
Local image/text processor returning expanded tokens before native packing.
Parameters:
Local checkpoint-compatible image processor.
Existing native K3 tokenizer and XTML chat encoder.
Return text and media fields consumed by the native model and pipeline collator.
Process standard text/images inputs with expansion before truncation.
Parameters:
Rendered prompts containing K3 image placeholders.
Images flattened in prompt order.
Unsupported; supplying videos raises ValueError.
Tokenizer padding policy.
Whether to truncate text to max_length; removing image tokens raises.
Maximum token length after image expansion.
Hugging Face output tensor format.
Tokenizer options. do_sample_frames is unused for image inputs.
Returns: BatchFeature
The text/media tensor layouts documented by _finish.
Pad text and attach ordered media without shifting labels.
Parameters:
Token and optional assistant-mask lists, one per document.
FP32 pixel_values [patches, 3, patch_size, patch_size] and integer image_grid_thw [images, 3].
Number of images owned by each document.
Tokenizer padding policy.
Hugging Face output format.
Target length for max_length padding.
Returns: BatchFeature
BatchFeature with input_ids/attention_mask/optional assistant_masks
Build expanded placeholders from original resolutions and processed grids.
Parameters:
Loaded PIL images in document order.
image_grid_thw tensor [images, 3] and pixel_values tensor [patches, 3, patch_size, patch_size] from the local image processor.
Returns: list[str]
One fully expanded textual image span per image.
Render native XTML chats and optionally process images and assistant masks.
Parameters:
One chat or a batch, with loaded images in content items.
Return tokens and processed images instead of rendered text.
Include masks and media with the token IDs.
Hugging Face output tensor format.
Tokenizer padding policy.
Truncate after image expansion; incomplete image spans are rejected.
Token limit or max_length padding target.
Append the native assistant generation prefix.
Mark assistant tokens before padding.
Image preprocessing options supplied by the VLM data pipeline.
Native K3 chat-rendering options, including tools and thinking settings.
Returns: str | list[str] | list[int] | list[list[int]] | torch.Tensor | BatchFeature
Rendered text, token IDs, or BatchFeature with the layouts documented by _finish.
Load local implementations using checkpoint data, without executing checkpoint Python.
Bases: typing.TypedDict
Bases: typing.TypedDict
Load an image without discarding alpha before the configured resize stage.