Spaces:
Running on Zero

Ruurd commited on
Commit
4152853
·
verified ·
1 Parent(s): a482b2c

Change prompt to Llama format

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -18,8 +18,8 @@ tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.1-8B", use_fast=Tr
18
  vocab_size = len(tokenizer)
19
  eos_token_id = tokenizer.eos_token_id
20
  mask_token_id = tokenizer.encode('MASK', add_special_tokens=False)[0]
21
- # assistant_marker_ids = tokenizer.encode("<|start_header_id|>assistant<|end_header_id|>", add_special_tokens=False)
22
- assistant_marker_ids = tokenizer.encode("Assistant:", add_special_tokens=False)
23
  # def load_model():
24
  # ckpt_path = hf_hub_download(
25
  # repo_id="ruurd/tini_bi_m",
@@ -195,19 +195,19 @@ def generate_diffusion_text(input_ids, top_p, top_k):
195
  conf = probs[range(len(sampled)), sampled].cpu().numpy()
196
  return sampled, conf
197
 
198
- # def format_chat_prompt(question):
199
- # return (
200
- # "<|begin_of_text|>\n"
201
- # "<|start_header_id|>system<|end_header_id|>\n"
202
- # "You are a helpful assistant.\n"
203
- # "<|start_header_id|>user<|end_header_id|>\n"
204
- # f"{question}\n"
205
- # "<|start_header_id|>assistant<|end_header_id|>\n"
206
- # )
207
  def format_chat_prompt(question):
208
- return(
209
- f"User:{question}\nAssistant:"
 
 
 
 
 
210
  )
 
 
 
 
211
 
212
 
213
  # --- Inference Wrapper ---
 
18
  vocab_size = len(tokenizer)
19
  eos_token_id = tokenizer.eos_token_id
20
  mask_token_id = tokenizer.encode('MASK', add_special_tokens=False)[0]
21
+ assistant_marker_ids = tokenizer.encode("<|start_header_id|>assistant<|end_header_id|>", add_special_tokens=False)
22
+ # assistant_marker_ids = tokenizer.encode("Assistant:", add_special_tokens=False)
23
  # def load_model():
24
  # ckpt_path = hf_hub_download(
25
  # repo_id="ruurd/tini_bi_m",
 
195
  conf = probs[range(len(sampled)), sampled].cpu().numpy()
196
  return sampled, conf
197
 
 
 
 
 
 
 
 
 
 
198
  def format_chat_prompt(question):
199
+ return (
200
+ "<|begin_of_text|>\n"
201
+ "<|start_header_id|>system<|end_header_id|>\n"
202
+ "You are a helpful assistant.\n"
203
+ "<|start_header_id|>user<|end_header_id|>\n"
204
+ f"{question}\n"
205
+ "<|start_header_id|>assistant<|end_header_id|>\n"
206
  )
207
+ # def format_chat_prompt(question):
208
+ # return(
209
+ # f"User:{question}\nAssistant:"
210
+ # )
211
 
212
 
213
  # --- Inference Wrapper ---