40 / 90

第 40 日:学習型埋め込みテーブルと分散表現

疎な one-hot 指示ベクトルを学習型埋め込み行列 C に置き換える。ルックアップ=行選択の同一性を証明し、行を特徴空間の点として読み、順伝播の前にテンソル形状とパラメータ数を予測する。各活動で予測・観察・復習・回復を記録する。

モデルと訓練 480 分の能動学習時間(8 時間の集中学習)
01 120 分

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 を構築して掛けるより安い理由を一文で述べる。

独立習得基準

学習者が恒等式 e_i * C = C[i,:] を書き、両方の例題ルックアップを正しく計算し、(27,10) テーブルの 270 パラメータを助けなしに導出できる。

公式ソースリソースと権利証跡

linking MIT License (repository) / Standard YouTube License (video, subtitle rights unknown) Video subtitles have unknown distribution rights and are not imported

makemore: Character-level language models on names.txt

著者・提供機関: Andrej Karpathy | オリジナル出所URL ↗

該当セクション・タイムスタンプ: 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)
Yoshua Bengio et al.: A Neural Probabilistic Language Model (JMLR 2003) ↗ compared_selected_co_primary [JMLR open access (author-retained copyright)]

The original architecture paper; selected jointly as the theoretical citation while Makemore supplies the stepwise implementation walkthrough.

Stanford CS336: Language Modeling from Scratch ↗ compared_deferred [No license declared (the repository has no LICENSE file, so all rights are reserved by default)]

Strong PyTorch rigor but assumes fluent tensor programming; deferred to the Days 43-60 pretraining blocks rather than the first embedding contact.

3Blue1Brown: Neural Networks series ↗ compared_alternative [3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions]

Strong visual intuition for network mechanics but covers image classification rather than embedding tables and next-token language modeling; retained as optional supplementary viewing.

linking JMLR open access (author-retained copyright)

A Neural Probabilistic Language Model

著者・提供機関: Yoshua Bengio, Rejean Ducharme, Pascal Vincent, Christian Jauvin | オリジナル出所URL ↗

該当セクション・タイムスタンプ: 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)
Andrej Karpathy: Let's build makemore (MLP) ↗ compared_selected_co_primary [MIT (repository code) / Standard YouTube License (video)]

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.

02 120 分

分散表現:学習される点としての行

独立習得確認

前提条件

前の活動を完了すること。詰まった場合は記載の回復リンクを使う。

学習目標

埋め込み行を学習された特徴空間の座標として解釈し、内積とコサイン類似度を計算し、未訓練の行が意味を持たない理由を説明する。

手順

必須作業:C の各行を R^2 の点として扱う。2 つの行ペアについて dot(u,v) = sum_i u_i v_i と cos(u,v) = dot(u,v)/(||u||*||v||) を計算する。次に「類似した」文字が近くに配置されるためには訓練が何を変えなければならないかを自分の言葉で説明する。テーブルはランダム初期化なので、初期の距離に意味はない。任意作業:4 つの点を紙にプロットし、最も近いペアに印をつける。

演習と予測記録

行 '.'=[0.1,0.3]、'a'=[0.2,-0.1]、'b'=[-0.4,0.5]、'c'=[0.0,0.2] を使い:
1. dot('.', 'c') と cos('.', 'c') を計算する。
2. cos('a', 'b') を計算する。
3. このテーブルで最も近いペアはどれか。また訓練前にこの類似度を信頼できるか、理由を述べる。

独立習得基準

両方のコサイン類似度を ±0.01 以内で独立に計算し、ランダム埋め込みは訓練されるまで意味を持たないと正しく述べられる。

公式ソースリソースと権利証跡

linking JMLR open access (author-retained copyright)

A Neural Probabilistic Language Model

著者・提供機関: Yoshua Bengio, Rejean Ducharme, Pascal Vincent, Christian Jauvin | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Section 1 (distributed representation fights the curse of dimensionality)

