Abstract
K-fold cross validation (CV) is a popular method for estimating the true performance of machine learning models, allowing model selection and parameter tuning. However, the very process of CV requires random partitioning of the data and so our performance estimates are in fact stochastic, with variability that can be substantial for natural language processing tasks. We demonstrate that these unstable estimates cannot be relied upon for effective parameter tuning. The resulting tuned parameters are highly sensitive to how our data is partitioned, meaning that we often select sub-optimal parameter choices and have serious reproducibility issues. Instead, we propose to use the less variable J-K-fold CV, in which J independent K-fold cross validations are used to assess performance. Our main contributions are extending J-K-fold CV from performance estimation to parameter tuning and investigating how to choose J and K. We argue that variability is more important than bias for effective tuning and so advocate lower choices of K than are typically seen in the NLP literature, instead use the saved computation to increase J. To demonstrate the generality of our recommendations we investigate a wide range of case-studies: sentiment classification (both general and target-specific), part-of-speech tagging and document classification.
Introduction: The "Luck of the Draw" in NLP
In the world of Natural Language Processing (NLP), researchers often celebrate performance gains of less than 1%. But how much of that gain is due to a genuinely better model, and how much is just the "luck of the draw" in how the data was split? Standard tuning practices are surprisingly unstable, leading to sub-optimal models and a reproducibility crisis. Most machine learning practitioners rely on $K$-fold cross-validation (CV) to estimate how well a model will generalize, assuming that rotating through $K$ pieces of data provides a solid ground truth for hyperparameters.
The Problem: Internal Variability
There is a hidden danger in standard CV: internal variability. Because CV requires a random shuffle before partitioning, the resulting performance estimate is a random variable. In NLP, where data has complex structural properties like syntax and discourse, a "bad" split can wildly swing the results.
As shown in Figure 1, the range of possible accuracy estimates is wide. If the variance of your CV estimate is larger than the performance differences you are trying to measure, your "optimal" parameters are essentially chosen by noise. This leads to models that don't perform as well as expected on new data and results that other researchers cannot replicate.
Proposed Solution: $J$-$K$-fold Cross Validation
To address this, we propose a shift to $J$-$K$-fold Cross Validation. Instead of one round of $K$-fold CV, you perform $J$ independent rounds (each with a different random shuffle) and average the results.
The Bias-Variance Trade-off in Tuning
We challenge the "rule of thumb" that $K=10$ is always best. For performance estimation, bias (how close we are to the truth) is critical. However, for tuning, variance is more damaging than bias. As long as the bias is relatively constant across different parameter settings, it won't change which parameter is identified as "best." Variance, however, creates random peaks in the parameter grid that lead the tuner astray.
Since $J$-$K$-fold CV requires training $J \times K$ models, it can be expensive. We suggest that if you have a fixed budget (e.g., you can afford to train 20 models), you are better off running a $4 \times 5$-fold CV (low $K$, high $J$) than a single $20$-fold CV. The lower $K$ might have slightly more bias, but the higher $J$ drastically reduces the variance that ruins parameter selection.
Key Results and Stability
Our approach was validated across diverse NLP tasks, including IMDB sentiment classification, the Brown Corpus for POS tagging, and Reuters document classification.
As illustrated in Figure 5, the stability of parameter selection improves dramatically with $J$-$K$-fold CV. In the IMDB task, the standard deviation of the chosen max_features parameter dropped by nearly 50% (from 0.0427 to 0.0221) when moving from 5-fold to 10-5-fold CV. For complex models like LSTMs, where a single 10-fold CV can produce almost uniform (random) results across a parameter grid, $J$-$K$-fold CV consistently identifies the same optimal configurations across different random partitions.
Conclusion
Stability matters. By prioritizing variance reduction over bias minimization during the tuning phase, researchers can produce more robust models and more reproducible results. While $J$-$K$-fold CV increases computational requirements, trading a high $K$ for a higher $J$ provides a more reliable path to finding truly optimal hyperparameters in the noisy landscape of NLP data.
Summary updated