samuelhe52/Notes · 12 Oct 2025 – 28 Sep 2026

反复横跳, Side-step

A year of notes that kept switching between classic computer science and AI, read back from the git history. It ends with ten ideas that turn up in both.

……就是现在对自己未来的方向还是稍微有点迷茫,时常在传统计科和AI之间反复横跳……

“…still a little lost about which way to go, forever side-stepping back and forth between traditional CS and AI…”

Quotes/Personal.md · committed 13 Nov 2025, 09:19, in the same commit that created Machine Learning/

反复横跳 is also a PE test. You stand astride a center line and step sideways over the lines on either side, scoring a point for each line. This page runs the same test on the repository. Part one puts every commit on a two-lane court, CS on the left and AI on the right, and counts how often the notes crossed the middle. Part two sets notes from the two lanes side by side and finds the same ideas in both.

Part one · the yearPart two · ten bridgesCoda

Part one · The year

59 crossings in 351 days

Each dot is a commit. It sits between the lanes according to the share of its changed words that went to AI notes rather than CS notes, and its size is the number of words changed. Ticks on the outer side of each lane are new notes. A crossing is two consecutive commits on opposite sides of the center line.

Hover or tap a dot for the commit. Focus the chart and use the arrow keys to step through it.

Month by month, as a table
MonthCommitsNew CS notesNew AI notesCS words changedAI words changedAI shareCrossingsLead at month end

Final score

59

center-line crossings in 351 days, one point per crossing, the way the PE test is scored.

The ledger, by words in each lane today

CS107,699157 notes
AI118,487152 notes

The strip shows which lane held more words at each point of the year. The lead has changed hands 9 times since 28 Jan 2026, when the AI lane first pulled ahead. The latest change came on 27 Sep 2026, when a single commit moved the count from 107,699 : 106,113 to 107,699 : 118,487.

Counted with wc -w, the AI lead looks 2.1 times as large, 121,993 to 99,057, because Chinese sentences have no spaces between words. Here every Chinese character counts as a word, the way word processors count mixed text.

After midnight
72 of 159 commits (45%) were made between midnight and 3 a.m., local time.
Written mostly in Chinese
28 notes.
Longest note
Discrete Math/final.md
Most revised
Torch/TensorOps.md
Formulas and code
5,527 LaTeX formulas and 1,056 code blocks.

Part two · The bridges

Ten ideas that live in both lanes

Read the two lanes against each other and the same ideas keep turning up on both sides. The ten pairs below are numbered by the date the second note of each pair was written. In six of them the CS note came first. In the other four the AI version came first, and its classical form showed up months later on the CS side. Four of the ten were completed in September 2026.

Each strut joins the dates of a pair's two notes, CS on top and AI below. Select one to jump to it.

01

A dictionary that blurs

completed 11 Feb 2026

CSData Structures/Hash Maps.md12 Oct 2025

Definition: Hash maps (or hash tables) store key-value pairs using a hash function to map keys to indices in an array for efficient retrieval.

AId2l/Attention Basics.md11 Feb 2026

Denote by $\mathcal{D}$ a set of key-value pairs … Given a query vector $\mathbf{q}$, the attention over $\mathcal{D}$ is defined as:

$$\text{Attention}(\mathbf{q}, \mathcal{D}) = \sum_{i=1}^{n} a(\mathbf{q}, \mathbf{k}_i) \mathbf{v}_i$$

Attention takes its vocabulary from the dictionary: query, key, value. It drops the dictionary's one strict rule. A hash map returns the value whose key equals the query, or nothing. Attention returns every value, weighted by a softmax over how well each key matches. Lower the softmax temperature and the weights pile onto the best match, which turns attention back into a lookup, for the nearest key instead of an identical one.

