amyakir commited on
Commit
19f74b2
·
verified ·
1 Parent(s): 3ed8dfc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -12
app.py CHANGED
@@ -1,17 +1,12 @@
1
- import gradio as gr
2
- import torch
3
  from transformers import pipeline
 
4
 
5
- # Load Hugging Face text generation pipeline
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
- output = pipe(prompt, max_new_tokens=200, do_sample=True)[0]["generated_text"]
12
- return output.strip()
13
-
14
- # Gradio Interface
15
- demo = gr.Interface(fn=generate_questions, inputs="textbox", outputs="textbox", title="Coursebook Question Generator")
16
 
17
- demo.launch()
 
 
 
 
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()