Large language models show great potential in generating and optimizing code. Widely used sampling methods such as Nucleus Sampling increase the diversity of generation but often produce repeated samples for low temperatures and incoherent samples for high temperatures. Furthermore, the temperature coefficient has to be tuned for each task, limiting its usability. We present Priority Sampling, a simple and deterministic sampling technique that produces unique samples ordered by the model's confidence. Each new sample expands the unexpanded token with the highest probability in the augmented search tree. Additionally, Priority Sampling supports generation based on regular expression that provides a controllable and structured exploration process. Priority Sampling outperforms Nucleus Sampling for any number of samples, boosting the performance of the original model from 2.87% to 5% improvement over -Oz. Moreover, it outperforms the autotuner used for the generation of labels for the training of the original model in just 30 samples.
翻译:大型语言模型在代码生成与优化方面展现出巨大潜力。广泛使用的采样方法(如Nucleus Sampling)虽能增加生成结果的多样性,但在低温度参数下常产生重复样本,高温度参数下则生成不连贯结果。此外,温度系数需针对每项任务单独调参,限制了其可用性。我们提出优先级采样(Priority Sampling),这是一种简单且确定性的采样技术,可生成按模型置信度排序的独特样本。每个新样本通过扩展增强搜索树中概率最高的未扩展词元(token)获得。该采样方法还支持基于正则表达式的生成,提供可控的结构化探索过程。优先级采样在任意样本数量下均优于Nucleus Sampling,将原始模型相对于-Oz的优化性能从2.87%提升至5%。此外,仅需30个样本,该方法的性能便超越了用于生成原始模型训练标签的自动调优器。