demo · v148

Determinism Test

Fix the prompt. Pick a temperature. Run it N times in a row and count how many distinct outputs you get. The other half of the sampling story: topK/temperature aren't just creativity knobs, they're the only way to ask the on-device model for repeatable output.

Heads up Origin trial. Enable chrome://flags/#prompt-api-for-gemini-nano and join the OT to run the model. If unavailable, the demo uses a deterministic mock that pretends to be sensitive to temperature so the UX still makes sense.

temperature

0.2

topK

3
0 runs
0 distinct outputs
determinism ratio

the code

// Determinism on the on-device model = low temperature + tight topK
const session = await LanguageModel.create({
  temperature: 0.0,   // NEW in 148
  topK: 1,            // NEW in 148
});

const results = [];
for (let i = 0; i < 10; i++) {
  results.push(await session.prompt(input));
}
const distinct = new Set(results).size;
console.log(`${distinct} distinct outputs across ${results.length} runs`);

see also

implementation reference

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