Fine Tuning

Fine-tuning a model refers to the process of taking a pre-trained machine learning model and further training it on a specific task or dataset to adapt it to the nuances of that particular domain. The term is commonly used in the context of transfer learning, where a model trained on a large and diverse dataset (pre-training) is adjusted to perform a specific task or work with a specific dataset (fine-tuning).

List of SKU

To get the list of SKU, send a GET request to the Finetuning Endpoint

https://api.e2enetworks.com/myaccount/api/v1/gpu/gpu_service/sku/?apikey={{tapi_key}}&image_id=&service=pipeline
import requests

url = "https://api.e2enetworks.com/myaccount/api/v1/gpu/gpu_service/sku/?apikey={{tapi_key}}&image_id=&service=pipeline"

payload={}
headers = {
    'Authorization': 'Bearer {{Token}}',
    'Content-Type': 'application/json',
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

List of Model

To get the list of Models, send a GET request to the Finetuning Endpoint

https://api.e2enetworks.com/myaccount/api/v1/gpu/projects/{{project_id}}/finetuning/model_types/?apikey={{tapi_key}}
import requests

url = "https://api.e2enetworks.com/myaccount/api/v1/gpu/projects/{{project_id}}/finetuning/model_types/?apikey={{tapi_key}}"

payload={}
headers = {
    'Authorization': 'Bearer {{Token}}',
    'Content-Type': 'application/json',
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

List of Fine Tuning Jobs

To get the list of Fine Tuning Jobs, send a GET request to the Finetuning Endpoint

https://api.e2enetworks.com/myaccount/api/v1/gpu/projects/{{project_id}}/finetuning/?apikey={{tapi_key}}&page_no=1&per_page=5
import requests

url = "https://api.e2enetworks.com/myaccount/api/v1/gpu/projects/{{project_id}}/finetuning/?apikey={{tapi_key}}&page_no=1&per_page=5"

payload={}
headers = {
    'Authorization': 'Bearer {{Token}}',
    'Content-Type': 'application/json',
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

Launch Finetune Job

To launch the FineTune Job, send a POST request to the Finetuning Endpoint

https://api.e2enetworks.com/myaccount/api/v1/gpu/projects/{{project_id}}/finetuning/?apikey={{tapi_key}}
import requests
import json

url = "https://api.e2enetworks.com/myaccount/api/v1/gpu/projects/{{project_id}}/finetuning/?apikey={{tapi_key}}"

payload = json.dumps({
"name": "tir-finetuning-070818181818",
"training_type": "Peft",
"training_inputs": {
    "source_repository_type": "base_model",
    "dataset": "MatthewWaller/cifar_stable_diffusion",
    "dataset_type": "huggingface",
    "validation_split_ratio": 0.1,
    "target_dataset_field": "text",
    "gradient_accumulation_steps": 1,
    "context_length": 512,
    "learning_rate": 0.0000141,
    "epochs": 3,
    "stop_training_when": "epoch_count",
    "max_steps": -1,
    "batch_size": 4,
    "peft_lora_alpha": 16,
    "peft_lora_r": 64,
    "max_grad_norm": 1,
    "save_strategy": "steps",
    "save_steps": 500,
    "save_total_limit": 10,
    "lora_dropout": 0.05,
    "lora_bias": "none",
    "load_in_4bit": False,
    "bnb_4bit_compute_dtype": "bfloat16",
    "bnb_4bit_quant_type": "fp4",
    "bnb_4bit_use_double_quant": False,
    "task": "Instruction-Finetuning",
    "prompt_configuration": "Below is an instruction that describes a task. Write a response that appropriately completes the request.  \n\n###Instruction image:[replace with image column]\n    \n###Text context:[replace with column for context text]"
},
"isClone": False,
"model_name": "stabilityai/stable-diffusion-2-1",
"huggingface_integration_id": 170,
"sku_item_price_id": 548
})
headers = {
    'Authorization': 'Bearer {{Token}}',
    'Content-Type': 'application/json',
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...
{
"name": "tir-finetuning-070818181818",
"training_type": "Peft",
"training_inputs": {
    "source_repository_type": "base_model",
    "dataset": "MatthewWaller/cifar_stable_diffusion",
    "dataset_type": "huggingface",
    "validation_split_ratio": 0.1,
    "target_dataset_field": "text",
    "gradient_accumulation_steps": 1,
    "context_length": 512,
    "learning_rate": 0.0000141,
    "epochs": 3,
    "stop_training_when": "epoch_count",
    "max_steps": -1,
    "batch_size": 4,
    "peft_lora_alpha": 16,
    "peft_lora_r": 64,
    "max_grad_norm": 1,
    "save_strategy": "steps",
    "save_steps": 500,
    "save_total_limit": 10,
    "lora_dropout": 0.05,
    "lora_bias": "none",
    "load_in_4bit": false,
    "bnb_4bit_compute_dtype": "bfloat16",
    "bnb_4bit_quant_type": "fp4",
    "bnb_4bit_use_double_quant": false,
    "task": "Instruction-Finetuning",
    "prompt_configuration": "Below is an instruction that describes a task. Write a response that appropriately completes the request.  \n\n###Instruction image:[replace with image column]\n    \n###Text context:[replace with column for context text]"
},
"isClone": false,
"model_name": "stabilityai/stable-diffusion-2-1",
"huggingface_integration_id": 170,
"sku_item_price_id": 548
}

Retry Fine Tune Job

To retry the Fine Tune Job, send a PUT request to the Finetuning Endpoint

https://api.e2enetworks.com/myaccount/api/v1/gpu/projects/{{project_id}}/finetuning/{{finetuning_id}}/?apikey={{tapi_key}}&action=retry
import requests

url = "https://api.e2enetworks.com/myaccount/api/v1/gpu/projects/{{project_id}}/finetuning/{{finetuning_id}}/?apikey={{tapi_key}}&action=retry"

payload={}
headers = {
        'Authorization': 'Bearer {{Token}}',
        'Content-Type': 'application/json',
}

response = requests.request("PUT", url, headers=headers, data=payload)

print(response.text)
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

Terminate Fine Tune Job

To terminate the Fine TUne Job, send a PUT request to the Finetuning Endpoint

https://api.e2enetworks.com/myaccount/api/v1/gpu/projects/{{project_id}}/finetuning/{{finetuning_id}}/?apikey={{tapi_key}}&action=terminate
import requests

url = "https://api.e2enetworks.com/myaccount/api/v1/gpu/projects/{{project_id}}/finetuning/{{finetuning_id}}/?apikey={{tapi_key}}&action=terminate"

payload={}
headers = {
    'Authorization': 'Bearer {{Token}}',
    'Content-Type': 'application/json',
}

response = requests.request("PUT", url, headers=headers, data=payload)

print(response.text)
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...

Delete Fine Tune Job

To delete the Fine Tune Job, send a DELETE request to the Finetuning Endpoint

https://api.e2enetworks.com/myaccount/api/v1/gpu/projects/{{project_id}}/finetuning/{{finetunning_id}}/?apikey={{tapi_key}}
import requests

url = "https://api.e2enetworks.com/myaccount/api/v1/gpu/projects/{{project_id}}/finetuning/{{finetunning_id}}/?apikey={{tapi_key}}"

payload={}
headers = {
    'Authorization': 'Bearer {{Token}}',
    'Content-Type': 'application/json',
}

response = requests.request("DELETE", url, headers=headers, data=payload)

print(response.text)
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAi...