Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
@@ -58,11 +58,11 @@ def generate(message, chat_history, max_new_tokens):
|
|
58 |
final_prompt += "User: " + message + "\n"
|
59 |
final_prompt += "Output:"
|
60 |
|
61 |
-
if (
|
62 |
-
|
63 |
-
|
64 |
-
):
|
65 |
-
|
66 |
|
67 |
# Streamer
|
68 |
streamer = TextIteratorStreamer(
|
@@ -99,7 +99,7 @@ with gr.Blocks() as demo:
|
|
99 |
# Phi-2 Scientific Question Chatbot
|
100 |
This chatbot was created using Microsoft's 2.7 billion parameter [phi-2](https://huggingface.co/microsoft/phi-2) Transformer model.
|
101 |
|
102 |
-
Phi-2 model was fine-tuned with questions including physics chemistry biology QA using SciQ dataset. In order to reduce the response time on this hardware, `max_new_tokens` has been set to `21` in the text generation pipeline. With this default configuration, it takes approximately `60 seconds` for the response to start being generated, and streamed one word at a time. Use the slider below to increase or decrease the length of the generated text.
|
103 |
|
104 |
For the safetensor: huggingface.co/mudogruer
|
105 |
"""
|
|
|
58 |
final_prompt += "User: " + message + "\n"
|
59 |
final_prompt += "Output:"
|
60 |
|
61 |
+
# if (
|
62 |
+
# len(tokenizer.tokenize(final_prompt))
|
63 |
+
# >= tokenizer.model_max_length - max_new_tokens
|
64 |
+
# ):
|
65 |
+
# final_prompt = "Instruction: Say 'Input exceeded context size, please clear the chat history and retry!' Output:"
|
66 |
|
67 |
# Streamer
|
68 |
streamer = TextIteratorStreamer(
|
|
|
99 |
# Phi-2 Scientific Question Chatbot
|
100 |
This chatbot was created using Microsoft's 2.7 billion parameter [phi-2](https://huggingface.co/microsoft/phi-2) Transformer model.
|
101 |
|
102 |
+
Phi-2 model was fine-tuned with questions including highschool level physics chemistry biology QA using SciQ dataset. In order to reduce the response time on this hardware, `max_new_tokens` has been set to `21` in the text generation pipeline. With this default configuration, it takes approximately `60 seconds` for the response to start being generated, and streamed one word at a time. Use the slider below to increase or decrease the length of the generated text.
|
103 |
|
104 |
For the safetensor: huggingface.co/mudogruer
|
105 |
"""
|