#1308: Other Spec Review: Prompt API Sampling Mode

Visit on Github

Opened Nov 9, 2026

Specification

https://webmachinelearning.github.io/prompt-api/#enumdef-languagemodelsamplingmode

Explainer

https://github.com/webmachinelearning/prompt-api/blob/main/README.md#sampling-parameters

Links

The specification

Where and by whom is the work is being done?

  • GitHub repo: https://github.com/webmachinelearning/prompt-api
  • Primary contacts:
    • Isaac Ahouma (@isaacahouma), Google, feature author
    • Mike Wasserman (@michaelwasserman), Google, Prompt API lead
    • Reilly Grant (@reillyeon), Google, spec editor
    • Kenji Baheux (@KenjiBaheux), Google, product manager
    • Anssi Kostiainen (@anssiko), Intel, WebML CG chair
  • Organization/project driving the specification: Google
  • This work is being funded by: Google
  • Primary standards group developing this feature: W3C Web Machine Learning Community Group
  • Group intended to standardize this work: W3C Machine Learning Working Group
  • Incubation and standards groups that have discussed the design:

Feedback so far

You should also know that...

We are requesting a focused delta review of how samplingMode implements the TAG's "Interoperable model parameters" guidance from https://github.com/w3ctag/design-reviews/issues/1093.

Specifically, the WebIDL surface adds:

enum LanguageModelSamplingMode {
  "most-predictable",
  "predictable",
  "slightly-predictable",
  "balanced",
  "slightly-creative",
  "creative",
  "most-creative"
};

partial dictionary LanguageModelCreateCoreOptions {
  LanguageModelSamplingMode samplingMode;
};

partial interface LanguageModel {
  readonly attribute LanguageModelSamplingMode? samplingMode;
};

Key design choices we would appreciate any TAG thoughts on:

  1. 7 symmetric presets along a predictability-to-creativity spectrum: User agents map each preset to model-appropriate sampling hyperparameters (and backends with fewer distinct configurations may map adjacent tiers to their closest supported behavior without breaking callers).
  2. Defaults, nullability, and legacy coexistence: Omitting options.samplingMode defaults the session to "balanced", and session.clone() preserves samplingMode. While options.samplingMode is non-nullable (so invalid values or null reject with TypeError), the read-only session.samplingMode getter is nullable (LanguageModelSamplingMode?) solely so sessions configured with deprecated extension-only temperature or topK options (without samplingMode) return null. When samplingMode is provided alongside deprecated raw options, samplingMode takes precedence.

Timeline note: We sent our Blink Intent to Ship targeting Chrome M160 on 2026-11-09 (https://groups.google.com/a/chromium.org/d/msgid/blink-dev/6af20fd7.7772a632.11fdae.052f.GAE%40google.com).

<!-- Content below this is maintained by @w3c-tag-bot -->

Track conversations at https://tag-github-bot.w3.org/gh/w3ctag/design-reviews/1308

Discussions