Divyasreepat commited on
Commit
081d046
·
verified ·
1 Parent(s): 15cb53f

Update README.md with new model card content

Browse files
Files changed (1) hide show
  1. README.md +177 -0
README.md CHANGED
@@ -8,5 +8,182 @@ tags:
8
  pipeline_tag: text-generation
9
  ---
10
  ### Model Overview
 
11
 
 
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  pipeline_tag: text-generation
9
  ---
10
  ### Model Overview
11
+ Vicuna is a chat assistant trained by fine-tuning Llama 2 on user-shared conversations collected from ShareGPT.Weights are release under the [Llama 2 Community License Agreement ](https://ai.meta.com/llama/license/) and Keras model code are released under the [Apache 2 License](https://github.com/keras-team/keras-hub/blob/master/LICENSE).
12
 
13
+ Model type: An auto-regressive language model based on the transformer architecture.
14
 
15
+ Fine tuned from model: Llama 2
16
+
17
+ Uses:
18
+ The primary use of Vicuna is research on large language models and chatbots. The primary intended users of the model are researchers and hobbyists in natural language processing, machine learning, and artificial intelligence.
19
+
20
+ ## Links
21
+
22
+ * [Vicuna Quickstart Notebook](https://www.kaggle.com/code/laxmareddypatlolla/vicuna-quickstart-notebook)
23
+ * [Vicuna API Documentation](coming soon)
24
+ * [Vicuna Model Card](https://huggingface.co/lmsys/vicuna-7b-v1.5#vicuna-model-card)
25
+ * [KerasHub Beginner Guide](https://keras.io/guides/keras_hub/getting_started/)
26
+ * [KerasHub Model Publishing Guide](https://keras.io/guides/keras_hub/upload/)
27
+
28
+ ## Installation
29
+
30
+ Keras and KerasHub can be installed with:
31
+
32
+ ```
33
+ pip install -U -q keras-hub
34
+ pip install -U -q keras
35
+ ```
36
+
37
+ Jax, TensorFlow, and Torch come preinstalled in Kaggle Notebooks. For instruction on installing them in another environment see the [Keras Getting Started](https://keras.io/getting_started/) page.
38
+
39
+ ## Presets
40
+
41
+ The following model checkpoints are provided by the Keras team. Full code examples for each are available below.
42
+
43
+ | Preset name | Parameters | Description |
44
+ |-----------------------|------------|---------------|
45
+ |` vicuna_1.5_7b_en ` | 6.74B | 7 billion parameter, 32-layer, instruction tuned Vicuna v1.5 model.|
46
+
47
+
48
+ Paper: https://arxiv.org/abs/2306.05685
49
+
50
+ ## Example Usage
51
+ ```python
52
+ import keras
53
+ import keras_hub
54
+ import numpy as np
55
+ ```
56
+
57
+ Use `generate()` to do text generation.
58
+ ```python
59
+ vicuna_lm = keras_hub.models.LlamaCausalLM.from_preset("vicuna_1.5_7b_en")
60
+ vicuna_lm.generate("### HUMAN:\nWhat is Keras? \n### RESPONSE:\n", max_length=500)
61
+
62
+ # Generate with batched prompts.
63
+ vicuna_lm.generate([
64
+ "### HUMAN:\nWhat is ML? \n### RESPONSE:\n",
65
+ "### HUMAN:\nGive me your best brownie recipe.\n### RESPONSE:\n",
66
+ ],max_length=500)
67
+ ```
68
+
69
+ Compile the `generate()` function with a custom sampler.
70
+ ```python
71
+ vicuna_lm = keras_hub.models.LlamaCausalLM.from_preset("vicuna_1.5_7b_en")
72
+ vicuna_lm.compile(sampler="greedy")
73
+ vicuna_lm.generate("I want to say", max_length=30)
74
+
75
+ vicuna_lm.compile(sampler=keras_hub.samplers.BeamSampler(num_beams=2))
76
+ vicuna_lm.generate("I want to say", max_length=30)
77
+ ```
78
+
79
+ Use `generate()` without preprocessing.
80
+ ```python
81
+ prompt = {
82
+ # `1` maps to the start token followed by "I want to say".
83
+ "token_ids": np.array([[1, 306, 864, 304, 1827, 0, 0, 0, 0, 0]] * 2),
84
+ # Use `"padding_mask"` to indicate values that should not be overridden.
85
+ "padding_mask": np.array([[1, 1, 1, 1, 1, 0, 0, 0, 0, 0]] * 2),
86
+ }
87
+
88
+ vicuna_lm = keras_hub.models.LlamaCausalLM.from_preset(
89
+ "vicuna_1.5_7b_en",
90
+ preprocessor=None,
91
+ dtype="bfloat16"
92
+ )
93
+ vicuna_lm.generate(prompt)
94
+ ```
95
+
96
+ Call `fit()` on a single batch.
97
+ ```python
98
+ features = ["The quick brown fox jumped.", "I forgot my homework."]
99
+ vicuna_lm = keras_hub.models.LlamaCausalLM.from_preset("vicuna_1.5_7b_en")
100
+ vicuna_lm.fit(x=features, batch_size=2)
101
+ ```
102
+
103
+ Call `fit()` without preprocessing.
104
+ ```python
105
+ x = {
106
+ "token_ids": np.array([[1, 450, 4996, 17354, 1701, 29916, 12500, 287, 29889, 0]] * 2),
107
+ "padding_mask": np.array([[1, 1, 1, 1, 1, 1, 1, 1, 1, 0]] * 2),
108
+ }
109
+ y = np.array([[450, 4996, 17354, 1701, 29916, 12500, 287, 29889, 0, 0]] * 2)
110
+ sw = np.array([[1, 1, 1, 1, 1, 1, 1, 1, 0, 0]] * 2)
111
+
112
+ vicuna_lm = keras_hub.models.LlamaCausalLM.from_preset(
113
+ "vicuna_1.5_7b_en",
114
+ preprocessor=None,
115
+ dtype="bfloat16"
116
+ )
117
+ vicuna_lm.fit(x=x, y=y, sample_weight=sw, batch_size=2)
118
+ ```
119
+
120
+ ## Example Usage with Hugging Face URI
121
+
122
+ ```python
123
+ import keras
124
+ import keras_hub
125
+ import numpy as np
126
+ ```
127
+
128
+ Use `generate()` to do text generation.
129
+ ```python
130
+ vicuna_lm = keras_hub.models.LlamaCausalLM.from_preset("hf://keras/vicuna_1.5_7b_en")
131
+ vicuna_lm.generate("### HUMAN:\nWhat is Keras? \n### RESPONSE:\n", max_length=500)
132
+
133
+ # Generate with batched prompts.
134
+ vicuna_lm.generate([
135
+ "### HUMAN:\nWhat is ML? \n### RESPONSE:\n",
136
+ "### HUMAN:\nGive me your best brownie recipe.\n### RESPONSE:\n",
137
+ ],max_length=500)
138
+ ```
139
+
140
+ Compile the `generate()` function with a custom sampler.
141
+ ```python
142
+ vicuna_lm = keras_hub.models.LlamaCausalLM.from_preset("hf://keras/vicuna_1.5_7b_en")
143
+ vicuna_lm.compile(sampler="greedy")
144
+ vicuna_lm.generate("I want to say", max_length=30)
145
+
146
+ vicuna_lm.compile(sampler=keras_hub.samplers.BeamSampler(num_beams=2))
147
+ vicuna_lm.generate("I want to say", max_length=30)
148
+ ```
149
+
150
+ Use `generate()` without preprocessing.
151
+ ```python
152
+ prompt = {
153
+ # `1` maps to the start token followed by "I want to say".
154
+ "token_ids": np.array([[1, 306, 864, 304, 1827, 0, 0, 0, 0, 0]] * 2),
155
+ # Use `"padding_mask"` to indicate values that should not be overridden.
156
+ "padding_mask": np.array([[1, 1, 1, 1, 1, 0, 0, 0, 0, 0]] * 2),
157
+ }
158
+
159
+ vicuna_lm = keras_hub.models.LlamaCausalLM.from_preset(
160
+ "hf://keras/vicuna_1.5_7b_en",
161
+ preprocessor=None,
162
+ dtype="bfloat16"
163
+ )
164
+ vicuna_lm.generate(prompt)
165
+ ```
166
+
167
+ Call `fit()` on a single batch.
168
+ ```python
169
+ features = ["The quick brown fox jumped.", "I forgot my homework."]
170
+ vicuna_lm = keras_hub.models.LlamaCausalLM.from_preset("hf://keras/vicuna_1.5_7b_en")
171
+ vicuna_lm.fit(x=features, batch_size=2)
172
+ ```
173
+
174
+ Call `fit()` without preprocessing.
175
+ ```python
176
+ x = {
177
+ "token_ids": np.array([[1, 450, 4996, 17354, 1701, 29916, 12500, 287, 29889, 0]] * 2),
178
+ "padding_mask": np.array([[1, 1, 1, 1, 1, 1, 1, 1, 1, 0]] * 2),
179
+ }
180
+ y = np.array([[450, 4996, 17354, 1701, 29916, 12500, 287, 29889, 0, 0]] * 2)
181
+ sw = np.array([[1, 1, 1, 1, 1, 1, 1, 1, 0, 0]] * 2)
182
+
183
+ vicuna_lm = keras_hub.models.LlamaCausalLM.from_preset(
184
+ "hf://keras/vicuna_1.5_7b_en",
185
+ preprocessor=None,
186
+ dtype="bfloat16"
187
+ )
188
+ vicuna_lm.fit(x=x, y=y, sample_weight=sw, batch_size=2)
189
+ ```