Skip to content

Commit eaddfc9

Browse files
isaacahoumaIsaac Ahoumamichaelwasserman
authored
Update docs to mention deprecation of LanguageModel params (topK and temperature) in non-extension contexts (#189)
* Add deprecation notes for topK, temperature, and params * Update spec and README with deprecation notes for topK, temperature, and params * Update spec and README with deprecation notes for topK, temperature, and params * Update README.md Co-authored-by: Mike Wasserman <michaelwasserman@users.noreply.github.com> * Update README.md Co-authored-by: Mike Wasserman <michaelwasserman@users.noreply.github.com> * Remove temperature from exisitng example and remove added comment --------- Co-authored-by: Isaac Ahouma <iahouma@google.com> Co-authored-by: Mike Wasserman <michaelwasserman@users.noreply.github.com>
1 parent 50687ea commit eaddfc9

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ The following are potential goals we are not yet certain of:
4545

4646
Both of these potential goals could pose challenges to interoperability, so we want to investigate more how important such functionality is to developers to find the right tradeoff.
4747

48+
### Deprecation Notice
49+
50+
The following features of the LanguageModel API are **deprecated** and their functionality is now restricted to web extension contexts only:
51+
52+
* The static method `LanguageModel.params()`
53+
* The instance attributes `languageModel.topK` and `languageModel.temperature`
54+
* The `LanguageModelParams` interface and all its attributes (`defaultTopK`, `maxTopK`, `defaultTemperature`, `maxTemperature`)
55+
* The `topK` and `temperature` options within `LanguageModel.create()`
56+
57+
These features may be completely removed in the future. This change is intended to simplify the API and address inconsistencies in parameter support across various models.
58+
4859
## Examples
4960

5061
### Zero-shot prompting
@@ -422,16 +433,23 @@ Note that `append()` can also cause [overflow](#tokenization-context-window-leng
422433

423434
### Configuration of per-session parameters
424435

425-
In addition to the `initialPrompts` option shown above, the currently-configurable model parameters are [temperature](https://huggingface.co/blog/how-to-generate#sampling) and [top-K](https://huggingface.co/blog/how-to-generate#top-k-sampling). The `params()` API gives the default and maximum values for these parameters.
436+
In addition to the `initialPrompts` option shown above, in extension contexts, the currently-configurable model parameters are [temperature](https://huggingface.co/blog/how-to-generate#sampling) and [top-K](https://huggingface.co/blog/how-to-generate#top-k-sampling). The `params()` API gives the default and maximum values for these parameters.
426437

427-
_However, see [issue #42](https://github.com/webmachinelearning/prompt-api/issues/42): sampling hyperparameters are not universal among models._
438+
**Deprecation Notice:** The `topK` and `temperature` options for `LanguageModel.create()`, the `LanguageModel.params()` static method, and the `languageModel.topK` and `languageModel.temperature` instance attributes are now **deprecated**. These features are only functional within web extension contexts and will be ignored or unavailable in standard web page contexts. They may be completely removed in a future release.
439+
440+
The `LanguageModel.params()` API, only available in extensions, can be used to query the default and maximum values for these parameters.
441+
442+
_The limited applicability and non-universal nature of these sampling hyperparameters are discussed further in [issue #42](https://github.com/webmachinelearning/prompt-api/issues/42): sampling hyperparameters are not universal among models._
428443

429444
```js
445+
// The topK and temperature members of the options object are deprecated. They will only be considered when
446+
// LanguageModel.create() is called from within a Chrome Extension. In web page contexts, they are ignored.
430447
const customSession = await LanguageModel.create({
431448
temperature: 0.8,
432449
topK: 10
433450
});
434-
451+
// This interface and all its attributes (`defaultTopK`, `maxTopK`, `defaultTemperature`, `maxTemperature`)
452+
// are now only available within Chrome Extension contexts. Web pages can no longer call this method.
435453
const params = await LanguageModel.params();
436454
const conditionalSession = await LanguageModel.create({
437455
temperature: isCreativeTask ? params.defaultTemperature * 1.1 : params.defaultTemperature * 0.8,
@@ -711,7 +729,6 @@ const options = {
711729
{ type: "text", languages: ["en", "es"] },
712730
{ type: "audio", languages: ["en", "es"] }
713731
],
714-
temperature: 2
715732
};
716733

717734
const availability = await LanguageModel.availability(options);

index.bs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ These APIs are part of a family of APIs expected to be powered by machine learni
3737
interface LanguageModel : EventTarget {
3838
static Promise<LanguageModel> create(optional LanguageModelCreateOptions options = {});
3939
static Promise<Availability> availability(optional LanguageModelCreateCoreOptions options = {});
40+
// **DEPRECATED**: This method is only available in extension contexts.
4041
static Promise<LanguageModelParams?> params();
4142

4243
// These will throw "NotSupportedError" DOMExceptions if role = "system"
@@ -61,13 +62,16 @@ interface LanguageModel : EventTarget {
6162
readonly attribute unrestricted double inputQuota;
6263
attribute EventHandler onquotaoverflow;
6364

65+
// **DEPRECATED**: This attribute is only available in extension contexts.
6466
readonly attribute unsigned long topK;
67+
// **DEPRECATED**: This attribute is only available in extension contexts.
6568
readonly attribute float temperature;
6669

6770
Promise<LanguageModel> clone(optional LanguageModelCloneOptions options = {});
6871
undefined destroy();
6972
};
7073

74+
// **DEPRECATED**: This interface and its attributes are only available in extension contexts.
7175
[Exposed=Window, SecureContext]
7276
interface LanguageModelParams {
7377
readonly attribute unsigned long defaultTopK;
@@ -92,7 +96,9 @@ dictionary LanguageModelTool {
9296
dictionary LanguageModelCreateCoreOptions {
9397
// Note: these two have custom out-of-range handling behavior, not in the IDL layer.
9498
// They are unrestricted double so as to allow +Infinity without failing.
99+
// **DEPRECATED**: This option is only allowed in extension contexts.
95100
unrestricted double topK;
101+
// **DEPRECATED**: This option is only allowed in extension contexts.
96102
unrestricted double temperature;
97103

98104
sequence<LanguageModelExpected> expectedInputs;

0 commit comments

Comments
 (0)