Skip to main content

A package for Transformer blocks

Project description

Echoai Transformer Block Package

This package provides components for building Transformer blocks, including Multi-Head Attention and FeedForward layers.

Installation

You can install the package using pip:

pip install echoai-transformer-block

Usage Here's an example of how to use the Block class from this package:

import torch from echoai_transformer_block import Block

Define parameters

n_heads = 8 n_embed = 512 block_size = 16 dropout = 0.1 expand = 4

Create a Block instance

block = Block(n_heads, n_embed, block_size, dropout, expand)

Example input tensor

input_tensor = torch.randn(1, 16, 512)

Forward pass through the Block

output_tensor = block(input_tensor)

print("Output shape:", output_tensor.shape)

Components

Block

from echoai_transformer_block import Block

The Block class represents a Transformer block containing a Multi-Head Attention layer followed by a FeedForward layer.

MultiAttentionHead from echoai_transformer_block import MultiAttentionHead The MultiAttentionHead class represents the Multi-Head Attention mechanism used in Transformers.

FeedForward from echoai_transformer_block import FeedForward The FeedForward class represents the FeedForward module used in Transformer encoder layers.

Requirements Python 3.7+ PyTorch

License This project is licensed under the MIT License - see the LICENSE file for details.

This README file includes:

  • The updated package name "Echoai Transformer Block".
  • Installation instructions for the package.
  • An example of how to use the Block class.
  • Descriptions and import statements for each component (Block, MultiAttentionHead, FeedForward).
  • Requirements section listing the required Python version and PyTorch.
  • Mention of the license for the package.

You can include this updated README.md file in the root directory of your package alongside other files. When users visit your package's repository on GitHub or PyPI, they will see this README file, providing them with information on how to use your package.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

echoai_transformer_block-0.2-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file echoai_transformer_block-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for echoai_transformer_block-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 febd3ecb170e40b17de26667d949b3494f86965731199524a551ba2484dd57b7
MD5 2ef1fd024ba8bf00b174902f3b56fe4b
BLAKE2b-256 bb8be40ba9d9015dd4364a14f56d34d2dedb0d42596ef677613bc54259204912

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