liveBook · Manning

Hyperparameter tuning

As explained in Data Analysis with LLMs

Model tuning is the adjustment of a model's generation settings to improve its behavior on a task.

Tune a language model’s generation settings to constrain its output, improve classification results, and avoid generating tokens that will not be used. section 9.3

Classifying reviews

For a ten-review classification sample, limiting output to one token increased correct labels from six to seven. This works because each of the two possible labels fits in one token. section 9.3

response = client.chat.completions.create(
    model='gpt-3.5-turbo',
    messages=[
        {'role':'user', 'content':prompt}
        ],
    logit_bias = {981:100, 29875:100},  #1
    temperature=0, max_tokens=1
    )

See the OpenAI Python call that combines token restrictions with a one-token output limit. section 9.3

How Data Analysis with LLMs covers it

How deep it goes
Demonstrates token restrictions and a one-token output limit, but notes these are only a subset of available tuning options.
Examples
Compares ten review labels and reports seven correct results after limiting output to one token, up from six.
What it assumes
Requires two class labels that each fit in one token for the demonstrated output limit to work.
What you can do after
Apply output constraints through the OpenAI Python client to generate single-token class labels and limit response length.
How it connects
Connects model tuning with text classification, precision, token consumption, and generation settings such as temperature.

Also explained in

Compare how 18 books explain hyperparameter tuning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Analysis with LLMs. The section links point to the parts of the book it draws on.