HN user

rasbt

1,717 karma

AI researcher and statistics professor

Posts134
Comments87
View on HN
sebastianraschka.com 1y ago

Show HN: New LLM Pre-Training and Post-Training Paradigms

rasbt
2pts0
www.youtube.com 2y ago

Developing an LLM: Building, Training, Finetuning (A 1h Video Explainer)

rasbt
43pts12
github.com 2y ago

Evaluating LLMs locally, on a laptop, with Llama 3 and Ollama

rasbt
2pts0
magazine.sebastianraschka.com 2y ago

Understanding the LLM Development Cycle: Building, Training, Finetuning

rasbt
3pts0
magazine.sebastianraschka.com 2y ago

The latest major open LLM releases: Mixtral, Llama 3, Phi-3, and OpenELM

rasbt
5pts0
github.com 2y ago

Finetuning an LLM-Based Spam Classifier with LoRA from Scratch

rasbt
14pts0
github.com 2y ago

Finetune a GPT Model for Spam Detection on Your Laptop in Just 5 Minutes

rasbt
3pts0
github.com 2y ago

Insights from Finetuning LLMs for Classification Tasks

rasbt
2pts0
sebastianraschka.com 2y ago

Tips for LLM Pretraining and Evaluating Reward Models

rasbt
2pts0
github.com 2y ago

Comparing 5 ways to implement Multihead Attention in PyTorch

rasbt
3pts0
sebastianraschka.com 2y ago

AI Research in Feb 2024 – LoRA Successor, "Small" LLMs, Transparent LLM Research

rasbt
3pts0
lightning.ai 2y ago

Understanding, using, and finetuning Gemma

rasbt
118pts48
magazine.sebastianraschka.com 2y ago

Implementing Weight-Decomposed Low-Rank Adaptation (DoRA) from Scratch

rasbt
96pts10
magazine.sebastianraschka.com 2y ago

AI Research Papers in Jan 2024: Model Merging, Mixtures of Experts, Smaller LLMs

rasbt
20pts0
github.com 2y ago

Implementing a ChatGPT-like LLM from scratch, step by step

rasbt
739pts98
lightning.ai 2y ago

LoRA from scratch: implementation for LLM finetuning

rasbt
339pts78
magazine.sebastianraschka.com 2y ago

Coding Self-Attention, Multi-Head Attention, Cross-Attention, Causal-Attention

rasbt
142pts11
magazine.sebastianraschka.com 2y ago

Noteworthy AI Research Papers of 2023

rasbt
3pts0
magazine.sebastianraschka.com 2y ago

AI Research Papers in November 2023: hallucinations and reasoning capabilities

rasbt
5pts0
magazine.sebastianraschka.com 2y ago

Practical Tips for Finetuning LLMs Using LoRA (Low-Rank Adaptation)

rasbt
342pts27
magazine.sebastianraschka.com 2y ago

AI Research Papers (October 2023)

rasbt
5pts0
magazine.sebastianraschka.com 2y ago

AI and Open Source in 2023: A Review of the Year's Highs and Lows

rasbt
2pts0
lightning.ai 2y ago

Takeaways from hundreds of LLM finetuning experiments with LoRA

rasbt
258pts39
www.marketwatch.com 2y ago

Atlassian to Acquire Loom in $975M Deal

rasbt
4pts2
www.reuters.com 2y ago

OpenAI plans to unveil major developer updates on November 6 like memory storage

rasbt
3pts0
www.cnbc.com 2y ago

AMD to acquire AI software startup as it seeks to catch up with Nvidia

rasbt
2pts0
magazine.sebastianraschka.com 2y ago

AI chips, acquisitions, new "small" open-source LLMs, and new LoRA techniques

rasbt
5pts0
magazine.sebastianraschka.com 2y ago

AI news editorial from custom AI chips to new "small" LLMs like phi and Mistral

rasbt
1pts0
www.reuters.com 2y ago

OpenAI is exploring making its own AI chips

rasbt
116pts94
www.wsj.com 2y ago

Meta pitches EU to charge a $10 subscription for ad-free Facebook and Instagram

rasbt
41pts70

I disagree here: Setting up a large-scale pretraining run is super complex if you have to manage your distributed computing platform, but looking at how the training data looks like and is fed into an LLM is not that complex. If you are developing a product based on or with LLMs, it's worth spending a few hours to understand it on the big-picture level. I mean, look at how many people are confused why LLMs a) hallucinate facts, b) sometimes copy text passages verbatim, c) why they probably shouldn't be used as scientific calculators etc. All that could be much more clear if you know how they are trained.

Quoting from the readme, it embraces other executers, including torch.compile and also works with multiple GPUs:

