Views
No views yet
1# pip install -q transformers
2from transformers import AutoModelForCausalLM, AutoTokenizer
3checkpoint = "sahil2801/instruct-codegen-16B"
4device = "cuda"
5tokenizer = AutoTokenizer.from_pretrained(checkpoint)
6model = AutoModelForCausalLM.from_pretrained(checkpoint).half().to(device)
7instruction = "Write a function to scrape hacker news."
8prompt = f"Below is an instruction that describes a task.\n Write a response that appropriately completes the request.\n\n ### Instruction:\n{instruction}\n\n### Response:"
9inputs = tokenizer(prompt, return_tensors="pt").to(device)
10outputs = model.generate(**inputs,temperature=0.3,do_sample=True,max_new_tokens=256)
11print(tokenizer.decode(outputs[0],skip_special_tokens=True))