qwenvl 中的attention pool如何理解,其实这就是一个概念的问题
看qwenvl的huggingface的代码的时候,发现代码里有一个Resampler 以及attn_pool,这和之前理解的连接池 线程池 表示资源复用的意思不太一样,查了一下:
注意这里的pool 和 线程池 连接池里面的pool 不一样:
-
深度学习中的池化:池化在深度学习中主要指通过滑动窗口对特征图进行下采样,提取最重要的特征,减少计算量并提高鲁棒性。它的目的是压缩数据的空间尺寸,减少不必要的信息。
-
传统池化(连接池、内存池等):资源池化指的是通过复用已有资源来减少重复的创建和销毁操作,提高系统性能。
由于这里面是采用cross attention 进行压缩的,因此就叫attention pool了
查看qwenvl的文章,里面有一个
Position-aware Vision-Language Adapter:
为了缓解长图像特征序列带来的效率问题,Qwen-VL引入了一个压缩图像特征的视觉语言适配器。该适配器包括一个随机初始化的单层交叉注意模块。该模块使用一组可训练向量(Embeddings)作为query向量,并使用视觉编码器的图像特征作为交叉注意操作的关键。该机制将视觉特征序列压缩为256的固定长度。
下面是文章原文:
Position-aware Vision-Language Adapter: To alleviate the efficiency issues arising from long image feature sequences, Qwen-VL introduces a vision-language adapter that compresses the image features. This adapter comprises a single-layer cross-attention module initialized randomly. The module uses a group of trainable vectors (Embeddings) as query vectors and the image features from the visual encoder as keys for crossattention operations. This mechanism compresses the visual feature sequence to a fixed length of 256.
下面是qwenvl的架构图,Vision-Language Adapter 就是里面cross attention的部分。