Text Generation
Transformers
Safetensors
English
llama
text-to-sql
text2sql
nlp2sql
nlp-to-sql
SQL
text-generation-inference
Instructions to use ishavverma/sql-coder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ishavverma/sql-coder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ishavverma/sql-coder")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ishavverma/sql-coder") model = AutoModelForCausalLM.from_pretrained("ishavverma/sql-coder") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ishavverma/sql-coder with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ishavverma/sql-coder" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ishavverma/sql-coder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ishavverma/sql-coder
- SGLang
How to use ishavverma/sql-coder with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ishavverma/sql-coder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ishavverma/sql-coder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ishavverma/sql-coder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ishavverma/sql-coder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ishavverma/sql-coder with Docker Model Runner:
docker model run hf.co/ishavverma/sql-coder
| license: cc-by-nc-sa-4.0 | |
| language: | |
| - en | |
| library_name: transformers | |
| tags: | |
| - text-to-sql | |
| - text2sql | |
| - nlp2sql | |
| - nlp-to-sql | |
| - SQL | |
| # Model Card for text2sql | |
| <!-- Provide a quick summary of what the model is/does. --> | |
| LLM instruction finetuned for Text-to-SQL task. | |
| ## How to Get Started with the Model | |
| Use the code below to get started with the model. | |
| ``` | |
| import torch | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| model = AutoModelForCausalLM.from_pretrained( | |
| "dataeaze/dataeaze-text2sql-codellama_7b_instruct-clinton_text_to_sql_v1", | |
| torch_dtype=torch.bfloat16, | |
| device_map='auto' | |
| ) | |
| tokenizer = AutoTokenizer.from_pretrained("dataeaze/dataeaze-text2sql-codellama_7b_instruct-clinton_text_to_sql_v1") | |
| # print("model device :", model.device) | |
| tokenizer.pad_token = tokenizer.eos_token | |
| model.eval() | |
| prompt = """ Below are sql tables schemas paired with instruction that describes a task. | |
| Using valid SQLite, write a response that appropriately completes the request for the provided tables. | |
| ### Instruction: How many transactions were made by a customer in a specific month? | |
| ### Database: RewardsProgramDB61 | |
| ### Input: | |
| CREATE SCHEMA RewardsProgram; | |
| CREATE TABLE Customer ( | |
| CustomerID INT NOT NULL AUTO_INCREMENT, | |
| FirstName VARCHAR(50) NOT NULL, | |
| LastName VARCHAR(50) NOT NULL, | |
| Email VARCHAR(100) UNIQUE NOT NULL, | |
| Phone VARCHAR(20) UNIQUE, | |
| DateOfBirth DATE, | |
| PRIMARY KEY (CustomerID) | |
| ); | |
| CREATE TABLE Membership ( | |
| MembershipID INT NOT NULL AUTO_INCREMENT, | |
| MembershipType VARCHAR(50) NOT NULL, | |
| DiscountPercentage DECIMAL(5, 2) NOT NULL, | |
| ValidFrom DATETIME, | |
| ValidTo DATETIME, | |
| CustomerID INT NOT NULL, | |
| PRIMARY KEY (MembershipID), | |
| FOREIGN KEY (CustomerID) REFERENCES Customer(CustomerID) | |
| ); | |
| CREATE TABLE Transaction ( | |
| TransactionID INT NOT NULL AUTO_INCREMENT, | |
| TransactionDate TIMESTAMP, | |
| TotalAmount DECIMAL(10, 2) NOT NULL, | |
| CustomerID INT NOT NULL, | |
| PRIMARY KEY (TransactionID), | |
| FOREIGN KEY (CustomerID) REFERENCES Customer(CustomerID) | |
| ); | |
| CREATE TABLE TransactionDetail ( | |
| TransactionDetailID INT NOT NULL AUTO_INCREMENT, | |
| TransactionID INT NOT NULL, | |
| ProductID INT NOT NULL, | |
| Quantity INT NOT NULL, | |
| UnitPrice DECIMAL(10, 2) NOT NULL, | |
| PRIMARY KEY (TransactionDetailID), | |
| FOREIGN KEY (TransactionID) REFERENCES Transaction(TransactionID), | |
| FOREIGN KEY (ProductID) REFERENCES Product(ProductID) | |
| ); | |
| CREATE TABLE Product ( | |
| ProductID INT NOT NULL AUTO_INCREMENT, | |
| ProductName VARCHAR(100) NOT NULL, | |
| UnitPrice DECIMAL(10, 2) NOT NULL, | |
| AvailableQuantity INT NOT NULL, | |
| CreatedDate DATETIME, | |
| PRIMARY KEY (ProductID) | |
| ); | |
| ALTER TABLE Membership ADD CONSTRAINT FK_Membership_Customer FOREIGN KEY (CustomerID) REFERENCES Customer(CustomerID); | |
| ALTER TABLE TransactionDetail ADD CONSTRAINT FK_TransactionDetail_Transaction FOREIGN KEY (TransactionID) REFERENCES Transaction(TransactionID); | |
| ALTER TABLE TransactionDetail ADD CONSTRAINT FK_TransactionDetail_Product FOREIGN KEY (ProductID) REFERENCES Product(ProductID);" | |
| """ | |
| input_ids = tokenizer(prompt, padding=True, return_tensors='pt') | |
| outputs = model.generate( | |
| input_ids=input_ids['input_ids'].to(model.device), | |
| attention_mask=input_ids['attention_mask'].to(model.device), | |
| max_new_tokens=3072, | |
| ) | |
| generated_query = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| print(generated_query) | |
| ``` | |
| ### Results | |
| ``` | |
| model-index: | |
| - name: dataeaze/dataeaze-text2sql-codellama_7b_instruct-dzsql | |
| results: | |
| - task: | |
| type: text-to-sql | |
| dataset: | |
| name: SPIDER 1.0 | |
| type: text-to-sql | |
| metrics: | |
| - name: Execution with Values | |
| type: Execution with Values | |
| value: 64.3 | |
| - name: Exact Set Match without Values | |
| type: Exact Set Match without Values | |
| value: 29.6 | |
| source: | |
| name: Spider 1.0 - Leaderboard | |
| url: https://yale-lily.github.io/spider | |
| ``` | |