CoolFace
Modelpublic

Karan6124/t5-nl2sql-gen

sourceHugging Facemitupdated 6mo agoView on Hugging Face
2likes14downloads
Model Card

๐Ÿค– T5-NL2SQL-Gen Specialist

This model is a fine-tuned T5-Small architecture specialized for converting Natural Language questions into precise PostgreSQL queries. It serves as the primary "Reasoning Specialist" within the NLP2SQL Autonomous Intelligence Layer.

๐Ÿš€ Model Details

  • โ€”Architecture: T5 (Text-to-Text Transfer Transformer)
  • โ€”Specialization: PostgreSQL Query Generation
  • โ€”Training Data: Fine-tuned on SQL-specific datasets (Spider/WikiSQL) and custom schema-mapped samples.
  • โ€”Project Role: Acts as the initial SQL Generator in a Hybrid Agentic loop.

๐Ÿ”„ Hybrid Agentic Flow

This model is designed to work in tandem with Large Language Models (like Gemini 2.0 Flash) in a structured multi-agent workflow:

  1. 1.Local ML (T5): Generates the initial high-speed SQL draft.
  2. 2.Gemini Auditor: Validates the draft against the actual schema, adds double-quotes, and fixes hallucinations.
  3. 3.Self-Healing Loop: If execution fails, the agents use this model's logic to refine the plan.

๐Ÿ”— Project Context

This model is the engine for the NLP2SQL Platform.

  • โ€”GitHub Repository: sumit08099/NLP_SQL_GEN
  • โ€”Frontend: React 19 / Vite
  • โ€”Backend: FastAPI / LangGraph

๐Ÿ›  Usage (Hugging Face Transformers)

python
from transformers import T5Tokenizer, T5ForConditionalGeneration

model_name = "Karan6124/t5-nl2sql-gen"
tokenizer = T5Tokenizer.from_pretrained(model_name)
model = T5ForConditionalGeneration.from_pretrained(model_name)

input_text = "translate English to SQL: How many users signed up in the last 30 days? \n Context: Table users (id, username, created_at)"
inputs = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(**inputs, max_length=512)

print(tokenizer.decode(outputs[0], skip_special_tokens=True))