# When to use AutoModelForSeq2SeqLM?

**URL:** <https://discuss.huggingface.co/t/when-to-use-automodelforseq2seqlm/20668>\
**Category:** 🤗Transformers\
**Created:** [July 21, 2022, 6:15am UTC](https://discuss.huggingface.co/t/when-to-use-automodelforseq2seqlm/20668 "2022-07-21T06:15:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sinduhrsh](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@sinduhrsh](https://discuss.huggingface.co/u/sinduhrsh)\
**Post date:** [July 21, 2022, 6:15am UTC](https://discuss.huggingface.co/t/when-to-use-automodelforseq2seqlm/20668/1 "2022-07-21T06:15:29Z")

</div>

Can anyone tell me when to use AutoModelForSeq2SeqLM. Is it generally used for translation? Can I use AutoModelForSeq2SeqLM for fine tuning a custom task using t5 model. If not when to use AutoModelForSeq2SeqLM and T5ForConditionalGeneration?

When to use

1. AutoModelForSeq2SeqLM.from\_pretrained(‘t5-base’)
2. T5ForConditionalGeneration.from\_pretrained(‘t5-base’)

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](https://discuss.huggingface.co/u/nielsr)\
**Post date:** [July 21, 2022, 11:21am UTC](https://discuss.huggingface.co/t/when-to-use-automodelforseq2seqlm/20668/2 "2022-07-21T11:21:31Z")

</div>

Hi,

`AutoModelForSeq2SeqLM` can be used to load any seq2seq (or encoder-decoder) model that has a language modeling (LM) head on top. These include BART, PEGASUS, T5, etc. You can check the full list of supported models in the docs: [Auto Classes](https://huggingface.co/docs/transformers/model_doc/auto#transformers.AutoModelForSeq2SeqLM)

So when you do `AutoModelForSeq2SeqLM.from_pretrained(‘t5-base’)`, it will actually load a `T5ForConditionalGeneration` for you behind the scenes.

---

<div class="post-metadata">

**Author:** ![bdzyubak](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/bdzyubak/32/27644_2.png) [@bdzyubak](https://discuss.huggingface.co/u/bdzyubak)\
**Post date:** [June 5, 2024, 9:30pm UTC](https://discuss.huggingface.co/t/when-to-use-automodelforseq2seqlm/20668/3 "2024-06-05T21:30:39Z")

</div>

Can you recommend a model to extract specific values from a large set of text? I am trying to do the SROIE dataset task2 - convert OCR-extracted text from receipts into total amount spent and company where the purchase was made. I am able to get ChatGPT-4 to extract the info quite nicely, but with t5-base, so far, I just get:  
`'<pad> True</s>'`

Data is bounding box coords + extracted text.

> 190,864,309,864,309,880,190,880,EXCHANGEABLE  
> 142,883,353,883,353,901,142,901,\*\*\*  
> 137,903,351,903,351,920,137,920,\*\*\*  
> 202,942,292,942,292,959,202,959,THANK YOU  
> 163,962,330,962,330,977,163,977,PLEASE COME AGAIN !  
> 412,639,442,639,442,654,412,654,9.00

The prompt I tried is:

> input\_text = f"Context: {the\_data\_above}\n\nQuestion: What is the total amount spent?\n\nAnswer:"

Is t5 a good model to use, or is there a better one? Any special tricks needed to getting it to use bounding box coordinates to infer text relationships?  
Many thanks!

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](https://discuss.huggingface.co/u/nielsr)\
**Post date:** [June 10, 2024, 9:15am UTC](https://discuss.huggingface.co/t/when-to-use-automodelforseq2seqlm/20668/4 "2024-06-10T09:15:57Z")

</div>

Hi,

T5 is a model meant to be fine-tuned, it is very limited in the zero-shot setting.

As SROIE is a document AI task, I recommend to take a look at the models we offer for that: [Accelerating Document AI](https://huggingface.co/blog/document-ai).
