imsanjoykb
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -1,22 +1,77 @@
|
|
1 |
-
|
2 |
-
base_model: unsloth/qwen2.5-coder-14b-instruct-bnb-4bit
|
3 |
-
tags:
|
4 |
-
- text-generation-inference
|
5 |
-
- transformers
|
6 |
-
- unsloth
|
7 |
-
- qwen2
|
8 |
-
- trl
|
9 |
-
license: apache-2.0
|
10 |
-
language:
|
11 |
-
- en
|
12 |
-
---
|
13 |
|
14 |
-
|
15 |
|
16 |
-
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
|
|
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[🤗 HF Repo](https://huggingface.co/imsanjoykb/sqlCoder-Qwen2.5-8bit) | [♾️ Colab](https://colab.research.google.com/drive/19e-u32GY2y5lsckNuWhBQExvXgVn8ZjG?usp=sharing)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
Introducing the latest fine-tuned version of Qwen2.5-Coder-14B-Instruct, specifically tailored for SQL code generation. Built on the robust 14-billion parameter Qwen2.5-Coder architecture, this model leverages advanced configurations like bfloat16 precision and a custom quantization setup, optimized for efficient 4-bit computation. With a maximum context window of 32K tokens, this model supports extensive SQL sequences and complex query generation without compromising accuracy or performance.
|
4 |
|
5 |
+
Our fine-tuning process has enriched this model with domain-specific SQL patterns and nuanced query constructions, making it exceptionally adept at handling real-world SQL requirements, from query creation to debugging and optimization. By combining Qwen2.5's foundational strengths with targeted training on custom SQL data, this model achieves a powerful balance of general-purpose code understanding and SQL-specific precision, making it an ideal tool for developers and data engineers seeking top-tier SQL generation capabilities.
|
6 |
+
|
7 |
+
|
8 |
+
## Inference
|
9 |
+
|
10 |
+
Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
|
11 |
+
|
12 |
+
```python
|
13 |
+
# Import necessary libraries
|
14 |
+
from unsloth import FastLanguageModel
|
15 |
+
import torch
|
16 |
+
|
17 |
+
# Define the model name and other parameters
|
18 |
+
model_name = "imsanjoykb/sqlCoder-Qwen2.5-8bit"
|
19 |
+
max_seq_length = 2048
|
20 |
+
dtype = None
|
21 |
+
load_in_4bit = True
|
22 |
+
|
23 |
+
# Load the model and tokenizer from Hugging Face
|
24 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
25 |
+
model_name=model_name,
|
26 |
+
max_seq_length=max_seq_length,
|
27 |
+
dtype=dtype,
|
28 |
+
load_in_4bit=load_in_4bit,
|
29 |
+
)
|
30 |
+
|
31 |
+
# Enable faster inference
|
32 |
+
FastLanguageModel.for_inference(model)
|
33 |
+
|
34 |
+
# Define the prompt template
|
35 |
+
odoo_text2sql_prompt = """Below is an instruction describing a task related to generating a SQL query specifically for Odoo's database structure. The input provides relevant context about Odoo models or data fields from {db_schema}. Write a SQL query that fulfills the given task using Odoo's database schema.
|
36 |
|
37 |
+
### Instruction:
|
38 |
+
Generate a SQL query in the context of Odoo to {}
|
39 |
|
40 |
+
### Input:
|
41 |
+
{}
|
42 |
+
|
43 |
+
### Response:
|
44 |
+
{}
|
45 |
+
"""
|
46 |
+
|
47 |
+
# Optionally, use a TextStreamer for continuous inference
|
48 |
+
from transformers import TextStreamer
|
49 |
+
|
50 |
+
# Prepare the input text for continuous inference
|
51 |
+
instruction = ""
|
52 |
+
input_text = "What is the top profitable product?"
|
53 |
+
output_text = ""
|
54 |
+
|
55 |
+
# Tokenize the input text
|
56 |
+
inputs = tokenizer(
|
57 |
+
[
|
58 |
+
odoo_text2sql_prompt.format(instruction, input_text, output_text)
|
59 |
+
],
|
60 |
+
return_tensors="pt"
|
61 |
+
).to("cuda")
|
62 |
+
|
63 |
+
# Initialize the TextStreamer
|
64 |
+
text_streamer = TextStreamer(tokenizer)
|
65 |
+
|
66 |
+
# Generate the output using the model with TextStreamer
|
67 |
+
_ = model.generate(**inputs, streamer=text_streamer, max_new_tokens=350)
|
68 |
+
```
|
69 |
+
## Model Download
|
70 |
+
| **Model** | **#Total Params** | **#Active Params** | **Context Length** | **Download** |
|
71 |
+
| :-----------------------------: | :---------------: | :----------------: | :----------------: | :----------------------------------------------------------: |
|
72 |
+
| sqlCoder-Qwen2.5-8bit | 14B | 2.4B | 128k | [🤗 HuggingFace](https://huggingface.co/imsanjoykb/sqlCoder-Qwen2.5-8bit) |
|
73 |
+
|
74 |
+
# Uploaded model
|
75 |
+
|
76 |
+
- **Developed by:** [Sanjoy Biswas](https://www.linkedin.com/in/imsanjoykb/)
|
77 |
+
- **License:** apache-2.0
|