theodore
Hello,
Like many people on Earth, I’ve been trying to understand the transformer architecture. I translated the Python code in https://www.youtube.com/watch?v=kCc8FmEb1nY to Elixir and packaged it in this livebook.
Some first impressions of Elixir’s ML libraries
- Livebook is very nice
- Using a functional style to implement models made more sense to my brain
Performance could be better (like using cache), but it should all work.
I hope this is helpful for anyone who’s trying to understand the transformer architecture.
Thanks!
Trending in Other Resources
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Latest Livebook Threads
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
johnknott
This is incredible. Thank you so much.
theodore
Thanks a lot! Glad it could help
NickGnd
Hey @theodore
I just checked out the livebook, that’s a lot of work, impressive! Thanks for sharing
I’ll definitely watch the video together with your livebook. Maybe this time I’ll finally grasp the transformer architecture and not stop at the intricate diagram.
Thanks again, cheers!
theodore
Thanks Nick
Yea it was quite a grind to figure it out. I actually used some of your notebooks to learn Nx + Axon, so thank you too!
NickGnd
Hey @theodore
Last week i started watching the video and implementing the GPT step-by-step following Karpathy’s video. Your livebook has been of great help so far, without which I’d have give up at the multinational distribution implementation.
Here my WIP livebook, I’m still at the training of the Bigram Model.
There are some small differences compared to your, in particular in the
but the generated text is basically the same (love the reproducibility
).
forwardandlossfunction implementation, the training with my implementation seems a bit faster for what it mattersAlso, how did you come up with this part of the code?
I (think) makes total sense since the prediction focus on the last
- but it’s slower.
block_sizechar at max, but I don’t recall Karpathy mentioning that when implementing thegeneratefunction, in fact is not present in his version and the generated text is the same when passing the wholeacc- feels magicLet’s see if I manage to proceed and finish it, but looking at your livebook, I still have a long way to the end
Again, thank you for putting together this great piece of work
Best.
theodore
Haha that’s awesome to hear! I appreciate it.
That’s a good question. The short answer is that I added the “fully finished” generate_fn in the beginning so I could reuse it for the singlehead / multihead / fully-finished models
But, you’re right, the bigram model doesn’t need to truncate the input because the predicted next char doesn’t rely on context. Every char already has a mapping to its likely next char in the [65][65] embedding kernel
…
But, if you try out the non-truncating generate_fn on the single head model, you’ll see this gibberish:
vs the original
Goodluck with learning the transformer architecture. I think implementing it in elixir helped cement the math behind it more, so even though it took a long time, I found it worthwhile. Anyways I hope that helped!
apoorv-2204
HI I am new to ML AND AI(practical side of it). I have gone through theory though