Spaces:
Sleeping
Sleeping
First commit
Browse files- app.py +25 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
| 3 |
+
|
| 4 |
+
# Instantiate the model
|
| 5 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("dantedgp/question-generator")
|
| 6 |
+
tokenizer = AutoTokenizer.from_pretrained("dantedgp/question-generator")
|
| 7 |
+
|
| 8 |
+
def generate_response(txt):
|
| 9 |
+
input_text = f"ask: {txt}"
|
| 10 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
|
| 11 |
+
outputs = model.generate(input_ids, max_new_tokens=100, do_sample=False)
|
| 12 |
+
question = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 13 |
+
|
| 14 |
+
print('question: ', question)
|
| 15 |
+
return question
|
| 16 |
+
|
| 17 |
+
st.set_page_config(page_title='AI Quiz Generator')
|
| 18 |
+
st.title('AI Quiz Generator')
|
| 19 |
+
|
| 20 |
+
# Text input
|
| 21 |
+
result = []
|
| 22 |
+
txt_input = st.text_area('Enter your text', '', height=200)
|
| 23 |
+
|
| 24 |
+
if len(result):
|
| 25 |
+
st.info(result)
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
torch
|