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 FinetunedModel Settings

From Leeroopedia
Field Value
Type Implementation
Source Cohere Python SDK
Domain Fine-tuning Model Training Configuration
Last Updated 2026-02-15
Implements Principle:Cohere_ai_Cohere_python_Finetuning_Configuration

Overview

Concrete Pydantic models for configuring Cohere fine-tuning jobs with model, data, and hyperparameter settings.

Description

Three nested models: FinetunedModel (top-level with name, settings, status), Settings (base_model, dataset_id, hyperparameters, wandb), and Hyperparameters (early_stopping_patience/threshold, train_batch_size, train_epochs, learning_rate, lora_alpha, lora_rank, lora_target_modules).

Code Reference

  • src/cohere/finetuning/finetuning/types/finetuned_model.py Lines L1-74
  • src/cohere/finetuning/finetuning/types/settings.py Lines L1-49
  • src/cohere/finetuning/finetuning/types/hyperparameters.py Lines L1-66

Signature

class FinetunedModel(UncheckedBaseModel):
    name: str
    settings: Settings
    status: typing.Optional[Status] = None
    ...

class Settings(UncheckedBaseModel):
    base_model: BaseModel
    dataset_id: str
    hyperparameters: typing.Optional[Hyperparameters] = None
    multi_label: typing.Optional[bool] = None
    wandb: typing.Optional[WandbConfig] = None

class Hyperparameters(UncheckedBaseModel):
    early_stopping_patience: typing.Optional[int] = None
    early_stopping_threshold: typing.Optional[float] = None
    train_batch_size: typing.Optional[int] = None
    train_epochs: typing.Optional[int] = None
    learning_rate: typing.Optional[float] = None
    lora_alpha: typing.Optional[int] = None
    lora_rank: typing.Optional[int] = None
    lora_target_modules: typing.Optional[LoraTargetModules] = None

Import

from cohere.finetuning.finetuning.types import FinetunedModel, Settings, Hyperparameters, BaseModel, BaseType

Inputs

Parameter Type Required Description
name str Yes Name for the fine-tuned model
base_model BaseModel Yes Base model with base_type (e.g., BASE_TYPE_CHAT)
dataset_id str Yes ID of the uploaded dataset
hyperparameters Optional[Hyperparameters] No Training hyperparameters (epochs, LR, LoRA settings)

Outputs

Configured FinetunedModel object for submission to the fine-tuning API.

Example

from cohere.finetuning.finetuning.types import (
    FinetunedModel, Settings, Hyperparameters, BaseModel, BaseType
)
model_config = FinetunedModel(
    name="my-custom-model",
    settings=Settings(
        base_model=BaseModel(base_type=BaseType.BASE_TYPE_CHAT),
        dataset_id="dataset-id-here",
        hyperparameters=Hyperparameters(
            train_epochs=3,
            learning_rate=0.01,
            lora_rank=16,
            lora_alpha=32,
        ),
    ),
)

Related

Page Connections

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