Fine-tune a model
curl --request POST \
--url https://api-dev.narrative.io/model-training/run \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"base_model_id": 57,
"dataset_id": 10736,
"training_config": {
"instance_type": "ml.g5.12xlarge"
},
"output_model": {
"name": "churn-predictor",
"collaborators": {
"view": {
"type": "none"
},
"train": {
"type": "none"
},
"deploy": {
"type": "none"
}
}
}
}
'import requests
url = "https://api-dev.narrative.io/model-training/run"
payload = {
"base_model_id": 57,
"dataset_id": 10736,
"training_config": { "instance_type": "ml.g5.12xlarge" },
"output_model": {
"name": "churn-predictor",
"collaborators": {
"view": { "type": "none" },
"train": { "type": "none" },
"deploy": { "type": "none" }
}
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
base_model_id: 57,
dataset_id: 10736,
training_config: {instance_type: 'ml.g5.12xlarge'},
output_model: {
name: 'churn-predictor',
collaborators: {view: {type: 'none'}, train: {type: 'none'}, deploy: {type: 'none'}}
}
})
};
fetch('https://api-dev.narrative.io/model-training/run', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-dev.narrative.io/model-training/run",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'base_model_id' => 57,
'dataset_id' => 10736,
'training_config' => [
'instance_type' => 'ml.g5.12xlarge'
],
'output_model' => [
'name' => 'churn-predictor',
'collaborators' => [
'view' => [
'type' => 'none'
],
'train' => [
'type' => 'none'
],
'deploy' => [
'type' => 'none'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-dev.narrative.io/model-training/run"
payload := strings.NewReader("{\n \"base_model_id\": 57,\n \"dataset_id\": 10736,\n \"training_config\": {\n \"instance_type\": \"ml.g5.12xlarge\"\n },\n \"output_model\": {\n \"name\": \"churn-predictor\",\n \"collaborators\": {\n \"view\": {\n \"type\": \"none\"\n },\n \"train\": {\n \"type\": \"none\"\n },\n \"deploy\": {\n \"type\": \"none\"\n }\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-dev.narrative.io/model-training/run")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"base_model_id\": 57,\n \"dataset_id\": 10736,\n \"training_config\": {\n \"instance_type\": \"ml.g5.12xlarge\"\n },\n \"output_model\": {\n \"name\": \"churn-predictor\",\n \"collaborators\": {\n \"view\": {\n \"type\": \"none\"\n },\n \"train\": {\n \"type\": \"none\"\n },\n \"deploy\": {\n \"type\": \"none\"\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/model-training/run")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"base_model_id\": 57,\n \"dataset_id\": 10736,\n \"training_config\": {\n \"instance_type\": \"ml.g5.12xlarge\"\n },\n \"output_model\": {\n \"name\": \"churn-predictor\",\n \"collaborators\": {\n \"view\": {\n \"type\": \"none\"\n },\n \"train\": {\n \"type\": \"none\"\n },\n \"deploy\": {\n \"type\": \"none\"\n }\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"job_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"error": "Unauthorized",
"error_description": "You are not authorized to use this endpoint."
}Model Training
Fine-tune a model
Create a job that fine-tunes a base model on a dataset. The trained model is saved under output_model.name;
if the caller already has a model with that name, the run produces its next version.
POST
/
model-training
/
run
Fine-tune a model
curl --request POST \
--url https://api-dev.narrative.io/model-training/run \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"base_model_id": 57,
"dataset_id": 10736,
"training_config": {
"instance_type": "ml.g5.12xlarge"
},
"output_model": {
"name": "churn-predictor",
"collaborators": {
"view": {
"type": "none"
},
"train": {
"type": "none"
},
"deploy": {
"type": "none"
}
}
}
}
'import requests
url = "https://api-dev.narrative.io/model-training/run"
payload = {
"base_model_id": 57,
"dataset_id": 10736,
"training_config": { "instance_type": "ml.g5.12xlarge" },
"output_model": {
"name": "churn-predictor",
"collaborators": {
"view": { "type": "none" },
"train": { "type": "none" },
"deploy": { "type": "none" }
}
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
base_model_id: 57,
dataset_id: 10736,
training_config: {instance_type: 'ml.g5.12xlarge'},
output_model: {
name: 'churn-predictor',
collaborators: {view: {type: 'none'}, train: {type: 'none'}, deploy: {type: 'none'}}
}
})
};
fetch('https://api-dev.narrative.io/model-training/run', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-dev.narrative.io/model-training/run",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'base_model_id' => 57,
'dataset_id' => 10736,
'training_config' => [
'instance_type' => 'ml.g5.12xlarge'
],
'output_model' => [
'name' => 'churn-predictor',
'collaborators' => [
'view' => [
'type' => 'none'
],
'train' => [
'type' => 'none'
],
'deploy' => [
'type' => 'none'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-dev.narrative.io/model-training/run"
payload := strings.NewReader("{\n \"base_model_id\": 57,\n \"dataset_id\": 10736,\n \"training_config\": {\n \"instance_type\": \"ml.g5.12xlarge\"\n },\n \"output_model\": {\n \"name\": \"churn-predictor\",\n \"collaborators\": {\n \"view\": {\n \"type\": \"none\"\n },\n \"train\": {\n \"type\": \"none\"\n },\n \"deploy\": {\n \"type\": \"none\"\n }\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-dev.narrative.io/model-training/run")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"base_model_id\": 57,\n \"dataset_id\": 10736,\n \"training_config\": {\n \"instance_type\": \"ml.g5.12xlarge\"\n },\n \"output_model\": {\n \"name\": \"churn-predictor\",\n \"collaborators\": {\n \"view\": {\n \"type\": \"none\"\n },\n \"train\": {\n \"type\": \"none\"\n },\n \"deploy\": {\n \"type\": \"none\"\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/model-training/run")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"base_model_id\": 57,\n \"dataset_id\": 10736,\n \"training_config\": {\n \"instance_type\": \"ml.g5.12xlarge\"\n },\n \"output_model\": {\n \"name\": \"churn-predictor\",\n \"collaborators\": {\n \"view\": {\n \"type\": \"none\"\n },\n \"train\": {\n \"type\": \"none\"\n },\n \"deploy\": {\n \"type\": \"none\"\n }\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"job_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"error": "Unauthorized",
"error_description": "You are not authorized to use this endpoint."
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Id of the model to fine-tune. The model must be active and available to the caller for training.
Id of the dataset to train on.
What the run publishes.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Where to deliver the trained model once training finishes. Each profile must be an enabled profile of an installed model connector app.
Show child attributes
Show child attributes
Response
OK
Id of the created training job. Poll the jobs API for status and results.
Was this page helpful?

