# How to do multi-span question answering?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-do-multi-span-question-answering%2F16291%3E%5C
**Category:** Beginners\
**Created:** [March 31, 2022, 4:52am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-do-multi-span-question-answering%2F16291 "2022-03-31T04:52:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sadhaklal](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sadhaklal/32/44699_2.png) [@sadhaklal](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsadhaklal)%5C
**Post date:** [March 31, 2022, 4:52am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-do-multi-span-question-answering%2F16291%2F1 "2022-03-31T04:52:25Z")

</div>

The `BertForQuestionAnswering` architecture is perfect for single span question answering, i.e., extracting a single span (as the answer) from (i) a context & (ii) a question. It outputs two tensors: `start_logits` & `end_logits`.

But what if the `"train"` split of the dataset provides multiple spans as the answer? (In this case, the objective is to predict multiple spans as the answer for a single example.)

What architecture works for this problem? Do we have to create something custom, or does HF Transformers provide a class (similar to `BertForQuestionAnswering`)?

---

<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:** [March 31, 2022, 8:02am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-do-multi-span-question-answering%2F16291%2F2 "2022-03-31T08:02:03Z")

</div>

Hi,

A paper showed that you can treat multi-span question answering as token classification. They got really nice results with it: [https://aclanthology.org/2020.emnlp-main.248.pdf](https://aclanthology.org/2020.emnlp-main.248.pdf)

So basically you can treat a multi-span QA problem as a sequence labeling problem, hence you can use `BertForTokenClassification`.
