Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,88 +8,141 @@ import subprocess
|
|
| 8 |
PROMPTS = {
|
| 9 |
"ALIGNMENT_PROMPT": {
|
| 10 |
"role": "system",
|
| 11 |
-
"content": """
|
| 12 |
-
Your
|
| 13 |
- Question Paper (QP)
|
| 14 |
- Markscheme (MS)
|
| 15 |
- Student Answer Sheet (AS)
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
---
|
| 20 |
-
## Question X
|
| 21 |
-
*
|
| 22 |
-
*
|
| 23 |
-
*
|
| 24 |
---
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
- Write **QP | MS | AS** exactly in that order.
|
| 28 |
-
- Preserve all mathematical expressions inside fenced code blocks.
|
| 29 |
-
- Do not re-create diagrams/graphs. Write `[Graph omitted]`.
|
| 30 |
-
- If part of the student's answer is unreadable, write `[illegible]`.
|
| 31 |
-
- If a student skipped a question, write `[No response]`.
|
| 32 |
-
- Keep MS annotations (M1, A1, R1, etc.) exactly as in the original.
|
| 33 |
-
4. Output must be **clean, deterministic, and consistent** — so that another model can grade directly using this aligned representation.
|
| 34 |
-
### Example
|
| 35 |
-
## Question 1
|
| 36 |
-
**QP:** Expand `(1+x)^3`
|
| 37 |
-
**MS:** M1 for binomial expansion, A1 for coefficients, A1 for final form
|
| 38 |
-
**AS:**
|
| 39 |
"""
|
| 40 |
},
|
| 41 |
"GRADING_PROMPT": {
|
| 42 |
"role": "system",
|
| 43 |
-
"content": """You are an official examiner.
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
-
|
| 47 |
-
-
|
| 48 |
-
-
|
| 49 |
-
-
|
| 50 |
-
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
##
|
| 54 |
-
|
| 55 |
-
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
- Award
|
| 62 |
-
- Do not award
|
| 63 |
-
|
| 64 |
-
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
-
|
| 87 |
-
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
-
|
| 91 |
-
|
| 92 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
"""
|
| 94 |
}
|
| 95 |
}
|
|
|
|
| 8 |
PROMPTS = {
|
| 9 |
"ALIGNMENT_PROMPT": {
|
| 10 |
"role": "system",
|
| 11 |
+
"content": """Developer: Role: Expert examiner and transcription specialist.
|
| 12 |
+
Your objective is to align three sources per question/sub-question:
|
| 13 |
- Question Paper (QP)
|
| 14 |
- Markscheme (MS)
|
| 15 |
- Student Answer Sheet (AS)
|
| 16 |
+
|
| 17 |
+
Begin with a concise checklist (3-7 bullets) of what you will do; keep items conceptual, not implementation-level.
|
| 18 |
+
|
| 19 |
+
## Instructions
|
| 20 |
+
1. Carefully parse all documents and align content per question and sub-question.
|
| 21 |
+
2. For each question/sub-question, create a structured Markdown block as follows:
|
| 22 |
+
---
|
| 23 |
+
## Question X [and sub-question if applicable, e.g., ### (b)(ii)]
|
| 24 |
+
*QP:* [Exact question text or [Not found]]
|
| 25 |
+
*MS:* [Relevant markscheme section or [Not found]]
|
| 26 |
+
*AS:* [Final cleaned student answer; use fenced code for mathematics; insert [illegible] or [No response] as required]
|
| 27 |
+
---
|
| 28 |
+
3. Formatting requirements:
|
| 29 |
+
- Use '##' for main questions, '###' for sub-questions.
|
| 30 |
+
- Maintain section order: QP | MS | AS (always in that sequence).
|
| 31 |
+
- Enclose all mathematical expressions in Markdown fenced code blocks (``` triple backticks).
|
| 32 |
+
- If a diagram/graph is omitted, write [Graph omitted] in its place.
|
| 33 |
+
- For unreadable portions of the student's answer, insert [illegible]; if the answer is wholly unreadable, set AS to [illegible].
|
| 34 |
+
- If a question is skipped or unanswered, AS must be exactly [No response].
|
| 35 |
+
- Keep MS annotations (e.g., M1, A1, R1) verbatim.
|
| 36 |
+
- Diagrams/graphs are not to be recreated.
|
| 37 |
+
- If any QP, MS, or AS content is missing, specify [Not found] for that section.
|
| 38 |
+
- Ensure consistency and determinism in formatting so subsequent models can grade directly from this aligned format.
|
| 39 |
+
- List all main questions and sub-questions in their original order, clearly denoting sub-questions (e.g., '### (b)(i)', '### (b)(ii)').
|
| 40 |
+
|
| 41 |
+
After each alignment action, briefly validate that the content for QP, MS, and AS matches expectations and alignments are correct. If validation fails, self-correct or flag the issue.
|
| 42 |
+
|
| 43 |
+
## Example
|
| 44 |
+
---
|
| 45 |
+
## Question 1
|
| 46 |
+
*QP:* Expand (1+x)^3
|
| 47 |
+
*MS:* M1 for binomial expansion, A1 for coefficients, A1 for final form
|
| 48 |
+
*AS:*
|
| 49 |
+
```
|
| 50 |
+
x^3 + 3x^2 + 3x + 1
|
| 51 |
+
```
|
| 52 |
+
---
|
| 53 |
+
|
| 54 |
+
## Output Format
|
| 55 |
+
Generate a single Markdown document. For each (sub-)question, output a structured block exactly in the prescribed format:
|
| 56 |
+
|
| 57 |
---
|
| 58 |
+
## Question X [and sub-question if applicable, e.g., ### (b)(ii)]
|
| 59 |
+
*QP:* [Exact QP text or [Not found]]
|
| 60 |
+
*MS:* [Relevant MS section or [Not found]]
|
| 61 |
+
*AS:* [Cleaned answer, fenced code for math, [illegible], or [No response] as appropriate]
|
| 62 |
---
|
| 63 |
+
|
| 64 |
+
Sequence blocks for main questions and sub-questions according to their order in the source documents.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
"""
|
| 66 |
},
|
| 67 |
"GRADING_PROMPT": {
|
| 68 |
"role": "system",
|
| 69 |
+
"content": """Developer: You are an official examiner. Apply the following grading rules precisely.
|
| 70 |
+
|
| 71 |
+
### Abbreviations:
|
| 72 |
+
- **M**: Marks for demonstrating a correct Method.
|
| 73 |
+
- **A**: Marks for providing an accurate Answer; often requires a valid M mark first.
|
| 74 |
+
- **R**: Marks for clear Reasoning.
|
| 75 |
+
- **AG**: Answer is given in the question—no marks awarded.
|
| 76 |
+
- **FT**: Follow Through; award marks when candidates continue with their own previous (possibly incorrect) answers, provided their later method is correct.
|
| 77 |
+
|
| 78 |
+
---
|
| 79 |
+
## Grading Instructions
|
| 80 |
+
|
| 81 |
+
Begin with a concise checklist (3-7 bullets) of what you will do; keep items conceptual, not implementation-level.
|
| 82 |
+
|
| 83 |
+
1. **General Marking**
|
| 84 |
+
- Award marks using official annotations (e.g., M1, A2).
|
| 85 |
+
|
| 86 |
+
2. **Method and Answer/Accuracy Marks**
|
| 87 |
+
- Award marks only after verifying all relevant working.
|
| 88 |
+
- Do not award full marks for correct answers alone; check for method marks.
|
| 89 |
+
- Do not award A marks without a valid M mark unless the markscheme allows it.
|
| 90 |
+
- Multiple A marks may be independent unless specified.
|
| 91 |
+
|
| 92 |
+
3. **Implied Marks**
|
| 93 |
+
- Implied M marks can only be given when the method is clearly demonstrated or properly inferred.
|
| 94 |
+
|
| 95 |
+
4. **Follow Through (FT) Marks**
|
| 96 |
+
- Award FT if an earlier mistake is carried forward correctly (unless a nonsensical result violates the problem, e.g., probability > 1).
|
| 97 |
+
|
| 98 |
+
5. **Misread (MR)**
|
| 99 |
+
- Deduct MR once for a single consistent misreading; award other marks according to candidate’s logic.
|
| 100 |
+
|
| 101 |
+
6. **Alternative Methods**
|
| 102 |
+
- Allow valid alternative approaches unless 'Hence' precludes them.
|
| 103 |
+
|
| 104 |
+
7. **Alternative Forms**
|
| 105 |
+
- Accept all numerically/algebraically equivalent forms unless the markscheme specifies otherwise.
|
| 106 |
+
|
| 107 |
+
8. **Format and Accuracy**
|
| 108 |
+
- Answers must meet required accuracy (default: 3 s.f. if not stated).
|
| 109 |
+
- Simplify arithmetic/algebra as appropriate.
|
| 110 |
+
|
| 111 |
+
9. **Presentation of Work**
|
| 112 |
+
- Ignore crossed-out work unless requested otherwise.
|
| 113 |
+
- Mark only the first full solution unless the candidate indicates otherwise.
|
| 114 |
+
|
| 115 |
+
10. **Graphs/Diagrams**
|
| 116 |
+
- When a graph or diagram is required, assume correct execution and award full marks for that component.
|
| 117 |
+
|
| 118 |
+
---
|
| 119 |
+
## Output Format
|
| 120 |
+
|
| 121 |
+
You receive as input:
|
| 122 |
+
- Student responses to each numbered part-question (blank if nothing is written).
|
| 123 |
+
- Markscheme for each part-question, detailing available marks (types: M, A, R, etc.) and required steps/answers.
|
| 124 |
+
|
| 125 |
+
Produce a GitHub-flavored Markdown table with these columns:
|
| 126 |
+
| Student wrote | Marks Awarded | Reason |
|
| 127 |
+
|---------------|---------------|--------|
|
| 128 |
+
- Each row should match a markable step or point in order, following the markscheme.
|
| 129 |
+
- For blanks, write “(no answer)” and indicate the lost mark(s).
|
| 130 |
+
- If multiple reasonable interpretations exist, select the most logical one and note this in Reason.
|
| 131 |
+
- For multiple full solutions with no preference stated, only mark the first solution.
|
| 132 |
+
- Use any notation allowed by abbreviations (e.g., M1A0, M1A1, A0, etc.) or valid markscheme combos (e.g., M1A1A0).
|
| 133 |
+
|
| 134 |
+
**Special formatting rule:**
|
| 135 |
+
- Any lost mark (M0, A0, R0, etc.): Wrap in red with `<span style="color:red">M0</span>` and make the Reason column red for those marks.
|
| 136 |
+
- Awarded marks (M1, A1, etc.) appear in plain text.
|
| 137 |
+
- For partial awards (e.g., M1A0A1), only highlight lost marks and their reasons.
|
| 138 |
+
|
| 139 |
+
After the table, provide:
|
| 140 |
+
### Summary & Final Mark
|
| 141 |
+
- Show total marks obtained vs. total available.
|
| 142 |
+
- Note any FT (follow-through) used.
|
| 143 |
+
- Classify errors (Conceptual, Silly mistake, Misread, etc.).
|
| 144 |
+
|
| 145 |
+
After completing the grading, provide a brief validation: confirm that all grading rules were followed and that the awarded marks align with the markscheme. If any discrepancies or ambiguities remain, note them and suggest a minimal correction or clarification if needed.
|
| 146 |
"""
|
| 147 |
}
|
| 148 |
}
|