Explains the full flow from input through tokens to a response without memorizing unfamiliar terms separately.
Difficulty
Absolute beginner
Structure
3 core units · 15 chapters
CORE UNIT 1 / 3
Understanding LLMs
Explains what an LLM does and what it does not guarantee.
Difficulty
Absolute beginner
Structure
Lessons 5 · Labs 2 · Assessment
Diagrams and tables: composed by the author using each lesson's official primary sources. Find the originals and review dates at the end of that lesson.
NEW HIRE ONBOARDING
Start in the order you would receive your first assignment
So that even a new hire with no prior IT background can follow along, we start with the situation, the task, the evidence, and when to report, before difficult definitions.
01
Read the situation in one sentence
Compute the probabilities of several candidates following “Tonight’s dinner is” and choose one.
02
Today's assignment
Explains what an LLM does and what it does not guarantee.
03
Evidence that shows the work is complete
Small models are useful for summaries, classification, and narration drafts.
04
When to stop and ask a senior colleague
It is not a database that retrieves a complete sentence all at once.
Unpack unfamiliar terms first
Token
Text pieces the model reads and writes
Inference
Execution that generates answers using a trained model
Hallucination
The phenomenon of generating plausible content that has no factual basis
PREREQUISITE CHECK
Three things to check before reading
This is not a test of memorized answers. Think about each question first, then open the explanation to review the foundational concepts used in this course.
1Are programs and files the same thing?
They are not the same. A file is stored data; a program is an executable procedure that reads files and performs computation. This distinction explains the relationship between model weight files and runtimes such as Ollama.
2Why does a computer need memory?
Memory is a temporary workspace that makes data from storage quickly available to computing devices. A local LLM must keep context and intermediate computation values in memory as well as model weights.
3Do natural explanations and verified facts mean the same thing?
They are not the same. Readable sentences are a matter of writing quality, while factual correctness is a matter of accuracy that must be checked separately against sources, measurements, and calculations.
TEXTBOOK GUIDE
Main text that covers each concept from its background to the criteria for judging it
We explain the material section by section so readers new to IT can connect causes and effects without memorizing terms.
CONCEPT FLOW
How the chapters connect
The chapters are not isolated short answers to memorize. Follow them from left to right to see how each chapter's concepts support the next decision.
1.An LLM is a next-token predictor→
2.Distinguish training from inference→
3.A first look at Transformers and attention→
4.Hallucination and verification→
5.Advantages and disadvantages of local LLMs
Understanding LLMs: the overall map. If you lose track while reading the detailed explanations and chapters below, return to this sequence.
CONTROLLED EXPLANATION
Explore the order in which concepts build on each other
It does not start automatically. Play, or select the previous or next step, to see how the current concept connects to the next decision, step by step.
Current explanation · 1/5
An LLM is a next-token predictor
Read the tokens that the sentence is split into, and repeatedly compute the probability of the next token.
Natural sentence generation and fact-checking are different skills.
Up next: Distinguish training from inference, where this standard continues to apply.
See the full step description
1. An LLM is a next-token predictor
Read the tokens that the sentence is split into, and repeatedly compute the probability of the next token. Natural sentence generation and fact-checking are different skills.
2. Distinguish training from inference
Training is a long process of changing weights; inference produces answers using already-trained weights. Downloading a model is not training.
3. A first look at Transformers and attention
Attention calculates which preceding tokens to attend to more when producing the current answer. Contextual representations are updated as they pass through the layers.
4. Hallucination and verification
LLMs optimize plausibility, so they can confidently invent facts they do not know. Check original sources for important numerical, legal and medical information.
5. Advantages and disadvantages of local LLMs
Data control and offline use are advantages, and the responsibility for equipment, operation, and quality lies with the user. Small models are useful for summaries, classification, and narration drafts.
The text description below shows the same content without the animation. Your operating system's reduced-motion setting is also respected.Conceptual explanation 01
First, picture the whole map
A Large Language Model (LLM) may look like a single program that understands written instructions, but a real service consists of several layers. When a user enters a question, the application assembles the system prompt (hidden operating instructions), the previous conversation, retrieved documents, and the question in a fixed order. A tokenizer, the component that splits text into pieces for the model, converts this text into an array of numbers called token IDs, and a runtime such as Ollama, llama.cpp, MLX, or vLLM performs the computation with the model weights. Finally, the reverse process turns the numeric pieces back into sentences people can read. Understanding a local LLM means looking at this entire flow, not just the model name.
The model weights at the bottom are a very large set of numbers adjusted during training. A file that stores only these numbers cannot take questions, draw an interface, or search the internet on its own. It needs a runtime to read the file format, a Central Processing Unit (CPU) or Graphics Processing Unit (GPU) to compute, a chat template to format inputs, and an app to show results. This is why the same model file can produce different speeds and answers when runtime settings, prompt formats, context lengths, or quantization methods differ.
Even when a user says “I want to put my data into AI,” first break down the function they want. Retrieval-Augmented Generation (RAG), which retrieves new facts and attaches them next to the question, fine-tuning, which adjusts answer format and behavior, and history management, which feeds earlier conversation into the next request, are different functions. Assuming the model has permanently learned a PDF you made searchable, or putting the latest internal policies into fine-tuning data to fix tone, makes maintenance difficult. Only with this distinction can you choose the right solution without overbuying tools and hardware.
How to read the figure A model file alone does not produce an answer. Each of the five layers owns a different job, so when something fails, start by identifying which layer broke.
Why does this happen?
Because the cause can be found only by separating which layer the problem arose in when an error occurs: the model itself, the runtime, the prompt, or the retrieved documents.
When is it a problem?
If you only record that “the AI is acting strange,” you may misdiagnose a wrong chat template or an outdated retrieved document as a model performance problem and end up buying more expensive hardware.
Common beginner misconceptions
Downloading a model file does not install an entire AI or train it on your data. It only prepares already trained numbers to run on your hardware.
How to verify it yourself
For the app you use, write down the model name, runtime version, context setting, system prompt, and whether retrieval is used. Anything you cannot fill in is a system layer that is currently invisible to you.
Conceptual explanation 02
A sentence is not generated all at once
To a human reader, a paragraph of answer appears quickly, but inside the model small generation steps repeat continuously. First, the model reads the entire input and computes logits, the scores for the many token candidates that could come next. These scores are converted into a probability distribution, and one candidate is selected according to the configured selection rule. Appending the selected token to the existing text makes the input one piece longer, and the model computes the next candidates again with the extended context. The same computation continues until an end token is selected or the maximum output length is reached.
After 'It rained on my way home', plausible continuations might mention an umbrella, a taxi or wet clothes. The model does not look up a question's meaning in a dictionary and copy a finished answer; it estimates the next piece's probability from learned language patterns and current context. Lower temperature favors high-scoring candidates more consistently, while higher temperature increases the chance of lower-ranked candidates. This generation process naturally produces different wording for the same question.
You may wonder, “If it predicts the next token, how is it different from simple autocomplete?” The difference lies in the scale of training and the depth of internal representations. To predict the next token across vast amounts of text, code, tables, and explanations, the model must compress not only grammar but also relationships between entities, the purpose of the writing, facts that frequently appear together, and reasoning patterns into numerical relationships. As multiple Transformer layers combine these relationships, complex capabilities that look like translation, summarization, and question answering emerge. A simple training objective does not mean the model's internal computation or its results are simple.
Why does this happen?
Understanding token-by-token iteration lets you measure response speed in tokens per second and explain why longer outputs require more waiting.
When is it a problem?
If you mistakenly believe entire answers are stored, you cannot understand why temperature, context, and retrieved evidence change the results, and you become careless about fact-checking.
Common beginner misconceptions
Always choosing the most probable token does not make the whole sentence the most factual. Picking a natural candidate at each position is different from verifying external facts.
How to verify it yourself
In the course's token generation lab, change the selection rule while keeping the same sentence. You can see whether changing one earlier token changes the candidate distributions that follow in a chain.
Conceptual explanation 03
Understand training, inference and retrieval separately
Training calculates the difference between model predictions and training-data targets, then repeatedly adjusts weights to reduce that error. Large-scale pretraining requires many GPUs and substantial time, alongside data cleaning, distributed computation, checkpointing, and evaluation. Individual LoRA (Low-Rank Adaptation, fine-tuning a small set of additional weights) has a narrower scope but still requires data preparation, training, and evaluation procedures. Pasting a document into a chat window or downloading a model file does not change weights.
Inference is the process of loading already trained weights into memory and computing the answer to a new input. Running a model in Ollama to chat, or opening a GGUF file with llama.cpp, is inference. When a chat app saves earlier messages and prepends them to the next question, the model may seem to remember the past, but the conversation history has not become the model's permanent knowledge. If the history is not sent in a new conversation, that information is gone, and the model file remains unchanged.
RAG is useful for frequently changing facts such as current regulations or personal documents. Retrieve relevant document passages first, then send their source text with the question so the model answers within the evidence. Fine-tuning is more suitable for consistent response formats, tone, classification, and task procedures. A monthly price list may be managed with RAG, while consistently classifying customer inquiries into one of five company categories may be a fine-tuning candidate. Before choosing, ask whether the need concerns new facts, behavior, or temporary conversation memory.
Why does this happen?
Distinguishing the three functions lets you design the data update cycle, GPU requirements, personal data exposure points, and failure causes precisely.
When is it a problem?
Teaching current facts through fine-tuning requires retraining whenever information changes; trying to change tone through RAG can require repeating long instructions on every request.
Common beginner misconceptions
When people say they “trained AI on their data,” they have often just added a file search feature. Even if the results are useful, the two are not technically the same thing.
How to verify it yourself
Compare the model file's modification time and hash before and after a conversation, then ask about previous information in a new conversation. Without a separate training process, weights remain unchanged and information outside the supplied history does not persist.
Conceptual explanation 04
Why fluent language can still be wrong
Because the model is trained to predict the next token well, it is good at producing explanations that sound natural in context. But naturalness is no guarantee of factual accuracy. When asked about events after its training cutoff, exact version numbers, rare specialist knowledge, or papers and sources that may not exist, a model can fill the gaps with plausible patterns. It may accept a false premise in the question as given or mix up the specifications of similar products. This is not a matter of tone; it is a structural limitation that stems from the generation objective and the evidence available.
For example, if you ask about the name of a hypothetical, unreleased GPU as if it were a real product, the model may infer patterns from the name and invent a memory capacity and release date. In programming, it may confidently present a function name that does not exist, and in legal questions it may mix past and current provisions. The fact that such an answer is grammatically smooth and even includes a table is not evidence of accuracy. The greater risk is automation bias, where people feel reassured by polished wording and skip verification.
Design where failures are caught instead of merely asking the model never to be wrong. Ground current facts in source retrieval and citations, recalculate numbers, validate structured outputs with JSON schemas and test code. Require human approval for hard-to-reverse actions such as deletion, payments and external sending. RAG can retrieve wrong documents too, so separately evaluate source dates, versions, permissions and whether answers faithfully follow evidence.
Why does this happen?
Treating a model as a probabilistic generator rather than a fact database lets you plan verification costs that match the risk.
When is it a problem?
If you rely only on the prompt “If you are unsure, say you don't know,” you will miss boundary cases in production where the model is confidently wrong.
Common beginner misconceptions
Adding RAG does not eliminate hallucinations. Retrieval can miss or the model can ignore the evidence, so check the retrieval and generation stages separately.
How to verify it yourself
Mark dates, numbers, proper nouns and citations in the answer, then compare each against the source. If no source is provided for checking, classify the sentence as a claim awaiting verification, not a fact.
Conceptual explanation 05
What “local” does and does not guarantee
A local LLM (local large language model) is a setup in which model computation runs on equipment the user controls, such as a personal PC, workstation, or company server. It works without an internet connection, makes it easier to avoid sending sensitive source text to external model APIs, and keeps the cost of repeated calls predictable within the equipment cost. Pinning model and runtime versions also makes it easy to reproduce the same environment. However, apps can still communicate through update checks, telemetry, external search, or extensions, so you can say "nothing is sent externally" only after checking the actual network traffic.
Operational responsibilities that the cloud provider handled return to the user. You must manage the provenance of models and executables, licenses, malicious-file checks, GPU driver and runtime compatibility, accounts and access control, personal data in chat logs, backups, and failure recovery. A setup used by one family member on their own PC and a setup that multiple employees access through an API are not the same local service. The latter needs Transport Layer Security (TLS, encrypted communication), authentication, request limits, audit records, and resource isolation.
For example, running hospital document summaries on an in-house GPU does not protect privacy if every employee can view the source documents and prompt logs. Conversely, an individual polishing a public blog draft may face low data risk even when using an external API. Rather than treating local or cloud as inherently good or bad, compare data sensitivity, required quality, response speed, expected request volume, hardware and power costs, operating staff, and tolerable downtime in the same table.
Why does this happen?
Consider computation location and security controls separately so you do not overlook the actual data paths and responsible owners.
When is it a problem?
If authentication and logging policies are skipped just because a system is local, other users on the same network can access sensitive conversations or the model API.
Common beginner misconceptions
Open-weight does not mean free, unrestricted or safe. Check licenses, usage restrictions and deployment-file provenance separately.
How to verify it yourself
While the model runs, check the operating system's connection list and firewall logs, and document in a data-flow diagram where inputs, outputs, retrieved documents, and error logs are stored and for how long.
Conceptual explanation 06
Choose narrow, well-defined tasks that small models handle well
Small models are useful for clearly defined inputs and outputs: document classification, summary drafts, standardized writing, simple code explanations and unit-test drafts, subtitle cleanup and narration scripts. Classifying customer inquiries as payment, shipping, exchange, account or other lets people quickly review results and correct misclassifications. Extracting candidate dates and owners from meeting minutes with source links is also relatively easy to verify. Define success using measurable accuracy, omission rates and review-time savings rather than whether the model looks intelligent.
When creating narration for Text-to-Speech (TTS), an LLM may refine the script rather than act as the speech model that generates pronunciation. Calling Speech-to-Text (STT), LLM summarization, and TTS a single AI makes it difficult to locate errors. Incorrect transcription of meeting audio and factual omissions by the summarizer require different fixes. Dividing the workflow into stages makes it easier to combine small models with conventional programs appropriately and recover from failures.
But it's not the first project to ask for the latest expertise without a foundation, to put in very long documents at once, to come up with multiple systems, and to fully automate complex decisions. The bigger the loss or the harder it is to figure out the correct answer when the model is wrong, the bigger the model, the RAG, the dedicated search and settlement tools, and the approval process. If the small model is enough within the scope of the task, it's faster, cheaper, and easier to operate than choosing the larger model.
Why does this happen?
Narrowing the task scope lets you concretely define the required model size, data, evaluation items, and failure handling.
When is it a problem?
If you start by targeting an assistant that handles all company work, you cannot define correct-answer criteria or measure which model has improved.
Common beginner misconceptions
It is wrong to conclude that small models are useless, and equally wrong to conclude that every simple task can safely be delegated to them. The task and whether its output can be verified determine success or failure.
How to verify it yourself
Have people first process 20 candidate task cases and record correct answers and time spent. Compare model accuracy, omissions and review time under the same criteria.
Conceptual explanation 07
Check the total memory budget before model size
An 8B in a model name means roughly 8 billion parameters (numbers adjusted during training). Stored at 16 bits per weight, the simple theoretical size is 8 billion × 16 bits ÷ 8, about 16GB. Applying 4-bit quantization reduces this to about 4GB, but actual files also contain quantization scales, metadata, and some values at other precisions, so they can be larger than the theoretical value. This calculation is only a starting point and does not lead directly to the conclusion that “a 4GB file runs on a 4GB GPU.”
During generation, the model keeps a Key-Value cache (KV cache, the space that stores computations for earlier context) so it does not recompute intermediate attention results for previous tokens. The longer the context and the more concurrent users, the larger the cache. Memory must also be left for the runtime's compute buffers, graphs, the driver, and Video Random Access Memory (VRAM, GPU-dedicated memory) used for display output. So rather than loading a model that uses 11.5GB on a 12GB GPU, it is safer to start around 8–9GB and measure with the actual longest inputs and concurrent requests.
Out of Memory (OOM) is an execution stop caused by total demand exceeding available memory. Instead of blindly restarting, reduce context, maximum output length, and concurrent requests to establish a baseline, then adjust model size or quantization. Changing multiple values at once hides which item was the cause. A setting that fills memory to its limit is not stable: small updates or input-length changes can stop execution again, so determine headroom through repeated measurements.
Why does this happen?
Understanding memory beyond the weights explains why a model loads but stops only during long conversations.
When is it a problem?
Buying hardware based only on model file size may handle short questions, but OOM errors can occur with long documents or once a second user arrives.
Common beginner misconceptions
A 4bit model does not mean that every calculation is performed in 4 bits. Storage precision, compute precision, and KV cache precision can be considered separately.
How to verify it yourself
Record memory and speed immediately after runtime startup, with a short prompt, at the target maximum context, and with 2 concurrent requests, in that order. The increase at each stage reveals actual safety headroom.
Conceptual explanation 08
Start the first project with a questionnaire and a verification checklist
First ask who will produce which results from which inputs, rather than which model is best. Record whether inputs contain personal data or company secrets, whether outputs are drafts or automatically executed commands, the loss caused by one error, and who can verify correctness against which original sources. Then define daily request volume, concurrent users, acceptable response times and budget. This information supports a reasoned choice of local execution, model size, context, runtime and GPU.
For example, a personal task of turning family photo filenames into descriptions is a good fit for testing a small vision-language model locally, because the owner does not want the data sent externally and can check the results at a glance. By contrast, automatically judging the legal risk of company contracts and sending the results should not begin without evidence, authorization, and expert approval. Even the same summarization task carries different data risks and access controls for public news drafts than for patient records. A single model performance table cannot make this decision.
Start by collecting 20 to 50 representative cases, having people produce the expected results, and then measuring a baseline with the smallest candidate model. Include not only normal cases but also failure cases such as empty documents, ambiguous questions, outdated regulations, and prohibited requests. Record not just accuracy and speed but also human correction time, missing evidence, and whether requests that should be refused are handled. Increase data and user counts only when the pass criteria are met. Validating at small scale before expanding reduces hardware and operating costs and limits the scope of incidents.
Why does this happen?
Tying model selection to task requirements avoids decisions driven by trendy model names or top benchmark scores.
When is it a problem?
Watching demos without success criteria leads people to mistake a few impressive answers for overall quality and to discover omissions and costs only after going live.
Common beginner misconceptions
Installing a large model first and then finding a use for it may be fun for learning, but it is not the design sequence for an operational project.
How to verify it yourself
Fill in a table with input examples, expected output, acceptable errors, prohibited behavior, verifier, processing time, and data storage location. Blank cells are requirements to resolve before installing a model.
CONCRETE CASES
Check concepts in different situations
Before memorizing definitions, compare how these concepts appear on a personal PC and in real work.
Case 1 · An LLM is a next-token predictor
Compute the probabilities of several candidates following “Tonight’s dinner is” and choose one.
Key points to check here: Natural sentence generation and fact-checking are different skills.
Case 2 · Distinguish training from inference
Running a model with Ollama is inference; creating an adapter with LoRA is additional training.
Key points to check here: Downloading a model is not training.
Case 3 · A first look at Transformers and attention
In “Cheolsu held an umbrella. He…,” it draws on the relationship between “He” and Cheolsu.
Key points to check here: Contextual representations are updated as they pass through the layers.
Case 4 · Hallucination and verification
Present the document name and paragraph with the answer so a person can check the original source.
Key points to check here: Check original sources for important numerical, legal and medical information.
Case 5 · Advantages and disadvantages of local LLMs
Internal document classification can run locally, while difficult reasoning goes to an approved external model.
Key points to check here: Small models are useful for summaries, classification, and narration drafts.
CHAPTER 1 / 5
An LLM is a next-token predictor
When first encountering an LLM, it is easy to assume it contains a huge database of questions and answers. In fact, it works from a much simpler rule. It converts the text a user writes into small pieces called tokens and, based on all the tokens so far, calculates the probability of each token that could come next. It picks one, appends it, and then uses the longer text as input again to predict the following token. The sentence on the screen is the result of repeating this short calculation dozens of times, or thousands for a long answer, until the response ends.
After the input “Tonight’s dinner is,” many candidates are possible, such as “kimchi stew,” “at home,” “rain,” or “something simple.” The model assigns each candidate a score called a logit and converts the scores into a probability distribution. A lower temperature tends to favor the highest-scoring candidate more consistently; a higher temperature increases the chance of selecting lower-ranked candidates. This is why answers to the same question can vary, and it is important evidence that the model is not simply retrieving a stored answer from a database.
Training on vast amounts of text to predict the next token compresses grammar, recurring facts, writing styles, logical patterns, and code structures into weights. This makes a simple predictor appear to translate, summarize, explain code, and answer questions. A simple “predict the next piece” training objective does not imply simple capabilities. Combining many patterns across layers produces much more complex behavior.
Selecting a natural next sentence is different from verifying facts. A model can invent contextually plausible numbers or sources and does not automatically check the internet or original documents during generation. Treat an LLM answer as a probabilistically generated draft rather than established fact. Supply evidence through search or RAG when current facts matter, and verify important decisions against original sources through a separate process.
How to read the figure An LLM does not produce a sentence all at once; it repeats a computation that appends one token. Each pass makes the input 1 token longer, and it stops when an end token is drawn or the maximum token count is reached.
To recap the key points
Natural sentence generation and fact-checking are different skills.
It is not a database that retrieves a complete sentence all at once.
How this connects in practice
Compute the probabilities of several candidates following “Tonight’s dinner is” and choose one.
CHAPTER 2 / 5
Distinguish training from inference
Training and inference are the two terms most often confused when using LLMs. Training feeds in many examples, computes prediction errors, and gradually adjusts billions of weights in the direction that reduces those errors. It requires very large amounts of computation and memory, plus management of checkpoints, optimizer state, learning rates, and data quality. A finished model file is the set of weights produced by this long process.
Inference loads previously trained weights into memory and computes the next token for a user input. Pulling a model and chatting in Ollama, running a compatible model with MLX LM, running a GGUF file with llama.cpp, or sending a question to a vLLM API are all inference. Having many conversations does not automatically modify the weights in the model file. An app saving chat history and attaching it to the next request is different from model training.
Between these lies fine-tuning such as LoRA and QLoRA. Instead of retraining the entire original model, it adds small adapter weights to adjust response format, tone, or how specific tasks are performed. By contrast, if you want to provide current facts such as internal policies or product prices that change weekly, RAG is easier to manage than fine-tuning, because RAG leaves the original weights unchanged and retrieves documents relevant to the question into the prompt.
So when you hear a request like “I want to put my data into the model,” first identify the purpose. Depending on whether the goal is to retrieve the data and answer based on it, to learn a consistent output format and behavior, or to remember conversation history temporarily, you choose among different solutions: RAG, fine-tuning, or context management.
To recap the key points
Downloading a model is not training.
Conversation content does not immediately become the model's permanent knowledge.
How this connects in practice
Running a model with Ollama is inference; creating an adapter with LoRA is additional training.
CHAPTER 3 / 5
A first look at Transformers and attention
The Transformer is a common neural-network architecture for LLMs. Input tokens become numerical vectors called embeddings, then pass through successive Transformer layers. Each layer generally contains attention and a feed-forward network, with residual connections and normalization helping computations proceed stably. The model’s knowledge is distributed across these many matrix computations rather than stored in a single organized table.
Attention calculates which context positions to attend to and by how much when processing a token. In “Cheolsu held an umbrella. He avoided the rain,” the preceding “Cheolsu” matters for interpreting “He.” The model creates query, key, and value vectors for each token, calculates query–key relevance, and mixes values. Multiple heads can capture different patterns such as grammar, position, and entities.
This computation covers more positions as the prompt grows longer. During generation, the keys and values of previous tokens are stored in the KV cache so they do not have to be recomputed each time. As a result, longer contexts and more concurrent users significantly increase memory beyond the model weights. This is why feasibility cannot be judged simply by whether the model file fits in VRAM.
Do not assume one attention map reveals all of a model’s thinking. Outputs result from repeated computations across multiple heads, layers, and feed-forward networks, and individual neurons or attention values cannot easily explain all causes. At an introductory level, understanding attention as dynamically mixing contextual relationships and then connecting it to parameter and KV-cache calculations is sufficient.
To recap the key points
Contextual representations are updated as they pass through the layers.
Attention alone cannot explain all internal behavior.
How this connects in practice
In “Cheolsu held an umbrella. He…,” it draws on the relationship between “He” and Cheolsu.
CHAPTER 4 / 5
Hallucination and verification
Hallucination is fluent generation of unsupported or incorrect content. A model’s basic objective is context-appropriate next-token prediction rather than deciding truth, making it particularly vulnerable on rarely seen content, recent information, exact numbers and sources. Even models tuned to say “I don’t know” can answer confidently depending on question phrasing and context.
Verification is not solved by adding “answer accurately” to a prompt. When current information is needed, retrieve reliable source material and require citations identifying the document sections supporting the answer. Repeat calculations with code or a calculator, validate API schemas and formats programmatically, and leave final decisions in high-risk fields such as law, medicine, and finance to qualified people.
RAG is not universal. If retrieval returns irrelevant documents, mixes old and current versions, or exposes unauthorized documents, generation follows the wrong evidence. Evaluate retrieval hit rate and answer faithfulness separately, and preserve document date·version·permission metadata.
In practice, design where incorrect answers are caught rather than simply deciding whether to trust them. Have people review low-risk drafts, use confidence and exception queues for automated classification, and require human approval immediately before external sending, deletion or payments. A good LLM system is safe because failures are controlled, not because the model is perfect.
To recap the key points
Check original sources for important numerical, legal and medical information.
RAG can also be wrong when retrieval is wrong.
How this connects in practice
Present the document name and paragraph with the answer so a person can check the original source.
CHAPTER 5 / 5
Advantages and disadvantages of local LLMs
A local LLM runs directly on your PC, workstation, or internal server. It makes it easier to keep inputs from leaving through an external API, works offline, and, when requests are frequent, lets you experiment freely within the cost of your hardware. Pinning model and runtime versions also reduces the impact of service changes.
You take responsibility for work previously handled by the cloud provider. You must manage model provenance and licenses, GPU drivers and runtime compatibility, memory shortages, speed, access control, personal data in logs, updates and failure recovery. There is a large gap between downloading a free model and operating a safe, reliable service.
Small models are useful when their scope is well defined. Good starting points are tasks whose results people can easily check, such as summarizing specified documents, drafting, explaining simple code and drafting tests, classification, narration scripts, and preprocessing for voice pipelines. Conversely, complex multi-step reasoning, up-to-date specialist knowledge, and analysis of entire very long documents may require a larger model, RAG, or separate tools.
A practical design does not use one model for everything. Initial classification and drafts containing personal data can be handled locally, with only anonymized difficult questions sent to an approved external model or handed to a person. Start local AI design by defining available VRAM, required context, target response speed and quality, then choose a model within those bounds.
To recap the key points
Small models are useful for summaries, classification, and narration drafts.
Do not expect the same capabilities as large cloud models.
How this connects in practice
Internal document classification can run locally, while difficult reasoning goes to an approved external model.
INTERACTIVE LAB 1 / 2
Lab 1 · Sentence observation lab
Enter values in the browser and check the execution results and the failure and recovery paths. No commands are ever sent to real equipment or the NAS.
Lab observing the difference between character count and token count
Type a sentence, predict the result, then run the analysis. The ranges in this lab are not actual tokenizer results for a specific model but conservative estimates that prepare the next check.
Situation
You want to set the context limit by measuring document length in characters only.
Goal
Use the results to explain that characters, whitespace-separated words, UTF-8 bytes, and estimated tokens are different units.
Prerequisites
Prepare a Korean or English sentence without sensitive information and an expected token count.
Success criteria
Compare the four values in the analysis result and conclude that they must be remeasured with the model's tokenizer before actual deployment.
Enter a sentence to compare.
Before you see the results, write down the expected number of tokens.
Run sentence analysis, then compare your estimate with the range.
Failure and recovery: Empty input is not analyzed. If the result differs from your prediction or range, do not rewrite the sentence to match; record why it differs and compare it with actual tokenizer results. Some models may fall outside this estimated range.
INTERACTIVE LAB 2 / 2
Lab 2 · LLM system incident isolation lab
Enter values in the browser and check the execution results and the failure and recovery paths. No commands are ever sent to real equipment or the NAS.
Find the system layer and first evidence from a symptom
This is a fault-isolation exercise: instead of swapping models blindly, find the conditions that changed along with the symptom and run the cheapest checks first.
Situation
One of four incidents with different causes has occurred in a production LLM app.
Goal
Separate model, input-format, retrieval, memory and access-control issues, and choose the first evidence to inspect.
Prerequisites
First read the LLM system-architecture diagram above and the distinctions between training, inference and retrieval.
Success criteria
Select the system layer matching the symptom along with the first check, and explain the order of safe recovery and revalidation under identical conditions.
Select one incident scenario and read its actual symptoms.
First, choose the system layer to suspect and the evidence to collect.
Run diagnosis Then, if it fails, use the hint to change your selection and run it again.
Observed symptomsShort questions work, but entering a long document or a request from a second user stops it with Out of Memory (OOM).
Safety conditions: This lab changes only the browser state. It does not read or change the actual model server, NAS, document index, accounts, or logs.
KEY TERMS
Key terms in this unit
Token
Text pieces the model reads and writes
Inference
Execution that generates answers using a trained model
Hallucination
The phenomenon of generating plausible content that has no factual basis
UNIT WORKBOOK
Exercises and worksheets for applying concepts to new situations
Start by checking basic principles, then expand to practical workplace decisions. After submitting an answer, you can see why every option is correct or incorrect, not just the correct answer.
Basic Question 1
Which statement most accurately describes how an LLM produces an answer sentence?
Basic Question 2
What is the task of downloading an existing model with Ollama and asking it questions called?
Apply Question 3
You want answers about the company's monthly-changing travel expense policy to come with evidence. What is the most appropriate first choice?
The original policies are in the document-management system, and employees must be able to verify the document version and paragraph used for each answer.
Apply Question 4
An 8GB model file runs on a GPU with 8GB of VRAM, but Out of Memory(OOM) errors occur only when a long document is entered. What is the most plausible explanation and the first action to take?
Capstone Question 5
Which of the following plans starts a first local LLM task most safely?
The goal is to classify customer inquiries into five categories and reduce the time support staff spend organizing them.
PERSONAL WORKSHEET
A learning worksheet you adapt to your own environment
Your input remains only on the current browser screen and is not stored or transmitted externally. Use categories and pseudonyms instead of actual sensitive information.
OFFICIAL SOURCES
Verify against official sources
Technical, compatibility, and model information reviewed: August 2026
Understand why token counts vary by language and tokenizer.
Difficulty
Beginner
Structure
Lessons 5 · Labs 2 · Assessment
Diagrams and tables: composed by the author using each lesson's official primary sources. Find the originals and review dates at the end of that lesson.
NEW HIRE ONBOARDING
Start in the order you would receive your first assignment
So that even a new hire with no prior IT background can follow along, we start with the situation, the task, the evidence, and when to report, before difficult definitions.
01
Read the situation in one sentence
A Korean greeting that is five characters on screen may be a single piece in one tokenizer and several pieces in another.
02
Today's assignment
Understand why token counts vary by language and tokenizer.
03
Evidence that shows the work is complete
Record the tokenizer with its revision pinned.
04
When to stop and ask a senior colleague
The same sentence produces different results on different models.
Unpack unfamiliar terms first
Tokenizer
Component that converts between text and token IDs
Vocabulary
A list of token pieces known to the tokenizer
Chat template
A format that turns conversation roles into model input
PREREQUISITE CHECK
Three things to check before reading
This is not a test of memorized answers. Think about each question first, then open the explanation to review the foundational concepts used in this course.
1Is one character on screen the same unit as one byte stored in a file?
They are not the same. Characters are represented as Unicode code points, and after an encoding such as UTF-8, one character can become several bytes. Tokens are a separate unit produced when the tokenizer splits that string again.
2Does the model's input include only what the user types in the input box?
No. System instructions, role control tokens, previous conversation, retrieved documents, and tool schemas and results can all be included. Measure the completed prompt just before actual transmission.
3Are maximum input and maximum output separate, independent spaces?
In typical generation, output tokens follow the input and share the context budget. Check each runtime's limit definitions and reserve output space first.
TEXTBOOK GUIDE
Main text that covers each concept from its background to the criteria for judging it
We explain the material section by section so readers new to IT can connect causes and effects without memorizing terms.
CONCEPT FLOW
How the chapters connect
The chapters are not isolated short answers to memorize. Follow them from left to right to see how each chapter's concepts support the next decision.
1.Characters, words, and tokens differ→
2.The difference between English and Korean→
3.Special tokens and chat template→
4.Setting a context budget→
5.Inspect the tokenizer directly
Korean, English and tokens: the overall map. If you lose track while reading the detailed explanations and chapters below, return to this sequence.
CONTROLLED EXPLANATION
Explore the order in which concepts build on each other
It does not start automatically. Play, or select the previous or next step, to see how the current concept connects to the next decision, step by step.
Current explanation · 1/5
Characters, words, and tokens differ
The tokenizer normalizes the original text, splits it into learned string pieces, and converts them into integer vocabulary IDs.
Whitespace-delimited words and token boundaries are different.
Up next: The difference between English and Korean, where this standard continues to apply.
See the full step description
1. Characters, words, and tokens differ
The tokenizer normalizes the original text, splits it into learned string pieces, and converts them into integer vocabulary IDs. Whitespace-delimited words and token boundaries are different.
2. The difference between English and Korean
Per-language token efficiency does not reflect the superiority of any writing system; it depends on the data and vocabulary the tokenizer was trained on. Per-language efficiency depends on vocabulary and training data.
3. Special tokens and chat template
A chat model does not read roles and content as-is; it reads a sequence, including control tokens, produced by the model-specific chat template. Use the chat template the model requires.
4. Setting a context budget
Fit the sum of input, retrieved documents, conversation history, and output reservation within the context limit, and leave a safety margin for small changes. Reserve tokens for output in advance.
5. Inspect the tokenizer directly
Make the final decision after pinning the model, tokenizer, and template revisions and actually measuring the tokens, ids, and offsets of representative inputs. Record the tokenizer with its revision pinned.
The text description below shows the same content without the animation. Your operating system's reduced-motion setting is also respected.Conceptual explanation 01
First separate on-screen characters from the model’s input units
In a document editor, the Hangul syllable “ga” appears as one character. A computer, however, first represents characters as Unicode code points (international numbers assigned to characters), and files and networks convert them with an encoding such as UTF-8 (a rule for storing those numbers as bytes). One Hangul syllable may take one position on screen but several bytes in UTF-8. The tokenizer (the component that turns text into pieces and numbers the model can process) then performs its own separate segmentation. “One character,” “one byte,” and “one token” are therefore not three names for the same amount but distinct units at different processing stages.
Visually identical strings can have different internal representations. A Korean syllable may be stored as a precomposed syllable code point or as a sequence of jamo code points for initial consonant, vowel, and final consonant. Unicode Normalization Forms standardize equivalent character sequences. Segmentation can vary with tokenizer normalization, so identical appearance of copied sentences does not establish identical token IDs.
This distinction is not merely a matter of terminology. File upload limits are set in bytes, editors display length in characters or words, and LLM context limits and usage are counted in tokens. If a customer asks, "The document is only 2MB, so why can't I add it?", explain that the size of a file containing images and formatting is not directly proportional to the token count of the extracted text. Conversely, even a small text file can use more tokens than expected when repeated code, long digit strings, or garbled OCR characters are split into small pieces.
Why does this happen?
Each stage uses different units, so to solve the problem, identify whether the size grew in the file, the character representation, or the token split.
When is it a problem?
Treating character count as token count can lead to discovering context overflows, cost miscalculations, and insufficient output space only after deployment.
Common beginner misconceptions
It is incorrect to assume that more UTF-8 bytes always mean proportionally more tokens. The tokenizer’s vocabulary and segmentation algorithm regroup and split the input.
How to verify it yourself
First record the character count and UTF-8 byte count of the same sentence, then print the token strings and IDs produced by the actual model tokenizer side by side, and compare the three columns.
Conceptual explanation 02
A tokenizer converts strings into numbers in four steps
The first stage, normalization, adapts source text to the representation expected by the tokenizer. Tokenizers differ in whether they apply Unicode normalization such as NFC or NFD, case conversion, whitespace handling or accent removal. Normalization helps handle equivalent expressions consistently in retrieval and training, but can change information. If product-code case matters or original spelling must be preserved, store normalized model input separately from the original text shown to users.
The second stage, pre-tokenization, first splits candidate boundaries such as spaces, punctuation, and numbers. The third stage, the tokenizer model, further divides these pieces into subwords in a vocabulary (a list of token strings and IDs) and maps each to an integer ID. Byte-Pair Encoding (BPE), which repeatedly merges frequent pairs, WordPiece, which selects useful subwords according to a training criterion, and Unigram, which chooses probable combinations among possible segmentations, are different algorithms for this stage. Their shared goal is to represent frequent expressions in larger pieces and rare expressions in smaller pieces using a limited vocabulary.
Final post-processing may add special tokens the model requires, such as sentence starts and ends or boundaries between sentence pairs. After generation, the decoder (the component that turns token IDs back into human-readable text) combines subword markers and spacing rules to restore the sentence. A greeting that looks natural on screen was not necessarily one piece internally. For accurate diagnosis, inspect the normalized text, pre-tokens, token strings, token IDs, and special-token inclusion at each stage, not just the final string.
How to read the figure When the token count is not what you expected, the cause lies in the per-stage intermediate results, not in the final string. Print tokens, ids, offsets, and the special token mask together to find the stage where it changed.
Why does this happen?
Splitting the pipeline into stages shows whether a change in the same sentence comes from Unicode normalization, boundary rules, vocabulary, or special tokens.
When is it a problem?
Replacing only some tokenizer files can misalign ID meanings even when the model weights are the same, sharply degrading answer quality or breaking sentences.
Common beginner misconceptions
A tokenizer does more than split sentences at spaces. It includes learned subword rules and post-processing to handle languages without spaces and rare strings.
How to verify it yourself
Print tokens, ids, offsets, and the special token mask from the tokenizer's encode output, and map line by line which range of the source text became which ID.
Conceptual explanation 03
Subwords balance vocabulary size between words and characters
Storing every word as a single token would make the vocabulary grow endlessly with each new word, while using single characters as tokens makes sentences far too long. Subword tokenization takes the middle path. It adds strings that frequently occur together in training data, such as “transform” and “ation”, and recurring Hangul fragments to the vocabulary, and it represents unseen words as combinations of known pieces. Common expressions are therefore processed in fewer tokens, while rare proper nouns, long URLs, and misspellings can split into more tokens.
BPE starts with small units and learns merge rules for frequent neighboring pairs in training data. WordPiece and Unigram train differently and may produce different boundaries for the same sentence. SentencePiece can train subword models on raw sentences without assuming pre-segmented words. The key conclusion is not that one algorithm is always superior, but that inference must use the exact vocabulary and rules of the tokenizer used to train the weights.
For example, if the internal product code "KDX-2026-α" rarely appeared in training data, its hyphens, digits, and Greek letter may be split into several tokens. If this code repeats hundreds of times per document, it consumes context quickly, and even small notation differences can change search embedding results. Yet simply adding the product code to the production tokenizer as a single token does not solve the problem. Unless the embedding for the new ID is trained or the model is adjusted, that ID has no prepared meaning, so first consider whether external handling such as normalization, alias dictionaries, or search metadata can solve it.
Why does this happen?
Subword tokenization is a tradeoff that represents new strings with a limited vocabulary while shortening sequences for common expressions.
When is it a problem?
Applying ordinary-prose character/token ratios to logs, code or OCR documents with repeated rare strings can badly misestimate input budgets.
Common beginner misconceptions
One meaning does not imply one token. Token boundaries depend on learned string frequencies and algorithms rather than a semantic dictionary.
How to verify it yourself
Pass ordinary words, internal proper nouns, typos, URLs and UUIDs through the same tokenizer, compare counts and boundaries, and calculate total usage across repetitions.
Conceptual explanation 04
Differences between Korean and English arise more from the learned vocabulary than from the characters themselves
Korean attaches particles and endings to stems to express grammatical roles, honorifics and tense. Forms meaning “find,” “found” and “did you find?” are related but have different surface strings. Some tokenizers store frequently seen spacing units as large tokens; others split stems and endings or smaller character fragments. English also splits words such as run, running and unpredictability differently, so one English word is not always one token. These differences reflect compression efficiency from training data and vocabulary design, not superiority of one writing system.
Tokenizers trained predominantly on English may store common English words as long tokens while equivalent Korean expressions split into several pieces. Tokenizers trained with sufficient multilingual or Korean material may use larger Korean units. A fixed claim such as 'Korean costs exactly twice as much as English' can become wrong when the model changes. Translation length, style and mixtures of numbers and English product names also matter; do not generalize one example to the whole task.
Compare representative sentence sets with equivalent meanings. Prepare short conversations, official documents, technical documents, table extracts and customer inquiries with inconsistent spacing in Korean and English, and measure token-count distributions for exact tokenizer revisions. Inspect the 95th percentile and largest increases as well as means to set safe context and quota limits. Translation to reduce tokens can lose source meaning and adds translation cost; remove unnecessary boilerplate, duplicate documents and old conversations first.
Why does this happen?
Because word forms and tokenizer training distributions differ by language, the number of long pieces the vocabulary can reuse differs even for the same character count.
When is it a problem?
Testing context budgets only with English examples can cause Korean customer inquiries or mixed technical documents to be truncated first in production.
Common beginner misconceptions
Neither one Korean syllable always equaling one token nor one English word always equaling one token is a model-independent rule.
How to verify it yourself
Measure 50 anonymized Korean, 50 English and 50 mixed-language task sentences with the actual tokenizer. Store mean, median, 95th percentile and maximum by revision.
Conceptual explanation 05
Spaces, numbers, emoji, and code create unexpected boundaries
A person may read “stock: 1000 items” and “stock: 1,000 items,” or “2026-08-26” and “August 26, 2026,” as the same information, but to a tokenizer they are different strings with different combinations of commas, hyphens, spaces, and digits. Strings that follow a pattern but rarely repeat, such as long serial numbers, hashes, Base64, and UUIDs, can be split far more finely than short natural-language text. This is why pasting just a few lines of logs into a prompt can use up a large part of the context. A better design passes only the important values in structured form and retrieves the full original when needed.
An emoji may look like a single image on screen, but it can combine several Unicode code points. When skin tone, gender, or family combinations, variation selectors, and zero-width joiners are involved, character-counting methods and token splits differ. Broken characters and control characters from OCR errors are even worse. Users see one odd symbol, but the tokenizer may process it as several byte-level pieces, and search may fail to find the same word. If characters removed during input cleaning are not recorded, it becomes hard to trace positions in the source text and answers later.
Whitespace and line breaks matter for code syntax or readability, so do not indiscriminately collapse them as natural language. Indentation, long identifiers, import paths and repeated generated code consume tokens, but arbitrary compression can change execution semantics. First select relevant functions and the area around errors, preserve line numbers and file boundaries, and exclude files unnecessary for the question, such as build outputs, lockfiles and minified code. Reducing scope while preserving source structure is more accurate than deleting characters merely to fit a token count.
Why does this happen?
A tokenizer processes actual strings and learned boundaries, not units of meaning that people recognize, so spelling differences directly produce different input arrays.
When is it a problem?
Inserting logs, OCR output, code, and identifiers without cleanup consumes context faster than natural-language documents and makes search results unstable.
Common beginner misconceptions
Assuming that whitespace and symbols carry no meaning and can all be deleted is dangerous. You can lose code syntax, table columns, document positions, and proper-noun boundaries.
How to verify it yourself
Write the same meaning as four strings that differ only in number·date·whitespace formatting, compare their token boundaries, and check that positions in the original can still be traced before and after cleanup.
Conceptual explanation 06
Include system, role, and tool tokens outside the chat screen in the budget
Even if the chat UI shows only the final one-line question, the application may assemble system instructions, safety rules, user and assistant roles, earlier conversation, retrieved documents, tool schemas and execution results into one request. A chat template converts roles and content into the control-token format seen during model training. Chat models derived from the same base can use different templates, so copying another model’s template can degrade role separation and stopping behavior. Counting only visible characters misses all these hidden inputs.
With tool calling, function names, descriptions, and parameter schemas can consume hundreds or thousands of tokens per request. RAG documents may be much longer than the question, and multi-turn agents reinsert observations and tool outputs at each step. A quota such as “500 characters per question” therefore cannot protect actual GPU memory and throughput. At the gateway or runtime, measure final prompt tokens, reserved output tokens, cached tokens, and actual generated tokens separately.
Check immediately before actual transmission, not at the UI input box. After assembling the messages array and tools, the application applies the same tokenizer and chat template to count tokens. If the input limit is exceeded, explain which elements are large before calling the model. Even when recovery automatically summarizes old conversations, adjusts retrieved-document count, or reduces the tool list, record source-information loss and permission changes. Simply cutting off the beginning may remove system rules or the question’s premises.
Why does this happen?
A chat model does not read the role dictionary directly; it reads the token sequence the template produces, so invisible control tokens and additional inputs also consume context.
When is it a problem?
Measuring only the user's question cannot explain why a short question still exceeds the context or leaves no room for output.
Common beginner misconceptions
When earlier conversation is collapsed on screen, it is easy to assume it has also disappeared from the model input, but if the app resends it, all of it is included in the current request.
How to verify it yourself
Record an anonymized list of messages, tools, and retrieved documents immediately before the API call. After apply_chat_template, output the length including special tokens and each component’s share.
Conceptual explanation 07
The context budget reserves output space first and allocates the rest to inputs
A Context window is the token range a model can handle in one request. Some runtimes limit input plus new output and may also impose separate max-input/max-output limits, so check official documentation and actual errors. An 8,192-token limit cannot fit 8,000 input tokens plus a requested 1,000-token answer. Unless the application specifies what is truncated or rejected, important content can disappear at different positions for different users.
When building a budget, first reserve the maximum output the task needs. Then measure current values in this order: fixed system prompt and template, current question, conversation history, and RAG documents. For example, reserving 1,200 tokens for output, 500 for system and template, and 300 for the question within an 8K limit leaves about 6,000 tokens for history and retrieved documents. Using all of it without a safety margin means even small changes in tokenizer revision, tool schemas, or document length can exceed the limit.
When the limit is exceeded, do not mechanically delete tokens from the beginning. First summarize older conversation into facts, decisions and unresolved items, reduce RAG chunks unrelated to the question, and remove duplicate system instructions and tool descriptions. If conditions and conclusions are far apart in a large document, preserve headings and sections and improve retrieval and reranking rather than indiscriminately shrinking chunks. After recovery, rerun the same longest questions to test answer omissions and citation accuracy.
Why does this happen?
The generated answer continues in the same sequence, so fitting only the input within the limit does not leave room for the complete request.
When is it a problem?
Without an output reservation, the answer can be cut off midway, leaving the JSON unclosed or dropping citations and conclusions.
Common beginner misconceptions
It is wrong to assume that raising the context limit always improves quality. Processing time and KV cache grow, and key evidence can be buried in long input.
How to verify it yourself
In the lab, add up the system, history, document, question, and output reservation budgets, bring an over-budget state under the limit by reducing only history and documents, and then run a regression test with the actual longest input.
Conceptual explanation 08
Use estimates only for planning, then remeasure with the deployment tokenizer
During planning, no model may be selected yet, so rough ranges can help. Character-type heuristics can estimate minimum and maximum ranges, but must not serve as purchase guarantees or operational limits. The same sentence might produce 30 tokens in model A and 46 in model B, with chat templates widening the difference. Estimation tools identify relatively risky sentences; they do not imitate the authoritative tokenizer.
In the deployment checklist, record the model ID and revision, the tokenizer file's commit or digest, chat template, special-token inclusion, truncation and padding settings, and measurement code. Include not only ordinary sentences but also empty inputs, very long Korean text, technical documents mixed with English abbreviations, digit strings, emoji, OCR errors, code, and tool schemas. Recording the mean token count, 95th percentile, maximum, and failing source types lets you set quotas and chunk sizes on evidence.
When updating a model or tokenizer, measure again with the same input set. Fewer tokens do not mean better quality, and existing prompts may be split at different boundaries, which can change answers. Compare not only whether context overflows decreased but also retrieval recall, format compliance, preservation of Korean proper nouns and numbers, first-token latency, and KV cache. If something goes wrong, you must be able to roll back the previous tokenizer, template, and model as one set to isolate the cause.
Why does this happen?
Rules of thumb do not know the actual vocabulary or template, so they can only give a range; operational decisions require reproducible, actual ID arrays.
When is it a problem?
If only the model weights are pinned and the tokenizer or template is left on a moving version, the token count and meaning of the same prompt can change without warning.
Common beginner misconceptions
A tokenizer that produces fewer tokens is not always better. Evaluate training compatibility, language quality, special-character handling, and model performance together.
How to verify it yourself
Keep fixed evaluation inputs in JSONL and automatically compare tokens, IDs, totals, and output quality before and after deployment. Put promotion on hold if differences exceed permitted limits.
Conceptual explanation 09
Manage tokenizer replacement as a compatibility change, like a model replacement
A tokenizer is the contract that maps displayed strings to model embedding row IDs. Attaching a tokenizer with a different vocabulary order to existing weights makes the same ID point to a different piece, which can cause meaningless repetition, exposed special tokens, and termination failures. Even when vocabulary sizes happen to match, ID mapping, normalization, and pre-tokenization rules can differ. Download the tokenizer files, config, and special tokens from the model repository at the exact revision and pin them in one manifest with the weights.
Chat templates are part of tokenizer migration. Changes in Beginning of Sequence (BOS), End of Sequence (EOS), role, and tool-control token IDs or insertion points affect both token count and conversation interpretation. Do not immediately label shorter responses after a template change an efficiency gain. Retest system compliance, multi-turn roles, tool schemas, termination, and output format on the same dialogue set.
Before replacement, prepare a fixed corpus covering Korean spacing, particles, proper names, English abbreviations, numbers, dates, emoji, OCR errors, code, and tool schemas. Compare normalized text, token strings and IDs, totals including special tokens, and upper percentiles between the previous and candidate tokenizers. Changed IDs may be normal, but explain whether associated weights match the candidate and whether context quotas, chunk boundaries, and costs remain within limits.
If context-limit errors or repeated outputs increase after promotion, roll back the model/tokenizer/template bundle to the previous revision rather than editing only the new tokenizer. Verify recovery of the same failing inputs, then change just normalization, template or quota and retest once the cause is isolated. Report averages plus maximum increases in Korean, numeric and code subsets, context-limit error counts and output quality so costs affecting only some users are visible. Preserve cases where customer names or numeric units split into many more pieces as regression inputs and remeasure them on new models. Retain tokenizer JSON, model, special-token settings and digests together in rollback artifacts to reproduce the same ID arrays.
Why does this happen?
Token IDs select embedding rows and control tokens mark conversation boundaries, so the tokenizer, model weights, and template must be compatible with one another.
When is it a problem?
If changing only the tokenizer causes repetition, termination failures, token-count surges, or changes to RAG chunks, inspect ID, normalization, and template differences.
Common beginner misconceptions
Matching vocabulary size or model family name does not mean any tokenizer can be attached and yield the same inputs and quality.
How to verify it yourself
Compare normalized text, tokens, IDs, and totals for a fixed multilingual corpus between previous and candidate versions. Retest failure recovery by rolling back the model and template bundle.
CONCRETE CASES
Check concepts in different situations
Before memorizing definitions, compare how these concepts appear on a personal PC and in real work.
Case 1 · Characters, words, and tokens differ
A Korean greeting that is five characters on screen may be a single piece in one tokenizer and several pieces in another.
Key points to check here: Whitespace-delimited words and token boundaries are different.
Case 2 · The difference between English and Korean
Prepare the same notice in Korean and English, and compare tokenizer results using sets of sentences that mix actual business writing style and proper nouns.
Key points to check here: Per-language efficiency depends on vocabulary and training data.
Case 3 · Special tokens and chat template
The system·user·assistant markers and end markers are included in the actual context even if they are not visible in the UI.
Key points to check here: Use the chat template the model requires.
Case 4 · Setting a context budget
Within the 8K limit, reserve 1,200 tokens for output first, then allocate the rest to the system·question·history·retrieved documents.
Key points to check here: Reserve tokens for output in advance.
Case 5 · Inspect the tokenizer directly
Reproduce the same input set before and after deployment using the Hugging Face tokenizer or the runtime's official tokenize function.
Key points to check here: Record the tokenizer with its revision pinned.
CHAPTER 1 / 5
Characters, words, and tokens differ
People read letters, words, and sentences on paper and screens. Computer files store characters as Unicode numbers and bytes, and an LLM receives an array of token IDs produced by a tokenizer. These three representations are connected, but their boundaries differ. A Hangul syllable that takes several bytes in UTF-8 is not necessarily several tokens, and an English word surrounded by spaces is not necessarily one token. To judge context, processing cost, and generation speed, use the final count of token IDs.
A tokenizer normalizes the original text, pre-splits it at locations such as spaces and punctuation, then uses a subword algorithm such as BPE, WordPiece, or Unigram to find vocabulary pieces. Common strings may become one long piece, while rare strings split into smaller pieces. Thus, sentences with equal character counts can have different token counts. Different models have different training data, vocabularies, and normalization rules, so even the same sentence produces different ID arrays.
Check Unicode representation too. Even visually identical Korean text may use different code-point arrays for precomposed syllables and decomposed jamo. Final token boundaries may match or differ depending on NFC or NFD normalization in the tokenizer. OCR, old-document conversion, and text copied across operating systems are likely sources of these differences. Preserve the original text seen by the user, normalization results, and token offsets together so you can locate errors again.
In practice, a question like "The document is 3,000 characters; how many tokens is that?" cannot be answered with an exact number without a model name. Ranges can be estimated during planning, but final limits must be measured with the actual deployment tokenizer and chat template. Recording character count, UTF-8 bytes, whitespace-separated words, and tokens in the same table reveals which unit was misused. The first lab in this course likewise aims not to imitate a correct token count but to observe that these four numbers differ.
To recap the key points
Whitespace-delimited words and token boundaries are different.
The same sentence produces different results on different models.
How this connects in practice
A Korean greeting that is five characters on screen may be a single piece in one tokenizer and several pieces in another.
CHAPTER 2 / 5
The difference between English and Korean
Korean combines stems with particles and endings to express roles, tense and honorifics, producing many surface forms. Forms meaning “check,” “checked” and “would you check?” are related but have different endings. Token counts depend on whether the tokenizer stores frequent spacing units whole, separates stems and endings, or splits further into syllables or bytes. English compounds, affixes and rare spellings also split, so one English word cannot be assumed to equal one token.
A vocabulary built from English-centric training data may store common English strings as long tokens and split Korean into relatively small pieces. Tokenizers with sufficient multilingual or Korean data may produce different results. Therefore, do not put a fixed ratio such as "Korean always costs twice as much as English" in cost tables. The ratio also shifts when the model generation changes or the style moves from official documents to chat. The length of the translated text itself and the mix of numbers and product names also affect the results.
One sentence with equivalent meaning is insufficient for a fair comparison. Collect anonymized short inquiries, long explanations, table-derived text, technical terms, and spacing errors from actual services for each language. For each tokenizer revision, calculate mean, median, 95th-percentile, and maximum token counts and inspect the least efficient originals. Averages alone can hide context overflows caused by rare URLs, product codes, and OCR errors.
Use caution when automatically translating Korean into English to reduce token counts. Translation may change proper names, honorifics, legal conditions, and table structures, while adding models, costs, and paths for personal information. Removing duplicate headers, old conversations, irrelevant retrieved documents, and repeated logs first is less likely to damage meaning. Choose language conversion only after verifying meaning preservation and total processing cost on the same evaluation set.
To recap the key points
Per-language efficiency depends on vocabulary and training data.
Do not infer API cost from character count.
How this connects in practice
Prepare the same notice in Korean and English, and compare tokenizer results using sets of sentences that mix actual business writing style and proper nouns.
CHAPTER 3 / 5
Special tokens and chat template
In a chat API, developers see an array of messages labeled system, user and assistant, but the causal language model ultimately processes a single token sequence. The chat template inserts control tokens around each message to mark roles, starts and ends, and indicates where the assistant response begins. These special tokens consume context even when hidden from the user interface. The same one-line question can therefore produce a much larger actual input when system instructions and conversation history are long.
Two chat models derived from the same base model may have learned different control tokens and orderings. If you copy another model's template, the model may fail to distinguish the user's words from the assistant's answer, end its answer immediately, or ignore the stop token and keep generating. This is not a simple display error but the result of a mismatch between the input format seen during training and the format used at inference. Do not pin only the model ID; bundle the tokenizer revision and chat template into the same deployment unit.
Tool calling and RAG increase hidden inputs. Function names, descriptions, JSON schemas, retrieved document titles and bodies, and prior tool results may all enter the template. To understand context overflow when the user entered only 50 characters, measure the complete prompt immediately before API transmission rather than the UI text. Record token counts per component to decide whether reducing tools, adjusting retrieved documents, or summarizing history will help.
During validation, record token lengths both excluding and including special tokens. Training-data preparation may require omitting a generation prompt, while inference may require an assistant-start marker, so options depend on purpose. Use official tokenizer paths such as apply_chat_template and avoid arbitrary string concatenation. After changing templates, test role separation, termination, tool calls, and Korean quality with the same regression questions.
To recap the key points
Use the chat template the model requires.
A wrong template degrades quality and termination behavior.
How this connects in practice
The system·user·assistant markers and end markers are included in the actual context even if they are not visible in the UI.
CHAPTER 4 / 5
Setting a context budget
A context window is the token budget for a single request. The system prompt, chat template, past turns, RAG chunks, the current question, and the generated answer all share this budget. If you fill an 8K model with 8K of input and request a long answer, there is no room left for output. Depending on the runtime, the request may be rejected, input may be cut from the front or back, or the answer may stop midway. Automatic truncation that hides what it cuts can remove critical safety rules or the point of the question.
Build the budget by reserving output first. Allocate the maximum answer length the task requires, the fixed system prompt and template, and the current question first, then divide the remaining space between history and retrieved documents. Include any tool schemas in the fixed cost. Do not treat 100% of the target limit as the normal operating value; leave headroom for changes in document length and templates. Also keep in mind that longer contexts increase KV cache size and prompt processing time.
When over budget, summarize old history into decisions, facts and unresolved items; remove irrelevant RAG chunks; and reduce duplicate instructions and unnecessary tools. Cutting the beginning of a string can remove system instructions; cutting the end can remove the current question. Excessively small document chunks can separate conditions from conclusions, producing retrievable but incorrect answers. Reduce content while preserving structure, and retrieve for each question.
The second lab's initial values intentionally exceed 8K. Rather than blindly reducing numbers, judge which components are stale or less relevant and reallocate the budget. After achieving a passing number, generate the actual longest prompt, remeasure it with the tokenizer, and verify that citations, deadlines, and JSON closure in the answer are preserved. An arithmetic pass is not a content-quality pass.
To recap the key points
Reserve tokens for output in advance.
Shorten and split long documents according to importance and structure.
How this connects in practice
Within the 8K limit, reserve 1,200 tokens for output first, then allocate the rest to the system·question·history·retrieved documents.
CHAPTER 5 / 5
Inspect the tokenizer directly
Recording only the model ID is not enough when you start measuring. Also record the tokenizer files and config, revision or commit, chat template, special-token options, truncation and padding settings, and library versions used. Using the moving main or latest revision on the Hub as is makes the same results hard to reproduce later. Keeping digests of downloaded files lets you confirm which artifact was tested even if the hosting location changes.
Representative inputs should include failure-prone formats as well as ordinary sentences: long Korean official documents, technical documents mixing English abbreviations and numbers, emoji, URLs, UUIDs, OCR errors, code blocks, empty inputs, multiline tables and tool schemas. Save source text, normalization results, token strings, IDs, offsets and total counts including special tokens. Remove personal data and secrets and use structurally equivalent pseudonyms instead of real values.
Do not compare two tokenizers by token count alone: fewer tokens do not always mean better language understanding. With the same model and prompt, check preservation of Korean proper nouns, numerical accuracy, format compliance and answer quality, and measure context, latency and KV cache under the same conditions. An incompatible tokenizer changes the meaning of token IDs, so arbitrary replacement is not performance optimization.
If differences exceed the acceptable range after an update, roll back to the previous model, tokenizer, and template bundle and compare which layer changed, one at a time. Add failing sentences to the regression set. In production, record the final input tokens, reserved output, actual output, and whether truncation occurred as per-request metrics, while minimizing source text and personal information. This procedure lets you explain why the same document started getting truncated this month with evidence rather than guesswork.
To recap the key points
Record the tokenizer with its revision pinned.
Also record normalization and whether special tokens are included.
How this connects in practice
Reproduce the same input set before and after deployment using the Hugging Face tokenizer or the runtime's official tokenize function.
INTERACTIVE LAB 1 / 2
Lab 1 · Sentence observation lab
Enter values in the browser and check the execution results and the failure and recovery paths. No commands are ever sent to real equipment or the NAS.
Lab observing the difference between character count and token count
Type a sentence, predict the result, then run the analysis. The ranges in this lab are not actual tokenizer results for a specific model but conservative estimates that prepare the next check.
Situation
You want to set the context limit by measuring document length in characters only.
Goal
Use the results to explain that characters, whitespace-separated words, UTF-8 bytes, and estimated tokens are different units.
Prerequisites
Prepare a Korean or English sentence without sensitive information and an expected token count.
Success criteria
Compare the four values in the analysis result and conclude that they must be remeasured with the model's tokenizer before actual deployment.
Enter a sentence to compare.
Before you see the results, write down the expected number of tokens.
Run sentence analysis, then compare your estimate with the range.
Failure and recovery: Empty input is not analyzed. If the result differs from your prediction or range, do not rewrite the sentence to match; record why it differs and compare it with actual tokenizer results. Some models may fall outside this estimated range.
INTERACTIVE LAB 2 / 2
Lab 2 · Context budgeting lab
Enter values in the browser and check the execution results and the failure and recovery paths. No commands are ever sent to real equipment or the NAS.
Budgeting a request, including off-screen tokens
Enter token counts assumed to have been measured with a particular model’s tokenizer, and calculate the total for system instructions, conversation history, retrieved documents, the question and reserved output.
Situation
After putting a long conversation and retrieved documents together into an 8K-context model, answers are cut off or requests are rejected.
Goal
Rather than only filling the input, reserve output space first, then set a cap for each input element.
Prerequisites
Use the token count measured by running the tokenizer on the final prompt the actual app produced. Do not enter sensitive source text on this screen.
Success criteria
Switch to a configuration whose total stays within the context limit and reserves at least 512 output tokens, then recalculate.
First, enter the model's context limit and output reservation.
Enter actual measurements for the system text, history, retrieved documents, and question.
Run budget calculation If over budget afterward, reduce old history and irrelevant documents first, then rerun.
Failure and recovery: Filling the input to the limit leaves no room for the answer. Repeat the same calculation using the final token count after the actual tokenizer and chat template, not UI character counts or document file sizes.
KEY TERMS
Key terms in this unit
Tokenizer
Component that converts between text and token IDs
Vocabulary
A list of token pieces known to the tokenizer
Chat template
A format that turns conversation roles into model input
UNIT WORKBOOK
Exercises and worksheets for applying concepts to new situations
Start by checking basic principles, then expand to practical workplace decisions. After submitting an answer, you can see why every option is correct or incorrect, not just the correct answer.
Basic Question 1
Which statement most accurately describes the relationship among character count, UTF-8 byte count, and token count?
Basic Question 2
Which order best describes a typical tokenization pipeline?
Apply Question 3
A user asked a question only 40 characters long, but the server returned a context-exceeded error. What evidence should be collected first?
The app automatically attaches long system rules, 20 turns of conversation history, 6 RAG documents, and 12 tool schemas.
Apply Question 4
Within an 8,192-token limit, you plan to use 500 tokens for the system, 2,400 for history, 4,000 for retrieved documents, 300 for the question, and reserve 1,500 for output. What is the most appropriate assessment?
Capstone Question 5
What is the most complete plan for safely deploying tokenizer updates?
The workload combines Korean support, English product codes, OCR documents, and tool calling, and context limits and quality criteria have already been measured on the existing version.
PERSONAL WORKSHEET
A learning worksheet you adapt to your own environment
Your input remains only on the current browser screen and is not stored or transmitted externally. Use categories and pseudonyms instead of actual sensitive information.
OFFICIAL SOURCES
Verify against official sources
Technical, compatibility, and model information reviewed: August 2026
Read size labels such as 3B·8B·70B and Transformer settings in terms of performance, memory, and failure symptoms.
Difficulty
Beginner
Structure
Lessons 5 · Labs 2 · Assessment
Diagrams and tables: composed by the author using each lesson's official primary sources. Find the originals and review dates at the end of that lesson.
NEW HIRE ONBOARDING
Start in the order you would receive your first assignment
So that even a new hire with no prior IT background can follow along, we start with the situation, the task, the evidence, and when to report, before difficult definitions.
01
Read the situation in one sentence
An 8B model for document classification can outperform a general-purpose 70B model on well-curated task examples, and at the same precision a 70B model needs far more resources to store weights and compute.
02
Today's assignment
Read size labels such as 3B·8B·70B and Transformer settings in terms of performance, memory, and failure symptoms.
03
Evidence that shows the work is complete
Base and instruct/chat models differ in purpose and input format even at the same size.
04
When to stop and ask a senior colleague
Even within the same model family, the relationship between size and quality must be checked together with the evaluation conditions, data, and amount of training.
Unpack unfamiliar terms first
Parameter
Numbers distributed across matrices such as embeddings, attention and FFN, adjusted during training to reduce error
Hidden size
Vector dimension representing the state of each token position
Feed-Forward Network(FFN)
A neural network inside a block that expands and then shrinks each token position's representation to transform it nonlinearly
PREREQUISITE CHECK
Three things to check before reading
This is not a test of memorized answers. Think about each question first, then open the explanation to review the foundational concepts used in this course.
1Can you explain why tables that arrange numbers in rows and columns are used?
Because it makes it easy to compute many inputs and outputs at once using the same rules. Neural network matrices and tensors likewise arrange many numbers into structures used for computations such as embedding and projection.
2Does storage space mean the same thing as computing ability?
They are not the same. Even if the weights fit in memory, the model can be impractically slow or stop running if compute speed, memory bandwidth, or space for context and concurrent requests is insufficient.
3What conditions must be identical to compare the numbers of the two products?
Keep the target task, inputs, output limit, precision, execution environment, and scoring criteria identical. The same principle applies when fairly evaluating 8B and 70B models or models with different architectures.
TEXTBOOK GUIDE
Main text that covers each concept from its background to the criteria for judging it
We explain the material section by section so readers new to IT can connect causes and effects without memorizing terms.
CONCEPT FLOW
How the chapters connect
The chapters are not isolated short answers to memorize. Follow them from left to right to see how each chapter's concepts support the next decision.
1.Read the B notation as a numeric unit→
2.Converting token IDs into embeddings and positional representations→
3.Updating representations in the Transformer block→
4.Distinguish attention heads from GQA→
5.Verify candidates with the model card and config
Parameters and Transformer: the overall map. If you lose track while reading the detailed explanations and chapters below, return to this sequence.
CONTROLLED EXPLANATION
Explore the order in which concepts build on each other
It does not start automatically. Play, or select the previous or next step, to see how the current concept connects to the next decision, step by step.
Current explanation · 1/5
Read the B notation as a numeric unit
The B in 8B stands for billion, meaning about 8 billion trainable numbers, not 8 billion pieces of knowledge or an accuracy score of 8.
Parameters work together within matrices, so do not map one number to one fact.
Up next: Converting token IDs into embeddings and positional representations, where this standard continues to apply.
See the full step description
1. Read the B notation as a numeric unit
The B in 8B stands for billion, meaning about 8 billion trainable numbers, not 8 billion pieces of knowledge or an accuracy score of 8. Parameters work together within matrices, so do not map one number to one fact.
2. Converting token IDs into embeddings and positional representations
Integer IDs produced by the tokenizer become input to context computation only after they are looked up as vectors in the embedding matrix and combined with positional information. Embedding is not a dictionary of word meanings; it is a multidimensional representation adjusted through training.
3. Updating representations in the Transformer block
One block passes through normalization, self-attention, residual connections, and an FFN, alternately accumulating contextual relationships and per-token transformations. Attention mixes information across positions, and the FFN expands and transforms the representation at each position.
4. Distinguish attention heads from GQA
Multi-Head Attention uses multiple Query heads, while GQA has multiple Query heads share a smaller number of grouped Key·Value heads, reducing cache load during generation. Query head count and Key·Value head count may be the same or, in GQA, different.
5. Verify candidates with the model card and config
Choosing a model does not end with the B number. Combine architecture, training and tuning type, context, tokenizer, precision, license, and your own evaluation results into a single deployment record. Base and instruct/chat models differ in purpose and input format even at the same size.
The text description below shows the same content without the animation. Your operating system's reduced-motion setting is also respected.Conceptual explanation 01
What does the parameter count measure?
A parameter is a number that changes during neural network training to reduce prediction error. The B in a model name stands for billion, so 3B means about 3 billion, 8B about 8 billion, and 70B about 70 billion parameters. These numbers are not laid out side by side in one giant table. They are distributed across many tensors: the embedding that turns token IDs into vectors, attention that computes contextual relationships, the Feed-Forward Network (FFN) that transforms each token representation, normalization, and the output projection. A tensor can be understood as data that arranges numbers of the same kind across multiple dimensions.
Beginners should first discard the idea that one parameter stores one piece of knowledge. Even the relationship that Seoul is South Korea’s capital is not retrieved from one particular number: distributed representations learned across many language contexts and computation across layers work together to produce the answer. Deleting one parameter does not neatly remove one fact. Nor do 8 billion parameters mean 8 billion verified facts. Knowledge accuracy, freshness and source attribution require separate evaluation and retrieval systems.
Parameter count is useful for estimating capacity and compute. For two models with similar architecture and precision, the one with the larger number tends to require more weight storage and memory bandwidth. However, the actual file reflects quantization, some tensors at other precisions, and metadata, and execution also needs KV cache and workspace. B is therefore a first clue about a candidate's rough scale, not a final value that decides downloadability, speed, and task acceptance all at once.
Why does this happen?
Reading B correctly makes it possible to estimate model file size and keeps performance comparisons from overlooking conditions other than size.
When is it a problem?
Reading 70B as a model 8.75 times more accurate than 8B leads you to buy more hardware than you need or to deploy a large model without evaluating it on real work.
Common beginner misconceptions
Parameters are not human-readable fact rows or dictionary entries. They are learned values distributed across many computational matrices.
How to verify it yourself
In the candidate model’s config and weight index, find the names and shapes of the embedding, attention, and FFN tensors, and note which components hold the numbers.
Conceptual explanation 02
Reframe the question of whether a bigger model is always better
More parameters may increase the capacity to represent complex patterns, but whether the model makes good use of that room depends on training. Data language and quality, total training tokens, duplication and contamination, optimizer and learning rate, architecture, instruction tuning, and safety tuning all change the result. Google DeepMind's compute-optimal research showed experimentally that, under a fixed compute budget, training tokens should be scaled along with model size instead of increasing model size alone. This result is not a rule to apply a specific ratio to every model forever; it is evidence that size alone cannot determine how well a model has been trained.
Classifying Korean parcel-delivery inquiries into five categories has a clear output format and easily checked answers. An 8B model tuned for Korean and the task may achieve higher format compliance than a general-purpose 70B. A larger model may help with conflicting conditions across documents or complex program-state changes. These outcomes are consistent: define model quality in terms of task, prompt, evaluation metrics and acceptable cost.
A fair comparison uses the same model variant, tokenizer, chat template, precision, input and output limits, and evaluation set. Read public benchmarks under the reported shot count, prompt, language, scoring method, and model revision. For your task, measure accuracy, evidence fidelity, format compliance, first-token latency, generation speed, peak memory, and failure recovery. Start with the smallest passing candidate to reduce costs and scale up incrementally if quality is insufficient.
Why does this happen?
Only a task-based comparison can explain why public rankings differ from real users' success rates and support reproducible choices.
When is it a problem?
Directly comparing scores produced with different prompts and quantization in one table cannot separate the effect of size from the effect of settings.
Common beginner misconceptions
Saying that larger models tend to have an advantage is not the same as saying a larger model is best under every task and cost condition.
How to verify it yourself
Fix 20 normal, 5 boundary, and 5 failure cases from your task. Run both candidates with identical settings and record quality, latency, and memory together.
Conceptual explanation 03
Where contextual representations begin from token IDs
When the tokenizer turns “I revised the report” into token IDs, the model does not perform arithmetic directly on those IDs. It retrieves the corresponding rows from a vocabulary-size × hidden-size embedding matrix to obtain vectors. With a hidden size of 4,096, each token position is represented by 4,096 numbers. These coordinates are not human-assigned meanings; they are adjusted together during training. Tokens frequently used in similar contexts may show similar relationships, but input embeddings alone do not determine their final meaning in a sentence.
Sentences have order, so position must also be represented. “The administrator approved the user” and “The user approved the administrator” use the same tokens but have opposite subjects. The original Transformer paper used sinusoidal positional encoding, and modern causal models may use methods such as Rotary Position Embedding (RoPE). Raising only the context number at runtime while ignoring the position scheme and training range can leave the model unable to use distant positions properly or degrade quality.
Combined embedding and positional representations change through attention and FFN layers. Even with the same token ID for “she,” preceding text such as “Minji revised the report” can produce a representation linked to Minji, while another context may refer to someone else. Do not overstate embeddings as human-readable coordinate tables. Research tools inspecting layer hidden states on identical sentences offer clues to relationships, not complete proof that the model answered solely for that reason.
Why does this happen?
Distinguishing input IDs, embeddings, and contextual hidden states lets you diagnose tokenizer mismatches and model reasoning problems at different layers.
When is it a problem?
Connecting a different tokenizer to the same weight can misalign the embedding rows referenced by token IDs, causing repeated characters, meaningless output, or failure to terminate.
Common beginner misconceptions
Each number in an embedding does not carry a single human-readable meaning, and there is no guarantee that nearby vectors mean the same thing in every context.
How to verify it yourself
In the deployment artifact, check that the tokenizer revision, vocab size, and special token IDs match the config's vocab_size, and compare token IDs for representative prompts with the previous deployment.
Conceptual explanation 04
Follow the full path through a Transformer block
A simplified Decoder-only Transformer block can be viewed as normalization, masked self-attention, residual addition, normalization, FFN, and residual addition, in that order. Masked self-attention hides positions after the current one so the model cannot see upcoming tokens, and computes relationships with the preceding context. The FFN does not mix positions directly; it expands each position's state into a wider intermediate dimension and projects it back to the hidden size. Modern implementations can differ in normalization placement, activations, and attention variants, so the model architecture documentation is authoritative for the actual wiring.
Residual connections add block inputs to new computation results. Deep networks accumulate necessary changes without overwriting all previous information at each stage, and training signals can pass more easily across layers. Normalization stabilizes computation by controlling value distributions and scales; it is not a database of facts. Claims such as “attention stores all knowledge” or “FFN is knowledge, attention is reasoning” oversimplify intertwined computations.
Structure also explains failure symptoms. Mismatches between checkpoint tensor shapes and configuration hidden size, intermediate size or layer count produce loader size errors. Incorrect weight-name mapping during conversion can destroy output quality even if files open. Do not fill missing tensors arbitrarily during recovery: restore the official source revision, architecture class and configuration, then compare representative inputs before and after conversion. The structural diagram preserves this diagnostic sequence.
How to read the figure One block is not a single attention step; it updates the state through six stages, and the hidden state keeps its shape while only the values inside change. When the hidden or intermediate size and the layer count in the config diverge from the checkpoint, it surfaces as a shape mismatch.
Why does this happen?
Understanding the whole block helps avoid explaining an entire model from one attention visualization and makes it possible to find config and weight mismatches systematically.
When is it a problem?
Forcibly converting a checkpoint with a different architecture can make loading fail on a shape mismatch or cause a silent quality regression.
Common beginner misconceptions
The encoder-decoder diagram in the original paper does not exactly match the detailed ordering in every modern decoder-only model.
How to verify it yourself
Open the official architecture documentation and config, and record the normalization type, number of layers, hidden and intermediate sizes, and activation and attention types in one table.
Conceptual explanation 05
How Query·Key·Value gather relationships
Self-attention creates Query (Q), Key (K), and Value (V) vectors from each token state. As an analogy, Query represents what the current position is looking for, Key represents the clues each context position offers, and Value represents the content to retrieve when selected. Scale the Query–Key dot products by the square root of the head dimension, then apply a mask and softmax to obtain attention weights that sum to 1. Use these weights to mix Values. This analogy explains the computation order; it does not mean the vectors literally contain human-written questions.
In “Minji corrected the report. She found an error,” the position of “She” can gather information related to the earlier “Minji.” However, you cannot conclude that a single attention weight is the complete cause of how the pronoun is resolved. Multiple heads and layers operate at the same time, and the FFN and residual connections then change the state. A visualization showing that the model attended heavily to a particular token is a clue for exploration; confirming a causal explanation for the answer additionally requires intervention experiments that change the input and compare the outputs.
The causal mask also matters. If a next-token model sees future answers during training, its conditions differ from inference. Mask future attention scores so each position attends only to itself and earlier positions. Incorrect masks or padding can leak answers, make training metrics look unusually good, and sharply reduce generation quality. Verify training and inference masks, padding, and position IDs on the same representative sequences.
Why does this happen?
Understanding Q·K·V and causal masks helps you read attention diagrams accurately and distinguish training-leakage symptoms from padding errors.
When is it a problem?
If the future-token mask breaks, training loss may look low, but the model learns from information that is not available during actual autoregressive generation.
Common beginner misconceptions
A high attention weight alone cannot fully explain human-like reasoning by the model or the cause of its final decision.
How to verify it yourself
In a short sentence using pseudonyms, mark the positions visible to the current token, and verify from framework output that the upper triangular region of the causal attention mask is blocked.
Conceptual explanation 06
Read head counts in MHA·GQA·MQA
Multi-Head Attention(MHA) divides Query·Key·Value so multiple heads calculate relationships in different representation subspaces. Standard MHA has equal Query and KV head counts. Multi-Query Attention(MQA) lets all Query heads share one Key head and one Value head. Grouped-Query Attention(GQA) lies between them, dividing Query heads among several KV groups. The original GQA paper introduces an intermediate configuration with more than one KV head but fewer KV heads than Query heads, aiming for quality close to MHA and speed close to MQA.
With 32 Query heads and 8 KV heads, every four Query heads share one KV group. With the same number of layers, head dimension, number of tokens, precision, and batch, the head entries stored in the KV cache are one quarter of those in MHA with 32 heads. However, total runtime memory does not shrink to one quarter. Embedding and FFN, Query and output projections, the rest of the model weights, and runtime workspace do not disappear. A conclusion such as “because it uses GQA, a 70B model runs in 8B memory” is wrong.
When reading a model config, write down num_attention_heads and num_key_value_heads separately and check the head dimension as hidden_size÷num_attention_heads. If the Query head count is not divisible by the KV head count, the model may not use simple equal-sized groups, or the config may have been misread. The official Llama 3.1 model card states that 8B·70B·405B all use GQA, but specific tensor shapes and runtime support must be verified against that model's config and implementation.
How to read the figure GQA does not remove Query heads; it groups Key and Value heads so they are shared. The cache calculation therefore takes num_key_value_heads, not num_attention_heads.
Why does this happen?
Read the KV-head count correctly to avoid overestimating or underestimating cache memory for long contexts and concurrent requests.
When is it a problem?
Substituting Query head count into the KV-cache equation overestimates GQA cache. Applying the GQA ratio to the entire model instead underestimates total memory.
Common beginner misconceptions
Do not assume that each head is dedicated to grammar, facts, or reasoning, or that GQA reduces the number of Query heads itself.
How to verify it yourself
Find the two head counts in the official config and calculate the group size, then record the difference between the estimate and the cache memory the runtime reports at the same context.
Conceptual explanation 07
Estimate where parameters come from using config numbers
For a beginner's approximation, calculate embedding parameters as vocabulary size × hidden size. If the output projection uses weight tying (sharing weights) with the input embedding, this table is reused; otherwise an output matrix of similar size is added. Attention sums the shapes of the Q, K, V, and output projections, and gated FFNs often use three large hidden × intermediate matrices, depending on the implementation. Multiply by the number of layers and add small items such as normalization to see the approximate breakdown of total model size.
The purpose of this calculation is not a game of reverse-engineering the official parameter count; it is to understand which setting drives which cost. Increasing the vocabulary enlarges the embedding and, in some cases, the output table; increasing hidden size sharply grows several square projections; intermediate size directly enlarges the FFN; and layer count repeats the block cost. The formula also shows that reducing KV heads shrinks the K and V projections and the cache, while the Query, output, and FFN stay the same.
Actual architectures differ in biases, gated-activation matrix counts, tied embeddings, local/global attention, mixtures of experts and multimodal projectors, so they do not exactly match the simple formula. Label exercise results educational approximations and verify against official model cards, configurations and sums derived from weight-index tensor shapes. Large discrepancies mean you must explain omitted structure rather than declare the model wrong.
Why does this happen?
Breaking the total parameter count in billions into components explains why changes to hidden dimensions, FFN and heads affect capacity and cache differently.
When is it a problem?
Counting only two matrices for a gated FFN or omitting an untied output can substantially underestimate size and lead to an incorrect equipment budget.
Common beginner misconceptions
Educational approximations do not replace official parameter counts for every architecture, and matching a number does not prove implementation compatibility.
How to verify it yourself
In the first lab, calculate the share of each component, compare it with the sum of tensor shapes in the official weight index, and record the names of missing items.
Conceptual explanation 08
Build a deployment contract from a model card
When reading a model card, do not take only the size from its first line. Check the developer and release date, pretrained/base versus instruction-tuned status, text-only versus vision input, supported languages and knowledge cutoff, architecture, context, intended use and known limitations, evaluation methods, license, and acceptable use. Compare vocab·hidden·intermediate sizes, layers, Query·KV heads, positions, and dtype in the config. If the documents disagree numerically, first verify that you are reading the exact same variant and revision.
Meta's official Llama 3.1 model card specifies text-model sizes of 8B·70B·405B, a 128K context, and GQA across all sizes. This claim supports structural information about that public model family, but it does not guarantee accuracy on your Korean-language tasks, the quality of quantized files, latency at 128K, or whether a consumer GPU can run the model. Google's Gemma 3 model card likewise distinguishes input modality and context conditions by size. Do not assume that every size in a family with the same name has the same features and limits.
The deployment record keeps the exact model ID and commit or revision, weight hash, tokenizer and chat template, quantization and dtype, runtime and driver, context and batch, license review date, evaluation set results, and rollback artifact. If output starts repeating after an update, diff which of model weights, tokenizer, template, or runtime changed, and restore the previous bundle. With this record, “why did the same 8B change?” can be explained with reproducible evidence instead of guesses from the name.
Why does this happen?
A model is not a single weight file but a bundle of artifacts that includes input formats and execution conditions, so pin them together to make comparison and rollback possible.
When is it a problem?
Recording only a mutable latest makes it impossible to reproduce the same experiment after upstream changes and can miss license, template, and config changes.
Common beginner misconceptions
The official maximum context and benchmarks are values reported under specific conditions, not a guarantee of the same results across all languages, runtimes, and precisions.
How to verify it yourself
For each candidate, record model ID, revision, hash, variant, context, tokenizer, template, license, runtime and evaluation results in one row. Do not promote candidates with missing fields.
Conceptual explanation 09
Distinguishing weight tying and parameter sharing from the actual total tensor size
A language model has an input embedding that converts token IDs into hidden vectors and an output projection that converts the final hidden state into vocabulary logits. The two matrices can have corresponding shapes, such as vocabulary size × hidden size. Weight tying is a design in which the output projection shares the same parameters as the input embedding. There are two roles but only one stored and trained tensor, so counting it twice in a simple calculation overestimates the total.
Config fields such as `tie_word_embeddings` are clues, but not every architecture uses the same names and storage scheme. Use the framework loader and official architecture documentation to check whether the input and output names in the weight index refer to the same storage and whether the checkpoint includes a separate output tensor. If the byte total of the Safetensors shards cannot fully explain parameter sharing, compare the loaded model's named parameters against data pointers and the official count.
Parameter sharing is not limited to embeddings. Some architectures reuse weights across layers or conditionally attach experts·adapters. Conversely, multimodal models can add a vision encoder, projector, and audio components, giving them more tensors than the text model name suggests. Do not force the teaching dense-decoder approximation onto every checkpoint; explain differences between the estimate and the official count with a list of structures.
Check that weight sharing survives conversion and quantization. If a converter materializes a shared tensor twice, the displayed parameter count may look the same while artifact bytes and load memory grow; conversely, alias handling may show only one entry in the file list. Compare tensor names, shapes, dtypes, and storage bytes between the original and converted files, then retest quality on the same prompts and peak memory to close the conversion contract.
Why does this happen?
Parameter counts measure independently learned tensor elements, not computational roles. Count shared weights only once even when used in several places.
When is it a problem?
Always counting embedding and output weights twice, or breaking weight sharing in a converted artifact, makes parameter, file, and memory estimates diverge sharply from official figures.
Common beginner misconceptions
Identical shapes do not automatically mean identical weights, and a single sharing flag in the config does not prove every artifact alias.
How to verify it yourself
In the official config, weight index, and loaded parameters, check the names, shapes, and storage sharing of the input and output tensors, and compare bytes and peaks before and after conversion.
Conceptual explanation 10
Keeping separate ledgers for weight parameters and activation·cache·optimizer memory
Storing 8B parameters in 4bit gives a simple lower bound of about 4GB for the weights, but scale·metadata and mixed tensors add to that, and the runtime uses graph·kernel workspace and an allocator. Even with a fixed parameter count, activation and KV cache vary with input·output tokens, layers, hidden·KV heads, batch, and concurrency. The conclusion “the 8B Q4 file is 6GiB, so it is safe on an 8GiB device” ignores the runtime state of the longest request.
During inference, prefill activations can create temporary peaks depending on the kernel and implementation, while KV cache grows with tokens and sequences during decoding. Static cache may reserve maximum space, and paged runtimes have block and allocator overhead. This explains why one 4K-context request and four 32K-context requests have different peaks for the same model parameters. Measure GPU and system memory separately during loading, prefill, decoding and each target concurrency level.
Training stores weights, gradients, optimizer states, and activations needed for backward passes. Adam-family optimizers may keep several states per parameter, and mixed-precision training may retain master weights. LoRA and QLoRA can reduce trainable parameters and weight memory, but do not eliminate activations, quantization metadata, or optimizer states. A parameter-count label alone does not prove that hardware capable of inference can also support training.
Use separate operational columns for artifact bytes, loaded weights, loading/prefill/decode peaks, KV cache, host offload and training peaks. Attach measurement time, exact model/runtime, input/output tokens and concurrency to each value. Purchasing tables should include actual maxima for representative/longest inputs and single/target user counts, not just weight lower bounds. For offloaded layers, record transfer latency, CPU usage and response-latency percentiles alongside device-memory reduction. Mark unmeasured cells unverified, not zero. Have another operator check inputs and units before approval. Change runtime, context, batch and quantization individually and retest peaks, latency and quality on the same failures. On OOM, identify the growing memory category and first restore admission limits and previous settings rather than immediately choosing a smaller parameter name.
Why does this happen?
This is because weights are fixed tensors, while activation·cache·gradient·optimizer states are created and grow with the purpose of execution and the requests·batch.
When is it a problem?
If file and weight calculations are correct but OOM occurs during prefill, concurrent requests or training, the separate accounting for runtime state and workspace is likely missing.
Common beginner misconceptions
Parameter×bit÷8 is not all model execution·training memory, and total peaks do not necessarily shrink exactly in proportion to quantization.
How to verify it yourself
For the same artifact, measure device·host peaks during load·prefill·decode·concurrency and training, and explain the difference from the weight lower bound item by item.
CONCRETE CASES
Check concepts in different situations
Before memorizing definitions, compare how these concepts appear on a personal PC and in real work.
Case 1 · Read the B notation as a numeric unit
An 8B model for document classification can outperform a general-purpose 70B model on well-curated task examples, and at the same precision a 70B model needs far more resources to store weights and compute.
Key points to check here: Parameters work together within matrices, so do not map one number to one fact.
Case 2 · Converting token IDs into embeddings and positional representations
The English word bank means a financial institution in “deposit money at the bank” and the side of a river in “sit on the river bank”. Even assuming the same token ID is used, its contextual representation changes with its relationships to surrounding tokens.
Key points to check here: Embedding is not a dictionary of word meanings; it is a multidimensional representation adjusted through training.
Case 3 · Updating representations in the Transformer block
In “Do not pay for goods that have not been shipped,” attention gathers the relationship between “not” and “goods,” and the FFN transforms that combination into a representation for the next decision.
Key points to check here: Attention mixes information across positions, and the FFN expands and transforms the representation at each position.
Case 4 · Distinguish attention heads from GQA
With 32 Query heads and 8 KV heads, every four Query heads share one KV group, and the number of simple KV cache entries is one quarter of what storing 32 would require.
Key points to check here: Query head count and Key·Value head count may be the same or, in GQA, different.
Case 5 · Verify candidates with the model card and config
Meta's Llama 3.1 model card specifies 8B·70B·405B, 128K context, and GQA, but it does not automatically guarantee quality on Korean-language tasks or a practical context length on your GPU.
Key points to check here: Base and instruct/chat models differ in purpose and input format even at the same size.
CHAPTER 1 / 5
Read the B notation as a numeric unit
The B in 3B, 8B, and 70B in a model name stands for billion, indicating about 3 billion, 8 billion, and 70 billion parameters, respectively. A parameter is a number adjusted during training to reduce error. Parameters are spread across many locations, such as the embedding table that converts tokens into vectors, the Query·Key·Value·output matrices of attention, and the matrices of the Feed-Forward Network (FFN, the network that transforms each token representation nonlinearly). A single number is not a drawer that stores one fact, such as whether Seoul is a capital.
More parameters give more room to represent broader patterns, but that alone does not guarantee performance. Results depend on what data was learned and how clean it was, how well the tokenizer handles the task language, whether the number of training tokens and the optimization were sufficient, and how instruction tuning was applied on top of the base model. The Chinchilla study showed that, for a fixed compute budget, training data must be scaled together with model size, precisely because a single size number cannot explain training quality.
For a task classifying customer inquiries into five categories, a small model trained well on Korean examples and the output format may be more consistent than a larger general model. Comparing conflicting clauses in long contracts or tracing complex code causes may improve with a larger model. In either case, public model-card benchmarks are only a starting point. Compare normal, boundary, and failure cases using identical prompts and scoring criteria.
Beginners may assume that 70B is about 8.75 times smarter than 8B. That is a parameter-count ratio, not an accuracy or reasoning-ability ratio. Weight storage at a given precision, prompt-processing time, generation speed, power and concurrent-user capacity also vary. Define task passing criteria first, then measure starting with the smallest candidate that meets them to reduce cost and failure risk.
To recap the key points
Parameters work together within matrices, so do not map one number to one fact.
Even within the same model family, the relationship between size and quality must be checked together with the evaluation conditions, data, and amount of training.
How this connects in practice
An 8B model for document classification can outperform a general-purpose 70B model on well-curated task examples, and at the same precision a 70B model needs far more resources to store weights and compute.
CHAPTER 2 / 5
Converting token IDs into embeddings and positional representations
A token ID produced by the tokenizer is simply a vocabulary row number. The model retrieves the corresponding numerical vector from an embedding matrix of vocabulary size × hidden size. Hidden size is the number of values used to represent each token state. For example, a hidden size of 4,096 represents one position with 4,096 numbers, but coordinates do not have fixed human-assigned names such as “noun” or “past.” Many coordinates jointly form directions and distances, with meaning represented in a distributed way through layer computations.
Order information is necessary too: 'The dog bit the person' and 'The person bit the dog' have similar tokens but different meanings because their order differs. Early Transformers added positional encodings; modern decoder-only models often use variants such as Rotary Position Embedding (RoPE), applying position-dependent rotations to queries and keys. Check model configuration and cards for the method, maximum trained positions and runtime context limits.
Describing an Embedding as a map where similar words are nearby can offer an initial intuition, but it is not a complete definition. The input embedding is the starting representation before any layer, while a contextual hidden state incorporates information from surrounding tokens. In the example distinguishing the financial and river-side meanings of the English word bank, first assume that the same token ID is used. Attention and FFN update the representation at that position using the surrounding information. Actual token segmentation can vary with the tokenizer and preceding whitespace; the Korean word for a financial bank does not also mean the side of a river.
One real-world incident is a mismatched pairing of vocabulary or tokenizer with model weights. If the piece that ID 105 referred to during training differs from the piece the deployed tokenizer produces, embedding meanings diverge and the output breaks. Do not assume reproducibility just because the model file matches; pin the tokenizer files, special token IDs, chat template, config, and revision as one bundle. If characters repeat or roles get mixed after an update, compare this input contract first.
To recap the key points
Embedding is not a dictionary of word meanings; it is a multidimensional representation adjusted through training.
The same token turns into different contextual representations as it passes through surrounding tokens and layers.
How this connects in practice
The English word bank means a financial institution in “deposit money at the bank” and the side of a river in “sit on the river bank”. Even assuming the same token ID is used, its contextual representation changes with its relationships to surrounding tokens.
CHAPTER 3 / 5
Updating representations in the Transformer block
A Transformer block contains more than attention. Modern causal language models generally normalize value scales, use masked self-attention to let the current position attend to itself and preceding positions, and add the result to the prior state through a residual connection. They then apply another normalization and FFN and add another residual. Normalization placement, activations, biases, and parallel structures vary by implementation, so do not treat the original paper’s diagram as the exact wiring of every modern model.
Self-attention dynamically mixes relationships between token positions. Similarities between the Query at the current position and Keys at preceding positions produce weights used to combine Values. The FFN applies the same matrices at every position, but different input states produce different transformed outputs. In many decoder models, a gated FFN expands the hidden state to a larger intermediate size, applies a gate and activation, and reduces it back to the hidden size. These intermediate matrices may account for a large share of the parameters.
Treating residual connections as mere bypass lines misses why deep models retain earlier information. Because each block adds its input representation instead of passing only its new computation to the next layer, the model can develop representations by stacking corrections on top of the existing state. Normalization is likewise a computation that stabilizes value scales, not a layer that stores word meanings. More layers allow more correction stages, but depth alone does not guarantee good results without supporting training and design.
When troubleshooting, compare config names against tensor shapes. If the hidden size is not divisible by the number of attention heads, or a converted checkpoint's intermediate size differs from the config, loading can fail with a shape mismatch. Even if the file opens, an incorrect conversion of the architecture name and weight key mapping can wreck quality. Recovery does not mean forcing sizes to match; it means returning to the official config and original checkpoint revision and re-verifying architecture, shape, and tokenizer.
How to read the figure One block is not a single attention step; it updates the state through six stages, and the hidden state keeps its shape while only the values inside change. When the hidden or intermediate size and the layer count in the config diverge from the checkpoint, it surfaces as a shape mismatch.
To recap the key points
Attention mixes information across positions, and the FFN expands and transforms the representation at each position.
Residual connections add the previous representation so that information and training signals carry through even deep layers.
How this connects in practice
In “Do not pay for goods that have not been shipped,” attention gathers the relationship between “not” and “goods,” and the FFN transforms that combination into a representation for the next decision.
CHAPTER 4 / 5
Distinguish attention heads from GQA
Multi-Head Attention (MHA) splits the hidden state into multiple heads and computes different relationships in parallel. With 32 Query heads and a hidden size of 4,096, the head dimension in a common configuration is 128. It cannot be concluded that each head handles one independent rule of human language, but the design can be understood as capturing relationships in multiple representation subspaces rather than through a single large attention computation.
Autoregressive generation reuses previous tokens’ Keys and Values when producing each new token, so they are retained in the KV cache. Standard MHA has as many KV heads as Query heads; Multi-Query Attention (MQA) shares one KV head. Grouped-Query Attention (GQA) lies between them, grouping multiple Query heads around shared KV heads. The original GQA paper describes an intermediate KV-head count greater than one and less than the Query-head count.
With 32 Query heads and 8 KV heads, the group size is 4. Comparing only the number of K·V heads stored under the same layer·head dimension·context·cache precision conditions, the entry count is one quarter of MHA with 32 KV heads. However, total model memory does not become exactly one quarter as well. Embedding, FFN, Query and output projections, and runtime buffers stay the same, and cache layout and precision vary by implementation. Missing this distinction leads you to underestimate the hardware budget.
A common GQA deployment error is calculating KV cache using only num_attention_heads. Use num_key_value_heads, head_dim, num_hidden_layers, context tokens, bytes per value and concurrent sequences from the model configuration. Conversely, an incorrect KV-head count during configuration conversion can cause tensor-shape errors or prevent loading the checkpoint. The second exercise checks Query/KV divisibility, related token selection and relative cache size together.
How to read the figure GQA does not remove Query heads; it groups Key and Value heads so they are shared. The cache calculation therefore takes num_key_value_heads, not num_attention_heads.
To recap the key points
Query head count and Key·Value head count may be the same or, in GQA, different.
GQA affects attention's KV projections and cache size; it does not reduce the entire weight file by the same ratio.
How this connects in practice
With 32 Query heads and 8 KV heads, every four Query heads share one KV group, and the number of simple KV cache entries is one quarter of what storing 32 would require.
CHAPTER 5 / 5
Verify candidates with the model card and config
A model card is the starting point for recovering the conditions behind a model name. Read the developer, release date, parameter size, architecture, modality, supported languages, training-data scope and knowledge cutoff, intended use, restrictions, evaluation method, and license. In the config, check model_type, vocab_size, hidden_size, intermediate_size, num_hidden_layers, num_attention_heads, num_key_value_heads, max_position_embeddings, rope-related values, and dtype. Cross-check for contradictions rather than relying on one file.
Pretrained or base models are starting points trained for next-token prediction; instruct/chat models are additionally adapted for instruction following and conversation. Even at 8B, chat templates and special tokens may differ, as can safety tuning·supported languages·tool calling. Select the exact variant and tokenizer together to avoid blaming architecture for an unsuitable base model’s conversational output or copying another family’s template and causing failure to stop.
The maximum context in official documentation does not guarantee sufficient quality and speed for your task at that length. Meta’s Llama 3.1 model card stating 128K context and GQA at every size supports architectural facts, while Korean quality, specific quantization, and concurrent-user throughput require separate tests. Google’s Gemma 3 model card also specifies different context limits and input modalities by size. Assuming identical conditions across all variants based on the family name can cause request rejection or memory exhaustion.
The final candidate record includes the exact model ID and revision, file hash, tokenizer and template, license review date, runtime, driver, and precision, context and batch settings, hardware, normal, boundary, and failure evaluation results, and rollback artifacts. If quality drops after an update, do not immediately switch to a larger model; restore the previous bundle, then change only one of the model weights, tokenizer, template, or runtime to isolate the cause. Choosing a model is not picking a name but approving a reproducible system contract.
To recap the key points
Base and instruct/chat models differ in purpose and input format even at the same size.
Read the official maximum context and benchmarks with the document's conditions intact, and remeasure them in your runtime.
How this connects in practice
Meta's Llama 3.1 model card specifies 8B·70B·405B, 128K context, and GQA, but it does not automatically guarantee quality on Korean-language tasks or a practical context length on your GPU.
INTERACTIVE LAB 1 / 2
Lab 1 · Parameter-structure budget lab
Enter values in the browser and check the execution results and the failure and recovery paths. No commands are ever sent to real equipment or the NAS.
Split config numbers into embedding/attention/FFN budgets
This is a simplified approximation of a typical decoder-only gated FFN architecture. It does not replace the official parameter count; use it to observe which settings drive which costs.
Situation
The file name says 7B, but there is no explanation of how the numbers in the config relate to the total.
Goal
Calculate the size and share of major tensors from vocabulary, hidden, intermediate, layer, and head counts.
Prerequisites
Find the six values in the official model config and check whether the input and output embeddings are shared.
Success criteria
Derive integer head dimensions and even GQA groups, and explain the omitted structures behind differences from the official total.
Enter values from the official config and choose whether the output embedding is shared.
Architecture budget calculation to compare the embedding, attention and FFN proportions.
If it fails, fix the head division; after it succeeds, record the difference from the official weight index.
Limitations: This teaching formula lets you choose three gated-FFN matrices and tied embeddings. Projections, biases, experts, multimodal components, and tensor sharing vary by architecture, so verify capacity for purchasing and deployment against the actual artifact.
INTERACTIVE LAB 2 / 2
Lab 2 · Attention relationship and GQA diagnostic lab
Enter values in the browser and check the execution results and the failure and recovery paths. No commands are ever sent to real equipment or the NAS.
Choose context relationships and diagnose the GQA cache scope
In a short sentence, choose the earlier expression related to the current token, then calculate the Query-to-KV head sharing ratio. This lab does not reproduce actual model attention weights.
Situation
The learner has seen the attention diagram and the GQA numbers but overstates relationship selection and the extent of cache reduction.
Goal
Find the preceding context the current expression needs, distinguish Query heads from KV heads, and calculate the relative number of cache entries.
Prerequisites
Read the sentence from left to right and prepare the two head values from the model config.
Success criteria
Identifies the relationship token, confirms that Query heads divide evenly into KV groups, and explains that only KV entries shrink, not total memory.
Choose a situation, then choose which earlier clue is needed to understand the current expression.
Enter the Query and KV head counts, then run Relationship and GQA diagnosis.
Read the hold reasons, correct the relationship or head count and rerun the same scenario.
SentenceMinji fixed the report. She found an error.Current expression: She
Caveat: The chosen relationship is a human-made answer for practicing the concept of attention. Real models use many heads, layers, and FFNs together, so a single weight is not presented as a complete explanation of human reasoning.
KEY TERMS
Key terms in this unit
Parameter
Numbers distributed across matrices such as embeddings, attention and FFN, adjusted during training to reduce error
Hidden size
Vector dimension representing the state of each token position
Feed-Forward Network(FFN)
A neural network inside a block that expands and then shrinks each token position's representation to transform it nonlinearly
Grouped-Query Attention(GQA)
An attention method in which multiple query heads share fewer key and value heads in groups
UNIT WORKBOOK
Exercises and worksheets for applying concepts to new situations
Start by checking basic principles, then expand to practical workplace decisions. After submitting an answer, you can see why every option is correct or incorrect, not just the correct answer.
Basic Question 1
What most accurately describes the B and the parameters in an 8B model?
Basic Question 2
Which option best connects the roles within a Transformer block?
Apply Question 3
Which statement best describes a GQA model with 32 Query heads and 8 KV heads?
The MHA model used for comparison has the same layers, head dimension, context, and cache precision, with 32 Query heads and 32 KV heads.
Apply Question 4
What is the safest first response when a newly converted checkpoint fails to open with a hidden size mismatch error?
The original ran normally before conversion, and the new config's hidden_size does not match some weight tensor shapes.
Capstone Question 5
What is the most complete plan for selecting an operational candidate among the two models?
A is an 8B instruct model and B is a 70B instruct model, intended for Korean document classification and evidence explanations. Hardware, latency, and licensing constraints apply.
PERSONAL WORKSHEET
A learning worksheet you adapt to your own environment
Your input remains only on the current browser screen and is not stored or transmitted externally. Use categories and pseudonyms instead of actual sensitive information.
OFFICIAL SOURCES
Verify against official sources
Technical, compatibility, and model information reviewed: August 2026