Skip to main content 홈 크리에이터 adu2021 skillxiv unicom-compressed-multimodal-representations
unicom-compressed-multimodal-representations Compress visual embeddings into compact latent space for unified image understanding and generation. Combines attention-based compression with diffusion decoding to bridge comprehension and generation through a shared semantic bottleneck.
설치로 이동 Skills Marketplace 커뮤니티가 만든 AI 스킬을 발견하고 탐색하세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/ADu2021/skillXiv --skill unicom-compressed-multimodal-representations명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
Zip 다운로드 다운로드 중... 이 저장소의 다른 Skills meaningful-kebab-case-name Convert arXiv papers into ready-to-use agent skills using category-aware extraction. First classifies the paper into one or more of 11 research categories, then applies a specialized extraction pipeline for each category — because different types of papers produce different types of usable knowledge. A single paper can yield multiple skills if it spans categories. Use this skill whenever the user wants to turn a paper into a skill, extract practical techniques from research, build a skill library from papers, convert arXiv papers into reusable agent instructions, or batch-process multiple papers into skills. Also trigger when someone asks about extracting actionable knowledge from papers, making research practical for LLM agents, or systematically converting academic contributions into structured agent capabilities.
action-quantization-behavior-cloning Establish regret bounds for behavior cloning with discretized actions combining statistical error and quantization error terms. Prove smoothness requirements for safe quantizer design, show that learning-based quantizers fail these requirements, and propose model-based augmentation to reduce error dependence from H² to H.
adaptive-lora-personalized-ranks Dynamically allocate LoRA ranks per-layer during fine-tuning instead of using fixed uniform ranks. Learn optimal rank for each layer and subject via variational framework with discretized exponential distribution, reducing memory footprint while maintaining fidelity and text-alignment.
name unicom-compressed-multimodal-representations title UniCom: Unified Multimodal Modeling via Compressed Continuous Semantic Representations version 0.0.2 engine skillxiv-v0.0.2-claude-opus-4.6 license MIT url https://arxiv.org/abs/2603.10702 keywords ["Multimodal","Compression","Semantic Representations","Generation","Understanding"] description Compress visual embeddings into compact latent space for unified image understanding and generation. Combines attention-based compression with diffusion decoding to bridge comprehension and generation through a shared semantic bottleneck.
Technique: Channel-Wise Visual Compression for Unified Multimodal Modeling
Multimodal models struggle with the fundamental tension: dense visual features enable fine-grained understanding, but high dimensionality is wasteful for generation. UniCom inverts this by compressing along the channel axis rather than spatially, maintaining spatial structure while reducing feature richness. This creates a unified semantic space for both understanding and generation tasks.
The key insight is that channel reduction is more effective than spatial downsampling—it preserves the spatial layout needed for tasks like visual grounding while compressing redundancy in feature representation.
Core Concept
UniCom operates through three stages:
Semantic Compression : Attention-based compressor reduces visual features from 1152-d to 64-d per spatial location
Transfusion Prediction : Single transformer processes interleaved text and compressed latents
Diffusion Reconstruction : Flow-matching decoder expands latents to pixels for generation
This architecture enables efficient bidirectional flow: text → latents (comprehension) and latents → pixels (generation), all within a single model.
Architecture Overview
Visual encoder : Standard ViT producing 1152-d features
Semantic compressor : Attention-based channel reduction module
Transfusion backbone : Unified transformer for text and latents
Latent predictor : Maps text to compressed representations
Diffusion decoder : Flow-matching model from latents to pixels
Joint optimizer : Reconstruction + perceptual loss for both tasks
Implementation Steps
Step 1: Attention-Based Semantic Compressor
Compress visual features while preserving semantic content via learned attention weighting.
import torch
import torch.nn as nn
class SemanticCompressor (nn.Module):
def __init__ (self, input_dim=1152 , output_dim=64 , num_heads=8 ):
super ().__init__()
.input_dim = input_dim
.output_dim = output_dim
.query = nn.Linear(input_dim, num_heads * output_dim)
.key = nn.Linear(input_dim, num_heads * output_dim)
.value = nn.Linear(input_dim, num_heads * output_dim)
.num_heads = num_heads
.head_dim = output_dim // num_heads
( ):
batch_size, height, width, feat_dim = visual_features.shape
features_flat = visual_features.reshape(- , feat_dim)
Q = .query(features_flat)
K = .key(features_flat)
V = .value(features_flat)
Q = Q.reshape(- , .num_heads, .head_dim)
K = K.reshape(- , .num_heads, .head_dim)
V = V.reshape(- , .num_heads, .head_dim)
scores = torch.bmm(Q, K.transpose( , )) / ( .head_dim ** )
attn = torch.softmax(scores, dim=- )
compressed = torch.bmm(attn, V)
compressed = compressed.reshape(- , .output_dim)
compressed = compressed.reshape(batch_size, height, width, .output_dim)
compressed
self
self
self
self
self
self
self
def
forward
self, visual_features
"""
visual_features: (batch, height, width, input_dim)
returns: (batch, height, width, output_dim)
"""
1
self
self
self
1
self
self
1
self
self
1
self
self
1
2
self
0.5
1
1
self
self
return
Step 2: Transfusion Processing Pipeline Interleave text and visual tokens for efficient unified processing.
class TransfusionBackbone (nn.Module):
def __init__ (self, vocab_size, latent_dim=64 , hidden_dim=768 , num_layers=12 ):
super ().__init__()
self .vocab_size = vocab_size
self .latent_dim = latent_dim
self .hidden_dim = hidden_dim
self .text_embedding = nn.Embedding(vocab_size, hidden_dim)
self .latent_projection = nn.Linear(latent_dim, hidden_dim)
self .position_embedding = nn.Embedding(2048 , hidden_dim)
self .transformer = nn.ModuleList([
nn.TransformerEncoderLayer(
d_model=hidden_dim,
nhead=8 ,
dim_feedforward=3072 ,
batch_first=True
)
for _ in range (num_layers)
])
def forward (self, text_ids, latent_features ):
"""
text_ids: (batch, text_len)
latent_features: (batch, num_latents, latent_dim) from compressor
"""
batch_size = text_ids.shape[0 ]
text_embed = self .text_embedding(text_ids)
latent_embed = self .latent_projection(latent_features)
mixed_sequence = torch.cat([text_embed, latent_embed], dim=1 )
positions = torch.arange(mixed_sequence.shape[1 ], device=mixed_sequence.device)
position_embed = self .position_embedding(positions.unsqueeze(0 ))
mixed_sequence = mixed_sequence + position_embed
for layer in self .transformer:
mixed_sequence = layer(mixed_sequence)
latent_portion = mixed_sequence[:, text_ids.shape[1 ]:]
return latent_portion
Step 3: Latent Predictor Head Predict compressed representations from text for generation tasks.
class LatentPredictorHead (nn.Module):
def __init__ (self, hidden_dim=768 , latent_dim=64 , num_latents=256 ):
super ().__init__()
self .hidden_dim = hidden_dim
self .latent_dim = latent_dim
self .num_latents = num_latents
self .predictor = nn.Sequential(
nn.Linear(hidden_dim, hidden_dim * 2 ),
nn.GELU(),
nn.Linear(hidden_dim * 2 , num_latents * latent_dim)
)
def forward (self, text_representations ):
"""
text_representations: (batch, hidden_dim)
returns: (batch, num_latents, latent_dim)
"""
predictions = self .predictor(text_representations)
predictions = predictions.reshape(-1 , self .num_latents, self .latent_dim)
return predictions
Step 4: Diffusion Decoder from Latents to Pixels Use flow matching to reconstruct images from compressed latents.
class DiffusionDecoder (nn.Module):
def __init__ (self, latent_dim=64 , num_diffusion_steps=50 ):
super ().__init__()
self .latent_dim = latent_dim
self .num_steps = num_diffusion_steps
self .net = nn.Sequential(
nn.Linear(latent_dim + 1 , 256 ),
nn.GELU(),
nn.Linear(256 , 512 ),
nn.GELU(),
nn.Linear(512 , 256 ),
nn.GELU(),
nn.Linear(256 , 3 )
)
def forward (self, compressed_latents, num_pixels ):
"""
Reconstruct pixels from compressed latents via iterative refinement.
"""
batch_size = compressed_latents.shape[0 ]
pixels = torch.randn(batch_size, num_pixels, 3 )
for t in range (self .num_steps):
time_embedding = torch.tensor(t / self .num_steps, dtype=torch.float32)
expanded_latents = self .upsample(compressed_latents, num_pixels)
residual = self .net(
torch.cat([expanded_latents, time_embedding.unsqueeze(0 ).unsqueeze(0 ).expand_as(expanded_latents)], dim=-1 )
)
pixels = pixels + residual
return torch.clamp(pixels, -1 , 1 )
def upsample (self, latents, target_size ):
"""Simple upsampling from latents to pixel space."""
return torch.nn.functional.interpolate(
latents.permute(0 , 2 , 1 ).unsqueeze(-1 ),
size=(target_size, 1 ),
mode='bilinear' ,
align_corners=False
).squeeze(-1 ).permute(0 , 2 , 1 )
Step 5: Joint Training with Reconstruction + Perceptual Loss Optimize compressor and decoder jointly to preserve semantics across both directions.
def train_step_unicom (
compressor,
transfusion,
predictor,
decoder,
images,
text_ids,
lpips_model,
optimizer
):
"""
Unified training combining reconstruction and generation.
"""
batch_size = images.shape[0 ]
visual_features = extract_visual_features(images)
compressed = compressor(visual_features)
text_embed = transfusion(text_ids, compressed)
predicted_latents = predictor(text_embed.mean(dim=1 ))
reconstructed = decoder(predicted_latents, images.shape[1 ] * images.shape[2 ])
recon_loss = torch.nn.functional.mse_loss(reconstructed, images)
perceptual_loss = lpips_model(reconstructed, images).mean()
total_loss = recon_loss + 0.1 * perceptual_loss
optimizer.zero_grad()
total_loss.backward()
optimizer.step()
return {
'total_loss' : total_loss.item(),
'recon_loss' : recon_loss.item(),
'perceptual_loss' : perceptual_loss.item()
}
Practical Guidance
Unified multimodal systems requiring both comprehension and generation
Scenarios where visual grounding (spatial structure) matters
Training efficiency is important (compressed representations reduce compute)
Applications needing consistent semantic space across tasks
Ultra-high-resolution generation (compression may lose fine details)
Tasks requiring extreme pixel accuracy
Single-task systems (overhead of unified architecture not justified)
output_dim (compression ratio) : 64 good default; 32-128 depending on semantic richness needed
num_heads in compressor : 8 standard; more heads for richer compression
diffusion_steps : 20-50 balance quality and speed
latent_dim vs num_latents : Trade spatial resolution vs feature dimensionality
Compression too aggressive, losing important visual details
Spatial downsampling instead of channel compression (harmful for grounding)
Diffusion decoder undertrained relative to compressor
Missing perceptual loss leading to semantically poor reconstructions
Reference