Thunder is a source-to-source compiler for PyTorch. It makes PyTorch programs faster by combining and using different hardware executors at once (ie: nvFuser, torch.compile, cuDNN, and TransformerEngine FP8).

Works on single accelerators and in multi-GPU settings. Thunder aims to be usable, understandable, and extensible.

Yes, it's 8.5B params if you account for weight tying, and 9.3B if you count the embedding layer and output layer weights separately as shown in the 2nd figure in the article. In the paper, I think they justified 7B by only counting the non-embedding parameters (7,751,248,896), which is kind of cheating in my opinion, because if you do that, then Llama 2 is basically a 5B-6B param model.

Gemma is a +9B model

Yes that's correct. It's 9.3B parameters if you count the embedding layer and final projection layer separately. However, since they used weight tying, the adjusted count is 8.5B as discussed in the article.

Not sure, but in general, it looks like ZipLoRA is only useful in specific contexts like when you have two different tasks you want to optimize for (like style and content in a vision context). DoRA is more general, it's basically normalizing and scaling the LoRA matrices to get much better performance. According to the paper, it even works great for low ranks, which also effectively makes it even more parameter-efficient than OG LoRA.

I'd say that I've finished all of my previous books, and I have no intention of doing anything different here. Of course, there's always the chance that I get run over by a bus or equivalent, but in that case, I assume that Manning would find a replacement (as per contract) who finishes the book. I don't think there are any benefits to be reaped from not finishing.

That's a good point. I may briefly mention RAG-like systems and add some literature references on this, but I am bit hesitant to give general advice because it's heavily project-dependent in my opinion. It usually also comes down in what form the client has the data and whether referencing from a database or documentation is desired or not. The focus of chapter 6+7 is also instruction-finetuning and alignment rather than finetuning for knowledge. The latter goal is best achieved done via pretraining (as opposed to finetuning) imho. In any case, I just read this interesting case study last week on Finetuning vs RAG that might come in handy: "RAG vs Fine-tuning: Pipelines, Tradeoffs, and a Case Study on Agriculture" (https://arxiv.org/abs/2401.08406)

Unfortunately, I am not aware of any other resource that delves into these topics. However, as others commented above, Karpathy has a 2h YouTube video that is probably worthwhile watching. Based on skimming the YT video, it has some overlap with chapters 3 & 4, but the book has a much larger scope.

I am not sure how to link to other comments on HN, so let me just copy & paste it here:

How does this compare to the karpathy video [0]? I'm trying to get into LLMs and am trying to figure out what the best resource to get that level of understanding would be. [0] https://www.youtube.com/watch?v=kCc8FmEb1nY

Haven't fully watched this but from a brief skimming, here are some differences that the book has: - it implements a real word-level LLM instead of a character-level LLM - after pretraining also shows how to load pretrained weights - instruction-finetune that LLM after pretraining - code the alignment process for the instruction-finetuned LLM - also show how to finetune the LLM for classification tasks - the book it overall has a lots of figures. For Chapter 3, there are 26 figures alone :) The video looks awesome though. I think it's probably a great complementary resource to get a good solid intro because it's just 2 hours. I think reading the book will probably be more like 10 times that time investment.

The attention mechanism we implement in this book* is specific to LLMs in terms of the text inputs, but it's fundamentally the same attention mechanism that is used in vision transformers. The only difference is that in LLMs, you turn text into tokens, and convert these tokens into vector embeddings that go into an LLM. In vision transformers, instead of regarding images as tokens, you use an image patch as a token and turn those into vector embeddings (a bit hard to explain without visuals here). In both text or vision context, it's the same attention mechanism, and it both cases it receives vector embeddings.

(*Chapter 3, already submitted last week and should be online in the MEAP soon, in the meantime the code along with the notes is also available here: https://github.com/rasbt/LLMs-from-scratch/blob/main/ch03/01...)

Good question. I think a Python background is strongly recommended. PyTorch knowledge would be a nice to have (although I've written a comprehensive 40 page intro for the Appendix, which is also already available). From a math perspective, I think it should be gentle. I'm introducing dot products in Chapter 3, but I also explain how you could do the same with for-loops. Same with matrix multiplication. I'm bad at estimating requirements, but I hope this should be sufficient.

On that note, I have a relative comprehensive intro to PyTorch in the Appendix (~40 pages) that go over automatic differentiation etc.

The alternative, if you want to build something truly from scratch, would be to implement everything in CUDA, but that would not be a very accessible book.

Thanks, comparing positional encodings, MoEs, kv-caches etc are all good topics that I have in mind for either supplementary material and/or a follow-up book. The reason why it probably won't land in this current book is the length and time line. It's already going to be a big book as it is (400-500 pages). And I also want to be a bit mindful of the planned release date. However, these are indeed good suggestions.