Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Cohere ai Cohere python TrainingStepMetrics

From Leeroopedia
Revision as of 12:18, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Cohere_ai_Cohere_python_TrainingStepMetrics.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains SDK, Fine_Tuning
Last Updated 2026-02-15 14:00 GMT

Overview

The TrainingStepMetrics class represents evaluation metrics captured at a specific step during fine-tuned model training.

Description

TrainingStepMetrics is a Pydantic-based data class that holds metric data for a single training step. It records the step number, when the metrics were captured, and a dictionary mapping metric names to their floating-point values (e.g., loss, accuracy). The class extends UncheckedBaseModel and supports both Pydantic v1 and v2 through a compatibility layer.

Usage

Use this class to monitor and analyze training progress for a fine-tuned model. Instances are typically returned by the API as part of a training job's metrics history, enabling you to track how evaluation metrics evolve over training steps.

Code Reference

Source Location

  • Repository: Cohere Python SDK
  • File: src/cohere/finetuning/finetuning/types/training_step_metrics.py

Signature

class TrainingStepMetrics(UncheckedBaseModel):
    """
    The evaluation metrics at a given step of the training of a fine-tuned model.
    """

    created_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    step_number: typing.Optional[int] = pydantic.Field(default=None)
    metrics: typing.Optional[typing.Dict[str, float]] = pydantic.Field(default=None)

Import

from cohere.finetuning.finetuning.types import TrainingStepMetrics

I/O Contract

Fields

Field Type Required Default Description
created_at typing.Optional[datetime.datetime] No None Creation timestamp for when the metrics were recorded.
step_number typing.Optional[int] No None The training step number at which the metrics were captured.
metrics typing.Optional[Dict[str, float]] No None Map of metric names to their values for this training step (e.g., {"loss": 0.42, "accuracy": 0.87}).

Usage Examples

Inspecting training step metrics

from cohere.finetuning.finetuning.types import TrainingStepMetrics
from datetime import datetime

# Typically returned from the API as part of training progress
step_metrics = TrainingStepMetrics(
    created_at=datetime(2026, 2, 15, 11, 0, 0),
    step_number=500,
    metrics={"loss": 0.32, "accuracy": 0.91},
)

print(step_metrics.step_number)          # 500
print(step_metrics.metrics["loss"])      # 0.32
print(step_metrics.metrics["accuracy"])  # 0.91
print(step_metrics.created_at)           # 2026-02-15 11:00:00

Iterating over multiple training steps

from cohere.finetuning.finetuning.types import TrainingStepMetrics

# Assume steps is a list of TrainingStepMetrics returned from the API
steps = [
    TrainingStepMetrics(step_number=100, metrics={"loss": 1.05}),
    TrainingStepMetrics(step_number=200, metrics={"loss": 0.72}),
    TrainingStepMetrics(step_number=300, metrics={"loss": 0.45}),
]

for step in steps:
    print(f"Step {step.step_number}: loss={step.metrics['loss']}")
# Step 100: loss=1.05
# Step 200: loss=0.72
# Step 300: loss=0.45

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment