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

Clone the repository and install in development mode:

git clone https://github.com/Gurumurthy30/Stackformer
cd transformers
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.0.tar.gz (10.8 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.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: stackformer-0.1.0.tar.gz
  • Upload date:
  • Size: 10.8 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.0.tar.gz
Algorithm Hash digest
SHA256 8fdc7d291dd1a83ebc06978e23a87820cbb17f65ac22acec2bc7a127c1d588a9
MD5 2b252d8a7813f73edab476a1b1b9ddf4
BLAKE2b-256 e9144f8de989ad2f9eaae10806d760f2b9b4441d3fddd64c24bb0d78c2a8295a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: stackformer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 53fa39f5d90169d4315de5ab86162e2255a5b338d7ee94248c7df849f6dea686
MD5 b575c0281df5ae09f07fb67ed2c4e954
BLAKE2b-256 99f3261a99624e2b161936fcc4db1879e6e50d3ed13e3b9104e7b297e28d5897

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