Hot or Cold? Adaptive Temperature Sampling for Code Generation with Large Language Models
Proceedings of the AAAI Conference on Artificial Intelligence · 24.03.2024 · 38 (1) · 437-445
DOI: 10.1609/aaai.v38i1.27798 ↗Kurz gefasst
Fachartikel in der Zeitschrift Proceedings of the AAAI Conference on Artificial Intelligence, online erschienen am 24.03.2024. Verfasst von Yuqi Zhu und 6 weiteren Autor:innen. Die Arbeit wurde bisher 43-mal zitiert (Crossref).
Abstract (Originalsprache)
Recently, Large Language Models (LLMs) have shown impressive abilities in code generation. However, existing LLMs' decoding strategies are designed for Natural Language (NL) generation, overlooking the differences between NL and programming languages (PL). Due to this oversight, a better decoding strategy for code generation remains an open question. In this paper, we conduct the first systematic study to explore a decoding strategy specialized in code generation. With an analysis of loss distributions of code tokens, we find that code tokens can be divided into two categories: challenging tokens that are difficult to predict and confident tokens that can be easily inferred. Among them, the challenging tokens mainly appear at the beginning of a code block. Inspired by the above findings, we propose a simple yet effective method: Adaptive Temperature (AdapT) sampling, which dynamically adjusts the temperature coefficient when decoding different tokens. We apply a larger temperature when sampling for challenging tokens, allowing LLMs to explore diverse choices. We employ a smaller temperature for confident tokens avoiding the influence of tail randomness noises. We apply AdapT sampling to LLMs with different sizes and conduct evaluations on two popular datasets. Results show that AdapT sampling significantly outperforms state-of-the-art decoding strategy.
Zitieren
APA
Zhu, Y., Li, J., Li, G., Zhao, Y., Li, J., Jin, Z., & Mei, H. (2024). Hot or Cold? Adaptive Temperature Sampling for Code Generation with Large Language Models. Proceedings of the AAAI Conference on Artificial Intelligence, 38(1), 437-445. https://doi.org/10.1609/aaai.v38i1.27798
Vancouver
Zhu Y, Li J, Li G, Zhao Y, Li J, Jin Z, et al. Hot or Cold? Adaptive Temperature Sampling for Code Generation with Large Language Models. Proceedings of the AAAI Conference on Artificial Intelligence. 2024;38(1):437-445. doi:10.1609/aaai.v38i1.27798
BibTeX
@article{Zhu2024,
author = {Zhu, Yuqi and Li, Jia and Li, Ge and Zhao, YunFei and Li, Jia and Jin, Zhi and Mei, Hong},
title = {Hot or Cold? Adaptive Temperature Sampling for Code Generation with Large Language Models},
journal = {Proceedings of the AAAI Conference on Artificial Intelligence},
year = {2024},
volume = {38},
number = {1},
pages = {437--445},
doi = {10.1609/aaai.v38i1.27798}
}
EUVIMED