Paper commentary
Random Selection Reveals Implicit Knowledge Consensus in Code Generation
Random sampling often beats complex selectors when picking code solutions to fine-tune
- Problem Code datasets often hold many accepted solutions per problem, and training on all of them costs substantial compute. How to choose among these equally correct solutions had gone unexplored.
- Method The authors compare six selectors against uniform random sampling, each keeping up to 11 solutions per problem. Complex selectors pick for diversity, while random sampling draws without any proxy objective.
- Results On Qwen2.5-7B, random sampling reached 6.32 test Pass@1, ahead of Kernel Herding at 6.23. Across four models, random sampling had the top test Pass@1 on half of them.
Several correct solutions per problem
Code datasets built from competitive programming sites often hold many accepted solutions for the same problem. Verifier-based pipelines, such as test-based filtering or best-of-N rejection sampling, create the same kind of pool before SFT reuses it. Training on every one of these solutions costs substantial compute, and the extra solutions may add little because many of them are redundant.
Coreset and active-learning work suggests that diversity-maximizing selection should generalize better. That line of work asks which questions to pick, though, and says little about how to choose among several correct answers to one question. The paper takes that gap as its starting point and asks whether complex selectors beat plain random draws in this setting.
How the pool is cleaned and the selectors are defined
The authors start from a LeetCode dataset with more than 500K Python solutions and remove near-duplicates with MinHash LSH. Each cluster of near-duplicates keeps only the solution with the highest average similarity to the others, and each problem's pool is then capped at 100 solutions. After this cleaning the dataset holds 154,714 solutions across 2,641 training problems, with 228 held-out problems for testing.
Every selector must return a subset of each problem's pool with at most min(k, m_i) solutions, where k is the per-problem budget. The budget is k = 11, which gives about 25,600 training samples per strategy. Uniform random sampling draws without replacement and optimizes no proxy objective, so it serves as the baseline. K-Center Greedy minimizes the largest distance from any pool member to its nearest chosen solution, and its default distance is token-level Levenshtein distance.
Facility Location maximizes \( \sum_{s \in S_i} \max_{s' \in S'_i} \mathrm{sim}(s,s') \) with cosine similarity on CodeBERT embeddings, a sum-based objective with a (1 − 1/e) guarantee. K-Means clusters the embeddings and takes the solution nearest each centroid, while AST Coverage greedily maximizes coverage of abstract syntax tree subtree fingerprints.
Kernel Herding matches the mean embedding of the chosen subset to that of the whole pool, and IFD Ranking keeps the solutions with the highest Instruction Following Difficulty, computed with DeepSeek-Coder-6.7B-Base.
Every model trains with AdamW at a learning rate of 1 × 10−5, a batch size of 128 and 3 epochs. Selection methods finish in 600 steps, while full-data training runs for 3,600 steps. Pass@1 on the training set comes from greedy decoding with one sample per problem, and test Pass@k uses n = 10 samples at temperature 1.0. Pass@k is an unbiased estimator of the chance that at least one of k samples is correct.
Main comparison across four base models
On Qwen2.5-7B, random sampling reached 6.32 test Pass@1, ahead of Kernel Herding at 6.23 and Full Dataset at 6.14. Across the four models, random sampling has the top test Pass@1 on half of them, and no single selector wins everywhere.
On Qwen2.5-Coder-7B, K-Means scored 6.14 test Pass@1 against 5.57 for random sampling. The authors read this as model dependence: complex selectors may fit the traits of one architecture.
K-Center Greedy, AST Coverage and IFD Ranking reach lower training Pass@1 than random sampling on all four models. For Qwen2.5-7B, K-Center Greedy reaches 49.41 training Pass@1, compared to 65.20 for random sampling.
Full Dataset trains for six times as many steps, and the authors call that comparison epoch-matched rather than compute-matched. Even so, random sampling beats full-data training on test Pass@1 for Qwen2.5-7B and Llama-3.1-8B, while full data holds the higher training Pass@1 (72.02 on Qwen2.5-7B). Kernel Herding, Facility Location and K-Means match or exceed the full-data baseline on DeepSeek-Coder-6.7B.
Seed spread and the 32B model
The mean test Pass@10 of random sampling is higher than that of every complex selector in the five-seed table.
The seed-347 run in the seed study reaches 6.32 test Pass@1, and the other seeds range from 4.39 to 5.39 for that metric. The authors conclude that different random draws reach similar performance levels.
On Qwen2.5-32B with 600 steps, random sampling gets the best test Pass@1 at 13.82, with K-Means at 13.55. For test Pass@10, however, Facility Location reaches 35.53, K-Means 34.65 and Kernel Herding 34.21, above the 31.58 of random sampling.
Where complex selectors help
On 59 tagged Medium and Hard problems, random sampling leads on Pass@1 with 1.86, while K-Means and Facility Location reach 8.47 on Pass@10 against 6.78 for random sampling. The authors read this split as random sampling being preferable for one representative solution, with complex selectors helping when several routes count.
Split by difficulty on Qwen2.5-7B, with 48, 101 and 79 tasks, random sampling leads on Easy problems, with 22.71 Pass@1 against 15.21 for K-Means. On Hard problems, Kernel Herding scores 1.77 Pass@1, compared to 0.89 for random sampling. Medium problems favor random sampling on Pass@10, at 10.89.
Harder subsets have larger solution-pool diversity, with Jaccard rising from 0.42 on Easy to 0.51 on Hard and Levenshtein distance from 88.29 to 229.00. Across random-selection results, the Pearson correlation of Levenshtein diversity is -0.447 for Pass@1 and -0.430 for Pass@10. The authors interpret these negative correlations as diverse pools being tied to harder problems, which motivates targeted selection on the tail.
At the case level, 38 problems are solved by both selectors and 167 by neither. Random sampling alone solves 6 problems, and the complex selectors alone solve 17. So the methods mostly trade individual boundary cases rather than solving different kinds of problems.
Learning rate, budget and distance choices
Training Pass@1 rises across the same sweep, from 56.57 to 71.49.
Varying the budget on Qwen2.5-7B with random sampling raises both training Pass@1 and test Pass@10. The gains are steepest at small budgets and taper as the budget grows.
Among four K-Center distance functions, cosine distance gives the highest training Pass@1 on each model. On Qwen2.5-7B, cosine reaches 58.69 and Levenshtein 49.41, and both sit below the 65.20 of random sampling. The authors attribute the cosine advantage to embeddings capturing functional similarity better than surface text.
Why random draws may hold up
The authors suggest that code LLMs already hold broad programming knowledge from pretraining, so SFT mainly activates and aligns patterns they have already learned. On this view, random sampling keeps the representative patterns of accepted solution pools, whereas diversity objectives can overweight atypical implementations.
The appendix gives an intuition, not a proof, based on a coupon-collector argument: with C ≤ 5 clusters and k = 11 samples, the chance of missing any cluster is under 5%. Random sampling also keeps the training distribution close to the pool, while diversity-based selection shifts it, which the authors argue can hurt generalization when the pool reflects real patterns.
The authors frame stronger objectives as tools for shifting coverage rather than as better replacements for random sampling.
Limits of the tested scope
The study uses Python algorithmic problems, and other languages, domains, task formats and models beyond 32B parameters were not tested. Single-solution datasets and unverified code corpora were also left for future work.
The five-seed comparison covers only Qwen2.5-7B, and the other models have single-seed results. Full Dataset is compared at matched epochs, not matched compute.
Paper info
- Authors
- Ren-Biao Liu, Xin-Ye Li, Hui Sun, Yali Du, Jiang-Tian Xue, Ming Li
- Venue
- International Conference on Machine Learning · Published
- First published
- 2026-9-29
- Added
- 2026-11-26
- Original paper terms
- Check in the original ↗
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Ren-Biao Liu, Xin-Ye Li, Hui Sun, Yali Du, Jiang-Tian Xue, Ming Li (2026). Random Selection Reveals Implicit Knowledge Consensus in Code Generation. International Conference on Machine Learning. https://proceedings.mlr.press/v306/liu26bz.html
BibTeX
@article{liu2026random,
title = {{Random Selection Reveals Implicit Knowledge Consensus in Code Generation}},
author = {Ren-Biao Liu and Xin-Ye Li and Hui Sun and Yali Du and Jiang-Tian Xue and Ming Li},
year = {2026},
journal = {International Conference on Machine Learning},
url = {https://proceedings.mlr.press/v306/liu26bz.html}
}