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 auth

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), process them into training data instead of curating a dataset by hand. Traces are first uploaded as a PreparedTraces resource, then processed to produce training and test data (an Upload). The trace processing pipeline automatically filters, relabels, and splits your traces.

Your traces directory should contain:

File Format Required Description
traces.jsonl JSONL Yes Production traces in Langfuse or OpenAI messages format
job_description.json JSON Yes Task objectives and configuration
config.yaml YAML Yes Training and trace processing parameters

Upload your traces, then process them:

# Step 1: Store the trace files as a PreparedTraces resource
distil traces upload --data ./traces
# Output: Prepared traces created. ID: <traces-id>

# Step 2: Process them into an Upload
distil upload create-from-traces <traces-id>
# Output: Processing started. Upload ID: <upload-id>

Processing takes several minutes. Poll distil upload status <upload-id> until it reports success, then hand the processed data to your model:

distil upload download <upload-id> --destination ./processed
distil model upload-data <model-id> --data ./processed

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:

File Format Required Description
job_description.json JSON Yes Task objectives and configuration
train.jsonl JSONL Yes 20+ labeled examples, each a messages conversation
test.jsonl JSONL Yes Held-out evaluation set
config.yaml YAML Yes Training hyperparameters
unstructured.jsonl JSONL No Text 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>

# Or, working from the upload ID directly
distil teacher-evaluation create-from-upload <upload-id>
distil teacher-evaluation status <teacher-evaluation-id>
distil teacher-evaluation metrics <teacher-evaluation-id>

Optional: inspect the synthetic training data

Section titled “Optional: inspect the synthetic training data”

Training generates synthetic examples from your upload as part of its pipeline. You can also run that generation on its own first, to see what the platform would train on before committing to a training run.

# Generate a training dataset from the upload
distil training-dataset create-from-upload <upload-id>

# Poll until it finishes
distil training-dataset status <training-dataset-id>

# Preview up to 20 generated rows, for free
distil training-dataset sample <training-dataset-id>

# Or download the whole bundle
distil training-dataset download <training-dataset-id>

Training still runs from the upload, as in the next step — generating a dataset here does not replace that.

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 --conversation '[{"role": "user", "content": "Your question here"}]'

For question answering models that require context, wrap it in a <context> tag (followed by a newline) inside the first user message:

uv run $PATH_TO_CLIENT --conversation '[{"role": "user", "content": "<context>Your context here</context>\nYour question 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: