# Sequence Classification Long Documents

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsequence-classification-long-documents%2F5232%3E%5C
**Category:** Beginners\
**Created:** [March 31, 2021, 11:43am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsequence-classification-long-documents%2F5232 "2021-03-31T11:43:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sallu](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@sallu](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsallu)%5C
**Post date:** [March 31, 2021, 11:43am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsequence-classification-long-documents%2F5232%2F1 "2021-03-31T11:43:28Z")

</div>

Hi.  
I need to process very long documents on TPUs and be able to use any pre-trained models except LongFormer. There are multiple approaches to this but I am interested in the sliding window approach. I am able to tokenize the documents into sub-documents using stride option and return\_overflowing\_tokens=True, but I have no clue how to incorporate them into training. I don’t want each sub-document to behave as a separate document. Rather, the activations of sub-documents should be combined first by any approach (mean for instance) and then the softmax should be applied and loss calculated.

Is there a way to achieve this using HuggingFace Trainer / Training Arguments? Any working example that is doing the same thing using transformers library?

Thanks

---

<div class="post-metadata">

**Author:** ![davibarreira](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/davibarreira/32/5026_2.png) [@davibarreira](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdavibarreira)%5C
**Post date:** [June 9, 2022, 3:41pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsequence-classification-long-documents%2F5232%2F2 "2022-06-09T15:41:26Z")

</div>

Hey, @sallu , have you figured it out? I’m with the same issue.
