<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Priyanka-Chettri</title>
    <description>The latest articles on DEV Community by Priyanka-Chettri (@priyankaa).</description>
    <link>https://dev.to/priyankaa</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1412856%2F956fa6ee-5d64-428a-9639-c845f1288f7f.png</url>
      <title>DEV Community: Priyanka-Chettri</title>
      <link>https://dev.to/priyankaa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/priyankaa"/>
    <language>en</language>
    <item>
      <title>You Typed a Prompt. What Happens Next?</title>
      <dc:creator>Priyanka-Chettri</dc:creator>
      <pubDate>Thu, 27 Aug 2026 11:38:42 +0000</pubDate>
      <link>https://dev.to/priyankaa/you-typed-a-prompt-what-happens-next-iai</link>
      <guid>https://dev.to/priyankaa/you-typed-a-prompt-what-happens-next-iai</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwav1af8ytzq11owatvjp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwav1af8ytzq11owatvjp.png" alt="LLMs actually work" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You open a chat window and type:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The mole on my face may need a biopsy. Explain this simply.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then you press &lt;strong&gt;Send&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A few moments later, an answer begins appearing on your screen.&lt;/p&gt;

&lt;p&gt;What happened between those two moments?&lt;/p&gt;

&lt;p&gt;The model did not search a dictionary for the meaning of every word. It did not read the prompt exactly as a person would. It also did not write the complete answer internally and reveal it all at once.&lt;/p&gt;

&lt;p&gt;Instead, your prompt went through a pipeline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;messages → tokens → embeddings → Transformer layers
         → logits → probabilities → one new token
         → repeat until finished
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let us follow this one prompt through that journey.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before we begin: training has already happened
&lt;/h2&gt;

&lt;p&gt;Everything in this article happens during &lt;strong&gt;inference&lt;/strong&gt;—the stage where an already-trained model responds to an input.&lt;/p&gt;

&lt;p&gt;The model’s weights, embedding matrix, attention projections, and output matrix were learned earlier during training. They normally remain fixed while your request is being answered.&lt;/p&gt;

&lt;p&gt;Your prompt affects temporary calculations inside the model. It does not immediately retrain the model or permanently rewrite its weights.&lt;/p&gt;

&lt;p&gt;With that out of the way, let us press Send.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Your prompt joins the conversation
&lt;/h2&gt;

&lt;p&gt;You see only the message you typed, but a chat application usually manages a list of messages with roles:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System: You are a helpful assistant.
User: The mole on my face may need a biopsy. Explain this simply.
Assistant:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If this is an ongoing conversation, earlier messages may also be included. An application may additionally provide retrieved documents, tool results, or other instructions.&lt;/p&gt;

&lt;p&gt;The model does not intrinsically understand JavaScript-like objects containing &lt;code&gt;role&lt;/code&gt; and &lt;code&gt;content&lt;/code&gt;. Before inference, a &lt;strong&gt;chat template&lt;/strong&gt; converts the messages into one sequence, using special control tokens to identify message boundaries and roles.&lt;/p&gt;

&lt;p&gt;A simplified sequence might resemble:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;system&amp;gt;
You are a helpful assistant.
&amp;lt;/system&amp;gt;
&amp;lt;user&amp;gt;
The mole on my face may need a biopsy. Explain this simply.
&amp;lt;/user&amp;gt;
&amp;lt;assistant&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The exact control tokens differ between model families. Hugging Face’s &lt;a href="https://huggingface.co/docs/transformers/chat_templating" rel="noopener noreferrer"&gt;chat-template documentation&lt;/a&gt; makes the central point clearly: even a chat model ultimately receives and continues a sequence of tokens.&lt;/p&gt;

&lt;p&gt;The final &lt;code&gt;&amp;lt;assistant&amp;gt;&lt;/code&gt; marker tells a chat-tuned model that an assistant response should come next.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: The tokenizer breaks the sequence into tokens
&lt;/h2&gt;

&lt;p&gt;The model cannot process the raw string directly. A tokenizer converts it into smaller text units called &lt;strong&gt;tokens&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Tokens are not always complete words. Depending on the tokenizer, the sequence might be divided approximately like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The | mole | on | my | face | may | need | a | bio | psy | .
Explain | this | simply | .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That split is only illustrative. A real tokenizer may split the same text differently.&lt;/p&gt;

&lt;p&gt;Tokens can represent:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;complete words;&lt;/li&gt;
&lt;li&gt;parts of words;&lt;/li&gt;
&lt;li&gt;punctuation;&lt;/li&gt;
&lt;li&gt;spaces or space-prefixed pieces;&lt;/li&gt;
&lt;li&gt;bytes or characters;&lt;/li&gt;
&lt;li&gt;special control markers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every token belongs to the tokenizer’s fixed &lt;strong&gt;vocabulary&lt;/strong&gt; and has an integer ID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"The"     → 791
"mole"    → 17342
"face"    → 3234
"biopsy"  → 48291
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These numbers are illustrative too.&lt;/p&gt;

&lt;p&gt;The vocabulary is not a dictionary. It does not store definitions such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mole → a mark on the skin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It stores a mapping closer to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;text piece → token ID
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Subword methods such as BPE, WordPiece, and Unigram allow a limited vocabulary to represent a much larger range of text. The &lt;a href="https://huggingface.co/docs/transformers/tokenizer_summary" rel="noopener noreferrer"&gt;Hugging Face tokenizer guide&lt;/a&gt; compares these approaches.&lt;/p&gt;

&lt;p&gt;At the end of this step, the application has a sequence of IDs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[system-token, 1639, 389, ..., user-token, 791, 17342, ..., assistant-token]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The token IDs themselves do not contain useful semantic meaning. They are indexes telling the model which rows to retrieve next.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Token IDs become embeddings
&lt;/h2&gt;

&lt;p&gt;Inside the model is a learned table called the &lt;strong&gt;embedding matrix&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It contains one starting vector for every vocabulary token:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Token&lt;/th&gt;
&lt;th&gt;Starting embedding&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;mole&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[0.18, -0.42, 0.71, ...]&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;face&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[-0.14, 0.63, 0.27, ...]&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;biopsy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;[0.51, 0.09, -0.32, ...]&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If the vocabulary contains &lt;code&gt;V&lt;/code&gt; tokens and the model’s hidden size is &lt;code&gt;d&lt;/code&gt;, the embedding matrix has the shape:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;V × d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, a model could have 50,000 vocabulary tokens and vectors containing 4,096 values.&lt;/p&gt;

&lt;p&gt;When the tokenizer produces the ID for &lt;code&gt;mole&lt;/code&gt;, the model retrieves the corresponding row from this table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;token "mole"
      ↓
token ID
      ↓
row in embedding matrix
      ↓
starting vector
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is why it is called an embedding: a discrete token is placed into a continuous, high-dimensional numerical space.&lt;/p&gt;

&lt;h3&gt;
  
  
  But &lt;code&gt;mole&lt;/code&gt; can have several meanings
&lt;/h3&gt;

&lt;p&gt;The embedding matrix still contains only one starting vector for the token &lt;code&gt;mole&lt;/code&gt;, even though the word can mean:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;an animal;&lt;/li&gt;
&lt;li&gt;a mark on the skin;&lt;/li&gt;
&lt;li&gt;a spy.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That stored vector is only the starting point. Context will be incorporated as the sequence passes through the Transformer.&lt;/p&gt;

&lt;p&gt;The stored row itself is not rewritten for this prompt. The model creates new &lt;strong&gt;temporary hidden states&lt;/strong&gt; during the forward pass.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: The model adds positional information
&lt;/h2&gt;

&lt;p&gt;The sequences below contain the same words but do not mean the same thing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dog bites man
man bites dog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model therefore needs information about where each token occurs.&lt;/p&gt;

&lt;p&gt;Different Transformer families represent position differently. The original Transformer added sinusoidal positional encodings, while later models may use learned, relative, or rotary position techniques.&lt;/p&gt;

