File size: 786 Bytes
4106a0f
 
 
 
 
 
 
 
10f532a
4106a0f
 
 
d282df4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
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)