Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -67,16 +67,14 @@ def generate_text(prompt, max_tokens=50, temperature=0.8):
|
|
| 67 |
probs = torch.nn.functional.softmax(logits, dim=-1)
|
| 68 |
next_token = torch.multinomial(probs, num_samples=1)
|
| 69 |
x = torch.cat([x, next_token], dim=1)
|
| 70 |
-
|
| 71 |
-
if next_token.item() == tokenizer.eos_token_id:
|
| 72 |
-
break
|
| 73 |
|
| 74 |
output_tokens = x[0].tolist()
|
| 75 |
output = tokenizer.decode(output_tokens)
|
| 76 |
return output
|
| 77 |
|
| 78 |
except Exception as e:
|
| 79 |
-
|
|
|
|
| 80 |
|
| 81 |
demo = gr.Interface(
|
| 82 |
fn=generate_text,
|
|
|
|
| 67 |
probs = torch.nn.functional.softmax(logits, dim=-1)
|
| 68 |
next_token = torch.multinomial(probs, num_samples=1)
|
| 69 |
x = torch.cat([x, next_token], dim=1)
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
output_tokens = x[0].tolist()
|
| 72 |
output = tokenizer.decode(output_tokens)
|
| 73 |
return output
|
| 74 |
|
| 75 |
except Exception as e:
|
| 76 |
+
import traceback
|
| 77 |
+
return f"Error: {str(e)}\n\n{traceback.format_exc()}"
|
| 78 |
|
| 79 |
demo = gr.Interface(
|
| 80 |
fn=generate_text,
|