&lt;p&gt;The exact technique is less important for this mental model than its purpose:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Every token enters the Transformer with information about both its identity and its position.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Step 5: The prompt enters the prefill phase
&lt;/h2&gt;

&lt;p&gt;Inference for a decoder-only LLM is often easier to understand as two phases:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Prefill:&lt;/strong&gt; process the prompt that already exists.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decode:&lt;/strong&gt; generate new tokens one at a time.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;During prefill, the model processes the prompt tokens through all its Transformer layers. Because all prompt tokens are already known, their calculations can be performed largely in parallel.&lt;/p&gt;

&lt;p&gt;However, the model still uses a &lt;strong&gt;causal mask&lt;/strong&gt;. A position may use only itself and earlier positions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Position 1 can see: 1
Position 2 can see: 1, 2
Position 3 can see: 1, 2, 3
...
Final prompt position can see: the complete prompt before it
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates an important correction to a common explanation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does the &lt;code&gt;mole&lt;/code&gt; token look ahead at &lt;code&gt;face&lt;/code&gt; and change its meaning?
&lt;/h3&gt;

&lt;p&gt;Not in a decoder-only model if &lt;code&gt;face&lt;/code&gt; appears after &lt;code&gt;mole&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;At the &lt;code&gt;mole&lt;/code&gt; position, causal attention prevents the model from seeing future tokens such as &lt;code&gt;face&lt;/code&gt; and &lt;code&gt;biopsy&lt;/code&gt;. Its hidden state is not later rewritten by those future words.&lt;/p&gt;

&lt;p&gt;Instead, later positions can see &lt;code&gt;mole&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"mole" position   → can see "The mole"
"face" position   → can see "The mole on my face"
"biopsy" position → can see everything before and including "biopsy"
final position     → can see the complete prompt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The final prompt position therefore contains a representation built from the entire preceding prompt. That is the position used to predict the first response token.&lt;/p&gt;

&lt;p&gt;In an encoder-only model such as BERT, attention can be bidirectional, so the &lt;code&gt;mole&lt;/code&gt; position itself can attend to words on both sides. That is not how causal attention in a GPT-style decoder works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Attention lets positions retrieve relevant context
&lt;/h2&gt;

&lt;p&gt;Every Transformer layer creates three projections from each current hidden state:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Query:&lt;/strong&gt; what information is this position looking for?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Key:&lt;/strong&gt; what kind of information does this position offer?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Value:&lt;/strong&gt; what information should this position contribute if selected?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The model compares a query with the keys of the visible positions. After scaling, masking, and softmax, those comparisons become attention weights. The output is a weighted combination of the value vectors.&lt;/p&gt;

&lt;p&gt;The original Transformer expresses this as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Attention(Q, K, V) = softmax(QKᵀ / √dk) V
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This mechanism comes from &lt;a href="https://arxiv.org/abs/1706.03762" rel="noopener noreferrer"&gt;&lt;em&gt;Attention Is All You Need&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For the final prompt position, different attention heads may retrieve information connected to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;mole&lt;/code&gt;, &lt;code&gt;face&lt;/code&gt;, and &lt;code&gt;biopsy&lt;/code&gt; for the topic;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;explain&lt;/code&gt; for the requested action;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;simply&lt;/code&gt; for the desired style;&lt;/li&gt;
&lt;li&gt;earlier system instructions for the expected behaviour.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Attention does not search through every token in the model’s vocabulary. It operates over the token representations in the available sequence.&lt;/p&gt;

&lt;p&gt;It is also not literal, permanent memory. A better description is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Attention is a context-dependent information-routing mechanism.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Step 7: The representations pass through many layers
&lt;/h2&gt;

&lt;p&gt;A Transformer layer contains more than attention. A simplified decoder block includes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hidden states
    ↓
normalization
    ↓
masked self-attention
    ↓
residual connection
    ↓
normalization
    ↓
feed-forward network / MLP
    ↓
residual connection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The precise ordering varies between model architectures.&lt;/p&gt;

&lt;p&gt;Attention moves and combines information across token positions. The feed-forward network performs additional learned processing at each position. Residual connections preserve information across deep stacks, and normalization helps keep computation stable.&lt;/p&gt;

&lt;p&gt;This block is repeated many times.&lt;/p&gt;

&lt;p&gt;Therefore, a token position does not have only one vector throughout the model. It has:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;starting embedding
      ↓
hidden state after layer 1
      ↓
hidden state after layer 2
      ↓
...
      ↓
final hidden state
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These hidden states exist temporarily for this inference request. Hugging Face models can expose the initial embedding output and the hidden states produced by individual layers, as shown in the &lt;a href="https://huggingface.co/docs/transformers/model_doc/gpt2" rel="noopener noreferrer"&gt;GPT-2 model documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 8: The last prompt position becomes the prediction point
&lt;/h2&gt;

&lt;p&gt;After prefill passes through the final Transformer layer, the model has a final hidden state for every prompt position.&lt;/p&gt;

&lt;p&gt;The important one for generation is the final input position—often the last token of an assistant-generation marker added by the chat template.&lt;/p&gt;

&lt;p&gt;Why that position?&lt;/p&gt;

&lt;p&gt;Because in a causal model it can access everything before it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;system instructions
+ conversation history
+ the current user prompt
+ the fact that an assistant response should begin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Its final hidden vector is a compressed, context-dependent representation used to answer:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Given everything before this point, which token should come next?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The model does not need to turn this vector into a human-readable summary first. It sends it directly to the output layer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 9: The unembedding matrix produces logits
&lt;/h2&gt;

&lt;p&gt;At the beginning, the embedding matrix performed this operation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;token ID → hidden-sized vector
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the model needs the opposite direction:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;final hidden vector → one score for every vocabulary token
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A learned output projection performs this operation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;logits = final hidden state × output matrix + bias
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This output projection is often called the:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;language-model head&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LM head&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;output projection&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;or informally, the &lt;strong&gt;unembedding matrix&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the hidden size is &lt;code&gt;d&lt;/code&gt; and vocabulary size is &lt;code&gt;V&lt;/code&gt;, its conceptual shape is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;d × V
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some models reuse the transpose of the input embedding matrix here. This is called &lt;strong&gt;weight tying&lt;/strong&gt;. Other models use separate parameters.&lt;/p&gt;

&lt;p&gt;For our prompt, the output might contain illustrative scores like:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Candidate next token&lt;/th&gt;
&lt;th&gt;Logit&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;It&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;9.1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;A&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;8.4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;This&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;7.9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Banana&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;-3.2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A &lt;strong&gt;logit&lt;/strong&gt; is a raw, unnormalized score. It is not yet a probability.&lt;/p&gt;

&lt;p&gt;The output layer produces a score for every vocabulary token. This is the first point in this journey where the complete output vocabulary is considered at once.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 10: Logits become a probability distribution
&lt;/h2&gt;

&lt;p&gt;Before selecting a token, the inference system may adjust the logits. The precise implementation varies, but temperature and repetition penalties are commonly applied before or as part of building the sampling distribution.&lt;/p&gt;

&lt;h3&gt;
  
  
  Temperature
&lt;/h3&gt;

&lt;p&gt;Temperature controls how sharp the probability distribution becomes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;lower temperature makes high-scoring tokens more dominant;&lt;/li&gt;
&lt;li&gt;higher temperature gives lower-scoring alternatives more opportunity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Temperature does not add knowledge or creativity to the model. It changes the randomness of token selection.&lt;/p&gt;

&lt;h3&gt;
  
  
  Presence and frequency penalties
&lt;/h3&gt;

&lt;p&gt;Some APIs expose repetition controls:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a &lt;strong&gt;presence penalty&lt;/strong&gt; reacts to whether a token has appeared;&lt;/li&gt;
&lt;li&gt;a &lt;strong&gt;frequency penalty&lt;/strong&gt; reacts to how often it has appeared.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These controls normally make repetition less likely. They do not guarantee that a previous token will never appear again, and they do not update the model’s training data.&lt;/p&gt;

