File size: 861 Bytes
d096bd5
4cecb95
 
d096bd5
 
 
 
 
 
 
4cecb95
 
 
d096bd5
 
 
 
 
 
 
 
 
 
 
 
 
4cecb95
d096bd5
 
 
 
 
 
 
 
4cecb95
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
---
language:
- en
tags:
- text2sql
- causal-lm
- transformers
- safetensors
license: mit
pipeline_tag: text-generation
base_model:
- microsoft/Phi-3-mini-4k-instruct
library_name: transformers
---



# 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 = "bhavika67/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)