Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,10 +5,6 @@ from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
|
| 5 |
"""
|
| 6 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 7 |
"""
|
| 8 |
-
#client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 9 |
-
#client = InferenceClient("vennify/t5-base-grammar-correction")
|
| 10 |
-
#gr.load("models/vennify/t5-base-grammar-correction").launch()
|
| 11 |
-
|
| 12 |
# Load the model and tokenizer
|
| 13 |
model_name = "vennify/t5-base-grammar-correction"
|
| 14 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
|
@@ -28,15 +24,7 @@ def correct_text(text, max_length, num_beams, temperature, top_p):
|
|
| 28 |
return corrected_text
|
| 29 |
|
| 30 |
|
| 31 |
-
def respond(
|
| 32 |
-
message,
|
| 33 |
-
history: list[tuple[str, str]],
|
| 34 |
-
system_message,
|
| 35 |
-
max_tokens,
|
| 36 |
-
num_beams,
|
| 37 |
-
temperature,
|
| 38 |
-
top_p,
|
| 39 |
-
):
|
| 40 |
#messages = [{"role": "system", "content": system_message}]
|
| 41 |
|
| 42 |
#for val in history:
|
|
@@ -47,7 +35,7 @@ def respond(
|
|
| 47 |
|
| 48 |
#messages.append({"role": "user", "content": message})
|
| 49 |
|
| 50 |
-
response = correct_text(message,
|
| 51 |
yield response
|
| 52 |
|
| 53 |
"""
|
|
@@ -57,7 +45,8 @@ demo = gr.ChatInterface(
|
|
| 57 |
respond,
|
| 58 |
additional_inputs=[
|
| 59 |
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
| 60 |
-
gr.Slider(minimum=1, maximum=2048, value=
|
|
|
|
| 61 |
gr.Slider(minimum=1, maximum=10, value=5, step=1, label="Num Beams"),
|
| 62 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 63 |
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
|
|
|
|
| 5 |
"""
|
| 6 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 7 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
# Load the model and tokenizer
|
| 9 |
model_name = "vennify/t5-base-grammar-correction"
|
| 10 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
|
|
|
| 24 |
return corrected_text
|
| 25 |
|
| 26 |
|
| 27 |
+
def respond(message, history: list[tuple[str, str]], system_message, max_length, min_length, num_beams, temperature, top_p):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
#messages = [{"role": "system", "content": system_message}]
|
| 29 |
|
| 30 |
#for val in history:
|
|
|
|
| 35 |
|
| 36 |
#messages.append({"role": "user", "content": message})
|
| 37 |
|
| 38 |
+
response = correct_text(message, max_length, min_length, num_beams, temperature, top_p)
|
| 39 |
yield response
|
| 40 |
|
| 41 |
"""
|
|
|
|
| 45 |
respond,
|
| 46 |
additional_inputs=[
|
| 47 |
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
| 48 |
+
gr.Slider(minimum=1, maximum=2048, value=100, step=1, label="Max Length"),
|
| 49 |
+
gr.Slider(minimum=1, maximum=2048, value=0, step=1, label="Min Length"),
|
| 50 |
gr.Slider(minimum=1, maximum=10, value=5, step=1, label="Num Beams"),
|
| 51 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 52 |
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
|