\begin{tikzpicture}

\tikzstyle{h2o} = [or, mark=diamond, mark size=1pt]
\tikzstyle{snap} = [gr, mark=x, mark size=1.3pt]
\tikzstyle{pyramid} = [bl, mark=+, mark size=1.3pt]
\tikzstyle{prob} = [red, mark=*, mark size=0.7pt]

\begin{groupplot}[group style={columns=4, rows=3, horizontal sep=1cm, vertical sep=1.2cm},
    width=3.9cm,
    height=3.4cm,
    every axis plot/.append style={thick},
    % Label
    xlabel shift=-0.12cm,         
    ylabel shift=-0.16cm,
    xlabel near ticks,
    ylabel near ticks,
    label style={font=\scriptsize},
    xlabel={KV cache ratio},
    % Grid
    grid=major,
    xmajorgrids=true,
    ymajorgrids=true,
    major grid style={dotted, black},
    % tick
    tick label style={font=\scriptsize},
    tick pos=left,
    x tick label style={/pgf/number format/.cd, fixed, fixed zerofill, precision=1},
    y tick label style={/pgf/number format/.cd, fixed, fixed zerofill, precision=0},
    ytick distance=20,
    xmax=1.0,
    xmin=0.1,
    xtick={0.2, 0.4, 0.6, 0.8, 1.0},
    extra x ticks={0.3, 0.5, 0.7, 0.9},   
    extra x tick labels={,,,},
    extra x tick style={
        grid=none,
        tick style={thin},
        major tick length=2.4pt,
    },    
    % title
    title style={
      at={(axis description cs:0.5,0.88)}, 
      anchor=south,
      font={\footnotesize}
    },    
]

%%%% Retrieval-Matching %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\nextgroupplot[title=NIAH, ylabel={Accuracy (\%)},  
legend columns=4, legend style={at={(0.84,1.26)}, anchor=south west, font=\footnotesize},
]
\addplot[prob] table[x=ratio, y=needle-prob, col sep=comma]{data/gemma-12b-full.csv};\addlegendentry{KVzip (ours)}
\addplot[h2o] table[x=ratio, y=needle-h2o, col sep=comma]{data/gemma-12b-full.csv};\addlegendentry{$\text{H}_2\text{O}$}
\addplot[snap] table[x=ratio, y=needle-snap, col sep=comma]{data/gemma-12b-full.csv};\addlegendentry{SnapKV}
\addplot[pyramid] table[x=ratio, y=needle-pyramid, col sep=comma]{data/gemma-12b-full.csv};\addlegendentry{PyramidKV}


\nextgroupplot[title=Retr.KV, ylabel={Accuracy (\%)}, ytick distance=5]
\addplot[h2o] table[x=ratio, y=kv-h2o, col sep=comma]{data/gemma-12b-full.csv};
\addplot[snap] table[x=ratio, y=kv-snap, col sep=comma]{data/gemma-12b-full.csv};
\addplot[pyramid] table[x=ratio, y=kv-pyramid, col sep=comma]{data/gemma-12b-full.csv};
\addplot[prob] table[x=ratio, y=kv-prob, col sep=comma]{data/gemma-12b-full.csv};


\nextgroupplot[title=Retr.Prefix-Suffix, ylabel={Accuracy (\%)}, ytick distance=10]
\addplot[h2o] table[x=ratio, y=prefix-h2o, col sep=comma]{data/gemma-12b-full.csv};
\addplot[snap] table[x=ratio, y=prefix-snap, col sep=comma]{data/gemma-12b-full.csv};
\addplot[pyramid] table[x=ratio, y=prefix-pyramid, col sep=comma]{data/gemma-12b-full.csv};
\addplot[prob] table[x=ratio, y=prefix-prob, col sep=comma]{data/gemma-12b-full.csv};


\nextgroupplot[title=Code.RepoQA, ylabel={Pass@1 (\%)}, ytick distance=10]
\addplot[h2o] table[x=ratio, y=repoqa-h2o, col sep=comma]{data/gemma-12b-full.csv};
\addplot[snap] table[x=ratio, y=repoqa-snap, col sep=comma]{data/gemma-12b-full.csv};
\addplot[pyramid] table[x=ratio, y=repoqa-pyramid, col sep=comma]{data/gemma-12b-full.csv};
\addplot[prob] table[x=ratio, y=repoqa-prob, col sep=comma]{data/gemma-12b-full.csv};


%%%%%% Context Understanding %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\nextgroupplot[title=SQuAD, ylabel={Accuracy (\%)}, ymax=100]
\addplot[h2o] table[x=ratio, y=squad-h2o, col sep=comma]{data/gemma-12b-full.csv};
\addplot[snap] table[x=ratio, y=squad-snap, col sep=comma]{data/gemma-12b-full.csv};
\addplot[pyramid] table[x=ratio, y=squad-pyramid, col sep=comma]{data/gemma-12b-full.csv};
\addplot[prob] table[x=ratio, y=squad-prob, col sep=comma]{data/gemma-12b-full.csv};

