Hong Kong Chinese and Shanghai AI Lab released a unified framework for multimodal (12 types) learning: Meta-Transformer

Title: Meta-Transformer: A Unified Framework for Multimodal Learning
PDF: arxiv.org/pdf/2307.10…
Code: github.com/invictus717…

guide

Designing a unified network to handle various modalities such as natural language, 2D images, 3D point clouds, audio, video, time series, and tabular data is an extremely challenging task.

This paper proposes a framework named Meta-Transformer to perform multimodal perception without any pairwise multimodal training data using a frozen encoder. In Meta-Transformer, raw input data from various modalities are mapped to a shared token space and allow a subsequent encoder to extract high-level semantic features of the input data using frozen parameters. Meta-Transformer consists of three main components: a unified data tagger, a modality-sharing encoder, and a task-specific header for downstream tasks.

It is the first framework capable of unified learning across 12 different modalities without training on paired multimodal data. Experiments on different benchmarks demonstrate that the Meta-Transformer is capable of handling a wide range of tasks, including basic perception tasks (text, images, point clouds, audio, video), practical applications (X-ray, infrared, hyperspectral and inertial measurement unit IMU), and data mining tasks (graphs, tables, and time series). Meta-Transformer lays the foundation for unified multimodal intelligence development using Transformer.

introduction

The human brain serves as an inspiration for neural network models that can simultaneously process input from various senses (such as visual, auditory, and tactile signals). However, in deep learning, designing a unified network that can handle a wide range of data formats is a very complex task due to the significant modality gap.

Different data modalities present unique data patterns, for example, images present a high degree of information redundancy due to dense pixels, while natural language does not. However, 3D point clouds are sparsely distributed in 3D space, making them more susceptible to noise and difficult to represent. Audio spectrograms are time-varying, non-stationary data patterns composed of waveforms in the frequency domain. Video data consists of a sequence of image frames, giving it the unique ability to simultaneously capture spatial information and temporal dynamics. In graph data, nodes in the graph represent entities, and edges represent relationships between entities, modeling complex many-to-many relationships. Due to the significant differences between different data modalities, it is common practice to encode each modality individually using different network architectures.

The article points out that recently developed unified frameworks (Table 1 above, VLMO, OFA, and BEiT-3) improve the multimodal understanding ability of the network by performing large-scale multimodal pre-training on paired data, but they pay more attention to vision and language, and cannot share the entire encoder across modalities. Therefore, designing a unified framework that can exploit a shared modality parameter space to encode multiple data modalities remains a major challenge.

To achieve this goal, the authors propose a novel unified framework called Meta-Transformer, designed to process 12 different data modalities, including image, natural language, point cloud, audio spectrogram, video, infrared, hyperspectral, X-ray, IMU, tabular, graph and time series data. Meta-Transformer employs three simple yet effective components: modality experts to transform data into serialized tokens, modality-shared encoders to extract representations across modalities, and task-specific headers for downstream tasks. Specifically, the Meta-Transformer first transforms the multimodal data into a shared sequence of tokens, then extracts the representation using a parameter-frozen modality-shared encoder, and further adapts it by updating the parameters of the downstream task head and lightweight tokenizer to each task. This simple framework can efficiently learn task-specific and modality-generic representations.

作者在12个模态的各种基准测试上进行了大量实验,通过专门使用LAION-2B数据集的图像进行预训练,Meta-Transformer在处理多模态数据方面表现出色,在不同的多模态学习任务中始终优于现有方法。这些实验证明了Meta-Transformer在统一多模态学习方面的潜力。

方法

如上图2所示,Meta-Transformer由三个组件组成:一个将数据转化为序列的标记器,一个用于编码不同模态嵌入的模态通用编码器,以及用于执行下游预测的任务特定头部。

初步定义

将n个数据模态的输入空间表示为 X = { X 1 , X 2 , , X n } X = \{X_1, X_2, \ldots, X_n\} ,相应的标签空间为 Y = { Y 1 , Y 2 , , Y n } Y = \{Y_1, Y_2, \ldots, Y_n\} 。此外,我们假设对于每个模态 i i 都存在一个有效的参数空间 Θ i \Theta_i ,其中任何参数 θ i Θ i \theta_i \in \Theta_i 都可以用于处理来自该模态的数据 x i X i x_i \in X_i 。我们说,Meta-Transformer的本质是找到一个共享的参数 θ \theta^* ,满足以下条件:

