File size: 1,664 Bytes
e8c5ea3 6cbe5c0 7c4aad7 6cbe5c0 cfcf518 6cbe5c0 cfcf518 6cbe5c0 cfcf518 6cbe5c0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
---
datasets:
- b-mc2/sql-create-context
language:
- en
library_name: transformers
pipeline_tag: text2text-generation
tags:
- text-2-sql
- text-generation-inference
---
This Model is based on Llama-2 7B model provided by Meta. The Model accepts text and return SQL-query. This Model has been fine-tuned on "NousResearch/Llama-2-7b-hf".
```python
! pip install transformers accelerate
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text2text-generation", model="ekshat/Llama-2-7b-chat-finetune-for-text2sql")
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("ekshat/Llama-2-7b-chat-finetune-for-text2sql")
model = AutoModelForCausalLM.from_pretrained("ekshat/Llama-2-7b-chat-finetune-for-text2sql")
# Run text generation pipeline with our model
context = "CREATE TABLE Student (name VARCHAR, college VARCHAR, age VARCHAR, group VARCHAR, marks VARCHAR)"
question = "List the name of Students belongs to school 'St. Xavier' and having marks greater than '600'"
prompt = f"""Below is an context that describes a sql query, paired with an question that provides further information. Write an answer that appropriately completes the request.
### Context:
{context}
### Question:
{question}
### Answer:"""
sequences = pipeline(
prompt,
do_sample=True,
top_k=10,
num_return_sequences=1,
eos_token_id=tokenizer.eos_token_id,
max_length=200,
)
for seq in sequences:
print(f"Result: {seq['generated_text']}")
``` |