news 2026/9/25 1:25:06

Qwen2.5VL的token演化规律探究

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Qwen2.5VL的token演化规律探究

UMAP可视化

Qwen2.5VL输入的input ids的token embedding的UMAP可视化:

其中type 0代表img token的占位符,由于都是同样的token,所以在空间距离上接近

type1代表system prompt的token

type2代表text token

Qwen2.5VL输入的input ids的token embedding+将img token的占位符换成经过ViT的实际img token的UMAP可视化:

可以看出此时img token和text token还是分为了明显不同的簇

在经过LLM之后得到的最后一层的hidden embedding中,UMAP显示此时的img token基本上和text token融合到了一起。其中type4代表img token之间的<|vision_start|>和<|vision_end|> token

直接将LLM得到的最后一层的hidden embedding经过mlp head并按照最大概率转换成ids,并用detokenizer解码得到text,发现视觉token基本上转化为了图像里面包含的物体的名字,这进一步说明其实最后visual token已经对齐到了text语意空间。

<|im_end|><|im_end|>A.. AI assistant<|im_end|><|im_end|> <|im_start|> <|im_end|>This<|im_end|><|im_end|>0 and<|im_end|>, and picture and,,边door,, <|im_end|> <|im_end|><|im_end|> wall and on and picture painting picture blue picture边,,,, curtains. door0 picture on, on and,,, on on,,,,, hotel on picture picture picture,, picture on,,,.,<|im_end|> room<|im_end|> room hotel onpicture picture picture, picture,边,,..,,<|im_end|> wall door wallpicture to picture边 on on black picture,,,, curtain,<|im_end|>,, to,,pictureful画 above,,,, curtain,, 0 door inowel,,,,picture, room,, curtain,<|im_end|>door2 door wall above bottom, above, picture picture,,,, curtainscur curtains, wall,,owel, of white on white andbox curtain towel. curtains shower6, door wall door to,, white towel on white white curtain curtain.. curtain5 door, to, white white on on,, , ,垂 door bathroom to, box box to on top white ,. curtain curtains curtains curtain7 wall knobskk knob and toilet paper toilet影 tan to curtain toilet <|im_end|><|im_end|><|im_end|>0画<|im_end|><|im_end|> picture wall框ful,, ,, curtains<|im_end|><|im_end|><|im_end|><|im_end|>,, to above, and pictureful room curtains curtains, curtains curtains curtains curtains<|im_end|> on0 picture picture above picture、 andpicture, door door curtains in. curtains curtain hotel on picture in and picture frame, frame black picture curtains picture to. hotel art hotel to wall door Picture picture picture picture边, board. curtains curtains curtains.<|im_end|> above, and wall 边 picture, and by picture frame,2 curtains white white curtains curtains room on picture picture picture colors , picture picture to, shower curtains. room to,ewire picture picture, picture,,s picture picture curtains curtains above picture, IH above mirrorpicture picture picture pictureicturegreen. painting on. between <|im_end|> curtains room in curtains to1 wall on picture Picture picture,, picture. room, on.. , toilet above to picture picture<|im_end|>边 picture picture frame to curtains curtains curtains curtains pattern, door, door ", to above to picture, to curtains abstract curtains tan , to door wall above picture below to wall toilet to to door cream doorcur. chain yellow tub0, abstract, toilet,,,, camera, curtains door curtains curtains curtains curtains shower<|im_start|><|im_end|><|im_end|>1 and<|im_end|><|im_end|>, room,,, wall,, white curtain head, curtains<|im_end|> wall to\ above aboveboard, yellow wall corner in of hook curtain on,, to0 curtain to, and wall curtain,, to curtains-ring for.,, curtain curtains picture on picture picture picture picture above directly above curtains. curtain, curtains above curtain curtains<|im_end|> wall showerpicture picture andpicture hotel above curtains, curtain,cur curtains,<|im_end|> wall to picture on picture, room shower, wallcur curtainscur. beigecur curtain,, to frame border frame picture frame边 board to curtaincurling drawnining, ,ish on frame picture,, picture picture picture picture curtain, above curtainsishish curtain) left toilet picture Picture,,, on框 bathroom curtaincurcur.ish bathroomcur picture wall on picture picture blue and, Picture on of yellow. above rings green to. door wall to picture , and painting to on of curtainsaw curtainsled curtain texture pattern curtain0 framedfulblue and and,picture and bathroom curtains cream rings, curtains , door door to picture colored画 picture, picture to area curtains to curtain cream curtains door, door0 black black frame<|im_end|> above frame picture to, curtains caramel curtains curtains shower to curtains door bathroom<|im_end|><|im_end|>0 and<|im_end|> pattern, picture picture and, curtains shower - curtains towel<|im_end|> <|im_end|>, wall picture picture, and,, on, curtains curtains curtains. curtains<|im_end|> , space0 picture picture,、, picture., curtains to curtain, shower , hotel door on picture picture green,),ful,. to curtain,,robe curtain door wall picture picture image, painting, picture above shower,垂 curtains<|im_end|> curtain, wall on above picture below on above black, to curtain curtains curtain. hotel toilet, curtain hotel, toilet picture black above边, on, curtain, side curtains.,,, toilet, paper to wall to to,,, room, to toilet, curtains to, door door above above, above to wall to to curtaincur side curtainsy,it curtain, hotel wall bathroom on white white towel , corner curtain. curtains. bathroom curtains white to, to, white white towel on tocur., curtains curtain The by,,iler color to white on towel on on to to, draped yellow back1 bath bathroom to white white on on toilet cover to curtain. to. curtains curtains� tub1 door,, and on of, Ни curtains curtain toilet curtains curtain curtains tub curtainpicture<|im_end|><|im_end|> and<|im_end|> picture ,,, beigeaint 前 curtain,,<|im_end|> wall hotel color toilet, Holidaycur room curtains curtain curtains ,距,, toilet<|im_end|> and to on to single ,. to式. curtain vanity <|im_end|> paper w on on on onower, to式ish. up隔 stall, dooruters on on bath towel white, to curtain$$$ishuum curtains curtain tubish, wall to white on on on on shape,.igeuring curtains., on to, side, of cup on white toilet,右侧. curtains curtain垂. tubr tub, cupto, on silver to toilet room<|im_end|> stall room<|im_end|><|im_end|>, to ,, other silver, toilet white bowl, to right curtain hotelyc2.ush tub,, paper silver stall paper to to to to side curtains.. shower tocur, tub. paper paper bin to white to toilet to to tocur curtain tub tub curtain tub tub bin bin box to and curtains toilet toilet<|im_end|> seat toilet curtains, bathtub tub to-bottom, can bin trash left white to toilet tub toilet to white side shower垂 tub tubbat bathtub7 trash trash floor white lid toilet toilet door厕 toilet toilet curtains tub bathtub in-bottom bathtub bathroom<|im_end|><|im_end|> toilet on,,, curtains tub curtain caramel<|im_end|> 隔塑<|im_end|>室<|im_end|> towel on towel, on top,黄色纹 curtain curtainiped动 tub tub tub,<|im_end|><|im_end|> toilet toilet white tù tà curtains to curtain 隔 curtain tub bathtub in tub),) toilet toilet sil toilet tub curtain paper黄色 acc bathtub tubPicturehtub,,插, side tub white white垂.生 curtain.色 curtain curtain tub经济 end , to cover toilet, to to, curtain hotel drawn to curtainahu tub, tub wall bin in to tub lid curtain. shower bathtubow, tub, tub bin can pipe, stall to toilet , curtain bathtub tub tub , at can under to toilet lid lid hood bathtub lid curtains shower tub tub tub tub a at can can toto toilet to toilet bathtub bathtub toilet tub tub tub<|im_end|> tub bathtub can trash to. toilet lid toilet toilet<|im_end|> bowl curtain white on on tub.bat tub bin under hotel<|im_end|> c toilet toilet toilet lid wash on toiletwhite on by in bathtub p floor toilet floorestyle to<|im_end|> <|im_end|>. trash white towel on tubbat picture5地 door picture towel floor to<|im_end|>�单<|im_end|> floor<|im_end|>, on white on . tub standard<|im_end|><|im_end|> towel<|im_end|><|im_end|><|im_end|> box<|im_end|><|im_end|><|im_end|><|im_end|><|im_end|><|im_end|><|im_end|><|im_end|><|im_end|><|im_end|><|im_end|><|im_end|> detailed<|im_end|><|im_end|><|im_end|> object is<|im_end|><|im_end|><|im_end|><|im_end|><|im_end|>label",<|im_end|><|im_end|><|im_end|><|im_end|>D coordinates box<|im_end|> thebbox_3d".<|im_end|><|im_end|>3D coordinates box of is<|im_end|>:x,, y,, z_center, width_size, y_size, z_size, yaw, pitch, pitch]<|im_end|> <|im_start|><|im_end|>``````

