Skip to main content

Bidirectional Cross Attention

JAX implementation of lucidrains/bidirectional-cross-attention.

Installation

pip install bidirectional-cross-attention-jax

Usage

import jax
import jax.numpy as jnp
from bidirectional_cross_attention_jax import BidirectionalCrossAttention

key = jax.random.PRNGKey(0)
video = jax.random.normal(key, (1, 4096, 512))
audio = jax.random.normal(key, (1, 8192, 386))

video_mask = jnp.ones((1, 4096), dtype=jnp.bool_)
audio_mask = jnp.ones((1, 8192), dtype=jnp.bool_)

joint_cross_attn = BidirectionalCrossAttention(
    dim = 512,
    heads = 8,
    dim_head = 64,
    context_dim = 386
)

init = joint_cross_attn.init(key, video, audio)
video_out, audio_out = joint_cross_attn.apply(
    init,
    video,
    audio,
    mask = video_mask,
    context_mask = audio_mask
)

# attended output should have the same shape as input

assert video_out.shape == video.shape
assert audio_out.shape == audio.shape

Citations

@article{Hiller2024PerceivingLS,
    title   = {Perceiving Longer Sequences With Bi-Directional Cross-Attention Transformers},
    author  = {Markus Hiller and Krista A. Ehinger and Tom Drummond},
    journal = {ArXiv},
    year    = {2024},
    volume  = {abs/2402.12138},
    url     = {https://api.semanticscholar.org/CorpusID:267751060}
}

Metadata

Release files for bidirectional-cross-attention-jax 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bidirectional-cross-attention-jax 0.0.2
File Size Uploaded Provenance Actions
bidirectional_cross_attention_jax-0.0.2.tar.gz 3.4 kB Without provenance Details for bidirectional_cross_attention_jax-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bidirectional-cross-attention-jax 0.0.2
File Interpreter ABI Platform Actions
bidirectional_cross_attention_jax-0.0.2-py3-none-any.whl Python 3 none any Details for bidirectional_cross_attention_jax-0.0.2-py3-none-any.whl

Total release size: 7.7 kB

Release files / bidirectional_cross_attention_jax-0.0.2.tar.gz

Download URL bidirectional_cross_attention_jax-0.0.2.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0314a3dbbd8392cd23fb3d49333cde432d6e9129134dc0c6190e83f6655450fa
BLAKE2b-256 checksum
How to use checksums
ef8795a567e185e5e2d1a8a394beb56103921243b7eee0dca4c4894747a4d977
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.3

Release files / bidirectional_cross_attention_jax-0.0.2-py3-none-any.whl

Download URL bidirectional_cross_attention_jax-0.0.2-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
682f0d321a3924e461c7fa22ac05cb6c564b386c65d7ce9261c91efdf5c9a668
BLAKE2b-256 checksum
How to use checksums
1e98e934230779fce5e5bf62eb5adb0555699700425299b66c921e4a9bcae350
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.3

Security for bidirectional-cross-attention-jax 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page