Sammaali commited on
Commit
7577eec
Β·
verified Β·
1 Parent(s): 9336c43

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -34
app.py CHANGED
@@ -9,58 +9,45 @@ model_name = "mistral-large-latest"
9
 
10
 
11
  def generate_MCQquestion(text):
12
-
13
  prompt = f"""
14
  You are a strict Arabic exam generator.
15
-
16
  You MUST use ONLY the information explicitly written in the Context.
17
  DO NOT use any external knowledge.
18
- DO NOT add any information not present in the Context.
19
-
20
  Context:
21
  {text}
 
22
  Generate MCQs in Arabic based on the length of the Context.
23
-
24
  Question count rules:
25
- - Very short context (less than 100 words): generate 3 questions only
26
- - Short context (100–300 words): generate 3–5 questions
27
- - Medium context (300–700 words): generate 5–7 questions
28
- - Long context (more than 700 words): generate 7–10 questions
29
- STRICT RULES:
30
- - DO NOT generate more questions than the Context can support.
31
- - DO NOT invent information just to increase the number of questions.
32
- - Quality is more important than quantity.
33
- - Every question MUST be answerable ONLY using the Context.
34
- - Every correct answer MUST exist explicitly in the Context.
35
- - DO NOT infer or assume information.
36
- - DO NOT use outside knowledge.
37
- - DO NOT create general biology questions.
38
- - Use ONLY facts present in the Context text.
39
- - If the answer cannot be found directly in the Context, DO NOT create the question.
40
-
41
-
42
- Options rules:
43
- - 4 options per question
44
- - Only one correct answer
45
- - Incorrect options must be plausible but still related to the Context
46
- - No duplicate options
47
-
48
  Return ONLY valid JSON:
49
-
50
  {{
51
  "mcqs": [
52
  {{
53
  "question": "string",
54
  "options": ["opt1", "opt2", "opt3", "opt4"],
55
- "answer_index": integer
56
  "answer_source": "exact sentence from context"
57
  }}
58
  ]
59
  }}
60
-
61
-
62
-
63
- """
64
 
65
  try:
66
 
 
9
 
10
 
11
  def generate_MCQquestion(text):
 
12
  prompt = f"""
13
  You are a strict Arabic exam generator.
 
14
  You MUST use ONLY the information explicitly written in the Context.
15
  DO NOT use any external knowledge.
16
+
 
17
  Context:
18
  {text}
19
+
20
  Generate MCQs in Arabic based on the length of the Context.
21
+
22
  Question count rules:
23
+ - Very short context (< 100 words): 3 questions.
24
+ - Short context (100–300 words): 3–5 questions.
25
+ - Medium context (300–700 words): 5–7 questions.
26
+ - Long context (> 700 words): 7–10 questions.
27
+
28
+ STRICT RULES FOR OPTIONS & ANSWERS:
29
+ 1. **Randomize Answer Position:** The correct answer index (0-3) MUST be distributed randomly across the questions. Do NOT always place the correct answer at index 0.
30
+ 2. **Length Consistency:** All 4 options for a single question should have roughly the same length. Do NOT make the correct answer significantly longer or more detailed than the distractors.
31
+ 3. **Plausible Distractors:** Incorrect options must be highly plausible and derived from the context's vocabulary to challenge the student.
32
+ 4. **Source Integrity:** Every correct answer and its "answer_source" MUST exist explicitly in the text.
33
+
34
+ STRICT QUALITY RULES:
35
+ - Quality over quantity.
36
+ - No outside knowledge or general info.
37
+ - If the context doesn't support the required number of questions, stop at what is factual.
38
+
 
 
 
 
 
 
 
39
  Return ONLY valid JSON:
 
40
  {{
41
  "mcqs": [
42
  {{
43
  "question": "string",
44
  "options": ["opt1", "opt2", "opt3", "opt4"],
45
+ "answer_index": integer (0 to 3),
46
  "answer_source": "exact sentence from context"
47
  }}
48
  ]
49
  }}
50
+ """
 
 
 
51
 
52
  try:
53