mix-llama-3-8B-inst-line is a merge of the following models using
LazyMergekit:
1dtype: bfloat16
2merge_method: linear
3slices:
4 - sources:
5 - layer_range: [0, 32] # Assuming the first half of the model is more general and can be reduced more
6 model: NousResearch/Meta-Llama-3-8B-Instruct
7 parameters:
8 weight: 1.0 # Reduce the weight of the first half to make room for the second half
9 - layer_range: [0, 32] # Assuming the second half of the model is more specialized and can be reduced less
10 model: NousResearch/Meta-Llama-3-8B-Instruct
11 parameters:
12 weight: 1.0 # Maintain the weight of the second half
13
1!pip install -qU transformers accelerate
2
3from transformers import AutoTokenizer
4import transformers
5import torch
6
7model = "JoPmt/mix-llama-3-8B-inst-line"
8messages = [{"role": "user", "content": "What is a large language model?"}]
9
10tokenizer = AutoTokenizer.from_pretrained(model)
11prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
12pipeline = transformers.pipeline(
13 "text-generation",
14 model=model,
15 torch_dtype=torch.float16,
16 device_map="auto",
17)
18
19outputs = pipeline(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
20print(outputs[0]["generated_text"])