Smiley0707 commited on
Commit
1674648
1 Parent(s): 460745e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -4
app.py CHANGED
@@ -8,6 +8,7 @@ from threading import Thread
8
 
9
  MODEL_LIST = ["meta-llama/Meta-Llama-3.1-8B-Instruct"]
10
  HF_TOKEN = os.environ.get("HF_TOKEN", None)
 
11
 
12
  TITLE = "<h1><center>Meta-Llama3.1-8B</center></h1>"
13
 
@@ -38,9 +39,9 @@ quantization_config = BitsAndBytesConfig(
38
  bnb_4bit_use_double_quant=True,
39
  bnb_4bit_quant_type= "nf4")
40
 
41
- tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3.1-8B-Instruct")
42
  model = AutoModelForCausalLM.from_pretrained(
43
- "meta-llama/Meta-Llama-3.1-8B-Instruct",
44
  torch_dtype=torch.bfloat16,
45
  device_map="auto",
46
  quantization_config=quantization_config)
@@ -100,13 +101,68 @@ chatbot = gr.Chatbot(height=600, placeholder=PLACEHOLDER)
100
 
101
  with gr.Blocks(css=CSS, theme="soft") as demo:
102
  gr.HTML(TITLE)
 
103
  gr.ChatInterface(
104
  fn=stream_chat,
105
  chatbot=chatbot,
106
  fill_height=True,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  cache_examples=False,
108
  )
109
 
110
 
111
- if __name__=='__main__':
112
- demo.launch()
 
8
 
9
  MODEL_LIST = ["meta-llama/Meta-Llama-3.1-8B-Instruct"]
10
  HF_TOKEN = os.environ.get("HF_TOKEN", None)
11
+ MODEL = os.environ.get("MODEL_ID")
12
 
13
  TITLE = "<h1><center>Meta-Llama3.1-8B</center></h1>"
14
 
 
39
  bnb_4bit_use_double_quant=True,
40
  bnb_4bit_quant_type= "nf4")
41
 
42
+ tokenizer = AutoTokenizer.from_pretrained(MODEL)
43
  model = AutoModelForCausalLM.from_pretrained(
44
+ MODEL,
45
  torch_dtype=torch.bfloat16,
46
  device_map="auto",
47
  quantization_config=quantization_config)
 
101
 
102
  with gr.Blocks(css=CSS, theme="soft") as demo:
103
  gr.HTML(TITLE)
104
+ gr.DuplicateButton(value="Duplicate Space for private use", elem_classes="duplicate-button")
105
  gr.ChatInterface(
106
  fn=stream_chat,
107
  chatbot=chatbot,
108
  fill_height=True,
109
+ additional_inputs_accordion=gr.Accordion(label="⚙️ Parameters", open=False, render=False),
110
+ additional_inputs=[
111
+ gr.Textbox(
112
+ value="You are a helpful assistant",
113
+ label="System Prompt",
114
+ render=False,
115
+ ),
116
+ gr.Slider(
117
+ minimum=0,
118
+ maximum=1,
119
+ step=0.1,
120
+ value=0.8,
121
+ label="Temperature",
122
+ render=False,
123
+ ),
124
+ gr.Slider(
125
+ minimum=128,
126
+ maximum=8192,
127
+ step=1,
128
+ value=1024,
129
+ label="Max new tokens",
130
+ render=False,
131
+ ),
132
+ gr.Slider(
133
+ minimum=0.0,
134
+ maximum=1.0,
135
+ step=0.1,
136
+ value=1.0,
137
+ label="top_p",
138
+ render=False,
139
+ ),
140
+ gr.Slider(
141
+ minimum=1,
142
+ maximum=20,
143
+ step=1,
144
+ value=20,
145
+ label="top_k",
146
+ render=False,
147
+ ),
148
+ gr.Slider(
149
+ minimum=0.0,
150
+ maximum=2.0,
151
+ step=0.1,
152
+ value=1.2,
153
+ label="Repetition penalty",
154
+ render=False,
155
+ ),
156
+ ],
157
+ examples=[
158
+ ["Help me study vocabulary: write a sentence for me to fill in the blank, and I'll try to pick the correct option."],
159
+ ["What are 5 creative things I could do with my kids' art? I don't want to throw them away, but it's also so much clutter."],
160
+ ["Tell me a random fun fact about the Roman Empire."],
161
+ ["Show me a code snippet of a website's sticky header in CSS and JavaScript."],
162
+ ],
163
  cache_examples=False,
164
  )
165
 
166
 
167
+ if __name__ == "__main__":
168
+ demo.launch()