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

Set min/max values for float options for OpenAI models #115

Closed
simonw opened this issue Jul 18, 2023 · 3 comments
Closed

Set min/max values for float options for OpenAI models #115

simonw opened this issue Jul 18, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Jul 18, 2023

No description provided.

@simonw simonw added the enhancement New feature or request label Jul 18, 2023
simonw added a commit that referenced this issue Jul 18, 2023
@simonw
Copy link
Owner Author

simonw commented Jul 18, 2023

I tried this in a branch:

temperature: Optional[confloat(ge=0, le=2)] = Field(

It has an unfortunate impact on the output of llm models list --options:

llm/docs/usage.md

Lines 102 to 118 in 6bad6de

OpenAI Chat: gpt-3.5-turbo (aliases: 3.5, chatgpt)
temperature: Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=2), None, None]
What sampling temperature to use, between 0 and 2. Higher values like
0.8 will make the output more random, while lower values like 0.2 will
make it more focused and deterministic.
max_tokens: int
Maximum number of tokens to generate.
top_p: Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=1), None, None]
An alternative to sampling with temperature, called nucleus sampling,
where the model considers the results of the tokens with top_p
probability mass. So 0.1 means only the tokens comprising the top 10%
probability mass are considered. Recommended to use top_p or
temperature but not both.
frequency_penalty: Annotated[float, None, Interval(gt=None, ge=-2, lt=None, le=2), None, None]
Number between -2.0 and 2.0. Positive values penalize new tokens based
on their existing frequency in the text so far, decreasing the model's
likelihood to repeat the same line verbatim.

Note the ugly:

temperature: Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=2), None, None]

I'm not sure how best to clean that up, especially since that output differs between Python versions.

In fact https://github.com/simonw/llm/actions/runs/5583462965/jobs/10203805843 failed on Python 3.7 with this differing cog output:

  temperature: typing_extensions.Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=2), None, None]

@simonw
Copy link
Owner Author

simonw commented Jul 18, 2023

In the meantime it works OK without those min/max settings - the prompt ends up being sent to the OpenAI API which returns a useful error message:

llm -m chatgpt 'say hello twice' -o temperature -1
Error: -1.0 is less than the minimum of 0 - 'temperature'

@pavelkraleu
Copy link
Contributor

What about something like this @simonw ?

@simonw simonw closed this as completed in 838484b Jul 26, 2023
simonw added a commit that referenced this issue Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants