Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should we clamp or throw for out-of-range sampling hyperparameters? #53

Open
domenic opened this issue Oct 29, 2024 · 1 comment
Open

Comments

@domenic
Copy link
Collaborator

domenic commented Oct 29, 2024

Right now the Chrome implementation throws if temperature is outside the [0, maxTemperature] range, and similarly for top-K.

This might pose an interop problem, or a compat problem over time. Although ideally developers would check maxTemperature before providing a temperature value, maybe we should make it easier for them.

The proposal would be to change from throwing, to clamping to the nearest valid value. The developer could detect this clamping by checking the session's temperature (and topK).

This opens up the possibility of people writing code such as

ai.languageModel.create({ temperature: Infinity })

to get the max temperature intentionally. Probably that's fine.

domenic pushed a commit that referenced this issue Oct 29, 2024
@tomayac
Copy link
Contributor

tomayac commented Oct 29, 2024

I think it's fine to clamp. Is this something worth logging a console warning for, though? While ai.languageModel.create({ temperature: Infinity }) definitely is intentional, someone trying ai.languageModel.create({ temperature: 1.0 }) and then ai.languageModel.create({ temperature: 1.5 }) (assuming a [0.0, 1.0] interval) may expect a change to happen, thinking the model accepts [0.0, 2.0] (as per #41 (comment)) for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants