Instructions to use Arogyasami/Llama-3-8b-text2sql-finetune with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Arogyasami/Llama-3-8b-text2sql-finetune with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Arogyasami/Llama-3-8b-text2sql-finetune", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Studio
How to use Arogyasami/Llama-3-8b-text2sql-finetune with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Arogyasami/Llama-3-8b-text2sql-finetune to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Arogyasami/Llama-3-8b-text2sql-finetune to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Arogyasami/Llama-3-8b-text2sql-finetune to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="Arogyasami/Llama-3-8b-text2sql-finetune", max_seq_length=2048, )
# Llama-3 8B Text-to-SQL (Fine-Tuned with LoRA)
## π Model Overview
This repository contains a fine-tuned version of Meta's **Llama-3 (8B)**, optimized specifically for the **Natural Language to SQL (Text-to-SQL)** generation task. By converting conversational English into executable SQL queries, this model is designed to bridge the gap between non-technical stakeholders and complex relational databases.
- **Developer:** DanielMartin Arogyasami
- **Base Model:** Meta-Llama-3-8B
- **Task:** Text-to-SQL (Code Generation)
- **Fine-Tuning Methodology:** Low-Rank Adaptation (LoRA) / PEFT
- **Language:** English, SQL
- **License:** Meta Llama 3 Community License / MIT (for fine-tuned weights)
## π― Intended Use Cases
This model is highly specialized for deployment in regulated enterprise environments (e.g., healthcare, finance), where data sovereignty is paramount.
- **Enterprise Data Retrieval:** Empowering business users to query databases using natural language, significantly reducing reliance on specialized SQL programmers.
- **Agentic AI Workflows:** Serving as the SQL-generation agent within larger Retrieval-Augmented Generation (RAG) and enterprise AI architectures.
- **Privacy-Preserving Analytics:** Allowing companies to run text-to-SQL conversions entirely on-premises or within air-gapped Virtual Private Clouds (VPCs). This ensures compliance with HIPAA and FDA CFR Part 11, as no sensitive data is transmitted to external proprietary APIs.
## βοΈ Technical Details & Training
This model was trained using **Parameter-Efficient Fine-Tuning (PEFT)**. Specifically, **LoRA (Low-Rank Adaptation)** was applied to the foundational Llama-3 model. This approach adapts the foundational reasoning capabilities of Llama-3 to the strict syntax requirements of SQL generation, while significantly reducing computational overhead.
* **Adapter:** LoRA
* **Target Modules:** Attention weights (`q_proj`, `v_proj`)
* **Precision:** FP16 / 4-bit Quantization (QLoRA) supported for edge-deployment.
* **Architecture:** Auto-Regressive Transformer.
## π How to Use (Inference)
You can load this model and run inference using the `transformers` and `peft` libraries from Hugging Face.
```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# Load base model and tokenizer
base_model_id = "meta-llama/Meta-Llama-3-8B"
adapter_id = "Arogyasami/Llama-3-8b-text2sql-finetune"
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
base_model = AutoModelForCausalLM.from_pretrained(base_model_id, torch_dtype=torch.float16, device_map="auto")
# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, adapter_id)
# Define your schema and question
schema = "CREATE TABLE Employees (ID int, Name varchar(255), Department varchar(255), Salary int);"
question = "What is the average salary of employees in the Sales department?"
prompt = f"Given the following database schema:\n{schema}\n\nWrite a SQL query to answer this question: {question}\n\nSQL:"
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
# Generate SQL
outputs = model.generate(**inputs, max_new_tokens=100)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
β οΈ Limitations & Bias
- Deterministic Requirement: Generative AI models can "hallucinate." While fine-tuned to minimize this, generated queries must be validated before execution, especially in clinical contexts where erroneous data retrieval could impact regulatory submissions.
- Schema Complexity: While the model performs exceptionally well on standard schemas, highly complex schemas with dozens of nested joins may reduce accuracy.
- Security: Always execute generated SQL in a safe, read-only environment. The model does not inherently enforce database permissions.
π Environmental Impact
By utilizing LoRA instead of full-parameter fine-tuning, the computational cost and carbon footprint required to train this model were drastically reduced. Its 8B parameter size allows it to be served efficiently on consumer-grade hardware (e.g., NVIDIA RTX 4090 or A10G), democratizing advanced AI access.
π€ Acknowledgements & Citation
- Meta for the foundational Llama-3 architecture.
- If this model assists in your research or enterprise architecture, please cite: Arogyasami, DanielMartin. (2024). Llama-3 8B Text-to-SQL (Fine-Tuned with LoRA). Hugging Face.
- Downloads last month
- 4
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support
Model tree for Arogyasami/Llama-3-8b-text2sql-finetune
Base model
meta-llama/Meta-Llama-3-8B Quantized
unsloth/llama-3-8b-bnb-4bit