JaiPatel4717 commited on
Commit
dc59162
1 Parent(s): 0e8a501

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -28,7 +28,9 @@ if user_input:
28
  # Generate output with attention mask and pad token ID
29
  try:
30
  # Increased max_length to 100 for more space for generation
31
- outputs = model.generate(input_ids, attention_mask=attention_mask, max_length=100, num_return_sequences=1)
 
 
32
 
33
  # Debugging model raw output (just the token ids)
34
  st.write("Model Output (Raw Token IDs):", outputs)
@@ -37,4 +39,4 @@ if user_input:
37
  decoded_output = tokenizer.decode(outputs[0], skip_special_tokens=True)
38
  st.write("Decoded Answer:", decoded_output)
39
  except Exception as e:
40
- st.write("Error generating output:", str(e))
 
28
  # Generate output with attention mask and pad token ID
29
  try:
30
  # Increased max_length to 100 for more space for generation
31
+ # Added temperature and top_k for better randomness and diversity
32
+ outputs = model.generate(input_ids, attention_mask=attention_mask, max_length=150,
33
+ temperature=0.7, top_k=50, num_return_sequences=1)
34
 
35
  # Debugging model raw output (just the token ids)
36
  st.write("Model Output (Raw Token IDs):", outputs)
 
39
  decoded_output = tokenizer.decode(outputs[0], skip_special_tokens=True)
40
  st.write("Decoded Answer:", decoded_output)
41
  except Exception as e:
42
+ st.write("Error generating output:", str(e))