Views
No views yet
1from datasets import load_dataset
2from huggingface_hub import snapshot_download
3from transformers import pipeline
4
5# Load validation split
6valid = load_dataset("McGill-NLP/weblinx", split="validation")
7
8# Download and load the templates
9snapshot_download(
10 "McGill-NLP/WebLINX", repo_type="dataset", allow_patterns="templates/*.txt", local_dir="./"
11)
12with open('templates/llama.txt') as f:
13 template = f.read()
14
15turn = valid[0]
16turn_text = template.format(**turn)
17
18# Load action model and input the text to get prediction
19action_model = pipeline(
20 model="McGill-NLP/Llama-2-13b-chat-weblinx", device=0, torch_dtype='auto'
21)
22out = action_model(turn_text, return_full_text=False, max_new_tokens=64, truncation=True)
23pred = out[0]['generated_text']
24
25print("Ref:", turn["action"])
26print("Pred:", pred)