Views
No views yet
SELECT queries.1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3tokenizer = AutoTokenizer.from_pretrained("NumbersStation/nsql-llama-2-7B")
4model = AutoModelForCausalLM.from_pretrained("NumbersStation/nsql-llama-2-7B", torch_dtype=torch.bfloat16)
5
6text = """CREATE TABLE stadium (
7 stadium_id number,
8 location text,
9 name text,
10 capacity number,
11 highest number,
12 lowest number,
13 average number
14)
15
16CREATE TABLE singer (
17 singer_id number,
18 name text,
19 country text,
20 song_name text,
21 song_release_year text,
22 age number,
23 is_male others
24)
25
26CREATE TABLE concert (
27 concert_id number,
28 concert_name text,
29 theme text,
30 stadium_id text,
31 year text
32)
33
34CREATE TABLE singer_in_concert (
35 concert_id number,
36 singer_id text
37)
38
39-- Using valid SQLite, answer the following questions for the tables provided above.
40
41-- What is the maximum, the average, and the minimum capacity of stadiums ?
42
43SELECT"""
44
45input_ids = tokenizer(text, return_tensors="pt").input_ids
46
47generated_ids = model.generate(input_ids, max_length=500)
48print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3tokenizer = AutoTokenizer.from_pretrained("NumbersStation/nsql-llama-2-7B")
4model = AutoModelForCausalLM.from_pretrained("NumbersStation/nsql-llama-2-7B", torch_dtype=torch.bfloat16)
5
6text = """CREATE TABLE stadium (
7 stadium_id number,
8 location text,
9 name text,
10 capacity number,
11)
12
13-- Using valid SQLite, answer the following questions for the tables provided above.
14
15-- how many stadiums in total?
16
17SELECT"""
18
19input_ids = tokenizer(text, return_tensors="pt").input_ids
20
21generated_ids = model.generate(input_ids, max_length=500)
22print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3tokenizer = AutoTokenizer.from_pretrained("NumbersStation/nsql-llama-2-7B")
4model = AutoModelForCausalLM.from_pretrained("NumbersStation/nsql-llama-2-7B", torch_dtype=torch.bfloat16)
5
6text = """CREATE TABLE work_orders (
7 ID NUMBER,
8 CREATED_AT TEXT,
9 COST FLOAT,
10 INVOICE_AMOUNT FLOAT,
11 IS_DUE BOOLEAN,
12 IS_OPEN BOOLEAN,
13 IS_OVERDUE BOOLEAN,
14 COUNTRY_NAME TEXT,
15)
16
17-- Using valid SQLite, answer the following questions for the tables provided above.
18
19-- how many work orders are open?
20
21SELECT"""
22
23input_ids = tokenizer(text, return_tensors="pt").input_ids
24
25generated_ids = model.generate(input_ids, max_length=500)
26print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))