미분류

2024년 1월 2일 pytorch tutorial

cape.coder 2024. 1. 2. 23:00

PyTorch Tutorial - nn.Transformer & torchtext

https://pytorch.org/tutorials/beginner/transformer_tutorial.html

 

Language Modeling with nn.Transformer and torchtext — PyTorch Tutorials 2.2.0+cu121 documentation

Note Click here to download the full example code Language Modeling with nn.Transformer and torchtext This is a tutorial on training a model to predict the next word in a sequence using the nn.Transformer module. The PyTorch 1.2 release includes a standard

pytorch.org

 

nn.Transformer을 활용한다면서

막상 활용하는 것은 nn.TransformerEncoder 클래스를 훈련하는

뉴비를 속이는 잔혹한 파이토치 튜토리얼을 아라보자.

 

Transfomer은 그 유명한 attention is all you need 논문을 활용한 클래스이다.

소스코드를 확인해보면,

nn.Transfomer은 nn.TransformerEncoder과 nn.TransformerDecoder을 활용하여

편의상 만들어진 클래스로 보인다.

 

유명한 LLM인 BERT는 Transformer에서 Encoder만 활용하며,

GPT는 Transformer에서 Decoder만 활용한다.