onekq commited on
Commit
2b9d89e
·
verified ·
1 Parent(s): 2f3374e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +33 -39
README.md CHANGED
@@ -1,58 +1,52 @@
1
  ---
2
- base_model: Qwen/Qwen2.5-Coder-3B-Instruct
3
  library_name: transformers
4
- model_name: onesql-qwen-3B
5
  tags:
6
  - generated_from_trainer
 
7
  - trl
8
  - sft
9
- licence: license
 
10
  ---
11
 
12
- # Model Card for onesql-qwen-3B
13
 
14
- This model is a fine-tuned version of [Qwen/Qwen2.5-Coder-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-3B-Instruct).
15
- It has been trained using [TRL](https://github.com/huggingface/trl).
16
 
17
- ## Quick start
18
 
19
- ```python
20
- from transformers import pipeline
21
-
22
- question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
23
- generator = pipeline("text-generation", model="onekq-ai/onesql-qwen-3B", device="cuda")
24
- output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
25
- print(output["generated_text"])
26
- ```
27
-
28
- ## Training procedure
29
 
30
-
31
-
32
-
33
- This model was trained with SFT.
34
 
35
- ### Framework versions
 
 
 
36
 
37
- - TRL: 0.17.0
38
- - Transformers: 4.51.3
39
- - Pytorch: 2.7.0
40
- - Datasets: 3.0.1
41
- - Tokenizers: 0.21.1
42
 
43
- ## Citations
 
 
 
 
 
 
44
 
 
 
45
 
 
 
 
46
 
47
- Cite TRL as:
48
-
49
- ```bibtex
50
- @misc{vonwerra2022trl,
51
- title = {{TRL: Transformer Reinforcement Learning}},
52
- author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
53
- year = 2020,
54
- journal = {GitHub repository},
55
- publisher = {GitHub},
56
- howpublished = {\url{https://github.com/huggingface/trl}}
57
- }
58
  ```
 
1
  ---
2
+ base_model: unsloth/Qwen2.5-Coder-3B-Instruct-bnb-4bit
3
  library_name: transformers
4
+ model_name: onekq-ai/OneSQL-v0.2-Qwen-3B
5
  tags:
6
  - generated_from_trainer
7
+ - unsloth
8
  - trl
9
  - sft
10
+ licence: apache-2.0
11
+ pipeline_tag: text-generation
12
  ---
13
 
14
+ # Introduction
15
 
16
+ This model is the full-weight version of the adapter model [OneSQL-v0.1-Qwen-3B](https://huggingface.co/onekq-ai/OneSQL-v0.1-Qwen-3B).
 
17
 
18
+ # Quick start
19
 
20
+ To use this model, craft your prompt to start with your database schema in the form of **CREATE TABLE**, followed by your natural language query preceded by **--**.
21
+ Make sure your prompt ends with **SELECT** in order for the model to finish the query for you.
 
 
 
 
 
 
 
 
22
 
23
+ ```python
24
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
25
+ from peft import PeftModel
 
26
 
27
+ model_name = "onekq-ai/OneSQL-v0.2-Qwen-3B"
28
+ model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto")
29
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
30
+ tokenizer.padding_side = "left"
31
 
32
+ generator = pipeline("text-generation", model=model, tokenizer=tokenizer, return_full_text=False)
 
 
 
 
33
 
34
+ prompt = """
35
+ CREATE TABLE students (
36
+ id INTEGER PRIMARY KEY,
37
+ name TEXT,
38
+ age INTEGER,
39
+ grade TEXT
40
+ );
41
 
42
+ -- Find the three youngest students
43
+ SELECT """
44
 
45
+ result = generator(f"<|im_start|>system\nYou are a SQL expert. Return code only.<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n")[0]
46
+ print(result["generated_text"])
47
+ ```
48
 
49
+ The model response is the finished SQL query without **SELECT**
50
+ ```sql
51
+ * FROM students ORDER BY age ASC LIMIT 3
 
 
 
 
 
 
 
 
52
  ```