cd /news/large-language-models/how-to-fine-tune-a-small-language-mo… · home topics large-language-models article
[ARTICLE · art-132321] src=pub.towardsai.net ↗ pub= topic=large-language-models verified=true sentiment=· neutral

How to Fine-Tune a Small Language Model Without Writing a Single Line of Python Code on Modal Cloud

A tutorial published on Modal Cloud's platform shows how to fine-tune the 135M-parameter HuggingFaceTB/SmolLM2-135M-Instruct model on the b-mc2/sql-create-context dataset using a single YAML configuration file and no Python code. The job runs on a T4 GPU via the TRLoom library, uses SFT with LoRA (lora_r 16, lora_alpha 32), trains on the first 2,000 of the dataset's 78,577 rows for 3 epochs at a learning rate of 2.0e-4, then pushes the adapters to Hugging Face and metrics to W&B.

by read4 min views2 publishedSep 17, 2026

This is a short article that demonstrates how to fine-tune a small language model without writing a single line of Python code. The fine-tuning job is dispatched on the Modal Cloud platform and uses a T4 GPU. The fine-tuned adapters are then pushed to Hugging Face, and metrics are pushed to W&B. We use a library called ** TRLoom** that provides us the ability to dispatch fine-tuning jobs with a single yaml configuration file.

Dataset used: b-mc2/sql-create-context available on huggingface. For simplicity we consider only the first 2000 items of the train split of the dataset. This can be extended based on your usage.

Base Model: HuggingFaceTB/SmolLM2–135M-Instruct. We use a 135M Instruction-tuned model.

Step 1:

Install the dependency. “all” installs wandb and modal dependencies.

pip install "trloom[all]"

Step 2:

Setup modal and authenticate via browser

python -m modal setup

Step 3:

Add secrets to Modal Cloud

python -m modal secret create wandb WANDB_API_KEY=your_key_herepython -m modal secret create huggingface HF_TOKEN=your_hf_token_here

Step 4:

So we are all set. Our environments are prepared to take up the fine-tuning job. Create a configuration file for your fine-tuning configurations. Refer to the yaml below.

Step 4.1 (Optional)

Validate the yaml:

trloom validate sft_config.yaml

You should get the response like below:

{  "ok": true,  "method": "sft",  "trainer": "SFTTrainer",  "config_class": "SFTConfig",  "experimental": false,  "output_dir": <whatever the output directory is>,  "wandb_enabled": true,  "modal_enabled": true}

Step 5:

Run the fine tuning job:

trloom run sft_config.yaml

Your fine tuning job will be live on Modal and You will get the link of W&B runs in the Modal container logs.

After the training has been completed the Model will be pushed to hub.

The W&B runs will be visible in the project page of W&B

Thanks for reading. TRLoom is now open for contributions. A star to the repo ⭐️ would be much appreciated.

For documentation: https://saqlain2204.github.io/trloom

Github Repo: https://github.com/saqlain2204/trloom

Pypi: https://pypi.org/project/trloom/

How to Fine-Tune a Small Language Model Without Writing a Single Line of Python Code on Modal Cloud was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.

── more in #large-language-models 4 stories · sorted by recency
── more on @modal cloud 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/how-to-fine-tune-a-s…] indexed:0 read:4min 2026-09-17 ·