# Using HF to train a custom PyTorch architecture

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-hf-to-train-a-custom-pytorch-architecture%2F21008%3E%5C
**Category:** Beginners\
**Created:** [July 29, 2022, 6:22pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-hf-to-train-a-custom-pytorch-architecture%2F21008 "2022-07-29T18:22:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![curt-tigges](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/curt-tigges/32/5532_2.png) [@curt-tigges](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fcurt-tigges)%5C
**Post date:** [July 29, 2022, 6:22pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-hf-to-train-a-custom-pytorch-architecture%2F21008%2F1 "2022-07-29T18:22:57Z")

</div>

I’ve created a basic Seq2Seq transformer from scratch in PyTorch (mainly so that I can learn the architecture), and I was wondering if it is possible to train this kind of model using the HuggingFace Tokenizers, Dataset, and Trainer classes. I’d rather not hand-code the tokenization and training loop for the transformer from scratch.

Is there a way to do this with HF? Existing tutorials seem to exclusively use models that are already in the library.

If it is possible, what parts of the training would I still need to take care of (loss, masking, label smoothing, greedy decode, etc.)?
