circlelee commited on
Commit
dfe8a9e
1 Parent(s): 813283b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +46 -0
README.md CHANGED
@@ -10,6 +10,8 @@ tags:
10
  - gemma2
11
  - trl
12
  - sft
 
 
13
  ---
14
 
15
  # Uploaded model
@@ -21,3 +23,47 @@ tags:
21
  This gemma2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
22
 
23
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  - gemma2
11
  - trl
12
  - sft
13
+ datasets:
14
+ - Clinton/Text-to-sql-v1
15
  ---
16
 
17
  # Uploaded model
 
23
  This gemma2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
24
 
25
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
26
+
27
+
28
+
29
+
30
+
31
+
32
+ ## Model Information
33
+
34
+ Summary description and brief definition of inputs and outputs.
35
+
36
+ ### Description
37
+
38
+ This model is based on Gemma2 and is fine-tuned to generate SQL from Natural Language.
39
+
40
+ ### Usage
41
+
42
+ Below we share some code snippets on how to get quickly started with running the model. First, install the Transformers library with:
43
+ ```sh
44
+ pip install -U transformers
45
+ ...
46
+ from transformers import AutoTokenizer, AutoModelForCausalLM
47
+
48
+ model = AutoModelForCausalLM.from_pretrained("circlelee/gemma-2-2b-it-nl2sql")
49
+ tokenizer = AutoTokenizer.from_pretrained("circlelee/gemma-2-2b-it-nl2sql", trust_remote_code=True)
50
+
51
+ table_schemas = "CREATE TABLE person ( name VARCHAR, age INTEGER, address VARCHAR )"
52
+ user_query = "people whoes ages are older than 27 and name starts with letter 'k'"
53
+ messages = [
54
+ {"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.
55
+ {table_schemas}
56
+ step 1. check columns that I want.
57
+ step 2. check condition that I want.
58
+ step 3. make SQL query to get every information that I want.
59
+
60
+ {user_query}
61
+ """}
62
+ ]
63
+
64
+ formated_messages = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, return_tensors="pt")
65
+ input_ids = tokenizer(formated_messages, return_tensors="pt")
66
+
67
+ outputs = model.generate(**input_ids, max_new_tokens=64)
68
+ print(tokenizer.decode(outputs[0]))
69
+ ```