llm-basics.mdupdated 2026-07-162635 words
ダブルクリックで英日反転
Applied Sciences · Engineering

What Is an LLM? How It Works in One Go

EN

An LLM (Large Language Model) is the brain behind ChatGPT and Claude — a giant probability machine that generates text by repeatedly predicting the most likely next token.

Core Mechanism

  • Predicts the next token (word or sub-word chunk) given all preceding text.
  • Repeats one token at a time to produce fluent, extended output.
  • "Token" = the atomic unit the model operates on (e.g. "東京都" → "東京" + "都").

Why It Got So Clever — Transformer & Attention

  • The 2017 Transformer architecture was the turning point.
  • Attention mechanism: weighs relationships between all words simultaneously, regardless of distance.
  • Enables long-context understanding by linking pronouns, references, and far-apart words.

Training: Two Stages

  • Pre-training: reads internet-scale text, solves "next-word prediction" billions of times.
  • Post-tuning (fine-tuning / RLHF): aligns outputs with human preferences via reward signals.
  • RLHF (Reinforcement Learning from Human Feedback) is where safety and helpfulness are instilled.

Power & Weakness

  • Parameters (billions–trillions of learned weights) determine expressive capacity — but data quality matters more than sheer count.
  • Hallucination: the model picks "plausible" words, not necessarily true ones — confident errors are possible.
  • RAG (Retrieval-Augmented Generation) is a common mitigation: attach authoritative sources at query time.
An LLM is a probabilistic next-token predictor; Transformer attention gives it context, RLHF gives it manners — but fact-checking stays on the human side.
Applied Sciences · Engineering

LLMとは​何か​ — 仕組みを​一気に​理解する

JP

LLM​(大規模言語モデル)は​ChatGPTや​Claudeの​中枢。​「次に​来る​トークンを​確率的に​予測し続ける」​ことで​テキストを​生成する​巨大な​確率機械だ。

中核の​仕組み

  • 直前までの​文脈を​受け取り、​次の​トークン​(単語や​単語の​一部)を​確率で​選ぶ。
  • これを​1トークンずつ​繰り返して​文章を​伸ばす。
  • 「トークン」​=モデルが​扱う​最小単位​(例:​「東京都」​→​「東京」+​「都」に​分割)。

飛躍の​理由 — Transformer​(トランスフォーマー)と​Attention​(注意機構)

  • 2017年登場の​Transformerアーキテクチャが​転換点。
  • Attention​(注意機構)​:文中の​すべての​語の​関係を​距離に​関わらず​一度に​計算する。
  • 離れた​語の​参照関係も​保持でき、​長い​コンテキストの​理解が​可能に​なった。

学習の​2段階

  • 事前学習​(Pre-training)​:インターネット規模の​テキストで​「次の​単語予測」を​大量に​解く。
  • 後調整​(RLHF)​:人間の​評価を​報酬と​して​使い​「望ましい​答え方」を​教え込む。
  • RLHF​(人間フィードバックに​よる​強化学習)で​安全性・​丁寧さ・​有用性が​身に​つく。

強みと​弱み

  • パラメータ​(数十億〜数兆の​学習済み重み)が​表現力を​決めるが、​データ品質の​方が​重要。
  • ハルシネーション​(幻覚)​:​「もっと​もらしい」語を​選ぶため、​自信満々に​誤情報を​出力する。
  • 対策の​定番は​RAG​(検索拡張生成)​:外部の​信頼情報を​検索して​モデルに​添付する​手法。
LLMは​確率的な​次トークン予測器。​Transformerの​attentionが​文脈を​保ち、​RLHFが​礼儀を​与えるが、​ファクトチェックは​人間の​役割のまま。
148 notestil