Nous.Eval.Optimizer.Parameter (nous v0.13.3)

View Source

Defines optimizable parameters for agent configuration.

Parameters define the search space for optimization. Each parameter specifies a name, type, and valid range of values.

Parameter Types

  • :float - Continuous floating point values
  • :integer - Discrete integer values
  • :choice - Categorical choices from a list
  • :bool - Boolean true/false

Examples

# Temperature from 0.0 to 1.0 in steps of 0.1
Parameter.float(:temperature, 0.0, 1.0, step: 0.1)

# Max tokens from 100 to 2000 in steps of 100
Parameter.integer(:max_tokens, 100, 2000, step: 100)

# Model selection
Parameter.choice(:model, [
  "lmstudio:ministral-3-14b",
  "lmstudio:qwen-7b",
  "openai:gpt-4"
])

# Enable/disable a feature
Parameter.bool(:use_cot)

Conditional Parameters

Parameters can be conditional on other parameter values:

Parameter.float(:top_p, 0.0, 1.0,
  condition: {:temperature, &(&1 > 0.5)}
)

Summary

Functions

Check if a parameter is active given current config.

Create a boolean parameter.

Create a categorical choice parameter.

Create a float parameter.

Create an integer parameter.

Sample a random value from the parameter space.

Get all possible values for a parameter (for grid search).

Types

param_type()

@type param_type() :: :float | :integer | :choice | :bool

t()

@type t() :: %Nous.Eval.Optimizer.Parameter{
  choices: [term()] | nil,
  condition: {atom(), function()} | nil,
  default: term() | nil,
  log_scale: boolean(),
  max: number() | nil,
  min: number() | nil,
  name: atom(),
  step: number() | nil,
  type: param_type()
}

Functions

active?(parameter, config)

@spec active?(t(), map()) :: boolean()

Check if a parameter is active given current config.

bool(name, opts \\ [])

@spec bool(
  atom(),
  keyword()
) :: t()

Create a boolean parameter.

Options

  • :default - Default value (default: false)
  • :condition - Conditional on another parameter

Examples

Parameter.bool(:use_cot)
Parameter.bool(:stream, default: true)

choice(name, choices, opts \\ [])

@spec choice(atom(), [term()], keyword()) :: t()

Create a categorical choice parameter.

Options

  • :default - Default value
  • :condition - Conditional on another parameter

Examples

Parameter.choice(:model, ["gpt-4", "gpt-3.5-turbo", "claude-3"])
Parameter.choice(:strategy, [:greedy, :sampling, :beam_search])

float(name, min, max, opts \\ [])

@spec float(atom(), number(), number(), keyword()) :: t()

Create a float parameter.

Options

  • :step - Step size for grid search (default: calculated)
  • :default - Default value
  • :log_scale - Use log scale for sampling
  • :condition - Conditional on another parameter

Examples

Parameter.float(:temperature, 0.0, 1.0)
Parameter.float(:temperature, 0.0, 1.0, step: 0.1)
Parameter.float(:learning_rate, 1.0e-5, 1.0e-2, log_scale: true)

integer(name, min, max, opts \\ [])

@spec integer(atom(), integer(), integer(), keyword()) :: t()

Create an integer parameter.

Options

  • :step - Step size (default: 1)
  • :default - Default value
  • :condition - Conditional on another parameter

Examples

Parameter.integer(:max_tokens, 100, 4000)
Parameter.integer(:max_tokens, 100, 4000, step: 100)

sample(parameter)

@spec sample(t()) :: term()

Sample a random value from the parameter space.

values(parameter)

@spec values(t()) :: [term()]

Get all possible values for a parameter (for grid search).