circlelee's picture
Update README.md
dfe8a9e verified
---
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]))
```