&lt;p&gt;Softmax transforms logits into a probability distribution that adds up to 1:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Candidate&lt;/th&gt;
&lt;th&gt;Illustrative probability&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;It&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;52%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;A&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;27%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;This&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;17%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Other tokens&lt;/td&gt;
&lt;td&gt;4%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Step 11: A decoding strategy chooses one token
&lt;/h2&gt;

&lt;p&gt;The system now chooses a token according to its decoding strategy.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Greedy decoding&lt;/strong&gt; selects the highest-probability token.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sampling&lt;/strong&gt; selects from a probability distribution instead of always taking the maximum.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two common sampling controls limit the candidate set:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Top-k&lt;/strong&gt; keeps the &lt;code&gt;k&lt;/code&gt; highest-probability candidates.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Top-p&lt;/strong&gt; keeps the smallest group of candidates whose cumulative probability reaches a threshold.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After filtering, the remaining probabilities are normalized for sampling. Exact processing order and formulas are implementation-specific. Hugging Face documents temperature, top-k, and top-p in its &lt;a href="https://huggingface.co/docs/transformers/main_classes/text_generation" rel="noopener noreferrer"&gt;text-generation guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Suppose the selected token is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;It
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model has generated exactly one token—not the full answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 12: The selected token is appended
&lt;/h2&gt;

&lt;p&gt;The sequence now looks conceptually like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;system&amp;gt; ... &amp;lt;/system&amp;gt;
&amp;lt;user&amp;gt; The mole on my face may need a biopsy. Explain this simply. &amp;lt;/user&amp;gt;
&amp;lt;assistant&amp;gt; It
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the model must predict the token after &lt;code&gt;It&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The generated token receives its embedding and positional information, passes through the Transformer layers, produces another final hidden state, and is projected into a new set of vocabulary logits.&lt;/p&gt;

&lt;p&gt;Perhaps the next token is &lt;code&gt;means&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;It → means
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then the model runs again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;It → means → your → doctor → wants → ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is why decoder-only generation is &lt;strong&gt;autoregressive&lt;/strong&gt;: every generated token becomes part of the input used to generate the following token.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 13: The KV cache prevents wasteful repetition
&lt;/h2&gt;

&lt;p&gt;If the model recalculated every earlier prompt token from scratch after generating each new token, generation would be extremely wasteful.&lt;/p&gt;

&lt;p&gt;Attention uses key and value vectors for previous positions. During prefill, the system stores those vectors in a &lt;strong&gt;KV cache&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;During decoding:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Generate "It"
  → reuse cached K/V for the prompt
  → store K/V for "It"

Generate "means"
  → reuse cached K/V for prompt + "It"
  → store K/V for "means"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model still calculates the new token’s query, key, value, and subsequent layer operations. It simply avoids recalculating the stored keys and values for the previous sequence.&lt;/p&gt;

&lt;p&gt;The cache therefore trades memory for speed. It grows as more tokens are stored, although sliding-window and other attention designs may limit that growth.&lt;/p&gt;

&lt;p&gt;A KV cache does &lt;strong&gt;not&lt;/strong&gt; automatically give the model a larger context window. It makes generation within the supported context more efficient. Hugging Face’s &lt;a href="https://huggingface.co/docs/transformers/kv_cache" rel="noopener noreferrer"&gt;KV-cache guide&lt;/a&gt; describes this reuse and the available speed-versus-memory strategies.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 14: Tokens are decoded and streamed to your screen
&lt;/h2&gt;

&lt;p&gt;The model generates token IDs. The tokenizer’s decoding process converts those IDs back into readable text.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[2181, 3445, 701, ...]
        ↓
"It means your..."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Applications often stream decoded text as tokens or small groups of tokens become available. That is why you see the response appear gradually instead of waiting for the entire paragraph.&lt;/p&gt;

&lt;p&gt;Tokenizer &lt;strong&gt;decoding&lt;/strong&gt; should not be confused with a Transformer decoder. The names are similar, but they refer to different operations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;tokenizer decoding: token IDs → text;&lt;/li&gt;
&lt;li&gt;Transformer decoder: causally processes token representations and generates subsequent tokens.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 15: The model eventually stops
&lt;/h2&gt;

&lt;p&gt;The generation loop continues until a stopping condition occurs. Common conditions include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the model generates an end-of-sequence or end-of-message token;&lt;/li&gt;
&lt;li&gt;the system encounters a configured stop sequence;&lt;/li&gt;
&lt;li&gt;the maximum output-token limit is reached;&lt;/li&gt;
&lt;li&gt;the application stops generation for another reason.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The final generated sequence is decoded, and you see the completed response.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where does the context window fit?
&lt;/h2&gt;

&lt;p&gt;Everything sent to the model must fit within its supported context budget. Depending on the application, that can include:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;system instructions
+ conversation history
+ retrieved documents
+ tool results
+ current prompt
+ generated response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The context window is not permanent memory. It is the amount of tokenized information available to the model for this inference sequence.&lt;/p&gt;

&lt;p&gt;If information is not present in the current context—and is not recovered by an external retrieval or memory system—the model cannot directly attend to it.&lt;/p&gt;

&lt;p&gt;The context window also should not be confused with the KV cache:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Concept&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Context window&lt;/td&gt;
&lt;td&gt;Limits how much tokenized sequence the model can process&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;KV cache&lt;/td&gt;
&lt;td&gt;Stores previous attention keys and values to speed up decoding&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What did not happen?
&lt;/h2&gt;

&lt;p&gt;Several tempting explanations are slightly wrong.&lt;/p&gt;

&lt;h3&gt;
  
  
  The model did not fetch definitions from a dictionary
&lt;/h3&gt;

&lt;p&gt;The tokenizer vocabulary maps text pieces to IDs. Learned meaning is distributed across embeddings and the model’s other parameters.&lt;/p&gt;

&lt;h3&gt;
  
  
  The model did not permanently modify the &lt;code&gt;mole&lt;/code&gt; embedding
&lt;/h3&gt;

&lt;p&gt;It retrieved the stored starting embedding and created temporary hidden states while processing this request.&lt;/p&gt;

&lt;h3&gt;
  
  
  In a decoder-only model, &lt;code&gt;mole&lt;/code&gt; did not look ahead at &lt;code&gt;face&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Causal attention blocks future positions. Later positions combined the earlier &lt;code&gt;mole&lt;/code&gt; token with &lt;code&gt;face&lt;/code&gt;, &lt;code&gt;biopsy&lt;/code&gt;, and the rest of the prompt.&lt;/p&gt;

&lt;h3&gt;
  
  
  Attention did not compare the prompt against the complete vocabulary
&lt;/h3&gt;

&lt;p&gt;Attention combined visible sequence representations. The LM head later produced logits for the full output vocabulary.&lt;/p&gt;

&lt;h3&gt;
  
  
  The model did not generate the complete answer in one operation
&lt;/h3&gt;

&lt;p&gt;It generated one token, appended it, and repeated the process.&lt;/p&gt;

&lt;h3&gt;
  
  
  The KV cache did not increase the context window
&lt;/h3&gt;

&lt;p&gt;It reused earlier key and value tensors so they did not need to be recomputed.&lt;/p&gt;

&lt;h3&gt;
  
  
  The model did not train itself on your message while answering
&lt;/h3&gt;

&lt;p&gt;Ordinary inference uses fixed trained parameters. Your message influences temporary activations and the current output.&lt;/p&gt;

&lt;h2&gt;
  
  
  The entire journey in one view
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. You press Send.

2. The application assembles the conversation:
   system instructions + history + current prompt + assistant marker

3. A chat template converts the messages into one model-specific sequence.

4. The tokenizer converts text pieces into token IDs.

5. The embedding matrix converts every ID into a starting vector.

6. Positional information tells the model where each token occurs.

7. During prefill, causal Transformer layers process the prompt and build
   temporary hidden states and a KV cache.

8. The final prompt position contains information gathered from the complete
   preceding prompt.

9. The LM head / unembedding matrix converts that final hidden state into
   one logit for every vocabulary token.

10. Temperature or repetition controls may adjust the logits, and softmax
    converts them into probabilities.

11. A decoding strategy may filter the candidates and selects one token.

