lnaba.reisen

Fall 2026 - BaLLM

Last edited by D, 2026-10-29 ; ongoing

Back to Projects

About this project

An attempt at teaching myself large language model development. This page will mostly feature notes for myself, clarifications/explanations on concepts I especially struggled with, etc.

If you are also someone studying LLM development and happened to land on this page: Take everything that’s written here with a grain of salt. I’m by no means an expert on this topic. Whatever conclusions I’ve arrived at for a particular issue may not be correct and/or optimal.

Resources

Deep Learning with Python, Third Edition Build a Large Language Model (From Scratch)

Hardware

MacBook Pro Processor - Apple M5 Memory - 16GB

What is an LLM?

A large language model, often abbreviated as an LLM, is a type of neural network that specializes in natural language processing. In easier words, it’s just another program (or module, class, function, whatever you want to compare it with). If I were to create a Doxygen comment block for one, it would look something like this:

/**
 * @brief Predicts the next word for the given text.
 *
 * @param[in] input    The input string; usually a sentence.
 * 
 * @return output      The output string; the sequence of words most likely to appear after the input string.
 */

The actual implementation would involve a lot of submodules, stuff called tokenization, sampling, tensor operations, backpropagation, all that. (And apparently these submodules have been meticulously implemented and made public through libraries such as PyTorch or Keras. A lotta geniuses out there.)

Naturally, then, if one were to understand how an LLM works underneath the hood, one would have to study how these underlying structures are formed, and how they work alongside each other.

Machine learning vs Deep learning

The goal is to create a program that “understands language”. How would a program understand language? Of course they don’t ‘understand’ any given string of words exactly as a human would; I would argue that individual humans have different mechanisms for language processing, in the first place.

Languages, rules

That being, language can be simplified as ‘a set of rules that would correspond a given array of tokens to some meaning’. It of course in no way allows for exactly one way to represent a given idea or vice versa, as I’ve painfully learned through my Syntax classes, but can nonetheless theoretically be described with a set of rules.

Here’s an example for a rule that applies to the Korean language: A는 B이다 means A is B.

It would be extremely convenient if all rules for a language were this simple and straightforward. Alas, the human mind teems with creativity. Over our history, we’ve invented millions of grammatical rules that combine together to form expressions that convey the delicate details of how one accidentally bit into a moldy sandwich that morning, or of the churning emotions that keep them awake at night. These languages consist of countless rules that interlace upon one another to form complex sentences. And that’s without mentioning all the exceptions that need to be taken into account!

Therefore, although theoretically possible, explicitly programming all of these rules into a language model would be terribly inefficient and inaccurate. Early attempts at creating language models nonetheless took this approach, as no other alternatives had been invented back then. They’re called symbolic AI.

Machine learning

Grammatical rules aren’t explicitly programmed into our brains when humans learn languages. We usually consume a ton of usage examples in that language and infer our own set of rules from them. Why don’t we let machines learn languages that way, as well? That’s the idea behind machine learning. Per Deep Learning with Python, Third Edition:

A machine learning system is trained rather than explicitly programmed. It’s presented with many examples relevant to a task, and it finds statistical structure in these examples that eventually allows the system to come up with rules for automating the task.

Let’s revisit our goal. When we talk to each other, we do so with a purpose in mind, and we usually have some sort of an expectation for what the other party would reply. For example, when I’m asking my Database class instructor “Will the midterms be open or closed book?”, I’m looking for a response along the lines of, “You can bring up to two pages of notes.” or, “It will be strictly closed book.” Although I have a clear preference between these two options, both are answers that make sense. But then, what if the instructor says with a completely serious face, “One large nacho combo, with extra cheese sauce, please.” or, “这个是放这里是吧”? I would be flabbergasted, to say the least. Neither of these are appropriate responses to the question I asked. In other words, for each given input(the question I asked, in this case) there both exists ‘right’ and ‘wrong’ outputs(the response from the instructor, in this case).

We can intuitively tell if a given output is right or wrong. This intuition is the result of subconsciously taking into consideration the context behind the conversation, the grammatical rules of the language being spoken in, some real-world knowledge relevant to the topic being discussed, and so on. Machine learning aims to embed this ‘intuition’ within a program.

Deep learning

Deep learning is a subfield of machine learning.

[!NOTE] Section under construction!

Data preprocessing - Tokenization

[!NOTE] Section under construction!

Sampling data

[!NOTE] Section under construction!

GPT architecture & Python implementation

[!NOTE] Section under construction!

Pretraining & Model evaluation

[!NOTE] Section under construction!