Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model = AutoModelForCausalLM.from_pretrained("pandoradox/llama-3.1-8B-table-finetuned")
4tokenizer = AutoTokenizer.from_pretrained("pandoradox/llama-3.1-8B-table-finetuned")
5
6# Format your input with a table
7prompt = '''
8<|system|>
9You are an expert at analyzing tables and answering questions about them.
10<|end|>
11<|user|>
12Based on the following table:
13
14Table title: Example Table
15
16Headers: Name, Age, City
17
18Row 1: John, 30, New York
19Row 2: Jane, 25, Boston
20Row 3: Bob, 35, Chicago
21
22Question: Who is the oldest person in the table?
23<|end|>
24<|assistant|>
25'''
26
27inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
28outputs = model.generate(**inputs, max_length=2048)
29response = tokenizer.decode(outputs[0], skip_special_tokens=True)
30print(response)