CoolFace
Modelpublic

Ellbendls/Qwen-3-4b-Text_to_SQL

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
7likes117downloads
README.md71 linesDownload Raw Back to root
1---2library_name: transformers3license: apache-2.04datasets:5- gretelai/synthetic_text_to_sql6base_model:7- Qwen/Qwen3-4B-Instruct-25078pipeline_tag: text-generation9language:10- zho11- eng12- fra13- spa14- por15- deu16- ita17- rus18- jpn19- kor20- vie21- tha22- ara23---24 25# Fine-Tuned LLM for Text-to-SQL Conversion26 27This model is a fine-tuned version of [Qwen/Qwen3-4B](https://huggingface.co/Qwen/Qwen3-4B) designed to convert natural language queries into SQL statements. It was trained on the `gretelai/synthetic_text_to_sql` dataset and can provide both SQL queries and table schema context when needed.28 29---30 31## Model Details32 33### Model Description34 35This model has been fine-tuned to help users generate SQL queries based on natural language prompts. In scenarios where table schema context is missing, the model is trained to generate schema definitions along with the SQL query. The base Qwen-3-4B provides stronger multilingual support and larger context windows.  36 37- **Base Model:** [Qwen/Qwen3-4B-Instruct-2507](https://huggingface.co/Qwen/Qwen3-4B-Instruct-2507)  38- **Dataset:** Gretel AI Synthetic Text-to-SQL Dataset  39- **Languages Supported (base):** many including English, Chinese, etc.  40- **License:** Apache-2.0  41 42### Key Features43 441. Text-to-SQL Conversion: Converts natural language queries into accurate SQL statements.  452. Schema Generation: Generates table schema context when none is provided.  463. Optimized for Analytics and Reporting: Handles SQL queries with aggregation, grouping, filtering.  474. Multilingual Capabilities: Base model is trained on 119 languages/dialects. :contentReference[oaicite:0]{index=0}  485. Large Context Window: Qwen-3-4B uses long context length (32K tokens in many cases). :contentReference[oaicite:1]{index=1}49 50---51 52## Usage53 54### Direct Use55 56```python57from transformers import AutoTokenizer, AutoModelForCausalLM58 59tokenizer = AutoTokenizer.from_pretrained("Ellbendls/Qwen-3-4B-Text_to_SQL")60model = AutoModelForCausalLM.from_pretrained("Ellbendls/Qwen-3-4B-Text_to_SQL")61 62# Input prompt63query = "What is the average salary by department in 2024?"64 65# Tokenize input and generate output66inputs = tokenizer(query, return_tensors="pt")67outputs = model.generate(**inputs, max_length=512)68 69# Decode and print70print(tokenizer.decode(outputs[0], skip_special_tokens=True))71