{"slug": "studybuddy-ai-taming-gemma-2b-to-build-a-local-quiz-generator-for-a-friend", "title": "StudyBuddy AI: Taming Gemma 2B to Build a Local Quiz Generator for a Friend", "summary": "A developer built StudyBuddy AI, a fully local web app that generates three-question multiple-choice quizzes on any topic using Google's gemma2:2b model via Ollama, a .NET 10 Minimal API backend, and a vanilla JavaScript frontend. To work around the small model's tendency to hallucinate or merge answers when asked for a multi-question JSON array, the backend queries Gemma for one question at a time in a loop and assembles the JSON itself, while option shuffling is handled client-side.", "body_md": "## \n  \n  \n  Who I Built It For\n\nMy friend is currently preparing for university exams and technical interviews (focusing on databases and C#). Reading dry documentation gets boring quickly, so I wanted to build an interactive, multiple-choice quiz partner that tests their knowledge on any given topic. Since it's for a student, it had to be completely free and accessible without internet restrictions.\n\n## \n  \n  \n  What I Built\n\nI built **StudyBuddy AI** — a lightweight, completely local web application that generates 3-question multiple-choice quizzes on any subject. \n\nGitHub Repository: [https://github.com/Shadow16Ua/StudyBuddy-AI](https://github.com/Shadow16Ua/StudyBuddy-AI)\n\n**The Tech Stack:**\n\n-  **AI Model:** Google's`gemma2:2b` running locally via Ollama.\n-  **Backend:** .NET 10 Minimal API (C#) to handle prompting and JSON parsing.\n-  **Frontend:** Pure HTML, CSS, and Vanilla JavaScript (with a sleek dark mode).\n\n### \n  \n  \n  📸 Demo\n\n## \n  \n  \n  Why Open Innovation Matters Here\n\nChoosing an open-weight model like Gemma 2B over a closed API (like OpenAI) was crucial for this project for three main reasons:\n\n1.  **Zero Cost & Privacy:** My friend can generate hundreds of quizzes without worrying about API limits, subscription fees, or sending their study data to a third-party server.\n2.  **100% Offline Capability:** It runs perfectly on a standard laptop CPU, meaning they can study during commutes or internet outages.\n3.  **The Engineering Challenge (Taming the 2B Model):** This was the most interesting part. I quickly realized that small 2B models struggle to output complex JSON arrays (like 3 questions at once). It would constantly hallucinate structures or merge answers. Because I had full control over the local inference, I was able to completely redesign the backend pipeline. Instead of asking for 3 questions in one prompt, my C# backend asynchronously asks Gemma for*one* question, exactly 3 times in a loop, and then manually constructs a bulletproof JSON array. This guarantees perfect UI rendering every single time. I also shifted the \"shuffle options\" logic to the frontend to prevent the AI from confusing correct/incorrect indexes.\n\nOpen source allowed me to iterate rapidly, observe the raw output locally, and engineer a robust wrapper around a lightweight model to make it perform like a much heavier one.\n\n*Note: I'm submitting this project for the Best Use of Gemma category as well!*", "url": "https://wpnews.pro/news/studybuddy-ai-taming-gemma-2b-to-build-a-local-quiz-generator-for-a-friend", "canonical_source": "https://dev.to/shadow16ua/studybuddy-ai-taming-gemma-2b-to-build-a-local-quiz-generator-for-a-friend-4mpo", "published_at": "2026-10-04 14:39:41+00:00", "updated_at": "2026-10-04 14:42:43.039694+00:00", "lang": "en", "topics": ["ai-tools", "large-language-models", "generative-ai", "ai-products", "developer-tools"], "entities": ["StudyBuddy AI", "Gemma 2B", "Google", "Ollama", ".NET 10", "C#"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/studybuddy-ai-taming-gemma-2b-to-build-a-local-quiz-generator-for-a-friend", "markdown": "https://wpnews.pro/news/studybuddy-ai-taming-gemma-2b-to-build-a-local-quiz-generator-for-a-friend.md", "text": "https://wpnews.pro/news/studybuddy-ai-taming-gemma-2b-to-build-a-local-quiz-generator-for-a-friend.txt", "jsonld": "https://wpnews.pro/news/studybuddy-ai-taming-gemma-2b-to-build-a-local-quiz-generator-for-a-friend.jsonld"}}