Update app.py
Browse files
app.py
CHANGED
@@ -129,8 +129,13 @@ def talk(prompt, history):
|
|
129 |
tokenizer.convert_tokens_to_ids("<|eot_id|>") # Converts a token strings in a single/ sequence of integer id using the vocabulary
|
130 |
]
|
131 |
# indicates the end of a sequence
|
|
|
|
|
|
|
|
|
|
|
132 |
|
133 |
-
model_input = model.create_chat_completion(messages = messages)
|
134 |
|
135 |
# input_ids = tokenizer.apply_chat_template(
|
136 |
# messages,
|
@@ -166,9 +171,9 @@ def talk(prompt, history):
|
|
166 |
# t.start()
|
167 |
# print("check11")
|
168 |
# start a thread
|
169 |
-
outputs = []
|
170 |
-
outputs = model_input
|
171 |
-
return outputs
|
172 |
# print(model.tokenize(messages))
|
173 |
# tokens = model.tokenize(messages)
|
174 |
# for token in model.generate(tokens):
|
@@ -190,20 +195,7 @@ def talk(prompt, history):
|
|
190 |
# print(f'Time per token: {(time_generate/NUM_TOKENS)*1000}ms')
|
191 |
|
192 |
|
193 |
-
|
194 |
-
print("check9")
|
195 |
-
#print(outputtokens)
|
196 |
-
|
197 |
-
#outputs = model.detokenize(outputtokens, decode = True)
|
198 |
-
#print(outputs)
|
199 |
-
# for token in model.generate(input_ids):
|
200 |
-
# print(model.detokenize(token))
|
201 |
-
# outputs.append(model.detokenize(token))
|
202 |
-
# output = model.detokenize(token)
|
203 |
-
# print(outputs)
|
204 |
-
# yield "".join(outputs)
|
205 |
-
# print("check12")
|
206 |
-
|
207 |
pd.options.display.max_colwidth = 800
|
208 |
print("check13")
|
209 |
# outputstring = ''.join(outputs)
|
|
|
129 |
tokenizer.convert_tokens_to_ids("<|eot_id|>") # Converts a token strings in a single/ sequence of integer id using the vocabulary
|
130 |
]
|
131 |
# indicates the end of a sequence
|
132 |
+
text = ""
|
133 |
+
stream = model(formatted_prompt, max_tokens=1000, stop=["</s>"], stream=True)
|
134 |
+
for output in stream:
|
135 |
+
text += output["choices"][0]["text"]
|
136 |
+
yield text
|
137 |
|
138 |
+
# model_input = model.create_chat_completion(messages = messages)
|
139 |
|
140 |
# input_ids = tokenizer.apply_chat_template(
|
141 |
# messages,
|
|
|
171 |
# t.start()
|
172 |
# print("check11")
|
173 |
# start a thread
|
174 |
+
# outputs = []
|
175 |
+
# outputs = model_input
|
176 |
+
# return outputs
|
177 |
# print(model.tokenize(messages))
|
178 |
# tokens = model.tokenize(messages)
|
179 |
# for token in model.generate(tokens):
|
|
|
195 |
# print(f'Time per token: {(time_generate/NUM_TOKENS)*1000}ms')
|
196 |
|
197 |
|
198 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
pd.options.display.max_colwidth = 800
|
200 |
print("check13")
|
201 |
# outputstring = ''.join(outputs)
|