Files
Superfig/examples/branch-architecture.tex
T
dela db5598fbf7 feat: add superfig paper-figure toolkit
Standalone LaTeX/TikZ skill for non-tensor paper figures: node/edge
macros, lint-on-warning build, golden examples, and negative fixtures.
2026-08-17 09:40:12 +08:00

49 lines
1.4 KiB
TeX

% superfig golden example 2 -- a small branchy architecture, not a tensor
% shape diagram. Main path uses the cursor; the residual is a skip edge;
% the group is captioned on the shared lane, not as an overlay.
% ../scripts/build.sh branch-architecture.tex
\documentclass[border=10pt]{standalone}
\usepackage[cjk]{superfig}
\sfsetrole{enc}{sfTeal}
\sfsetrole{attn}{sfOrange}
\sfsetrole{ffn}{sfViolet}
\sfsetrole{out}{sfCoral}
\begin{document}
\begin{tikzpicture}
\sfstage{S}{双分支结构:主路 + 残差}
\sfvgap{7mm}
\sfrow{R1}{12mm}
\sfnode[role=enc]{in}{输入}{16mm}{10mm}
\sfconn{e1}{}
\sfnode[role=attn]{attn}{注意力}{18mm}{10mm}
\sfconn{e2}{特征}
\sfnode[role=ffn]{ffn}{前馈}{18mm}{10mm}
\sfgap{\sflinklen}
\sfnode[role=enc]{add}{融合}{14mm}{10mm}
\sfconn{e4}{}
\sfnode[role=out]{out}{输出}{14mm}{10mm}
\sfrowend
% No overlay caption: it would sit on the residual. Caption the group below.
\sfgroup[role=attn]{block}{(attn)(ffn)}{}
\sfarrow{block.east}{add.west}
\sfarrowlabel[bend left=18]{in.north}{add.north}{残差}
\sflane{R1}
\sfcaption{in}{输入}{源数据}
\sfcaption{block}{主路模块}{注意力 + 前馈}
\sfcaption{add}{融合}{残差相加}
\sfcaption{out}{输出}{目标表示}
\sfbbox{all}
\sfmeaningbox{mb}{108mm}{all}
{主路逐层处理,残差边跳过主路}
{输入、主路模块、融合节点、输出}
{残差把输入直接送入融合,减轻深层优化负担}
\end{tikzpicture}
\end{document}