kez-lab/quiz-korean
๐ง Qwen2.5-0.5B Blog-to-Quiz (On-Device Android AI)
   
A specialized, ultra-lightweight On-Device Small Language Model (sLLM) fine-tuned to read blogs, technical articles, or personal notes and automatically synthesize 4-choice multiple-choice quizzes (Question, Options, Answer Index, and In-depth Explanation) in strictly formatted JSON.
Designed natively for mobile applications and edge runtimes (Google MediaPipe GenAI / LiteRT), running completely offline with zero cloud inference costs and 100% user privacy.
๐ Key Highlights
- ๐ 100% On-Device & Private: No data leaves the user's phone. Operates seamlessly without internet connectivity.
- โก Ultra Lightweight (~350MB in INT4): Optimized for fast token generation on mobile CPUs, GPUs, and NPUs with low thermal footprint.
- ๐ฏ Deterministic JSON Schema: Generates clean, parseable JSON objects designed for direct deserialization into Android/Kotlin data models.
- ๐ Educational & Productivity Focus: Ideal for flashcard apps, tech blog readers (Medium, Velog, Tistory), study assistants, and note-taking tools.
๐ Output Schema & Example
Given an input article or document, the model returns an array of structured quiz objects:
[
{
"question": "Which dispatcher in Kotlin Coroutines is specifically optimized for disk and network I/O operations?",
"options": [
"Dispatchers.Main",
"Dispatchers.IO",
"Dispatchers.Default",
"Dispatchers.Unconfined"
],
"answer_index": 1,
"explanation": "Dispatchers.IO is designed and optimized for offloading blocking I/O tasks such as network requests and file access."
}
]๐ Quickstart & Usage
1. Python (Transformers + PEFT)
import json
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
BASE_MODEL = "Qwen/Qwen2.5-0.5B-Instruct"
ADAPTER_REPO = "kez-lab/qwen2.5-0.5b-blog-quiz-android"
# 1. Load Tokenizer & Base Model
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL, trust_remote_code=True)
base_model = AutoModelForCausalLM.from_pretrained(BASE_MODEL, torch_dtype=torch.float32, trust_remote_code=True)
# 2. Merge LoRA Adapter
model = PeftModel.from_pretrained(base_model, ADAPTER_REPO)
model.eval()
# 3. Inference
article = "Kotlin Coroutines provide lightweight threads that can suspend without blocking..."
system_prompt = (
"You are an AI that analyzes given text and generates multiple-choice quizzes.\n"
"Respond strictly with a JSON array: [{\"question\": \"...\", \"options\": [\"...\"], \"answer_index\": 0, \"explanation\": \"...\"}]"
)
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": f"Generate a multiple-choice quiz based on this text:\n\n{article}"}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt")
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.3, do_sample=True)
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(response)2. Android Kotlin SDK
Integrate this model directly into any Android app using the companion SDK:
// 1. Initialize On-Device Generator
val quizGen = LocalQuizGenerator.builder(context)
.fromHuggingFace("kez-lab/qwen2.5-0.5b-blog-quiz-android")
.build()
// 2. Generate Quizzes on-device
val result = quizGen.generateQuiz(blogText, count = 2)
result.onSuccess { quizzes ->
quizzes.forEach { quiz ->
println("Question: ${quiz.question}")
println("Options: ${quiz.options}")
println("Correct Answer: ${quiz.correctAnswer}")
println("Explanation: ${quiz.explanation}")
}
}๐ฌ Training Configuration
- Base Architecture:
Qwen2.5-0.5B-Instruct(0.49B parameters) - Fine-Tuning Technique: Parameter-Efficient Fine-Tuning (PEFT) via LoRA
- LoRA Hyperparameters:
- Rank ($r$):
16 - Alpha ($\alpha$):
32 - Dropout:
0.05 - Target Modules:
q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj - Training Setup:
- Hardware: Apple Silicon (M4 Pro) via Metal Performance Shaders (
torch.device("mps")) - Epochs:
8 - Optimizer: AdamW (
learning_rate=3e-4) - Final Loss: `0.4139`
โ๏ธ License
This model and its adapter weights are released under the Apache 2.0 License.
๐ค Author & Attribution
- Author: kez-lab
- Repository: kez-lab/qwen2.5-0.5b-blog-quiz-android
Framework versions
- PEFT 0.20.0
