Expand description
Image, video and audio attachments: decoding (files through oxideav with the media feature,
decoded oxideav frames with the oxideav feature), encoding with the vision / audio towers
into soft tokens, and mapping them onto the placeholder tokens of the prompt. Gemma 4 takes
images, videos (frames as images with mm:ss timestamps) and audio; Qwen3.5 / 3.6 / 3.8 take
images and videos (temporal patches of two frames with <t seconds> timestamps, placed with
M-RoPE).
Structs§
- MmFeature
- Soft tokens for one attachment: placeholder token id and
[n, hidden]embeddings. - MmFrames
- Decoded attachments (the
oxideavfeature) forprepare_frames: each kind goes after the files of the same kind inMmRequest. - MmRequest
- Attachments for one prompt.
Functions§
- bind
- Prepares a prompt’s attachments for a prefill at the session’s current position: declares
the vision spans (Qwen M-RoPE) on
sessand returns the embedding overrides forgenerate::prefill. - decode_
images - Decodes encoded images (PNG, JPEG, WebP, GIF, BMP; the
mediafeature). - encode_
images encode_rgb_imagesfor encoded images (PNG, JPEG, WebP, GIF, BMP bytes;mediafeature).- encode_
rgb_ images - Images for a Qwen3.5-family vision checkpoint in
model: per image, its placeholder text (<|vision_start|><|image_pad|>...<|vision_end|>, to place anywhere in a prompt) and its feature.max_soft_tokensas inMmRequest. For prompts that are not chat turns (typed decisions). - overrides
- Maps placeholder token positions in
idsto soft-token embeddings, in attachment order. - prepare
- Decodes and encodes all attachments. Returns the placeholder text to prepend to the user
message and the features in the same order. Files need the
mediafeature. - prepare_
frames preparewith decoded frames too, each kind after the files ofargs(theoxideavfeature; the files still needmedia).- vision_
spans - Qwen M-RoPE:
(position in ids, rows, cols)of each run of placeholder tokens (seeMmFeature::grids), to declare withQwenSession::add_vision_spanbefore the prefill.