harbor run -t LiteCoder/finetune-llm-sql-pipelineharbor download LiteCoder/finetune-llm-sql-pipelineBuild an end-to-end Python pipeline that fine-tunes a small open-source LLM to convert natural-language questions into PostgreSQL queries on CPU, and expose the result via a REST API.
python pipeline.py. The script must run unattended (no interactive prompts).app.py must serve the fine-tuned model.requirements.txt must list all dependencies with pinned versions.b-mc2/sql-create-context dataset using the HuggingFace datasets library.question (natural-language) and answer (SQL) fields from each example.seed=42../outputs/data/:
./outputs/data/train.jsonl./outputs/data/val.jsonl./outputs/data/test.jsonl"question" (string) and "answer" (string).microsoft/DialoGPT-medium or similar).r=8, lora_alpha=32, lora_dropout=0.05. Target all linear layers.per_device_train_batch_size=2gradient_accumulation_steps=4num_train_epochs=3fp16=False, bf16=False (CPU-safe)Trainer class. Select the best checkpoint based on exact-match accuracy on the validation set../outputs/eval_results.json with this exact structure:{
"exact_match_accuracy": <float between 0.0 and 1.0>,
"bleu_score": <float between 0.0 and 1.0>,
"num_test_samples": <int>,
"sample_predictions": [
{
"question": "<input question>",
"gold_sql": "<ground truth SQL>",
"predicted_sql": "<model output SQL>"
}
]
}
sample_predictions must contain exactly 10 randomly selected examples from the test set (use seed=42 for reproducibility)../outputs/lora_adapter/../outputs/merged_model/../outputs/lora_adapter/ directory must contain at minimum adapter_config.json and adapter_model.safetensors (or adapter_model.bin)../outputs/merged_model/ directory must contain at minimum config.json and model weight files../outputs/merged_model/ must not exceed 1 GB.app.py)/app/app.py../outputs/merged_model/ (or ./outputs/lora_adapter/ with base model)./generate:
{"question": "<natural language question>"}{"sql": "<generated SQL query>"}question field, return HTTP 422 with a JSON body containing an "detail" key./health endpoint that returns {"status": "ok"}.After running python pipeline.py, the ./outputs/ directory must contain at least:
outputs/
├── data/
│ ├── train.jsonl
│ ├── val.jsonl
│ └── test.jsonl
├── eval_results.json
├── lora_adapter/
│ ├── adapter_config.json
│ └── adapter_model.safetensors (or adapter_model.bin)
└── merged_model/
├── config.json
└── (model weight files)
Additionally, the root directory must contain:
pipeline.pyapp.pyrequirements.txt