Kosmos-2 patch14-224

Click a block to read its description, or select it with Tab and Enter.

Kosmos-2 patch14-224Grounded entity generation. Image 224 × 224; native Transformers image-to-text projection and decoder.LibreYOLOKosmos-2 patch14-224Grounded entity generation. Image 224 × 224; native Transformers image-to-text projection and decoder.Vision encoderImage tensor1 × 3 × 224 × 224Conv2d patch embedding3 to 1024; kernel14, stride14; no biasPrepend learned CLS257 × 1024 including 256 patchesAdd learned absolute positions257 positions; LayerNorm1024Vision transformer layers24 layers; 16 heads; head width64Post LayerNorm on all tokens257 × 1024L2 normalize each tokenDivide by channel-vector normLatent-query image projectionLinear visual features1024 to 2048Learned latent queries64 × 2048Concat features and queries321 × 2048; source for K and VCross-attention projectionQ=64 latent queries; K/V=321 tokensImage embedding sequence64 × 2048Embed prompt token IDsVocabulary65037; width2048Replace image-token placeholdersInsert64 image embeddingsScale by sqrt(2048); add positionsSinusoidal text positions; sequence L × 2048Language decoder and adapterCausal text transformer layers24 layers; 32 heads; head width64Final LayerNormL × 2048Tied vocabulary Linear2048 to65037; greedy token selectionProcessor decodes grounded entitiesNames, spans, normalized xyxy boxesMatch entity names to classesExact or substring match; requested classesFilter boxes and synthetic score1Reject nonpositive area; cap max_detResults.boxesScale x by original W and y by original HVision transformer layerInputS × 1024LayerNorm1024 channelsVision attention+LayerNorm1024 channelsVision MLP+OutputS × 1024S is the token count of this sublayer.Text transformer layerInputS × 2048LayerNorm2048 channelsText attention+LayerNorm2048 channelsText MLP+OutputS × 2048S is the token count of this sublayer.Vision attentionQ Linear1024 to 1024K Linear1024 to 1024V Linear1024 to 1024Q/K/V from the same normalized input.Split into heads16 heads × 64 channelsQ × transpose(K)Scale1/sqrt(64)Softmax over keysAll source tokensAttention weights × VPer-head weighted value sumConcat headsWidth1024Output Linear1024 to 1024Text attention with inner normalizationQ Linear2048 to 2048K Linear2048 to 2048V Linear2048 to 2048Q/K/V from the same normalized input.Split into heads32 heads × 64 channelsQ × transpose(K)Scale1/sqrt(64)Softmax over keysCausal/padding maskAttention weights × VPer-head weighted value sumConcat headsWidth2048Inner attention LayerNorm2048 channelsOutput Linear2048 to 2048Projection attentionQ Linear2048 to 2048K Linear2048 to 2048V Linear2048 to 2048Q: latent queries; K/V: features + queries.Split into heads32 heads × 64 channelsQ × transpose(K)Scale1/sqrt(64)Softmax over keysAll source tokensAttention weights × VPer-head weighted value sumConcat headsWidth2048Output Linear2048 to 2048Vision MLPInputS × 1024Linear1024 to 4096QuickGELUDown Linear4096 to 1024OutputS × 1024Residual addition is in the enclosing layer diagram.S is the token count of this sublayer.Text MLP with inner normalizationLinear2048 to8192GELUElementwise activationInner FFN LayerNorm8192 channelsLinear8192 to2048Execution and tensor scopeOne released 224-pixel configuration.Image tokens:257 before the projector.Image embeddings:64 after the projector.Text length L is runtime dependent.No language cross-attention layers.Image features enter via placeholders.Dropout disabled in inference.Cached generation reuses text K/V.QuickGELU: x × sigmoid(1.702 × x).Source/config and meta checks only.No pretrained output was evaluated.Sources: pinned microsoft/kosmos-2-patch14-224 config; native Transformers 5.16.1 Kosmos2 classes; LibreYOLO output adapter.Source: libreyolo/models/vlm/kosmos2.py; Transformers 5.16.1. Revision a4d0ecc9e17f.libreyolo.com