Text Generation
PEFT
Safetensors
French
text2sql
text-to-sql
lora
qlora
schema-linking
qwen2.5-coder
french
conversational
Instructions to use axrafTic/text2sqlProspeciton with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use axrafTic/text2sqlProspeciton with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/Qwen2.5-Coder-3B-Instruct-bnb-4bit") model = PeftModel.from_pretrained(base_model, "axrafTic/text2sqlProspeciton") - Notebooks
- Google Colab
- Kaggle
Deploy QLoRA Approach B (Schema-Linking Text-to-SQL Qwen2.5-Coder-3B)
Browse filesFiles changed (11)
- .gitattributes+1
- README.mdAdded+70
- adapter_config.jsonAdded+50
- adapter_model.safetensorsAdded+3
- added_tokens.jsonAdded+25
- merges.txtAdded
- special_tokens_map.jsonAdded+31
- tokenizer.jsonAdded+3
- tokenizer_config.jsonAdded+216
- trainer_state.jsonAdded+295
- vocab.jsonAdded
32 unmodified lines3334353632 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -texttokenizer.json filter=lfs diff=lfs merge=lfs -text12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970---base_model: unsloth/Qwen2.5-Coder-3B-Instruct-bnb-4bitlibrary_name: peftpipeline_tag: text-generationlanguage:- frtags:- text2sql- text-to-sql- lora- qlora- schema-linking- qwen2.5-coder- french---
# Text-to-SQL Prospect Model (Approach B: Schema-Linking)
Fine-tuned QLoRA adapter for **Qwen2.5-Coder-3B-Instruct** designed to generate SQL queries in French for the `companies` database schema.
## Model Details- **Base Model**: `Qwen/Qwen2.5-Coder-3B-Instruct` / `unsloth/Qwen2.5-Coder-3B-Instruct-bnb-4bit`- **Method**: QLoRA Fine-Tuning (`r=32`, `alpha=64`, target modules: all linear layers)- **Task**: Text-to-SQL (French natural language questions -> SQLite / Postgres SQL queries)- **Approach**: Schema-Linking with column annotations (`SCHEMA_B`)
## Prompt Structure (ChatML)
```text<|im_start|>systemTu es un analyste de données expert en SQL. Transforme la question de l'utilisateur en une requête SQL valide et exécutable. Ne génère que le code SQL, sans explication.<|im_end|><|im_start|>userBase de données:[SCHEMA]Table: companies (Profils d'entreprises françaises)Colonnes:- id (UUID identifiant unique)- name (Nom commercial de l'entreprise)- rating (Note Google Maps de 0 à 5)- reviews (Nombre total d'avis Google)- is_spending_on_ads (1 si l'entreprise paie pour des annonces, 0 sinon)- description (Description textuelle de l'activité)- website (URL du site web, NULL si absent)- address (Adresse postale complète)- ville (ex: 'Paris', 'Lyon', 'Marseille')- secteur (ex: 'Informatique', 'Finance', 'Santé')- region (ex: 'Ile-de-France', 'Auvergne-Rhone-Alpes')- codeAPE (Code NAF d'activité économique)- siren (Identifiant unique entreprise à 9 chiffres)- siret (Identifiant unique établissement à 14 chiffres)
Question: Lister les entreprises à Paris avec une note supérieure à 4.SQL:<|im_end|><|im_start|>assistant```
## How to Load in Python
```pythonimport torchfrom transformers import AutoTokenizer, AutoModelForCausalLMfrom peft import PeftModel
base_model_id = "Qwen/Qwen2.5-Coder-3B-Instruct"adapter_id = "axrafTic/text2sqlProspeciton"
tokenizer = AutoTokenizer.from_pretrained(adapter_id)base_model = AutoModelForCausalLM.from_pretrained(base_model_id, torch_dtype=torch.float16, device_map="auto")model = PeftModel.from_pretrained(base_model, adapter_id)```1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950{ "alora_invocation_tokens": null, "alpha_pattern": {}, "arrow_config": null, "auto_mapping": null, "base_model_name_or_path": "unsloth/Qwen2.5-Coder-3B-Instruct-bnb-4bit", "bias": "none", "corda_config": null, "ensure_weight_tying": false, "eva_config": null, "exclude_modules": null, "fan_in_fan_out": false, "inference_mode": true, "init_lora_weights": true, "layer_replication": null, "layers_pattern": null, "layers_to_transform": null, "loftq_config": {}, "lora_alpha": 64, "lora_bias": false, "lora_dropout": 0.05, "lora_ga_config": null, "megatron_config": null, "megatron_core": "megatron.core", "modules_to_save": null, "monteclora_config": null, "peft_type": "LORA", "peft_version": "0.20.0", "qalora_group_size": 16, "r": 32, "rank_pattern": {}, "revision": null, "target_modules": [ "up_proj", "q_proj", "gate_proj", "down_proj", "v_proj", "k_proj", "o_proj" ], "target_parameters": null, "task_type": "CAUSAL_LM", "trainable_token_indices": null, "use_bdlora": null, "use_dora": false, "use_qalora": false, "use_rslora": false, "velora_config": null}123version https://git-lfs.github.com/spec/v1oid sha256:2cead126e0899a24d04249ec488b177987eee31b3173df05f6f413144abffc05size 23953627212345678910111213141516171819202122232425{ "</tool_call>": 151658, "<tool_call>": 151657, "<|PAD_TOKEN|>": 151665, "<|box_end|>": 151649, "<|box_start|>": 151648, "<|endoftext|>": 151643, "<|file_sep|>": 151664, "<|fim_middle|>": 151660, "<|fim_pad|>": 151662, "<|fim_prefix|>": 151659, "<|fim_suffix|>": 151661, "<|im_end|>": 151645, "<|im_start|>": 151644, "<|image_pad|>": 151655, "<|object_ref_end|>": 151647, "<|object_ref_start|>": 151646, "<|quad_end|>": 151651, "<|quad_start|>": 151650, "<|repo_name|>": 151663, "<|video_pad|>": 151656, "<|vision_end|>": 151653, "<|vision_pad|>": 151654, "<|vision_start|>": 151652}12345678910111213141516171819202122232425262728293031{ "additional_special_tokens": [ "<|im_start|>", "<|im_end|>", "<|object_ref_start|>", "<|object_ref_end|>", "<|box_start|>", "<|box_end|>", "<|quad_start|>", "<|quad_end|>", "<|vision_start|>", "<|vision_end|>", "<|vision_pad|>", "<|image_pad|>", "<|video_pad|>" ], "eos_token": { "content": "<|im_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "pad_token": { "content": "<|PAD_TOKEN|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }}123version https://git-lfs.github.com/spec/v1oid sha256:a49c1b786ba7cd9c539085ebc8eb83025f6b16a7ce910a34b35957768c4b52a7size 11422185123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216{ "add_bos_token": false, "add_prefix_space": false, "added_tokens_decoder": { "151643": { "content": "<|endoftext|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151644": { "content": "<|im_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151645": { "content": "<|im_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151646": { "content": "<|object_ref_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151647": { "content": "<|object_ref_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151648": { "content": "<|box_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151649": { "content": "<|box_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151650": { "content": "<|quad_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151651": { "content": "<|quad_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151652": { "content": "<|vision_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151653": { "content": "<|vision_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151654": { "content": "<|vision_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151655": { "content": "<|image_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151656": { "content": "<|video_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151657": { "content": "<tool_call>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151658": { "content": "</tool_call>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151659": { "content": "<|fim_prefix|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151660": { "content": "<|fim_middle|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151661": { "content": "<|fim_suffix|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151662": { "content": "<|fim_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151663": { "content": "<|repo_name|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151664": { "content": "<|file_sep|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": false }, "151665": { "content": "<|PAD_TOKEN|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true } }, "additional_special_tokens": [ "<|im_start|>", "<|im_end|>", "<|object_ref_start|>", "<|object_ref_end|>", "<|box_start|>", "<|box_end|>", "<|quad_start|>", "<|quad_end|>", "<|vision_start|>", "<|vision_end|>", "<|vision_pad|>", "<|image_pad|>", "<|video_pad|>" ], "bos_token": null, "chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0]['role'] == 'system' %}\n {{- messages[0]['content'] }}\n {%- else %}\n {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}\n {%- endif %}\n {{- \"\\n\\n# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n{%- else %}\n {%- if messages[0]['role'] == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0]['content'] + '<|im_end|>\\n' }}\n {%- else %}\n {{- '<|im_start|>system\\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) or (message.role == \"assistant\" and not message.tool_calls) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {{- '<|im_start|>' + message.role }}\n {%- if message.content %}\n {{- '\\n' + message.content }}\n {%- endif %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '\\n<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- message.content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n{%- endif %}\n", "clean_up_tokenization_spaces": false, "eos_token": "<|im_end|>", "errors": "replace", "model_max_length": 131072, "pad_token": "<|PAD_TOKEN|>", "padding_side": "right", "split_special_tokens": false, "tokenizer_class": "Qwen2Tokenizer", "unk_token": null}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295{ "best_metric": 0.041570067405700684, "best_model_checkpoint": "./sql_lora_approach_b/checkpoint-34", "epoch": 2.9565217391304346, "eval_steps": 500, "global_step": 34, "is_hyper_param_search": false, "is_local_process_zero": true, "is_world_process_zero": true, "log_history": [ { "epoch": 0.08695652173913043, "grad_norm": 1.1549581289291382, "learning_rate": 6.666666666666667e-05, "loss": 1.7303, "step": 1 }, { "epoch": 0.17391304347826086, "grad_norm": 1.1289726495742798, "learning_rate": 0.00013333333333333334, "loss": 1.7252, "step": 2 }, { "epoch": 0.2608695652173913, "grad_norm": 0.934922993183136, "learning_rate": 0.0002, "loss": 1.597, "step": 3 }, { "epoch": 0.34782608695652173, "grad_norm": 0.8451507091522217, "learning_rate": 0.00019981755542233177, "loss": 1.3325, "step": 4 }, { "epoch": 0.43478260869565216, "grad_norm": 0.9650647640228271, "learning_rate": 0.0001992708874098054, "loss": 1.038, "step": 5 }, { "epoch": 0.5217391304347826, "grad_norm": 1.6881967782974243, "learning_rate": 0.00019836199069471437, "loss": 0.7972, "step": 6 }, { "epoch": 0.6086956521739131, "grad_norm": 0.9939894080162048, "learning_rate": 0.0001970941817426052, "loss": 0.5526, "step": 7 }, { "epoch": 0.6956521739130435, "grad_norm": 0.9496100544929504, "learning_rate": 0.00019547208665085457, "loss": 0.3339, "step": 8 }, { "epoch": 0.782608695652174, "grad_norm": 0.7385075688362122, "learning_rate": 0.0001935016242685415, "loss": 0.1994, "step": 9 }, { "epoch": 0.8695652173913043, "grad_norm": 0.5156198740005493, "learning_rate": 0.00019118998459920902, "loss": 0.0954, "step": 10 }, { "epoch": 0.9565217391304348, "grad_norm": 0.3693973124027252, "learning_rate": 0.000188545602565321, "loss": 0.06, "step": 11 }, { "epoch": 0.9565217391304348, "eval_loss": 0.06161738932132721, "eval_runtime": 16.8375, "eval_samples_per_second": 0.535, "eval_steps_per_second": 0.535, "step": 11 }, { "epoch": 1.0434782608695652, "grad_norm": 0.3475421965122223, "learning_rate": 0.00018557812723014476, "loss": 0.0668, "step": 12 }, { "epoch": 1.1304347826086956, "grad_norm": 0.2272304743528366, "learning_rate": 0.00018229838658936564, "loss": 0.0472, "step": 13 }, { "epoch": 1.2173913043478262, "grad_norm": 0.18348968029022217, "learning_rate": 0.00017871834806090501, "loss": 0.0408, "step": 14 }, { "epoch": 1.3043478260869565, "grad_norm": 0.1996564120054245, "learning_rate": 0.00017485107481711012, "loss": 0.0533, "step": 15 }, { "epoch": 1.391304347826087, "grad_norm": 0.17511172592639923, "learning_rate": 0.00017071067811865476, "loss": 0.042, "step": 16 }, { "epoch": 1.4782608695652173, "grad_norm": 0.14677977561950684, "learning_rate": 0.00016631226582407952, "loss": 0.0318, "step": 17 }, { "epoch": 1.5652173913043477, "grad_norm": 0.19209422171115875, "learning_rate": 0.00016167188726285434, "loss": 0.0478, "step": 18 }, { "epoch": 1.6521739130434783, "grad_norm": 0.222362220287323, "learning_rate": 0.00015680647467311557, "loss": 0.0578, "step": 19 }, { "epoch": 1.7391304347826086, "grad_norm": 0.1985371708869934, "learning_rate": 0.00015173378141776568, "loss": 0.039, "step": 20 }, { "epoch": 1.8260869565217392, "grad_norm": 0.19283267855644226, "learning_rate": 0.00014647231720437686, "loss": 0.0338, "step": 21 }, { "epoch": 1.9130434782608696, "grad_norm": 0.18836742639541626, "learning_rate": 0.0001410412805452757, "loss": 0.0367, "step": 22 }, { "epoch": 2.0, "grad_norm": 0.22117920219898224, "learning_rate": 0.00013546048870425356, "loss": 0.0562, "step": 23 }, { "epoch": 2.0, "eval_loss": 0.042378202080726624, "eval_runtime": 16.8523, "eval_samples_per_second": 0.534, "eval_steps_per_second": 0.534, "step": 23 }, { "epoch": 2.0869565217391304, "grad_norm": 0.08625093847513199, "learning_rate": 0.00012975030538552032, "loss": 0.0223, "step": 24 }, { "epoch": 2.1739130434782608, "grad_norm": 0.10370675474405289, "learning_rate": 0.0001239315664287558, "loss": 0.0292, "step": 25 }, { "epoch": 2.260869565217391, "grad_norm": 0.15547294914722443, "learning_rate": 0.0001180255037813906, "loss": 0.0403, "step": 26 }, { "epoch": 2.3478260869565215, "grad_norm": 0.1734398603439331, "learning_rate": 0.0001120536680255323, "loss": 0.0341, "step": 27 }, { "epoch": 2.4347826086956523, "grad_norm": 0.12611858546733856, "learning_rate": 0.00010603784974222861, "loss": 0.025, "step": 28 }, { "epoch": 2.5217391304347827, "grad_norm": 0.11490053683519363, "learning_rate": 0.0001, "loss": 0.0254, "step": 29 }, { "epoch": 2.608695652173913, "grad_norm": 0.11299990862607956, "learning_rate": 9.396215025777139e-05, "loss": 0.0287, "step": 30 }, { "epoch": 2.6956521739130435, "grad_norm": 0.09447255730628967, "learning_rate": 8.79463319744677e-05, "loss": 0.0226, "step": 31 }, { "epoch": 2.782608695652174, "grad_norm": 0.13230058550834656, "learning_rate": 8.197449621860943e-05, "loss": 0.0277, "step": 32 }, { "epoch": 2.869565217391304, "grad_norm": 0.13557763397693634, "learning_rate": 7.606843357124426e-05, "loss": 0.0325, "step": 33 }, { "epoch": 2.9565217391304346, "grad_norm": 0.10920581966638565, "learning_rate": 7.024969461447972e-05, "loss": 0.0219, "step": 34 }, { "epoch": 2.9565217391304346, "eval_loss": 0.041570067405700684, "eval_runtime": 16.9013, "eval_samples_per_second": 0.533, "eval_steps_per_second": 0.533, "step": 34 } ], "logging_steps": 1, "max_steps": 55, "num_input_tokens_seen": 0, "num_train_epochs": 5, "save_steps": 500, "stateful_callbacks": { "TrainerControl": { "args": { "should_epoch_stop": false, "should_evaluate": false, "should_log": false, "should_save": true, "should_training_stop": false }, "attributes": {} } }, "total_flos": 1208798594408448.0, "train_batch_size": 1, "trial_name": null, "trial_params": null}.gitattributes+1
README.mdAdded+70
adapter_config.jsonAdded+50
adapter_model.safetensorsAdded+3
added_tokens.jsonAdded+25
merges.txtAdded
special_tokens_map.jsonAdded+31
tokenizer.jsonAdded+3
tokenizer_config.jsonAdded+216
trainer_state.jsonAdded+295
vocab.jsonAdded