Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,12 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import torch
|
3 |
from transformers import pipeline
|
|
|
4 |
|
5 |
-
|
6 |
-
pipe = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta", device_map="auto", torch_dtype=torch.float16)
|
7 |
|
8 |
-
# Function to generate questions
|
9 |
def generate_questions(text):
|
10 |
-
prompt = f"Ask 5 short, simple comprehension questions about this English coursebook text:\n\n{text}"
|
11 |
-
|
12 |
-
return
|
13 |
-
|
14 |
-
# Gradio Interface
|
15 |
-
demo = gr.Interface(fn=generate_questions, inputs="textbox", outputs="textbox", title="Coursebook Question Generator")
|
16 |
|
17 |
-
demo.
|
|
|
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
|
4 |
+
pipe = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta")
|
|
|
5 |
|
|
|
6 |
def generate_questions(text):
|
7 |
+
prompt = f"Ask 5 short, simple comprehension questions about this English coursebook text:\n\n\"{text}\""
|
8 |
+
response = pipe(prompt, max_new_tokens=200)[0]["generated_text"]
|
9 |
+
return response
|
|
|
|
|
|
|
10 |
|
11 |
+
demo = gr.Interface(fn=generate_questions, inputs="text", outputs="text")
|
12 |
+
demo.launch()
|