Skip to content
1 min read · 232 words

Interface: TransformersJsGenerationProcessor() ​

Defined in: src/batteries/generation/transformers_js/types.ts:114

Structural duck-type of VLChatProcessor (or AutoProcessor.from_pretrained's resolved instance) — a callable that builds the input_ids/attention_mask/image-mask tensors generate_images expects, plus the model's fixed per-image token budget it exposes after construction.

Remarks ​

Verified against the installed @huggingface/transformers source (src/models/janus/processing_janus.js): _call(conversation, { images, chat_template }) returns { input_ids, attention_mask, images_seq_mask, images_emb_mask, ... }; num_image_tokens is read off this.config.num_image_tokens at construction (the fixed per-image token budget the official model-card example forwards as both min_new_tokens and max_new_tokens).

ts
TransformersJsGenerationProcessor(conversation: {
  content: string;
  role: string;
}[], options?: {
  chat_template?: string;
}): Promise<Record<string, unknown>>;

Defined in: src/batteries/generation/transformers_js/types.ts:115

Structural duck-type of VLChatProcessor (or AutoProcessor.from_pretrained's resolved instance) — a callable that builds the input_ids/attention_mask/image-mask tensors generate_images expects, plus the model's fixed per-image token budget it exposes after construction.

Parameters ​

ParameterType
conversation{ content: string; role: string; }[]
options?{ chat_template?: string; }
options.chat_template?string

Returns ​

Promise<Record<string, unknown>>

Remarks ​

Verified against the installed @huggingface/transformers source (src/models/janus/processing_janus.js): _call(conversation, { images, chat_template }) returns { input_ids, attention_mask, images_seq_mask, images_emb_mask, ... }; num_image_tokens is read off this.config.num_image_tokens at construction (the fixed per-image token budget the official model-card example forwards as both min_new_tokens and max_new_tokens).

Properties ​

PropertyTypeDescriptionDefined in
num_image_tokens?numberThe model's fixed per-image token budget (config.num_image_tokens).src/batteries/generation/transformers_js/types.ts:120