Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import fitz # PyMuPDF
|
| 3 |
# Load model directly
|
| 4 |
-
from transformers import AutoTokenizer,
|
| 5 |
|
| 6 |
-
tokenizer = AutoTokenizer.from_pretrained("google
|
| 7 |
-
model =
|
| 8 |
|
| 9 |
# Function to extract text from PDF
|
| 10 |
def extract_text_from_pdf(pdf_file):
|
|
@@ -20,7 +20,6 @@ def generate_mcqs(text, num_questions=5):
|
|
| 20 |
if not text.strip():
|
| 21 |
return ["No text extracted from the PDF. Unable to generate MCQs."]
|
| 22 |
|
| 23 |
-
|
| 24 |
# Tokenize the input text
|
| 25 |
inputs = tokenizer(text, return_tensors="pt", max_length=512, truncation=True)
|
| 26 |
|
|
@@ -30,7 +29,6 @@ def generate_mcqs(text, num_questions=5):
|
|
| 30 |
output = model.generate(
|
| 31 |
**inputs,
|
| 32 |
max_length=512, # Adjusted to match the tokenized input length
|
| 33 |
-
max_new_tokens=100, # Limit the number of new tokens added during generation
|
| 34 |
temperature=0.7,
|
| 35 |
num_return_sequences=1
|
| 36 |
)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import fitz # PyMuPDF
|
| 3 |
# Load model directly
|
| 4 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 5 |
|
| 6 |
+
tokenizer = AutoTokenizer.from_pretrained("google/bert_uncased_L-12_H-768_A-12")
|
| 7 |
+
model = AutoModelForCausalLM.from_pretrained("google/bert_uncased_L-12_H-768_A-12")
|
| 8 |
|
| 9 |
# Function to extract text from PDF
|
| 10 |
def extract_text_from_pdf(pdf_file):
|
|
|
|
| 20 |
if not text.strip():
|
| 21 |
return ["No text extracted from the PDF. Unable to generate MCQs."]
|
| 22 |
|
|
|
|
| 23 |
# Tokenize the input text
|
| 24 |
inputs = tokenizer(text, return_tensors="pt", max_length=512, truncation=True)
|
| 25 |
|
|
|
|
| 29 |
output = model.generate(
|
| 30 |
**inputs,
|
| 31 |
max_length=512, # Adjusted to match the tokenized input length
|
|
|
|
| 32 |
temperature=0.7,
|
| 33 |
num_return_sequences=1
|
| 34 |
)
|