12. The new token is appended to the sequence.

13. During decoding, cached keys and values are reused while one new token is
    processed at a time.

14. The tokenizer converts generated token IDs back into text, which may be
    streamed to your screen.

15. Generation ends when a stopping condition is reached.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The shortest accurate explanation is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When you send a prompt, an LLM converts it into token vectors, processes those vectors through causally masked Transformer layers, uses the final prompt position to score every possible next token, selects one, appends it, and repeats—reusing cached attention information—until the response is complete.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Sources and further reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Vaswani et al., &lt;a href="https://arxiv.org/abs/1706.03762" rel="noopener noreferrer"&gt;&lt;em&gt;Attention Is All You Need&lt;/em&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://huggingface.co/docs/transformers/chat_templating" rel="noopener noreferrer"&gt;Hugging Face: Chat templates&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://huggingface.co/docs/transformers/tokenizer_summary" rel="noopener noreferrer"&gt;Hugging Face: Tokenization algorithms&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://huggingface.co/docs/transformers/model_doc/gpt2" rel="noopener noreferrer"&gt;Hugging Face: GPT-2 hidden states and language-model logits&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://huggingface.co/docs/transformers/main_classes/text_generation" rel="noopener noreferrer"&gt;Hugging Face: Text-generation controls&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://huggingface.co/docs/transformers/kv_cache" rel="noopener noreferrer"&gt;Hugging Face: KV-cache strategies&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Whenever the terminology becomes overwhelming, return to this smaller loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;prompt → tokens → temporary representations → next-token probabilities
       → selected token → repeat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That loop is the heart of decoder-only LLM inference.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>From Neural Networks to LLMs: The Mental Model I Was Missing</title>
      <dc:creator>Priyanka-Chettri</dc:creator>
      <pubDate>Sun, 16 Aug 2026 11:30:08 +0000</pubDate>
      <link>https://dev.to/priyankaa/from-neural-networks-to-llms-a-developers-mental-model-55a6</link>
      <guid>https://dev.to/priyankaa/from-neural-networks-to-llms-a-developers-mental-model-55a6</guid>
      <description>&lt;p&gt;Before jumping into APIs, RAG, agents, and AI applications, I wanted to understand what actually happens inside an LLM.&lt;/p&gt;

&lt;p&gt;I kept coming across terms like &lt;strong&gt;neural networks, deep learning, Transformers, attention, tokens, embeddings, BERT, GPT, and causal language modeling&lt;/strong&gt; — but they all felt like disconnected pieces.&lt;/p&gt;

&lt;p&gt;I could understand each concept individually, but I didn't have a clear picture of how they all connected.&lt;/p&gt;

&lt;p&gt;So I decided to step back and build the mental model from the ground up.&lt;/p&gt;

&lt;p&gt;This article is my attempt to connect those pieces.&lt;/p&gt;




&lt;h1&gt;
  
  
  1. Starting With Neural Networks
&lt;/h1&gt;

&lt;p&gt;Before understanding LLMs, it helps to understand where they come from.&lt;/p&gt;

&lt;p&gt;A neural network is a machine learning model that learns patterns from data.&lt;/p&gt;

&lt;p&gt;For example, suppose we want to recognize handwritten digits.&lt;/p&gt;

&lt;p&gt;We could give a neural network thousands of images of handwritten digits:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Images of handwritten digits
            ↓
      Neural Network
            ↓
     Learned patterns
            ↓
        Prediction
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of manually programming rules such as:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"If the image has this curve and this line, it must be a 3."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;we allow the neural network to learn those patterns from examples.&lt;/p&gt;

&lt;p&gt;The things the network learns are stored in its &lt;strong&gt;parameters&lt;/strong&gt;, primarily weights and biases.&lt;/p&gt;

&lt;p&gt;As we increase the number of layers in a neural network, we enter the world of &lt;strong&gt;deep learning&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Machine Learning
       ↓
Neural Networks
       ↓
Deep Learning
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Different neural network architectures became useful for different types of problems.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CNNs&lt;/strong&gt; became popular for image-related tasks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RNNs and LSTMs&lt;/strong&gt; were commonly used for sequential data such as language.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transformers&lt;/strong&gt; later became extremely important for language and many other sequence-based tasks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But language has a special challenge.&lt;/p&gt;

&lt;h2&gt;
  
  
  Context matters
&lt;/h2&gt;

&lt;p&gt;Consider:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The animal didn't cross the road because it was tired."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To understand what &lt;strong&gt;"it"&lt;/strong&gt; refers to, we need to understand its relationship with the other words in the sentence.&lt;/p&gt;

&lt;p&gt;This is where things like &lt;strong&gt;attention&lt;/strong&gt; become important.&lt;/p&gt;

&lt;p&gt;And this eventually leads us to Transformers.&lt;/p&gt;




&lt;h1&gt;
  
  
  2. Why Did Transformers Come Into the Picture?
&lt;/h1&gt;

&lt;p&gt;Before Transformers, RNNs and LSTMs were commonly used for language-related tasks.&lt;/p&gt;

&lt;p&gt;They processed sequences step by step.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;I → love → machine → learning
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sequential processing created some challenges.&lt;/p&gt;

&lt;p&gt;One major problem was that it made training difficult to parallelize efficiently.&lt;/p&gt;

&lt;p&gt;It could also become difficult to capture relationships between tokens that were far apart in a long sequence.&lt;/p&gt;

&lt;p&gt;Then, in 2017, researchers introduced the &lt;strong&gt;Transformer architecture&lt;/strong&gt; in the paper:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"Attention Is All You Need"&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The original Transformer was designed for &lt;strong&gt;machine translation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The basic architecture looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;English sentence
       ↓
    Encoder
       ↓
Contextual representation
       ↓
    Decoder
       ↓
French sentence
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"I love cats"
      ↓
   Transformer
      ↓
"J'aime les chats"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key idea that made Transformers different was &lt;strong&gt;attention&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Instead of processing a sequence strictly one step at a time, the Transformer could use attention to determine relationships between different tokens.&lt;/p&gt;

&lt;p&gt;This made it much better suited to capturing context and also allowed much more parallel computation during training.&lt;/p&gt;




&lt;h1&gt;
  
  
  3. Attention: The Key Idea
&lt;/h1&gt;

&lt;p&gt;At a high level, attention answers:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"When I'm processing this token, which other tokens should I pay attention to?"&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Consider:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The animal didn't cross the road because it was tired."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When processing &lt;strong&gt;"it"&lt;/strong&gt;, the model needs to determine which other tokens are relevant.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The animal didn't cross the road because it was tired.
                                      ↑
                                     "it"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model can assign different levels of importance to different tokens.&lt;/p&gt;

&lt;p&gt;This is called &lt;strong&gt;self-attention&lt;/strong&gt;, because tokens in the sequence attend to other tokens in the same sequence.&lt;/p&gt;

&lt;p&gt;I initially thought attention was something separate from the Transformer.&lt;/p&gt;

&lt;p&gt;It isn't.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Attention is one of the core mechanisms inside a Transformer.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For now, the mental model I use is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Current token
     ↓
Look at other relevant tokens
     ↓
Combine useful information
     ↓
Create a contextual representation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The mathematical details — Query, Key, Value, attention scores, and matrix multiplication — deserve their own article.&lt;/p&gt;




&lt;h1&gt;
  
  
  4. The Original Transformer: Encoder + Decoder
&lt;/h1&gt;

&lt;p&gt;The original Transformer architecture contained two major components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input
  ↓
Encoder
  ↓
Representation
  ↓
Decoder
  ↓
Output
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A useful beginner mental model is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Encoder → processes and represents the input&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Decoder → generates the output&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For translation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;English
   ↓
Encoder
   ↓
Representation
   ↓
Decoder
   ↓
French
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This architecture was designed around a very natural problem:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Take one sequence and transform it into another sequence.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;English → French&lt;/li&gt;
&lt;li&gt;Article → Summary&lt;/li&gt;
&lt;li&gt;Question → Answer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But later, researchers realized that we don't always need both parts.&lt;/p&gt;

