legolasyiu commited on
Commit
2c0a69a
·
verified ·
1 Parent(s): d190031

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +51 -1
README.md CHANGED
@@ -26,13 +26,63 @@ This gemma2 model was trained 2x faster with [Unsloth](https://github.com/unslot
26
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
27
 
28
  How to use
29
- This repository contains two versions of Meta-Llama-3.1-8B-Instruct, for use with transformers and with the original llama codebase.
30
 
31
  Use with transformers
32
  Starting with transformers >= 4.43.0 onward, you can run conversational inference using the Transformers pipeline abstraction or by leveraging the Auto classes with the generate() function.
33
 
34
  Make sure to update your transformers installation via pip install --upgrade transformers.
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  ```python
37
  from unsloth import FastLanguageModel
38
 
 
26
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
27
 
28
  How to use
29
+ This repository contains two versions of Gemma-1-9B, for use with transformers and with the original llama codebase.
30
 
31
  Use with transformers
32
  Starting with transformers >= 4.43.0 onward, you can run conversational inference using the Transformers pipeline abstraction or by leveraging the Auto classes with the generate() function.
33
 
34
  Make sure to update your transformers installation via pip install --upgrade transformers.
35
 
36
+ You need to prepare prompt in alpaca format to generate properly:
37
+ ```python
38
+ def format_test(x):
39
+
40
+ if x['input']:
41
+ formatted_text = f"""Below is an instruction that describes a task. \
42
+ Write a response that appropriately completes the request.
43
+
44
+ ### Instruction:
45
+ {x['instruction']}
46
+
47
+ ### Input:
48
+ {x['input']}
49
+
50
+ ### Response:
51
+ """
52
+
53
+ else:
54
+ formatted_text = f"""Below is an instruction that describes a task. \
55
+ Write a response that appropriately completes the request.
56
+
57
+ ### Instruction:
58
+ {x['instruction']}
59
+
60
+ ### Response:
61
+ """
62
+
63
+ return formatted_text
64
+
65
+ # using code_instructions_122k_alpaca dataset
66
+ Prompt = format_test(data[155])
67
+ print(Prompt)
68
+
69
+ ```
70
+ - transfomer method:
71
+ ```python
72
+ from transformers import TextStreamer
73
+
74
+ FastLanguageModel.for_inference(model) # Enable native 2x faster inference
75
+ inputs = tokenizer(
76
+ [
77
+ Prompt
78
+ ], return_tensors = "pt").to("cuda")
79
+
80
+ text_streamer = TextStreamer(tokenizer)
81
+ _ = model.generate(**inputs, streamer = text_streamer, max_new_tokens = 512)
82
+ ```
83
+
84
+
85
+ - unsloth method
86
  ```python
87
  from unsloth import FastLanguageModel
88