DEV Community

Cover image for Exploring HuggingFace and Building an AI Exam Question Generator
Kurt De Austria
Kurt De Austria

Posted on

Exploring HuggingFace and Building an AI Exam Question Generator

Hello there! I’m Kurt. Recently, I’ve been diving deep into the world of AI models. You’ve probably heard of HuggingFace—a powerful platform for AI enthusiasts and developers. Let me take you through my journey of experimenting with one of its AI models and how it led me to build something useful for educators: an AI Exam Question Generator.


What is HuggingFace?

HuggingFace is a treasure trove for anyone curious about AI. It offers:

  • 900k+ AI models
  • 200k+ datasets
  • 300k+ demo apps (Spaces)

All of this is open-source and ready to use, making collaboration in machine learning a breeze. These models cover a wide range of categories like Multimodal, Computer Vision, Natural Language Processing (NLP), and Audio.

But here’s the thing—reading about AI wasn’t enough for me. I wanted hands-on experience. So, I decided to test one of HuggingFace’s models.


My First Steps with HuggingFace

Setting up a project using HuggingFace was straightforward. Here’s a quick overview of the process:

  1. Create an Account: Sign up and navigate to the settings to generate an access token.
  2. Start a Node.js Project:

    npm init --y
    
  3. Install Required Packages:

    npm i @huggingface/inference dotenv
    
  4. Copy Sample Code: Paste a code snippet from the HuggingFace model page into your project.

    import { HfInference } from "@huggingface/inference"
    const client = new HfInference("YOUR_HF_TOKEN")
    
    let out = "";
    
    const stream = client.chatCompletionStream({
        model: "Qwen/QwQ-32B-Preview",
        messages: [
            { role: "system", content: "You are a helpful and harmless assistant. You are Qwen developed by Alibaba. You should think step-by-step." },
            { role: "user", content: "Tell me a story" }
        ],
        temperature: 0.5,
        max_tokens: 2048,
        top_p: 0.7
    });
    
    for await (const chunk of stream) {
        if (chunk.choices && chunk.choices.length > 0) {
            const newContent = chunk.choices[0].delta.content;
            out += newContent;
            console.log(newContent);
        }
    }
    
  5. Run the Code: See the magic unfold as the AI processes your input and generates outputs.

And just like that, I had the model up and running! But I wasn’t satisfied—I wanted to do more.


Finding the Problem to Solve

As a former part-time Computer Science professor, I often faced the challenge of creating test questions for exams. My friends who are teachers share the same struggle. Writing questions that align with Bloom’s Taxonomy is tedious and time-consuming.

If you’re not familiar, Bloom’s Taxonomy is a framework used in education to classify learning objectives by cognitive levels. It includes:

  1. Remembering: Basic recall and recognition
  2. Understanding: Comprehending information
  3. Applying: Using information in new situations
  4. Analyzing: Breaking information into parts
  5. Evaluating: Making judgments based on criteria
  6. Creating: Producing new or original work

Effective exams require a mix of these levels, not just basic recall questions. And that’s where I saw an opportunity for innovation.


Introducing Nexar: The AI Exam Question Generator

To address this problem, I developed Nexar, an AI-powered tool to generate exam questions. Here’s how it works:

  1. Set the Number of Questions: Decide how many items to generate. NumberQuestoins
  2. Choose a Starting Item Number: Useful for organizing questions.StartingNumber

  3. Select Question Type: Choose from Multiple-choice, Fill in the blanks, or True/False.QuestionType

  4. Select Difficulty Level: Based on Bloom’s Taxonomy.Dificulty

  5. Provide Content: Paste text from your modules or write a topic.

Content

Click "Generate" and watch as the AI creates questions tailored to your input. These questions align with Bloom’s framework, making exam preparation much easier! Here is the sample output

Result


How You Can Try It

Nexar is still a prototype, but it’s fully functional. If you’re a teacher, developer, or just someone curious about AI, I’d love for you to try it out. Your feedback will help me improve and take this tool to the next level.

👉 Try Nexar Now!


Building Nexar was a fun and fulfilling experience. It’s proof that AI can solve real-world problems creatively and efficiently. If you’ve got ideas or want to collaborate, let’s connect!

Top comments (0)