> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Mean tokens

> Learn how to use the mean tokens test

## Definition

The mean tokens test ensures that the mean number of tokens in the data is within a given range.

## Taxonomy

* **Task types**: LLM.
* **Availability**: development (Continuously evaluate your models and datasets as you iterate on their versions.)
  and monitoring (Monitor a model in production, measure its health, check for drifts and set up alerts.).

## Why it matters

* Depending on the application you are building, you might want to limit the number of tokens generated by the LLM.
* LLMs have a limited context window, so it is important to ensure that the number of tokens in the data is within the context window capacity.

## Test configuration examples

If you are writing a `tests.json`, here are a few valid configurations for the character length test:

```json Development theme={null}
[
  {
    "name": "Mean number of tokens below 1500",
    "description": "Make sure that the average response has less than 1500 tokens",
    "type": "performance",
    "subtype": "metricThreshold",
    "thresholds": [
      {
        "insightName": "metrics",
        "measurement": "meanTokens",
        "operator": "<",
        "value": 1500
      }
    ],
    "subpopulationFilters": null,
    "mode": "development",
    "usesValidationDataset": true,
    "usesTrainingDataset": false,
    "usesMlModel": true,
    "syncId": "b4dee7dc-4f15-48ca-a282-63e2c04e0689"
  }
]
```

```json Monitoring theme={null}
[
  {
    "name": "Mean number of tokens below 1500",
    "description": "Make sure that the average response has less than 1500 tokens",
    "type": "performance",
    "subtype": "metricThreshold",
    "thresholds": [
      {
        "insightName": "metrics",
        "measurement": "meanTokens",
        "operator": "<",
        "value": 1500
      }
    ],
    "subpopulationFilters": null,
    "mode": "monitoring",
    "usesProductionData": true,
    "evaluationWindow": 3600,
    "delayWindow": 0,
    "syncId": "b4dee7dc-4f15-48ca-a282-63e2c04e0689"
  }
]
```

## Related

* [Max tokens test](https://docs.openlayer.com/tests/performance/max-tokens).
* [Total tokens test](https://docs.openlayer.com/tests/performance/total-tokens).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.