# What Is the clip Parameter in KronosPredictor? Default Value and Usage Explained

> Learn about the clip parameter in KronosPredictor. Understand its default value of 5 and how it prevents extreme outliers from destabilizing inference.

- Repository: [ShiYu/Kronos](https://github.com/shiyu-coder/Kronos)
- Tags: api-reference
- Published: 2026-04-10

---

**The `clip` parameter in `KronosPredictor` caps normalized input features at `[-clip, clip]` using NumPy's `np.clip` to prevent extreme outliers from destabilizing autoregressive inference, and it defaults to `5`.**

The `clip` parameter is a critical hyperparameter in the **Kronos** transformer-based time series forecasting framework. It controls the magnitude of standardized input features—such as price, volume, and trade amounts—before they are fed into the model's forward pass. According to the source code in [`model/kronos.py`](https://github.com/shiyu-coder/Kronos/blob/main/model/kronos.py), this safeguard ensures that the normalized data remains within the distribution range the model was trained on, avoiding unstable predictions caused by rare spikes or data errors.

## Understanding the clip Parameter in KronosPredictor

### Technical Definition and Default Value

In the `KronosPredictor` class defined in [`model/kronos.py`](https://github.com/shiyu-coder/Kronos/blob/main/model/kronos.py), `clip` is initialized as a numeric threshold in the constructor:

```python
def __init__(self, model, tokenizer, device=None, max_context=512, clip=5):
    ...
    self.clip = clip

```

**The default value is `5`**. This value is stored as an instance attribute (`self.clip`) and applied during both single-step and batch prediction routines. When input features are standardized using the formula `(x - mean) / std`, the resulting values are clipped to the interval `[-self.clip, self.clip]` before being passed to the transformer model.

### Why Feature Clipping Matters

Normalization is essential for training and inference in transformer architectures. However, without clipping, a single erroneous data point—such as a fat-finger trade or a corrupted price tick—could produce normalized values far outside the range seen during training. This can lead to:

- **Numerical instability** in the autoregressive generation loop
- **Out-of-distribution representations** that the model's attention layers cannot interpret
- **Degraded forecast accuracy** on subsequent time steps

The default threshold of `5` represents a practical trade-off that tolerates moderate market volatility while discarding extreme statistical outliers that exceed five standard deviations from the mean.

## Implementation Details in the Source Code

The clipping logic is implemented in the `predict` and `predict_batch` methods within [`model/kronos.py`](https://github.com/shiyu-coder/Kronos/blob/main/model/kronos.py) (lines 44-48 and surrounding context).

For single-step predictions, the workflow follows:

```python

# Standardization

x = (x - mean) / std

# Clipping to prevent outlier destabilization

x = np.clip(x, -self.clip, self.clip)

```

Similarly, batch processing applies the same constraint:

```python
x_norm = (x - x.mean(axis=0)) / x.std(axis=0)
x_norm = np.clip(x_norm, -self.clip, self.clip)

```

These operations use **NumPy's** `np.clip` function to enforce the bounds efficiently. The [`finetune/config.py`](https://github.com/shiyu-coder/Kronos/blob/main/finetune/config.py) file also reflects this default configuration, explicitly setting `self.clip = 5.0` for training pipelines to maintain consistency between training and inference distributions.

## Practical Code Examples

### Using the Default Clip Value (5)

When instantiating `KronosPredictor` without specifying `clip`, it automatically applies the default threshold of `5`:

```python
from model import Kronos, KronosTokenizer, KronosPredictor
import pandas as pd

# Load pretrained artifacts

model = Kronos.load_pretrained("model.ckpt")
tokenizer = KronosTokenizer.load_pretrained("tokenizer.ckpt")

# Instantiate with default clip=5

predictor = KronosPredictor(model, tokenizer)

# Prepare historical data

df = pd.read_csv("data/stock_prices.csv")  # Requires OHLC columns

# Forecast next 10 steps

future = predictor.predict(
    df,
    x_timestamp=pd.date_range(start="2023-01-01", periods=len(df), freq="D"),
    y_timestamp=pd.date_range(start=df.index[-1] + pd.Timedelta(days=1), periods=10, freq="D"),
    pred_len=10
)

```

### Customizing the Clip Threshold

For datasets with higher volatility or when you require stricter outlier control, override the default by passing a custom value to the constructor:

```python

# Tighter clipping at 3 standard deviations

predictor = KronosPredictor(model, tokenizer, clip=3)

# Inference proceeds identically

future = predictor.predict(df, x_timestamp=..., y_timestamp=..., pred_len=10)

```

Reducing `clip` to `3` creates a more conservative boundary, which may improve robustness on noisy datasets but could truncate legitimate extreme movements.

### Batch Predictions with Consistent Clipping

The `clip` setting persists across batch operations. When processing multiple time series simultaneously, each series is standardized and clipped independently using the same threshold:

```python

# Multiple series inputs

df_list = [df1, df2, df3]
x_ts_list = [ts1, ts2, ts3]
y_ts_list = [future_ts] * 3

# Batch inference applies the same clip threshold to all inputs

batch_results = predictor.predict_batch(
    df_list,
    x_timestamp_list=x_ts_list,
    y_timestamp_list=y_ts_list,
    pred_len=10,
    sample_count=3  # Stochastic average

)

```

The unit tests in [`tests/test_kronos_regression.py`](https://github.com/shiyu-coder/Kronos/blob/main/tests/test_kronos_regression.py) implicitly validate this behavior by instantiating `KronosPredictor` with the default configuration and verifying forecast stability across diverse input ranges.

## Summary

- **`clip`** is a numeric hyperparameter in `KronosPredictor` that bounds standardized features to `[-clip, clip]` using `np.clip`.
- **Default value**: `5`, defined in [`model/kronos.py`](https://github.com/shiyu-coder/Kronos/blob/main/model/kronos.py) at line 84 in the `__init__` signature.
- **Purpose**: Prevents extreme outliers from destabilizing autoregressive inference by keeping inputs within the training distribution range.
- **Application**: Enforced in both `predict()` and `predict_batch()` methods immediately after feature standardization.
- **Configuration**: Also referenced in [`finetune/config.py`](https://github.com/shiyu-coder/Kronos/blob/main/finetune/config.py) to ensure training-inference consistency.

## Frequently Asked Questions

### What happens if I set clip to a very large number or disable it?

Setting `clip` to an extremely large value (e.g., `1000`) effectively disables the safeguard. While the code will still execute `np.clip`, outliers will remain unbounded, potentially causing the transformer to generate unrealistic predictions if it encounters values far outside its training distribution. The default of `5` is recommended unless your specific domain requires handling extreme tail events.

### Does the clip parameter affect the training process or only inference?

The `clip` parameter in `KronosPredictor` specifically governs **inference**. However, the [`finetune/config.py`](https://github.com/shiyu-coder/Kronos/blob/main/finetune/config.py) file indicates that the training configuration also uses `clip=5.0` by default, ensuring that the normalization statistics and clipping thresholds remain consistent between training and prediction phases.

### How does clip interact with the tokenizer in Kronos?

The `KronosTokenizer` handles the initial discretization of raw price and volume data into tokens, while `clip` operates on the **normalized numeric features** immediately before they enter the transformer model. The tokenizer processes raw values first; subsequently, the predictor standardizes these representations and applies the clip constraint as a final preprocessing step before the forward pass.

### Can I use different clip values for different features in the same prediction?

Based on the implementation in [`model/kronos.py`](https://github.com/shiyu-coder/Kronos/blob/main/model/kronos.py), `clip` is a **scalar value** applied uniformly to all standardized features. The code uses `np.clip(x, -self.clip, self.clip)` on the entire input array simultaneously. To apply feature-specific clipping, you would need to subclass `KronosPredictor` and override the `predict` or `predict_batch` methods with custom per-column logic.