Flowing Seamlessly Across Text and Image Tokens

1. FlowTok: Flowing Seamlessly Across Text and Image Tokens

FlowTok presents a revolutionary approach to cross-modal generation by enabling direct flow matching between text and image modalities. Unlike conventional methods that treat text as a conditioning signal for image generation, FlowTok projects both modalities into a unified, compact 1D latent space.

1.1. Direct Flow Between Modalities

1.1.1. Unified Latent Space Design

FlowTok encodes both text and images into compact 1D tokens with shape 77×16:

Text Processing:

  • CLIP text encoder extracts initial embeddings 𝑇init𝑁×𝐶
  • Text projector maps to latent space: 𝑍𝑇𝑁×𝐷
  • Gaussian distribution modeling with KL regularization

Image Processing:

  • Enhanced TA-TiTok with RoPE and SwiGLU FFN
  • Direct encoding to 𝑍𝐼𝐾×𝐷 where 𝐾=𝑁=77
  • Maintains semantic information in compact representation

1.1.2. Flow Matching Framework

The flow matching objective learns direct transformation:

𝑋 𝑡 = ( 1 𝑡 ) 𝑋 + 𝑡 𝑁

where the velocity field is:

𝑉 𝑡 = 𝑑 𝑋 𝑡 𝑑 𝑡 = 𝑁 𝑋

Unlike standard flow matching that uses noise as source distribution, FlowTok treats text tokens 𝑍𝑇 and image tokens 𝑍𝐼 as both source and target distributions.

1.1.3. Semantic Preservation

To prevent information loss during dimensionality reduction, FlowTok introduces text alignment loss:

ℒ︀ align = CE ( logits TZ , labels ) + CE ( logits ZT , labels ) 2

where:

logits TZ = exp ( 𝜏 ) × ( 𝑇 𝑃 × 𝑍 𝑇 𝑇 ) logits ZT = exp ( 𝜏 ) × ( 𝑍 𝑇 × 𝑇 𝑃 𝑇 )

1.1.4. Training Objective

Complete loss function:

ℒ︀ = ℒ︀ fm + 𝛾 1 ℒ︀ kld + 𝛾 2 ℒ︀ align

where:

  • ℒ︀fm: Flow matching loss
  • ℒ︀kld: KL divergence regularization
  • ℒ︀align: Text alignment preservation

References

  1. FlowTok: Flowing Seamlessly Across Text and Image Tokens