license: apache-2.0
language:
- en
tags:
- nlp
- code-generation
- sql
- transformers
- finetuned-model
Finetuned CodeGen for SQL Query Generation
Model Description
This model is a fine-tuned version of the Salesforce CodeGen model with 350M parameters, specialized in generating SQL queries from plain English text descriptions. It leverages the power of large language models to understand natural language and convert it into executable SQL, making it easier for analysts, developers, and data enthusiasts to interact with databases without deep SQL expertise.
Intended Use
This model is intended for the automatic generation of SQL queries from descriptions in English. It can be used to:
- Quickly generate sample SQL queries for database analysis and reporting.
- Assist in educational environments for learning SQL syntax.
- Provide non-technical users with the ability to know how to retrieve data from databases using natural language.
How to Use
This model can be used with the Hugging Face Transformers library. Here is a quick example:
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("ansumanpandey/codgen-finetuned-SQLQueryGeneration") model = AutoModelForCausalLM.from_pretrained("ansumanpandey/codgen-finetuned-SQLQueryGeneration")
def get_sql(query): input_text = "Write a SQL query to %s " % query features = tokenizer([input_text], return_tensors='pt')
output = model.generate(input_ids=features['input_ids'], attention_mask=features['attention_mask'], max_new_tokens=70) sql_query= tokenizer.decode(output[0]) return sql_query