# How can I run separately the Encoder and Decoder layers?

**URL:** <https://discuss.huggingface.co/t/how-can-i-run-separately-the-encoder-and-decoder-layers/1835>\
**Category:** 🤗Transformers\
**Created:** [November 1, 2020, 8:50am UTC](https://discuss.huggingface.co/t/how-can-i-run-separately-the-encoder-and-decoder-layers/1835 "2020-11-01T08:50:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ophiry](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ophiry/32/534_2.png) [@ophiry](https://discuss.huggingface.co/u/ophiry)\
**Post date:** [November 1, 2020, 8:50am UTC](https://discuss.huggingface.co/t/how-can-i-run-separately-the-encoder-and-decoder-layers/1835/1 "2020-11-01T08:50:37Z")

</div>

For the models that are built from distinct encoding and decoding phases, is there a simple way to use them separately (without changing the actual model code)?

use cases may include:

- text from data (use the decoder on top of a linear layer)
- style transfer (encode, “change style”, decode)

---

<div class="post-metadata">

**Author:** ![patrickvonplaten](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/patrickvonplaten/32/2171_2.png) [@patrickvonplaten](https://discuss.huggingface.co/u/patrickvonplaten)\
**Post date:** [November 2, 2020, 1:07pm UTC](https://discuss.huggingface.co/t/how-can-i-run-separately-the-encoder-and-decoder-layers/1835/2 "2020-11-02T13:07:06Z")

</div>

Hey @ophiry,

The code example at the end of this section in the Encoder-Decoder blog posts: [https://huggingface.co/blog/encoder-decoder#decoder](https://huggingface.co/blog/encoder-decoder#decoder) gives an example of how to run each part differently. In general the blog post should be helpful in answering your question. To try tweak the code examples the blog post is also available as a google colab.
