Files changed (1) hide show
  1. README.md +98 -0
README.md ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: meta-llama/Meta-Llama-3-8B-Instruct
3
+ library_name: transformers
4
+ tags:
5
+ - axolotl
6
+ - finetune
7
+ - dpo
8
+ - facebook
9
+ - meta
10
+ - pytorch
11
+ - llama
12
+ - llama-3
13
+ language:
14
+ - en
15
+ pipeline_tag: text-generation
16
+ license: llama3
17
+ license_name: llama3
18
+ license_link: LICENSE
19
+ inference: false
20
+ model_creator: MaziyarPanahi
21
+ model_name: Llama-3-8B-Instruct-DPO-v0.3
22
+ quantized_by: MaziyarPanahi
23
+ datasets:
24
+ - Intel/orca_dpo_pairs
25
+ ---
26
+
27
+ <img src="./llama-3-merges.webp" alt="Llama-3 DPO Logo" width="500" style="margin-left:'auto' margin-right:'auto' display:'block'"/>
28
+
29
+
30
+ # Llama-3-8B-Instruct-DPO-v0.3
31
+
32
+ This model is a fine-tune (DPO) of `meta-llama/Meta-Llama-3-8B-Instruct` model.
33
+
34
+ # How to use
35
+
36
+ You can use this model by using `MaziyarPanahi/Llama-3-8B-Instruct-DPO-v0.3` as the model name in Hugging Face's
37
+ transformers library.
38
+
39
+ ```python
40
+ from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
41
+ from transformers import pipeline
42
+ import torch
43
+
44
+ model_id = "MaziyarPanahi/Llama-3-8B-Instruct-DPO-v0.3"
45
+
46
+ model = AutoModelForCausalLM.from_pretrained(
47
+ model_id,
48
+ torch_dtype=torch.bfloat16,
49
+ device_map="auto",
50
+ trust_remote_code=True,
51
+ # attn_implementation="flash_attention_2"
52
+ )
53
+
54
+ tokenizer = AutoTokenizer.from_pretrained(
55
+ model_id,
56
+ trust_remote_code=True
57
+ )
58
+
59
+ streamer = TextStreamer(tokenizer)
60
+
61
+ pipeline = pipeline(
62
+ "text-generation",
63
+ model=model,
64
+ tokenizer=tokenizer,
65
+ model_kwargs={"torch_dtype": torch.bfloat16},
66
+ streamer=streamer
67
+ )
68
+
69
+ # Then you can use the pipeline to generate text.
70
+
71
+ messages = [
72
+ {"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
73
+ {"role": "user", "content": "Who are you?"},
74
+ ]
75
+
76
+ prompt = tokenizer.apply_chat_template(
77
+ messages,
78
+ tokenize=False,
79
+ add_generation_prompt=True
80
+ )
81
+
82
+ terminators = [
83
+ tokenizer.eos_token_id,
84
+ tokenizer.convert_tokens_to_ids("<|im_end|>")
85
+ ]
86
+
87
+ outputs = pipeline(
88
+ prompt,
89
+ max_new_tokens=256,
90
+ eos_token_id=terminators,
91
+ do_sample=True,
92
+ temperature=0.6,
93
+ top_p=0.95,
94
+ )
95
+ print(outputs[0]["generated_text"][len(prompt):])
96
+ ```
97
+
98
+