saucam commited on
Commit
840b25c
β€’
1 Parent(s): 38dba10

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +96 -0
README.md CHANGED
@@ -22,6 +22,102 @@ This llama model was trained 2x faster with [Unsloth](https://github.com/unsloth
22
 
23
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  ## Training
27
 
 
22
 
23
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
24
 
25
+ ## Usage with Unsloth
26
+
27
+
28
+ ```
29
+ from unsloth.chat_templates import get_chat_template
30
+ from unsloth import FastLanguageModel
31
+
32
+ max_seq_length = 2048
33
+ dtype = None
34
+ model, tokenizer = FastLanguageModel.from_pretrained(
35
+ model_name = "saucam/Saga-8B", # Choose ANY! eg teknium/OpenHermes-2.5-Mistral-7B
36
+ max_seq_length = max_seq_length,
37
+ dtype = dtype,
38
+ load_in_4bit = False,
39
+ # token = "hf_...", # use one if using gated models like meta-llama/Llama-2-7b-hf
40
+ )
41
+
42
+ tokenizer = get_chat_template(
43
+ tokenizer,
44
+ chat_template = "chatml", # Supports zephyr, chatml, mistral, llama, alpaca, vicuna, vicuna_old, unsloth
45
+ mapping = {"role" : "from", "content" : "value", "user" : "human", "assistant" : "gpt"}, # ShareGPT style
46
+ map_eos_token = True, # Maps <|im_end|> to </s> instead
47
+ )
48
+
49
+ FastLanguageModel.for_inference(model) # Enable native 2x faster inference
50
+
51
+ messages = [
52
+ {"from": "human", "value": "What is a famous tall tower in Paris?"},
53
+ ]
54
+ inputs = tokenizer.apply_chat_template(
55
+ messages,
56
+ tokenize = True,
57
+ add_generation_prompt = True, # Must add for generation
58
+ return_tensors = "pt",
59
+ ).to("cuda")
60
+
61
+ outputs = model.generate(input_ids = inputs, max_new_tokens = 64, use_cache = True)
62
+ print(tokenizer.batch_decode(outputs))
63
+ ```
64
+
65
+ Output:
66
+ ```
67
+ ==((====))== Unsloth: Fast Llama patching release 2024.4
68
+ \\ /| GPU: NVIDIA A100 80GB PCIe. Max memory: 79.151 GB. Platform = Linux.
69
+ O^O/ \_/ \ Pytorch: 2.2.0+cu121. CUDA = 8.0. CUDA Toolkit = 12.1.
70
+ \ / Bfloat16 = TRUE. Xformers = 0.0.24. FA = True.
71
+ "-____-" Free Apache license: http://github.com/unslothai/unsloth
72
+ Loading checkpoint shards: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4/4 [00:03<00:00, 1.19it/s]
73
+ Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
74
+ Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
75
+ Unsloth: Will map <|im_end|> to EOS = <|im_end|>.
76
+ The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
77
+ Setting `pad_token_id` to `eos_token_id`:128001 for open-end generation.
78
+ ['<|im_start|>user\nWhat is a famous tall tower in Paris?<|im_end|>\n<|im_start|>assistant\nThe Eiffel Tower is the most famous tall tower in Paris. It is a wrought iron tower that was built in 1889 as the entrance to the 1889 Exposition Universelle (Universal Exhibition) of Paris. The tower was named after its designer, engineer Gustave Eiffel. It stands ']
79
+ ```
80
+
81
+ ## Usage with Transformers
82
+
83
+ ```
84
+ from transformers import AutoTokenizer
85
+ import transformers
86
+ import torch
87
+
88
+ model = "saucam/Saga-8B"
89
+ messages = [{"from": "human", "value": "Write a horror story about the monster of eldoria kingdom"}]
90
+
91
+ tokenizer = AutoTokenizer.from_pretrained(model)
92
+ prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
93
+ pipeline = transformers.pipeline(
94
+ "text-generation",
95
+ model=model,
96
+ torch_dtype=torch.float16,
97
+ device_map="auto",
98
+ )
99
+
100
+ outputs = pipeline(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
101
+ print(outputs[0]["generated_text"])
102
+ ```
103
+
104
+ Output:
105
+ ```
106
+ Loading checkpoint shards: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4/4 [00:12<00:00, 3.20s/it]
107
+ Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
108
+ <|im_start|>user
109
+ Write a horror story about the monster of eldoria kingdom<|im_end|>
110
+ <|im_start|>assistant
111
+ Title: The Eldorian Beast - A Tale of Eldoria Kingdom
112
+
113
+ In the heart of Eldoria Kingdom, nestled in the dense forests, lives a creature like no other. It's a tale of survival, love, and betrayal, woven into the intricate narrative of the Eldorian Beast.
114
+
115
+ The Eldorian Beast, a creature of Eldoria Kingdom, is a symbol of the kingdom's core beliefs and beliefs that reflect its core values. The Eldorian Beast is known for its loyalty, its bravery, and its resilience. Its heart is as big as its kingdom, and like the kingdom, it has its own secrets, challenges, and triumphs, all of which makes it a unique character.
116
+
117
+ The Eldorian Beast is a wolf, not just any wolf but one that is a true guardian and protector of the kingdom. It is a wolf that knows the kingdom like no one else does, and knows the kingdom like it's its heart. It's a wolf that knows the kingdom's secrets and mysteries, and it's a wolf that knows the kingdom's strengths and weaknesses.
118
+
119
+ The Eldorian Beast is not just a wolf. It's a wolf that has been through many challenges and has survived every obstacle, just like Eldoria Kingdom. It's a wolf that's been
120
+ ```
121
 
122
  ## Training
123