Add IFD analysis: density/length-bias figures and appendix

This commit is contained in:
ViperEkura 2026-07-04 23:33:12 +08:00
parent 9534316bac
commit bc8d4066c1
3 changed files with 44 additions and 1 deletions

BIN
data/ifd_density_dist.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
data/length_vs_loss_ifd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 KiB

View File

@ -157,11 +157,20 @@ Figure~\ref{fig:ifd} shows the distribution.
\begin{figure}[H] \begin{figure}[H]
\centering \centering
\includegraphics[width=0.80\linewidth]{data/ifd_compare_clean.png} \includegraphics[width=0.80\linewidth]{data/ifd_compare_clean.png}
\caption{IFD comparison: base model vs.\ trained checkpoint. The \caption{IFD scatter: base model vs.\ trained checkpoint. The
diagonal line marks $\mathrm{IFD}_{\text{base}} = \mathrm{IFD}_{\text{ckpt}}$.} diagonal line marks $\mathrm{IFD}_{\text{base}} = \mathrm{IFD}_{\text{ckpt}}$.}
\label{fig:ifd} \label{fig:ifd}
\end{figure} \end{figure}
\begin{figure}[H]
\centering
\includegraphics[width=0.80\linewidth]{data/ifd_density_dist.png}
\caption{IFD density distribution: base model and SFT checkpoint.}
\label{fig:ifd_density}
\end{figure}
Figure~\ref{fig:ifd_density} shows the corresponding density
estimates, confirming the systematic leftward shift after SFT.
The pretrained base model (15B tokens) has mean IFD $0.9625$; The pretrained base model (15B tokens) has mean IFD $0.9625$;
$29.8\%$ of samples exceed $1.0$. After 1K SFT steps, mean IFD drops $29.8\%$ of samples exceed $1.0$. After 1K SFT steps, mean IFD drops
to $0.7539$, with only $0.4\%$ of samples above $1.0$. The average to $0.7539$, with only $0.4\%$ of samples above $1.0$. The average
@ -177,6 +186,7 @@ modeling. Detailed analysis is provided in Appendix~\ref{app:ifd}.
The model is a 24-layer decoder-only Transformer with Grouped Query Attention The model is a 24-layer decoder-only Transformer with Grouped Query Attention
(GQA)~\cite{ainslie2023gqa} and SwiGLU feed-forward blocks~\cite{shazeer2020glu}, (GQA)~\cite{ainslie2023gqa} and SwiGLU feed-forward blocks~\cite{shazeer2020glu},
with Rotary Position Embedding (RoPE)~\cite{su2024roformer}. with Rotary Position Embedding (RoPE)~\cite{su2024roformer}.
Table~\ref{tab:model_config} summarizes the configuration.
\begin{table}[H] \begin{table}[H]
\centering \centering
@ -466,6 +476,39 @@ a residual signal persists: instructions that require complex reasoning
tend to remain non-trivially harder than simple rewrite or extraction tend to remain non-trivially harder than simple rewrite or extraction
tasks even after SFT. tasks even after SFT.
\subsection{A Note on IFD Bias from Response Length}
\label{sec:ifd_bias}
Both $L_{\text{cond}}$ and $L_{\text{uncond}}$ are reported as per-token
average losses. For a response of length $T$, the unconditional loss is
$L_{\text{uncond}} = \frac{1}{T} \sum_{t=1}^T \log P(x_t)$.
Since the variance of this average scales as $1/T$, shorter responses
exhibit much larger fluctuations in $L_{\text{uncond}}$---a mathematical
necessity, not a signal of instruction difficulty. Consequently, IFD,
being a ratio of two such averages, inherits a systematic length bias:
short responses inflate IFD variance.
Figure~\ref{fig:length_bias} illustrates this artifact. Responses
with $<20$ tokens (e.g., ``Paris,'' ``42'') show wildly scattered
$L_{\text{uncond}}$ values, producing spurious high or low IFD scores.
Longer responses ($>50$ tokens) converge toward the model's intrinsic
mean loss, yielding stable IFD estimates.
\begin{figure}[H]
\centering
\includegraphics[width=0.75\linewidth]{data/length_vs_loss_ifd.png}
\caption{Response length vs.\ unconditional loss and IFD. Short
responses produce high-variance $L_{\text{uncond}}$ estimates,
inflating IFD noise.}
\label{fig:length_bias}
\end{figure}
This bias is well-known in the IFD literature but often omitted.
For practitioners, a simple mitigation is to filter samples with
$<20$ response tokens before computing IFD. In our Alpaca-style
dataset, this removes approximately $5$--$8\%$ of samples and
substantially reduces false positives in the high-IFD tail.
% ====================================================================== % ======================================================================
\begin{thebibliography}{99} \begin{thebibliography}{99}