对LLM的attention进行可视化

对attention进行可视化发现确实出现了attetnion sink的情况:

Qwen2.5VL 3B一共有36个layer

feature dim是2048,head数是16,每个head管128维的子向量

选择可视化Qwen2.5VL的第一个head的前100个token的attention map:

由于是自回归,存在causal attention的attention mask,因此非零的attention只会出现在对角线的左下角

可以观察到在某些维度确实出现了attention sink的情况。

但是最后由于token的数量过多(1k+以上),导致全局的attention map基本看不出东西

疑问:当token序列过长时会不会出现attention值过度平滑的情况?(attention的总和必须为1)

答案:其实在绝大多数情况下,由于softmax的存在,很多attention对应的值都是非常稀疏的,对于大多数token的attention基本都是0

第100个token对前100个token的causal attention的分布图(比较特殊):

绝大多数情况都是大部分attention的值都接近于0:

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/9/21 18:12:16

STM32CubeMX汉化环境下外设初始化代码生成解析

深入STM32CubeMX中文环境&#xff1a;外设初始化代码是如何“一键生成”的&#xff1f;你有没有经历过这样的场景&#xff1f;刚打开STM32参考手册&#xff0c;上千页的英文文档扑面而来&#xff0c;RCC_APB2ENR、GPIOx_MODER这些寄存器看得人头晕眼花。明明只是想点亮一个LED&…

