Training your first custom model

In this guide we will walk you through training your own custom model.

These are the steps for you to build your custom model.

Creating your custom model

We will utilize a dataset we have already created for you.

curl --location '<https://api.hume.ai/v0/batch/jobs/tl/train'>  
--header 'X-Hume-Api-Key: <YOUR API KEY>'  
--header 'Content-Type: application/json'  
--data '{  
  "custom_model": {  
    "name": "Negative, Neutral, & Positive Facial Expressions",  
    "description": "Is Facial Expression Negative, Neutral or Positive"  
  },  
  "dataset": {  
    "id": "ef7955ce-1755-4942-8615-bc16e654e7e5"  
  },  
  "target_feature": "Affect",  
  "task": {  
    "type": "classification"  
  }  
}'

You will receive a response

{  
  "job_id": "<JOB ID>"  
}

Let's check the status of our training job

We will use this endpoint Get Job Details to get the status of our job

curl --location --globoff '<https://api.hume.ai/v0/batch/jobs/<JOB ID>'  
--header 'X-Hume-Api-Key: <YOUR API KEY>'

We will be paying attention to the state field and once complete it will look like this:

{  
  "type": "TRAINING",  
  "job_id": "<JOB ID>",  
  "user_id": "<USER ID>",  
  "request": {  
    "custom_model": {  
      "name": "Negative, Neutral, & Positive Facial Expressions",  
      "description": "Is Facial Expression Negative, Neutral or Positive",  
     },  
    "dataset": {  
      "id": "ef7955ce-1755-4942-8615-bc16e654e7e5"  
    },  
    "target_feature": "interaction",  
    "task": {  
      "type": "classification"  
    }  
  },  
  "state": {  
    "status": "COMPLETED",  
    "created_timestamp_ms": 42,  
    "started_timestamp_ms": 32,  
    "ended_timestamp_ms": 23,  
 		 "custom_model": {  
			"id": <CUSTOM MODEL ID>"  
  		}  
  	}  
}

Test your custom model

Your custom model is ready to use!

The structure of the file will look very similar to running a job on our platform.

curl --location 'https://api.hume.ai/v0/batch/jobs/tl/inference' \
--header 'X-Hume-Api-Key: <YOUR API KEY>' \
--header 'Content-Type: application/json' \
--data '{
  "custom_model": {
    "id": "<CUSTOM MODEL ID>"
  },
  "urls": ["<URL TO FILE TO TEST>"]
 }'

Response

{  
  "job_id": "<JOB ID>"  
}

Check if the job is done

curl --location --globoff '<https://api.hume.ai/v0/batch/jobs/<JOB ID>'  
--header 'X-Hume-Api-Key: <YOUR API KEY>'

Again here we will look for the complete status

{
  "type": "INFERENCE",
  "job_id": "<JOB ID>",
  "user_id": "<YOUR USER ID>",
  "request": { },
  "state": {
    "status": "COMPLETE",
    "created_timestamp_ms": 42
  }
}

With our final step looking at the results we got.

Get Job Predictions

curl --request GET  
     --url <https://api.hume.ai/v0/batch/jobs/>\<JOB_ID>/predictions  
     --header 'X-Hume-Api-Key: \<YOUR_API_KEY>'  
     --header 'accept: application/json; charset=utf-8'

What’s Next

Creating Datasets