Hypster Docs
Github 🌟Contact Us
  • 👋Welcome
  • Getting Started
    • 🖥️Installation
    • 🚀Defining of A Config Function
    • ⚡Instantiating a Config Function
    • 🍡Selecting Output Variables
    • 🎮Interactive Instantiation (UI)
    • 🪄Usage Examples
      • Machine Learning
      • LLM Generation
  • In Depth
    • 🤖Parameter Naming
    • 🍱HP Call Types
      • Selectable Types
      • Numeric Types
      • Boolean Types
      • Textual Types
      • Nested Configurations
    • 🧠Best Practices
Powered by GitBook

Contact & Follow the Author

  • Website
  • LinkedIn
  • Github
  • Medium

© Gilad Rubin 2024

On this page
  • Instantiation Rules
  • Default Values
  • Conditional Logic
  • Numeric Bounds Validation
  • Variable Selection Methods
  • Available Parameter Types
  • HP Call Types

Was this helpful?

Edit on GitHub
  1. Getting Started

Instantiating a Config Function

In this section, we'll use the following configuration function:

from hypster import config, HP

@config
def llm_config(hp: HP):
    model_name = hp.select({"sonnet" : "claude-3-5-sonnet-20241022"
                            "haiku" : "claude-3-5-haiku-20241022"},
                            default="haiku")

    if model_type == "haiku":
        max_tokens = hp.int(256, min=0, max=2048)
    else:
        max_tokens = hp.int(126, min=0, max=1024)

    cache = Cache(folder=hp.text("./cache"))
    config_dct = {"temperature" : hp.number(0, min=0, max=1),
                  "max_tokens" : max_tokens}

    model = Model(model_name, cache)

Instantiation Rules

Default Values

Parameters use their default values when not specified:

config = llm_config()
# equivalent to {"model_name" : "haiku", "max_tokens" = 256, "cache.folder" : "./cache"), ...

Conditional Logic

Values must respect the configuration's conditional logic:

# Valid: haiku model allows up to 2048 tokens
config = llm_config(values={
    "model_name": "haiku",
    "max_tokens": 2000
})

# Invalid: sonnet model only allows up to 1024 tokens
config = llm_config(values={
    "model_name": "sonnet",
    "max_tokens": 2000  # Will raise error
})

Numeric Bounds Validation

Numeric parameters undergo bounds validation, if specified:

# These will raise validation errors:
config = llm_config(values={
    "config_dct.temperature": 1.5,  # Exceeds max=1
    "max_tokens": -10               # Below min=0
})

Variable Selection Methods

To ensure we pass only the required variables, we have two filtering approaches:

  1. Include specific variables using final_vars:

config = my_config(final_vars=["model", "config_dict"], values={...})
run("Hello", **config)

Use final_vars when you need only a few specific variables

When final_vars is empty, all variables are returned (except those in exclude_vars)

  1. Exclude unwanted variables using exclude_vars:

config = my_config(exclude_vars=["cache", "temp_data"], values={...})
run("Hello", **config)

Choose exclude_vars when you have many variables to keep and little to filter out.

Available Parameter Types

Each parameter type has specific validation and behavior rules. See each section for more details:

HP Call Types

PreviousDefining of A Config FunctionNextSelecting Output Variables

Last updated 6 months ago

Was this helpful?

- For categorical choices

- For numeric values

- For boolean values

- For string values

- For nested configurations

⚡
select & multi_select
int, number & multi_int, multi_number
bool & multi_bool
text & multi_text
nest