Native CLIP Text Encoder
Description
Native R torch implementation of CLIP text encoder. Replaces TorchScript for better GPU compatibility.
Usage
text_encoder_native(vocab_size = 49408, context_length = 77, embed_dim = 768,
num_layers = 12, num_heads = 12, mlp_dim = 3072,
apply_final_ln = TRUE, gelu_type = "tanh")
Arguments
vocab_size: Vocabulary size (default 49408)context_length: Maximum sequence length (default 77)embed_dim: Embedding dimensionnum_layers: Number of transformer layersnum_heads: Number of attention headsmlp_dim: MLP hidden dimensionapply_final_ln: Whether to apply final layer norm (default TRUE). Set to FALSE to match TorchScript exports that don’t include final LN.gelu_type: GELU variant: “tanh” (matches the TorchScript exports), “quick” (HF CLIP ViT-L, used by FLUX), or “exact”
Value
An nn_module representing the text encoder