Text Generation
Transformers
Safetensors
English
llama
text-to-sql
conversational
text-generation-inference
Instructions to use Ary-007/Text-to-sql-llama-3.2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Ary-007/Text-to-sql-llama-3.2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Ary-007/Text-to-sql-llama-3.2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Ary-007/Text-to-sql-llama-3.2") model = AutoModelForCausalLM.from_pretrained("Ary-007/Text-to-sql-llama-3.2", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Ary-007/Text-to-sql-llama-3.2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Ary-007/Text-to-sql-llama-3.2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Ary-007/Text-to-sql-llama-3.2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Ary-007/Text-to-sql-llama-3.2
- SGLang
How to use Ary-007/Text-to-sql-llama-3.2 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 "Ary-007/Text-to-sql-llama-3.2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Ary-007/Text-to-sql-llama-3.2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "Ary-007/Text-to-sql-llama-3.2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Ary-007/Text-to-sql-llama-3.2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Ary-007/Text-to-sql-llama-3.2 with Docker Model Runner:
docker model run hf.co/Ary-007/Text-to-sql-llama-3.2
Update README.md
Browse files
README.md
CHANGED
|
@@ -19,9 +19,9 @@ This model is a fine-tuned version of Llama-3.2-3B-Instruct designed specificall
|
|
| 19 |
It is lightweight (3B parameters), making it suitable for local deployment on consumer GPUs using 4-bit quantization.
|
| 20 |
|
| 21 |
### Model Description
|
| 22 |
-
Base Model: unsloth/Llama-3.2-3B-Instruct
|
| 23 |
-
Fine-tuning Framework: Unsloth (QLoRA)
|
| 24 |
-
Dataset: gretelai/synthetic_text_to_sql
|
| 25 |
|
| 26 |
|
| 27 |
## Uses
|
|
@@ -32,11 +32,54 @@ The model was trained using the Alpaca prompt format. For best results, structur
|
|
| 32 |

|
| 33 |
|
| 34 |
## How to Get Started with the Model
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
|
|
|
| 19 |
It is lightweight (3B parameters), making it suitable for local deployment on consumer GPUs using 4-bit quantization.
|
| 20 |
|
| 21 |
### Model Description
|
| 22 |
+
1) Base Model: unsloth/Llama-3.2-3B-Instruct
|
| 23 |
+
2) Fine-tuning Framework: Unsloth (QLoRA)
|
| 24 |
+
3) Dataset: gretelai/synthetic_text_to_sql
|
| 25 |
|
| 26 |
|
| 27 |
## Uses
|
|
|
|
| 32 |

|
| 33 |
|
| 34 |
## How to Get Started with the Model
|
| 35 |
+
'''python
|
| 36 |
+
|
| 37 |
+
import torch
|
| 38 |
+
from transformers import pipeline
|
| 39 |
+
|
| 40 |
+
model_id = "Ary-007/Text-to-sql-llama-3.2"
|
| 41 |
+
|
| 42 |
+
# Load the pipeline
|
| 43 |
+
pipe = pipeline(
|
| 44 |
+
"text-generation",
|
| 45 |
+
model=model_id,
|
| 46 |
+
device_map="auto",
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
# Define the schema (Context)
|
| 50 |
+
schema = """
|
| 51 |
+
CREATE TABLE employees (
|
| 52 |
+
id INT,
|
| 53 |
+
name TEXT,
|
| 54 |
+
department TEXT,
|
| 55 |
+
salary INT,
|
| 56 |
+
hire_date DATE
|
| 57 |
+
);
|
| 58 |
+
"""
|
| 59 |
+
|
| 60 |
+
# Define the user question
|
| 61 |
+
question = "Find the name and salary of employees in the 'Engineering' department who earn more than 80000."
|
| 62 |
+
|
| 63 |
+
# Format the prompt exactly as trained
|
| 64 |
+
prompt = f"""Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
| 65 |
+
|
| 66 |
+
### Instruction:
|
| 67 |
+
Company Database : {schema}
|
| 68 |
+
|
| 69 |
+
### Input:
|
| 70 |
+
SQL Prompt :{question}
|
| 71 |
+
|
| 72 |
+
### Response:
|
| 73 |
+
"""
|
| 74 |
+
|
| 75 |
+
outputs = pipe(
|
| 76 |
+
prompt,
|
| 77 |
+
max_new_tokens=200,
|
| 78 |
+
do_sample=True,
|
| 79 |
+
temperature=0.1,
|
| 80 |
+
top_p=0.9
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
+
print(outputs[0]["generated_text"])
|
| 84 |
+
'''
|
| 85 |
|