lucidrains/perceiver-pytorch

Implementation of Perceiver, General Perception with Iterative Attention, in Pytorch

What it solves

This project provides a PyTorch implementation of the Perceiver architecture, which is designed to handle diverse types of data—such as images, video, or sequences—using a single, unified framework. It addresses the challenge of processing large or complex inputs by using a fixed-size set of "latent" variables to compress and reason about data, rather than processing every single input point directly.

How it works

The model uses an iterative attention mechanism. It takes raw input data and uses "cross-attention" to project it into a smaller, fixed-size set of latent vectors. These latents then process the information through multiple layers of self-attention. This approach allows the model to handle inputs of varying sizes and types while keeping the computational cost manageable. The library includes modules for basic perception, flexible input/output handling (Perceiver IO), and language modeling.

Who it’s for

This library is for researchers and developers working with deep learning who want to experiment with the Perceiver architecture. It is suitable for those building models that need to process structured data, images, or language, and who want a flexible, modular implementation that can be integrated into larger PyTorch projects.

Highlights

  • Implements the original Perceiver architecture for general perception.
  • Includes Perceiver IO for flexible input and output sequence lengths.
  • Provides a PerceiverLM module specifically for language modeling tasks.
  • Offers a modular PerceiverBlock for building custom neural network stacks.
  • Includes experimental support for bottom-up attention using Induced Set Attention Blocks.

Related

  • Project
  • Project
  • Dispatch
  • Project
  • Project