Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,13 +18,20 @@ user_input = st.text_input("Ask me about nutrition:")
|
|
| 18 |
if user_input:
|
| 19 |
# Use encode_plus to get both input_ids and attention_mask
|
| 20 |
inputs = tokenizer.encode_plus(user_input, return_tensors="pt", padding=True, truncation=True)
|
| 21 |
-
|
| 22 |
input_ids = inputs['input_ids']
|
| 23 |
attention_mask = inputs['attention_mask']
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
|
| 27 |
-
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
if user_input:
|
| 19 |
# Use encode_plus to get both input_ids and attention_mask
|
| 20 |
inputs = tokenizer.encode_plus(user_input, return_tensors="pt", padding=True, truncation=True)
|
|
|
|
| 21 |
input_ids = inputs['input_ids']
|
| 22 |
attention_mask = inputs['attention_mask']
|
| 23 |
|
| 24 |
+
# Print the input tensors for debugging
|
| 25 |
+
st.write("Input IDs:", input_ids)
|
| 26 |
+
st.write("Attention Mask:", attention_mask)
|
| 27 |
|
| 28 |
+
# Generate output with attention mask and pad token ID
|
| 29 |
+
try:
|
| 30 |
+
outputs = model.generate(input_ids, attention_mask=attention_mask, max_length=50)
|
| 31 |
+
st.write("Model Output (Raw):", outputs) # Debugging model raw output
|
| 32 |
+
|
| 33 |
+
# Decode the output and display
|
| 34 |
+
answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 35 |
+
st.write("Answer:", answer)
|
| 36 |
+
except Exception as e:
|
| 37 |
+
st.write("Error generating output:", str(e))
|