pratikshahp commited on
Commit
bc39835
·
verified ·
1 Parent(s): cf5c285

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -20,11 +20,14 @@ def generate_mcqs(text, num_questions=5):
20
  # Tokenize the input text
21
  inputs = tokenizer(text, return_tensors="pt", max_length=1024, truncation=True)
22
 
23
- # Generate MCQs by providing the text as input to the model
24
- outputs = model.generate(**inputs, max_length=100, num_return_sequences=num_questions, temperature=0.7)
25
-
26
- # Decode the generated sequences
27
- mcqs = [tokenizer.decode(output, skip_special_tokens=True) for output in outputs]
 
 
 
28
 
29
  return mcqs
30
 
 
20
  # Tokenize the input text
21
  inputs = tokenizer(text, return_tensors="pt", max_length=1024, truncation=True)
22
 
23
+ mcqs = []
24
+ for _ in range(num_questions):
25
+ # Generate a single MCQ at a time
26
+ output = model.generate(**inputs, max_length=100, temperature=0.7, num_return_sequences=1)
27
+
28
+ # Decode the generated sequence
29
+ mcq = tokenizer.decode(output[0], skip_special_tokens=True)
30
+ mcqs.append(mcq)
31
 
32
  return mcqs
33