Views
No views yet

This model uses PoSE to extend Llama's context length from 8k to 64k @ rope_theta: 500000.0. We used PoSE with continued pretraining on 300M tokens from the RedPajama V1 dataset using data between 6k-8k tokens. We have further set rope_theta to 2M after continued pre-training to potentially further extend the context past 64k. This was trained on a subset of the RedPajama v1 dataset with text between 6k-8k context. We trained a rank stabilized LoRA of rank 256. WandB
64000: MaziyarPanahi/Llama-3-8B-Instruct-64k-GGUFMaziyarPanahi/Llama-3-8B-Instruct-DPO-v0.3 as the model name in Hugging Face's
transformers library.1from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
2from transformers import pipeline
3import torch
4
5model_id = "MaziyarPanahi/Llama-3-8B-Instruct-64k"
6
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 torch_dtype=torch.bfloat16,
10 device_map="auto",
11 trust_remote_code=True,
12 # attn_implementation="flash_attention_2"
13)
14
15tokenizer = AutoTokenizer.from_pretrained(
16 model_id,
17 trust_remote_code=True
18)
19
20streamer = TextStreamer(tokenizer)
21
22pipeline = pipeline(
23 "text-generation",
24 model=model,
25 tokenizer=tokenizer,
26 model_kwargs={"torch_dtype": torch.bfloat16},
27 streamer=streamer
28)
29
30# Then you can use the pipeline to generate text.
31
32messages = [
33 {"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
34 {"role": "user", "content": "Who are you?"},
35]
36
37prompt = tokenizer.apply_chat_template(
38 messages,
39 tokenize=False,
40 add_generation_prompt=True
41)
42
43terminators = [
44 tokenizer.eos_token_id,
45 tokenizer.convert_tokens_to_ids("<|im_end|>")
46]
47
48outputs = pipeline(
49 prompt,
50 max_new_tokens=8192,
51 eos_token_id=terminators,
52 do_sample=True,
53 temperature=0.6,
54 top_p=0.95,
55)
56print(outputs[0]["generated_text"][len(prompt):])