lewtun HF staff commited on
Commit
27c60ec
1 Parent(s): b7f7d63

Bump defaults

Browse files
Files changed (1) hide show
  1. app.py +1 -72
app.py CHANGED
@@ -36,45 +36,6 @@ def save_inputs_and_outputs(inputs, outputs, generate_kwargs):
36
  commit_url = repo.push_to_hub()
37
 
38
 
39
- # def generate(instruction, temperature=0.9, max_new_tokens=128, top_p=0.95, top_k=100):
40
- # set_seed(42)
41
- # formatted_instruction = PROMPT_TEMPLATE.format(prompt=instruction)
42
-
43
- # temperature = float(temperature)
44
- # top_p = float(top_p)
45
- # streamer = TextIteratorStreamer(tokenizer)
46
- # model_inputs = tokenizer(formatted_instruction, return_tensors="pt", truncation=True, max_length=2048).to(device)
47
-
48
- # generate_kwargs = dict(
49
- # top_p=top_p,
50
- # temperature=temperature,
51
- # max_new_tokens=max_new_tokens,
52
- # do_sample=True,
53
- # top_k=top_k,
54
- # eos_token_id=tokenizer.eos_token_id,
55
- # pad_token_id=tokenizer.eos_token_id,
56
- # )
57
- # t = Thread(target=model.generate, kwargs={**dict(model_inputs, streamer=streamer), **generate_kwargs})
58
- # t.start()
59
-
60
- # output = ""
61
- # hidden_output = ""
62
- # for new_text in streamer:
63
- # # skip streaming until new text is available
64
- # if len(hidden_output) <= len(formatted_instruction):
65
- # hidden_output += new_text
66
- # continue
67
- # # replace eos token
68
- # # if tokenizer.eos_token in new_text:
69
- # # new_text = new_text.replace(tokenizer.eos_token, "")
70
- # output += new_text
71
- # yield output
72
- # if HF_TOKEN:
73
- # print("Pushing prompt and completion to the Hub")
74
- # save_inputs_and_outputs(formatted_instruction, output, generate_kwargs)
75
- # return output
76
-
77
-
78
  def generate(instruction, temperature=0.9, max_new_tokens=256, top_p=0.95, top_k=100):
79
  formatted_instruction = PROMPT_TEMPLATE.format(prompt=instruction)
80
 
@@ -106,38 +67,6 @@ def generate(instruction, temperature=0.9, max_new_tokens=256, top_p=0.95, top_k
106
 
107
  return output
108
 
109
- # streamer = TextIteratorStreamer(tokenizer)
110
- # model_inputs = tokenizer(formatted_instruction, return_tensors="pt", truncation=True, max_length=2048).to(device)
111
-
112
- # generate_kwargs = dict(
113
- # top_p=top_p,
114
- # temperature=temperature,
115
- # max_new_tokens=max_new_tokens,
116
- # do_sample=True,
117
- # top_k=top_k,
118
- # # eos_token_id=tokenizer.eos_token_id,
119
- # # pad_token_id=tokenizer.eos_token_id,
120
- # )
121
- # t = Thread(target=model.generate, kwargs={**dict(model_inputs, streamer=streamer), **generate_kwargs})
122
- # t.start()
123
-
124
- # output = ""
125
- # hidden_output = ""
126
- # for new_text in streamer:
127
- # # skip streaming until new text is available
128
- # if len(hidden_output) <= len(formatted_instruction):
129
- # hidden_output += new_text
130
- # continue
131
- # # replace eos token
132
- # # if tokenizer.eos_token in new_text:
133
- # # new_text = new_text.replace(tokenizer.eos_token, "")
134
- # output += new_text
135
- # yield output
136
- if HF_TOKEN:
137
- print("Pushing prompt and completion to the Hub")
138
- save_inputs_and_outputs(formatted_instruction, output, generate_kwargs)
139
- # return output
140
-
141
 
142
  examples = [
143
  "A llama is in my lawn. How do I get rid of him?",
@@ -193,7 +122,7 @@ with gr.Blocks(theme=theme, analytics_enabled=False, css=".generating {visibilit
193
  )
194
  max_new_tokens = gr.Slider(
195
  label="Max new tokens",
196
- value=128,
197
  minimum=0,
198
  maximum=2048,
199
  step=4,
 
36
  commit_url = repo.push_to_hub()
37
 
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  def generate(instruction, temperature=0.9, max_new_tokens=256, top_p=0.95, top_k=100):
40
  formatted_instruction = PROMPT_TEMPLATE.format(prompt=instruction)
41
 
 
67
 
68
  return output
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  examples = [
72
  "A llama is in my lawn. How do I get rid of him?",
 
122
  )
123
  max_new_tokens = gr.Slider(
124
  label="Max new tokens",
125
+ value=256,
126
  minimum=0,
127
  maximum=2048,
128
  step=4,