Run this model with HF Jobs
Run DebeshSahoo/text2sql-finetune on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/DebeshSahoo/text2sql-finetune. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/DebeshSahoo/text2sql-finetune on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use DebeshSahoo/text2sql-finetune with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use DebeshSahoo/text2sql-finetune with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="DebeshSahoo/text2sql-finetune")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("DebeshSahoo/text2sql-finetune") model = AutoModelForSeq2SeqLM.from_pretrained("DebeshSahoo/text2sql-finetune", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Debesh Sahoo commited on
Commit ·
e66ad92
1
Parent(s): a280f47
text2sql finetune
Browse files123456789101112131415161718192021222324252627282930313233343536from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
# Load the tokenizertokenizer = AutoTokenizer.from_pretrained("t5-small")
# Load the modelmodel = AutoModelForSeq2SeqLM.from_pretrained("t5-small")
# Rest of the code for preparing input, generating predictions, and decoding the output...
from typing import List
table_prefix = "table:"question_prefix = "question:"
def prepare_input(question: str, table: List[str]): print("question:", question) print("table:", table) join_table = ",".join(table) inputs = f"{question_prefix} {question} {table_prefix} {join_table}" input_ids = tokenizer(inputs, max_length=700, return_tensors="pt").input_ids return input_ids
def inference(question: str, table: List[str]) -> str: input_data = prepare_input(question=question, table=table) input_data = input_data.to(model.device) outputs = model.generate(inputs=input_data, num_beams=10, top_k=10, max_length=512) result = tokenizer.decode(token_ids=outputs[0], skip_special_tokens=True) return result
test_id = 1000print("model result:", inference(dataset["test"][test_id]["question"], dataset["test"][test_id]["table"]["header"]))print("real result:", dataset["test"][test_id]["sql"]["human_readable"])
inference("what is id with name jui and age equal 25", ["id","name", "age"])README.mdAdded+36