&lt;p&gt;This led to different Transformer architectures.&lt;/p&gt;




&lt;h1&gt;
  
  
  5. Different Transformer Architectures
&lt;/h1&gt;

&lt;p&gt;This was one of the things I initially found confusing.&lt;/p&gt;

&lt;p&gt;If BERT, GPT, T5, and BART are all based on Transformers, why are they different?&lt;/p&gt;

&lt;p&gt;The answer is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Transformer is an architecture, not one specific model.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Different models can use different parts of the Transformer architecture.&lt;/p&gt;

&lt;p&gt;A simple mental model is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                         Transformer
                              │
              ┌───────────────┼───────────────┐
              ↓               ↓               ↓
        Encoder-only     Decoder-only    Encoder-decoder
              ↓               ↓               ↓
            BERT              GPT          T5 / BART
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's look at each one.&lt;/p&gt;

&lt;h2&gt;
  
  
  5.1 Encoder-only Models
&lt;/h2&gt;

&lt;p&gt;An encoder-only model uses the encoder part of the Transformer.&lt;/p&gt;

&lt;p&gt;The encoder processes the input and creates contextual representations.&lt;/p&gt;

&lt;p&gt;The most famous example is &lt;strong&gt;BERT&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;BERT was trained using &lt;strong&gt;Masked Language Modeling&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The cat is [MASK] on the mat.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model tries to predict the missing token.&lt;/p&gt;

&lt;p&gt;Because the encoder can use context from both sides of the masked token, it can build a bidirectional representation.&lt;/p&gt;

&lt;p&gt;This makes encoder-only models useful for tasks such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Text classification&lt;/li&gt;
&lt;li&gt;Sentiment analysis&lt;/li&gt;
&lt;li&gt;Named Entity Recognition&lt;/li&gt;
&lt;li&gt;Search understanding&lt;/li&gt;
&lt;li&gt;Information extraction&lt;/li&gt;
&lt;li&gt;Some question-answering tasks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The simple mental model:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Encoder-only → understand/represent text&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  5.2 Decoder-only Models
&lt;/h2&gt;

&lt;p&gt;A decoder-only model uses the decoder part of the Transformer.&lt;/p&gt;

&lt;p&gt;The most famous example is &lt;strong&gt;GPT&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;GPT stands for:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Generative Pre-trained Transformer&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;GPT is trained primarily using &lt;strong&gt;causal language modeling&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Its objective is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Predict the next token using the previous tokens.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The cat is
       ↓
    sleeping
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The cat is sleeping
                  ↓
              next token
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model keeps generating one token at a time.&lt;/p&gt;

&lt;p&gt;This is why GPT is naturally suited to text generation.&lt;/p&gt;

&lt;p&gt;The simple mental model:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Decoder-only → generate text&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  5.3 Encoder-decoder Models
&lt;/h2&gt;

&lt;p&gt;Encoder-decoder models use both parts.&lt;/p&gt;

&lt;p&gt;The encoder processes the input.&lt;/p&gt;

&lt;p&gt;The decoder generates the output.&lt;/p&gt;

&lt;p&gt;For example, in summarization:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Article
   ↓
Encoder
   ↓
Representation
   ↓
Decoder
   ↓
Summary
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or translation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;English
   ↓
Encoder
   ↓
Representation
   ↓
Decoder
   ↓
French
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Examples include &lt;strong&gt;T5&lt;/strong&gt; and &lt;strong&gt;BART&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The simple mental model:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Encoder-decoder → transform one sequence into another&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  6. BERT vs GPT vs T5 vs BART
&lt;/h1&gt;

&lt;p&gt;This is the simplest table I use to remember them:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Architecture&lt;/th&gt;
&lt;th&gt;Simple mental model&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;BERT&lt;/td&gt;
&lt;td&gt;Encoder-only&lt;/td&gt;
&lt;td&gt;Understand / represent&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GPT&lt;/td&gt;
&lt;td&gt;Decoder-only&lt;/td&gt;
&lt;td&gt;Generate&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;T5&lt;/td&gt;
&lt;td&gt;Encoder-decoder&lt;/td&gt;
&lt;td&gt;Input → Output&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;BART&lt;/td&gt;
&lt;td&gt;Encoder-decoder&lt;/td&gt;
&lt;td&gt;Understand → Generate&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The important thing to remember is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;They are different ways of using the Transformer architecture.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  7. What Is an LLM?
&lt;/h1&gt;

&lt;p&gt;Now we can finally talk about &lt;strong&gt;Large Language Models&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;LLM stands for:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Large Language Model&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's break down the name.&lt;/p&gt;

&lt;h3&gt;
  
  
  Large
&lt;/h3&gt;

&lt;p&gt;"Large" generally refers to the enormous number of learned parameters.&lt;/p&gt;

&lt;p&gt;Parameters are numerical values learned during training, primarily:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Weights&lt;/li&gt;
&lt;li&gt;Biases&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Modern language models can have billions of parameters.&lt;/p&gt;

&lt;h3&gt;
  
  
  Language
&lt;/h3&gt;

&lt;p&gt;The model is trained on large amounts of language data and learns patterns and relationships in that data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Model
&lt;/h3&gt;

&lt;p&gt;It is ultimately a neural network that has learned these patterns through its parameters.&lt;/p&gt;

&lt;p&gt;So:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LLM
│
├── Large
│     └── Many learned parameters
│
├── Language
│     └── Learns patterns from language
│
└── Model
      └── Neural network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  8. GPT as an LLM
&lt;/h1&gt;

&lt;p&gt;GPT-style models are generally &lt;strong&gt;large decoder-only Transformer models&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;They are trained primarily using &lt;strong&gt;causal language modeling&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The basic objective is surprisingly simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Predict the next token based on the previous context.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Suppose the training data contains:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The sky is blue.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model learns to predict:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The
 ↓
sky
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The sky
 ↓
is
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The sky is
 ↓
blue
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This happens across enormous amounts of training data.&lt;/p&gt;

&lt;p&gt;During training:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input context
     ↓
Predict next token
     ↓
Compare with actual token
     ↓
Calculate error
     ↓
Update parameters
     ↓
Repeat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Over time, the model becomes better at predicting the next token.&lt;/p&gt;




&lt;h1&gt;
  
  
  9. How Can Next-token Prediction Do So Many Things?
&lt;/h1&gt;

&lt;p&gt;This was one of the most interesting things for me to understand.&lt;/p&gt;

&lt;p&gt;If GPT is fundamentally trained to predict the next token, how can it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Answer questions?&lt;/li&gt;
&lt;li&gt;Translate languages?&lt;/li&gt;
&lt;li&gt;Summarize articles?&lt;/li&gt;
&lt;li&gt;Write code?&lt;/li&gt;
&lt;li&gt;Write poems?&lt;/li&gt;
&lt;li&gt;Explain concepts?&lt;/li&gt;
&lt;li&gt;Have conversations?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The answer is largely &lt;strong&gt;context&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The model doesn't necessarily need a separate mechanism for every task.&lt;/p&gt;

&lt;p&gt;The prompt provides context about what kind of continuation is expected.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Translate to French:

I love cats.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The context tells the model that the expected continuation is a translation.&lt;/p&gt;

&lt;p&gt;Or:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Summarize this article:

[article]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the expected continuation is a summary.&lt;/p&gt;

&lt;p&gt;Or:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Write a Python function that sorts a list.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the expected continuation is code.&lt;/p&gt;

&lt;p&gt;The underlying mechanism is still:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Context
   ↓
Predict next token
   ↓
Add token to context
   ↓
Predict next token
   ↓
Add token to context
   ↓
Repeat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is one of the most important mental models I have taken away:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A relatively simple training objective — next-token prediction — can result in a model capable of many different language tasks.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  10. Where Do Tokens Come In?
&lt;/h1&gt;

&lt;p&gt;At this point, another question naturally appears:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If the model predicts tokens, does it actually process words directly?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;No.&lt;/p&gt;