検証バージョンと日付: 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)
Andrej Karpathy: Let's build makemore (MLP) ↗ compared_selected_co_primary [MIT (repository code) / Standard YouTube License (video)]

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.

linking MIT License (repository) / Standard YouTube License (video, subtitle rights unknown) Video subtitles have unknown distribution rights and are not imported

makemore: Character-level language models on names.txt

著者・提供機関: Andrej Karpathy | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Embedding table inspection segment; 2-D embedding visualization of learned character rows

検証バージョンと日付: 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)
Yoshua Bengio et al.: A Neural Probabilistic Language Model (JMLR 2003) ↗ compared_selected_co_primary [JMLR open access (author-retained copyright)]

The original architecture paper; selected jointly as the theoretical citation while Makemore supplies the stepwise implementation walkthrough.

Stanford CS336: Language Modeling from Scratch ↗ compared_deferred [No license declared (the repository has no LICENSE file, so all rights are reserved by default)]

Strong PyTorch rigor but assumes fluent tensor programming; deferred to the Days 43-60 pretraining blocks rather than the first embedding contact.

3Blue1Brown: Neural Networks series ↗ compared_alternative [3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions]

Strong visual intuition for network mechanics but covers image classification rather than embedding tables and next-token language modeling; retained as optional supplementary viewing.

03 120 分

文脈連結とパラメータ台帳

Agent支援エンジニアリング確認

前提条件

前の活動を完了すること。詰まった場合は記載の回復リンクを使う。

学習目標

文脈順に位置ごとの埋め込み行を連結してモデル入力を構成し、その次元を予測し、極小モデルと名前スケール構成の完全なパラメータ台帳を維持する。

手順

必須作業:block_size = 2 で文脈 ('a','b') = インデックス [1,2] の場合、ネットワーク入力は x = concat(C[1], C[2]) = [0.2, -0.1, -0.4, 0.5] で次元は block_size * d = 4。文脈 ('b','.') に対して同じベクトルを構築する。次に極小モデル(隠れ層サイズ 3)と名前スケール構成 V=27、d=10、block=3、hidden=100 のパラメータ台帳を書く。任意作業:連結の位置順序を入れ替えてはいけない理由を説明する。

演習と予測記録

1. 文脈 ('b','.') の x を書く。
2. 極小台帳:C (4x2)、W1 (4x3)、b1 (3)、W2 (3x4)、b2 (4) の合計パラメータ数は?
3. 名前台帳:C (27x10)、W1 (30x100)、b1 (100)、W2 (100x27)、b2 (27) の合計パラメータ数は?

独立習得基準

位置順序の正しい連結ベクトルと、暗記ではなく導出した両方の台帳(39 と 6097)を示せる。

公式ソースリソースと権利証跡

linking MIT License (repository) / Standard YouTube License (video, subtitle rights unknown) Video subtitles have unknown distribution rights and are not imported

makemore: Character-level language models on names.txt

著者・提供機関: Andrej Karpathy | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Segment building X from context indices and flattening C[X] into the input layer

検証バージョンと日付: 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)
Yoshua Bengio et al.: A Neural Probabilistic Language Model (JMLR 2003) ↗ compared_selected_co_primary [JMLR open access (author-retained copyright)]

The original architecture paper; selected jointly as the theoretical citation while Makemore supplies the stepwise implementation walkthrough.

Stanford CS336: Language Modeling from Scratch ↗ compared_deferred [No license declared (the repository has no LICENSE file, so all rights are reserved by default)]

Strong PyTorch rigor but assumes fluent tensor programming; deferred to the Days 43-60 pretraining blocks rather than the first embedding contact.

3Blue1Brown: Neural Networks series ↗ compared_alternative [3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions]

Strong visual intuition for network mechanics but covers image classification rather than embedding tables and next-token language modeling; retained as optional supplementary viewing.

linking JMLR open access (author-retained copyright)

A Neural Probabilistic Language Model

