Contact emails iah...@google.com, m...@google.com
Explainer
https://github.com/webmachinelearning/prompt-api#sampling-parameters
Specification
https://webmachinelearning.github.io/prompt-api/
Summary
The Prompt API Sampling Parameters allow developers to control the output variety of the built-in AI language model. Instead of exposing raw numerical parameters (e.g. topK and temperature) which can behave inconsistently across different underlying model families and versions, this feature introduces a categorical samplingMode enum. This allows the browser to handle the heavy lifting of mapping semantic presets to optimal raw parameters for a specific underlying model, providing developers with the necessary granularity to tune responses while maintaining cross-browser interoperability.
enum AILanguageModelSamplingMode {
"most-predictable", // For strict consistency/factual extraction
"predictable", // For highly focused outputs
"slightly-predictable", // For moderately focused, consistent outputs
"balanced", // The default state for standard prompting
"slightly-creative", // For moderately varied, expressive outputs
"creative", // For tasks favoring variety over strict facts
"most-creative" // For maximum token diversity and brainstorming
};
Blink component
Blink>AI>Prompt
Web Feature ID
https://webstatus.dev/features/languagemodel
TAG review status
Pending
Link to previous “Intent to Experiment” blink-dev discussion
https://groups.google.com/a/chromium.org/g/blink-dev/c/4KvH5XEBYtE
Goals for experimentation
Our primary goal during this extension is to gather real-world usage data on the newly expanded categorical presets to see which modes developers gravitate toward most. We will use this data and developer feedback to conduct more concerted medium-term mode evaluations. Specifically, we want to evaluate developer adoption of this expanded spectrum, and validate that the new granularity effectively covers the previously identified dead zones.
Experimental timeline
The extended experiment will continue through Chrome 159.
Reason this experiment is being extended
We are extending this experiment because we are actively iterating on the API surface based on developer feedback. During this trial, we received developer feedback requesting predictable space granularity to cover dead zones while restoring the balanced preset to the API default parameters. We have expanded the preset enum values to cover these dead zones, and we need the extended timeline to give developers sufficient time to integrate and test these specific changes.
Interoperability and Compatibility Risks
The original raw parameters were excluded from the initial Prompt API launch due to cross-browser interoperability concerns. By refining the categorical sampling modes to provide better coverage of the predictable space based on developer feedback, we maintain the cross-browser interoperability benefits of semantic presets while offering the necessary granularity developers requested.
WebView application risks
None
Ongoing technical constraints
None
Debuggability
It is possible that giving DevTools more insight into the nondeterministic states of the model, e.g. random seeds, could help with debugging. See related discussion at https://github.com/webmachinelearning/prompt-api/issues/9.
Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, ChromeOS, Android, and Android WebView)?
No, the Prompt API currently supports Windows, Mac, Linux, and ChromeOS.
Is this feature fully tested by web-platform-tests?
No; while the API shape is fully tested, automated testing of sampling parameter effects on probabilistic model response is not readily feasible; instead we conduct rounds of evaluations on configuration updates.
Flag name on about://flags
prompt-api-sampling-mode
Finch feature name
AIPromptAPIParams
Requires code in //chrome?
True
Tracking bug
https://crbug.com/502214118
Launch bug
https://launch.corp.google.com/launch/4463387
Link to entry on the Chrome Platform Status:
https://chromestatus.com/feature/6325545693478912