Alien-Y commited on
Commit
a1910a9
·
1 Parent(s): 034e924

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -34,6 +34,10 @@ if question == '':
34
  else:
35
  result = model.predict(keras.preprocessing.sequence.pad_sequences(tokenizer.texts_to_sequences([question]),
36
  truncating='post', maxlen=max_len))
 
 
 
 
37
 
38
  tag = lbl_encoder.inverse_transform([np.argmax(result)])
39
 
 
34
  else:
35
  result = model.predict(keras.preprocessing.sequence.pad_sequences(tokenizer.texts_to_sequences([question]),
36
  truncating='post', maxlen=max_len))
37
+
38
+ idk = ['عذراً، لا يمكنني الإجابة عن السؤال المطروح', 'عذراً، لم أفهم سؤالك']
39
+ if result[0][np.argmax(result)] < 0.65: # if perplexity is high
40
+ st.write(np.random.choice(idk))
41
 
42
  tag = lbl_encoder.inverse_transform([np.argmax(result)])
43