<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>LLM on davethehuman.com</title><link>https://davethehuman.com/tags/llm/</link><description>Recent content in LLM on davethehuman.com</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>© 2026 Dave the human</copyright><lastBuildDate>Mon, 28 Sep 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://davethehuman.com/tags/llm/index.xml" rel="self" type="application/rss+xml"/><item><title>leaky ReLU</title><link>https://davethehuman.com/notes/leaky-relu/</link><pubDate>Mon, 28 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/leaky-relu/</guid><description>&lt;p&gt;&lt;em&gt;LeakyReLU&lt;/em&gt; is a variation of the &lt;a href="https://davethehuman.com/notes/relu/"&gt;ReLU&lt;/a&gt; &lt;a href="https://davethehuman.com/notes/activation-function/"&gt;activation function&lt;/a&gt;:&lt;/p&gt;
$$
f(x) = \max(\alpha x, x)
$$&lt;p&gt;&lt;figure&gt;&lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="low"
 alt="Human evolution illustration"
 src="attachments/leaky-ReLU.png"
 &gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;It leaves positive inputs unvaried while multiplying the negative ones by a small positive constant $\alpha$.
Unlike ReLU, which outputs zero for any negative input, Leaky ReLU keeps a small slope on the negative side, allowing &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;gradients&lt;/a&gt; to flow through &lt;a href="https://davethehuman.com/notes/neuron/"&gt;neurons&lt;/a&gt; with negative inputs during &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;backpropagation&lt;/a&gt;, and mitigating the &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;dying ReLU&lt;/a&gt; problem.&lt;/p&gt;
&lt;p&gt;In standard Leaky ReLU, $\alpha$ is a fixed &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;hyperparameter&lt;/a&gt;, while in [PReLU] it is learned during training.&lt;/p&gt;</description></item><item><title>activation function</title><link>https://davethehuman.com/notes/activation-function/</link><pubDate>Tue, 22 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/activation-function/</guid><description>&lt;p&gt;An &lt;em&gt;Activation Function&lt;/em&gt; is a mathematical operation applied to the linear output of a &lt;a href="https://davethehuman.com/notes/neuron/"&gt;neuron&lt;/a&gt; to introduce non-linearity into a &lt;a href="https://davethehuman.com/notes/neural-network/"&gt;neural network&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Without activation functions, a multi-layer neural network collapses into a single linear transformation (similar to &lt;a href="https://davethehuman.com/notes/linear-regression/"&gt;Linear Regression&lt;/a&gt;) regardless of its depth:&lt;/p&gt;
$$
W_2(W_1 x + b_1) + b_2 = (W_2 W_1)x + (W_2 b_1 + b_2) = W'x + b'
$$&lt;p&gt;&lt;strong&gt;Non-linear activations allow networks to learn complex, non-linear decision boundaries&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Common examples of activation functions used in neural networks are:&lt;/p&gt;</description></item><item><title>ReLU</title><link>https://davethehuman.com/notes/relu/</link><pubDate>Tue, 22 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/relu/</guid><description>&lt;p&gt;&lt;em&gt;ReLU (Rectified Linear Unit)&lt;/em&gt; is an &lt;a href="https://davethehuman.com/notes/activation-function/"&gt;activation function&lt;/a&gt; with formula:&lt;/p&gt;
$$
f(x) = \max(0, x)
$$&lt;p&gt;&lt;figure&gt;&lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="auto"
 alt="Human evolution illustration"
 width="1600"
 height="1100"
 src="https://davethehuman.com/attachments/ReLU_hu_28a8d9f66b312ef8.png"
 srcset="https://davethehuman.com/attachments/ReLU_hu_28a8d9f66b312ef8.png 800w, https://davethehuman.com/attachments/ReLU_hu_c3bc7cbf58118f9b.png 1280w"
 sizes="(min-width: 768px) 50vw, 65vw"
 data-zoom-src="https://davethehuman.com/attachments/ReLU.png"&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;It is the &lt;strong&gt;default activation function in the &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;hidden layers&lt;/a&gt;&lt;/strong&gt; of modern &lt;a href="https://davethehuman.com/notes/neural-network/"&gt;neural networks&lt;/a&gt;s (&lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;FNN&lt;/a&gt;, &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;CNN&lt;/a&gt;, etc.) and it just checks if a number is larger than zero, allowing for quick computation and fast &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;convergence&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Pros:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;it tackles the &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;vanishing gradient problem&lt;/a&gt;, keeping the &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;gradient&lt;/a&gt; flow strong during &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;backpropagation&lt;/a&gt; - this happens because its derivative (gradient) for any positive input is always &lt;strong&gt;exactly 1&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;it allows sparse activation, meaning that only relevant &lt;a href="https://davethehuman.com/notes/neuron/"&gt;neuron&lt;/a&gt;s fire, while negative inputs are zeroed out&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Cons:&lt;/p&gt;</description></item><item><title>Dataloader</title><link>https://davethehuman.com/notes/dataloader/</link><pubDate>Mon, 21 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/dataloader/</guid><description>&lt;p&gt;The &lt;em&gt;DataLoader&lt;/em&gt; is a PyTorch data primitive that allows to manage how a &lt;a href="https://davethehuman.com/notes/dataset/"&gt;Dataset&lt;/a&gt; is loaded onto a model.
