SPB Git

Repository Public MIT Research preview

CE01-F02-chaine-inference.tex 2.9 KB 44 lines latex

1% CE01-F02 — Chaîne complète d'inférence autorégressive, avec la forme de chaque tenseur.2% Question : par quelles étapes un texte devient-il le jeton suivant, et où le cache KV intervient-il ?3% Idée : une seule passe produit UN jeton ; il est ajouté à la séquence et la passe recommence. Les formes4% (T, d, V) disent où est le coût. Recouvrements : 1 = entrée, 2 = pile de couches et cache, 3 = sortie, 4 = boucle.5\begin{tikzpicture}[x=1mm, y=1mm]6  % ---- étape 1 : du texte aux vecteurs ----7  \node[atlas block, minimum width=19mm, minimum height=11mm] (dec) at (10, 35.5) {découpeur\\en jetons};8  \node[atlas block, minimum width=21mm, minimum height=11mm] (plo) at (38.5, 35.5) {plongements\\+ positions};9  \node[atlas note, anchor=south] (txt) at (10, 47) {texte d'entrée};10  \draw[atlas arrow] (txt.south) -- (dec.north);11  \draw[atlas arrow] (dec) -- node[ce forme, above=.6mm] {T} (plo);12  % ---- étape 2 : la pile de couches et le cache ----13  \CEEtape{2}{14    \node[atlas region, minimum width=46mm, minimum height=20mm, anchor=west, inner sep=0pt] (pile) at (57, 35.5) {};15    \node[atlas tag=atlasFlow, anchor=west] at ([xshift=3mm]pile.north west) {$\times\,L$ couches};16    \node[atlas block strong, minimum width=19.5mm, minimum height=11mm] (att) at (70, 35.5) {attention\\causale};17    \node[atlas block, minimum width=14mm, minimum height=11mm] (mlp) at (93.5, 35.5) {MLP};18    \draw[atlas arrow] (plo) -- node[ce forme, above=.6mm, pos=.36] {T×d} (att);19    \draw[atlas arrow] (att) -- (mlp);20    \node[atlas store, minimum width=17mm] (kv) at (70, 11.5) {cache KV};21    \draw[atlas arrow valid] ([xshift=-2.4mm]att.south) -- ([xshift=-2.4mm]kv.north);22    \draw[atlas arrow valid] ([xshift=2.4mm]kv.north) -- ([xshift=2.4mm]att.south);23    \node[atlas note, anchor=east] at (66.4, 20.8) {écrit K, V};24    \node[atlas note, anchor=west] at (73.6, 20.8) {relit le passé};25  }26  % ---- étape 3 : des états au jeton ----27  \CEEtape{3}{28    \node[atlas block, minimum width=16mm, minimum height=11mm] (log) at (115, 35.5) {projection\\de sortie};29    \node[atlas block uncertain, minimum width=15mm, minimum height=11mm] (ech) at (134.5, 35.5) {softmax\\+ tirage};30    \draw[atlas arrow] (mlp) -- node[ce forme, above=.6mm, pos=.66] {d} (log);31    \draw[atlas arrow] (log) -- node[ce forme, above=.6mm] {V} (ech);32    \node[atlas note, anchor=north, align=center] at (115, 29) {dernière\\position seule};33    \node[atlas token valid] (jet) at (134.5, 15) {jeton};34    \draw[atlas arrow valid] (ech) -- (jet);35  }36  % ---- étape 4 : la boucle ----37  \CEEtape{4}{38    \draw[atlas arrow] (jet.south) -- (134.5, 1.8) -- node[atlas note, above, pos=.44] {ajouté à la séquence : T devient T + 1, et la passe recommence} (38.5, 1.8) -- (plo.south);39    \node[atlas gate] (stop) at (115, 15) {fin ?};40    \draw[atlas arrow muted] (jet) -- (stop);41    \node[atlas note, anchor=east] at (stop.west) {si oui : arrêt};42  }43\end{tikzpicture}44
Files main
Menu

Theme