Views
No views yet
word embedding is the sum of the weights of the trained model and the original LLaMA,
so as to ensure that developers with LLaMA original model accessibility can convert the model released by this hub into a usable one.1python3 embedding_convert.py \
2 --model_dir /path_to_BiLLa/BiLLa-7B-SFT \
3 --meta_llama_pth_file /path_to_LLaMA/llama-7b/consolidated.00.pth1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3model_path = "/path_to_BiLLa/BiLLa-7B-SFT"
4tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False)
5model = AutoModelForCausalLM.from_pretrained(model_path, low_cpu_mem_usage=True, torch_dtype=torch.float16).cuda()
6
7prompt = "Human: Write a Python function that checks if a given number is even or odd.\nAssistant: "
8input_ids = tokenizer([prompt]).input_ids
9output_ids = model.generate(
10 torch.as_tensor(input_ids).cuda(),
11 do_sample=True,
12 temperature=0.7,
13 max_new_tokens=1024
14 )
15output_ids = output_ids[0][len(input_ids[0]):]
16
17outputs = tokenizer.decode(output_ids, skip_special_tokens=True).strip()
18print(outputs)BiLLa-7B-SFT should be formatted as follows:Human: [Your question]
Assistant: Assistant: