Skip to content

TotalTokens metric

Bases: LMOperationalMetric

Cumulated total tokens (input + output) for this run.

Example:

program.compile(
    metrics=[
        synalinks.metrics.TotalTokens(),
    ],
)
Source code in synalinks/src/metrics/lm_metrics.py
@synalinks_export("synalinks.metrics.TotalTokens")
class TotalTokens(LMOperationalMetric):
    """Cumulated total tokens (input + output) for this run.

    Example:

    ```python
    program.compile(
        metrics=[
            synalinks.metrics.TotalTokens(),
        ],
    )
    ```
    """

    def __init__(self, name="total_tokens"):
        super().__init__(name=name)

    def result(self):
        return int(self._delta("tokens"))