DHRUV SHEKHAWAT commited on
Commit
93c51a9
·
1 Parent(s): 8fa9e91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -17
app.py CHANGED
@@ -71,27 +71,27 @@ def completion_model(vocab_size, max_len, d_model, n_head, ff_dim, dropout_rate,
71
  chatbot.compile(optimizer="adam", loss="sparse_categorical_crossentropy")
72
 
73
  for i in range(1):
74
- other_text1 = text2
75
- other_text1 = other_text1.lower()
76
- other_words1 = other_text1.split()
77
- other_num1 = [word_to_num[word] for word in other_words1]
78
- given_X1 = other_num1
79
- input_sequence1 = pad_sequences([given_X1], maxlen=max_len, padding='post')
80
- output_sentence = ""
81
  for _ in range(len2):
82
- predicted_token = np.argmax(chatbot.predict(input_sequence1), axis=-1)
83
  predicted_token = predicted_token.item()
84
  out = num_to_word[predicted_token]
85
-
86
-
87
- output_sentence = out
88
-
89
- given_X1 = given_X1[1:]
90
- given_X1.append(predicted_token)
91
- input_sequence1 = pad_sequences([given_X1], maxlen=max_len, padding='post')
92
 
93
- out2 = output_sentence
94
- return out2
95
  st.title("UniGLM TEXT completion Model")
96
  st.subheader("Next Word Prediction AI Model by Webraft-AI")
97
  #Picking what NLP task you want to do
 
71
  chatbot.compile(optimizer="adam", loss="sparse_categorical_crossentropy")
72
 
73
  for i in range(1):
74
+ other_text2 = text2
75
+ other_text2 = other_text2.lower()
76
+ other_words2 = other_text2.split()
77
+ other_num2 = [word_to_num[word] for word in other_words2]
78
+ given_X2 = other_num2
79
+ input_sequence2 = pad_sequences([given_X2], maxlen=max_len, padding='post')
80
+ output_sentence = other_text2 + ""
81
  for _ in range(len2):
82
+ predicted_token = np.argmax(chatbot.predict(input_sequence2), axis=-1)
83
  predicted_token = predicted_token.item()
84
  out = num_to_word[predicted_token]
85
+ # if out == ".":
86
+ # break
87
+
88
+ output_sentence += " " + out
89
+ given_X2 = given_X2[1:]
90
+ given_X2.append(predicted_token)
91
+ input_sequence2 = pad_sequences([given_X2], maxlen=max_len, padding='post')
92
 
93
+ out2 = output_sentence
94
+ return out2
95
  st.title("UniGLM TEXT completion Model")
96
  st.subheader("Next Word Prediction AI Model by Webraft-AI")
97
  #Picking what NLP task you want to do