# How to use BART as an encoder and a decoder separately for summarization?

**URL:** <https://discuss.huggingface.co/t/how-to-use-bart-as-an-encoder-and-a-decoder-separately-for-summarization/10109>\
**Category:** 🤗Transformers\
**Created:** [September 19, 2021, 8:50am UTC](https://discuss.huggingface.co/t/how-to-use-bart-as-an-encoder-and-a-decoder-separately-for-summarization/10109 "2021-09-19T08:50:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![talha1503](https://avatars.discourse-cdn.com/v4/letter/t/9de053/32.png) [@talha1503](https://discuss.huggingface.co/u/talha1503)\
**Post date:** [September 19, 2021, 8:50am UTC](https://discuss.huggingface.co/t/how-to-use-bart-as-an-encoder-and-a-decoder-separately-for-summarization/10109/1 "2021-09-19T08:50:12Z")

</div>

Hi! I am a new comer to huggingface. I wanted to modify the encoder outputs from BART’s encoder and apply some operations on them, and then generate tokens from the decoder step by step. But I am not able to find any BARTEncoder model in huggingface, neither a BARTDecoder, so how should I go about it?

---

<div class="post-metadata">

**Author:** ![ashutoshml](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ashutoshml/32/18924_2.png) [@ashutoshml](https://discuss.huggingface.co/u/ashutoshml)\
**Post date:** [September 22, 2021, 11:54am UTC](https://discuss.huggingface.co/t/how-to-use-bart-as-an-encoder-and-a-decoder-separately-for-summarization/10109/2 "2021-09-22T11:54:10Z")

</div>

You might need to modify the encoder (and/or) the decoder in this:

[https://huggingface.co/transformers/\_modules/transformers/models/bart/modeling\_bart.html#BartModel](https://huggingface.co/transformers/_modules/transformers/models/bart/modeling_bart.html#BartModel)

Copy-paste the entire file, save it locally as ‘modifiedbart.py’, and call it instead of the default “BARTModel” in transformers.
