5to9 commited on
Commit
e817f11
1 Parent(s): c7efb5e

0.51 checking messages and history

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -24,7 +24,7 @@ system_prompts = {
24
  "Spanish": "Eres un chatbot servicial que responde a las entradas de los usuarios de forma concisa y original."
25
  }
26
 
27
- htmL_info = "<center><h1>Pharia Battle Royale</h1><p>Let the games begin: In this bot arena, the Pharia 1 model competes against a challenger. Try a prompt in a language you want to explore. Set the parameters and vote for the best answers. After casting your vote, the bots reveal their identity. Inputs, outputs and votes are logged anonymously for further insight.</p></center>"
28
 
29
  model_info = [{"id": "Aleph-Alpha/Pharia-1-LLM-7B-control-hf",
30
  "name": "Pharia 1 LLM 7B control hf"}]
@@ -107,10 +107,13 @@ def generate_both(system_prompt, input_text, chatbot_a, chatbot_b, max_new_token
107
  new_messages_a = system_prompt_list + chat_history_a + input_text_list
108
  new_messages_b = system_prompt_list + chat_history_b + input_text_list
109
 
 
 
 
110
  if "Pharia" in model_info[0]['id']:
111
  formatted_conversation = apply_pharia_template(messages=new_messages_a, add_generation_prompt=True)
112
  tokenized = tokenizer_a(formatted_conversation, return_tensors="pt").to(device)
113
- logging.debug(tokenized) #attention_mask
114
  input_ids_a = tokenized.input_ids
115
  tokenizer_a.eos_token = "<|endoftext|>" # not set für Pharia
116
  tokenizer_a.pad_token = "<|padding|>" # not set für Pharia
@@ -125,9 +128,8 @@ def generate_both(system_prompt, input_text, chatbot_a, chatbot_b, max_new_token
125
  if "Pharia" in model_info[1]['id']:
126
  formatted_conversation = apply_pharia_template(messages=new_messages_a, add_generation_prompt=True)
127
  tokenized = tokenizer_b(formatted_conversation, return_tensors="pt").to(device)
128
- logging.debug(tokenized)
129
  input_ids_b = tokenized.input_ids
130
- logging.debug(f'tokenizer_b.pad_token is {tokenizer_b.pad_token}')
131
  tokenizer_b.eos_token = "<|endoftext|>" # not set für Pharia
132
  tokenizer_b.pad_token = "<|padding|>" # not set für Pharia
133
  else:
@@ -254,7 +256,7 @@ with gr.Blocks() as demo:
254
  with gr.Accordion(label="Generation Configurations", open=False):
255
  max_new_tokens = gr.Slider(minimum=128, maximum=4096, value=512, label="Max new tokens", step=128)
256
  temperature = gr.Slider(minimum=0.0, maximum=1.0, value=0.7, label="Temperature", step=0.01)
257
- top_p = gr.Slider(minimum=0.0, maximum=1.0, value=1.0, label="Top_p", step=0.01)
258
  repetition_penalty = gr.Slider(minimum=0.1, maximum=2.0, value=1.1, label="Repetition Penalty", step=0.1)
259
 
260
 
 
24
  "Spanish": "Eres un chatbot servicial que responde a las entradas de los usuarios de forma concisa y original."
25
  }
26
 
27
+ htmL_info = "<center><h1>⚔️ Pharia Bot Battle Royale</h1><p>Let the games begin: In this arena, the Pharia 1 model competes against a random challenger. Try a prompt in a language you want to explore. Set the parameters and vote for the best answers. After casting your vote, the bots reveal their identity. Inputs, outputs and votes are logged anonymously.</p></center>"
28
 
29
  model_info = [{"id": "Aleph-Alpha/Pharia-1-LLM-7B-control-hf",
30
  "name": "Pharia 1 LLM 7B control hf"}]
 
107
  new_messages_a = system_prompt_list + chat_history_a + input_text_list
108
  new_messages_b = system_prompt_list + chat_history_b + input_text_list
109
 
110
+ logging.debug(f'{SPACER}\nNew message bot A: \n{new_messages_a}\n{SPACER}')
111
+ logging.debug(f'{SPACER}\nnNew message bot B: \n{new_messages_b}\n{SPACER}')
112
+
113
  if "Pharia" in model_info[0]['id']:
114
  formatted_conversation = apply_pharia_template(messages=new_messages_a, add_generation_prompt=True)
115
  tokenized = tokenizer_a(formatted_conversation, return_tensors="pt").to(device)
116
+ #logging.debug(tokenized) #attention_mask
117
  input_ids_a = tokenized.input_ids
118
  tokenizer_a.eos_token = "<|endoftext|>" # not set für Pharia
119
  tokenizer_a.pad_token = "<|padding|>" # not set für Pharia
 
128
  if "Pharia" in model_info[1]['id']:
129
  formatted_conversation = apply_pharia_template(messages=new_messages_a, add_generation_prompt=True)
130
  tokenized = tokenizer_b(formatted_conversation, return_tensors="pt").to(device)
131
+ #logging.debug(tokenized)
132
  input_ids_b = tokenized.input_ids
 
133
  tokenizer_b.eos_token = "<|endoftext|>" # not set für Pharia
134
  tokenizer_b.pad_token = "<|padding|>" # not set für Pharia
135
  else:
 
256
  with gr.Accordion(label="Generation Configurations", open=False):
257
  max_new_tokens = gr.Slider(minimum=128, maximum=4096, value=512, label="Max new tokens", step=128)
258
  temperature = gr.Slider(minimum=0.0, maximum=1.0, value=0.7, label="Temperature", step=0.01)
259
+ top_p = gr.Slider(minimum=0.0, maximum=1.0, value=0.97, label="Top_p", step=0.01)
260
  repetition_penalty = gr.Slider(minimum=0.1, maximum=2.0, value=1.1, label="Repetition Penalty", step=0.1)
261
 
262