Downloads ยท 30 days
24
27% of all-time downloads
mohhhhhit/nonoql
nonoql is a text generation model from mohhhhhit. Use it when you need the model to write or continue text. The card lists the license as apache-2.0.
NoNoQL (formerly TexQL) is a T5-based transformer model that converts natural language queries into both SQL and MongoDB queries. It supports SELECT, INSERT, UPDATE, DELETE, and other database operations.
Downloads ยท 30 days
24
27% of all-time downloads
All-time downloads
89
Public
Parameters
60.5M
242 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors484 MB ยท 99%
From the Hugging Face model README
NoNoQL (formerly TexQL) is a T5-based transformer model that converts natural language queries into both SQL and MongoDB queries. It supports SELECT, INSERT, UPDATE, DELETE, and other database operations.
This model translates natural language database queries into syntactically correct SQL and MongoDB commands. It's trained on a custom dataset of 30,000+ query pairs covering various database operations, tables, and query patterns.
translate to {sql|mongodb}: {natural_language_query}pip install transformers torch
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
# Load model and tokenizer
model_name = "mohhhhhit/nonoql" # Replace with your HF model path
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
# Generate SQL query
def generate_query(natural_language, target_type='sql'):
input_text = f"translate to {target_type}: {natural_language}"
inputs = tokenizer(input_text, return_tensors="pt", max_length=256, truncation=True)
outputs = model.generate(
**inputs,
max_length=512,
num_beams=10,
temperature=0.3,
repetition_penalty=1.2,
length_penalty=0.8,
early_stopping=True
)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
# Example usage
nl_query = "Find employees where salary is greater than 50000"
sql_query = generate_query(nl_query, target_type='sql')
print(f"SQL: {sql_query}")
# Output: SELECT * FROM employees WHERE salary > 50000;
mongodb_query = generate_query(nl_query, target_type='mongodb')
print(f"MongoDB: {mongodb_query}")
# Output: db.employees.find({"salary": {$gt: 50000}});
| Natural Language | SQL Output | MongoDB Output |
|---|---|---|
| Show all employees | SELECT * FROM employees; | db.employees.find({}); |
| Find products where price is less than 100 | SELECT * FROM products WHERE price < 100; | db.products.find({"price": {$lt: 100}}); |
| Update employees set department to Sales where employee_id is 101 | UPDATE employees SET department = 'Sales' WHERE employee_id = 101; | db.employees.updateMany({employee_id: 101}, {$set: {department: "Sales"}}); |
| Delete orders with total_amount less than 1000 | DELETE FROM orders WHERE total_amount < 1000; | db.orders.deleteMany({"total_amount": {$lt: 1000}}); |
| Insert a new employee with name John, email john@example.com | INSERT INTO employees (name, email) VALUES ('John', 'john@example.com'); | db.employees.insertOne({"name": "John", "email": "john@example.com"}); |
training_args = {
"learning_rate": 3e-4,
"per_device_train_batch_size": 8,
"per_device_eval_batch_size": 8,
"num_train_epochs": 10,
"weight_decay": 0.01,
"warmup_steps": 500,
"max_seq_length": 512,
}
The model includes several post-processing fixes to handle common issues:
= to >, <, >=, <= based on keywords like "greater than", "less than"| Issue | Fix Applied |
|---|---|
Model outputs = instead of > or < | Post-processing detects comparison keywords and replaces operators |
MongoDB missing {} braces | Adds curly braces around query objects |
SELECT instead of DELETE | Detects operation intent from keywords |
| Incomplete UPDATE queries | Reconstructs from natural language parsing |
If you use this model in your research or application, please cite:
@misc{nonoql2026,
title={NoNoQL: Natural Language to SQL and MongoDB Query Generation},
author={Mohit Panchal},
year={2026},
howpublished={\url{https://huggingface.co/mohhhhhit/nonoql}},
}
This model is released under the Apache 2.0 License.
Contributions, feedback, and suggestions are welcome! Please feel free to:
Note: This model is designed for educational and prototyping purposes. Always validate generated queries before executing them on production databases.