θ Θ 1 Θ 2 Θ 3 Θ n \theta^* \in \Theta_1 \cap \Theta_2 \cap \Theta_3 \cap \ldots \cap \Theta_n \quad

并且假设共享的参数空间非空:

Θ 1 Θ 2 Θ 3 Θ n \Theta_1 \cap \Theta_2 \cap \Theta_3 \cap \ldots \cap \Theta_n \neq \emptyset \quad

多模态神经网络可以表示为统一的映射函数: F : x X y ^ Y F: x \in X \rightarrow \hat{y} \in Y ,其中 x x 是来自任何模态 { X 1 , X 2 , , X n } \{X_1, X_2, \ldots, X_n\} 的输入数据, y ^ \hat{y} 表示网络的预测结果。我们将实际标签表示为 y y ,多模态处理流程可以表示为:

在这个公式中, L ( y ^ , y ) L(\hat{y}, y) 代表预测值 y ^ \hat{y} 与实际标签 y y 之间的损失函数。Meta-Transformer的目标是通过优化参数 θ \theta^* 来最小化预测值与实际标签之间的损失,并同时保持多个模态之间的共享参数空间。这样,Meta-Transformer能够实现在多个数据模态上进行统一的学习和预测。

数据序列化Tokenization

那么如何对不同模态的数据(文本,图像,点云和音频等)转换为共享嵌入空间中的embedding呢?

自然语言

在处理文本数据时,作者采用了常见的做法,使用WordPiece嵌入,并使用了30,000个标记的词汇表。WordPiece将原始单词分割为子词。例如原始句子:"The supermarket is hosting a sale",在WordPiece中可能被转换为:"_The _super market _is _host ing _a _sale"。这里,单词"supermarket"被分成两个子词"_super"和"market",单词"hosting"被分成"host"和"ing",而其他单词保持不变。每个子词对应于词汇表中的一个唯一标记,然后通过词嵌入层将其投影到高维特征空间,从而将每个输入文本转换为一组令牌嵌入 x R n × D x \in \mathbb{R}^{n \times D} ,其中 n 是标记的数量, D 是嵌入的维度。

图像

为了处理2D图像,作者将图像 x R H × W × C x \in \mathbb{R}^{H \times W \times C} 重塑为一系列扁平化的2D图像块 x p R N s × ( S 2 C ) x_p \in \mathbb{R}^{N_s \times (S^2 \cdot C)} ,其中 (H, W) 表示原始图像的分辨率, C 表示通道数, S 表示图像块的大小, N s = H W S 2 N_s = \frac{{HW}}{{S^2}} 表示最终图像块的数量。然后,使用一个投影层将嵌入的维度投影为 D:

x I R C × H × W x I R N s × ( S 2 C ) x I R N s × D x_I \in \mathbb{R}^{C \times H \times W} \rightarrow x'_I \in \mathbb{R}^{N_s \times (S^2 \cdot C)} \rightarrow x''_I \in \mathbb{R}^{N_s \times D}

点云

为了利用transformers学习3D模式,作者将点云从原始输入空间转换为token embedding空间。点云X = \(x_i\)_{i=1}^P表示P个点的点云,其中 x i = ( p i , f i ) x_i = (p_i, f_i) p i R 3 p_i \in \mathbb{R}^3 表示第i个点的3D坐标, f i R c f_i \in \mathbb{R}^c 是第i个点的特征。通常, f i f_i 包含了视觉提示,比如颜色、视角、法线等。作者使用最远点采样(Farthest Point Sampling,FPS)操作,以固定的采样比例(1/4)对原始点云进行采样,然后使用K最近邻(K-Nearest Neighbor,KNN)方法对邻近点进行分组。在构建具有局部几何先验信息的组合集合的基础上,构建邻接矩阵,使用聚集操作得到来自K个子集的结构表示。最终,得到点云的embedding:

x P R P × ( 3 + c ) x P R P 4 × D 2 x P R P 16 × D x_P \in \mathbb{R}^{P \times (3+c)} \rightarrow x'_P \in \mathbb{R}^{\frac{P}{4} \times \frac{D}{2}} \rightarrow x''_P \in \mathbb{R}^{\frac{P}{16} \times D}

音频谱图

首先,对音频波形进行预处理,使用对数Mel滤波器组,然后采用汉明窗口对频率进行分割,将原始波形分割为 l = ( t t s ) l = \left(\frac{t}{t_s}\right) 维的滤波器组。随后,将频谱图从时间和频率维度划分为大小为 S S 的补丁。与图像不同,音频补丁(patches)在频谱图上是重叠的。作者选择将整个频谱图划分为 N s = 12 ( 100 t 16 10 ) N_s = 12\left(\frac{{100t - 16}}{{10}}\right) 个补丁,通过 S × S S \times S 卷积,然后将补丁展平为令牌token序列。最终,得到音频谱图的embedding:

