Attention mechanisms from Every_Thing_About_Transformer, as an importable library
Project description
transformer-lib
Attention mechanisms from Every_Thing_About_Transformer, as an importable Python library.
Installation
pip install -e .
Usage
from transformer_lib import MultiHeadAttention
import torch
mha = MultiHeadAttention(embed_dim=512, num_heads=8)
x = torch.randn(2, 10, 512)
out = mha(x, x, x)
Available Modules
| Module | Description |
|---|---|
SelfAttention |
Basic scaled dot-product self-attention |
MultiHeadAttention |
Multi-head attention with separate Q/K/V projections |
CausalAttention |
Multi-head with lower-triangular causal mask |
CrossAttention |
Encoder-decoder cross-attention with self-attention pre-step |
GlobalAttention |
Additive (Bahdanau-style) alignment scoring |
MultiQueryAttention |
Shared K/V across all heads |
GroupedQueryAttention |
Groups of query heads sharing K/V (GQA) |
MultiHeadLatentAttention |
Latent-space compression for keys/values |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
transformer_lib-0.1.0.tar.gz
(6.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file transformer_lib-0.1.0.tar.gz.
File metadata
- Download URL: transformer_lib-0.1.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aaa0f4b2bfd1bceab6d0a3d77306fe6325ed5de692d36237a7e01bd3253a3734
|
|
| MD5 |
12a4022ca99d65f84581e78d1c6f1d4c
|
|
| BLAKE2b-256 |
45bcacf7bb5f4947d12704a08fb63666145cf044866111f6138cda9fd70f104e
|
File details
Details for the file transformer_lib-0.1.0-py3-none-any.whl.
File metadata
- Download URL: transformer_lib-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0f1c563485d20d57090ec6f0018ccbf7142453668ca89e13296d038f38df103
|
|
| MD5 |
1299733200c39cab912f8ea0557b0d22
|
|
| BLAKE2b-256 |
18a95c9dc5ab70d93b42d19fb5a998d86deb4fde3f49e5678f7c151c090a758e
|