atlas

Research map / Large language models / Language, safety and interpretability

Hot or Cold? Adaptive Temperature Sampling for Code Generation with Large Language Models

AAAI 2024 · Large language models › Language, safety and interpretability · approach: Parallel and early-exit decoding · 34 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes AdapT sampling, which uses a higher temperature for challenging code-block-initial tokens and a lower temperature elsewhere, improving pass@k on HumanEval and MBPP for CodeGen-2B, InCoder-6B, and CodeGeeX-13B.

Problem

Standard decoding strategies (greedy, beam, temperature plus top-p sampling) were designed for natural language, and a single temperature is suboptimal for code generation, where some tokens are hard to predict and others are highly deterministic.

Approach

Analysis of per-token loss shows challenging tokens concentrate at the first token of code blocks; AdapT sampling sets a higher temperature a for code-block-initial tokens and a lower temperature b for all other tokens, requiring no training.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Use adaptive temperature instead of the best fixed-temperature SP settingCodeGen-2B · HumanEvalpass@5, pass@10, pass@15: pass@5: 33.4 -> 34.4; pass@10: 39.7 -> 40.1; pass@15: 43.9 -> 43.9Mixed
Use adaptive temperature instead of the best fixed-temperature SP settingInCoder-6B · HumanEvalpass@5, pass@10, pass@15: pass@5: 25.0 -> 25.8; pass@10: 30.0 -> 31.6; pass@15: 32.9 -> 35.3Helped
Use adaptive temperature instead of the best fixed-temperature SP settingCodeGeeX-13B · HumanEvalpass@5, pass@10, pass@15: pass@5: 27.7 -> 29.4; pass@10: 33.0 -> 36.3; pass@15: 36.0 -> 40.9Helped
Use adaptive temperature instead of the best fixed-temperature SP settingCodeGen-2B · MBPPpass@5, pass@10, pass@15: pass@5: 37.1 -> 37.2; pass@10: 43.5 -> 44.4; pass@15: 47.0 -> 48.2Helped
Use adaptive temperature instead of the best fixed-temperature SP settingInCoder-6B · MBPPpass@5, pass@10, pass@15: pass@5: 26.0 -> 26.8; pass@10: 30.6 -> 32.9; pass@15: 34.6 -> 36.8Helped
Use adaptive temperature instead of the best fixed-temperature SP settingCodeGeeX-13B · MBPPpass@5, pass@10, pass@15: pass@5: 25.4 -> 25.8; pass@10: 31.2 -> 32.2; pass@15: 35.6 -> 36.0Helped
Vary a from 0.2 to 0.9 with b=0.3 (ablation)AdapT on CodeGeeX-13B · HumanEvalpass@15: 32.9% to 37.8%Helped
Vary b with a=0.8 (ablation)AdapT on CodeGeeX-13B · HumanEvalpass@1, pass@5, pass@10, pass@15Mixed

Surprising findings

Limitations

Experimental setup

Datasets: HumanEval MBPP APPS

Benchmarks: HumanEval MBPP

Metrics: pass@1 pass@5 pass@10 pass@15 syntax error counts

Baselines: Greedy search beam search temperature sampling (SP)

Builds on: temperature sampling top-p sampling pass@k

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy