1from transformers import (
2 AutoTokenizer,
3 AutoModelForCausalLM,
4)
5tokenizer = AutoTokenizer.from_pretrained("yuan-tian/chartgpt-llama3")
6model = AutoModelForCausalLM.from_pretrained("yuan-tian/chartgpt-llama3", device_map="auto")
7input_text = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
8Your response should follow the following format:
9Step 1. Select the columns:
10Step 2. Filter the data:
11Step 3. Add aggregate functions:
12Step 4. Choose chart type:
13Step 5. Select encodings:
14Step 6. Sort the data:
15
16### Instruction:
17Give me a visual representation of the faculty members by their professional status.
18
19### Input:
20Table Name: Faculty
21Table Header: FacID,Lname,Fname,Rank,Sex,Phone,Room,Building
22Table Header Type: quantitative,nominal,nominal,nominal,nominal,quantitative,nominal,nominal
23Table Data Example:
241082,Giuliano,Mark,Instructor,M,2424,224,NEB
251121,Goodrich,Michael,Professor,M,3593,219,NEB
26Previous Answer:
27
28
29### Response:"""
30inputs = tokenizer(input_text, return_tensors="pt", padding=True).to("cuda")
31outputs = model.generate(**inputs, max_new_tokens=256)
32print(tokenizer.decode(outputs[0], skip_special_tokens = True))