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. 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 https://github.com/saqlain2204/trloom that provides us the ability to dispatch fine-tuning jobs with a single yaml configuration file. Dataset used: b-mc2/sql-create-context https://huggingface.co/datasets/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 https://huggingface.co/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. TRLoom config: fine-tune a tiny instruct model to turn natural-language questions + a table schema into a SQL query. Model : HuggingFaceTB/SmolLM2-135M-Instruct 135M params — very small Dataset: b-mc2/sql-create-context question, context, answer Method : SFT + LoRA Validate: trloom validate sft sql config.yaml Run local: trloom run sft sql config.yaml --local Run modal: trloom run sft sql config.yaml --modalmethod: sftmodel: model name or path: HuggingFaceTB/SmolLM2-135M-Instruct dtype: bfloat16 use peft: true set to false to full-finetune model is tiny enough to afford it lora r: 16 lora alpha: 32 lora dropout: 0.05 lora target modules: - q proj - k proj - v proj - o projdataset: path: b-mc2/sql-create-context split: "train :2000 " smoke-test subset — remove this line or widen it to use all 78,577 rows train split: train eval split: null this dataset ships one split only Turn {question, context, answer} into one "text" field via an inline Jinja2 template — no extra Python file needed. prompt template: | Task: Given the SQL table schema below, write a SQL query that answers the question. Schema: {{ context }} Question: {{ question }} SQL: {{ answer }} prompt output column: text prompt remove columns: true text column: texttraining: output dir: ./outputs/sql-sft learning rate: 2.0e-4 num train epochs: 3 per device train batch size: 8 gradient accumulation steps: 2 logging steps: 10 save steps: 200 bf16: true dataset text field: text max length: 512wandb: enabled: true project: trloom-sql-tiny-sft run name: smollm2-135m-sql-lora tags: sft, lora, sql, smollm2 notes: "Fine-tuning SmolLM2-135M-Instruct on b-mc2/sql-create-context for NL-to-SQL generation." mode: online switch to "offline" to debug without network accessmodal: enabled: true app name: trloom-sql-sft gpu: T4 plenty for a 135M model; bump to A10G/A100 for the full dataset + more epochs timeout: 14400 volume name: trloom-sql-outputs volume mount: /outputs secrets: - wandb created via: python -m modal secret create wandb WANDB API KEY=... - huggingface created via: python -m modal secret create huggingface HF TOKEN=hf ... install source: pypi "local" while developing against a cloned trloom repo; use "pypi" otherwise download dir: ./outputs/remote-download Push the trained adapter or full model, if use peft: false to the Hub once training finishes. Requires being logged in locally huggingface-cli login or, on Modal, the "huggingface" secret above.push to hub: truehub model id: