Instructions to use Alghayth/qwen3-studygenie-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Alghayth/qwen3-studygenie-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/Qwen3-8B-unsloth-bnb-4bit") model = PeftModel.from_pretrained(base_model, "Alghayth/qwen3-studygenie-lora") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Desktop
StudyGenie — Arabic quiz & flashcard adapter
A LoRA adapter for Qwen3-8B that generates multiple-choice quizzes and flashcards from study material, always in Arabic, whether the source document is Arabic or English.
Built for StudyGenie, a graduation project at King Saud University (Group 4).
What it does
Given a passage from a lecture PDF, it produces strict JSON: four distinct options, one correct answer, an explanation, and a self-reported question type.
{
"question": "ما الذي يحدد كيفية اختيار وكيل ذكي لعملية عمله؟",
"options": ["...", "...", "...", "..."],
"correct_option": "يختار وكيلًا عملًا يُتوقع أن يُحسّن قياس الأداء الخاص به.",
"explanation": "...",
"question_type": "definition"
}
The cross-lingual case — an English lecture producing an Arabic quiz — is the capability this adapter exists for. Most computer science lectures at KSU are in English, while many students revise more comfortably in Arabic.
Usage
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "Alghayth/qwen3-studygenie-lora",
max_seq_length = 2048,
dtype = None,
load_in_4bit = True,
)
FastLanguageModel.for_inference(model)
Or with vLLM, applying the adapter over the full-precision base:
from vllm import LLM
from vllm.lora.request import LoRARequest
llm = LLM(model="Qwen/Qwen3-8B", enable_lora=True, max_lora_rank=16)
lora = LoRARequest("studygenie", 1, "<path to this adapter>")
Prompt format
The system prompt must match the one used in training, or quality degrades:
Generate exactly one multiple-choice question from the given passage. Use only the
passage content. Do not use outside knowledge. Return valid JSON only. Write the
question, all options and the explanation in Modern Standard Arabic, even if the
passage is in another language. Keep technical terms that have no established Arabic
equivalent in their original Latin form, followed by the Arabic term in parentheses on
first use. Include a "question_type" field with one of: "definition", "cause_effect",
"comparison", "factual", "applied".
User turn: Text passage: {chunk}
Qwen3 is a hybrid reasoning model. Apply the chat template with
enable_thinking=False — reasoning blocks break strict JSON output.
Sampling
| temperature | 0.3 — low enough for reliable JSON, high enough that a 15-question quiz varies |
| top_p | 0.9 |
| repetition_penalty | 1.05 — Arabic tends toward repeated phrasing in longer explanations |
| max_new_tokens | 400 |
Training
| Base | unsloth/Qwen3-8B-unsloth-bnb-4bit (4-bit QLoRA) |
| Rank / alpha | 16 / 16 |
| Target modules | q, k, v, o, gate, up, down |
| Learning rate | 2e-4, linear schedule, 10 warmup steps |
| Epochs | 3 (414 steps, effective batch size 8) |
| Max sequence length | 2048 |
| Hardware | one NVIDIA Tesla T4, 124 minutes, 9.94 GB peak |
| Final loss | 0.429 |
| Trainable parameters | 43,646,976 of 8,234,382,336 (0.53%) |
Loss is computed on the assistant response only. Without that, roughly 75% of the training signal would be spent teaching the model to reproduce lecture text rather than generate questions from it.
Training data
1,097 examples, built from a curated instruction dataset derived from Wikipedia (CC BY-SA 4.0):
| Slice | Count | Passage | Answer |
|---|---|---|---|
| Arabic native | 788 | Arabic | Arabic |
| Cross-lingual | 309 | English | Arabic |
The cross-lingual slice was generated by a teacher model and validated: JSON parses, four distinct options with the correct one among them, Arabic character ratio above 0.5, and every number and Latin-script term in the Arabic answer also present in the English source passage. That last check rejected 16 of 400 candidates in which the teacher introduced a figure the passage did not contain. Accept rate 96%.
English-output examples were deliberately excluded so the adapter could specialise.
Evaluation
Same harness, same 120-example held-out test split, both columns. The split is by topic, so no document or subject appears in both training and test.
| Metric | Base Qwen3-8B | This adapter |
|---|---|---|
| JSON validity | 100.0% | 100.0% |
| Schema validity | 43.3% | 97.5% |
| Arabic output from Arabic passages | 40.0% | 97.6% |
| Arabic output from English passages | 51.4% | 97.1% |
| Groundedness, Arabic passages | 23.5% | 70.6% |
| Groundedness, English passages | 45.7% | 80.0% |
The schema row is the clearest result: JSON validity is 100% in both columns, so the base
model can write JSON — it cannot write this JSON. Missing fields, wrong types, no
question_type.
On real lecture material
Run end to end over 33 chunks extracted from two English CS lecture PDFs:
| Quiz | 10 of 10 delivered, from 19 attempts (53% acceptance) |
| Flashcards | 10 of 10 delivered, from 14 attempts (71% acceptance) |
| Speed | 28 s per question, 7.5 s per flashcard |
Limitations
Training passages are encyclopaedic prose; deployment is on lecture slides, which are terser, bulleted and carry extraction artefacts. Measured effect: 53% acceptance on real lecture chunks against near-complete acceptance on clean prose.
Question-type labels carry a known bias. They were derived from question text by a bilingual keyword classifier; 20.4% matched no rule and took
definitionas a default. The labels teach the model the vocabulary of the field — quiz-level balance is enforced at generation time by a least-represented-type preference, not by these labels.Cross-lingual grounding is a weak discriminator. Embedding similarity was calibrated empirically (0.54 with
bge-m3), but matched and mismatched distributions overlap substantially (matched p10 = 0.530 against mismatched p90 = 0.560). Within a single academic domain, topic relatedness and actual grounding are hard to separate by embedding alone.English output quality is not maintained, by design.
Occasional Arabic spelling slips appear in generated text. Automated validation cannot catch these; human review is required for quality assurance.
Intended use
Educational question generation from study material, in Arabic. Output should be passed through grounding and schema validation before being shown to a student — the adapter alone will occasionally produce ungrounded questions.
Not suitable for high-stakes assessment without human review.
Citation
Developed as part of StudyGenie, a graduation project at King Saud University, 2026. NLP and model lane: Munira.
- Downloads last month
- 98