hjd's picture
Update README.md
55caf1f verified
|
raw
history blame
1.02 kB
metadata
license: apache-2.0
language:
  - en
  - ch
metrics:
  - accuracy
library_name: transformers
tags:
  - text2sql

1.Usage:

# Use a pipeline as a high-level helper
from transformers import pipeline
import torch
model_id = "xbrain/text2sql-8b-instruct-v1"


messages = [
    {"role": "system", 
     "content": "I want you to act as a SQL terminal in front of an example database, you need only to return the sql command to me.Below is an instruction that describes a task, Write a response that appropriately completes the request.\n\"\n##Instruction:\n database contains tables such as table_name_30. Table table_name_30 has columns such as nfl_team, draft_year."},
    {"role": "user", 
     "content": "###Input:\nIn 1978 what is the NFL team?\n\n###Response:"},
]
pipe_msg = pipeline(
    "text-generation",
    model=model_id,
    model_kwargs={"torch_dtype": torch.bfloat16},
    device_map="auto",)

outputs = pipe_msg(
    messages,
    max_new_tokens=256,
)
print(outputs[0]["generated_text"][-1])