# Using Parameters

> 💡 **About this tutorial:** We use YOLOv8 as a practical example to demonstrate Valohai's features. You don't need computer vision knowledge—the patterns you learn here apply to any ML framework. This tutorial focuses on defining parameters and configuration values while ensuring proper versioning and tracking of your ML workflows.

### Define parameters in valohai.yaml

Tell Valohai which arguments your training script accepts. Parameters become command-line arguments automatically, no boilerplate needed.

```yaml
- step:
    name: yolo
    image: docker.io/ultralytics/ultralytics:8.0.180-python
    command: python train.py {parameters}
    environment: aws-eu-west-1-p3-2xlarge
    parameters:
        - name: epochs
          type: integer
          default: 3
        - name: verbose
          type: flag
          default: False
          pass-true-as: --verbose=True
          pass-false-as: --verbose=False
```

**What's happening here:**

* `{parameters}` placeholder → Valohai injects `--epochs=3 --verbose=True`
* `environment` → GPU instance type (find available options: `vh environments --gpu`)
* Flag parameters need explicit pass-true/false values for boolean handling

### Parse parameters in Python

Use Python's standard `argparse` to receive these values. No special Valohai SDK required.

```python
import shutil
from ultralytics import YOLO
import argparse
import json


def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument("--epochs", type=int, default=3)
    parser.add_argument("--verbose", type=bool, default=False)
    return parser.parse_args()


args = parse_args()

# Load a model
model = YOLO("yolov8n.pt")  # load a pretrained model (recommended for training)

# Use the model
model.train(data="coco128.yaml", epochs=args.epochs, verbose=args.verbose)  # train the model
path = model.export(format="onnx")  # export the model to ONNX format

# Copy the exported model to the Valohai outputs directory
shutil.copy(path, "/valohai/outputs/")

# Define a JSON dictionary containing a friendly name
# You can then reference this file with datum://latest-model
file_metadata = {
    "valohai.alias": "latest-model",
}

# Attach the metadata to the file
with open("/valohai/outputs/best.onnx.metadata.json", "w") as f:
    f.write(file_metadata)
```

### Run with custom parameters

Override defaults directly from the CLI:

```shell
vh execution run yolo --adhoc --open-browser --epochs=1
```

Your execution details page now shows:

* **Parameters section**: Displays `epochs: 1` and other values
* **Logs**: Confirms YOLOv8 ran exactly 1 epoch

### Compare experiments at a glance

Navigate to the **Executions** tab to see all your runs in a table with parameter columns. No more guessing which job used which configuration.

***

#### Related content

* [Add hyperparameter sweeps](/notebook-executions/tune-from-notebook.md) to test multiple configurations automatically


---

# 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://docs.valohai.com/getting-started/intro/parameters.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.
