Skip to main content

Transformer from scratch for Machine Translation

Project description

tfs-mt
Transformer from scratch for Machine Translation

Release Build status License: MIT License: CC BY-SA 4.0 pypi monthly downloads

▶️ Getting started📖 Documentation🤗 Hugging Face🎬 Demo


This project implements the Transformer architecture from scratch considering Machine Translation as the usecase. It's mainly intended as an educational resource and a functional implementation of the architecture and the training/inference logic.

Getting Started

From PyPI

pip install tfs-mt

From source

Prerequisites

Steps

git clone https://github.com/Giovo17/tfs-mt.git
cd tfs-mt

uv sync

cp .env.example .env
# Edit .env file with your configuration

Usage

Training

To start training the model with the default configuration:

uv run src/train.py

Inference

To run inference using the trained model from the HuggingFace repo:

uv run src/inference.py

Configuration

The whole project parameters can be configured in src/tfs_mt/configs/config.yml. Key configurations include:

  • Model Architecture: Config, dropout, GloVe embedding init, ...
  • Training: Optimizer, Learning rate scheduler, number of epochs, ...
  • Data: Dataset, Dataloader, Tokenizer, ...

Documentation

Full documentation is available at https://giovo17.github.io/tfs-mt/.

The technical breakdown of the architecture and the training/inference workflows can be found in the following documentation sections:

Model Sizes

The project supports various model configurations to suit different computational resources:

Parameter Nano Small Base Original
Encoder Layers 4 6 8 6
Decoder Layers 4 6 8 6
d_model 50 100 300 512
Num Heads 4 6 8 8
d_ff 200 400 800 2048
Norm Type PostNorm PostNorm PostNorm PostNorm
Dropout 0.1 0.1 0.1 0.1
GloVe Dim 50d 100d 300d -

License

  • Source code: licensed under the MIT License.

    • Note: This project includes modified code derived from PyTorch Ignite, which is licensed under the BSD 3-Clause License. See the LICENSE file for the full text of both licenses and original copyright notices.
  • Documentation: located in the docs/ directory, licensed under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0). See docs/LICENSE.

Citation

If you use tfs-mt in your research or project, please cite:

@software{Spadaro_tfs-mt,
author = {Spadaro, Giovanni},
licenses = {MIT, CC BY-SA 4.0},
title = {{tfs-mt}},
url = {https://github.com/Giovo17/tfs-mt}
}

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

tfs_mt-0.1.4.post1.tar.gz (173.4 kB view details)

Uploaded Source

Built Distribution

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

tfs_mt-0.1.4.post1-py3-none-any.whl (52.6 kB view details)

Uploaded Python 3

File details

Details for the file tfs_mt-0.1.4.post1.tar.gz.

File metadata

  • Download URL: tfs_mt-0.1.4.post1.tar.gz
  • Upload date:
  • Size: 173.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tfs_mt-0.1.4.post1.tar.gz
Algorithm Hash digest
SHA256 b21cc5cf372da98818b1a3a5638a213ad570e8de4f7832785e09b4da9de4d503
MD5 3dfd3866b79bd53fabc53033add268f9
BLAKE2b-256 8901d2bd33d10ad116ef2d636b739a573e19c170bed1c86d58d65fe79437bb22

See more details on using hashes here.

File details

Details for the file tfs_mt-0.1.4.post1-py3-none-any.whl.

File metadata

  • Download URL: tfs_mt-0.1.4.post1-py3-none-any.whl
  • Upload date:
  • Size: 52.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tfs_mt-0.1.4.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 667b22a66229fa6e277f4e9e64b05ac71e756a4dd2a79c03a5202d733db4cdd7
MD5 fe7a5dc72348796e716c706e27466e09
BLAKE2b-256 f72b0e5b5dc23aeac0a3d215a3ec0f180c5e7b7bb941848c82e62b299e10efc6

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