| | --- |
| | language: en |
| | tags: |
| | - text2sql |
| | - causal-lm |
| | - transformers |
| | - safetensors |
| | license: mit |
| | pipeline_tag: text-generation |
| | --- |
| | |
| |
|
| |
|
| | # Phi-3 Text-to-SQL Model |
| |
|
| | This is a fine-tuned **Microsoft Phi-3** model specialized for **Text-to-SQL** generation. |
| |
|
| | ## Example |
| |
|
| | ```python |
| | from transformers import AutoModelForCausalLM, AutoTokenizer |
| | |
| | repo_id = "bhavika24/text2sql" |
| | tokenizer = AutoTokenizer.from_pretrained(repo_id) |
| | model = AutoModelForCausalLM.from_pretrained(repo_id, torch_dtype="auto", device_map="auto") |
| | |
| | question = "List all customers who ordered products over $500 last month." |
| | inputs = tokenizer(question, return_tensors="pt").to(model.device) |
| | outputs = model.generate(**inputs, max_new_tokens=128) |
| | |
| | sql_query = tokenizer.decode(outputs[0], skip_special_tokens=True) |
| | print(sql_query) |
| | |