encode_with_gemma3

Encode text with Gemma3 for LTX-2

Description

Full pipeline for encoding text prompts using Gemma3 text encoder. Returns the raw stacked per-layer hidden states (embedding layer plus all transformer layers) for downstream connector modules, which handle normalization and projection themselves.

Usage

encode_with_gemma3(prompts, model = NULL, tokenizer = NULL,
                   max_sequence_length = 1024L, device = "cuda",
                   dtype = "float16", verbose = TRUE)

Arguments

  • prompts: Character vector of prompts.
  • model: Gemma3 text model (or path to load from).
  • tokenizer: Gemma3 tokenizer (or path to load from).
  • max_sequence_length: Integer. Maximum sequence length.
  • device: Character. Device for computation.
  • dtype: Character. Data type.
  • verbose: Logical. Print progress.

Value

List with prompt_embeds (raw stacked hidden states, shape [batch, seq_len, hidden_size, num_layers + 1]) and prompt_attention_mask.