# Generating actual answers from QA models

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgenerating-actual-answers-from-qa-models%2F11048%3E%5C
**Category:** Beginners\
**Created:** [October 25, 2021, 11:19am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgenerating-actual-answers-from-qa-models%2F11048 "2021-10-25T11:19:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AntonioLopardo](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/antoniolopardo/32/2970_2.png) [@AntonioLopardo](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FAntonioLopardo)%5C
**Post date:** [October 25, 2021, 11:19am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgenerating-actual-answers-from-qa-models%2F11048%2F1 "2021-10-25T11:19:28Z")

</div>

Hi everybody,  
I’m planning or training a BARTQA model, but before training I would like to test how to actually generate an answer at inference time. I’ve looked through the documentation, but I couldn’t find an obvious answer. Can I do it using the BARTForQuestionAnswering model or do I have to use the BARTForConditionalGeneration model that has the generate() method?

Thank you very much for any help!  
Antonio

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [October 25, 2021, 12:55pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgenerating-actual-answers-from-qa-models%2F11048%2F2 "2021-10-25T12:55:36Z")

</div>

Hi,

Solving question-answering using Transformers is usually done in one of 2 ways:

1. either **extractive** , where the model predicts `start_scores` and `end_scores`. In other words, the model predicts which token it believes is at the start of the answer, and which token is at the end of the answer. This was introduced in the original [BERT paper](https://arxiv.org/abs/1810.04805).
2. either **generative** , where the model simply generates the correct answer. This was introduced in the [T5 paper](https://arxiv.org/abs/1910.10683), where they treated every NLP problem as a generative task.

As BART is a seq2seq (encoder-decoder) model similar to T5, it makes sense to use `BartForConditionalGeneration`. You can indeed use the `.generate()` method at inference time to let it generate a predicted answer. However, `BartForQuestionAnswering` is also available in the library, meaning you can also use BART to do BERT-like extractive question answering.

If you ask me, option 2 is much simpler, and more “human-like”.

---

<div class="post-metadata">

**Author:** ![AntonioLopardo](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/antoniolopardo/32/2970_2.png) [@AntonioLopardo](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FAntonioLopardo)%5C
**Post date:** [October 26, 2021, 8:08am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgenerating-actual-answers-from-qa-models%2F11048%2F3 "2021-10-26T08:08:12Z")

</div>

Isn’t BARTForConditionalGeneration trained for summarization, though? I’m going to finetune it but idk how much the model’s behaviour will change.  
Thank you very much for your anwser!
