# Instantiating a Config Function

Use `instantiate(func, values=...)` to execute your configuration function with optional overrides.

If you want to inspect the available parameters first, use [`explore()`](/hypster/getting-started/exploring-a-configuration-space.md) before instantiating.

```python
from hypster import instantiate

result = instantiate(model_cfg, values={
    "kind": "rf",
    "n_estimators": 200,
    "max_depth": 12.5,
})
# => {"model": ("rf", 200, 12.5)}
```

## Unknown parameters

Control how unknown or conditionally unreachable values are handled via `on_unknown`:

* `on_unknown="warn"` (default): issue a warning and continue
* `on_unknown="raise"`: raise a `ValueError`
* `on_unknown="ignore"`: silently ignore

```python
instantiate(model_cfg, values={"n_trees": 200}, on_unknown="warn")
```

## Dotted keys vs nested dicts

See In Depth → Values & Overrides for how to pass nested overrides and precedence.

The same `values=` format also works with `explore()` when you want to inspect a specific conditional branch.

## Passing args/kwargs to nested configs

When using `hp.nest`, you can pass `args=`/`kwargs=` to the child function; these are forwarded at call time.

```python

def child(hp: HP, multiplier: int, offset: int = 0) -> int:
    base = hp.int(5, name="base")
    return base * multiplier + offset


def parent(hp: HP):
    calc1 = hp.nest(child, name="calc1", args=(2,))
    calc2 = hp.nest(child, name="calc2", args=(3,), kwargs={"offset": 10})
    return {"calc1": calc1, "calc2": calc2}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gilad-rubin.gitbook.io/hypster/getting-started/instantiating-a-configuration-space.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
