How to use from
vLLM
Install from pip and serve model
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Rj18/text-to-sql-tinyllama-lora"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
	-H "Content-Type: application/json" \
	--data '{
		"model": "Rj18/text-to-sql-tinyllama-lora",
		"messages": [
			{
				"role": "user",
				"content": "What is the capital of France?"
			}
		]
	}'
Use Docker
docker model run hf.co/Rj18/text-to-sql-tinyllama-lora
Quick Links

Text-to-SQL TinyLlama LoRA Adapter

A fine-tuned LoRA adapter that converts natural language questions into SQL queries. Built on top of TinyLlama-1.1B-Chat-v1.0 using Supervised Fine-Tuning (SFT) on the Spider benchmark dataset.

Model Details

Model Description

This is a LoRA (Low-Rank Adaptation) adapter fine-tuned to generate SQL queries from natural language questions. Only 0.10% of the base model's parameters were trained, making it extremely lightweight (4.5 MB) while still achieving strong results.

Model Sources

How to Use

import torch from transformers import AutoModelForCausalLM, AutoTokenizer from peft import PeftModel

Load base model and tokenizer

base_model = "TinyLlama/TinyLlama-1.1B-Chat-v1.0" adapter = "Rj18/text-to-sql-tinyllama-lora"

tokenizer = AutoTokenizer.from_pretrained(adapter) model = AutoModelForCausalLM.from_pretrained(base_model, torch_dtype=torch.float16) model = PeftModel.from_pretrained(model, adapter) model.eval()

Generate SQL

question = "How many employees are in each department?" prompt = f"[INST] Generate SQL for the following question.\nQuestion: {question} [/INST]\n"

inputs = tokenizer(prompt, return_tensors="pt") with torch.no_grad(): outputs = model.generate(**inputs, max_new_tokens=128, temperature=0.1)

sql = tokenizer.decode(outputs[0], skip_special_tokens=True) print(sql)

Downloads last month
7
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Rj18/text-to-sql-tinyllama-lora

Adapter
(1575)
this model

Dataset used to train Rj18/text-to-sql-tinyllama-lora