Zurück zum Ranking

Kyubyong/transformer

Python

A TensorFlow Implementation of the Transformer: Attention Is All You Need

attention-mechanismtranslationattention-is-all-you-needimplementationtransformer
Sterne-Wachstum
Sterne
4.5k
Forks
1.3k
Wochenwachstum
Issues
126
2k4k
Juni 2017Juni 2020Juli 2023Juli 2026
ArtefaktePyPIpip install transformer
README

[UPDATED] A TensorFlow Implementation of Attention Is All You Need

When I opened this repository in 2017, there was no official code yet. I tried to implement the paper as I understood, but to no surprise it had several bugs. I realized them mostly thanks to people who issued here, so I'm very grateful to all of them. Though there is the official implementation as well as several other unofficial github repos, I decided to update my own one. This update focuses on:

  • readable / understandable code writing
  • modularization (but not too much)
  • revising known bugs. (masking, positional encoding, ...)
  • updating to TF1.12. (tf.data, ...)
  • adding some missing components (bpe, shared weight matrix, ...)
  • including useful comments in the code.

I still stick to IWSLT 2016 de-en. I guess if you'd like to test on a big data such as WMT, you would rely on the official implementation. After all, it's pleasant to check quickly if your model works. The initial code for TF1.2 is moved to the tf1.2_lecacy folder for the record.

Requirements

  • python==3.x (Let's move on to python 3 if you still use python 2)
  • tensorflow==1.12.0
  • numpy>=1.15.4
  • sentencepiece==0.1.8
  • tqdm>=4.28.1

Training

bash download.sh

It should be extracted to iwslt2016/de-en folder automatically.

  • STEP 2. Run the command below to create preprocessed train/eval/test data.
python prepro.py

If you want to change the vocabulary size (default:32000), do this.

python prepro.py --vocab_size 8000

It should create two folders iwslt2016/prepro and iwslt2016/segmented.

  • STEP 3. Run the following command.
python train.py

Check hparams.py to see which parameters are possible. For example,

python train.py --logdir myLog --batch_size 256 --dropout_rate 0.5
  • STEP 3. Or download the pretrained models.
wget https://dl.dropbox.com/s/4lom1czy5xfzr4q/log.zip; unzip log.zip; rm log.zip

Training Loss Curve

Learning rate

Bleu score on devset

Inference (=test)

  • Run
python test.py --ckpt log/1/iwslt2016_E19L2.64-29146 (OR yourCkptFile OR yourCkptFileDirectory)

Results

  • Typically, machine translation is evaluated with Bleu score.
  • All evaluation results are available in eval/1 and test/1.
tst2013 (dev) tst2014 (test)
28.06 23.88

Notes

  • Beam decoding will be added soon.
  • I'm going to update the code when TF2.0 comes out if possible.
Ähnliche Repositories
rasbt/LLMs-from-scratch

Implement a ChatGPT-like LLM in PyTorch from scratch, step by step

Jupyter NotebookOthergptlarge-language-models
amzn.to/4fqvn0D
99.5k15.3k
lucidrains/vit-pytorch

Implementation of Vision Transformer, a simple way to achieve SOTA in vision classification with only a single transformer encoder, in Pytorch

PythonPyPIMIT Licenseartificial-intelligenceattention-mechanism
25.4k3.5k
nndl/nndl

邱锡鹏《神经网络与深度学习》(蒲公英书)理论书 v2 与通识版

attention-mechanismchinese
nndl.github.io
19k3.7k
BlinkDL/RWKV-LM

RWKV (pronounced RwaKuv) is an RNN with great LLM performance, which can also be directly trained like a GPT transformer (parallelizable). We are at RWKV-7 "Goose". So it's combining the best of RNN and transformer - great performance, linear time, constant space (no kv-cache), fast training, infinite ctx_len, and free sentence embedding.

PythonPyPIApache License 2.0attention-mechanismdeep-learning
14.6k1k
brightmart/text_classification

all kinds of text classification models and more with deep learning

PythonPyPIMIT Licenseclassificationnlp
7.9k2.5k
lucidrains/x-transformers

A concise but complete full-attention transformer with a set of promising experimental features from various papers

PythonPyPIMIT Licenseartificial-intelligencedeep-learning
5.9k516
lucidrains/DALLE-pytorch

Implementation / replication of DALL-E, OpenAI's Text to Image Transformer, in Pytorch

PythonPyPIMIT Licenseartificial-intelligencedeep-learning
5.6k644
cmhungsteve/Awesome-Transformer-Attention

An ultimately comprehensive paper list of Vision Transformer/Attention, including papers, codes, and related websites

transformerattention-mechanism
5k497
benedekrozemberczki/awesome-graph-classification

A collection of important graph embedding, classification and representation learning papers with implementations.

PythonPyPICreative Commons Zero v1.0 Universalgraph2vecclassification-algorithm
4.8k726
ruvnet/RuVector

RuVector is a High Performance, Real-Time, Self-Learning Ai, Vector GNN, Memory DB built in Rust.

Rustcrates.ioMIT Licenseaiai-ocr
cognitum.one/RuVector
4.4k581
PetarV-/GAT

Graph Attention Networks (https://arxiv.org/abs/1710.10903)

PythonPyPIMIT Licensegraph-attention-networksattention-mechanism
petar-v.com/GAT/
3.5k671
zzw922cn/awesome-speech-recognition-speech-synthesis-papers

Automatic Speech Recognition (ASR), Speaker Verification, Speech Synthesis, Text-to-Speech (TTS), Language Modelling, Singing Voice Synthesis (SVS), Voice Conversion (VC)

MIT Licenseautomatic-speech-recognitionpapers
3.1k515