&lt;p&gt;The model needs to convert our text into numerical representations that a neural network can process.&lt;/p&gt;

&lt;p&gt;This starts with &lt;strong&gt;tokenization&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"I love programming"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;might become something conceptually like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;["I", " love", " programming"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The exact tokens depend on the tokenizer.&lt;/p&gt;

&lt;p&gt;A token can be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A complete word&lt;/li&gt;
&lt;li&gt;Part of a word&lt;/li&gt;
&lt;li&gt;Punctuation&lt;/li&gt;
&lt;li&gt;A space combined with text&lt;/li&gt;
&lt;li&gt;Other pieces of text&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A token is not necessarily a word.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The token is then mapped to a numerical ID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Text
 ↓
Tokens
 ↓
Token IDs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  11. Where Do Embeddings Come In?
&lt;/h1&gt;

&lt;p&gt;The Transformer doesn't directly work with the token ID as a meaningful representation.&lt;/p&gt;

&lt;p&gt;The token ID is essentially an index.&lt;/p&gt;

&lt;p&gt;The model needs a richer numerical representation.&lt;/p&gt;

&lt;p&gt;This is where &lt;strong&gt;embeddings&lt;/strong&gt; come in.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"cat"
  ↓
Token
  ↓
Token ID
  ↓
Embedding
  ↓
[0.21, -0.42, 0.17, ...]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An embedding is a vector containing many numerical values.&lt;/p&gt;

&lt;p&gt;For example, if an embedding has 4,096 dimensions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[0.21, -0.42, 0.17, ..., 0.31]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;it simply means that the vector contains &lt;strong&gt;4,096 numbers&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;These numbers allow the Transformer to perform mathematical operations on the representation of the token.&lt;/p&gt;

&lt;p&gt;At this point, our mental model becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Text
 ↓
Tokenization
 ↓
Tokens
 ↓
Token IDs
 ↓
Embeddings
 ↓
Transformer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'll go much deeper into tokenization and embeddings in the next article.&lt;/p&gt;




&lt;h1&gt;
  
  
  12. The Big Picture
&lt;/h1&gt;

&lt;p&gt;After connecting all these concepts, this is the mental map I currently have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                    Neural Networks
                           ↓
                     Deep Learning
                           ↓
                     Sequence Models
                           ↓
                      Transformers
                           ↓
                        Attention
                           ↓
              Transformer Architectures
                           ↓
          ┌────────────────┼────────────────┐
          ↓                ↓                ↓
     Encoder-only     Decoder-only    Encoder-decoder
          ↓                ↓                ↓
        BERT              GPT           T5 / BART
                           ↓
                          LLMs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And if I zoom into a GPT-style LLM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User Prompt
     ↓
Tokenization
     ↓
Token IDs
     ↓
Embeddings
     ↓
Transformer Blocks
     ↓
Attention
     ↓
Contextual Representation
     ↓
Next-token prediction
     ↓
Generated token
     ↓
Repeat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This finally gave me the map I was missing.&lt;/p&gt;

&lt;p&gt;I don't need to know every mathematical detail yet.&lt;/p&gt;

&lt;p&gt;I first need to know &lt;strong&gt;where each concept belongs&lt;/strong&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  13. What Happens When I Actually Ask an LLM a Question?
&lt;/h1&gt;

&lt;p&gt;Now comes the question I'm most interested in:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What actually happens inside an LLM when I type a prompt?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Suppose I ask:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;What is the capital of India?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At a very high level, the process looks something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"What is the capital of India?"
             ↓
        Tokenization
             ↓
         Token IDs
             ↓
         Embeddings
             ↓
   Positional Information
             ↓
     Transformer Blocks
             ↓
         Attention
             ↓
 Contextual Representation
             ↓
        Output Scores
             ↓
          Softmax
             ↓
 Probability Distribution
             ↓
        Next Token
             ↓
           Repeat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And this is where I want to go next.&lt;/p&gt;




&lt;h1&gt;
  
  
  14. What's Next?
&lt;/h1&gt;

&lt;p&gt;Now that I have the high-level map, I want to open up the black box.&lt;/p&gt;

&lt;p&gt;In the next article, I'll start from the beginning of the inference process:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Prompt
  ↓
Tokenization
  ↓
Token IDs
  ↓
Embeddings
  ↓
Positional information
  ↓
Transformer
  ↓
Attention
  ↓
Hidden states
  ↓
Unembedding
  ↓
Logits
  ↓
Softmax
  ↓
Probability distribution
  ↓
Next token
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'll break down each step and answer questions like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What exactly is a token?&lt;/li&gt;
&lt;li&gt;What does an embedding represent?&lt;/li&gt;
&lt;li&gt;What does "4,096-dimensional embedding" actually mean?&lt;/li&gt;
&lt;li&gt;How does positional information work?&lt;/li&gt;
&lt;li&gt;How does self-attention calculate which tokens are relevant?&lt;/li&gt;
&lt;li&gt;What are Query, Key, and Value?&lt;/li&gt;
&lt;li&gt;What is a hidden state?&lt;/li&gt;
&lt;li&gt;What is the unembedding matrix?&lt;/li&gt;
&lt;li&gt;How does the model turn its final representation into scores for every possible next token?&lt;/li&gt;
&lt;li&gt;What exactly does softmax do?&lt;/li&gt;
&lt;li&gt;Where does temperature come into the picture?&lt;/li&gt;
&lt;li&gt;How does the model finally choose the next token?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is not to start with mathematics.&lt;/p&gt;

&lt;p&gt;The goal is to first build an intuitive mental model and then introduce the mathematics once the pieces make sense.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Takeaway
&lt;/h1&gt;

&lt;p&gt;If I had to summarize everything I've learned so far in one sentence:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;An LLM like GPT is a large neural network built using the Transformer architecture, trained on language to predict the next token, and capable of many language tasks because of the patterns and representations it learns from enormous amounts of data.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The biggest thing that changed for me was realizing that all these terms aren't isolated concepts.&lt;/p&gt;

&lt;p&gt;They fit together:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Neural Networks
      ↓
Deep Learning
      ↓
Transformers
      ↓
Attention
      ↓
Encoder / Decoder Architectures
      ↓
GPT
      ↓
LLMs
      ↓
Tokens
      ↓
Embeddings
      ↓
Transformer Processing
      ↓
Next-token Prediction
      ↓
Generated Text
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that I have the map, I'm ready to understand what's actually happening &lt;strong&gt;inside the box&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>deeplearning</category>
      <category>llm</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Before I Built with AI, I Wanted to Understand What Was Underneath</title>
      <dc:creator>Priyanka-Chettri</dc:creator>
      <pubDate>Sun, 09 Aug 2026 13:58:48 +0000</pubDate>
      <link>https://dev.to/priyankaa/before-i-built-with-ai-i-wanted-to-understand-what-was-underneath-3a64</link>
      <guid>https://dev.to/priyankaa/before-i-built-with-ai-i-wanted-to-understand-what-was-underneath-3a64</guid>
      <description>&lt;p&gt;As I started learning Applied AI, I realized I didn't want to jump straight into LLM APIs, RAG, agents, and prompting without understanding what was underneath.&lt;/p&gt;

&lt;p&gt;So I went back to the basics.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;From Machine Learning to Deep Learning&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Traditional machine learning often relied on humans to decide which features were important.&lt;/p&gt;

&lt;p&gt;For example, for digit recognition, we might manually identify:&lt;/p&gt;

&lt;p&gt;edges&lt;br&gt;
curves&lt;br&gt;
strokes&lt;br&gt;
shapes&lt;/p&gt;

&lt;p&gt;Neural networks changed this approach.&lt;/p&gt;

&lt;p&gt;Instead of manually defining all the features, a neural network can learn useful representations from the data.&lt;/p&gt;

&lt;p&gt;A simple network looks like:&lt;/p&gt;

&lt;p&gt;Input → Hidden Layers → Output&lt;/p&gt;

&lt;p&gt;Each neuron uses weights and biases, and during training the model adjusts these parameters to reduce its error.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;cost function&lt;/em&gt; tells us how wrong the prediction is.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Backpropagation&lt;/em&gt; helps determine how each parameter contributed to that error, and gradient descent updates the parameters in a direction that reduces the cost.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Deep Learning?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When we stack many layers, we get deep neural networks.&lt;/p&gt;

&lt;p&gt;The interesting part is that different layers can learn increasingly complex representations:&lt;/p&gt;

&lt;p&gt;Pixels → Edges → Shapes → Parts → Object&lt;/p&gt;

&lt;p&gt;This ability to automatically learn representations from raw data became one of the major strengths of deep learning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From Deep Learning to Generative AI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A neural network doesn't have to be supervised. It can be trained using supervised, unsupervised, self-supervised, or reinforcement learning.&lt;/p&gt;

&lt;p&gt;Modern AI heavily relies on self-supervised learning.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;"The capital of France is ___"&lt;/p&gt;

&lt;p&gt;Target → Paris&lt;/p&gt;

&lt;p&gt;The text itself provides the training target. This makes it possible to learn from enormous amounts of data without manually labeling everything.&lt;/p&gt;

&lt;p&gt;Then came &lt;em&gt;Transformers&lt;/em&gt;, which introduced the idea of attention—allowing models to learn relationships between different parts of a sequence efficiently.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Large Transformers&lt;/em&gt; trained on massive datasets became foundation models.&lt;/p&gt;

&lt;p&gt;When these models are trained to work with language at enormous scale, we get &lt;em&gt;Large Language Models&lt;/em&gt; (LLMs).&lt;/p&gt;

&lt;p&gt;And when models can use what they've learned to generate new text, code, images, audio, or video, we call it Generative AI.&lt;/p&gt;

&lt;p&gt;The Mental Model&lt;/p&gt;

&lt;p&gt;This isn't a perfectly linear hierarchy, but this is the mental map that helped me:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Machine Learning&lt;br&gt;
      ↓&lt;br&gt;
Neural Networks&lt;br&gt;
      ↓&lt;br&gt;
Deep Learning&lt;br&gt;
      ↓&lt;br&gt;
Transformers&lt;br&gt;
      ↓&lt;br&gt;
Self-Supervised Learning&lt;br&gt;
      ↓&lt;br&gt;
Foundation Models&lt;br&gt;
      ↓&lt;br&gt;
LLMs&lt;br&gt;
      ↓&lt;br&gt;
Generative AI&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The goal isn't to become an ML researcher before becoming an Applied AI Engineer.&lt;/p&gt;

&lt;p&gt;For me, the goal is simpler:&lt;/p&gt;

&lt;p&gt;Understand what problem each concept solved, so that when I build on top of AI models, I know what I'm actually building on.&lt;/p&gt;

&lt;p&gt;That's the foundation I'm starting my Applied AI journey with.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>deeplearning</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>The React Pattern That Changed How I Build Reusable Components</title>
      <dc:creator>Priyanka-Chettri</dc:creator>
      <pubDate>Thu, 09 Oct 2025 10:33:07 +0000</pubDate>
      <link>https://dev.to/priyankaa/the-react-pattern-that-changed-how-i-build-reusable-components-k2o</link>
      <guid>https://dev.to/priyankaa/the-react-pattern-that-changed-how-i-build-reusable-components-k2o</guid>
      <description>&lt;p&gt;While building components for a design system, I initially followed an existing pattern that was already in place- they all had a consistent pattern. I didn’t know what it was called, but I loved how scalable and flexible it felt.&lt;/p&gt;

&lt;p&gt;Later, I realized… this approach had a name — &lt;strong&gt;the Compound Component Pattern&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let me explain with a simple example 👇&lt;/p&gt;

&lt;p&gt;Imagine we have a Flyout Button that, when clicked, opens a menu with a list.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw9l94eb7z92gvmti85oo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw9l94eb7z92gvmti85oo.png" alt="Flyout with menu" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, in a typical setup, if we want the Flyout to appear over a specific component, we’d probably pass a prop like toggle from the parent and control it there.&lt;br&gt;
That works — but what if we want to use this Flyout anywhere in the app, with any icon, and in multiple combinations?&lt;/p&gt;

&lt;p&gt;That’s where the Compound Pattern comes into play.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧩 How to Identify When to Use It&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;If there’s a shared state between two or more components, that shared state lives in the parent component&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You want flexibility and reusability without passing props down multiple levels&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You’d rather use React Context to manage state than prop drilling&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Then you’re probably looking at a perfect use case for the &lt;strong&gt;Compound Design Pattern.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A component with compound pattern in action looks like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Flyout&amp;gt;
  &amp;lt;Flyout.Toggle&amp;gt;
    &amp;lt;Icon name="more" /&amp;gt;
  &amp;lt;/Flyout.Toggle&amp;gt;
  &amp;lt;Flyout.Menu&amp;gt;
    &amp;lt;Flyout.Item&amp;gt;Profile&amp;lt;/Flyout.Item&amp;gt;
    &amp;lt;Flyout.Item&amp;gt;Settings&amp;lt;/Flyout.Item&amp;gt;
    &amp;lt;Flyout.Item&amp;gt;Logout&amp;lt;/Flyout.Item&amp;gt;
  &amp;lt;/Flyout.Menu&amp;gt;
&amp;lt;/Flyout&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, each sub-component (&lt;em&gt;Toggle, Menu, Item&lt;/em&gt;) communicates through a shared context, not props.&lt;br&gt;
This makes the component incredibly reusable, readable, and extensible — a win for design systems.&lt;/p&gt;

&lt;p&gt;This pattern truly changed how I think about building components in React.&lt;br&gt;
Once you start using the Compound Pattern, you realize it’s not just about cleaner code — it’s about creating a language for your UI.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>designpatterns</category>
      <category>ui</category>
    </item>
    <item>
      <title>𝐖𝐡𝐚𝐭 𝐛𝐮𝐢𝐥𝐝𝐢𝐧𝐠 𝐚 𝐬𝐢𝐦𝐩𝐥𝐞 𝐓𝐨-𝐃𝐨 𝐥𝐢𝐬𝐭 𝐢𝐧 𝐑𝐞𝐚𝐜𝐭 𝐜𝐚𝐧 𝐭𝐞𝐚𝐜𝐡 𝐲𝐨𝐮 𝐚𝐬 𝐚 𝐁𝐞𝐠𝐢𝐧𝐧𝐞𝐫🎯</title>
      <dc:creator>Priyanka-Chettri</dc:creator>
      <pubDate>Sun, 29 Sep 2024 10:03:50 +0000</pubDate>
      <link>https://dev.to/priyankaa/--cj6</link>
      <guid>https://dev.to/priyankaa/--cj6</guid>
      <description>&lt;p&gt;Creating a to-do in React appears simple. However, as you introduce add on features, it opens a whole new door to explore and understand concepts. Here's how this project can enhance your understanding.&lt;/p&gt;

&lt;p&gt;✅ 𝐂𝐨𝐦𝐩𝐨𝐧𝐞𝐧𝐭 𝐒𝐭𝐫𝐮𝐜𝐭𝐮𝐫𝐞: Break tasks into manageable chunks with reusable components.&lt;br&gt;
 ✅ 𝐏𝐫𝐨𝐩𝐬 &amp;amp; 𝐃𝐚𝐭𝐚 𝐅𝐥𝐨𝐰: Pass data seamlessly between parent and child components.&lt;br&gt;
 ✅ 𝐂𝐨𝐧𝐝𝐢𝐭𝐢𝐨𝐧𝐚𝐥 𝐑𝐞𝐧𝐝𝐞𝐫𝐢𝐧𝐠: Show or render components based on a condition ( example of to do: If the edit mode is on then place an input field).&lt;br&gt;
 ✅ 𝐄𝐯𝐞𝐧𝐭 𝐇𝐚𝐧𝐝𝐥𝐢𝐧𝐠 : Understand how to handle clicks, typing, and more. On delete button click how can you delete the to-do?&lt;br&gt;
 ✅ 𝐑𝐞𝐚𝐜𝐭 𝐡𝐨𝐨𝐤𝐬: Understand when to use useState and useEffect.&lt;/p&gt;

&lt;p&gt;Once you've built a basic to-do application, it's time to level up by adding features that make your app more robust and user-friendly.&lt;/p&gt;

&lt;p&gt;✅ 𝐈𝐦𝐩𝐥𝐞𝐦𝐞𝐧𝐭 𝐋𝐨𝐜𝐚𝐥 𝐒𝐭𝐨𝐫𝐚𝐠𝐞: With every change in the to-dos store the input into a local storage. Use useEffect to update the local storage.&lt;br&gt;
 ✅ 𝐈𝐦𝐩𝐫𝐨𝐯𝐞 𝐒𝐭𝐚𝐭𝐞 𝐌𝐚𝐧𝐚𝐠𝐞𝐦𝐞𝐧𝐭 𝐰𝐢𝐭𝐡 𝐂𝐨𝐧𝐭𝐞𝐱𝐭 𝐀𝐏𝐈: To avoid prop drilling if any and manage state more effectively, implement the React Context API. Understanding Context API solidifies your base.&lt;br&gt;
 ✅ 𝐎𝐩𝐭𝐢𝐦𝐢𝐬𝐞 𝐰𝐢𝐭𝐡 𝐑𝐞𝐚𝐜𝐭 𝐒𝐭𝐚𝐭𝐞 𝐌𝐚𝐧𝐚𝐠𝐞𝐦𝐞𝐧𝐭 𝐋𝐢𝐛𝐫𝐚𝐫𝐢𝐞𝐬: As your application grows, you might notice unnecessary re-renders, especially when working with multiple components and features. Libraries like Recoil, Redux, or Zustand can help manage state efficiently and prevent re-renders.&lt;/p&gt;

&lt;p&gt;By adding these features, you're not only enhancing functionality but also learning critical concepts like local storage, context-based state management, and optimising rendering behaviour, which are essential for building scalable React applications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmnzhzfj3tkqfxl2010ea.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmnzhzfj3tkqfxl2010ea.png" alt="A snapshot of the to do list app" width="800" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Accent Colors for Checkboxes and Radios</title>
      <dc:creator>Priyanka-Chettri</dc:creator>
      <pubDate>Wed, 05 Jun 2024 12:17:05 +0000</pubDate>
      <link>https://dev.to/priyankaa/accent-colors-for-checkboxes-and-radios-5jb</link>
      <guid>https://dev.to/priyankaa/accent-colors-for-checkboxes-and-radios-5jb</guid>
      <description>&lt;p&gt;Utilize &lt;strong&gt;accent-&lt;/strong&gt;* utilities to modify the accent color of elements, ideal for customizing the appearance of &lt;strong&gt;&lt;em&gt;checkboxes&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;radio buttons&lt;/em&gt;&lt;/strong&gt; by replacing the browser's default color.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6o9ahim44xl2w93z0t13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6o9ahim44xl2w93z0t13.png" alt="Cover" width="800" height="819"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, I have given accent color accent-pink-500, you can customize the color according to your need.This comes handy if you want to customize the look of your check boxes and radio buttons according to your theme.&lt;/p&gt;

&lt;p&gt;The code for it is given below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="mx-auto my-auto border h-[100px] w-[300px] rounded-md flex justify-center items-center gap-4 shadow-lg"&amp;gt;
&amp;lt;label class="font-semibold font-serif"&amp;gt;Accent Color&amp;lt;/label&amp;gt;
&amp;lt;input type="checkbox" class="accent-pink-500 " id="checkbox" &amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thanks for reading!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Unveiling the Magic of hover, focus and active variants in Tailwind CSS.</title>
      <dc:creator>Priyanka-Chettri</dc:creator>
      <pubDate>Tue, 28 May 2024 07:43:15 +0000</pubDate>
      <link>https://dev.to/priyankaa/unveiling-the-magic-of-hover-focus-and-active-variants-in-tailwind-css-54pg</link>
      <guid>https://dev.to/priyankaa/unveiling-the-magic-of-hover-focus-and-active-variants-in-tailwind-css-54pg</guid>
      <description>&lt;p&gt;💡𝐏𝐫𝐨 𝐓𝐢𝐩: Make your UI elements pop with Tailwind CSS! Use 𝐡𝐨𝐯𝐞𝐫, 𝐟𝐨𝐜𝐮𝐬, and 𝐚𝐜𝐭𝐢𝐯𝐞 variants to enhance user experience and engagement. Your designs will thank you!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F120ip3lm0tdb6f5ay1cb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F120ip3lm0tdb6f5ay1cb.png" alt="Cover Page" width="800" height="819"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Dive into this demo to see them in action!&lt;br&gt;
 Ready to give it a try? Check out the code below and start &lt;br&gt;
 experimenting! 👇&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/-NeBA9blo4o"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;➡️ Snippet of "hover" variant applied to a button.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4id33vf2k2eqxhk9sr2z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4id33vf2k2eqxhk9sr2z.png" alt="Hover Code" width="800" height="691"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;➡️ Snippet of a "focus" variant applied to a button&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F81xldmxajk6xjuizqloc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F81xldmxajk6xjuizqloc.png" alt="Focus Code" width="800" height="691"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;➡️ Snippet of an "active" variant applied to a button&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhrkqx3e0ahxx89j9zs9a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhrkqx3e0ahxx89j9zs9a.png" alt="Active Code" width="800" height="618"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Overcoming Tight Coupling In OOPs With Effective Solutions</title>
      <dc:creator>Priyanka-Chettri</dc:creator>
      <pubDate>Mon, 08 Apr 2024 20:14:28 +0000</pubDate>
      <link>https://dev.to/priyankaa/overcoming-tight-coupling-in-oops-with-effective-solutions-3d3g</link>
      <guid>https://dev.to/priyankaa/overcoming-tight-coupling-in-oops-with-effective-solutions-3d3g</guid>
      <description>&lt;p&gt;Familiar with "&lt;strong&gt;tight coupling&lt;/strong&gt;" in OOPs? It's a common issue where classes become overly interdependent, making code changes cumbersome and error-prone. Imagine updating one class and having to revise multiple others due to tight dependencies. &lt;/p&gt;

&lt;p&gt;This is how a tightly coupled code looks like:&lt;/p&gt;

&lt;p&gt;Here, the direct instantiation of &lt;strong&gt;Engine&lt;/strong&gt; class within the constructor of &lt;strong&gt;Car&lt;/strong&gt; class creates a strong dependency between the two classes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3wpv8cjwwc020qgwv9z4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3wpv8cjwwc020qgwv9z4.png" alt="Tight coupled code" width="800" height="713"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The problem encountered in the above code can be solved using &lt;strong&gt;Dependency injection&lt;/strong&gt; in Spring and by promoting the use of &lt;strong&gt;Interfaces&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;METHOD 1: Dependency injection using constructor injection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt; ❌: Tight coupling occurs when one class directly instantiates another class, using the “&lt;strong&gt;new&lt;/strong&gt;” keyword&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt; 💡: Use Dependency injection to pass dependency from external sources, highly used in Spring . In the below figure the engine object is being passed as the parameter to the constructor from an external source.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsaltogymi79118k8w8xl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsaltogymi79118k8w8xl.png" alt="Solving tight coupling using dependency injection" width="800" height="798"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;METHOD 2: Using interfaces&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt; ❌: Classes depending on  concrete implements rather than interfaces, causes tightly coupled relationship between them. To say,  if the type of engine to be used by a car is changed the whole code has to be re written again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt; 💡: Use interfaces instead of using concrete classes, this gives more flexibility to a code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqeb56njnfmotzkxh1wrz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqeb56njnfmotzkxh1wrz.png" alt="Solving tight coupling using Interface" width="800" height="913"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Follow &lt;a href="https://dev.to/priyankachettri"&gt;Me&lt;/a&gt; for such contents!&lt;br&gt;
Happy Learning :)&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>spring</category>
      <category>java</category>
      <category>oops</category>
    </item>
  </channel>
</rss>
