Skip to main content

Simple implementations of attention modules adapted for the biological data domain

Project description

bio-attention

Simple implementations of attention modules adapted for the biological data domain.

PyPi Version GitHub license Documentation

Why use this package?

There are already plenty of excellent implementations out there that allow you to test out the countless variants of transformers [1], [2]. This repository primarily separates itself from the previous in that it contains positional encodings schemes adapted to allow for irregularly-spaced positions in sequences. This is useful in, for example: (1) the mass spectral domain (proteomics, metabolomics, ...), where transformers operate on sets of peaks, (2) any kind of (epi)genomic data that measures sites of interests on the genome that are irregularly-spaced (such as WGBS/CpG sites, ATAC-seq/chromatin accessibility, ...). Additionally, the attention definitions in this repository are compatible with multi-dimensional data, such as the MSAs used in some protein language models, and AlphaFold.

Install

Since PyTorch is a dependency of bio-attention, we recommend installing PyTorch independently first, as your system may require a specific version (e.g. CUDA drivers).

After PyTorch installation, bio-attention can be installed using pip

pip install bio-attention

Note

This package used to be a 2D sliding window attention package. The current formulation of the package does not allow for this type of attention anymore (instead, I recommend to perform axial attention with alternating sliding window attention across one axis and full self-attention across the other). If you want to use 2D sliding window attention, check out the old version of this repo.

Usage

Package roadmap

  • Embedding layers
    • Continuous
    • Discrete
    • Binary
    • Bin
  • [~] Positional encoding schemes
    • Sinusoidal
    • Embedding
    • Continuous
    • Rotary
    • AliBi
    • DPB
    • XL
    • Test support for multi-dimensional inputs
  • [~] Attention modules
    • Vanilla
    • Windowed
    • Random
    • Performer
    • Encoder
    • Decoder
    • Cross
    • Support for multi-dim inputs
  • Add a warning if non-increasing positional indices are used with a decoder attention
  • Add docs clarifying that clf tokens are automatically accounted for if no pos is provided for them
  • Tests
  • Typing
  • Docs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bio_attention-0.1.15.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

bio_attention-0.1.15-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file bio_attention-0.1.15.tar.gz.

File metadata

  • Download URL: bio_attention-0.1.15.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for bio_attention-0.1.15.tar.gz
Algorithm Hash digest
SHA256 c69ba70e0e6e264f770128100c7e9a7eddf5b3808887da41018de59dc0a5b23f
MD5 4ae2c687bb44f4bb0907f9fb892f8d61
BLAKE2b-256 d22fe259dee5db7eb374e23c10118c9b981ce2fcbb44d093aa04f7ba764df8e9

See more details on using hashes here.

File details

Details for the file bio_attention-0.1.15-py3-none-any.whl.

File metadata

  • Download URL: bio_attention-0.1.15-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for bio_attention-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 62a88f5e776f75c2cac122fa739117a87bf9afb0fdfde933daf250d5a3c2767c
MD5 8f73cd0e8a8a76182beccafe107e203f
BLAKE2b-256 0971ca7099f37d02c4fcf74c178ec7c871608272ab4bca431c072c3cbd354e6e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page