著者・提供機関: Yoshua Bengio, Rejean Ducharme, Pascal Vincent, Christian Jauvin | オリジナル出所URL ↗

該当セクション・タイムスタンプ: Section 2 (concatenated feature vectors x = (C(w_{t-n+1}), ..., C(w_{t-1})))

検証バージョンと日付: 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)
Andrej Karpathy: Let's build makemore (MLP) ↗ compared_selected_co_primary [MIT (repository code) / Standard YouTube License (video)]

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.

04 120 分

独立習得確認:ルックアップ、形状、パラメータ数

独立習得確認

前提条件

活動 40-01 から 40-03 を完了すること。

学習目標

申告した AI 不使用条件の下で、埋め込みルックアップ、分散幾何、文脈連結、パラメータ会計の自力習得を検証する。

手順

必須作業:参考解答や知識チェックを開く前に、教科書を閉じて導出をドラフト作業領域に記録する。導出そのものに AI アシスタントや計算機を使わない(計算の事後検算は可)。任意作業:隠れ層サイズ 200 で台帳をやり直して比較する。

演習と予測記録

新しい課題は V=8 シンボル、d=4、block_size=3、hidden=64 を使う。
1. C の形状とパラメータ数。
2. 連結入力 x の次元。
3. C、W1、b1、W2、b2 の合計パラメータ数。
4. 一文で:訓練がなぜ埋め込み行を動かすのか?

客観的理解度チェック:埋め込みとルックアップテーブル

以下の設問に解答して理解度を確認してください。提出前に利用した補助条件を誠実に申告してください。

申告補助条件

注記: AI不使用は誠実な申告条件であり、監視や強制検知ではありません。

1.

V=27 シンボルの語彙を d=10 次元に埋め込むとき、埋め込みテーブル C が持つ学習可能パラメータ数は?

2.

one-hot ベクトル e_i と埋め込み行列 C の積が生み出すものは:

3.

block_size = 3、埋め込み次元 d = 10 のとき、連結文脈ベクトル x の次元は?

解答根拠と履歴

    独立習得基準

    4 つの答えすべてを独立に導出:32 パラメータ、次元 12、合計 1384、勾配による行移動の正しい一文説明。

    公式ソースリソースと権利証跡

    linking MIT License (repository) / Standard YouTube License (video, subtitle rights unknown) Video subtitles have unknown distribution rights and are not imported

    makemore: Character-level language models on names.txt

    著者・提供機関: Andrej Karpathy | オリジナル出所URL ↗

    該当セクション・タイムスタンプ: Embedding table construction and parameter summary segments

    検証バージョンと日付: 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)
    Yoshua Bengio et al.: A Neural Probabilistic Language Model (JMLR 2003) ↗ compared_selected_co_primary [JMLR open access (author-retained copyright)]

    The original architecture paper; selected jointly as the theoretical citation while Makemore supplies the stepwise implementation walkthrough.

    Stanford CS336: Language Modeling from Scratch ↗ compared_deferred [No license declared (the repository has no LICENSE file, so all rights are reserved by default)]

    Strong PyTorch rigor but assumes fluent tensor programming; deferred to the Days 43-60 pretraining blocks rather than the first embedding contact.

    3Blue1Brown: Neural Networks series ↗ compared_alternative [3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions]

    Strong visual intuition for network mechanics but covers image classification rather than embedding tables and next-token language modeling; retained as optional supplementary viewing.

    linking JMLR open access (author-retained copyright)

    A Neural Probabilistic Language Model

    著者・提供機関: Yoshua Bengio, Rejean Ducharme, Pascal Vincent, Christian Jauvin | オリジナル出所URL ↗

    該当セクション・タイムスタンプ: Sections 1-2 (model overview and notation)

    検証バージョンと日付: 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)
    Andrej Karpathy: Let's build makemore (MLP) ↗ compared_selected_co_primary [MIT (repository code) / Standard YouTube License (video)]

    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.