one-hot ベクトルから埋め込みルックアップへ
Agent支援エンジニアリング確認
前提条件
第 39 日のトークン化と n-gram 統計。数学ブロックの基本的な行列乗算。
学習目標
埋め込みルックアップが one-hot ベクトルと埋め込み行列の積に等しい理由を導出し、実際の構成に対してテーブルの形状とパラメータ数を予測する。
手順
必須作業:小さな語彙 V = {'.', 'a', 'b', 'c'}(インデックス 0-3)と、行 '.'=[0.1,0.3]、'a'=[0.2,-0.1]、'b'=[-0.4,0.5]、'c'=[0.0,0.2] を持つ埋め込みテーブル C(形状 (V,d) = (4,2))を使う。one-hot ベクトル e_2 = [0,0,1,0] と C の積が行 2 を選択し [-0.4, 0.5] になることを示す。コードが V 次元の one-hot ベクトルを実体化せず整数ルックアップ C[i] を使う理由を説明する。任意作業:同じ文字が 2 つの異なるテーブルで埋め込まれる場合に何が変わるかを述べる。
演習と予測記録
1. 上のテーブルで e_3 * C を計算し、どの行が選択されるか述べる。
2. 名前語彙 V=27、d=10 の場合、C の形状とパラメータ数を述べる。
3. C[i] が e_i を構築して掛けるより安い理由を一文で述べる。
one-hot ベクトルは 1 つの 1 以外すべて 0。積では 0 の要素が C の行を 1 行ずつ消去するため、1 が立つ行だけが残る。パラメータ数 = 行数 × 列数。
e_3 = [0,0,0,1] は行 3 を選択し [0.0, 0.2] を返す。V=27、d=10 のとき C の形状は (27,10)、パラメータ数は 270。ルックアップ C[i] のコストは O(d) の計算とメモリ。one-hot 方式は V-1 行を捨てるだけの O(V) の無駄な仕事をし、ほぼゼロのベクトルを格納するメモリも浪費する。
学習者が恒等式 e_i * C = C[i,:] を書き、両方の例題ルックアップを正しく計算し、(27,10) テーブルの 270 パラメータを助けなしに導出できる。
公式ソースリソースと権利証跡
makemore: Character-level language models on names.txt
該当セクション・タイムスタンプ: makemore MLP lecture segment: indexing the embedding table C with one-hot vectors
検証バージョンと日付: Repository state verified 2026-10-30; lecture published 2022
Standard beginner walkthrough of the Bengio-style MLP language model; the MIT-licensed reference implementation pairs with a stepwise derivation that matches the Days 40-42 worked numbers exactly.
Python basics, matrix multiplication, and the Day 37-39 tokenization and n-gram context
All forward-pass arithmetic, shapes, parameter counts, and loss values are reproduced as original hand-worked examples in the lesson text; no video, subtitle, or transcript is required.
比較対象候補リソースと選定評価 (3)
The original architecture paper; selected jointly as the theoretical citation while Makemore supplies the stepwise implementation walkthrough.
Strong PyTorch rigor but assumes fluent tensor programming; deferred to the Days 43-60 pretraining blocks rather than the first embedding contact.
Strong visual intuition for network mechanics but covers image classification rather than embedding tables and next-token language modeling; retained as optional supplementary viewing.
A Neural Probabilistic Language Model
該当セクション・タイムスタンプ: Sections 1-2 (feature vectors and the joint probability model)
検証バージョンと日付: JMLR Volume 3 (2003); verified 2026-10-30
The original paper introducing jointly learned word feature vectors and the neural probabilistic language model; grounds the curriculum's embedding and MLP derivations in the primary literature.
Probability basics and linear algebra
Every worked derivation in the lessons is self-contained and offline-complete; the paper is further reading only.
比較対象候補リソースと選定評価 (3)
Selected jointly: Makemore reproduces this architecture at character scale with MIT-licensed code; the paper supplies the original formalism and the n-gram comparison framing.
Strong textbook coverage of n-grams through neural LMs; kept as secondary reading because the primary derivation follows the original paper's notation.
Foundational for embedding geometry but trains on context-prediction objectives rather than the full next-token probabilistic model studied this week; revisited in later representation blocks.