Australia/Sydney
BlogMay 2, 2024

Fine-Tune Command R+ Model on Your Own Data Locally

Fahd Mirza

 This video is a simple hands-on tutorial to show how to do fine-tuning of Command R+ model from cohere locally by using your own data.


Code:

#pip install cohere
import os
import cohere
from cohere.finetuning import (
    BaseModel,
    BaseType,
    FinetunedModel,
    Settings,
)


api_key = os.getenv('COHERE_API_KEY')
co = cohere.Client(api_key)

# create a dataset
single_label_dataset = co.datasets.create(name="single-label-dataset",
                                         data=open("train.csv", "rb"),
                                         type="single-label-classification-finetune-input")

#print(co.wait(single_label_dataset))

datasetid=single_label_dataset.id

finetuned_model = co.finetuning.create_finetuned_model(
    request=FinetunedModel(
        name="test-finetuned-model",
        settings=Settings(
            base_model=BaseModel(
                base_type="BASE_TYPE_CLASSIFICATION",
            ),
            dataset_id=datasetid,
        ),
    )
)
print(finetuned_model)


Share this post:
On this page

Let's Partner

If you are looking to build, deploy or scale AI solutions — whether you're just starting or facing production-scale challenges — let's chat.

Subscribe to Fahd's Newsletter

Weekly updates on AI, cloud engineering, and tech innovations