AI Studio Model Fine-Tuning Guide
In this step-by-step guide, you'll learn how to fine-tune a base language model in Hyperstack AI Studio by walking through a simple example: creating a model that can accurately answer customer service questions about Hyperstack and AI Studio. Using a small dataset of prompt–response pairs, you'll teach the model domain-specific knowledge it doesn’t have by default.
This tutorial is a low-cost demonstration that costs less than $1 to complete (see cost details) and is intended for learning purposes only. The dataset is intentionally minimal to keep costs down, making it useful for illustrating the fine-tuning process but too small for optimal production performance. By the end, you'll have a fine-tuned model ready for deployment and testing in the AI Studio Playground. You’ll also be prepared to train your own model using your datasets for your specific use cases.
In this article
About The Example Training Data
The example training data used in this guide is a .jsonl
file containing 15 prompt-response pairs, each formatted as a message
object. Each entry simulates a short interaction where the user asks a question about Hyperstack or AI Studio and the assistant provides a relevant answer. The purpose of this dataset is to train the model to behave like a knowledgeable assistant that understands Hyperstack's terminology, features, and services. This is something the original base model cannot do before fine-tuning.
Below is one sample entry from the training data. For readability, it's displayed across multiple lines—but keep in mind that all records in your .jsonl
file must be on a single line, as required by the JSONL File Format guidelines:
{
"messages": [
{
"role": "user",
"content": "What is Hyperstack AI Studio?"
},
{
"role": "assistant",
"content": "Hyperstack AI Studio offers a suite of services including fine-tuning, evaluation, playground, and inference to support developers in building powerful AI Studio applications."
}
]
}
Each log in the training data contains a messages
object which simulates a conversation between different roles (user, assistant, and system). Each message includes the following fields:
role
: Defines the purpose of the text prompt. There are three distinct roles:user
: Represents the prompt or question from a human user.assistant
: Represents the expected response from the model.system
: (Not used in this dataset) Provides instructions or context to guide the assistant’s behavior. Useful for defining tone, style, or behavior, such as "You are a helpful support agent."
content
: A required string field present in all message objects. It contains the actual text for the message—whether it's the user’s query, the assistant’s reply, or the system's instructions.
Fine-Tuning a Model in AI Studio
Before you begin, make sure you have a Hyperstack account, added credits to your account, and access to AI Studio. For setup instructions, see Before Getting Started.
To fine-tune a model in Hyperstack AI Studio, follow these steps:
-
Upload Training Data
You can upload logs directly through the AI Studio UI using the following steps:
-
a. Open the Data Page
- In Hyperstack AI Studio, navigate to the Logs & Datasets page.
-
b. Upload Your
.jsonl
File-
Click here to download the example dataset used in this tutorial
-
After downloading, click the Upload Logs button in the top-right corner, then either select the
.jsonl
file you downloaded or drag and drop it into the upload area.
-
-
c. Add Tags and Upload
-
Enter at least one tag to help categorize your logs (e.g.,
customer-service
). -
Click Validate & Upload.
The system will automatically check your file format and structure, then upload the logs if validation succeeds.
-
-
-
Start a New Fine-Tuning Job
Go to the My Models page and click the Fine-Tune a Model button in the top-right corner.
-
Configure Basic Settings
Fine-Tuning Cost DetailsThe less than $1 cost applies only when using the example dataset provided in this guide, fine-tuning the Llama 3.1 8B or Mistral Small 24B base models, and using default hyperparameters. Actual costs may vary if you use a different dataset, model, or training configuration.
- Model Name – Enter a unique name for your fine-tuned model.
- Base Model – Select one of the available base models to fine-tune.
-
Select Training Data
Choose the source of logs to use for training:
- All Logs – Use all logs in your account.
- By Tags – Select logs that have specific tags.
- By Dataset – Select logs from an existing dataset.
- Upload Logs – Upload new logs for this training run. You can choose to save these logs with custom tags or not save them at all. Ensure your logs meet the required file format as outlined in the JSONL File Format guidelines.
Context and Sequence Length LimitEach training example (prompt + expected response) must fit within the training sequence length limit of 2048 tokens. After deployment, the fine-tuned model supports up to 8192 tokens for inference conversations.
-
Adjust Advanced Settings (Optional)
To customize training hyperparameters, click Advanced Settings and adjust the values as needed. If no changes are made, the default values will be applied.
Parameter Description Default Value Epochs Number of training epochs, where one epoch is a full pass through the dataset. 3
Batch Size Number of samples per training batch, with larger batches reducing update frequency but providing more stable gradients. 4
Learning Rate Learning rate for scaling parameter updates, where smaller values can help prevent overfitting and improve convergence. 0.0004
LoRA Rank (r) Rank of the LoRA (Low-Rank Adaptation) matrices, determining the number of trainable parameters in the adaptation layers. 32
LoRA Alpha Scaling factor for LoRA that adjusts the impact of LoRA parameters on the final model. 64
LoRA Dropout Dropout rate applied to LoRA layers to prevent overfitting by randomly disabling parts of the adaptation layer during training. 0.05
Warmup Steps Initial steps where the learning rate increases gradually from a small value to the target rate for stable training. 10
-
Start Training
Review your selected configuration and click Create to begin training. The following will occur:
- Validation – Logs are checked and filtered. Invalid logs will be skipped.
- Training Begins – The system allocates resources and initiates the fine-tuning job. You will see a "Fine-tuning job is being created" status message.
Click View Model Details to get an overview of the training progress, including training status, training loss over time, and cost per million tokens. For more detailed metrics, click Training Metrics as described in the next step.
You can click Cancel Training to end the fine-tuning at any time.
Fine-Tuning DurationTraining time varies depending on your dataset and model complexity. You can track progress in real time through the UI.
-
Review Training Results
From the model details page, click Training Metrics to access detailed insights, including training loss, validation loss, performance comparison (start vs. end of fine-tuning), overall model performance (loss), and more.
See Training Metrics documentation for more details on reviewing and interpreting results from training runs.
The Training Metrics shown above display clear improvement in model performance as a result of fine-tuning:
- Training Loss dropped from 2.577 to 0.361, and Validation Loss decreased from 2.641 to 1.616, indicating the model is learning and generalizing better on unseen data.
- The line chart shows training loss steadily decreasing over successive steps, confirming consistent learning throughout the process.
FAQs on Interpreting Training Results
Below are common questions and answers to help you evaluate and troubleshoot your fine-tuning results. Use these as a reference when reviewing your training and validation metrics in the model details page.
Q: How can I tell if my model is healthy?
A: Healthy learning curves typically show:
- A smooth, steady decline in both training and validation loss.
- A small gap between training and validation performance.
- Clear convergence without large fluctuations.
Q: My loss curve is erratic with no clear trend. How can I fix this?
A: Erratic curves often indicate the learning rate is too high or the batch size is too small. Try lowering the learning rate, increasing the batch size, and ensuring your training data is clean and consistent.
Q: My training loss decreased, but validation loss increased. What’s happening?
A: This is a classic sign of overfitting: the model is memorizing the training data instead of generalizing. Possible solutions include:
- Lower the rank (r): Reduces model capacity to help avoid overfitting.
- Increase LoRA dropout: Adds regularization by randomly zeroing parts of the LoRA matrices.
- Reduce alpha (α): Lowers the scaling factor to temper LoRA influence, especially effective when paired with a reduced rank.
- Increase dataset size or apply augmentation: More diverse examples reduce the tendency to overfit.
Q: Both my training and validation losses are high. What does this mean?
A: This usually signals underfitting: the model isn’t learning the patterns in the data. You can try:
- Increase the rank (r): Adds more trainable parameters for learning complex patterns.
- Increase alpha (α): Strengthens LoRA influence, often set to about 2× the rank.
- Train for more epochs: Give the model more time to learn, especially if loss is still decreasing.
- Expand or diversify the dataset: More and varied data improve representation learning and reduce underfitting.
For additional tips on reading training curves and diagnosing common model performance issues, see the Hugging Face LLM Course – Understanding Learning Curves.
-
Deploy The Fine-Tuned Model
Once training is complete, the model status will update to Ready To Deploy.
Click the Status toggle to deploy your fine-tuned model. The status will briefly show Deploying before updating to Deployed once the process is complete.
-
Testing The Model in The Playground
After the fine-tuned model has been successfully deployed, use the Playground in Hyperstack AI Studio to interact with it in a conversational interface. You can customize prompts, adjust generation parameters, and compare models side-by-side.
To use the AI Studio Playground feature, follow these steps:
-
a. Navigate to the Playground page from the Hyperstack AI Studio.
-
b. Click the Model dropdown menu and select the fine-tuned model you’ve trained and deployed (e.g. test-model-123).
-
c. (Optional) Adjust Advanced Parameters to customize the models' generation behavior (not used in this example)
Click here to see details about Advanced Parameters
Adjust the model’s generation behavior using the sliders and fields shown below. If you don’t modify a parameter, the default value shown in the table will be used.
Parameter Description Default Value Value Range Max Tokens Limits the maximum number of tokens in the model’s response. Combined with the input, the total must stay within the model's 8192 token context limit. null
1–4095
Temperature Controls randomness in the model’s output. Lower values (e.g. 0.1
) produce more focused, deterministic responses, while higher values (e.g.0.9
) produce more creative or varied outputs.1.0
0.0–2.0
Top-P Enables nucleus sampling by restricting token selection to a subset with cumulative probability ≤ top_p
.null
0.0–1.0
Top-K Limits token sampling to the top K
most likely options.-1
-1–200
Presence Penalty Penalizes tokens based on whether they appear in the prompt. Higher values encourage the model to introduce new concepts. 0.0
-2.0–2.0
Repetition Penalty Penalizes repeated tokens in the model’s output. Higher values reduce the likelihood of repeating the same phrases. 1.0
0.01–2.0
-
d. Type your query into the text input box and hit Enter to get a response.
Context and Sequence Length LimitEach training example (prompt + expected response) must fit within the training sequence length limit of 2048 tokens. After deployment, the fine-tuned model supports up to 8192 tokens for inference conversations.
The model will return a response in a conversational style, as shown below. In this example, the fine-tuned model successfully answers a question about Hyperstack and AI Studio based on what it learned during fine-tuning.
To compare the fine-tuned model against its base model, click Compare Side-by-Side, a feature that enables you to test both models' outputs using the same prompt.
- a. Select the two models from the dropdowns.
- b. Enter your prompt. (e.g. What is the AI Studio Playground?)
- c. View and compare both outputs side-by-side in real time.
As shown above, after testing the fine-tuned model against its base model Mistral Small 24B Instruct 2501 using the side-by-side comparison feature, the improvement in performance is clear. The fine-tuned model provides a specific and accurate answer about Hyperstack services, while the base model fails to do so.
Playground via APIYou can also enable API mode in the AI Studio Playground to view the cURL command that can be used to integrate the completions API with your business application. To do this, toggle the API option in the Playground interface, as shown below. For full API usage details, see the Model Inference API reference.
-
Conclusion and Next Steps
In this guide, we fine-tuned a base model with a small domain-specific dataset, resulting in a custom model that delivers more relevant responses in Playground testing. This walkthrough serves as a practical template for fine-tuning and deploying your own custom models in AI Studio.
Here’s what we accomplished:
- Uploaded and prepared training data
- Fine-tuned a base model with that dataset
- Deployed the resulting custom model
- Tested its performance in the AI Studio Playground
You’re now ready to apply the same process to your own datasets and fine-tune models tailored to your specific use cases.