In &lt;a href="https://davethehuman.com/notes/llm/"&gt;LLM&lt;/a&gt;s tasks, it is usually included in a funcion with the &lt;a href="https://davethehuman.com/notes/tokenizer/"&gt;tokenizer&lt;/a&gt; so that the input data is already processed to be ingested by the model, e.g.:&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;create_dataloader_v1&lt;/span&gt;(txt, 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;						 batch_size&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;4&lt;/span&gt;, 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;						 max_length&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;256&lt;/span&gt;, 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; stride&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;128&lt;/span&gt;, &lt;span style="color:#75715e"&gt;#number of positions the input shifts across batches&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; shuffle&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;True&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; drop_last&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;True&lt;/span&gt;, 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; num_workers&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; tokenizer &lt;span style="color:#f92672"&gt;=&lt;/span&gt; tiktoken&lt;span style="color:#f92672"&gt;.&lt;/span&gt;get_encoding(&lt;span style="color:#e6db74"&gt;&amp;#34;gpt2&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; dataset &lt;span style="color:#f92672"&gt;=&lt;/span&gt; GPTDatasetV1(txt, tokenizer, max_length, stride)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; dataloader &lt;span style="color:#f92672"&gt;=&lt;/span&gt; DataLoader(
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; dataset,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; batch_size&lt;span style="color:#f92672"&gt;=&lt;/span&gt;batch_size,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; shuffle&lt;span style="color:#f92672"&gt;=&lt;/span&gt;shuffle,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; drop_last&lt;span style="color:#f92672"&gt;=&lt;/span&gt;drop_last, &lt;span style="color:#75715e"&gt;#if True, drops the last batch if shorter than batch_size - to prevent loss spikes during training&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; num_workers&lt;span style="color:#f92672"&gt;=&lt;/span&gt;num_workers &lt;span style="color:#75715e"&gt;#n. of CPU processes to use &lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; )
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; dataloader&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</description></item><item><title>Dataset</title><link>https://davethehuman.com/notes/dataset/</link><pubDate>Mon, 21 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/dataset/</guid><description>&lt;p&gt;The &lt;em&gt;Dataset&lt;/em&gt; is a PyTorch data class that allows to manage how the individual rows are fetched and then loaded into the model by the &lt;a href="https://davethehuman.com/notes/dataloader/"&gt;DataLoader&lt;/a&gt;.
In &lt;a href="https://davethehuman.com/notes/llm/"&gt;LLM&lt;/a&gt;s tasks, it is usually included in a funcion with the &lt;a href="https://davethehuman.com/notes/tokenizer/"&gt;tokenizer&lt;/a&gt; so that the input data is already processed to be ingested by the model, e.g.:&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;GPTDatasetV1&lt;/span&gt;(Dataset):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;__init__&lt;/span&gt;(self, txt, tokenizer, max_length, stride):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;input_ids &lt;span style="color:#f92672"&gt;=&lt;/span&gt; []
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;target_ids &lt;span style="color:#f92672"&gt;=&lt;/span&gt; []
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; token_ids &lt;span style="color:#f92672"&gt;=&lt;/span&gt; tokenizer&lt;span style="color:#f92672"&gt;.&lt;/span&gt;encode(txt) &lt;span style="color:#75715e"&gt;#this tokenizes the entire text&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; i &lt;span style="color:#f92672"&gt;in&lt;/span&gt; range(&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;, len(token_ids) &lt;span style="color:#f92672"&gt;-&lt;/span&gt; max_length, stride): &lt;span style="color:#75715e"&gt;#sliding window&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; input_chunk &lt;span style="color:#f92672"&gt;=&lt;/span&gt; token_ids[i:i &lt;span style="color:#f92672"&gt;+&lt;/span&gt; max_length]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; target_chunk &lt;span style="color:#f92672"&gt;=&lt;/span&gt; token_ids[i&lt;span style="color:#f92672"&gt;+&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;:i&lt;span style="color:#f92672"&gt;+&lt;/span&gt;max_length&lt;span style="color:#f92672"&gt;+&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;input_ids&lt;span style="color:#f92672"&gt;.&lt;/span&gt;append(torch&lt;span style="color:#f92672"&gt;.&lt;/span&gt;tensor(input_chunk))
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;target_ids&lt;span style="color:#f92672"&gt;.&lt;/span&gt;append(torch&lt;span style="color:#f92672"&gt;.&lt;/span&gt;tensor(target_chunk))
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;__len__&lt;/span&gt;(self):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; len(self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;input_ids)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;__getitem__&lt;/span&gt;(self, idx):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;input_ids[idx], self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;target_ids[idx]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Among the common args we find the &lt;a href="https://davethehuman.com/notes/batch-size/"&gt;batch size&lt;/a&gt;, the &lt;a href="https://davethehuman.com/notes/stride/"&gt;stride&lt;/a&gt; and &lt;a href="https://davethehuman.com/notes/max_length/"&gt;max_length&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>max_length</title><link>https://davethehuman.com/notes/max_length/</link><pubDate>Mon, 21 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/max_length/</guid><description>&lt;p&gt;Talking about &lt;a href="https://davethehuman.com/notes/llm/"&gt;LLM&lt;/a&gt;s and the &lt;a href="https://davethehuman.com/notes/dataset/"&gt;Dataset&lt;/a&gt;s used for their training, &lt;em&gt;max_length&lt;/em&gt; usually indicates the length of the overlapping sequences that get loaded by the &lt;a href="https://davethehuman.com/notes/dataloader/"&gt;DataLoader&lt;/a&gt; in a sliding window fashion.&lt;/p&gt;</description></item><item><title>neural network</title><link>https://davethehuman.com/notes/neural-network/</link><pubDate>Mon, 21 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/neural-network/</guid><description>&lt;p&gt;A &lt;em&gt;neural network&lt;/em&gt; is a computational model inspired by the biological brain structure, consisting of interconnected layers of &lt;a href="https://davethehuman.com/notes/neuron/"&gt;neuron&lt;/a&gt;s that map input features to target outputs.&lt;/p&gt;
&lt;p&gt;A standard &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;feedforward neural network&lt;/a&gt; (&lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;FNN&lt;/a&gt;) is organized into three main types of layers:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Input Layer:&lt;/strong&gt; Receives the raw input vector \(x\).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hidden Layer(s):&lt;/strong&gt; Extracts latent representations using weighted sums and &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;activation function&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Output Layer:&lt;/strong&gt; Produces the final prediction \(\hat{y}\).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The core mechanism of the learning process of a neural network operates in a two-step feedback loop:&lt;/p&gt;</description></item><item><title>neuron</title><link>https://davethehuman.com/notes/neuron/</link><pubDate>Mon, 21 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/neuron/</guid><description>&lt;p&gt;In &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;deep learning&lt;/a&gt;, a &lt;em&gt;neuron&lt;/em&gt; is the foundational building block of a &lt;a href="https://davethehuman.com/notes/neural-network/"&gt;neural network&lt;/a&gt;.
It computes a scalar output from a vector of inputs.&lt;/p&gt;

&lt;h2 class="relative group"&gt;Formula
 &lt;div id="formula" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#formula" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Given an input vector \(\mathbf{x} = [x_1, x_2, \dots, x_n]\), a weight vector \(\mathbf{w} = [w_1, w_2, \dots, w_n]\), and a scalar bias \(b\):&lt;/p&gt;
$$
z = \mathbf{w}^T \mathbf{x} + b = \sum_{i=1}^{n} w_i x_i + b
$$&lt;p&gt;The final output \(a\) is obtained by applying an &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;activation function&lt;/a&gt; \(g(\cdot)\):&lt;/p&gt;</description></item><item><title>stride</title><link>https://davethehuman.com/notes/stride/</link><pubDate>Mon, 21 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/stride/</guid><description>&lt;p&gt;The &lt;em&gt;stride&lt;/em&gt; dictates the number of positions the inputs shift across &lt;a href="https://davethehuman.com/notes/batch/"&gt;batch&lt;/a&gt;es, creating a &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;sliding window&lt;/a&gt; approach.
It is used for example in the &lt;a href="https://davethehuman.com/notes/dataloader/"&gt;DataLoader&lt;/a&gt;; in the following example we see that a &lt;code&gt;stride = 1&lt;/code&gt; shifts the second batch by one position compared to the first one, with the target portion as an anchor point for the shift.&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dataloader &lt;span style="color:#f92672"&gt;=&lt;/span&gt; create_dataloader_v1(raw_text, batch_size&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;, 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; max_length&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;4&lt;/span&gt;, &lt;span style="color:#75715e"&gt;#usually much larger (e.g. 256)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; stride&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;, 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; shuffle&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;False&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;data_iter &lt;span style="color:#f92672"&gt;=&lt;/span&gt; iter(dataloader)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;inputs, targets &lt;span style="color:#f92672"&gt;=&lt;/span&gt; next(data_iter)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;print(&lt;span style="color:#e6db74"&gt;&amp;#34;Inputs:&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\n&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;, inputs)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;print(&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\n&lt;/span&gt;&lt;span style="color:#e6db74"&gt;Targets:&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\n&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;, targets)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre class="code-output"&gt;```
Inputs:
 tensor([[ 40, 367, 2885, 1464]])

Targets:
 tensor([[ 367, 2885, 1464, 1807]])
```&lt;/pre&gt;

&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#with a stride=1 the second batch will be shifted by 1 position &lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;inputs, targets &lt;span style="color:#f92672"&gt;=&lt;/span&gt; next(data_iter)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;print(&lt;span style="color:#e6db74"&gt;&amp;#34;Inputs:&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\n&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;, inputs)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;print(&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\n&lt;/span&gt;&lt;span style="color:#e6db74"&gt;Targets:&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\n&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;, targets)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre class="code-output"&gt;```
Inputs:
 tensor([[ 367, 2885, 1464, 1807]])

Targets:
 tensor([[2885, 1464, 1807, 3619]])
```&lt;/pre&gt;

&lt;p&gt;The anchor point concept is mote visible in an example where we use &lt;code&gt;batch_size = 2&lt;/code&gt; , and let&amp;rsquo;s use a larger &lt;code&gt;stride = 2&lt;/code&gt; too:&lt;/p&gt;</description></item><item><title>padding</title><link>https://davethehuman.com/notes/padding/</link><pubDate>Sat, 19 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/padding/</guid><description>&lt;p&gt;When training LLMs with &lt;a href="https://davethehuman.com/notes/batch-size/"&gt;batch size&lt;/a&gt; sizes larger than one, the batch might contain texts of varying lengths. To ensure all texts have the same length, the shorter texts are extended or &amp;ldquo;padded&amp;rdquo; up to the length of the longest text in the batch.&lt;/p&gt;</description></item><item><title>embedding</title><link>https://davethehuman.com/notes/embedding/</link><pubDate>Fri, 18 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/embedding/</guid><description>&lt;p&gt;An &lt;em&gt;embedding&lt;/em&gt; is a mapping from discrete objects, such as words, images, or entire documents, to points in a continuous vector space.
Its primary purpose is to convert non-numeric data into a format that neural networks can process.&lt;/p&gt;
&lt;p&gt;One of the earlier and most popular examples of word embedding is the &lt;a href="https://davethehuman.com/notes/word2vec/"&gt;Word2Vec&lt;/a&gt; approach.&lt;/p&gt;
&lt;p&gt;Such embedding models can be used as pretrained models to generate embeddings for Machine Learning models, but &lt;a href="https://davethehuman.com/notes/llm/"&gt;LLM&lt;/a&gt;s produce their own embeddings as part of the input layer and they get updated during training.
The advantage of optimizing the embeddings as part of the training is that they get optimized to the specific task and data at hand.&lt;/p&gt;</description></item><item><title>Word2Vec</title><link>https://davethehuman.com/notes/word2vec/</link><pubDate>Fri, 18 Sep 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/word2vec/</guid><description>&lt;p&gt;&lt;em&gt;Word2Vec&lt;/em&gt; is one of the earlier and most popular examples of word &lt;a href="https://davethehuman.com/notes/embedding/"&gt;embedding&lt;/a&gt; approach. It was created training a &lt;a href="https://davethehuman.com/notes/neural-network/"&gt;neural network&lt;/a&gt; architecture that predicts the context of a word given the target word or vice versa.&lt;/p&gt;
&lt;p&gt;The main idea behind this technique is that words that appear in similar contexts tend to have similar meanings, and consequently, when projected into two-dimensional word embeddings for visualization, simple terms are displayed as clustered together.&lt;/p&gt;</description></item><item><title>self-supervised learning</title><link>https://davethehuman.com/notes/self-supervised-learning/</link><pubDate>Mon, 17 Aug 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/self-supervised-learning/</guid><description>&lt;p&gt;&lt;a href="https://davethehuman.com/notes/llm/"&gt;LLM&lt;/a&gt;s use &lt;em&gt;self-supervised learning&lt;/em&gt;, where the model generates its own labels from the input data (as opposed to the conventional &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;supervised learning&lt;/a&gt; paradigm).&lt;/p&gt;</description></item><item><title>BPE</title><link>https://davethehuman.com/notes/bpe/</link><pubDate>Sat, 30 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/bpe/</guid><description>&lt;p&gt;&lt;em&gt;BPE&lt;/em&gt; stands for &lt;em&gt;Byte Pair Encoding&lt;/em&gt;, a method to split into &lt;a href="https://davethehuman.com/notes/token/"&gt;token&lt;/a&gt;s that can represent both common and rare words using a mix of full words and sub-words units. Spaces are also included in tokens, and this helps &lt;a href="https://davethehuman.com/notes/llm/"&gt;LLM&lt;/a&gt; detect word boundaries.&lt;/p&gt;
&lt;p&gt;Using a BPE &lt;a href="https://davethehuman.com/notes/tokenizer/"&gt;tokenizer&lt;/a&gt;, the correct &lt;a href="https://davethehuman.com/notes/encoding/"&gt;encoding&lt;/a&gt; and &lt;a href="https://davethehuman.com/notes/decoding/"&gt;decoding&lt;/a&gt; of unknown out-of-&lt;a href="https://davethehuman.com/notes/vocabulary/"&gt;vocabulary&lt;/a&gt; words is possible without an explicit &lt;code&gt;&amp;lt;|unk|&amp;gt;&lt;/code&gt; token.&lt;/p&gt;
&lt;p&gt;In short, &lt;em&gt;BPE&lt;/em&gt; builds its vocabulary by iteratively merging frequent characters into subwords and frequent subwords into words.
For example, it starts with adding single characters to the vocabulary (&lt;code&gt;a&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;, etc.), then at the following stage it merges the most frequent characters combinations into subwords (e.g. &lt;code&gt;d&lt;/code&gt; and &lt;code&gt;e&lt;/code&gt; may be merged into &lt;code&gt;de&lt;/code&gt;), dependent from a frequency cutoff.&lt;/p&gt;</description></item><item><title>decoding</title><link>https://davethehuman.com/notes/decoding/</link><pubDate>Sat, 30 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/decoding/</guid><description>&lt;p&gt;When a &lt;a href="https://davethehuman.com/notes/tokenizer/"&gt;tokenizer&lt;/a&gt; performs the process of &lt;em&gt;decoding&lt;/em&gt; (through its &lt;code&gt;decode&lt;/code&gt; method), a list of IDs representing &lt;a href="https://davethehuman.com/notes/token/"&gt;token&lt;/a&gt;s is converted to natural language.&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;input_token_ids_list &lt;span style="color:#f92672"&gt;=&lt;/span&gt; [&lt;span style="color:#ae81ff"&gt;19152&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;20238&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;11&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;358&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;646&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;944&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;653&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;429&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;text &lt;span style="color:#f92672"&gt;=&lt;/span&gt; tokenizer&lt;span style="color:#f92672"&gt;.&lt;/span&gt;decode(input_token_ids_list)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;print(text)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre class="code-output"&gt;Sorry Dave, I can&amp;#39;t do that&lt;/pre&gt;

&lt;p&gt;The other way around from natural language to IDs is called &lt;a href="https://davethehuman.com/notes/encoding/"&gt;encoding&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>encoding</title><link>https://davethehuman.com/notes/encoding/</link><pubDate>Sat, 30 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/encoding/</guid><description>&lt;p&gt;When a &lt;a href="https://davethehuman.com/notes/tokenizer/"&gt;tokenizer&lt;/a&gt; performs the process of &lt;em&gt;encoding&lt;/em&gt; (through its &lt;em&gt;encode&lt;/em&gt; method), a natural language text is broken into &lt;a href="https://davethehuman.com/notes/token/"&gt;token&lt;/a&gt;s that are then converted to IDs.&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Even notes can have code&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;prompt &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;Sorry Dave, I can&amp;#39;t do that&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;input_token_ids_list &lt;span style="color:#f92672"&gt;=&lt;/span&gt; tokenizer&lt;span style="color:#f92672"&gt;.&lt;/span&gt;encode(prompt)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;print(input_token_ids_list)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre class="code-output"&gt;[19152, 20238, 11, 358, 646, 944, 653, 429]&lt;/pre&gt;

&lt;p&gt;The way back from IDs to natural language is called &lt;a href="https://davethehuman.com/notes/decoding/"&gt;decoding&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>vocabulary</title><link>https://davethehuman.com/notes/vocabulary/</link><pubDate>Sat, 30 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/vocabulary/</guid><description>&lt;p&gt;The number of &lt;a href="https://davethehuman.com/notes/token/"&gt;token&lt;/a&gt;s that can be handled by a &lt;a href="https://davethehuman.com/notes/tokenizer/"&gt;tokenizer&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;A larger vocabulary in &lt;a href="https://davethehuman.com/notes/llm/"&gt;LLM&lt;/a&gt;s:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;increases the model size because the &lt;a href="https://davethehuman.com/notes/embedding/"&gt;embedding&lt;/a&gt; and output layers must store more &lt;a href="https://davethehuman.com/notes/token/"&gt;token&lt;/a&gt; representations&lt;/li&gt;
&lt;li&gt;increases the per-token compute cost of producing next-token probabilities&lt;/li&gt;
&lt;li&gt;allows more words to be represented as single tokens rather than being split into subword components; this can reduce the sequence length since less tokens are required to represent a sentence&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So the tradeoff is between a larger vocabulary with somewhat higher per-token cost and a smaller vocabulary that often produces longer token sequences.&lt;/p&gt;</description></item><item><title>RLHF</title><link>https://davethehuman.com/notes/rlhf/</link><pubDate>Fri, 15 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/rlhf/</guid><description>&lt;p&gt;&lt;em&gt;RLHF (Reinforcement Learning From Human Feedback)&lt;/em&gt; involves human evaluations or rankings of model outputs as reward signals; this means that humans are involved in the process to guide the model toward human-preferred behaviors.&lt;/p&gt;
&lt;p&gt;This is in contrast with &lt;a href="https://davethehuman.com/notes/rl/"&gt;RL&lt;/a&gt; in the context of &lt;a href="https://davethehuman.com/notes/reasoning/"&gt;reasoning&lt;/a&gt;, where the models rely on automated or environment-based reward signals (more objective but potentially less aligned with human preference).&lt;/p&gt;</description></item><item><title>distillation</title><link>https://davethehuman.com/notes/distillation/</link><pubDate>Thu, 14 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/distillation/</guid><description>&lt;p&gt;&lt;em&gt;Distillation&lt;/em&gt; (also called &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;knowledge distillation&lt;/a&gt;) consists of transferring complex reasoning patterns learned by larger models into smaller ones.
In &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;deep learning&lt;/a&gt;, distillation happens when a smaller &amp;ldquo;student&amp;rdquo; model learns from outputs and logits of a larger &amp;ldquo;teacher&amp;rdquo; model; when talking about &lt;a href="https://davethehuman.com/notes/llm/"&gt;Large Language Models&lt;/a&gt;, distillation typically means performing &lt;a href="https://davethehuman.com/notes/supervised-fine-tuning/"&gt;supervised fine-tuning&lt;/a&gt; using high-quality labeled instruction datasets generated by a more capable &lt;a href="https://davethehuman.com/notes/llm/"&gt;LLM&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>inference-compute scaling</title><link>https://davethehuman.com/notes/inference-compute-scaling/</link><pubDate>Wed, 13 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/inference-compute-scaling/</guid><description>&lt;p&gt;See &lt;a href="https://davethehuman.com/notes/inference-time-compute-scaling/"&gt;inference-time compute scaling&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>inference-time compute scaling</title><link>https://davethehuman.com/notes/inference-time-compute-scaling/</link><pubDate>Wed, 13 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/inference-time-compute-scaling/</guid><description>&lt;p&gt;&lt;em&gt;Inference-time compute scaling&lt;/em&gt; (also called &lt;a href="https://davethehuman.com/notes/inference-compute-scaling/"&gt;inference-compute scaling&lt;/a&gt; or &lt;a href="https://davethehuman.com/notes/test-time-scaling/"&gt;test-time scaling&lt;/a&gt;) is a technique that aims to improve a &lt;a href="https://davethehuman.com/notes/llm/"&gt;Large Language Model&lt;/a&gt;&amp;rsquo;s &lt;a href="https://davethehuman.com/notes/reasoning/"&gt;reasoning&lt;/a&gt; capabilities at &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;inference&lt;/a&gt; time without training or modifying the underlying model &lt;a href="https://davethehuman.com/notes/weights/"&gt;weights&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The core idea is to trade off increased computational resources for improved performance; in this way, even fixed models can become more capable through techniques like &lt;a href="https://davethehuman.com/notes/cot/"&gt;COT&lt;/a&gt; and various sampling procedures.&lt;/p&gt;</description></item><item><title>reasoning</title><link>https://davethehuman.com/notes/reasoning/</link><pubDate>Wed, 13 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/reasoning/</guid><description>&lt;p&gt;In the context of &lt;a href="https://davethehuman.com/notes/llm/"&gt;Large Language Model&lt;/a&gt;s, &lt;em&gt;reasoning&lt;/em&gt; is the ability to tackle more complex problems step-by-step.&lt;/p&gt;
&lt;p&gt;The concept of &lt;em&gt;reasoning&lt;/em&gt; became popular when &lt;a href="https://openai.com/index/introducing-openai-o1-preview/"&gt;OpenAI announced o1&lt;/a&gt; on the 12th of September 2024, highlighting their capabilities in tackling complex problems in science, math, coding etc.
Few months later, in January 2025, DeepSeek &lt;a href="https://arxiv.org/abs/2501.12948"&gt;released their R1 model&lt;/a&gt; that competed and exceeded the performance of the proprietary o1 model.
The great thing is that they made it openly available, sharing a blueprint on how to train such a model.&lt;/p&gt;</description></item><item><title>RL</title><link>https://davethehuman.com/notes/rl/</link><pubDate>Wed, 13 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/rl/</guid><description>&lt;p&gt;&lt;em&gt;RL (Reinforcement Learning)&lt;/em&gt; aims to improve an &lt;a href="https://davethehuman.com/notes/llm/"&gt;LLM&lt;/a&gt;&amp;rsquo;s &lt;a href="https://davethehuman.com/notes/reasoning/"&gt;reasoning&lt;/a&gt; capabilities by encouraging it to take actions that lead to high reward signals.&lt;/p&gt;
&lt;p&gt;While &lt;a href="https://davethehuman.com/notes/inference-time-compute-scaling/"&gt;inference-time compute scaling&lt;/a&gt; improves model&amp;rsquo;s reasoning performance without modifying the model, &lt;em&gt;RL&lt;/em&gt; updates the model&amp;rsquo;s &lt;a href="https://davethehuman.com/notes/weights/"&gt;weights&lt;/a&gt; during training, enabling the model to learn through trial and error based on the feedback from the environment.&lt;/p&gt;
&lt;p&gt;It is important to distinguish reinforcement learning in the context of reasoning from &lt;a href="https://davethehuman.com/notes/rlhf/"&gt;RLHF&lt;/a&gt;, which is used during &lt;a href="https://davethehuman.com/notes/preference-tuning/"&gt;preference tuning&lt;/a&gt;. Both settings use reinforcement learning principles but they differ primarily in how the reward is obtained and validated (through human verifiers for RLHF versus automated verifiers or environments for reasoning RL).&lt;/p&gt;</description></item><item><title>test-time scaling</title><link>https://davethehuman.com/notes/test-time-scaling/</link><pubDate>Wed, 13 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/test-time-scaling/</guid><description>&lt;p&gt;See &lt;a href="https://davethehuman.com/notes/inference-time-compute-scaling/"&gt;inference-time compute scaling&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>token</title><link>https://davethehuman.com/notes/token/</link><pubDate>Wed, 13 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/token/</guid><description>&lt;p&gt;A &lt;em&gt;token&lt;/em&gt; is not necessary an entire word: it can be defined as a small unit of text that gets processed by a language model.&lt;/p&gt;
&lt;p&gt;It can be a full word, part of a word, or even punctuation depending on how the text is split and mapped to IDs by the &lt;a href="https://davethehuman.com/notes/tokenizer/"&gt;tokenizer&lt;/a&gt;.
E.g. the sentence &lt;code&gt;Sorry Dave, I can't do that&lt;/code&gt; can be broken into tokens like this:&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;19152 --&amp;gt; Sorry
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;20238 --&amp;gt; Dave
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;11 --&amp;gt; ,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;358 --&amp;gt; I
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;646 --&amp;gt; can
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;944 --&amp;gt; &amp;#39;t
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;653 --&amp;gt; do
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;429 --&amp;gt; that&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The ID mapping is necessary to make the model ingest the tokens.&lt;/p&gt;</description></item><item><title>tokenizer</title><link>https://davethehuman.com/notes/tokenizer/</link><pubDate>Wed, 13 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/tokenizer/</guid><description>&lt;p&gt;A &lt;em&gt;tokenizer&lt;/em&gt; is a critical component of the &lt;a href="https://davethehuman.com/notes/llm/"&gt;LLM&lt;/a&gt; text processing and generation pipeline even though it is not directly part of it.
It splits the text into &lt;a href="https://davethehuman.com/notes/token/"&gt;token&lt;/a&gt;s that get converted into numerical IDs to be ingested by the language model (&lt;a href="https://davethehuman.com/notes/encoding/"&gt;encoding&lt;/a&gt;) and it decodes back the LLM&amp;rsquo;s output to human-readable text (&lt;a href="https://davethehuman.com/notes/decoding/"&gt;decoding&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Tokenization is usually done on a &lt;a href="https://davethehuman.com/notes/dataset/"&gt;Dataset&lt;/a&gt; within a &lt;a href="https://davethehuman.com/notes/dataloader/"&gt;DataLoader&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s an example code for a basic tokenizer:&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;SimpleTokenizerV2&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;__init__&lt;/span&gt;(self, vocab):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;str_to_int &lt;span style="color:#f92672"&gt;=&lt;/span&gt; vocab &lt;span style="color:#75715e"&gt;#stores the vocabulary&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;int_to_str &lt;span style="color:#f92672"&gt;=&lt;/span&gt; {i:s &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; s,i &lt;span style="color:#f92672"&gt;in&lt;/span&gt; vocab&lt;span style="color:#f92672"&gt;.&lt;/span&gt;items()} &lt;span style="color:#75715e"&gt;#creates inverse vocabulary&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;encode&lt;/span&gt;(self, text): 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	 &lt;span style="color:#75715e"&gt;#processes the input text into token ids&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; preprocessed &lt;span style="color:#f92672"&gt;=&lt;/span&gt; re&lt;span style="color:#f92672"&gt;.&lt;/span&gt;split(&lt;span style="color:#e6db74"&gt;r&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;([,.:;?_!&amp;#34;()&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\&amp;#39;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;]|--|\s)&amp;#39;&lt;/span&gt;,text)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; preprocessed &lt;span style="color:#f92672"&gt;=&lt;/span&gt; [item&lt;span style="color:#f92672"&gt;.&lt;/span&gt;strip() &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; item &lt;span style="color:#f92672"&gt;in&lt;/span&gt; preprocessed &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; item&lt;span style="color:#f92672"&gt;.&lt;/span&gt;strip()]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#replaces unknown words by &amp;lt;|unk|&amp;gt; tokens&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; preprocessed &lt;span style="color:#f92672"&gt;=&lt;/span&gt; [item &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; item &lt;span style="color:#f92672"&gt;in&lt;/span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;str_to_int &lt;span style="color:#66d9ef"&gt;else&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&amp;lt;|unk|&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; item &lt;span style="color:#f92672"&gt;in&lt;/span&gt; preprocessed]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ids &lt;span style="color:#f92672"&gt;=&lt;/span&gt; [self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;str_to_int[s] &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; s &lt;span style="color:#f92672"&gt;in&lt;/span&gt; preprocessed]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; ids
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;decode&lt;/span&gt;(self, ids): &lt;span style="color:#75715e"&gt;#converts token ids back into text&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; text &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34; &amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;.&lt;/span&gt;join([self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;int_to_str[i] &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; i &lt;span style="color:#f92672"&gt;in&lt;/span&gt; ids])
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; text &lt;span style="color:#f92672"&gt;=&lt;/span&gt; re&lt;span style="color:#f92672"&gt;.&lt;/span&gt;sub(&lt;span style="color:#e6db74"&gt;r&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;\s+([,.?!&amp;#34;()&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;\&amp;#39;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;])&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;r&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;\1&amp;#39;&lt;/span&gt;, text) &lt;span style="color:#75715e"&gt;#removes spaces before the specified punctuation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; text&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</description></item><item><title>LLM training pipeline</title><link>https://davethehuman.com/notes/llm-training-pipeline/</link><pubDate>Tue, 12 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/llm-training-pipeline/</guid><description>&lt;p&gt;Conventional &lt;a href="https://davethehuman.com/notes/llm/"&gt;LLM&lt;/a&gt; are typically trained in two stages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://davethehuman.com/notes/pre-training/"&gt;pre-training&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://davethehuman.com/notes/post-training/"&gt;post-training&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Some recent research also distinguish a &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;mid-training&lt;/a&gt; stage between them.&lt;/p&gt;</description></item><item><title>preference tuning</title><link>https://davethehuman.com/notes/preference-tuning/</link><pubDate>Tue, 12 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/preference-tuning/</guid><description>&lt;p&gt;&lt;em&gt;Preference tuning&lt;/em&gt; is nowadays often performed through &lt;a href="https://davethehuman.com/notes/rlhf/"&gt;RLHF (Reinforcement Learning From Human Feedback)&lt;/a&gt;, which refines the &lt;a href="https://davethehuman.com/notes/supervised-fine-tuning/"&gt;supervised fine-tuning&lt;/a&gt; stage with preferred stylistic choices.&lt;/p&gt;</description></item><item><title>supervised fine-tuning</title><link>https://davethehuman.com/notes/supervised-fine-tuning/</link><pubDate>Tue, 12 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/supervised-fine-tuning/</guid><description>&lt;p&gt;&lt;em&gt;Supervised fine-tuning&lt;/em&gt; (or &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;instruction tuning&lt;/a&gt;) improves an &lt;a href="https://davethehuman.com/notes/llm/"&gt;Large Language Model&lt;/a&gt; capabilities in question-answering, summarization, translation etc.
Later, the &lt;a href="https://davethehuman.com/notes/preference-tuning/"&gt;preference tuning&lt;/a&gt; refines these capabilities.&lt;/p&gt;</description></item><item><title>chain-of-thought</title><link>https://davethehuman.com/notes/cot/</link><pubDate>Thu, 07 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/cot/</guid><description>&lt;p&gt;&lt;em&gt;COT (Chain of thought)&lt;/em&gt; is a style of intermediate-step generation that the &lt;a href="https://davethehuman.com/notes/llm/"&gt;LLM&lt;/a&gt; uses to make all the &lt;a href="https://davethehuman.com/notes/reasoning/"&gt;reasoning&lt;/a&gt; stages explicit and easier to follow.&lt;/p&gt;
&lt;p&gt;With COT, the LLM does not just recall a fact but it rather gets to the conclusion through intermediate passages, resembling a person articulating their thoughts out loud.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Prompt&lt;/strong&gt;&lt;/em&gt;: &lt;em&gt;&amp;ldquo;Alice has 3 apples and Bob has 5 apples. Alice gives 1 apple to Bob. How many apples do they have together?&amp;rdquo;&lt;/em&gt;&lt;/p&gt;</description></item><item><title>AI agent</title><link>https://davethehuman.com/notes/ai-agent/</link><pubDate>Tue, 05 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/ai-agent/</guid><description>&lt;p&gt;An &lt;em&gt;AI agent&lt;/em&gt; is an autonomous software system that uses a &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;reasoning engine&lt;/a&gt; (typically a &lt;a href="https://davethehuman.com/notes/llm/"&gt;Large Language Model&lt;/a&gt;) to perceive its environment, reason about goals, and execute multi-step actions using external tools to achieve a specific objective. It basically uses an LLM as its brain.&lt;/p&gt;
&lt;p&gt;Unlike standard LLMs, which are reactive (answering prompts), agents are proactive (pursuing goals).
Some example differences between them:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;capabilities: the standard LLM can generate text and code, and the AI agent can get to action execution via APIs/Tools&lt;/li&gt;
&lt;li&gt;logic: the LLM works with &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;one-shot generation&lt;/a&gt; while the AI agent can do iterative planning and correction&lt;/li&gt;
&lt;li&gt;memory: a standard LLM resets at every session while the AI agent&amp;rsquo;s memory persist via external storage&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;a href="https://davethehuman.com/notes/agentic-loop/"&gt;agentic loop&lt;/a&gt; identifies the core components of AI agents.&lt;/p&gt;</description></item><item><title>fine-tuning</title><link>https://davethehuman.com/notes/fine-tuning/</link><pubDate>Tue, 05 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/fine-tuning/</guid><description>&lt;p&gt;During &lt;em&gt;fine-tuning&lt;/em&gt; the &lt;a href="https://davethehuman.com/notes/llm/"&gt;Large Language Model&lt;/a&gt; undergoes a specialised training on curated datasets to follow specific instructions or perform niche tasks.&lt;/p&gt;
&lt;p&gt;There are two key fine-tuning techniques:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://davethehuman.com/notes/supervised-fine-tuning/"&gt;supervised fine-tuning&lt;/a&gt; or &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;SFT&lt;/a&gt; or &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;instruction tuning&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://davethehuman.com/notes/preference-tuning/"&gt;preference tuning&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>hallucination</title><link>https://davethehuman.com/notes/hallucination/</link><pubDate>Tue, 05 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/hallucination/</guid><description>&lt;p&gt;The tendency to state false information with high confidence because it &amp;ldquo;looks&amp;rdquo; linguistically correct.
It is one of the main issues of &lt;a href="https://davethehuman.com/notes/llm/"&gt;Large Language Model&lt;/a&gt;s.&lt;/p&gt;</description></item><item><title>post-training</title><link>https://davethehuman.com/notes/post-training/</link><pubDate>Tue, 05 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/post-training/</guid><description>&lt;p&gt;During &lt;em&gt;post-training&lt;/em&gt;, the model trained during &lt;a href="https://davethehuman.com/notes/pre-training/"&gt;pre-training&lt;/a&gt; undergoes a specialised training stage to learn to respond to user queries.&lt;/p&gt;</description></item><item><title>pre-training</title><link>https://davethehuman.com/notes/pre-training/</link><pubDate>Tue, 05 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/pre-training/</guid><description>&lt;p&gt;During &lt;em&gt;pre-training&lt;/em&gt; the &lt;a href="https://davethehuman.com/notes/llm/"&gt;Large Language Model&lt;/a&gt; learns general patterns, grammar, and facts from the internet/books via &lt;a href="https://davethehuman.com/notes/self-supervised-learning/"&gt;self-supervised learning&lt;/a&gt;.
At this stage, the objective for the LLM is to learn to predict the next word (or &lt;a href="https://davethehuman.com/notes/token/"&gt;token&lt;/a&gt;) in these texts.&lt;/p&gt;
&lt;p&gt;We can think of this stage as &amp;ldquo;raw language prediction&amp;rdquo; that gives the LLM basic capabilities to produce coherent texts.&lt;/p&gt;
&lt;p&gt;A model that has completed the pre-training stage is often called a &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;base model&lt;/a&gt; or a &lt;a href="https://davethehuman.com/coming-soon/" rel="nofollow"&gt;foundation model&lt;/a&gt; and a typical example is the GPT-3 model.&lt;/p&gt;</description></item><item><title>LLM</title><link>https://davethehuman.com/notes/llm/</link><pubDate>Sat, 02 May 2026 00:00:00 +0000</pubDate><guid>https://davethehuman.com/notes/llm/</guid><description>&lt;p&gt;An &lt;em&gt;LLM (Large Language Model)&lt;/em&gt; is a type of artificial intelligence trained on humongous datasets of text to understand, generate, and manipulate human language.
They are built using &lt;a href="https://davethehuman.com/notes/transformer/"&gt;transformer&lt;/a&gt; architectures and function by predicting the next most likely &lt;a href="https://davethehuman.com/notes/token/"&gt;token&lt;/a&gt; (word or part of a word) in a sequence.&lt;/p&gt;
&lt;p&gt;The core technical concepts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;scale&lt;/strong&gt;: &amp;ldquo;Large&amp;rdquo; refers to both the training data (petabytes of text) and the &lt;a href="https://davethehuman.com/notes/parameters/"&gt;parameters&lt;/a&gt; count (billions)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://davethehuman.com/notes/llm-training-pipeline/"&gt;LLM training pipeline&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;context window&lt;/strong&gt;: the maximum amount of text the model can &amp;ldquo;hold in mind&amp;rdquo; at one time during a single conversation&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The main capabilities:&lt;/p&gt;</description></item></channel></rss>