# Separate image encoding and decoding in PreTrained decoder-only models

**URL:** <https://discuss.huggingface.co/t/separate-image-encoding-and-decoding-in-pretrained-decoder-only-models/169272>\
**Category:** Beginners\
**Created:** [October 19, 2025, 8:18pm UTC](https://discuss.huggingface.co/t/separate-image-encoding-and-decoding-in-pretrained-decoder-only-models/169272 "2025-10-19T20:18:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![minlu-21-new](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/minlu-21-new/32/54965_2.png) [@minlu-21-new](https://discuss.huggingface.co/u/minlu-21-new)\
**Post date:** [October 19, 2025, 8:18pm UTC](https://discuss.huggingface.co/t/separate-image-encoding-and-decoding-in-pretrained-decoder-only-models/169272/1 "2025-10-19T20:18:42Z")

</div>

Hi, currently I am trying to separate the image encoding and decoding phase of Qwen2.5-VL. As seen in the code here, [transformers/src/transformers/models/qwen2\_5\_vl/modular\_qwen2\_5\_vl.py at 307c5238546ba1675daabc46050c63ffde25f8e6 · huggingface/transformers · GitHub](https://github.com/huggingface/transformers/blob/307c5238546ba1675daabc46050c63ffde25f8e6/src/transformers/models/qwen2_5_vl/modular_qwen2_5_vl.py), currently the image embedding is done within the forward function (line 580-586). However, I want the image embedding to be done in a separate container and then have the result passed into the model which only does decoding. How would I do something like this?