x A R T × F x A R N s × S × S x A R ( N s D S 2 ) × D x_A \in \mathbb{R}^{T \times F} \rightarrow x'_A \in \mathbb{R}^{N_s \times S \times S} \rightarrow x''_A \in \mathbb{R}^{\left(\frac{N_s \cdot D}{S^2}\right) \times D}

通过将这些不同模态的数据转换为共同的token embedding space,Meta-Transformer便可以在多个数据模态上实现统一的学习和预测。

统一编码器

在将原始输入转换为token embedding space后,作者采用一个带有冻结参数的统一Transformer编码器来对来自不同模态的令牌嵌入序列进行编码。

预训练

作者使用ViT作为主干网络,并在LAION-2B数据集上进行对比学习的预训练,以增强通用令牌编码的能力。预训练之后,作者冻结主干网络的参数。此外,在文本理解方面,作者使用CLIP的预训练文本标记器,将句子分割为子词,并将子词转换为词嵌入。

模态不可知学习

作者在令牌嵌入序列的开头添加一个可学习的令牌 x C L S x_{CLS} ,而(x_{CLS})令牌的最终隐藏状态 z L 0 z^0_L 用作输入序列的摘要表示,通常用于执行识别任务。为了加强位置信息,作者将位置嵌入(embedding)引入到令牌嵌入中。考虑到我们将输入数据令牌化为1D嵌入,因此采用了标准的可学习的1D位置嵌入。此外,对于图像识别任务,采用更复杂的2D-aware位置嵌入并未观察到明显的性能改进。作者简单地将位置嵌入与内容嵌入进行逐元素加法操作,然后将得到的嵌入序列输入到编码器中。

Transformer编码器的深度为L,由多个堆叠的多头自注意力(MSA)层和MLP块组成。

特定任务头

在得到学习表示后,我们将这些表示送入特定任务头 h ( ; θ h ) h(\cdot; \theta_h) ,该头部主要由MLP组成,并根据不同的模态和任务而变化。Meta-Transformer的学习目标可以总结为:

其中, f ( ) f(\cdot) g ( ) g(\cdot) h ( ) h(\cdot) 分别表示标记器、主干网络和头部的函数。

在此公式中, y ^ \hat{y} 表示模型的预测输出, y y 是实际标签, θ \theta^* 表示要优化的参数, L ( y ^ , y ) L(\hat{y}, y) 是预测输出和真实标签之间的损失函数,目标是最小化损失函数,从而优化模型参数,使其能够更好地预测输出。整个学习过程是通过将输入数据 x x 经过tokenization得到 f ( x ) f(x) ,然后输入到主干网络 g ( ) g(\cdot) 中得到学习表示,最后通过特定任务头 h ( ; θ h ) h(\cdot; \theta_h) 对学习表示进行进一步处理,从而得到最终的预测输出 y ^ \hat{y}

实验结果

局限性

  1. 复杂性:Meta-Transformer需要处理令牌嵌入 ( E 1 , , E n ) (E_1,··· ,E_n) ,其计算复杂度为 O ( n 2 × D ) O(n^2 × D) 。高昂的内存成本和沉重的计算负担使其难以扩展。

  2. 方法论:与TimeSformer和Graphormer中的Axial Attention机制相比,Meta-Transformer缺乏时间和结构意识。这个限制可能会影响Meta-Transformer在涉及时间和结构建模起关键作用的任务中的整体性能,比如视频理解、视觉跟踪或社交网络预测等任务。

  3. 应用:Meta-Transformer主要在多模态感知方面展现其优势。关于它在跨模态生成方面的能力目前尚不清楚。作者将在未来的研究中继续探索这个问题。

结论

本文中,我们探索了纯Transformer在统一多模态学习方面的潜力,并突显了使用Transformer主干网络开发统一多模态智能的有希望趋势。在某种程度上,本文支持了Transformer在下一代网络中的主导地位。重要的是,卷积神经网络(CNNs)和多层感知机(MLPs)并没有被遗弃。它们在数据tokenization和表示投影中扮演着重要角色。 这个过程体现了神经网络中的继承规律以及人工智能的持续演进历程。

Guess you like

Origin juejin.im/post/7266368395786846262