Lecture Note: Structured Representations & Reasoning

11-777 Multimodal Machine Learning CMU Fall 2023
Instructor: Dr. Louis-Philippe Morency | Co-lecturer: Dr. Paul Pu Liang
Author: Yi-Jing Sie

Overview

This post goes beyond sequences for representation learning and reasoning.
The multimodal Transformer models discussed in the previous 2 posts, Multimodal Transformers -part 1 and Multimodal Transformers -part 2, all share one common characteristic: they all started out processing multimodal inputs as a flat sequence of token embeddings, , allowing inputs from different modalities to attend to one another simultaneously. However, this also prompts the question whether every element in a multimodal sequence really needs to attend to every other one.

This post discusses 3 types of hierarchical structures: graph structure, tree structure, and modular structure, exploring how they build domain knowledge directly into the model, using tools such as graph neural networks, syntactic parse trees, and neural module networks.

Graph Structure - Representation

Graphs naturally arise in many real-world domains, such as social networks, economic networks, biomedical networks, and web networks. This section focuses on representation learning on undirected graphs.

Supervised vs. Unsupervised Graph Representation Learning

  • In the supervised setting: Make use of labels associated with some or all of the nodes in order to optimize the embeddings.
  • In the unsupervised setting: Learn an embedding space where the similarity between two nodes is approximated by the dot product of their learned embedding vectors, i.e. $\text{similarity}(u, v) \approx z_v^T z_u$, where $z_u$ and $z_v$ are embeddings of node $u$ and node $v$, respectively.

Graph Neural Networks - Node Representations

Formally, a graph $G$ is described by a set of vertices $V$, a binary adjacency matrix $A$, a matrix of node features $X$, and an optional vector of node labels $Y$. The key idea behind Neighborhood-aggregation Encoder Algorithm for learning node representations in an undirected graph neural network is to recursively build each node's embedding from its local neighborhood. In this way, each node defines its own computation graph for learning its embedding.

Grid Image

Aggregator Functions

  • Average pooling (Scarselli et al., 2005): averages the neighbors' representations from the previous layer and combines that with the node's own previous representation, using separate weight matrices for neighbors and for the node itself.
  • Graph Convolution Network (Kipf et al., 2017) : applies a different normalization factor to each neighbor node based on the number of neighbors it has.
  • Graph Attention Network (Velickovic et al., 2018): adds attention weights between the target node and each of its neighbors to scale their respective normalized representations.
Grid Image

These node embeddings can then be trained end-to-end for a supervised classification task, where the loss is computed as the sum of the cross-entropy losses between each node's output embedding, passed through a linear layer, and its corresponding ground-truth class label

Grid Image

Tree Structure - Visual Grounding

Language also carries its own built-in structure in the form of syntax, and that structure can guide multimodal reasoning directly. Learning to Compose and Reason with Language Tree Structures for Visual Grounding proposes Recursive Grounding Tree (RvG-TREE) to jointly process a sentence and an image for visual grounding tasks, which aim to localize the region in the image referred to by a natural language sentence.

For natural language input, such as "skis of man in red jacket" , the model filters out all the determiners such as “a, an, another, any, both, each, either, those, that” in the sentence and then learns to compose a binary tree over the remaining terms.
For visual input, the model uses a region-based object detector to generate region proposals from the image.
Finally, the nodes of the syntax binary tree are recursively grounded with the proposed image regions. This allows the model to ground language in an image by following the sentence's syntax structure rather than its raw word order.

Grid Image

Modular Structure - Reasoning

A third way to move beyond flat sequences is to treat reasoning itself as a small, composable program. Neural Module Networks is an approach for Visual Question Answering (VQA) tasks that uses a semantic parser tool to parse a natural language question and dynamically construct a deep network composed of reusable modules, such as an attention module attend[.] and a classification module classify[.].
For example, the question "What color is the cat?" may be mapped to the network layout classify[color](attend[cat]) by the semantic parser.

The constructed Neural Module Network (NMN) outputs a distribution over labels. In addition, the model contains a separate but jointly trained LSTM that also processes the question and predicts a distribution over labels. The LSTM complements NMN by capturing the information that may get lost when the question is overly simplified by the semantic parser.
Finally, to answer the question with the associated image, the model combines the outputs of the constructed NMN and the LSTM via geometric average of their probability distributions.

The following contains a subset of reusable modules proposed in the paper :

  • attend[c]: turn an image into an unnormalized attention heatmap for a specific concept. For example, attend[dog] highlights the region of the image that likely contains a dog .
  • classify[c]: takes an attention heatmap and the input image as inputs and maps them to a distribution over labels for a concept. For example, classify[color] returns a distribution over colors for the attended region.
  • combine[c]: takes two attention heatmaps and merges them into a single attention heat map depends on the given concept. For example, combine[and] should return an attention heatmap that only highlights the regions that are active in both inputs.

Module Network V2: End-to-End Learning

Learning to Reason: End-to-End Module Networks for Visual Question Answering builds on the idea in Neural Module Network (NMN) and proposes End-to-End Module Networks (N2NMNs), which learns to reason by directly predicting network layouts without relying on a semantic parser tool to parse the question first. Instead, N2NMNs use a layout policy implemented with an attentional Recurrent Neural Network to predict the network layout.
For example, the question "How many other things are there of the same size as the matte ball?" may be mapped to count(relocate(find())) by the layout policy.

Module Network V3: Neural-symbolic VQA

Neural-Symbolic VQA (NS-VQA) has three components:

  • Scene Parser (De-Renderer): consists of a Mask R-CNN and a ResNet-34 that de-renders the image into a structural scene representation. This representation is essentially a table of object attributes, such as size, shape, material, color, and position, for each segment proposal generated by Mask R-CNN.
  • Question Parser (Program Generator): is an attention-based sequence to sequence (seq2seq) model that maps a natural language question into a program describing a series of independent operations that can be executed on the structural scene representation.
  • Program Executor: executes a series of functional modules on the structural scene representation according to the program, and the final answer to the question is obtained from the output of the last module.
Grid Image

Module Networks V4: The Neural State Machine

"A state machine is a computational model that consists of a collection of states, which it iteratively traverses while reading a sequence of inputs, as determined by a transition function."

Learning by Abstraction: The Neural State Machine goes a step further by converting the whole image into a probabilistic scene graph, which specifies the objects and their relations within the given image. Each node represents one of the objects (e.g. cat, apple), while each edge corresponds to the relations (e.g. behind, holding). In addition, the model translates the question into a fixed-length sequence of reasoning instructions, which are fed into the neural state machine to guide its traversal of the scene graph toward the answer.

The neural state machine starts with a uniform initial attention distribution over the states and maintains an attention distribution across object nodes. At each reasoning step, it takes a reasoning instruction derived from the question and uses it, together with the current attention distribution, to identify the most relevant neighboring state as the next step. It then updates the attention distribution over the states to shift the model’s attention from the current node to the next node. Finally, a standard fully-connected softmax classifier uses the question representation and the machine’s final state representation to predict an answer .

Key Takeaways

Hierarchical Structures

Hierarchical structures build domain knowledge directly into the model, and there are three types of hierarchical structures: graph structure, tree structure, and modular structure.