YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.


---
license: apache-2.0
language:
- en
- sql
datasets:
- wikisql
tags:
- text2text-generation
- t5
- sql
---

# Bidirectional SQL <-> Natural Language Converter

This is a fine-tuned version of the `t5-small` model, specifically trained to perform bidirectional translation between natural language questions (English) and SQL queries.

This model was trained on the [WikiSQL dataset](https://www.kaggle.com/datasets/thedevastator/dataset-for-developing-natural-language-interfac) as part of a portfolio project. The entire training process is documented in the accompanying [Google Colab notebook](<LINK_TO_YOUR_NOTEBOOK_IF_PUBLIC>).

## ๐Ÿš€ Model Capabilities

This single model can perform two distinct tasks based on the prefix provided:

1.  **Translate English to SQL:** Converts a user's question into a valid SQL query.
2.  **Translate SQL to English:** Converts a SQL query into a human-readable question.

---

## โš™๏ธ How to Use

You can use this model directly with the `transformers` library pipeline.

### English to SQL

```python
from transformers import T5ForConditionalGeneration, T5Tokenizer

model_name = "your-hf-username/bidirectional-sql-converter"
tokenizer = T5Tokenizer.from_pretrained(model_name)
model = T5ForConditionalGeneration.from_pretrained(model_name)

question = "What is the nationality of the player from duke?"
input_text = "translate English to SQL: " + question

inputs = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(**inputs, max_length=128)

generated_sql = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(generated_sql)
# Expected output: SELECT Nationality FROM table WHERE School/Club Team = Duke

SQL to English

from transformers import T5ForConditionalGeneration, T5Tokenizer

model_name = "your-hf-username/bidirectional-sql-converter"
tokenizer = T5Tokenizer.from_pretrained(model_name)
model = T5ForConditionalGeneration.from_pretrained(model_name)

sql_query = "SELECT Nationality FROM table WHERE School/Club Team = Duke"
input_text = "translate SQL to English: " + sql_query

inputs = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(**inputs, max_length=128)

generated_question = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(generated_question)
# Expected output: What is the nationality of the player from Duke?

๐Ÿง  Training Details

  • Base Model: t5-small
  • Dataset: WikiSQL
  • Training Environment: Google Colab with a T4 GPU.
  • Experiment Tracking: All training metrics, including loss and validation, were tracked using Weights & Biases.

Downloads last month
5
Safetensors
Model size
60.5M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support