作者头像 李华
网站建设 2026/9/22 12:05:05

苹果手机文件管理在测试与问题排查中的实际作用

在 iOS 生态里&#xff0c;苹果手机文件管理一直显得有些“低调”。 对普通用户来说&#xff0c;系统已经把文件藏得足够深&#xff1b; 对开发者来说&#xff0c;沙盒机制又让一切看起来井然有序。 但只要你真正参与过线上问题排查、测试回归&#xff0c;或者需要复现用户环境…

作者头像 李华
网站建设 2026/9/23 9:04:50

2025运维四大主流ITSM产品核心能力对比与选型建议

在数字化转型向纵深推进的 2025 年&#xff0c;IT 服务管理&#xff08;ITSM&#xff09;已从传统工单工具升级为连接 IT 运维与业务价值的核心枢纽。企业对 ITSM 的需求不再局限于流程流转&#xff0c;而是延伸到合规保障、生态协同、敏捷响应等多元维度。本文聚焦当前主流 IT…

作者头像 李华
网站建设 2026/9/9 3:57:52

跨平台上位机串口通信模块开发实战记录

跨平台上位机串口通信模块开发实战&#xff1a;从原理到落地的完整路径你有没有遇到过这样的场景&#xff1f;——在实验室里&#xff0c;你的Windows电脑能完美连接下位机读取数据&#xff1b;可客户一拿到Linux系统上运行&#xff0c;串口直接“失联”&#xff1b;或者macOS用…

作者头像 李华