Try it · drag the query

    Drag q anywhere. As the temperature drops, attention gives nearly all its weight to the nearest key. The hash map only answers when q is released on a key exactly; release it close to one and it snaps there, the way you'd type the exact key.

    02

    Everyone wants the same bucket

    completed 7 May 2026

    CSData Structures/Hash Collision Handling.md26 Nov 2025

    When two different keys produce the same hash value, a collision occurs. … This is unavoidable because hash outputs are finite.

    AIRecSys/TIGER.md7 May 2026

    The paper uses the hashing trick to generate the user token … different users can collide and share the same hashed user token

    and in RecSys/LC-Rec.md, 26 May 2026:

    standard nearest-neighbor assignment can place multiple items in the same leaf node (index conflict).

    A semantic ID is a hash that is supposed to collide, since similar items should share a prefix. When two items end up with the same full code, the RecSys notes reach for the fixes from the hash-table note. TIGER appends one more digit, which is separate chaining with the position in the chain written into the ID. LC-Rec reassigns the last level under a uniform constraint, which is what a better-spread hash function buys. The GRID note compares the two and finds TIGER's digit slightly ahead.

    The MoE note meets the same problem under another name. When too many tokens pick one expert, “that expert becomes a queue while other experts sit idle”, so each expert gets a fixed capacity, like a bucket with a size limit.

    Three ways out of one collision

    Separate chaining (hash table)

    bucket 3·1·4 → [A] → [B]
    bucket 3·2·7 → [C]
    bucket 3·1·5 → ∅

    A and B share a bucket. Lookup walks the chain and compares keys.

    TIGER: append a digit

    A → 3·1·4·0
    B → 3·1·4·1
    C → 3·2·7·0

    The extra token is B's position in the chain, written into the ID.

    LC-Rec: spread the last level

    A → 3·1·4
    B → 3·1·5
    C → 3·2·7

    Optimal transport pushes B into an empty last-level code: a better-spread hash.

    03

    Counting walks

    completed 18 May 2026

    CSDiscrete Math/7-Graph Theory.md18 May 2026 · 中文

    若 $A$ 为图 $G$ 的邻接矩阵,则 $A^k$ 的 $(i,j)$ 元素表示从结点 $v_i$ 到结点 $v_j$ 的长度为 $k$ 的通路的数量。

    If A is the adjacency matrix of G, the (i, j) entry of Ak is the number of walks of length k from vi to vj.

    and in Discrete Math/final.md: 注意不是布尔乘法,直接按普通矩阵乘。 (Not Boolean multiplication; use ordinary matrix multiplication.)

    AId2l/LightGCN.md23 Mar 2026

    such that the neighborhood aggregation can be vectorized as:

    $$\mathbf{E}^{(k+1)} = \mathbf{D}^{-\frac{1}{2}} \mathbf{A} \mathbf{D}^{-\frac{1}{2}} \mathbf{E}^{(k)}.$$

    Each layer can be viewed as a smoothing step, which smooths the embeddings by aggregating information from neighbors.

    LightGCN has no weight matrices inside its layers. Layer k is the normalized adjacency matrix raised to the k-th power, applied to the starting embeddings. If those embeddings were one-hot, the score between a user and an item would be exactly a weighted count of the walks between them. A walk of length 3, user → item → user → item, reads as “someone who liked what you liked also liked this”. That is collaborative filtering, derived from the exam fact.

    The RecSys note came first, two months before the graph-theory chapter. The final-exam note adds the warning that matters here: ordinary multiplication, not Boolean, because the counts are the signal.

    Try it · pick a user and a walk length

    Bars are one row of Ak: how many walks of length k lead from the user to each item. Highlighted edges lie on at least one of those walks. Hover an item to see them. The normalization is LightGCN's D−½AD−½, which discounts well-connected nodes.

    04

    Pruned prefixes

    completed 1 Jun 2026

    CSData Structures/Trie.md28 Nov 2025

    Prefix Search. Same as search, but don't require the end-of-word marker—just check if the path exists.

    AIRecSys/SID.md1 Jun 2026

    Notably, we usually use trie-based beam search to ensure that the generated token sequences correspond to valid item IDs, where branches are pruned if the last generated token does not lead to any valid item ID.

    Generating a semantic ID token by token is a walk down a trie of every valid ID. At each step, constrained beam search runs the prefix search from the data-structures note and keeps a candidate only if its path exists. The GRID note then reports the twist: constrained and unconstrained beam search score about the same, and skipping the trie is faster and cheaper.

    One step of trie-constrained beam search

    Beam width 2, second decoding step. The model's favourite continuation of 3 is 9, but no item's ID starts with 3·9, so the prefix search fails and the branch is pruned. The beam keeps 3·1 and 3·2.

    05

    A learned multiplexer

    completed 12 Jul 2026

    CSDigital Logic/digital_logic_key_takeaways.md29 Jun 2026

    A mux selects one data input according to address/select inputs.

    AIFoundation/MoE.md12 Jul 2026

    For a token, a router produces $E$ scores and selects its top $k$ experts. … Top-1 routing is the Switch Transformer simplification; top-2 routing is used by Mixtral.

    A top-1 mixture-of-experts layer is a multiplexer whose select lines are computed from the input and trained by gradient descent. The difference is where the work happens. A hardware mux has all of its inputs computed and wired in, and passes one of them through. An MoE layer runs only the expert it selects, which is the point of the design. Top-2 routing, as in Mixtral, has no mux equivalent: it blends two experts by their gate weights.

    Try it · route a token

    4-to-1 mux

    MoE layer, 4 experts

    06

    Greedy merges

    completed 14 Jul 2026

    CSDiscrete Math/8-Trees.md2 Jun 2026 · 中文

    Huffman 树:一种特殊的二元树,用于构造最优二元前缀码。构造方法:对于所有权值,不断重复:选取权值最小的两个结点,合并成一个新的结点,新结点的权值为两个结点权值之和。

    A Huffman tree builds an optimal binary prefix code. Repeat: take the two nodes with the smallest weights and merge them into a new node whose weight is their sum.

    AICMU Advanced NLP/Tokenizer.md14 Jul 2026

    Byte Pair Encoding (BPE) is a greedy algorithm that merges the most frequent pairs of characters or subwords iteratively. It balances vocabulary size and sequence length …

    Both are the same loop: count, merge one pair, repeat. They work from opposite ends of the frequency table. Huffman merges the two rarest symbols, so rare symbols sink deep into the tree and get long codes. BPE merges the most frequent adjacent pair, so common strings collapse into single tokens.

    Both are compression, too. BPE was published in 1994 as a data-compression algorithm and moved into machine translation about twenty years later. GPT-2 runs it on UTF-8 bytes, the encoding in your character-encoding note from December.

    Try it · one merge of each per step

    Huffman: merge the two rarest

    BPE: merge the most frequent pair

    07

    The order of addition

    completed 8 Sep 2026

    CSCPP/threading/MapAndReduce.md13 Nov 2025

    std::reduce combines all elements in a range into a single value using a binary operation. Unlike std::accumulate, std::reduce can execute in parallel but requires the operation to be associative and commutative.

    AILLM/training-inference-mismatch-rl.md8 Sep 2026

    The fundamental reason is the non-associative property of floating point addition. … performing inference on the same samples with different batch sizes can yield slightly different numerical outputs.

    std::reduce may regroup a sum because it assumes the operation is associative. Floating-point addition is not: every partial sum is rounded, to 24 significant bits in fp32 and 8 in bf16. An inference engine that splits a reduction differently at small batch sizes gets slightly different logits from the trainer, even with identical weights. PPO's ratio between the two should be exactly 1, and sometimes it isn't. The mismatch note calls the result “an incorrect form of importance sampling”.

    The std::reduce note and your first RL note were added in the same commit, on 13 Nov 2025. Ten months later they meet here, with the IEEE 754 layout from your computer-organization note two days after that.

    Try it · same numbers, different order

    Orderfp32 sumbits: sign · exponent · fractionoff by

    4,096 random products added three ways, rounding after every addition as fp32 hardware does. Bits are laid out as in the IEEE 754 note; highlighted bits differ from left-to-right. The last column is the error against the exact sum, in units of the last place.

    Same weights, two kernels

    logit rounds to a different bf16 valueidentical

    Running 64 tokens through both kernels…

    A toy 4-layer network with bf16 activations runs 64 tokens twice with the same weights: once with each dot product summed left to right, once split into 4 chunks, as a kernel picked for a different batch size would do. Rows are tokens, columns are logits. A row with many lit cells is a token where one rounding flip in an early layer spread into everything computed after it.

    08

    Bellman, twice

    completed 12 Sep 2026

    CSData Structures & Algorithms/Bellman & Floyd & Dijkstra.md12 Sep 2026

    The core idea is to relax all edges repeatedly, for a total of $n-1$ times.

    if (dist[u] != INF &&
        dist[u] + w < dist[v]) {
        // relaxation step
        dist[v] = dist[u] + w;
    }
    AIFoundation/RL Basics.md21 Aug 2026

    The Bellman equation gives:

    $$V^\pi(s) = \mathbb E_{a\sim\pi,\,s'\sim P(\cdot\mid s,a)}\left[r(s,a)+\gamma V^\pi(s')\right]$$

    This essentially says that the value of a state can be decomposed into the immediate reward plus the discounted value of the next state …

    Same Bellman. Richard Bellman's principle of optimality, that an optimal path is made of optimal sub-paths, drives both notes. Edge relaxation is a Bellman backup with costs instead of rewards, min instead of max, and no discount. Bellman–Ford sweeps every edge n − 1 times; value iteration sweeps every state until nothing changes.

    The negative-cycle check has a counterpart too. A cycle with negative total cost has no shortest path, and a loop with positive total reward has no finite value when γ = 1. Discounting with γ < 1 is how RL keeps those values finite.

    Try it · sweep toward the goal G

    A sweep updates every cell once from the previous sweep's numbers, as one pass of Bellman–Ford relaxes every edge. Distances start at ∞ and values at −∞, so both spread outward from G in the same wavefront. With γ = 1 the two views show the same numbers up to sign; lower γ and far-away values shrink toward −1/(1 − γ).

    09

    Forward, then backward

    completed 12 Sep 2026

    CSProblems/TopSort & Key Paths.md12 Sep 2026

    In topological order, for each vertex u, update its neighbors v as follows: ve[v] = max(ve[v], ve[u] + w(u, v)). … In reverse topological order, for each vertex u, update its neighbors v as follows: vl[u] = min(vl[u], vl[v] - w(u, v)).

    AId2l/Autograd.md4 Dec 2025

    The forward pass evaluates each node's value in topological order (from inputs to output) … Backward pass (accumulation): traverse the graph in reverse, applying local derivative rules and the chain rule to accumulate gradients from output back to each input.

    The critical-path method and backpropagation share a skeleton: one sweep over a DAG in topological order to compute values, then one sweep in reverse to send information back. Only the arithmetic changes. Earliest times use max and +, latest times use min and −, and backprop uses + and × on local derivatives.

    The match goes one step further. Lengthen an activity by a day and the project length L* grows by a day if the activity is on a critical path, and not at all otherwise. That is a derivative of 1 or 0, and the key activities are exactly the edges where it is 1.

    Try it · an activity-on-edge network

    Click a duration to change it. The gradient view answers one question per activity: if it took one more day, how much later would the project finish?

    10

    The same two lines

    completed 26 Sep 2026

    CSComputer Graphics/Geometric Transformations.md26 Sep 2026 · 中文

    旋转(glRotate)

    规定逆时针旋转为 $\theta > 0$。

    $x' = x \cos \theta - y \sin \theta$
    $y' = x \sin \theta + y \cos \theta$

    Rotation (glRotate). Counter-clockwise is θ > 0.

    AIFoundation/RoPE.md12 Apr 2026

    For a pair $(x_{2i}, x_{2i+1})$, the rotated pair is

    $$\begin{aligned} x'_{2i} &= x_{2i}\cos(p\theta_i) - x_{2i+1}\sin(p\theta_i), \\ x'_{2i+1} &= x_{2i}\sin(p\theta_i) + x_{2i+1}\cos(p\theta_i). \end{aligned}$$

    Your note of 26 September, written for a graphics class, holds the same two equations as the RoPE note from April. glRotate turns a vertex by θ. RoPE turns each pair of query and key coordinates by the token's position times a frequency θi.

    The property graphics relies on to chain transformations, that rotations compose, is what makes RoPE a relative encoding: $R_m^\top R_n = R_{n-m}$, so the attention score depends on $n - m$ alone. Your RoPE note describes the feature pairs as “people walking around circles at different speeds”. Here they are, each one moved with the two lines from the graphics note.

    Try it · move the query and the key

    query at position m key at position n outer ring θ = 1 rad per position, inner ring θ ≈ 0.02

    Every dot is placed with x′ = x cos θ − y sin θ, y′ = x sin θ + y cos θ. Query and key carry the same content here, so each pair contributes cos((n − m)θi). Press shift or play: every dot moves, the bars and the score do not. The frequencies use base 100 so the slow rings visibly turn; real models use 10,000.

    Coda

    取舍Trade-offs

    The advice you wrote down beside the 反复横跳 line was about choosing: 取舍是很重要的……要清楚自己真正热爱的事情是什么. Trade-offs matter; know what you really love. The next bullet was blunter: 兼顾xx与xx很多时候都是伪命题. Doing both is usually a false promise.

    This page can't make that choice, and doesn't try. It can report two things. Neither lane has stayed ahead for long: the lead between them has changed hands 9 times, most recently on 27 Sep 2026. And the ideas in them don't stay in their lanes: the same Bellman, the same two sweeps over a graph, the same rotation, written months apart and sometimes in different languages.

    Three weeks before that line, you saved a passage from a blog post about working with AI. One sentence in it describes the ten bridges better than this page does:

    复合型知识意味着你要能够跨越多个技术领域,理解它们之间的协同效应。

    Compound knowledge means being able to cross several technical fields and understand how they work together.

    Quotes/Personal.md · from onevcat, “Magpie 和「AI 贼船」” · saved 24 Oct 2025

    The same passage ends with the line you put in bold: AI 的强大在于它的“全知”,而人类的优势则在于“通识”。 AI's strength is knowing everything; a person's is seeing how it connects.