Tonic commited on
Commit
51ce0b9
Β·
unverified Β·
1 Parent(s): 1223061
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -13,10 +13,8 @@ model = AutoModelForCausalLM.from_pretrained(
13
  device_map="auto",
14
  torch_dtype=torch.bfloat16
15
  )
16
-
17
- # Set pad_token_id to eos_token_id if it's not set
18
- if tokenizer.pad_token_id is None:
19
- tokenizer.pad_token_id = tokenizer.eos_token_id
20
 
21
  description = """
22
  Salamandra-2b-instruct is a Transformer-based decoder-only language model that has been pre-trained on 7.8 trillion tokens of highly curated data.
@@ -47,7 +45,7 @@ def generate_text(system_prompt, user_prompt, temperature, max_new_tokens, top_p
47
  )
48
 
49
  inputs = tokenizer(chat_prompt, return_tensors="pt", padding=True, truncation=True)
50
- inputs = {k: v.to(model.device) for k, v in inputs.items()}
51
 
52
  outputs = model.generate(
53
  **inputs,
@@ -71,23 +69,25 @@ with gr.Blocks() as demo:
71
 
72
  with gr.Row():
73
  with gr.Column(scale=1):
74
- gr.Markdown(description)
 
75
  with gr.Column(scale=1):
76
- gr.Markdown(join_us)
 
77
 
78
  with gr.Row():
79
  with gr.Column(scale=1):
80
  system_prompt = gr.Textbox(
81
  lines=3,
82
  label="πŸ–₯️ System Prompt",
83
- value="You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information."
84
  )
85
  user_prompt = gr.Textbox(lines=5, label="πŸ™‹β€β™‚οΈ User Prompt")
86
  generate_button = gr.Button("Generate with 🦎 Salamandra-2b-instruct")
87
 
88
  with gr.Accordion("πŸ§ͺ Parameters", open=False):
89
  temperature = gr.Slider(0.0, 1.0, value=0.7, label="🌑️ Temperature")
90
- max_new_tokens = gr.Slider(1, 1000, value=200, step=1, label="πŸ”’ Max New Tokens")
91
  top_p = gr.Slider(0.0, 1.0, value=0.95, label="βš›οΈ Top P")
92
  repetition_penalty = gr.Slider(1.0, 2.0, value=1.2, label="πŸ” Repetition Penalty")
93
 
 
13
  device_map="auto",
14
  torch_dtype=torch.bfloat16
15
  )
16
+ # if tokenizer.pad_token_id is None:
17
+ # tokenizer.pad_token_id = tokenizer.eos_token_id
 
 
18
 
19
  description = """
20
  Salamandra-2b-instruct is a Transformer-based decoder-only language model that has been pre-trained on 7.8 trillion tokens of highly curated data.
 
45
  )
46
 
47
  inputs = tokenizer(chat_prompt, return_tensors="pt", padding=True, truncation=True)
48
+ # inputs = {k: v.to(model.device) for k, v in inputs.items()}
49
 
50
  outputs = model.generate(
51
  **inputs,
 
69
 
70
  with gr.Row():
71
  with gr.Column(scale=1):
72
+ with gr.Group():
73
+ gr.Markdown(description)
74
  with gr.Column(scale=1):
75
+ with gr.Group():
76
+ gr.Markdown(join_us)
77
 
78
  with gr.Row():
79
  with gr.Column(scale=1):
80
  system_prompt = gr.Textbox(
81
  lines=3,
82
  label="πŸ–₯️ System Prompt",
83
+ value="You are Tonic-ai a senior expert assistant known for their abilities to explain and answer questions."
84
  )
85
  user_prompt = gr.Textbox(lines=5, label="πŸ™‹β€β™‚οΈ User Prompt")
86
  generate_button = gr.Button("Generate with 🦎 Salamandra-2b-instruct")
87
 
88
  with gr.Accordion("πŸ§ͺ Parameters", open=False):
89
  temperature = gr.Slider(0.0, 1.0, value=0.7, label="🌑️ Temperature")
90
+ max_new_tokens = gr.Slider(1, 2046, value=450, step=1, label="πŸ”’ Max New Tokens")
91
  top_p = gr.Slider(0.0, 1.0, value=0.95, label="βš›οΈ Top P")
92
  repetition_penalty = gr.Slider(1.0, 2.0, value=1.2, label="πŸ” Repetition Penalty")
93