un-index commited on
Commit
2eebfca
·
1 Parent(s): 4d0bba1
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -129,7 +129,10 @@ def f(context, temperature, top_p, max_length, model_idx, SPACE_VERIFICATION_KEY
129
  else:
130
  # use GPT-2
131
  #
132
- set_seed(randint(1, 2**31))
 
 
 
133
  # return sequences specifies how many to return
134
 
135
  # for some reson indexing with 'generated-text' doesn't work
@@ -139,6 +142,8 @@ def f(context, temperature, top_p, max_length, model_idx, SPACE_VERIFICATION_KEY
139
  try:
140
  # todo fix max_length below, maybe there is a max_new_tokens parameter
141
  # try max_length=len(context)+max_length or =len(context)+max_length or make max_length inf or unspecified
 
 
142
  generated_text = generator(context, max_length=400, max_new_tokens=max_length, top_p=top_p, temperature=temperature, num_return_sequences=1)
143
  except Exception as e:
144
  return "Exception while generating text: " + str(e)
 
129
  else:
130
  # use GPT-2
131
  #
132
+ try:
133
+ set_seed(randint(1, 2**31))
134
+ except Exception as e:
135
+ return "Exception while setting seed: " + str(e)
136
  # return sequences specifies how many to return
137
 
138
  # for some reson indexing with 'generated-text' doesn't work
 
142
  try:
143
  # todo fix max_length below, maybe there is a max_new_tokens parameter
144
  # try max_length=len(context)+max_length or =len(context)+max_length or make max_length inf or unspecified
145
+ # note: added max_new_tokens parameter to see whether it actually works, if not remove,
146
+ # if yes, then make max_length infinite because it seems to be counted as max input length, not output
147
  generated_text = generator(context, max_length=400, max_new_tokens=max_length, top_p=top_p, temperature=temperature, num_return_sequences=1)
148
  except Exception as e:
149
  return "Exception while generating text: " + str(e)