--- base_model: Qwen/Qwen2.5-Coder-3B-Instruct library_name: peft pipeline_tag: text-generation language: - fr tags: - text2sql - text-to-sql - lora - qlora - schema-linking - qwen2.5-coder - french inference: true --- # 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` - **Adapter Repo**: `axrafTic/text2sqlProspeciton` - **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|>system Tu 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|>user Base 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 ```python import torch from transformers import AutoTokenizer, AutoModelForCausalLM from 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) ```