Skip to main content

Modular transformer blocks built in PyTorch

Project description

🧱 Stackformer

Stackformer is a modular transformer-building framework written entirely in PyTorch. It is designed primarily for experimentation, providing various transformer blocks such as attention mechanisms, normalization layers, feed-forward networks, and a simple model architecture. The project is a work-in-progress with plans for further enhancements and expansions.


📖 About Me

My name is Gurumurthy, and I am a final-year Bachelor of Engineering student from India. I created this library as my own size project to showcase my skills and knowledge in deep learning and transformer architectures.

I am also interested and free to work with others on different projects for knowledge sharing and building connections.


🌟 Features

  • Multiple attention mechanisms including multi-head, group query, linear, local, and KV cache variants
  • Token embedding via tiktoken
  • Absolute and sinusoidal positional embeddings
  • Normalization layers like LayerNorm and RMSNorm
  • Several feed-forward network variants with activations such as ReLU, GELU, SiLU, LeakyReLU, and Sigmoid
  • A simple GPT-style transformer model implementation

📁 Project Structure

stackformer/
|-- modules/
| |-- tokenizer.py # Token embedding using tiktoken
| |-- position_embedding.py # Absolute and sinusoidal embeddings
| |-- Attention.py # Attention mechanisms
| |-- Normalization.py # LayerNorm and RMSNorm
| |-- Feed_forward.py # Feed-forward layers with various activations
|-- models/
| -- GPT_2.py # GPT-style transformer stack model
-- trainer.py # Training loop and utilities \


💻 Installation

✅ Method 1: Install from PyPI:

pip install Stackformer
import stackformer

🔧 Method 2: Clone the repository:

git clone https://github.com/Gurumurthy30/Stackformer
cd Stackformer
pip install -e .

🚀 Future Plans

Currently, I am working on improving and optimizing the existing components while fixing known bugs and issues. After stabilizing the current modules, I plan to add more advanced blocks like Mixture of Experts (MoE), mask handling, and other essential transformer components. Eventually, I will expand the library by developing more comprehensive model architectures.

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

stackformer-0.1.3.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stackformer-0.1.3-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file stackformer-0.1.3.tar.gz.

File metadata

  • Download URL: stackformer-0.1.3.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for stackformer-0.1.3.tar.gz
Algorithm Hash digest
SHA256 14007b016effbaea39aa3f9321f52d07c398b4b921aaf80dc5b699abc87bae28
MD5 38aceefb8dfbc418e1fbf31d75d8cf41
BLAKE2b-256 141e6ca4db153028c7a628ca6c90458ae4b519e22482ae77495fc964d4498f67

See more details on using hashes here.

File details

Details for the file stackformer-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: stackformer-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for stackformer-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d45828d7576a28af9ddd01f35b0428f1b8f54b04761b68a9667b704dbb6c591a
MD5 b5cc862e73b928873534d3d3931abf6e
BLAKE2b-256 4628724d06faf4e54750b5d75bebf5adb89cf4693e6914efe961054be12ff712

See more details on using hashes here.

Supported by

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