Elixir Status

Implementing a GPT model from scratch (opens in new tab)

Implementing a GPT model from scratch 27 May 2026 by karlosmid This post implements a GPT-style model from scratch in Elixir/Nx, building on the attention mechanism post. We start with the GPT-2 configuration and parameter counts, then add layer normalization, GELU feed-forward layers, shortcut connections, transformer blocks, the full GPTModel, and a simple greedy text generation loop.

Read the original article
Sign in to keep reading the full article.

Keyboard Shortcuts

Navigation

Next / previous post
j/k
Open post
oorEnter
Preview post
v

Post Actions

Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s

Recommendations

Add interest / feed
Enter
Not interested
x

Go to

Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Discover
gb
Search
/

General

Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help