\nextgroupplot[title=GSM8K, ylabel={Accuracy (\%)}]
\addplot[h2o] table[x=ratio, y=gsm-h2o, col sep=comma]{data/gemma-12b-full.csv};
\addplot[snap] table[x=ratio, y=gsm-snap, col sep=comma]{data/gemma-12b-full.csv};
\addplot[pyramid] table[x=ratio, y=gsm-pyramid, col sep=comma]{data/gemma-12b-full.csv};
\addplot[prob] table[x=ratio, y=gsm-prob, col sep=comma]{data/gemma-12b-full.csv};



\nextgroupplot[title=En.QA, ylabel={Accuracy (\%)}, ytick distance=5]
\addplot[h2o] table[x=ratio, y=qa-h2o, col sep=comma]{data/gemma-12b-full.csv};
\addplot[snap] table[x=ratio, y=qa-snap, col sep=comma]{data/gemma-12b-full.csv};
\addplot[pyramid] table[x=ratio, y=qa-pyramid, col sep=comma]{data/gemma-12b-full.csv};
\addplot[prob] table[x=ratio, y=qa-prob, col sep=comma]{data/gemma-12b-full.csv};


\nextgroupplot[title=En.MultiChoice, ylabel={Accuracy (\%)}, ytick distance=5]
\addplot[h2o] table[x=ratio, y=choice-h2o, col sep=comma]{data/gemma-12b-full.csv};
\addplot[snap] table[x=ratio, y=choice-snap, col sep=comma]{data/gemma-12b-full.csv};
\addplot[pyramid] table[x=ratio, y=choice-pyramid, col sep=comma]{data/gemma-12b-full.csv};
\addplot[prob] table[x=ratio, y=choice-prob, col sep=comma]{data/gemma-12b-full.csv};

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\nextgroupplot[title=En.Summary, ylabel={ROUGE (\%)}, ytick distance=2]
\addplot[h2o] table[x=ratio, y=summary-h2o, col sep=comma]{data/gemma-12b-full.csv};
\addplot[snap] table[x=ratio, y=summary-snap, col sep=comma]{data/gemma-12b-full.csv};
\addplot[pyramid] table[x=ratio, y=summary-pyramid, col sep=comma]{data/gemma-12b-full.csv};
\addplot[prob] table[x=ratio, y=summary-prob, col sep=comma]{data/gemma-12b-full.csv};


\nextgroupplot[title=Retr.MultiHop, ylabel={Accuracy (\%)}, ytick distance=10]
\addplot[h2o] table[x=ratio, y=vt-h2o, col sep=comma]{data/gemma-12b-full.csv};
\addplot[snap] table[x=ratio, y=vt-snap, col sep=comma]{data/gemma-12b-full.csv};
\addplot[pyramid] table[x=ratio, y=vt-pyramid, col sep=comma]{data/gemma-12b-full.csv};
\addplot[prob] table[x=ratio, y=vt-prob, col sep=comma]{data/gemma-12b-full.csv};


\nextgroupplot[title=Math.Find, ylabel={Accuracy (\%)}, ytick distance=5]
\addplot[h2o] table[x=ratio, y=mf-h2o, col sep=comma]{data/gemma-12b-full.csv};
\addplot[snap] table[x=ratio, y=mf-snap, col sep=comma]{data/gemma-12b-full.csv};
\addplot[pyramid] table[x=ratio, y=mf-pyramid, col sep=comma]{data/gemma-12b-full.csv};
\addplot[prob] table[x=ratio, y=mf-prob, col sep=comma]{data/gemma-12b-full.csv};


\nextgroupplot[title=ICL.ManyShot, ylabel={Accuracy (\%)}, ytick distance=5, ymin=40]
\addplot[h2o] table[x=ratio, y=many-h2o, col sep=comma]{data/gemma-12b-full.csv};
\addplot[snap] table[x=ratio, y=many-snap, col sep=comma]{data/gemma-12b-full.csv};
\addplot[pyramid] table[x=ratio, y=many-pyramid, col sep=comma]{data/gemma-12b-full.csv};
\addplot[prob] table[x=ratio, y=many-prob, col sep=comma]{data/gemma-12b-full.csv};

\end{groupplot}

\node[rotate=90, align=center, anchor=center, font=\bfseries\footnotesize] at ($(group c1r1.west)+(-1.15cm,0)$) {Retrieval};
\node[rotate=90, align=center, anchor=center, font=\bfseries\footnotesize] at ($(group c1r2.west)+(-1.15cm,0)$) {Contextual QA};
\node[rotate=90, align=center, anchor=center, font=\bfseries\footnotesize] at ($(group c1r3.west)+(-1.15cm,0)$) {Redundancy};

\end{tikzpicture}
