Spaces:
Sleeping
Sleeping
un-index
commited on
Commit
·
45d20de
1
Parent(s):
0ddb594
app.py
CHANGED
|
@@ -121,6 +121,7 @@ def f(context, temperature, top_p, max_length, model_idx, SPACE_VERIFICATION_KEY
|
|
| 121 |
"token_max_length": max_length, # 512,
|
| 122 |
"temperature": temperature,
|
| 123 |
"top_p": top_p,
|
|
|
|
| 124 |
}
|
| 125 |
|
| 126 |
response = requests.post(
|
|
@@ -143,7 +144,7 @@ def f(context, temperature, top_p, max_length, model_idx, SPACE_VERIFICATION_KEY
|
|
| 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)
|
|
@@ -156,7 +157,7 @@ def f(context, temperature, top_p, max_length, model_idx, SPACE_VERIFICATION_KEY
|
|
| 156 |
return generated_text[0][0]['generated_text']
|
| 157 |
except:
|
| 158 |
return generated_text # was error due to timeout because of not enabling queue in gradio interface?
|
| 159 |
-
|
| 160 |
# except:
|
| 161 |
# generated_text = generator(context, max_length=max_length, top_p=top_p, temperature=temperature, num_return_sequences=1)[0]
|
| 162 |
|
|
@@ -168,7 +169,7 @@ def f(context, temperature, top_p, max_length, model_idx, SPACE_VERIFICATION_KEY
|
|
| 168 |
|
| 169 |
|
| 170 |
except Exception as e:
|
| 171 |
-
return f"error with idx{model_idx}
|
| 172 |
|
| 173 |
|
| 174 |
iface = gr.Interface(f, [
|
|
|
|
| 121 |
"token_max_length": max_length, # 512,
|
| 122 |
"temperature": temperature,
|
| 123 |
"top_p": top_p,
|
| 124 |
+
"max_time": 120.0
|
| 125 |
}
|
| 126 |
|
| 127 |
response = requests.post(
|
|
|
|
| 144 |
# todo fix max_length below, maybe there is a max_new_tokens parameter
|
| 145 |
# try max_length=len(context)+max_length or =len(context)+max_length or make max_length inf or unspecified
|
| 146 |
# note: added max_new_tokens parameter to see whether it actually works, if not remove,
|
| 147 |
+
# TODO if yes, then make max_length infinite because it seems to be counted as max input length, not output
|
| 148 |
generated_text = generator(context, max_length=400, max_new_tokens=max_length, top_p=top_p, temperature=temperature, num_return_sequences=1)
|
| 149 |
except Exception as e:
|
| 150 |
return "Exception while generating text: " + str(e)
|
|
|
|
| 157 |
return generated_text[0][0]['generated_text']
|
| 158 |
except:
|
| 159 |
return generated_text # was error due to timeout because of not enabling queue in gradio interface?
|
| 160 |
+
# if it works right now, then that was the reason for the JSON parsing error
|
| 161 |
# except:
|
| 162 |
# generated_text = generator(context, max_length=max_length, top_p=top_p, temperature=temperature, num_return_sequences=1)[0]
|
| 163 |
|
|
|
|
| 169 |
|
| 170 |
|
| 171 |
except Exception as e:
|
| 172 |
+
return f"error with idx{model_idx}: "+str(e)
|
| 173 |
|
| 174 |
|
| 175 |
iface = gr.Interface(f, [
|