File size: 1,022 Bytes
ab39a22
 
 
 
7b7e34c
ab39a22
 
 
 
 
fb65e44
 
 
 
dcafe3f
55caf1f
 
 
 
 
dcafe3f
55caf1f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b7e34c
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
---
license: apache-2.0
language:
- en
- zh
metrics:
- accuracy
library_name: transformers
tags:
- text2sql
---



# 1.Usage:
```python
# 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])
```