Skip to main content

Transformer Implementations

License PyPi Version PyPi Downloads Package Status

Transformer Implementations and some examples with them

Implemented:

  • Vanilla Transformer
  • ViT - Vision Transformers
  • DeiT - Data efficient image Transformers
  • BERT - Bidirectional Encoder Representations from Transformers
  • GPT - Generative Pre-trained Transformer

Installation

PyPi

$ pip install transformer-implementations

or

python setup.py build
python setup.py install

Example

In notebooks directory there is a notebook on how to use each of these models for their intented use; such as image classification for Vision Transformer (ViT) and others. Check them out!

from transformer_package.models import ViT

image_size = 28 # Model Parameters
channel_size = 1
patch_size = 7
embed_size = 512
num_heads = 8
classes = 10
num_layers = 3
hidden_size = 256
dropout = 0.2

model = ViT(image_size, 
            channel_size, 
            patch_size, 
            embed_size, 
            num_heads, 
            classes, 
            num_layers, 
            hidden_size, 
            dropout=dropout).to(DEVICE)

prediction = model(image_tensor)

Language Translation

from "Attention is All You Need": https://arxiv.org/pdf/1706.03762.pdf

Models trained with Implementation:

Multi-class Image Classification with Vision Transformers (ViT)

from "An Image is Worth 16x16 words: Transformers for image recognition at scale": https://arxiv.org/pdf/2010.11929v1.pdf

Models trained with Implementation:

Note: ViT will not perform great on small datasets

Multi-class Image Classification with Data-efficient image Transformers (DeiT)

from "Training data-efficient image transformers & distillation through attention": https://arxiv.org/pdf/2012.12877v1.pdf

Models trained with Implementation:

Metadata

Release files for transformer-implementations 0.0.9

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

Source distribution (sdist)

Source distribution for transformer-implementations 0.0.9
File Size Uploaded
transformer_implementations-0.0.9.tar.gz 7.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for transformer-implementations 0.0.9
File Interpreter ABI Platform
transformer_implementations-0.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 17.1 kB

Release files / transformer_implementations-0.0.9.tar.gz

Download URL transformer_implementations-0.0.9.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6d5a72d4b34646bd9c42b1642bded6f26c48a4c10e2cf40fd196179e40062aa4
BLAKE2b-256 checksum
How to use checksums
c64d6cdb70e02fe41041c7bf2727c42284aa610b73676ed7a7e9628e5d40de6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

Release files / transformer_implementations-0.0.9-py3-none-any.whl

Download URL transformer_implementations-0.0.9-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7218bfe9f0d5a4f507d2c2b72e0f387cf826cd14c1817d49a62d75c833b77a08
BLAKE2b-256 checksum
How to use checksums
7445632c964b1dffdbc4157781702bdda34d67c7fcbe2cbce0885eaccb7fdde3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.0.9 This release

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

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