模型:
instruct-codegen-16B 是一个基于 Salesforce codegen-16B-multi 的指令跟随代码生成模型,在 ALPACA 格式的 25 万条指令跟随样本上进行了微调。
这些数据不是使用任何商业 LLM API 生成的。
该模型在 HumanEval 基准测试上取得了 37.1% 的一次通过率。
# pip install -q transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
checkpoint = "sahil2801/instruct-codegen-16B"
device = "cuda"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForCausalLM.from_pretrained(checkpoint).half().to(device)
instruction = "Write a function to scrape hacker news."
prompt = 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:"
inputs = tokenizer(prompt, return_tensors="pt").to(device)
outputs = model.generate(**inputs,temperature=0.3,do_sample=True,max_new_tokens=256)
print(tokenizer.decode(outputs[0],skip_special_tokens=True))