Sure, You Can import transformers. Or You Could Just Rebuild Modern AI From Scratch, I Guess.

We’ve all done it. pip install transformers, from transformers import AutoModel, and... you’re a modern AI developer. It’s magic.

But what’s really happening under the hood? What’s going on in that “Attention Is All You Need” paper that everyone cites but maybe... didn’t fully read?

I decided to find out. I went on a quest to rebuild the Transformer Encoder from scratch in PyTorch. No nn.Transformer allowed.

My goal: To build a model that could perform Text Classification (specifically, sentiment analysis) on the IMDB movie review dataset. And, just maybe, to finally understand what q, k, and v really mean.

Spoiler: it worked. And it was a journey. Here’s how I did it…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help