Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -14,13 +14,14 @@ def generate_unique_feedback(text):
|
|
14 |
# Generate a prompt for writing feedback
|
15 |
prompt = f"Provide constructive feedback on the following creative writing piece:\n\n{text}\n\nFeedback:"
|
16 |
|
17 |
-
# Tokenize the input
|
18 |
-
inputs = tokenizer(prompt, return_tensors="pt")
|
19 |
|
20 |
# Attempt to generate unique feedback
|
21 |
for _ in range(5): # Try up to 5 times to get unique feedback
|
22 |
with torch.no_grad():
|
23 |
-
|
|
|
24 |
|
25 |
# Decode the response
|
26 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
@@ -57,5 +58,5 @@ with gr.Blocks() as app:
|
|
57 |
reset_button = gr.Button("Reset Feedback History")
|
58 |
reset_button.click(fn=reset_history, outputs=reset_status)
|
59 |
|
60 |
-
# Launch the app
|
61 |
-
app.launch()
|
|
|
14 |
# Generate a prompt for writing feedback
|
15 |
prompt = f"Provide constructive feedback on the following creative writing piece:\n\n{text}\n\nFeedback:"
|
16 |
|
17 |
+
# Tokenize the input with attention mask
|
18 |
+
inputs = tokenizer(prompt, return_tensors="pt", padding=True)
|
19 |
|
20 |
# Attempt to generate unique feedback
|
21 |
for _ in range(5): # Try up to 5 times to get unique feedback
|
22 |
with torch.no_grad():
|
23 |
+
# Use max_new_tokens instead of max_length
|
24 |
+
outputs = model.generate(inputs.input_ids, attention_mask=inputs.attention_mask, max_new_tokens=300, do_sample=True, top_p=0.85, temperature=0.7)
|
25 |
|
26 |
# Decode the response
|
27 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
|
|
58 |
reset_button = gr.Button("Reset Feedback History")
|
59 |
reset_button.click(fn=reset_history, outputs=reset_status)
|
60 |
|
61 |
+
# Launch the app with a public shareable link
|
62 |
+
app.launch(share=True)
|