The inners of Large Language Models

Search for a command to run...

No comments yet. Be the first to comment.
The inners and workings of prompts for LLM. What do they do and how do they do it
INTRODUCTION: THE ART AND SCIENCE OF AI COMMUNICATION Welcome to the exciting world of Prompt Engineering! Whether you are a developer, a writer, a business leader, or simply an AI enthusiast, mastering the art of communication with artificial intell...
In Part 1 of this series we explored the friendly foundations of machine learning: Classification Regression Clustering Neural networks Training Testing Overfitting Decision trees Reinforceme

Machine Learning with Trufa and Paula: A Friendly Guide to How Models Learn

The Microsoft Copilot Ecosystem

I love words, I compile words and always search what they mean. My native language is español and to my surprise there are not that many on line. México where I'm from has no official online language

Hey everyone, Roberto here and there and everywhere! We've all worked with data, we've all felt the pain of waiting. When you build a beautiful Power BI report, but the data is from yesterday. You have to wait for the nightly refresh to see the lates...


Welcome to the inner workings of Large Language Models! In this chapter, Trufa will guide Paula (and you) through the fascinating world of how LLMs actually work. We'll demystify the "black box" and explore the fundamental concepts that make these powerful AI systems tick.
Understanding LLM internals isn't just academic curiosity—it directly impacts how you craft better prompts. When you know how tokens work, how text is encoded, and how models process information, you can write prompts that work with the system rather than against it.

Large Language Models didn't appear overnight. They're the result of decades of research and innovation in natural language processing and machine learning.
The evolution of language models represents one of the most remarkable progressions in artificial intelligence. Early statistical models could barely predict the next word in a sentence. Neural networks brought pattern recognition capabilities. The transformer architecture revolutionized how models understand context. And modern LLMs like GPT, Claude, and Manus can engage in complex reasoning, creative writing, and technical problem-solving.
Key Milestones:
Tokens are the fundamental units that LLMs process. Think of them as the "words" that the model actually sees—but they're not always whole words.

Imagine you're building with LEGO blocks. Some blocks are big (common words like "the" or "hello"), and some are small (parts of words like "un-", "-ing"). LLMs work the same way—they break text into manageable pieces called tokens.
Why This Matters for Prompting:

Tokenization is the process of converting a sequence of characters into a sequence of token IDs that the model can process mathematically.
Formal Definition: Given a vocabulary V = {t₁, t₂, ..., tₙ}, tokenization is a function:
tokenize: String → [TokenID]
Each token ID corresponds to a specific entry in the model's vocabulary, which is then mapped to a high-dimensional embedding vector for processing.
Encoding is the bridge between human language and machine-readable numbers. It's how "Hello, world!" becomes something a neural network can process.

Think of encoding like translating a book into a secret code. Each word or word-part gets assigned a unique number. The LLM then works with these numbers, performing mathematical operations to understand meaning and generate responses.
The Pipeline:

Modern LLMs use sophisticated subword tokenization algorithms to balance vocabulary size with coverage.
Encoding Process:
Mathematical Representation:
V = vocabulary set
merge(a, b) → ab (creates new token)
The encoding process ensures that even rare or unseen words can be represented by combining subword units.
Byte-Pair Encoding (BPE) is one of the most popular tokenization algorithms. Let's see it in action with a real Spanish poem.

BPE works like creating shortcuts for common patterns. If you see "qu" + "e" appearing together frequently in Spanish text, BPE merges them into a single token "que".
Example with Spanish:
This is why common Spanish words like "que", "del", "por" become single tokens, making processing more efficient.

BPE Algorithm:
1. Initialize vocabulary V with all characters
2. Count all adjacent character pairs in corpus
3. Find most frequent pair (a, b)
4. Merge pair: a + b → ab
5. Add 'ab' to vocabulary V
6. Repeat until desired vocabulary size
Pseudocode:
while |V| < target_size:
pair = most_frequent(text)
merge(pair)
V.add(merged_token)
Spanish Poem Analysis: Using "A DULCINEA DEL TOBOSO" by Cervantes, we can observe:

You don't need to implement BPE yourself, but understanding why it exists helps you write better prompts.
Key Benefits:
Impact on Your Prompts:
Now let's peek inside the actual architecture of modern LLMs.

Manus, like other modern LLMs, is built on the transformer architecture with several key components:
Core Components:
Manus is optimized for cloud deployment with efficient attention mechanisms and scalable architecture.

While all modern LLMs share the transformer foundation, each has unique architectural choices:
Similarities (✓):
Differences (★):
Understanding these differences helps you choose the right model for your task and adjust your prompting strategy accordingly.

Congratulations! You've successfully explored the inner workings of Large Language Models. The mysterious black box is now transparent, revealing the elegant mechanisms that power modern AI.
Key Takeaways:
LLMs evolved from simple statistical models to sophisticated transformer-based architectures over several decades of research and innovation.
Tokens are the fundamental units of processing—understanding them helps you write more efficient prompts and manage context limits.
Encoding bridges human language and machine mathematics—text becomes numbers, gets processed, and converts back to text.
Byte-Pair Encoding (BPE) balances efficiency and coverage—it creates shortcuts for common patterns while handling rare words through subword composition.
Modern LLMs share transformer architecture but differ in implementation—Manus, ChatGPT, and Claude each have unique optimizations and design choices.
How This Knowledge Improves Your Prompting:
Preview of Next Chapter: Now that you understand how LLMs work internally, Chapter 3 will teach you how to communicate effectively with them through the art of contextual prompting.

Ready to test your understanding? Trufa challenges you to apply what you've learned!
Estimate how many tokens these prompts would use:
Given these common words, predict which would be single tokens and which would be split:
Rewrite this verbose prompt to use fewer tokens while maintaining clarity:
"I would like you to please write for me a comprehensive and detailed explanation about how neural networks work, including all the technical details and mathematical formulations."
Research and compare:
Use a tokenizer tool (like OpenAI's tokenizer or Hugging Face's) to:
Continue to Chapter 3: The Art of Contextual Prompting →
By Roberto | @soyroberto
For more content, visit allthingscloud.net