Extraction modes¶
Seven strategies. The mode is picked per job from the document's page, along with the model that will run it.
| Mode key | For | How it works |
|---|---|---|
standard |
A document with the answer marked inline after each question | One model pass per 50-page chunk, pulling question, options, answer and explanation together. |
questions_only |
No answers available anywhere | Extracts stems and options. The answer is left for a person. |
ai_answer |
Questions without a key, where the model can work the answer out | Two passes: extract the questions, then a second pass determines the correct answer for each. |
two_step |
A separate answer-key section at the back | Extract the questions, extract the key, then match the two. |
regex |
A non-standard but consistent answer format | The model analyses the format and writes a regex; the regex is then applied to the whole document with no further model calls. Cheap and fast once it is right. |
ai_decide |
An unknown format | The model samples the document, picks one of the above, and runs it. Falls back to standard if it cannot decide. |
generate |
A textbook chapter or study notes — no questions in the source at all | The model writes MCQs from the text. The correct answer comes from the text; the distractors come from the model. |
The README lists six
README.md omits ai_answer and merges regex with it under one "AI +
Regex" row. The code has seven mode keys.
Choosing between them¶
- If the PDF says "Correct Answer: C" or "Preferred Response: C" under each
question, use
standard. - If the answers are in a block at the end, use
two_step. - If the answers are marked in some house style the model keeps getting
slightly wrong, use
regex— it pays for one analysis pass and then never calls the model again, so it is the cheapest option for a long document in a consistent format. - If you do not know, use
ai_decideon a small page range first and look at what it chose. generateis a different activity from the other six. It is not extraction; it is authoring, and the drafts want reading as such.
Figures¶
The extraction schema includes a boolean has_figure per question, and the
prompt says to set it true only when a figure, radiograph, ECG or chart is
essential to answering.
A draft gets a page image attached only if that flag came back true. This is what stops every question on an illustrated page acquiring the illustration.
Where a job goes¶
POST /drafts/extract → Celery task extract_quiz → a DraftBatch of
DraftQuestion rows. Never a live Question, never a live Quiz.
Progress is pushed to a Redis list per job and polled from /jobs.
Configuring the models¶
Settings → AI Models. Models are registered per task:
| Task | Used by |
|---|---|
extraction |
These modes, and the offline article batch writer |
article |
POST /articles/ai-draft and ai-refine |
flashcard |
Generating a deck from an article |
teach |
The tutor drawer |
keyword |
Difficulty classification |
tool |
Reading an image when the primary model cannot see |
tts, stt |
Voice |
get_model_for_task(db, task) falls back to settings.LITELLM_MODEL;
get_configured_model(db, task) returns nothing instead, for work that must
not run on a model nobody chose.