模型:
VMware/open-llama-13b-open-instruct
Instruction-tuned version of the fully trained Open LLama 13B model. The model is open for COMMERCIAL USE.
注意:该模型是使用Alpaca提示模板进行训练的。注意:快速分词器会导致错误的编码,当实例化分词器时,请将use_fast = False参数设置为false。注意:由于分词器会合并多个空格,因此该模型可能在处理代码时遇到困难
import os import torch from transformers import AutoModelForCausalLM, AutoTokenizer model_name = 'VMware/open-llama-13b-open-instruct' tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=False) model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map='sequential') prompt_template = "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n### Instruction:\n{instruction}\n\n### Response:" prompt = 'Explain in simple terms how the attention mechanism of a transformer model works' inputt = prompt_template.format(instruction= prompt) input_ids = tokenizer(inputt, return_tensors="pt").input_ids.to("cuda") output1 = model.generate(input_ids, max_length=512) input_length = input_ids.shape[1] output1 = output1[:, input_length:] output = tokenizer.decode(output1[0]) print(output)
微调脚本将在我们的 RAIL Github Repository 中提供
TODO