Skip to content

Overview

Whether you are looking to classify text, answer questions, interact with internal tools, or solve other language tasks, our step-by-step workflow will take you from initial concept to production-ready model. Let’s dive in!

First, authenticate with the distil labs platform:

distil login

Register a new model to track your experiment:

# Returns your model ID
distil model create my-model-name

You can list all your models with:

distil model list

Step 2: Task selection and data preparation

Section titled “Step 2: Task selection and data preparation”

Begin by identifying the specific task you want your model to perform. Different tasks require different approaches to data preparation and model configuration.

Learn more about task selection →

If you have production traces (logs of real interactions with an LLM), upload them to train directly from real-world usage data. This is a two-step process: traces are first uploaded as a PreparedTraces resource, then processed to produce training and test data. The trace processing pipeline will automatically filter, relabel, and split your traces into training and test data.

Your traces directory should contain:

FileFormatRequiredDescription
traces.jsonlJSONLYesProduction traces in Langfuse or OpenAI messages format
job_description.jsonJSONYesTask objectives and configuration
config.yamlYAMLYesTraining and trace processing parameters

Upload your traces to the model:

distil model upload-traces <model-id> --data ./traces

Learn more about trace processing →

If you don’t have production traces, prepare a small structured dataset with labeled examples instead. A training job requires the following files in a directory:

FileFormatRequiredDescription
job_description.jsonJSONYesTask objectives and configuration
train.csvCSV or JSONLYes20+ labeled (question, answer) pairs
test.csvCSV or JSONLYesHeld-out evaluation set
config.yamlYAMLYesTraining hyperparameters
unstructured.csvCSV or JSONLNoText documents relating to your problem domain which we may use for synthetic data generation

Upload your data to the model:

distil model upload-data <model-id> --data ./data

Learn more about data preparation →

Before training your specialized small model, validate whether a large language model can accurately solve your task with the provided examples. If the teacher model can solve the task, the student model will be able to learn from it effectively. Learn about teacher evaluation →

# Start teacher evaluation
distil model run-teacher-evaluation <model-id>

# Check status
distil model teacher-evaluation <model-id>

Once your teacher evaluation shows satisfactory results, train your specialized small language model using knowledge distillation.

Understand the model training process →

# Start training
distil model run-training <model-id>

# Check status
distil model training <model-id>

Once training is complete, download your model:

distil model download <model-id>

Deploy your trained model locally or using distil labs inference for immediate integration with your applications.

Explore deployment options →

Use the distil CLI with llama-cpp as the inference backend:

distil model deploy local <model-id>

Once running, get a ready-to-run invocation script with distil model invoke:

distil model invoke <model-id>

This outputs a command using uv that you can copy and run directly:

uv run $PATH_TO_CLIENT --question "Your question here"

For question answering models that require context, use the --context flag:

uv run $PATH_TO_CLIENT --question "Your question here" --context "Your context here"

Alternatively, deploy your model on distil-managed remote infrastructure using the distil labs inference:

distil model deploy remote <model-id>

The CLI will provision your deployment and display the endpoint URL, API key, and a client script you can use to query your model.

Once deployed, you can also use distil model invoke to get a ready-to-run invocation script for your remote deployment:

distil model invoke <model-id>

You’ve successfully trained and deployed a specialized small language model! For more details, explore: