demo · v148

Sampling Playground

Drag the sliders, write a prompt, click run. The same prompt produces different outputs at different temperature / topK settings. Defaults come from LanguageModel.params() where the API is available.

model defaults: loading…
0.8
0 (deterministic)2 (chaotic)
40
1 (greedy)100 (broad)
Output appears here. The Prompt API is on-device; results will vary across hardware and Chrome versions.

the code

// Defaults shipped with the model
const params = await LanguageModel.params();
console.log(params.defaultTemperature, params.defaultTopK, params.maxTopK);

// Per-instance overrides
const session = await LanguageModel.create({
  temperature: 0.2,
  topK: 1,
});
const reply = await session.prompt("Summarise this article in three bullets.");

// Read what the instance is actually using
console.log(session.temperature, session.topK);

see also

implementation reference

Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