File size: 2,126 Bytes
8f784e9
 
 
 
 
 
 
 
 
 
 
54d6ef5
dfe8a9e
 
8f784e9
 
 
 
 
 
 
 
 
 
 
dfe8a9e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
base_model: unsloth/gemma-2-2b-it-bnb-4bit
language:
- en
license: apache-2.0
tags:
- text-generation-inference
- transformers
- unsloth
- gemma2
- trl
- sft
datasets:
- Clinton/Text-to-sql-v1
---

# Uploaded  model

- **Developed by:** circlelee
- **License:** apache-2.0
- **Finetuned from model :** unsloth/gemma-2-2b-it-bnb-4bit

This gemma2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.

[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)






## Model Information

Summary description and brief definition of inputs and outputs.

### Description

This model is based on Gemma2 and is fine-tuned to generate SQL from Natural Language.

### Usage

Below we share some code snippets on how to get quickly started with running the model. First, install the Transformers library with:
```sh
pip install -U transformers
...
from transformers import AutoTokenizer, AutoModelForCausalLM

model = AutoModelForCausalLM.from_pretrained("circlelee/gemma-2-2b-it-nl2sql")
tokenizer = AutoTokenizer.from_pretrained("circlelee/gemma-2-2b-it-nl2sql", trust_remote_code=True)

table_schemas = "CREATE TABLE person ( name VARCHAR, age INTEGER, address VARCHAR )"
user_query = "people whoes ages are older than 27 and name starts with letter 'k'"
messages = [
        {"role": "user", "content": f"""Use the below SQL tables schemas paired with instruction that describes a task. make SQL query that appropriately completes the request for the provided tables. And make SQL query according the steps.
{table_schemas}
step 1. check columns that I want.
step 2. check condition that I want.
step 3. make SQL query to get every information that I want.

{user_query}
"""}
]

formated_messages = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, return_tensors="pt")
input_ids = tokenizer(formated_messages, return_tensors="pt")

outputs = model.generate(**input_ids, max_new_tokens=64)
print(tokenizer.decode(outputs[0]))
```