[w3ctag/design-reviews] Other Spec Review: Prompt API Sampling Mode (Issue #1308)

isaacahouma created an issue (w3ctag/design-reviews#1308)

### Specification

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

### Explainer

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

### Links

* Previous early design review, if any: https://github.com/w3ctag/design-reviews/issues/1093 (specifically "Interoperable model parameters" in https://github.com/w3ctag/design-reviews/issues/1093#issuecomment-3515070512)
* An introduction to the feature, aimed at unfamiliar audiences: https://github.com/webmachinelearning/prompt-api/blob/main/README.md#sampling-parameters
* A description of the problems that end-users were facing before this proposal: https://github.com/webmachinelearning/prompt-api/issues/203 and https://github.com/webmachinelearning/prompt-api/issues/42
* Alternatives considered:
  * Exposing raw scalar `temperature` and `topK` parameters on the open web (excluded per TAG feedback in https://github.com/w3ctag/design-reviews/issues/1093; deprecated in extension contexts).
  * Synonym-based enum naming (`"deterministic"` / `"precise"` / `"imaginative"`) and single-axis naming (`AILanguageModelCreativity`), replaced after international developer readability discussions in https://github.com/webmachinelearning/prompt-api/issues/203#issuecomment-4341779584 and https://github.com/webmachinelearning/prompt-api/issues/203#issuecomment-4351334398.
  * Coarser 3-tier or 5-tier preset counts, expanded to 7 presets during the Origin Trial to cover predictable-side granularity gaps while keeping `"balanced"` aligned with default session behavior (https://github.com/webmachinelearning/prompt-api/issues/203#issuecomment-5483052364).
* Examples of how to use the proposal to solve the end-users' problems: https://github.com/webmachinelearning/prompt-api/blob/main/README.md#configuration-of-sampling-modes
* What do the end-users experience with this proposal: End users get more consistent structured extraction and classification on tasks using predictable presets (plus faster, lower-power on-device generation when `"most-predictable"` enables greedy speculative decoding), and more varied phrasing on open-ended drafting tasks using creative presets. Interactive comparison demo: https://isaacahouma.github.io/prompt-api-sampling-presets/
* User research you did to validate the problem and/or design, if any: Early Preview Program developer surveys, Origin Trial telemetry, and partner case studies summarized in https://github.com/webmachinelearning/prompt-api/issues/203#issuecomment-6747446996
* Web Platform Tests: https://wpt.fyi/results/ai/language-model?label=experimental&label=master&aligned (`language-model-availability-sampling-mode.tentative.https.window.html` and `language-model-create-sampling-mode.tentative.https.window.html`)


### The specification

- [x] Follows the [Web Platform Design Principles](https://www.w3.org/TR/design-principles/).
- [x] Includes Security and Privacy Considerations sections based on answers to the [Security/Privacy Questionnaire](https://www.w3.org/TR/security-privacy-questionnaire/).

### 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:
  * W3C Web Machine Learning Community Group (resolution in https://www.w3.org/2026/05/28-webmachinelearning-minutes.html#fbac and design thread in https://github.com/webmachinelearning/prompt-api/issues/203)


### Feedback so far

* Multi-stakeholder feedback:
  * Chromium comments: Positive; completed Origin Trial (M148 through M159) and sent Intent to Ship for M160.
  * Mozilla comments: https://github.com/mozilla/standards-positions/issues/1213 (position on the parent Prompt API specification)
  * WebKit comments: https://github.com/WebKit/standards-positions/issues/495 (position on the parent Prompt API specification)
  * Microsoft Edge comments: Positive on interoperable categorical presets even when underlying backends offer coarser granularity (https://github.com/webmachinelearning/prompt-api/issues/203#issuecomment-4384671360)
  * Developer comments: Summarized in https://github.com/webmachinelearning/prompt-api/issues/203#issuecomment-6747446996 (75% of parameter-tuning Early Preview Program respondents accepted presets, and over 95% of tuned Origin Trial and extension sessions select predictable outputs, with 75% choosing `"most-predictable"`).
* Major unresolved issues with or opposition to this specification: Mozilla and WebKit hold negative positions on the parent Prompt API specification linked above. Within the parameter-tuning developer cohort, 25% of surveyed developers still express a preference for raw scalar `temperature` and `topK` knobs, which were excluded on the open web following TAG guidance in #1093.
* Status/issue trackers for implementations: https://chromestatus.com/feature/6325545693478912 and https://issues.chromium.org/573612811


### 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:

```webidl
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).


-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/1308
You are receiving this because you are subscribed to this thread.

Message ID: <w3ctag/design-reviews/issues/1308@github.com>

Received on Monday, 9 November 2026 19:37:31 UTC