For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
DASHBOARDPLAYGROUNDDOCSCOMMUNITYLOG IN
Guides and conceptsAPI ReferenceRelease NotesLLMUCookbooks
Guides and conceptsAPI ReferenceRelease NotesLLMUCookbooks
  • Cohere API
    • About
    • Teams and Roles
    • Errors
    • Migrating From API v1 to API v2
    • Using the OpenAI SDK
  • Endpoints
  • Deprecated
      • GETLists fine-tuned models.
      • POSTTrains and deploys a fine-tuned model.
      • PATCHUpdates a fine-tuned model.
      • GETReturns a fine-tuned model by ID.
      • DELDeletes a fine-tuned model.
      • GETFetch history of statuses for a fine-tuned model.
      • GETRetrieve training metrics for fine-tuned models.
LogoLogodocs
DASHBOARDPLAYGROUNDDOCSCOMMUNITYLOG IN
Deprecatedv1/finetuning

Trains and deploys a fine-tuned model.

Deprecated
POST
https://api.cohere.com/v1/finetuning/finetuned-models
POST
/v1/finetuning/finetuned-models
1from cohere.finetuning import (
2 BaseModel,
3 FinetunedModel,
4 Hyperparameters,
5 Settings,
6 WandbConfig,
7)
8import cohere
9
10co = cohere.Client()
11hp = Hyperparameters(
12 early_stopping_patience=10,
13 early_stopping_threshold=0.001,
14 train_batch_size=16,
15 train_epochs=1,
16 learning_rate=0.01,
17)
18wnb_config = WandbConfig(
19 project="test-project",
20 api_key="<<wandbApiKey>>",
21 entity="test-entity",
22)
23finetuned_model = co.finetuning.create_finetuned_model(
24 request=FinetunedModel(
25 name="test-finetuned-model",
26 settings=Settings(
27 base_model=BaseModel(
28 base_type="BASE_TYPE_CHAT",
29 ),
30 dataset_id="my-dataset-id",
31 hyperparameters=hp,
32 wandb=wnb_config,
33 ),
34 )
35)
36print(finetuned_model)
1{
2 "finetuned_model": {
3 "name": "string",
4 "settings": {
5 "base_model": {
6 "base_type": "BASE_TYPE_UNSPECIFIED",
7 "name": "string",
8 "version": "string",
9 "strategy": "STRATEGY_UNSPECIFIED"
10 },
11 "dataset_id": "string",
12 "hyperparameters": {
13 "early_stopping_patience": 1,
14 "early_stopping_threshold": 1.1,
15 "train_batch_size": 1,
16 "train_epochs": 1,
17 "learning_rate": 1.1,
18 "lora_alpha": 1,
19 "lora_rank": 1,
20 "lora_target_modules": "LORA_TARGET_MODULES_UNSPECIFIED"
21 },
22 "multi_label": true,
23 "wandb": {
24 "project": "string",
25 "api_key": "string",
26 "entity": "string"
27 }
28 },
29 "id": "string",
30 "creator_id": "string",
31 "organization_id": "string",
32 "status": "STATUS_UNSPECIFIED",
33 "created_at": "2024-01-15T09:30:00Z",
34 "updated_at": "2024-01-15T09:30:00Z",
35 "completed_at": "2024-01-15T09:30:00Z",
36 "last_used": "2024-01-15T09:30:00Z"
37 }
38}

Creates a new fine-tuned model. The model will be trained on the dataset specified in the request body. The training process may take some time, and the model will be available once the training is complete.

Was this page helpful?
Previous

Updates a fine-tuned model.

Next
Built with

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.

Headers

X-Client-NamestringOptional
The name of the project that is making the request.

Request

Information about the fine-tuned model. Must contain name and settings.

namestringRequired

FinetunedModel name (e.g. foobar).

settingsobjectRequired
FinetunedModel settings such as dataset, hyperparameters...
statusenumOptionalDefaults to STATUS_UNSPECIFIED

read-only. Current stage in the life-cycle of the fine-tuned model.

Response

A successful response.
finetuned_modelobject

Information about the fine-tuned model.

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
404
Not Found Error
500
Internal Server Error
503
Service Unavailable Error