Text Generation
Transformers
Safetensors
English
qwen2
text-generation-inference
unsloth
text2sql
qwen2.5
conversational
Instructions to use iamkushagratomar/Qwen2.5-0.5B-text2sql with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use iamkushagratomar/Qwen2.5-0.5B-text2sql with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="iamkushagratomar/Qwen2.5-0.5B-text2sql") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("iamkushagratomar/Qwen2.5-0.5B-text2sql") model = AutoModelForCausalLM.from_pretrained("iamkushagratomar/Qwen2.5-0.5B-text2sql", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use iamkushagratomar/Qwen2.5-0.5B-text2sql with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "iamkushagratomar/Qwen2.5-0.5B-text2sql" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "iamkushagratomar/Qwen2.5-0.5B-text2sql", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/iamkushagratomar/Qwen2.5-0.5B-text2sql
- SGLang
How to use iamkushagratomar/Qwen2.5-0.5B-text2sql with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "iamkushagratomar/Qwen2.5-0.5B-text2sql" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "iamkushagratomar/Qwen2.5-0.5B-text2sql", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "iamkushagratomar/Qwen2.5-0.5B-text2sql" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "iamkushagratomar/Qwen2.5-0.5B-text2sql", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Desktop
- Docker Model Runner
How to use iamkushagratomar/Qwen2.5-0.5B-text2sql with Docker Model Runner:
docker model run hf.co/iamkushagratomar/Qwen2.5-0.5B-text2sql
Qwen2.5-0.5B Text-to-SQL Model
This model is a fine-tuned version of Qwen2.5-0.5B for the text-to-SQL task on the b-mc2/sql-create-context dataset. It converts natural language questions + database schemas into SQL queries.
🔧 How to Use
Install dependencies:
pip install transformers torchLoad the model:
from transformers import AutoModelForCausalLM, AutoTokenizer import torch model_name = "iamkushagratomar/Qwen2.5-0.5B-text2sql" tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForCausalLM.from_pretrained(model_name).to("cuda")Use the model (with your question + schema)::
def generate_sql(question, schema): # Format input as: "System: [message]\n\nUser: [question + schema]" system_message = "You are a SQL expert. Convert natural language questions into SQL queries." user_message = f"### Question: \n{question}\n\n### Schema: \n{schema}" full_input = f"System: {system_message}\n\nUser: {user_message}" inputs = tokenizer(full_input, return_tensors="pt").to(model.device) outputs = model.generate( input_ids=inputs.input_ids, max_new_tokens=100, temperature=0.2, do_sample=True, use_cache=True ) return tokenizer.decode(outputs[0], skip_special_tokens=True) # Example usage question = "Find the total revenue from orders placed in the last 30 days." schema = "CREATE TABLE orders (order_id INT, order_date DATE, order_total DECIMAL, customer_id INT);" sql_query = generate_sql(question, schema) print(sql_query)
Uploaded finetuned model
- Developed by: iamkushagratomar
- License: apache-2.0
- Finetuned from model : unsloth/Qwen2.5-0.5B-Instruct-bnb-4bit
This qwen2 model was trained 2x faster with Unsloth and Huggingface's TRL library.
- Downloads last month
- -
Model tree for iamkushagratomar/Qwen2.5-0.5B-text2sql
Base model
Qwen/Qwen2.5-0.5B Finetuned
Qwen/Qwen2.5-0.5B-Instruct Quantized
unsloth/Qwen2.5-0.5B-Instruct-bnb-4bit