This guide will walk you through the complete process of preparing a dataset, fine-tuning a language model using LLaMA-Factory, and making it available for use with Ollama, all orchestrated through the main dashboard.
Before you can fine-tune, you need a dataset in the correct format and the base model.
A. Create Your JSONL Dataset
LLaMA-Factory requires datasets to be in JSONL format, where each line is a separate JSON object.
- Option 1: Use
easy-dataset(Recommended for new datasets)- Launch the services (
docker compose up). - Open the main dashboard and click the link to the
easy-datasetUI. - Use its interface to create, label, and export your dataset. Ensure it is saved in the
shared_datadirectory.
- Launch the services (
B. Register Your Dataset
To make your dataset visible in the LLaMA-Factory UI, you must add an entry for it in the data/dataset_info.json file.
- Open the
data/dataset_info.jsonfile. - Add a new JSON object for your dataset. The key will be the name that appears in the UI.
C. Obtain the Base Model
You have two options to get the base model:
-
Option 1: Direct Download in LLaMA-Factory (Recommended)
- Launch the services (
docker compose up). - Open the LLaMA-Factory UI.
- In the "Model name" field, enter the full Hugging Face repository ID (e.g.,
unsloth/llama-3-8b-instruct-bnb-4bit). - LLaMA-Factory will attempt to download the model directly.
- If this fails due to network issues or repository access problems, proceed to Option 2.
- Launch the services (
-
Option 2: Manual
git clone(Fallback) To ensure a reliable workflow and avoid network issues, you can manually download the model.- Open a terminal in the project's root directory.
- Run the following
gitcommand to clone the model into the./modelsdirectory:git clone https://huggingface.co/unsloth/llama-3-8b-instruct-bnb-4bit models/unsloth/llama-3-8b-instruct-bnb-4bit
With the data and model ready, start the entire application stack.
- In your terminal, run:
docker compose up --build -d
- Open your web browser and navigate to the main orchestration dashboard (usually
http://localhost:3000).
- From the main dashboard, click the link to open the LLaMA-Factory UI.
- Set the following parameters carefully:
- Model name: If you used Option 1 (Direct Download), select the downloaded model from the dropdown. If you used Option 2 (Manual
git clone), selectCustomfrom the dropdown menu. - Model path: If you selected
Custom, enter the path to the model inside the container:/app/models/unsloth/llama-3-8b-instruct-bnb-4bit - Dataset: Select your dataset from the dropdown.
- Finetuning method:
lora - Extra configurations: Select
TensorBoardfrom the dropdown menu to enable monitoring.
- Model name: If you used Option 1 (Direct Download), select the downloaded model from the dropdown. If you used Option 2 (Manual
- Once all parameters are set, click the Start button.
- The fine-tuning process will begin. You can monitor the progress in two ways:
- LLaMA-Factory UI: Watch the logs and the Loss graph. A downward-trending loss curve indicates that the model is learning successfully.
- TensorBoard: Return to the main dashboard and view the TensorBoard Monitoring section for more detailed metrics.
After the fine-tuning job is complete, the final step is to convert the model and load it into Ollama.
- Return to the main Orchestration Dashboard.
- Navigate to the Model Converter section.
- Select your newly fine-tuned model from the list.
- In the Base Model Path field, enter the Hugging Face repository ID of the base model (e.g.,
unsloth/Llama-3.2-3B-Instruct). Do not use the local file path. - Give your new model a name and a system prompt.
- Click the Convert and Load Model button. The backend will handle merging the adapter, converting the model to GGUF, and loading it into Ollama.