| base_model: Qwen/Qwen2.5-Coder-1.5B-Instruct | |
| tags: | |
| - lora | |
| - qwen | |
| - sql | |
| - text-generation | |
| # Qwen 2.5 Coder LoRA for SQL Generation | |
| This is a LoRA adapter for Qwen/Qwen2.5-Coder-1.5B-Instruct fine-tuned for SQL query generation. | |
| ## Usage | |
| ```python | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| from peft import PeftModel | |
| # Load base model | |
| base_model = AutoModelForCausalLM.from_pretrained( | |
| "Qwen/Qwen2.5-Coder-1.5B-Instruct", | |
| torch_dtype=torch.float16, | |
| device_map="auto" | |
| ) | |
| tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-Coder-1.5B-Instruct") | |
| # Load LoRA adapter | |
| model = PeftModel.from_pretrained(base_model, "faizaltkl/qwen-2.5-coder-sql-lora") | |
| # Generate SQL | |
| prompt = "Create a SQL query to find all customers who made purchases in the last 30 days" | |
| inputs = tokenizer(prompt, return_tensors="pt") | |
| outputs = model.generate(**inputs, max_length=256) | |
| sql = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| print(sql) | |
| ``` | |