Training vs Inference, Visually Explained
シリーズ: イメージでわかる
「モデルを育てる時間」と「育ったモデルを使う時間」はまったく別のものです。LLM が会話中に勝手に賢くなっているわけではないことも、このページでやさしく整理します。
The time spent "raising a model" and the time spent "using a raised model" are completely different things. This page gently clarifies why normal LLM use does not mean the model is learning on the fly.
AI には大きく分けて2つの時間があります。
AI operates in two fundamentally different modes.
ひとつは、まちがいを見ながら中身を直していく学習(training)。
One is training — fixing internal parameters by looking at mistakes.
もうひとつは、できあがったモデルを使って答えを出す推論(inference)です。
The other is inference — using a finished model to produce answers.
🎓 たとえ: テスト勉強をしている時間が学習、テスト本番で答案を書いている時間が推論です。勉強しているときはノートを書き直しますが、テスト本番ではノートを書き直しません。
🎓 Analogy: Training is studying for an exam — you rewrite your notes. Inference is sitting the exam — you write answers but don't rewrite your notes.
核心は「重みが書き換わるかどうか」です。
The crux is whether the model's weights get rewritten.
学習中は、モデルの中の重み(weight)が少しずつ変わります。正解と比べて「どれくらいずれていたか」を計算し、その分だけ重みを修正します。
During training, the model's weights change step by step. The system computes how far off the prediction was from the correct answer, then adjusts the weights accordingly.
推論中は、重みは基本的に変わりません。すでに覚えたことを使って、入力に対する答えを計算するだけです。
During inference, the weights essentially stay fixed. The model simply uses what it already knows to compute an answer for the given input.
✅ ポイント: 推論は「すでに覚えたことを使う時間」です。新しいことを覚え直す時間ではありません。
✅ Key point: Inference is "using what was already learned." It is not the time for learning new things.
もうひとつわかりやすい違いがあります。
There's another clear-cut difference.
学習では、「正解」と比べて、どれだけ外れたかを見ます。正解があるからこそ、直す方向がわかります。
During training, predictions are compared against correct answers. Having the right answer is what tells the model which direction to adjust.
推論では、正解は一緒に渡されません。その場で答えを出すだけです。合っているかどうかは、推論の仕組みそのものには含まれていません。
During inference, no correct answer is provided. The model just produces its best guess. Whether it's right or wrong is outside the inference mechanism itself.
📝 たとえ: 学習は「赤ペン先生が答え合わせしてくれる練習問題」、推論は「答え合わせなしの本番」みたいなものです。
📝 Analogy: Training is like "practice problems graded by a teacher." Inference is like "the real test with no answer key."
よくある誤解を、ここではっきりさせます。
Let's clear up a common misconception.
ふつうのチャット利用では、LLM は会話のたびに自分の重みを学習し直しているわけではありません。会話中にやっているのは、入力文を読んで次の語を予測する推論です。
In normal chat use, an LLM does not retrain its weights with each conversation. What it's doing is reading the input and predicting the next token — that's inference.
ただし、会話の文脈を一時的に覚えて答え方を変えることはあります。これはその場の参照であって、モデル全体が学習し直されているわけではありません。
However, it can temporarily hold the conversation context and adjust its responses. This is in-context referencing, not retraining the entire model.
⚠ よくある勘違い:「ChatGPT に教えたから次から覚えてくれる」→ 多くの場合、それは文脈ウィンドウ内で参照しているだけで、モデルの重みは変わっていません。
⚠ Common misconception: "I taught ChatGPT something, so it'll remember next time" → In most cases, it's just referencing within the context window; the model's weights haven't changed.
似て見えますが、同じではありません。
They look similar, but they're not the same.
メモリは「あとで参照するために情報を残すこと」です。会話の履歴をウィンドウに入れたり、外部のデータベースに保存したりする仕組みがこれにあたります。
Memory means "saving information for later reference." This includes keeping conversation history in the context window, or storing data in an external database.
学習は「モデルの中の重みそのものを変えること」です。メモリに入れた情報をどれだけ使っても、重みが書き換わらなければ学習ではありません。
Learning (training) means "changing the model's weights themselves." No matter how much information you put into memory, if the weights don't change, it's not learning.
📎 たとえ: メモリは「付箋を机に貼ること」。学習は「教科書の中身を書き換えること」。付箋を何枚貼っても、教科書の本文は変わりません。
📎 Analogy: Memory is "sticking a Post-it on your desk." Learning is "rewriting the textbook itself." No matter how many Post-its you add, the textbook text stays the same.
計算の重さがまるで違います。
The computational load is completely different.
推論では、入力データを「前向き(forward)」に通して結果を得るだけです。
Inference only needs a single forward pass — feed data in, get a result out.
学習では、まず前向きに計算して答えを出し、次に「どこを直せばよいか」を逆向き(backward)にたどって計算し、さらに重みを更新します。
Training requires a forward pass to produce a prediction, then a backward pass to trace which weights need fixing, and finally a weight update step.
そのため、学習は推論よりもずっと重く、時間も VRAM も多く使います。
This makes training much heavier than inference, consuming more time and VRAM.
🔧 ROCm では: 推論でも学習でも、行列計算は rocBLAS や MIOpen が受け持ちます。ただし学習時は backward 計算が加わるため、GPU の仕事量が大幅に増えます。gfx900(Vega)は推論には十分使える場面が多いですが、大規模な学習には VRAM やサポート面で制約があります。
🔧 In ROCm: Both inference and training rely on rocBLAS and MIOpen for matrix operations. But training adds backward computation, significantly increasing GPU workload. gfx900 (Vega) is often sufficient for inference, but large-scale training faces VRAM and support constraints.
学習と推論の違いを、ひと目で整理します。
A quick comparison table to see the differences at a glance.
| 観点 | Aspect | 学習 (Training) | Training | 推論 (Inference) | Inference |
|---|---|---|---|---|---|
| 目的 | Purpose | モデルを育てる | Raise/improve the model | 答えを出す | Produce answers |
| 正解データ | Correct answers | 使う | Used | 使わない | Not used |
| 重み | Weights | 変わる | Change | 基本変わらない | Stay fixed |
| 計算の流れ | Computation | forward + backward + 更新 | Forward + backward + update | forward のみ | Forward only |
| 計算の重さ | Load | 重い(時間・VRAM 大) | Heavy (time & VRAM) | 比較的軽い | Relatively light |
| LLM チャット中 | During LLM chat | 通常ここではない | Usually not happening | ← ここ | ← This one |