# Sliding Transformer into a long sequence

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsliding-transformer-into-a-long-sequence%2F21246%3E%5C
**Category:** Models\
**Created:** [August 4, 2022, 2:57pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsliding-transformer-into-a-long-sequence%2F21246 "2022-08-04T14:57:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdelas](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@mdelas](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmdelas)%5C
**Post date:** [August 4, 2022, 2:57pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsliding-transformer-into-a-long-sequence%2F21246%2F1 "2022-08-04T14:57:55Z")

</div>

Hello everyone,

I have very long genome sequences where I have to do some classification stuff on top. What I want to try is to use a transformer to predict the next token from the 512 chunk sequence and slide this transformer to the whole sequence and use those to work on top of the whole sequence.

Let’s say an example: Imagine I have a 250.000 token sequence, I should slide the transformer 488 times producing 488 tokens. Concatenate this output to obtain a summary array of the sequence and build a classifier on top of it.

I’m trying to find any examples that could guide me in this direction but I hardly can find any of them. Does someone think that’s a good idea? Where could I look for some near examples of sliding a transformer/LSTM over a longer sequence?

Thank you very much, I’ll appreciate everything!

---

<div class="post-metadata">

**Author:** ![rwheel](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/rwheel/32/5603_2.png) [@rwheel](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Frwheel)%5C
**Post date:** [August 11, 2022, 6:47am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsliding-transformer-into-a-long-sequence%2F21246%2F2 "2022-08-11T06:47:26Z")

</div>

Hi @mdelas,

I’m not very familiar with your problem but I found a thread in the forum that seems to be similar to yours but for question answering task: [Handling long text in BERT for Question Answering](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhandling-long-text-in-bert-for-question-answering%2F382)

---

<div class="post-metadata">

**Author:** ![mdelas](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@mdelas](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmdelas)%5C
**Post date:** [August 19, 2022, 4:25pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsliding-transformer-into-a-long-sequence%2F21246%2F3 "2022-08-19T16:25:47Z")

</div>

Thank you very much @rwheel for your proposal! I will follow and try to figure out how can I use it. I posted and edited this question on [deep learning - Sliding Transformer model into longer sequence - Stack Overflow](https://stackoverflow.com/questions/73238155/sliding-transformer-model-into-longer-sequence) . Do you have some other references of similar work over there?

---

<div class="post-metadata">

**Author:** ![rwheel](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/rwheel/32/5603_2.png) [@rwheel](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Frwheel)%5C
**Post date:** [August 20, 2022, 8:17am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsliding-transformer-into-a-long-sequence%2F21246%2F4 "2022-08-20T08:17:37Z")

</div>

No, I haven’t read anything else about it. However, if I find something of interest, I will let you know 🙂

Have a good day.
