Repository Public MIT Research preview
1% CE01-F03 — Requêtes, clés, valeurs et masque causal : le mécanisme, puis une vraie carte d'attention.2% Question : comment la position i décide-t-elle où regarder, et que lui interdit le masque causal ?3% DONNÉES : CE01-F03-donnees.tex (carte réelle : couche 1, tête 1 du modèle jouet, six jetons).4% Idée : chaque ligne de la carte est une distribution (somme 1) sur les positions passées ; le triangle supérieur5% est interdit. MODÈLE JOUET : poids aléatoires, la carte montre la FORME du calcul, pas un sens linguistique.6\input{CE01-F03-donnees.tex}%7\begin{tikzpicture}[x=1mm, y=1mm]8 % ---- gauche : le mécanisme pour une position i ----9 \node[ce tenseur=atlasFlow, minimum width=15mm] (xi) at (8, 40) {état $x_i$};10 \node[ce tenseur, minimum width=15mm] (xj) at (8, 16) {états $x_j$\\$j \leq i$};11 \node[atlas block flow, minimum width=10mm] (wq) at (27, 40) {$W_Q$};12 \node[atlas block, minimum width=10mm] (wk) at (27, 22) {$W_K$};13 \node[atlas block, minimum width=10mm] (wv) at (27, 10) {$W_V$};14 \draw[atlas arrow] (xi) -- (wq);15 \draw[atlas arrow muted] (xj.east) -- ++(3.2,0) |- (wk.west);16 \draw[atlas arrow muted] (xj.east) -- ++(3.2,0) |- (wv.west);17 \node[ce operation, minimum size=9.5mm] (dot) at (46, 31) {$q \cdot k$};18 \draw[atlas arrow] (wq.east) -| node[atlas note, above, pos=.25] {requête $q_i$} (dot.north);19 \draw[atlas arrow muted] (wk.east) -| node[atlas note, below, pos=.25] {clés $k_j$} (dot.south);20 \node[atlas block uncertain, minimum width=15mm] (sm) at (66, 31) {softmax\\sur $j \leq i$};21 \draw[atlas arrow] (dot) -- node[ce forme, above=.5mm] {$/\sqrt{d_h}$} (sm);22 \node[ce operation, minimum size=9.5mm] (mix) at (66, 10) {$\sum$};23 \draw[atlas arrow] (sm) -- node[atlas note, right] {poids $a_{ij}$} (mix);24 \draw[atlas arrow muted] (wv) -- node[atlas note, above, pos=.5] {valeurs $v_j$} (mix);25 \node[atlas note, anchor=north, align=center] at (66, 4.6) {sortie : $\sum_{j \leq i} a_{ij}\, v_j$};26 % ---- droite : la carte réelle ----27 \begin{scope}[shift={(96, 6.5)}]28 \def\c{6.1}29 \foreach \i/\j/\p/\t in \CEFtroisCellules {30 \pgfmathtruncatemacro{\q}{min(58, 10 + 0.5*\p)}31 \node[ce cellule=\c mm, fill=atlasFlow!\q!atlasPanel, text=atlasFg] at ({(\j+.5)*\c}, {(5.5-\i)*\c}) {\t};32 }33 \foreach \i in {0,...,4}{34 \pgfmathtruncatemacro{\deb}{\i+1}35 \foreach \j in {\deb,...,5}{36 \node[ce cellule=\c mm, fill=atlasBg, draw=atlasRule, text=atlasHazard, font=\AtlasSizeTiny\bfseries] at ({(\j+.5)*\c}, {(5.5-\i)*\c}) {×};37 }38 }39 \foreach \k in {0,...,5}{40 \pgfmathtruncatemacro{\n}{\k+1}41 \node[atlas note, anchor=east] at (-.6, {(5.5-\k)*\c}) {$i = \n$};42 \node[atlas note, anchor=south] at ({(\k+.5)*\c}, 6*\c+.3) {\n};43 }44 \node[atlas note, anchor=south] at (3*\c, 6*\c+4.2) {position consultée $j$};45 \node[atlas note, anchor=north west, align=left] at (-9, -1.2) {\textcolor{atlasHazard}{\textbf{×}} = masqué (le futur)\enspace·\enspace chaque ligne somme à 1};46 \end{scope}47 \node[ce nature, anchor=north west] at (0, 52) {modèle jouet};48\end{tikzpicture}49