# Input format for T5 model in Question Answering task

**URL:** <https://discuss.huggingface.co/t/input-format-for-t5-model-in-question-answering-task/31025>\
**Category:** 🤗Transformers\
**Created:** [February 3, 2023, 4:41am UTC](https://discuss.huggingface.co/t/input-format-for-t5-model-in-question-answering-task/31025 "2023-02-03T04:41:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hduc-le](https://avatars.discourse-cdn.com/v4/letter/h/67e7ee/32.png) [@hduc-le](https://discuss.huggingface.co/u/hduc-le)\
**Post date:** [February 3, 2023, 4:41am UTC](https://discuss.huggingface.co/t/input-format-for-t5-model-in-question-answering-task/31025/1 "2023-02-03T04:41:11Z")

</div>

Hi, everyone. I am working with the T5 model for fine-tuning question-answering tasks with the custom dataset. My dataset contains 3 parts (question, question\_context, answer\_text). According to my understanding, we can encode the `question + question_context` into `input_ids` and feed it to the model, likewise, the `answer_text` will be `labels` for evaluating the model generation. I looked around the implementation of T5ForConditionalGeneration and realized that if the users input the `labels` **and** do not define the `decoder_input_ids`, they will assign it by the `labels` and shift it right for performing autoregressive internally. Here is the implementation for the [code](https://github.com/huggingface/transformers/blob/820c46a707ddd033975bc3b0549eea200e64c7da/src/transformers/models/t5/modeling_t5.py#L1644). However, in my case, I want to feed the model with the question as `input_ids`, question\_context as `decoder_input_ids`, and answer\_text as `labels`, so does the T5ForConditionalGeneration will shift right the `decoder_input_ids` for me internally or I have to do it by my self externally?

Hope you guys help me clear this situation. Thank you in advance!
